Hi Tomasz,

On Wed, 09 Feb 2011 22:00:22 +0100, Tomasz Rybak <[email protected]> wrote:
> Recently I have been playing with profiler and logger in CUDA.
> Detailed description is in
> http://wiki.tiker.net/ToolCheatSheet
> and
> http://wiki.tiker.net/ToolCheatSheet?action=AttachFile&do=view&target=compute-profiler-manual.txt
> 
> Basically I have set environment variable
> COMPUTE_PROFILE to 1 and run PyCUDA programs.
> I have observed that logger does not put every function
> call into text files. I have also observed that test cases
> (functions decorated by pycuda.tools.mark_cuda_test)
> were generating full logs. The only difference I have
> found was calling context.detach() in mark_cuda_test.
> 
> I have then experimented a little bit and observed
> that indeed when I was not using pycuda.autotools but
> instead created context manually and then popped
> _and detached_ it full log was generated.
> 
> I am attaching patch that adds ctx.detach to functions
> called at exit of program in pycuda.autoinit.
> I have tested PyCUDA with this patch, and all programs
> from test/* run without problems.
> 
> I am also attaching two logs from examples/demo.py.
> One is result of using autoinit with detach, one without.
> As you can see the latter misses some of the functions
> like (2*gpuarray).get() (axpb kernel).
> 
> So Andreas, please apply this patch before finalising 2011.1.

I see the need, but unfortunately your fix would introduce incorrect
semantics. The problem is that by the time atexit is called, references
to objects within that context may still be held. If we pop the context
(but leave it alive), those objects can be destroyed without an issue
once the garbage collector gets around to them. If we detach, then the
context is gone [1], and any cleanup will fail, spewing warnings at the
user.

Until we decide what to do, can you please add an FAQ?

http://wiki.tiker.net/PyCuda/FrequentlyAskedQuestions

[1] 
http://developer.download.nvidia.com/compute/cuda/3_2/toolkit/docs/online/group__CUDA__CTX_g3136efc315abd4c4455e875b9dbb65a1.html#g3136efc315abd4c4455e875b9dbb65a1

Andreas

Attachment: pgpF4JJYLZLLl.pgp
Description: PGP signature

_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda

Reply via email to