[osg-users] osgCuda: Using CUDA in osg - Problem with Threading

Robert Osfield robert.osfield at gmail.com
Thu Mar 12 02:03:08 PDT 2009


HI Mick,

On Wed, Mar 11, 2009 at 9:24 PM, Mick <mick.svt at googlemail.com> wrote:
> Unfortunately these calls are all done by the main thread. All the allocated
> memory (by cudaMalloc) is bound to the thread which allocated it (in a
> multithreaded application this is the GraphicsThread). The CUDA API says
> explicitly that these resources cannot be used by another thread by the
> runtime API (which we use). Thus, we can only destruct the resources (by
> calling cudaFree) in the thread which created the resources.

It's sounds like the runtime API make a few too many "convenience"
choices in it's design, this might have been done for implementation
simplicity or API simplicity, it is still a bit crudy though...

I do hope OpenCL fairs a bit better in this respect.


> We are only familiar with the Runtime API of CUDA. This API does not allow
> any context management. We chose this API because it is very comfortable and
> allows us also to debug the graphics kernels.
> The second API, the Driver API, can do some kind of context handling. But it
> can only process precompiled kernels and it does not allow any debugging.

I'm curious, are you able to mix and match the Driver and Runtime API's?

>> ...clean up operations in GraphicsThread, or
>> release operations mechanism as you suggest might well be viable or
>> not too an intrusive change.
>>
>
>
> This would be perfect for our needs.

Do you want to dive in a make changes to your local
OpenSceneGraph/GraphicsThread classes get it working robustly for
osgCuda and then post me your changes.  It might be that this changes
will need some further evolution before they make it into svn/trunk,
but I won't know this till I see the extent and nature of them first
hand.

Cheers,
Robert.



More information about the osg-users mailing list