Description

The memory fence functions described in this sub-section are deprecated by OpenCL C 2.0.

The OpenCL C programming language implements the following explicit memory fence functions to provide ordering between memory operations of a work-item.

Table 1. Built-in Explicit Memory Fence Functions
Function Description

void mem_fence(
cl_mem_fence_flags flags)

Orders loads and stores of a work-item executing a kernel. This means that loads and stores preceding the mem_fence will be committed to memory before any loads and stores following the mem_fence.

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

CLK_LOCAL_MEM_FENCE
CLK_GLOBAL_MEM_FENCE

The value of flags must be the same for all work-items in the work-group.

void read_mem_fence(
cl_mem_fence_flags flags)

Read memory barrier that orders only loads.

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

CLK_LOCAL_MEM_FENCE
CLK_GLOBAL_MEM_FENCE

The value of flags must be the same for all work-items in the work-group.

void write_mem_fence(
cl_mem_fence_flags flags)

Write memory barrier that orders only stores.

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

CLK_LOCAL_MEM_FENCE
CLK_GLOBAL_MEM_FENCE

The value of flags must be the same for all work-items in the work-group.

See Also

No cross-references are available

Document Notes

For more information, see the OpenCL C Specification

This page is extracted from the OpenCL C Specification. Fixes and changes should be made to the Specification, not directly.

Copyright 2014-2023 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0