[Openmp-commits] [openmp] [OpenMP] Remove declaration and usage of __AMDGCN_WAVEFRONT_SIZE (PR #143761)

via Openmp-commits openmp-commits at lists.llvm.org
Wed Jun 11 11:04:31 PDT 2025


https://github.com/nicebert created https://github.com/llvm/llvm-project/pull/143761

Removes usage of __AMDGCN_WAVEFRONT_SIZE as compile time constant.

>From 577fb9b7a9691dd8f1f92f5f6c907751ce07c8ef Mon Sep 17 00:00:00 2001
From: Nicole Aschenbrenner <nicole.aschenbrenner at amd.com>
Date: Wed, 11 Jun 2025 14:01:39 -0400
Subject: [PATCH] [OpenMP] Remove declaration and usage of
 __AMDGCN_WAVEFRONT_SIZE

Removes usage of __AMDGCN_WAVEFRONT_SIZE as compile time constant.
---
 openmp/runtime/src/include/ompx.h.var | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/openmp/runtime/src/include/ompx.h.var b/openmp/runtime/src/include/ompx.h.var
index 623f0b9c315bd..03e5e59ab28cc 100644
--- a/openmp/runtime/src/include/ompx.h.var
+++ b/openmp/runtime/src/include/ompx.h.var
@@ -9,13 +9,21 @@
 #ifndef __OMPX_H
 #define __OMPX_H
 
-#ifdef __AMDGCN_WAVEFRONT_SIZE
-#define __WARP_SIZE __AMDGCN_WAVEFRONT_SIZE
-#else
-#define __WARP_SIZE 32
+#if (defined(__NVPTX__) || defined(__AMDGPU__))
+  #include <gpuintrin.h>
+  #define OMPX_TARGET_IS_GPU
 #endif
 
 typedef unsigned long uint64_t;
+typedef unsigned int uint32_t;
+
+inline uint32_t gpu_num_lanes(void) {
+  #ifdef OMPX_TARGET_IS_GPU
+    return __gpu_num_lanes();
+  #else
+    return 1;
+  #endif
+}
 
 #ifdef __cplusplus
 extern "C" {
@@ -212,7 +220,7 @@ static inline uint64_t ballot_sync(uint64_t mask, int pred) {
 ///{
 #define _TGT_KERNEL_LANGUAGE_SHFL_DOWN_SYNC(TYPE, TY)                          \
   static inline TYPE shfl_down_sync(uint64_t mask, TYPE var, unsigned delta,   \
-                                    int width = __WARP_SIZE) {                 \
+                                    int width = gpu_num_lanes()) {                 \
     return ompx_shfl_down_sync_##TY(mask, var, delta, width);                  \
   }
 



More information about the Openmp-commits mailing list