openCl Multiple context ! is it possible ?

Hi again !

in my openCl i am using only one context for one device using

clCreateContext ()
, but my question is can i use multiple context or one device in the same application , if yes ! where i should use multiple context and when i should one context

and thank you .

but my question is can i use multiple context or one device in the same application , if yes ! where i should use multiple context and when i should one context

Yes, you can create multiple contexts for the same device on the same application. Typically it has no benefit; I recommend always using a single context.

The reason it is allowed to have multiple contexts is because, for example, the programmer that is writing an application may use OpenCL for certain operations. This application may also use some third-party library that also happens to use OpenCL internally to accelerate some algorithms. If we didn’t allow the same process to create multiple OpenCL contexts then this sort of scenario wouldn’t work.