[libclc] libclc: Move get_global_id into clc (PR #185180)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 7 04:33:28 PST 2026


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

>From 241e7f2d8e8b43524148c1b871e646460128fa97 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Sat, 7 Mar 2026 13:01:51 +0100
Subject: [PATCH] libclc: Move get_global_id into clc

---
 libclc/clc/lib/generic/SOURCES                  |  1 +
 .../lib/generic/workitem/clc_get_global_id.cl   | 17 +++++++++++++++++
 .../lib/generic/workitem/get_global_id.cl       |  5 ++---
 3 files changed, 20 insertions(+), 3 deletions(-)
 create mode 100644 libclc/clc/lib/generic/workitem/clc_get_global_id.cl

diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES
index b352382fbe6d9..926efe9c6f188 100644
--- a/libclc/clc/lib/generic/SOURCES
+++ b/libclc/clc/lib/generic/SOURCES
@@ -176,6 +176,7 @@ shared/clc_min.cl
 shared/clc_qualifier.cl
 shared/clc_vload.cl
 shared/clc_vstore.cl
+workitem/clc_get_global_id.cl
 workitem/clc_get_global_linear_id.cl
 workitem/clc_get_local_linear_id.cl
 workitem/clc_get_num_sub_groups.cl
diff --git a/libclc/clc/lib/generic/workitem/clc_get_global_id.cl b/libclc/clc/lib/generic/workitem/clc_get_global_id.cl
new file mode 100644
index 0000000000000..515ef7a173f25
--- /dev/null
+++ b/libclc/clc/lib/generic/workitem/clc_get_global_id.cl
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// 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/workitem/clc_get_global_offset.h>
+#include <clc/workitem/clc_get_group_id.h>
+#include <clc/workitem/clc_get_local_id.h>
+#include <clc/workitem/clc_get_local_size.h>
+
+_CLC_OVERLOAD _CLC_DEF size_t __clc_get_global_id(uint dim) {
+  return __clc_get_group_id(dim) * __clc_get_local_size(dim) +
+         __clc_get_local_id(dim) + __clc_get_global_offset(dim);
+}
diff --git a/libclc/opencl/lib/generic/workitem/get_global_id.cl b/libclc/opencl/lib/generic/workitem/get_global_id.cl
index f56981975acd3..d134dfc3f8d72 100644
--- a/libclc/opencl/lib/generic/workitem/get_global_id.cl
+++ b/libclc/opencl/lib/generic/workitem/get_global_id.cl
@@ -6,9 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <clc/opencl/opencl-base.h>
+#include <clc/workitem/clc_get_global_id.h>
 
 _CLC_DEF _CLC_OVERLOAD size_t get_global_id(uint dim) {
-  return get_group_id(dim) * get_local_size(dim) + get_local_id(dim) +
-         get_global_offset(dim);
+  return __clc_get_global_id(dim);
 }



More information about the cfe-commits mailing list