Reputation: 41
Does anybody know, is it possible to share opencl memory objects between different contexts the way opengl does it?
I want to pass to kernel two memory objects belonging to different contexts...
Upvotes: 4
Views: 1824
Reputation: 155
I don't know if this would work, but if, as Klee1 says, that bit isn't possible, I might try this:
1) create each of your two CL contexts from a single GL context with sharing enabled, one memory object for each CL context.
2) use GL to do a framebuffer blit between the two when you want to move data between the two.
... this would keep the data within the GPU and save you lots of time vs. copying it both ways across the PCI-E bus....
Upvotes: 2
Reputation: 6178
I don't think that this is possible to do directly with OpenCL. This is because of the way contexts, queues, and memory are defined in OpenCL. If you pass memory from two different contexts, then it is very likely that the data is on two different devices and we wouldn't know which device to perform the computation on.
If you would like to perform this type of computation, you would first have to copy the data from one context to the other. This can be done as so:
If instead you have two buffers in different command queues (under the same context), they can be shared as specified in Section A.1 of the OpenCL 1.2 specification.
Upvotes: 0