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

>From 8aeee1114aa3c06f475040706535ba4ebacb70a0 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <[email protected]>
Date: Thu, 5 Mar 2026 12:41:52 +0100
Subject: [PATCH 1/4] 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 0baa2d49fab68adb0ee49adfd0b2c82a20a22982 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <[email protected]>
Date: Thu, 5 Mar 2026 14:27:29 +0100
Subject: [PATCH 2/4] 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 ccd5fd77ceaa685068003dd51dc8ca6683782966 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <[email protected]>
Date: Thu, 5 Mar 2026 14:28:30 +0100
Subject: [PATCH 3/4] 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) {

>From c6e2ff84bb916cb7f370eb8befe7e50945427259 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <[email protected]>
Date: Fri, 6 Mar 2026 00:03:33 +0100
Subject: [PATCH 4/4] __opencl_get_clang_memory_scope

---
 .../lib/generic/synchronization/work_group_barrier.cl      | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libclc/opencl/lib/generic/synchronization/work_group_barrier.cl 
b/libclc/opencl/lib/generic/synchronization/work_group_barrier.cl
index 5c7c375f3bfe4..14de313c4f582 100644
--- a/libclc/opencl/lib/generic/synchronization/work_group_barrier.cl
+++ b/libclc/opencl/lib/generic/synchronization/work_group_barrier.cl
@@ -6,14 +6,15 @@
 //
 
//===----------------------------------------------------------------------===//
 
-#include <clc/opencl/synchronization/utils.h>
-#include <clc/synchronization/clc_work_group_barrier.h>
+#include "clc/opencl/synchronization/utils.h"
+#include "clc/opencl/utils.h"
+#include "clc/synchronization/clc_work_group_barrier.h"
 
 _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(__opencl_get_memory_scope(scope), memory_order,
+  __clc_work_group_barrier(__opencl_get_clang_memory_scope(scope), 
memory_order,
                            memory_semantics);
 }
 

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

Reply via email to