Results 1 to 2 of 2

Thread: Suggestion: Querying memory object alignment

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    10

    Suggestion: Querying memory object alignment

    I am writing a library. I have multiple versions of the kernel depending on the alignment. The library API receives a buffer (as a cl_mem) and depending on whether or not it is aligned to (say) float4, I select the applicable kernel.

    However, the problem is, there appears to be no standard way to know if the buffer I am getting is appropriately aligned. For now, I have pushed this responsibility to the user of the library by forcing them to select the appropriate version. But this is not an ideal solution.

    Would definitely like a clean approach to query the alignment info of buffer objects.

  2. #2
    Senior Member
    Join Date
    Aug 2011
    Posts
    271

    Re: Suggestion: Querying memory object alignment

    Quote Originally Posted by codedivine
    I am writing a library. I have multiple versions of the kernel depending on the alignment. The library API receives a buffer (as a cl_mem) and depending on whether or not it is aligned to (say) float4, I select the applicable kernel.

    However, the problem is, there appears to be no standard way to know if the buffer I am getting is appropriately aligned. For now, I have pushed this responsibility to the user of the library by forcing them to select the appropriate version. But this is not an ideal solution.

    Would definitely like a clean approach to query the alignment info of buffer objects.
    Kernels are all executed with alignment determined wholly by the implementation, you do not have any control over it at all. The implementation will ensure the data is aligned appropriately for the kernel which normally involves copying memory around if necessary on a cpu-based implementation. On a GPU memory is always aligned to some efficient value.

    I'm not sure exactly how you're even testing this: once you call putWriteBuffer(), or putMapBuffer() the alignment is out of your hands.

Similar Threads

  1. memory alignment for struct members
    By fangq in forum OpenCL
    Replies: 4
    Last Post: 04-12-2011, 02:00 PM
  2. Global memory alignment
    By guy.brush in forum OpenCL
    Replies: 1
    Last Post: 04-22-2010, 04:55 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
  •