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.

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.