Skip to content

Commit cf6ae06

Browse files
nicebertshiltian
andauthored
[OpenMP] Remove declaration and usage of __AMDGCN_WAVEFRONT_SIZE (#143761)
Removes usage of __AMDGCN_WAVEFRONT_SIZE as compile time constant. --------- Co-authored-by: Shilei Tian <[email protected]>
1 parent 9670e09 commit cf6ae06

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

openmp/runtime/src/include/ompx.h.var

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@
99
#ifndef __OMPX_H
1010
#define __OMPX_H
1111

12-
#ifdef __AMDGCN_WAVEFRONT_SIZE
13-
#define __WARP_SIZE __AMDGCN_WAVEFRONT_SIZE
14-
#else
15-
#define __WARP_SIZE 32
12+
#if (defined(__NVPTX__) || defined(__AMDGPU__))
13+
#include <gpuintrin.h>
14+
#define __OMPX_TARGET_IS_GPU
1615
#endif
1716

1817
typedef unsigned long uint64_t;
18+
typedef unsigned int uint32_t;
19+
20+
static inline uint32_t __warpSize(void) {
21+
#ifdef __OMPX_TARGET_IS_GPU
22+
return __gpu_num_lanes();
23+
#else
24+
__builtin_trap();
25+
#endif
26+
}
1927

2028
#ifdef __cplusplus
2129
extern "C" {
@@ -212,7 +220,7 @@ static inline uint64_t ballot_sync(uint64_t mask, int pred) {
212220
///{
213221
#define _TGT_KERNEL_LANGUAGE_SHFL_DOWN_SYNC(TYPE, TY) \
214222
static inline TYPE shfl_down_sync(uint64_t mask, TYPE var, unsigned delta, \
215-
int width = __WARP_SIZE) { \
223+
int width = __warpSize()) { \
216224
return ompx_shfl_down_sync_##TY(mask, var, delta, width); \
217225
}
218226

0 commit comments

Comments
 (0)