[libclc] [libclc] Move prefetch to clc library (PR #141721)

Wenju He via cfe-commits cfe-commits at lists.llvm.org
Tue May 27 23:53:10 PDT 2025


https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/141721

llvm-diff shows no change to amdgcn--amdhsa.bc

>From 72d456f335d78b8ae7e1d25a0229e9f9f89a466b Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Tue, 27 May 2025 23:50:32 -0700
Subject: [PATCH] [libclc] Move prefetch to clc library

llvm-diff shows no change to amdgcn--amdhsa.bc
---
 libclc/clc/include/clc/async/clc_prefetch.h   | 18 ++++++++++++++++++
 libclc/clc/include/clc/async/clc_prefetch.inc | 10 ++++++++++
 libclc/clc/lib/generic/SOURCES                |  1 +
 libclc/clc/lib/generic/async/clc_prefetch.cl  | 16 ++++++++++++++++
 libclc/clc/lib/generic/async/clc_prefetch.inc | 10 ++++++++++
 libclc/opencl/lib/generic/async/prefetch.cl   |  1 +
 libclc/opencl/lib/generic/async/prefetch.inc  |  4 +++-
 7 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 libclc/clc/include/clc/async/clc_prefetch.h
 create mode 100644 libclc/clc/include/clc/async/clc_prefetch.inc
 create mode 100644 libclc/clc/lib/generic/async/clc_prefetch.cl
 create mode 100644 libclc/clc/lib/generic/async/clc_prefetch.inc

diff --git a/libclc/clc/include/clc/async/clc_prefetch.h b/libclc/clc/include/clc/async/clc_prefetch.h
new file mode 100644
index 0000000000000..a416d97fa0ae7
--- /dev/null
+++ b/libclc/clc/include/clc/async/clc_prefetch.h
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __CLC_ASYNC_CLC_PREFETCH_H__
+#define __CLC_ASYNC_CLC_PREFETCH_H__
+
+#define __CLC_BODY <clc/async/clc_prefetch.inc>
+#include <clc/integer/gentype.inc>
+
+#define __CLC_BODY <clc/async/clc_prefetch.inc>
+#include <clc/math/gentype.inc>
+
+#endif // __CLC_ASYNC_CLC_PREFETCH_H__
diff --git a/libclc/clc/include/clc/async/clc_prefetch.inc b/libclc/clc/include/clc/async/clc_prefetch.inc
new file mode 100644
index 0000000000000..178646efb9956
--- /dev/null
+++ b/libclc/clc/include/clc/async/clc_prefetch.inc
@@ -0,0 +1,10 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+_CLC_OVERLOAD _CLC_DECL void __clc_prefetch(const global __CLC_GENTYPE *p,
+                                            size_t num_gentypes);
diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES
index a8a906159e286..5dfff6d6023db 100644
--- a/libclc/clc/lib/generic/SOURCES
+++ b/libclc/clc/lib/generic/SOURCES
@@ -1,3 +1,4 @@
+async/clc_prefetch.cl
 common/clc_degrees.cl
 common/clc_radians.cl
 common/clc_sign.cl
diff --git a/libclc/clc/lib/generic/async/clc_prefetch.cl b/libclc/clc/lib/generic/async/clc_prefetch.cl
new file mode 100644
index 0000000000000..1b8da199eb4ad
--- /dev/null
+++ b/libclc/clc/lib/generic/async/clc_prefetch.cl
@@ -0,0 +1,16 @@
+//===----------------------------------------------------------------------===//
+//
+// 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/async/clc_prefetch.h>
+#include <clc/internal/clc.h>
+
+#define __CLC_BODY <clc_prefetch.inc>
+#include <clc/integer/gentype.inc>
+
+#define __CLC_BODY <clc_prefetch.inc>
+#include <clc/math/gentype.inc>
diff --git a/libclc/clc/lib/generic/async/clc_prefetch.inc b/libclc/clc/lib/generic/async/clc_prefetch.inc
new file mode 100644
index 0000000000000..a9c6b41a8ff6e
--- /dev/null
+++ b/libclc/clc/lib/generic/async/clc_prefetch.inc
@@ -0,0 +1,10 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+_CLC_OVERLOAD _CLC_DEF void __clc_prefetch(const global __CLC_GENTYPE *p,
+                                           size_t num_gentypes) {}
diff --git a/libclc/opencl/lib/generic/async/prefetch.cl b/libclc/opencl/lib/generic/async/prefetch.cl
index 7903550e89e41..50abbc5083428 100644
--- a/libclc/opencl/lib/generic/async/prefetch.cl
+++ b/libclc/opencl/lib/generic/async/prefetch.cl
@@ -6,6 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include <clc/async/clc_prefetch.h>
 #include <clc/opencl/clc.h>
 
 #define __CLC_BODY <prefetch.inc>
diff --git a/libclc/opencl/lib/generic/async/prefetch.inc b/libclc/opencl/lib/generic/async/prefetch.inc
index b952c532dc284..61be19bbfb34d 100644
--- a/libclc/opencl/lib/generic/async/prefetch.inc
+++ b/libclc/opencl/lib/generic/async/prefetch.inc
@@ -7,4 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 _CLC_OVERLOAD _CLC_DEF void prefetch(const global __CLC_GENTYPE *p,
-                                     size_t num_gentypes) {}
+                                     size_t num_gentypes) {
+  __clc_prefetch(p, num_gentypes);
+}



More information about the cfe-commits mailing list