PDA

View Full Version : Array of pointers in device memory



Sarnath
06-02-2009, 11:59 PM
Just wondering,

How do I go about creating a cl_mem object which appears as an array of pointers to the kernel?

I understand that a "cl_mem" argument appears as a "pointer" argument in the kernel...

What if this cl_mem object contains an array of cl_mem objects??? Will it appear as array of pointers to the kernel?

How do I go about this?

affie
06-03-2009, 11:08 AM
In OpenCL 1.0, a cl_mem object cannot contain cl_mem objects. So a pointer to pointers cannot be passed as an argument to a kernel. T

Sarnath
06-03-2009, 09:58 PM
Thanks for the answer.

Well, Is there a reason why you mention "1.0"?

Is there any consideration for array of pointers?

People often need to copy complex data-structures on to GPUs or other HPC devices. Wondering, why OpenCL is not considerate about these requirements?

martman
06-18-2009, 11:17 PM
I'm new to this and a bit confused.

Does this mean we cant pass multi-dimensional arrays to the GPU?

Sarnath
06-19-2009, 05:47 AM
Not just array of pointers.... Even true heterogeneous computing (simultaneously harnessing CPU and GPU power) is NOT possible with this spec.

dbs2
07-21-2009, 01:19 PM
You can absolutely pass multi-dimensional arrays to kernels. When you pass in a buffer, it is just a bunch of data that you can use however you want inside the kernel. What you can not do is pass in an array of cl_mem objects (buffers or images).

With regards to "true" heterogeneous computation, the OpenCL spec allows you to execute kernels on any supported device in your system. So this is "true" heterogeneous computation, but it is not, is "automatic" heterogeneous computation. (E.g., the developer will still have to determine how to split the work across the supported devices, but OpenCL will allow them to all be used together.)

Sarnath
07-21-2009, 11:27 PM
You can absolutely pass multi-dimensional arrays to kernels. When you pass in a buffer, it is just a bunch of data that you can use however you want inside the kernel. What you can not do is pass in an array of cl_mem objects (buffers or images).


I think I differ here. CL_MEM can hold data... that is uni-dimensional. In CUDA, I could technically create an "int **a" on the device.... So, "a" points to an array of pointers each of which point to an array of integers... I cant replicate that with OpenCL.

But arrays like int "a[100][100]" can be replicated once we know if it is row_major or column_major.



With regards to "true" heterogeneous computation, the OpenCL spec allows you to execute kernels on any supported device in your system


Not really. The spec does NOT spell out the Platform layer. Each vendor comes out with his own version of clFindDevices and so on....

Therez no device manager layer outlined by the spec at all. Thus true heterogeneous computing is still out of reach.

Best REgards,
Sarnath

dhilvert
08-17-2009, 02:18 PM
Just to clarify, is it allowable under the 1.0 standard that separate kernel executions passed the same cl_mem object may provide to the kernel different pointer values for this object? The spec does not seem to explicitly specify one way or the other.

(If the pointer values passed for cl_mem objects were guaranteed to always be the same, then it should be possible to arrange for pointer-based data structures to persist between kernel calls.)

affie
08-17-2009, 08:55 PM
It is certainly possible that separate kernel executions passed the same cl_mem object may result in different pointer values for this memory object in the kernel. Consider for example if memory usage results in memory objects being punted from the device's memory. In this case, there is no guarantee that the cl_mem object will be the same pointer value across multiple kernel executions.