Results 1 to 9 of 9

Thread: Array of pointers in device memory

  1. #1
    Junior Member
    Join Date
    Mar 2009
    Posts
    12

    Array of pointers in device memory

    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?

  2. #2
    Senior Member
    Join Date
    Sep 2002
    Location
    Santa Clara
    Posts
    105

    Re: Array of pointers in device memory

    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

  3. #3
    Junior Member
    Join Date
    Mar 2009
    Posts
    12

    Re: Array of pointers in device memory

    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?

  4. #4
    Junior Member
    Join Date
    Jun 2009
    Posts
    1

    Re: Array of pointers in device memory

    I'm new to this and a bit confused.

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

  5. #5
    Junior Member
    Join Date
    Mar 2009
    Posts
    12

    Re: Array of pointers in device memory

    Not just array of pointers.... Even true heterogeneous computing (simultaneously harnessing CPU and GPU power) is NOT possible with this spec.

  6. #6
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: Array of pointers in device memory

    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.)

  7. #7
    Junior Member
    Join Date
    Mar 2009
    Posts
    12

    Re: Array of pointers in device memory

    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

  8. #8
    Junior Member
    Join Date
    Aug 2009
    Posts
    2

    Re: Array of pointers in device memory

    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.)

  9. #9
    Senior Member
    Join Date
    Sep 2002
    Location
    Santa Clara
    Posts
    105

    Re: Array of pointers in device memory

    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.

Similar Threads

  1. copying a variable from host memory to device memory
    By shahsaurabh1990 in forum OpenCL
    Replies: 4
    Last Post: 03-26-2013, 01:10 AM
  2. Replies: 2
    Last Post: 10-28-2009, 07:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •