I’m curious about the behavior of opencl when I do something like this.
In my program, I have one opencl kernel, and I want to call it twice with different arguments. I use non-blocking read and write. My program looks somewhat like this.
0 int a = 1, b = 2;
1 clSetKernelArg(kernel, 0, sizeof(cl_mem), &clmem1);
2 clSetKernelArg(kernel, 1, sizeof(int), &a);
3 clEnqueueNDRangeKernel(queue,kernel,dimensions,0,workdim,NULL,0,NULL,NULL);
4 clFlush(queue);
5
6 clSetKernelArg(kernel, 0, sizeof(cl_mem), &clmem2);
7 clSetKernelArg(kernel, 1, sizeof(int), &b);
8 clEnqueueNDRangeKernel(queue,kernel,dimensions,0,workdim,NULL,0,NULL,NULL);
9 clFlush(queue);
Since I use clFlush, clSetKernelArg in line 6 and 7 might get called before the first kernel run (line 3) is actually executed. What will happen in that case? Will it still have the data of the old arguments and use that or will it use the new arguments?