calling the same kernel object multiple times

But won’t this affect the kernel object, since the kernel arguments are associated with the kernel object.

If I do a



clSetKernelArg(kernel, 0, value1);
clEnqueueNDKernelRange(kernel,.....);


where I enqueue the kernel and immediately I do this , before this previous kernel enqueue command has even executed -



// immediately I change the kernel arg for the same kernel object to some other value and enqueue the kernel again
clSetKernelArg(kernel, 0, value2);
clEnqueueNDKernelRange(kernel,......);


won’t I end up changing the kernel arguments for this kernel object instance which was enqueued previously, which might lead to side effects? I am not sure what clSetKernelArg() and clSetEnqueueNDRangeKernel(), do at the background. If clSetKernelArg() and clEnqueueNDRangeKernel(), copy the kernel object and its arguments before returning, then the kernel objects’ arguments can be immediately modified to re-enqueue the same kernel object but with new arguments, even before the previous clEnqueueNDRangeKernel() command has finished execution.