c++kernelopenclgpgpuopencl-c

How could I use a vector<char**> buffer on opencl c kernel or set a SVM with this vector?


I am trying to allocate a vector (array of strings) to store 2 or more char(bytes) but the OpenCL kernel's compiler(clang) throw the following error kernel parameter cannot be declared as a pointer to a pointer when declaring a char** compressedBytes array

kernel: https://gist.github.com/PontiacGTX/0f0897ac1eaf93cb04a5c1e3c205dc4b

host: https://gist.github.com/PontiacGTX/745b4942acab0c7213dee1fede6a8e35

the kernel compiler errors are:

Failed Creating kernel 1

C:\Users\PONTIA~1\AppData\Local\Temp\OCL4936T1.cl:31:111: error: kernel parameter cannot be declared as a pointer to a pointer __kernel void CopyBytes(__global unsigned char const* fileBytes,unsigned long length,__global unsigned char** compressedBytes, __global unsigned long* arrayCountCompressedBytes) ^

C:\Users\PONTIA~1\AppData\Local\Temp\OCL4936T1.cl:40:16: warning: incompatible integer to pointer conversion initializing 'const __generic char ' with an expression of type 'int' const char str=fileBytes[i] + fileBytes[i+1]; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

C:\Users\PONTIA~1\AppData\Local\Temp\OCL4936T1.cl:41:9: warning: incompatible pointer types passing '__global unsigned char *__generic *' to parameter of type 'const __global char *__generic *' Find(compressedBytes,size,str,found); ^~~~~~~~~~~~~~~

C:\Users\PONTIA~1\AppData\Local\Temp\OCL4936T1.cl:10:33: note: passing argument to parameter 'begin' here void Find(__global const char** begin,unsigned long length, const char* val,int found) ^

C:\Users\PONTIA~1\AppData\Local\Temp\OCL4936T1.cl:45:23: error: assigning 'const __generic char *' to '__global unsigned char *__generic' changes address space of pointer compressedBytes[i]=str; ^~~~


Solution

  • OpenCL doesn't support pointers to random memory inside the kernel. So no pointers of pointers, all you have linear chunks of memory in the form of cl_buffers – Quimby