PDA

View Full Version : multiple contexts and devices



brdavs
01-24-2013, 10:19 AM
I have questions regarding contexts and multiple devices.

Multiple devices can be attached to a single context.

My questions are:
1. If you have multiple devices (say 1 CPU and 2 GPU),
when do you want share a context between devices?
Or is it always better to have 1 device per context?

2. Is there a good example of transferring buffers
between different contexts?

Thanks.

matthiasv
01-24-2013, 02:02 PM
My questions are:
1. If you have multiple devices (say 1 CPU and 2 GPU),
when do you want share a context between devices?
Or is it always better to have 1 device per context?
In most cases, you want one context that spans all devices. First, memory is transparently transferred between devices in the same context. Second, an event is only valid in a context where it was created, so synchronization is much simpler than if you have to do it manually for two contexts.


2. Is there a good example of transferring buffers
between different contexts?
Well, transfer from the device in context 1 to host via clEnqueueReadBuffer and then copy it into the other buffer that is used by device in context 2 via clEnqueueWriteBuffer.