I want to define a function inside a kernel function to make the indexing code more understandable:
kernel void do_something (const int some_offset, const int other_offset, global float* buffer) { int index(int x, int y) { return some_offset+other_offset*x+y; } float value = buffer[index(1,2)]; ... }
Otherwise, I will have to declare an index function outside my kernel and an index like
float value = buffer[index(1,2,some_offset,other_offset)];
which would make it more ugly, etc. Is there any way to do this? The compiler gives me an error saying:
OpenCL Compile Error: clBuildProgram failed (CL_BUILD_PROGRAM_FAILURE). Line 5: error: expected a ";"
Is it possible to do what I want, or is there another way to achieve the same? Thanks!
source share