saint_shark
saint_shark

Reputation: 17

How to pass the openCL context between different cpu pthreads?

Cuda has cuCtxPopCurrent() and cuCtxPushCurrent() for popping cuda context from the pthread that created it and push it another pthread that wants to use it.

By default, that CUDA context can be accessed only from the CPU thread that created it. If you want to access the CUDA context from other threads, you have to call cuCtxPopCurrent() to pop it from the thread that created it. The context then can be pushed onto any other CPU thread's current context stack, and subsequent CUDA calls would reference that context.

I could not find something similar for openCL.

Upvotes: 0

Views: 383

Answers (1)

Elad Maimoni
Elad Maimoni

Reputation: 4575

OpenCL contexts and command queues have no thread association. There is no such thing as 'current context' for a thread. You have to explicitly supply the context / queue handle to each API call.

Also, There is no special issue in accessing an OpenCL context or command queue from multiple threads. They are thread safe.

Upvotes: 4

Related Questions