Skip to content

[libclc] Move mem_fence and barrier to clc library #151446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wenju-he
Copy link
Contributor

__clc_mem_fence and __clc_barrier function have two parameters Scope and MemorySemantics, which are defined in SPIR-V spec. The design allows the clc functions to implement SPIR-V ControlBarrier and MemoryBarrier functions in the future.

The default memory ordering in clc is set to SequentiallyConsistent, which is also the default and strongest ordering in OpenCL and C++.

The default memory scope in clc is set to memory_scope_device for amdgcn and ptx-nvidiacl since __opencl_c_atomic_scope_all_devices feature macro is not defined for these targets.

llvm-diff shows no change to amdgcn--amdhsa.bc and nvptx64--nvidiacl.bc.

__clc_mem_fence and __clc_barrier function have two parameters Scope and
MemorySemantics, which are defined in SPIR-V spec. The design allows the
clc functions to implement SPIR-V ControlBarrier and MemoryBarrier
functions in the future.

The default memory ordering in clc is set to SequentiallyConsistent,
which is also the default and strongest ordering in OpenCL and C++.

The default memory scope in clc is set to memory_scope_device for amdgcn
and ptx-nvidiacl since __opencl_c_atomic_scope_all_devices feature macro
is not defined for these targets.

llvm-diff shows no change to amdgcn--amdhsa.bc and nvptx64--nvidiacl.bc.
@llvmbot llvmbot added the libclc libclc OpenCL library label Jul 31, 2025
@wenju-he wenju-he requested review from frasercrmck and arsenm July 31, 2025 04:13
#define __CLC_MEM_FENCE_CLC_MEM_SCOPE_SEMANTICS_H__

// Scope values are defined in SPIR-V spec.
typedef enum Scope {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should stick to OpenCL spec and terminology; I thought clang already had predefined enums for both of these

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libclc libclc OpenCL library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants