Is there any way of making a particular thread to wait for o


void example(__global int *a, __global int *dependency, uint cols)
    int j = genter code hereet_global_id(0);
    int i = get_global_id(1);
    if(i &gt; 0 && j &gt; 0)
	   test = 1;				
        //Wait for the dependents



In the above kernel code why the while loop is just skipped in all the threads with out infinitely looping. Any ideas on this.
I’m working on some interesting problem which requires a thread to wait for some other threads to finish based on some criteria but every time while of above or while(wait_condition) is skipped when it is being run on GPU.

Is there any other way of making a particular thread to wait for the other threads in OpenCL kernel on GPU?

Thanks in advance!

Please read up on the memory model of opencl c - it uses a relaxed memory model where for example memory accesses may be cached in registers.

You probably want to use barriers and local memory (although to be honest it’s impossible to tell from your example fragment what you’re even trying to accomplish), and/or maybe atomics.

They are well described in the opencl specification and the vendor programming guides.

One hint: you cannot synchronise outside of a workgroup: simply because the hardware may be incapable of running all work items concurrently, and so there is no way to talk to work items which haven’t started yet/have already finished.