<#part sign=pgpmime> Hi Eli, On Thu, 8 Mar 2012 09:33:21 -0800, "Eli Stevens (Gmail)" <wickedg...@gmail.com> wrote: > I was wondering if the following will work: > > - Main thread spins up thread B. > - Thread B creates a context, invokes a kernel, and creates an event. > - Event is saved. > - Thread B pops the context (kernel is still running at this point) > and finishes. > - Main thread join()s B and grabs the event. > - Main thread does other stuff and eventually calls .synchronize() > > Does that work? Or will trying to use an event after popping the > associated context (and from a different thread) cause problems? My > actual use case involves a thread C that's doing other things on a > second GPU. Maybe instead of an event, I should just have the threads > block and then use the join to indicate when the kernel is done? Any > advice appreciated. :)
This should work as well as it does in the underlying CUDA implementation. The problem is that there is always a question of what context is active where and there's an intricate dance that has to be performed of one thread having to release the context and another one grabbing it (as you describe). To me, this seems not worth the headache. OpenCL is cleaner in this respect, if that's an option for you. Failing that, keeping all CUDA objects associated with a context within a thread *will* make your life easier (especially with respect to garbage collection). If you can, processes make all of this even less brittle (and more concurrent). HTH, Andreas _______________________________________________ PyCUDA mailing list PyCUDA@tiker.net http://lists.tiker.net/listinfo/pycuda