Skip to content

Commit de41b13

Browse files
authored
[Offload] Provide a CMake cache file to easily build offloading (#115074)
Summary: This patch adds a cache file that will automatically enable openpm, offload, and all the fancy GPU libraries.
1 parent 87feafc commit de41b13

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

offload/cmake/caches/Offload.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;compiler-rt;lld" CACHE STRING "")
2+
set(LLVM_ENABLE_RUNTIMES "libunwind;libcxx;libcxxabi;openmp;offload" CACHE STRING "")
3+
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
4+
5+
set(CLANG_DEFAULT_CXX_STDLIB "libc++" CACHE STRING "")
6+
set(CLANG_DEFAULT_LINKER "lld" CACHE STRING "")
7+
8+
set(LLVM_RUNTIME_TARGETS default;amdgcn-amd-amdhsa;nvptx64-nvidia-cuda CACHE STRING "")
9+
set(RUNTIMES_nvptx64-nvidia-cuda_CACHE_FILES "${CMAKE_SOURCE_DIR}/../libcxx/cmake/caches/NVPTX.cmake" CACHE STRING "")
10+
set(RUNTIMES_amdgcn-amd-amdhsa_CACHE_FILES "${CMAKE_SOURCE_DIR}/../libcxx/cmake/caches/AMDGPU.cmake" CACHE STRING "")
11+
set(RUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES "compiler-rt;libc;libcxx;libcxxabi" CACHE STRING "")
12+
set(RUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES "compiler-rt;libc;libcxx;libcxxabi" CACHE STRING "")

openmp/docs/SupportAndFAQ.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,23 @@ All patches go through the regular `LLVM review process
5151

5252
Q: How to build an OpenMP GPU offload capable compiler?
5353
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54-
To build an *effective* OpenMP offload capable compiler, only one extra CMake
54+
55+
The easiest way to create an offload capable compiler is to use the provided
56+
CMake cache file. This will enable the projects and runtimes necessary for
57+
offloading as well as some extra options.
58+
59+
.. code-block:: sh
60+
61+
$> cd llvm-project # The llvm-project checkout
62+
$> mkdir build
63+
$> cd build
64+
$> cmake ../llvm -G Ninja \
65+
-C ../offload/cmake/caches/Offload.cmake \ # The preset cache file
66+
-DCMAKE_BUILD_TYPE=<Debug|Release> \ # Select build type
67+
-DCMAKE_INSTALL_PREFIX=<PATH> \ # Where the libraries will live
68+
$> ninja install
69+
70+
To manually build an *effective* OpenMP offload capable compiler, only one extra CMake
5571
option, ``LLVM_ENABLE_RUNTIMES="openmp;offload"``, is needed when building LLVM (Generic
5672
information about building LLVM is available `here
5773
<https://llvm.org/docs/GettingStarted.html>`__.). Make sure all backends that

0 commit comments

Comments
 (0)