Skip to content

Conversation

@jhuber6
Copy link
Contributor

@jhuber6 jhuber6 commented Nov 5, 2024

Summary:
This patch adds a cache file that will automatically enable openpm,
offload, and all the fancy GPU libraries.

Summary:
This patch adds a cache file that will automatically enable openpm,
offload, and all the fancy GPU libraries.
@llvmbot llvmbot added openmp:libomp OpenMP host runtime openmp:libomptarget OpenMP offload runtime offload labels Nov 5, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2024

@llvm/pr-subscribers-offload

Author: Joseph Huber (jhuber6)

Changes

Summary:
This patch adds a cache file that will automatically enable openpm,
offload, and all the fancy GPU libraries.


Full diff: https://github.com/llvm/llvm-project/pull/115074.diff

2 Files Affected:

  • (added) offload/cmake/caches/Offload.cmake (+12)
  • (modified) openmp/docs/SupportAndFAQ.rst (+16)
diff --git a/offload/cmake/caches/Offload.cmake b/offload/cmake/caches/Offload.cmake
new file mode 100644
index 00000000000000..9205c38903d65f
--- /dev/null
+++ b/offload/cmake/caches/Offload.cmake
@@ -0,0 +1,12 @@
+set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "libunwind;libcxx;libcxxabi;openmp;offload" CACHE STRING "")
+set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
+
+set(CLANG_DEFAULT_CXX_STDLIB "libc++" CACHE STRING "")
+set(CLANG_DEFAULT_LINKER "lld" CACHE STRING "")
+
+set(LLVM_RUNTIME_TARGETS default;amdgcn-amd-amdhsa;nvptx64-nvidia-cuda CACHE STRING "") 
+set(RUNTIMES_nvptx64-nvidia-cuda_CACHE_FILES "${CMAKE_SOURCE_DIR}/../libcxx/cmake/caches/NVPTX.cmake" CACHE STRING "")
+set(RUNTIMES_amdgcn-amd-amdhsa_CACHE_FILES "${CMAKE_SOURCE_DIR}/../libcxx/cmake/caches/AMDGPU.cmake" CACHE STRING "")
+set(RUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES "compiler-rt;libc;libcxx;libcxxabi" CACHE STRING "")
+set(RUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES "compiler-rt;libc;libcxx;libcxxabi" CACHE STRING "")
diff --git a/openmp/docs/SupportAndFAQ.rst b/openmp/docs/SupportAndFAQ.rst
index dee707cf50f919..df6aea11416184 100644
--- a/openmp/docs/SupportAndFAQ.rst
+++ b/openmp/docs/SupportAndFAQ.rst
@@ -51,6 +51,22 @@ All patches go through the regular `LLVM review process
 
 Q: How to build an OpenMP GPU offload capable compiler?
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The easiest way to create an offload capable compiler is to use the provided 
+CMake cache file. This will enable the projects and runtimes necessary for 
+offloading as well as some extra options.
+
+.. code-block:: sh
+
+  $> cd llvm-project  # The llvm-project checkout
+  $> mkdir build
+  $> cd build
+  $> cmake ../llvm -G Ninja                                                 \
+     -C ../offload/cmake/caches/Offload.cmake \ # The preset cache file
+     -DCMAKE_BUILD_TYPE=<Debug|Release>   \ # Select build type
+     -DCMAKE_INSTALL_PREFIX=<PATH>        \ # Where the libraries will live
+  $> ninja install
+
 To build an *effective* OpenMP offload capable compiler, only one extra CMake
 option, ``LLVM_ENABLE_RUNTIMES="openmp;offload"``, is needed when building LLVM (Generic
 information about building LLVM is available `here

-DCMAKE_INSTALL_PREFIX=<PATH> \ # Where the libraries will live
$> ninja install
To build an *effective* OpenMP offload capable compiler, only one extra CMake
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be refined in a way that, as a manual alternative, ...

Copy link
Contributor

@shiltian shiltian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks okay

Copy link
Contributor

@shiltian shiltian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. We can always improve it if necessary.

@jhuber6 jhuber6 merged commit de41b13 into llvm:main Nov 7, 2024
7 checks passed
@jhuber6 jhuber6 deleted the Cache branch November 7, 2024 21:35
Groverkss pushed a commit to iree-org/llvm-project that referenced this pull request Nov 15, 2024
…#115074)

Summary:
This patch adds a cache file that will automatically enable openpm,
offload, and all the fancy GPU libraries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

offload openmp:libomp OpenMP host runtime openmp:libomptarget OpenMP offload runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants