1

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; ^~~~

  • 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_buffer`s – Quimby Jun 23 '19 at 20:15
  • @Quimby so my only choice would be using another array that contains the string length and a char* array? someone said that SVM allow allocating buffers with pointers https://stackoverflow.com/a/26144016/11493865 so either way with SVM i would need another array with the string length? –  Jun 23 '19 at 20:39
  • 1
    For SVM you have to work with at least OpenCL 2.0 - do you have it? – HEKTO Jul 04 '19 at 03:54
  • @HEKTO yes but if I need spir for anything dont count on it since AMD dropped the support only can use Opencl 2.0 from APP SDK also checked and it seems that it support unsigned long long but only to assign one variable to other if I did some operation arithmetic operation between 2 pointers clang(AMD's opencl compiler) throws an error –  Jul 05 '19 at 04:07

1 Answers1

0

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