Skip to content

[libc] Change the GPU loaders to LLVM executables #101442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2024
Merged

Conversation

jhuber6
Copy link
Contributor

@jhuber6 jhuber6 commented Aug 1, 2024

Summary:
I am going to rework these tools to just me LLVM tools. This patch is
pretty much NFC to set up the CMake for that.

Summary:
I am going to rework these tools to just me LLVM tools. This patch is
pretty much NFC to set up the CMake for that.
@llvmbot
Copy link
Member

llvmbot commented Aug 1, 2024

@llvm/pr-subscribers-libc

@llvm/pr-subscribers-backend-amdgpu

Author: Joseph Huber (jhuber6)

Changes

Summary:
I am going to rework these tools to just me LLVM tools. This patch is
pretty much NFC to set up the CMake for that.


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

5 Files Affected:

  • (modified) libc/utils/gpu/loader/CMakeLists.txt (+2)
  • (modified) libc/utils/gpu/loader/amdgpu/CMakeLists.txt (+8-1)
  • (renamed) libc/utils/gpu/loader/amdgpu/amdhsa-loader.cpp ()
  • (modified) libc/utils/gpu/loader/nvptx/CMakeLists.txt (+8-8)
  • (renamed) libc/utils/gpu/loader/nvptx/nvptx-loader.cpp ()
diff --git a/libc/utils/gpu/loader/CMakeLists.txt b/libc/utils/gpu/loader/CMakeLists.txt
index b562cdc521c07..7b5f28075c8b1 100644
--- a/libc/utils/gpu/loader/CMakeLists.txt
+++ b/libc/utils/gpu/loader/CMakeLists.txt
@@ -4,6 +4,8 @@ target_include_directories(gpu_loader PUBLIC
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${LIBC_SOURCE_DIR}/include
   ${LIBC_SOURCE_DIR}
+  ${LLVM_MAIN_INCLUDE_DIR}
+  ${LLVM_BINARY_DIR}/include)
 )
 
 find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
diff --git a/libc/utils/gpu/loader/amdgpu/CMakeLists.txt b/libc/utils/gpu/loader/amdgpu/CMakeLists.txt
index 97a2de9f8379a..46c5631046ce2 100644
--- a/libc/utils/gpu/loader/amdgpu/CMakeLists.txt
+++ b/libc/utils/gpu/loader/amdgpu/CMakeLists.txt
@@ -1,4 +1,11 @@
-add_executable(amdhsa-loader Loader.cpp)
+set(LLVM_LINK_COMPONENTS
+  BinaryFormat
+  Object
+  Option
+  Support
+  )
+
+add_llvm_executable(amdhsa-loader amdhsa-loader.cpp)
 
 target_link_libraries(amdhsa-loader
   PRIVATE
diff --git a/libc/utils/gpu/loader/amdgpu/Loader.cpp b/libc/utils/gpu/loader/amdgpu/amdhsa-loader.cpp
similarity index 100%
rename from libc/utils/gpu/loader/amdgpu/Loader.cpp
rename to libc/utils/gpu/loader/amdgpu/amdhsa-loader.cpp
diff --git a/libc/utils/gpu/loader/nvptx/CMakeLists.txt b/libc/utils/gpu/loader/nvptx/CMakeLists.txt
index 948493959badf..21453b9ca0348 100644
--- a/libc/utils/gpu/loader/nvptx/CMakeLists.txt
+++ b/libc/utils/gpu/loader/nvptx/CMakeLists.txt
@@ -1,15 +1,15 @@
-add_executable(nvptx-loader Loader.cpp)
+set(LLVM_LINK_COMPONENTS
+  BinaryFormat
+  Object
+  Option
+  Support
+  )
+
+add_llvm_executable(nvptx-loader nvptx-loader.cpp)
 
-if(NOT LLVM_ENABLE_RTTI)
-  target_compile_options(nvptx-loader PRIVATE -fno-rtti)
-endif()
-target_include_directories(nvptx-loader PRIVATE
-                           ${LLVM_MAIN_INCLUDE_DIR} ${LLVM_BINARY_DIR}/include)
 target_link_libraries(nvptx-loader
   PRIVATE
   gpu_loader
   llvmlibc_rpc_server
   CUDA::cuda_driver
-  LLVMObject
-  LLVMSupport
 )
diff --git a/libc/utils/gpu/loader/nvptx/Loader.cpp b/libc/utils/gpu/loader/nvptx/nvptx-loader.cpp
similarity index 100%
rename from libc/utils/gpu/loader/nvptx/Loader.cpp
rename to libc/utils/gpu/loader/nvptx/nvptx-loader.cpp

Support
)

add_llvm_executable(amdhsa-loader amdhsa-loader.cpp)
Copy link
Contributor

Choose a reason for hiding this comment

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

will this be copied into <build-dir>/bin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's also installed into <install>/bin.

Copy link
Contributor

@SchrodingerZhu SchrodingerZhu left a comment

Choose a reason for hiding this comment

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

LGTM. Just a small concern that the name maybe too general for a installation target exposed to users. Perhaps not a problem for now.

@jhuber6 jhuber6 merged commit feeb833 into llvm:main Aug 1, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants