[OpenMP] Remove use of '__AMDGCN_WAVEFRONT_SIZE' (#113156)

Summary:
This is going to be deprecated in
https://github.com/llvm/llvm-project/pull/112849. This patch ports it to
use the builtin instead. This isn't a compile constant, so it could
slightly negatively affect codegen. There really should be an IR pass to
turn it into a constant if the function has known attributes.

Using the builtin is correct when we just do it for knowing the size
like we do here. Obviously guarding w32/w64 code with this check would
be broken.
This commit is contained in:
Joseph Huber
2024-11-25 07:38:28 -06:00
committed by GitHub
parent 52755ac253
commit 506ca19dc9
3 changed files with 34 additions and 19 deletions

View File

@@ -25,7 +25,6 @@ namespace ompx {
namespace impl {
// Forward declarations defined to be defined for AMDGCN and NVPTX.
const llvm::omp::GV &getGridValue();
LaneMaskTy activemask();
LaneMaskTy lanemaskLT();
LaneMaskTy lanemaskGT();
@@ -37,15 +36,14 @@ uint32_t getBlockIdInKernel(int32_t Dim);
uint32_t getNumberOfBlocksInKernel(int32_t Dim);
uint32_t getWarpIdInBlock();
uint32_t getNumberOfWarpsInBlock();
uint32_t getWarpSize();
/// AMDGCN Implementation
///
///{
#pragma omp begin declare variant match(device = {arch(amdgcn)})
const llvm::omp::GV &getGridValue() {
return llvm::omp::getAMDGPUGridValues<__AMDGCN_WAVEFRONT_SIZE>();
}
uint32_t getWarpSize() { return __builtin_amdgcn_wavefrontsize(); }
uint32_t getNumberOfThreadsInBlock(int32_t Dim) {
switch (Dim) {
@@ -152,7 +150,7 @@ uint32_t getNumberOfThreadsInBlock(int32_t Dim) {
UNREACHABLE("Dim outside range!");
}
const llvm::omp::GV &getGridValue() { return llvm::omp::NVPTXGridValues; }
uint32_t getWarpSize() { return __nvvm_read_ptx_sreg_warpsize(); }
LaneMaskTy activemask() { return __nvvm_activemask(); }
@@ -219,8 +217,6 @@ uint32_t getNumberOfWarpsInBlock() {
#pragma omp end declare variant
///}
uint32_t getWarpSize() { return getGridValue().GV_Warp_Size; }
} // namespace impl
} // namespace ompx