diff options
| author | JonChesterfield <jonathanchesterfield@gmail.com> | 2019-12-16 16:16:13 +0000 |
|---|---|---|
| committer | Jon Chesterfield <jonathanchesterfield@gmail.com> | 2019-12-16 16:16:14 +0000 |
| commit | 69fcc6ecc15bd01b2ade9efc49315b2097f0da40 (patch) | |
| tree | 78efeba319291b0decf4fbe0b8e7684e8ad035d0 /openmp | |
| parent | d7efa6b1985ff14d0c50ade771d4b01ee1b5075e (diff) | |
| download | bcm5719-llvm-69fcc6ecc15bd01b2ade9efc49315b2097f0da40.tar.gz bcm5719-llvm-69fcc6ecc15bd01b2ade9efc49315b2097f0da40.zip | |
Revert "Revert "[libomptarget] Move resource id functions into target specific code, implement for amdgcn""
Summary:
This reverts commit dd8a7fcdd73dd63529b81bf9f72c7529dfe99ec3.
Alexey reports undefined symbols for the new inline functions defined in target_impl.h
This does not reproduce for me for nvptx, or amdgcn, under release or debug builds.
I believe the patch is fine, based on:
- the semantics of an inline function in C++ (the cuda INLINE functions end
up as linkonce_odr in IR), which are only legal to drop if they have no uses
- the code generated from a debug build of clang 9 does not show these undef symbols
- the tests pass
- the code is trivial
To progress from here I either need:
- A tie break - someone to play the role of CI in determining whether the patch works
- Alexey to provide sufficient information about his build for me to reproduce the failure
- Alexey to debug why the symbols are disappearing for him and report back
Reviewers: ABataev, jdoerfert, grokos
Subscribers: jvesely, openmp-commits
Tags: #openmp
Differential Revision: https://reviews.llvm.org/D71502
Diffstat (limited to 'openmp')
4 files changed, 15 insertions, 13 deletions
diff --git a/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h b/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h index 62cbfb0f523..5082d469d05 100644 --- a/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h +++ b/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h @@ -136,6 +136,14 @@ EXTERN void __kmpc_impl_threadfence(void); EXTERN void __kmpc_impl_threadfence_block(void); EXTERN void __kmpc_impl_threadfence_system(void); +// Calls to the AMDGCN layer (assuming 1D layout) +EXTERN uint64_t __ockl_get_local_size(uint32_t); +EXTERN uint64_t __ockl_get_num_groups(uint32_t); +INLINE int GetThreadIdInBlock() { return __builtin_amdgcn_workitem_id_x(); } +INLINE int GetBlockIdInKernel() { return __builtin_amdgcn_workgroup_id_x(); } +INLINE int GetNumberOfBlocksInKernel() { return __ockl_get_num_groups(0); } +INLINE int GetNumberOfThreadsInBlock() { return __ockl_get_local_size(0); } + // DEVICE versions of part of libc extern "C" { DEVICE __attribute__((noreturn)) void diff --git a/openmp/libomptarget/deviceRTLs/common/src/support.cu b/openmp/libomptarget/deviceRTLs/common/src/support.cu index 2f992f2778e..ea1fc3841ad 100644 --- a/openmp/libomptarget/deviceRTLs/common/src/support.cu +++ b/openmp/libomptarget/deviceRTLs/common/src/support.cu @@ -98,14 +98,6 @@ DEVICE bool checkRuntimeInitialized(kmp_Ident *loc) { // //////////////////////////////////////////////////////////////////////////////// -DEVICE int GetThreadIdInBlock() { return threadIdx.x; } - -DEVICE int GetBlockIdInKernel() { return blockIdx.x; } - -DEVICE int GetNumberOfBlocksInKernel() { return gridDim.x; } - -DEVICE int GetNumberOfThreadsInBlock() { return blockDim.x; } - DEVICE unsigned GetWarpId() { return GetThreadIdInBlock() / WARPSIZE; } DEVICE unsigned GetLaneId() { return GetThreadIdInBlock() & (WARPSIZE - 1); } diff --git a/openmp/libomptarget/deviceRTLs/common/support.h b/openmp/libomptarget/deviceRTLs/common/support.h index 8cffd91c9f3..400d2649afd 100644 --- a/openmp/libomptarget/deviceRTLs/common/support.h +++ b/openmp/libomptarget/deviceRTLs/common/support.h @@ -1,4 +1,4 @@ -//===--------- support.h - NVPTX OpenMP support functions -------- CUDA -*-===// +//===--------- support.h - OpenMP GPU support functions ---------- CUDA -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -51,10 +51,6 @@ DEVICE bool checkRuntimeInitialized(kmp_Ident *loc); //////////////////////////////////////////////////////////////////////////////// // get low level ids of resources -DEVICE int GetThreadIdInBlock(); -DEVICE int GetBlockIdInKernel(); -DEVICE int GetNumberOfBlocksInKernel(); -DEVICE int GetNumberOfThreadsInBlock(); DEVICE unsigned GetWarpId(); DEVICE unsigned GetLaneId(); diff --git a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h index fe36a46c5cd..161cd6cac11 100644 --- a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h +++ b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h @@ -167,4 +167,10 @@ INLINE void __kmpc_impl_threadfence(void) { __threadfence(); } INLINE void __kmpc_impl_threadfence_block(void) { __threadfence_block(); } INLINE void __kmpc_impl_threadfence_system(void) { __threadfence_system(); } +// Calls to the NVPTX layer (assuming 1D layout) +INLINE int GetThreadIdInBlock() { return threadIdx.x; } +INLINE int GetBlockIdInKernel() { return blockIdx.x; } +INLINE int GetNumberOfBlocksInKernel() { return gridDim.x; } +INLINE int GetNumberOfThreadsInBlock() { return blockDim.x; } + #endif |

