logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

barrier - All work-items in a work-group executing the kernel on a processor must execute this function

Authors

TheKhronosGroup

Description

       All work-items in a work-group executing the kernel on a processor must execute this function before any
       are allowed to continue execution beyond the barrier. This function must be encountered by all work-items
       in a work-group executing the kernel.

       If barrier is inside a conditional statement, then all work-items must enter the conditional if any
       work-item enters the conditional statement and executes the barrier.

       If barrier is inside a loop, all work-items must execute the barrier for each iteration of the loop
       before any are allowed to continue execution beyond the barrier.

       The barrier function also queues a memory fence (reads and writes) to ensure correct ordering of memory
       operations to local or global memory.

       The flags argument specifies the memory address space and can be set to a combination of the following
       literal values.

       CLK_LOCAL_MEM_FENCE - The barrier function will either flush any variables stored in local memory or
       queue a memory fence to ensure correct ordering of memory operations to local memory.

       CLK_GLOBAL_MEM_FENCE - The barrier function will queue a memory fence to ensure correct ordering of
       memory operations to global memory. This can be useful when work-items, for example, write to buffer or
       image objects and then want to read the updated data.

Name

       barrier - All work-items in a work-group executing the kernel on a processor must execute this function
       before any are allowed to continue execution beyond the barrier.

       voidbarrier(cl_mem_fence_flagsflags);

Notes

        1. OpenCL Specification
           page 274, section 6.12.8 - Synchronization Functions

The Khronos Group                                  11/18/2024                                      BARRIER(3clc)

Specification

OpenCLSpecification[1]

See Also