[OpenMP] Introduce basic JIT support to OpenMP target offloading
authorShilei Tian <i@tianshilei.me>
Wed, 28 Dec 2022 03:18:57 +0000 (22:18 -0500)
committerShilei Tian <i@tianshilei.me>
Wed, 28 Dec 2022 03:19:05 +0000 (22:19 -0500)
commit5a3a527f8ae220583981a122fda2a2c2eefa1a41
treea72b6630b930d058333dfd1c5daea0c2a221af35
parent95956bd896225eb6fcdd05cc3b6c4b0a133fbc7e
[OpenMP] Introduce basic JIT support to OpenMP target offloading

This patch adds the basic JIT support for OpenMP. Currently it only works on Nvidia GPUs.

The support for AMDGPU can be extended easily by just implementing three interface functions. However, the infrastructure requires a small extra extension (add a pre process hook) to support portability for AMDGPU because the AMDGPU backend reads target features of functions. https://github.com/shiltian/llvm-project/commit/02bc7effccc6ff2f5ab3fe5218336094c0485766#diff-321c2038035972ad4994ff9d85b29950ba72c08a79891db5048b8f5d46915314R432 shows how it roughly works.

As for the test, even though I added the corresponding code in CMake files, the test still cannot be triggered because some code is missing in the new plugin CMake file, which has nothing to do with this patch. It will be fixed later.

In order to enable JIT mode, when compiling, `-foffload-lto` is needed, and when linking, `-foffload-lto -Wl,--embed-bitcode` is needed. That implies that, LTO is required to enable JIT mode.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D139287
openmp/libomptarget/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.h [new file with mode: 0644]
openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
openmp/libomptarget/test/lit.cfg