zhensydow/opencl — Issue #22: clSetKernelArg cannot specify size of local memory arrays
Author: radarsat1
Created: 2012-01-11 16:20:04+00:00
State: open

I asked on [stack overflow](http://stackoverflow.com/questions/8813201/how-can-i-use-clsetkernelarg-to-set-local-memory-size-in-an-opencl-haskell-progr) how to use `clSetKernelArg` with locals but someone suggested I report it as a bug instead. It seems impossible to use the exported `clSetKernelArg` function to specify local arrays. I really like that it determines the size and pointer for the given `Storable` automatically, but unfortunately this doesn't work for the intended usage with locals, where you are supposed to specify the size along with a null-pointer. Passing `nullPtr` does not work, since there is no way to specify the size.

Possibly suggestion: don't wrap `clSetKernelArg` with `sizeOf` and `with`, instead make the user do it. Perhaps provide a higher-level function doing this automatically, with a different name like `clSetKernelArgStorable`.

Alternative suggestion: additionally provide `clSetKernelArgLocal` specifically for using with locals.

I like the second suggestion better, but the first suggestion is more in keeping with the original OpenCL API, so I'm not sure which idea is best.