0
votes

I am porting existing Reed-Solomon decoding code to OpenCL There are some local arrays in my kernel, like uint myarray[256]; in local functions. And I have quite a number of memset functions over them and I've failed to use them. I can just write filling them in a loop, but that might be inefficient. Also, some suggestions about writing such a loop are welcome too, cause seems OpenCL just don't have memset.

But OpenCL complains about missing memset the way it seems not being missing it entirely

warning: implicitly declaring C library function 'memset' with type 'void *(void *, int, unsigned long)'

and suggests to include <string.h> but fails to find it

fatal error: <string.h> file not found.

1
Please post a minimal, complete and verifiable example (mcve) - Mohamad Elghawi
Well, take the simpliest OpenCL example from the OpenCL SDK and write something like uint myarray[256]; memset(myarray, 0, 100); at, say, the beginning of the kernel source. - Morgun Dmytro
did you #include <string.h> in your code? - Gilles
Yes, I've tried that and wrote what error it produces (file not found). Are there standard headers for OpenCL and how do I include them? Hmm, I've not googled this that way... - Morgun Dmytro
Thanks! I'll stick to loop filling then. This is actually the answer =\ - Morgun Dmytro

1 Answers

1
votes

There is no memset (nor any of the rest of the C standard library) available in OpenCL device code, so you'll need to either loop manually (possibly with a #pragma unroll hint) or, if the array is actually local in the OpenCL sense (i.e. shared between work-items in a work-group) have each work-item clear one of the elements (which is considerably more efficient).