0

I have a question about OpenCL the example listed in the following link :

OpenCL vector addition program

I replaced one old line with one new - actually reading strings as elements of array of pointers as stated in documentation.

const cl_uint NumberOfStrings = 1;  // Works ONLY FOR just one string

const char* sourcearr[] = { source_str1 , source_str2, source_str3 };   // array pointers to strings
const size_t   sourcesizearr[] = { source_size1 , source_size2, source_size3}; // pointers to string sizes

// new 
cl_program program = clCreateProgramWithSource(context, NumberOfStrings , (const char**)&sourcearr, (const size_t*)&sourcesizearr, &ret);

// old
//  cl_program program = clCreateProgramWithSource(context, 1 , (const char**)&source_str, (const size_t*)&source_size, &ret);

All is working for just one string. If I put the value of NumberOfStrings > 1 I get a bunch of zeroes again.

I do not understand what happens. I was not albe to find an example of reading more that one string into memory. It is always 1.

  • Have you seen these questions/answers? https://stackoverflow.com/a/31760184/48660 https://stackoverflow.com/q/55103811/48660 https://stackoverflow.com/a/59993026/48660 These seem very close to what you're asking. It basically comes down to the fact that C strings are pointers, so you'll need to arrange for them all to be located in the same OpenCL buffer. Perhaps think about what your kernel code would look like. (I can go into detail if there's anything not already covered in those other answers, in which case please update your question.) – pmdj Jul 15 '20 at 13:00
  • Thank you. I did see those answers but no help here. – Dragan Popovic Jul 16 '20 at 10:48

0 Answers0