https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/184780

>From 34d8d214fd531fa6f3e13094cf16fb1fd0da8eee Mon Sep 17 00:00:00 2001
From: Matt Arsenault <[email protected]>
Date: Thu, 5 Mar 2026 12:41:52 +0100
Subject: [PATCH 1/3] libclc: Define work_group_barrier

Previously only the old barrier name was implemented. Define this
as an indirection around the new name, and move it to common code.
The target implementations are already provided by __clc_work_group_barrier,
so targets were unnecessarily duplicating these.

This also fixes the default scope, which should be
memory_work_group_scope. Previously this was guessing that
if the flags included global memory, it makes the scope
device which is not the case.
---
 libclc/opencl/lib/amdgcn/SOURCES                |  1 -
 libclc/opencl/lib/generic/SOURCES               |  1 +
 .../lib/generic/async/wait_group_events.cl      |  2 +-
 .../synchronization/barrier.cl                  | 14 +++++++++++---
 libclc/opencl/lib/ptx-nvidiacl/SOURCES          |  1 -
 .../lib/ptx-nvidiacl/synchronization/barrier.cl | 17 -----------------
 6 files changed, 13 insertions(+), 23 deletions(-)
 rename libclc/opencl/lib/{amdgcn => generic}/synchronization/barrier.cl (63%)
 delete mode 100644 libclc/opencl/lib/ptx-nvidiacl/synchronization/barrier.cl

diff --git a/libclc/opencl/lib/amdgcn/SOURCES b/libclc/opencl/lib/amdgcn/SOURCES
index 0522e13f5d3db..84fc4a6650c32 100644
--- a/libclc/opencl/lib/amdgcn/SOURCES
+++ b/libclc/opencl/lib/amdgcn/SOURCES
@@ -1,5 +1,4 @@
 mem_fence/fence.cl
-synchronization/barrier.cl
 workitem/get_global_offset.cl
 workitem/get_group_id.cl
 workitem/get_global_size.cl
diff --git a/libclc/opencl/lib/generic/SOURCES 
b/libclc/opencl/lib/generic/SOURCES
index bb5e8ab08a711..084d74834611c 100644
--- a/libclc/opencl/lib/generic/SOURCES
+++ b/libclc/opencl/lib/generic/SOURCES
@@ -199,5 +199,6 @@ shared/max.cl
 shared/min.cl
 shared/vload.cl
 shared/vstore.cl
+synchronization/barrier.cl
 workitem/get_global_id.cl
 workitem/get_global_size.cl
diff --git a/libclc/opencl/lib/generic/async/wait_group_events.cl 
b/libclc/opencl/lib/generic/async/wait_group_events.cl
index 0881a74bd9047..76a9ee38bb89c 100644
--- a/libclc/opencl/lib/generic/async/wait_group_events.cl
+++ b/libclc/opencl/lib/generic/async/wait_group_events.cl
@@ -12,5 +12,5 @@ _CLC_DEF _CLC_OVERLOAD void wait_group_events(int num_events,
                                               event_t *event_list) {
   (void)num_events;
   (void)event_list;
-  barrier(CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE);
+  work_group_barrier(CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE);
 }
diff --git a/libclc/opencl/lib/amdgcn/synchronization/barrier.cl 
b/libclc/opencl/lib/generic/synchronization/barrier.cl
similarity index 63%
rename from libclc/opencl/lib/amdgcn/synchronization/barrier.cl
rename to libclc/opencl/lib/generic/synchronization/barrier.cl
index 9f67b6ebcb6db..e817bd43578b0 100644
--- a/libclc/opencl/lib/amdgcn/synchronization/barrier.cl
+++ b/libclc/opencl/lib/generic/synchronization/barrier.cl
@@ -9,9 +9,17 @@
 #include <clc/opencl/synchronization/utils.h>
 #include <clc/synchronization/clc_work_group_barrier.h>
 
-_CLC_DEF _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags) {
-  int memory_scope = __opencl_get_memory_scope(flags);
+_CLC_DEF _CLC_OVERLOAD void work_group_barrier(cl_mem_fence_flags flags,
+                                               memory_scope scope) {
   int memory_order = __ATOMIC_SEQ_CST;
   __CLC_MemorySemantics memory_semantics = 
__opencl_get_memory_semantics(flags);
-  __clc_work_group_barrier(memory_scope, memory_order, memory_semantics);
+  __clc_work_group_barrier(scope, memory_order, memory_semantics);
+}
+
+_CLC_DEF _CLC_OVERLOAD void work_group_barrier(cl_mem_fence_flags flags) {
+  work_group_barrier(flags, memory_scope_work_group);
+}
+
+_CLC_DEF _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags) {
+  work_group_barrier(flags);
 }
diff --git a/libclc/opencl/lib/ptx-nvidiacl/SOURCES 
b/libclc/opencl/lib/ptx-nvidiacl/SOURCES
index eb28570a617af..eb64360fece7a 100644
--- a/libclc/opencl/lib/ptx-nvidiacl/SOURCES
+++ b/libclc/opencl/lib/ptx-nvidiacl/SOURCES
@@ -1,5 +1,4 @@
 mem_fence/fence.cl
-synchronization/barrier.cl
 workitem/get_global_id.cl
 workitem/get_group_id.cl
 workitem/get_local_id.cl
diff --git a/libclc/opencl/lib/ptx-nvidiacl/synchronization/barrier.cl 
b/libclc/opencl/lib/ptx-nvidiacl/synchronization/barrier.cl
deleted file mode 100644
index 9f67b6ebcb6db..0000000000000
--- a/libclc/opencl/lib/ptx-nvidiacl/synchronization/barrier.cl
+++ /dev/null
@@ -1,17 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include <clc/opencl/synchronization/utils.h>
-#include <clc/synchronization/clc_work_group_barrier.h>
-
-_CLC_DEF _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags) {
-  int memory_scope = __opencl_get_memory_scope(flags);
-  int memory_order = __ATOMIC_SEQ_CST;
-  __CLC_MemorySemantics memory_semantics = 
__opencl_get_memory_semantics(flags);
-  __clc_work_group_barrier(memory_scope, memory_order, memory_semantics);
-}

>From cbfe2d354c0a5c732a9991d8df3f5374f6dc77d5 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <[email protected]>
Date: Thu, 5 Mar 2026 14:27:29 +0100
Subject: [PATCH 2/3] Rename file

---
 .../generic/synchronization/{barrier.cl => work_group_barrier.cl} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename libclc/opencl/lib/generic/synchronization/{barrier.cl => 
work_group_barrier.cl} (100%)

diff --git a/libclc/opencl/lib/generic/synchronization/barrier.cl 
b/libclc/opencl/lib/generic/synchronization/work_group_barrier.cl
similarity index 100%
rename from libclc/opencl/lib/generic/synchronization/barrier.cl
rename to libclc/opencl/lib/generic/synchronization/work_group_barrier.cl

>From fb1121334150668d46551390e227b33089d43a54 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <[email protected]>
Date: Thu, 5 Mar 2026 14:28:30 +0100
Subject: [PATCH 3/3] Use __opencl_get_clang_memory_scope

---
 libclc/opencl/lib/generic/SOURCES                              | 2 +-
 .../opencl/lib/generic/synchronization/work_group_barrier.cl   | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libclc/opencl/lib/generic/SOURCES 
b/libclc/opencl/lib/generic/SOURCES
index 084d74834611c..df84731f059f5 100644
--- a/libclc/opencl/lib/generic/SOURCES
+++ b/libclc/opencl/lib/generic/SOURCES
@@ -199,6 +199,6 @@ shared/max.cl
 shared/min.cl
 shared/vload.cl
 shared/vstore.cl
-synchronization/barrier.cl
+synchronization/work_group_barrier.cl
 workitem/get_global_id.cl
 workitem/get_global_size.cl
diff --git a/libclc/opencl/lib/generic/synchronization/work_group_barrier.cl 
b/libclc/opencl/lib/generic/synchronization/work_group_barrier.cl
index e817bd43578b0..5c7c375f3bfe4 100644
--- a/libclc/opencl/lib/generic/synchronization/work_group_barrier.cl
+++ b/libclc/opencl/lib/generic/synchronization/work_group_barrier.cl
@@ -13,7 +13,8 @@ _CLC_DEF _CLC_OVERLOAD void 
work_group_barrier(cl_mem_fence_flags flags,
                                                memory_scope scope) {
   int memory_order = __ATOMIC_SEQ_CST;
   __CLC_MemorySemantics memory_semantics = 
__opencl_get_memory_semantics(flags);
-  __clc_work_group_barrier(scope, memory_order, memory_semantics);
+  __clc_work_group_barrier(__opencl_get_memory_scope(scope), memory_order,
+                           memory_semantics);
 }
 
 _CLC_DEF _CLC_OVERLOAD void work_group_barrier(cl_mem_fence_flags flags) {

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to