Skip to content

Commit

Permalink
[#60][feat] Support barrier with memory scope parameter (#63)
Browse files Browse the repository at this point in the history
Co-authored-by: qinfan <[email protected]>
  • Loading branch information
wangqinfan and qinfan committed Nov 27, 2023
1 parent e5295c8 commit 6e7227a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/BuiltinsRISCV.def
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//===----------------------------------------------------------------------===//

// Barrier function builtins
TARGET_BUILTIN(barrier, "vi", "n", "32bit")
TARGET_BUILTIN(barrier, "vi.", "n", "32bit")
TARGET_BUILTIN(work_group_barrier, "vi.", "n", "32bit")
// WORKAROUND: Disabled for now.
/*
Expand Down
2 changes: 0 additions & 2 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19491,8 +19491,6 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID,

// Ventus GPGPU workitem
case RISCV::BIbarrier:
ID = Intrinsic::riscv_ventus_barrier;
break;
case RISCV::BIwork_group_barrier: {
unsigned NumArgs = E->getNumArgs();
switch (NumArgs) {
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Headers/opencl-c.h
Original file line number Diff line number Diff line change
Expand Up @@ -12397,6 +12397,7 @@ void __ovld vstorea_half16_rtn(double16, size_t, __private half *);
*/

void __ovld __conv barrier(cl_mem_fence_flags);
void __ovld __conv barrier(cl_mem_fence_flags, memory_scope);

#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
void __ovld __conv work_group_barrier(cl_mem_fence_flags, memory_scope);
Expand Down
12 changes: 12 additions & 0 deletions clang/test/CodeGenOpenCL/barrier.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: clang -no-opaque-pointers -triple riscv32-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s

void test() {
// CHECK: call void @llvm.riscv.ventus.barrier(i32 1)
// CHECK-NEXT: call void @llvm.riscv.ventus.barrier.with.scope(i32 1, i32 2)
// CHECK-NEXT: call void @llvm.riscv.ventus.barrier(i32 1)
// CHECK-NEXT: call void @llvm.riscv.ventus.barrier.with.scope(i32 1, i32 2)
barrier(1);
barrier(1, 2);
work_group_barrier(1);
work_group_barrier(1, 2);
}

0 comments on commit 6e7227a

Please sign in to comment.