Dnia 2011-02-11, piÄ… o godzinie 18:19 -0500, Andreas Kloeckner pisze: > Hi Tomasz, > > On Wed, 09 Feb 2011 22:00:22 +0100, Tomasz Rybak <bogom...@post.pl> 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 >
Added to the FAQ, also decided to add to documentation; see attached diff. -- Tomasz Rybak <bogom...@post.pl> GPG/PGP key ID: 2AD5 9860 Fingerprint A481 824E 7DD3 9C0E C40A 488E C654 FB33 2AD5 9860 http://member.acm.org/~tomaszrybak
diff --git a/doc/source/util.rst b/doc/source/util.rst index b8252dd..4cb64a8 100644 --- a/doc/source/util.rst +++ b/doc/source/util.rst @@ -10,6 +10,16 @@ The module :mod:`pycuda.autoinit`, when imported, automatically performs all the steps necessary to get CUDA ready for submission of compute kernels. It uses :func:`pycuda.tools.make_default_context` to create a compute context. +.. warning :: + + Although it is possible to use CUDA profiler with PyCUDA, it will not + work correctly if :mod:`pycuda.autoinit` is used. In such a case CUDA + profiler will not save all events to the log file. One needs to manually + manage PyCUDA context for CUDA profiler to save all data to log files. + Context needs to be detached for CUDA to save all performance-related + events to the log file. See :class:`pycuda.driver.Context` and + :meth:`pycuda.driver.Context.pop` and :meth:`pycuda.driver.Context.detach`. + .. data:: device An instance of :class:`pycuda.driver.Device` that was used for automatic
signature.asc
Description: This is a digitally signed message part
_______________________________________________ PyCUDA mailing list PyCUDA@tiker.net http://lists.tiker.net/listinfo/pycuda