Sync across work groups

Hello

I have written OpenCL kernel in which there are no work groups, only single work items in a 2D range. There are two read/write operations in kernel and I need a function like barrier/mem_fence that ensures that all work items read updated values after that sync function. In particular

work-items writing to global memory;
sync();
work-items reading updated values from global memory;

I see that barrier() and mem_fence() functions only gives this syncronization within work groups, but since I dont have work groups but only single work items, how can I achieve this synconization? or should I have to make two kernels first writing and second reading from that same global memory ?

I see that barrier() and mem_fence() functions only gives this syncronization within work groups, but since I dont have work groups but only single work items, how can I achieve this synconization?

Work-items are always executed in work-groups. If you don’t specify a work-group size when you call clEnqueueNDRangeKernel() then the OpenCL driver will pick a work-group size for you.

Whether using a work-group barrier is going to be enough or whether you will need to enqueue two different NDRanges depends on what your kernel is doing. If the work-items are only going to read data that was written by other work-items in the same work-group then a work-group barrier is enough. If work-items from one work-group need to read data that was written by other work-groups then you will need to enqueue two NDRanges.

Aha ok thank you so much…