From a8633717b6f5e7b5d914f5ed0b84839e6f3e1031 Mon Sep 17 00:00:00 2001 From: Nicole Aschenbrenner Date: Wed, 11 Jun 2025 14:01:39 -0400 Subject: [PATCH 1/2] [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..a6e8b4718f881 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 +#define __OMPX_TARGET_IS_GPU #endif typedef unsigned long uint64_t; +typedef unsigned int uint32_t; + +static inline uint32_t __warpSize(void) { + #ifdef __OMPX_TARGET_IS_GPU + return __gpu_num_lanes(); + #else + __builtin_trap(); + #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 = __warpSize()) { \ return ompx_shfl_down_sync_##TY(mask, var, delta, width); \ } From 321468ecd2ad042bab8c69a0f0948857debbc71b Mon Sep 17 00:00:00 2001 From: nicebert <110385235+nicebert@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:18:48 +0200 Subject: [PATCH 2/2] Update openmp/runtime/src/include/ompx.h.var Removes whitespaces at start of line. Co-authored-by: Shilei Tian --- openmp/runtime/src/include/ompx.h.var | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openmp/runtime/src/include/ompx.h.var b/openmp/runtime/src/include/ompx.h.var index a6e8b4718f881..6884745f4240c 100644 --- a/openmp/runtime/src/include/ompx.h.var +++ b/openmp/runtime/src/include/ompx.h.var @@ -18,11 +18,11 @@ typedef unsigned long uint64_t; typedef unsigned int uint32_t; static inline uint32_t __warpSize(void) { - #ifdef __OMPX_TARGET_IS_GPU - return __gpu_num_lanes(); - #else - __builtin_trap(); - #endif +#ifdef __OMPX_TARGET_IS_GPU + return __gpu_num_lanes(); +#else + __builtin_trap(); +#endif } #ifdef __cplusplus