PDA

View Full Version : Why is 'cl_mem' associated to 'cl_context'?



tanakamura
08-27-2009, 11:25 PM
Hi,

'clContextCreate' takes multiple devices. 'cl_context' is associated to multiple devices.
And, 'clCreateBuffer' takes single context object.

So, 'cl_mem' is associated to multiple devices.
On platform that has multiple GPUs that have different memory size,
size of allocatable memory is limited to most small device.

It seems strange. I think that 'cl_mem' should be associated to single device.

Why is cl_mem associated to cl_context?

PaulS
09-09-2009, 02:18 AM
My guess would be (and I'm still getting my head around things) is that when you enqueue a task, it could be run on any device in that context. Therefore any memory objects that the task requires must be able to be supported by any device in that context. Hence the maximum allocatable is that of the device with the lowest capability the largest that's globally supported.

If the memory object was linked to a device, then the choice of devices would be limited to the ones that had the relevant memory objects attached. That's a rather late point to discover that a task cannot be run.

If you want a memory object larger than some of the devices can support, then you need to create a context with those devices excluded.

tanakamura
09-16-2009, 03:29 AM
Thanks, I see.