[all-commits] [llvm/llvm-project] 7c03f7: [OpenMP][deviceRTLs] Build the deviceRTLs with Ope...
Shilei Tian via All-commits
all-commits at lists.llvm.org
Tue Jan 26 09:29:09 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7c03f7d7d04c0f017cc8e9522209c98036042f17
https://github.com/llvm/llvm-project/commit/7c03f7d7d04c0f017cc8e9522209c98036042f17
Author: Shilei Tian <tianshilei1992 at gmail.com>
Date: 2021-01-26 (Tue, 26 Jan 2021)
Changed paths:
M clang/lib/Driver/ToolChains/Cuda.cpp
A clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-cuda_80-sm_20.bc
R clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_20.bc
M clang/test/Driver/openmp-offload-gpu.c
M openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
A openmp/libomptarget/deviceRTLs/common/allocator.h
M openmp/libomptarget/deviceRTLs/common/omptarget.h
M openmp/libomptarget/deviceRTLs/common/src/omp_data.cu
M openmp/libomptarget/deviceRTLs/common/src/reduction.cu
M openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
M openmp/libomptarget/deviceRTLs/nvptx/src/nvptx_interface.h
M openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
M openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
Log Message:
-----------
[OpenMP][deviceRTLs] Build the deviceRTLs with OpenMP instead of target dependent language
>From this patch (plus some landed patches), `deviceRTLs` is taken as a regular OpenMP program with just `declare target` regions. In this way, ideally, `deviceRTLs` can be written in OpenMP directly. No CUDA, no HIP anymore. (Well, AMD is still working on getting it work. For now AMDGCN still uses original way to compile) However, some target specific functions are still required, but they're no longer written in target specific language. For example, CUDA parts have all refined by replacing CUDA intrinsic and builtins with LLVM/Clang/NVVM intrinsics.
Here're a list of changes in this patch.
1. For NVPTX, `DEVICE` is defined empty in order to make the common parts still work with AMDGCN. Later once AMDGCN is also available, we will completely remove `DEVICE` or probably some other macros.
2. Shared variable is implemented with OpenMP allocator, which is defined in `allocator.h`. Again, this feature is not available on AMDGCN, so two macros are redefined properly.
3. CUDA header `cuda.h` is dropped in the source code. In order to deal with code difference in various CUDA versions, we build one bitcode library for each supported CUDA version. For each CUDA version, the highest PTX version it supports will be used, just as what we currently use for CUDA compilation.
4. Correspondingly, compiler driver is also updated to support CUDA version encoded in the name of bitcode library. Now the bitcode library for NVPTX is named as `libomptarget-nvptx-cuda_[cuda_version]-sm_[sm_number].bc`, such as `libomptarget-nvptx-cuda_80-sm_20.bc`.
With this change, there are also multiple features to be expected in the near future:
1. CUDA will be completely dropped when compiling OpenMP. By the time, we also build bitcode libraries for all supported SM, multiplied by all supported CUDA version.
2. Atomic operations used in `deviceRTLs` can be replaced by `omp atomic` if OpenMP 5.1 feature is fully supported. For now, the IR generated is totally wrong.
3. Target specific parts will be wrapped into `declare variant` with `isa` selector if it can work properly. No target specific macro is needed anymore.
4. (Maybe more...)
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D94745
More information about the All-commits
mailing list