llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Tsukasa OI (a4lg)

<details>
<summary>Changes</summary>

This PR adds new AMD's ROCm distribution ― TheRock-based device library path to 
Clang.

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


5 Files Affected:

- (modified) clang/lib/Driver/ToolChains/AMDGPU.cpp (+8-2) 
- (added) clang/test/Driver/Inputs/rocm-therock/include (+1) 
- (added) clang/test/Driver/Inputs/rocm-therock/lib/llvm/amdgcn (+1) 
- (added) clang/test/Driver/Inputs/rocm-therock/share/hip/version (+1) 
- (modified) clang/test/Driver/hip-device-libs.hip (+9-1) 


``````````diff
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 87ccd40372681..69ada73342127 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -436,15 +436,21 @@ void RocmInstallationDetector::detectDeviceLibrary() {
   if (HasDeviceLibrary)
     return;
 
-  // Find device libraries in a legacy ROCm directory structure
-  // ${ROCM_ROOT}/amdgcn/bitcode/*
+  // Find device libraries in a ROCm directory structure
   auto &ROCmDirs = getInstallationPathCandidates();
   for (const auto &Candidate : ROCmDirs) {
+    // Legacy: ${ROCM_PATH}/amdgcn/bitcode/*
     LibDevicePath = Candidate.Path;
     llvm::sys::path::append(LibDevicePath, "amdgcn", "bitcode");
     HasDeviceLibrary = CheckDeviceLib(LibDevicePath, Candidate.StrictChecking);
     if (HasDeviceLibrary)
       return;
+    // TheRock: ${ROCM_PATH}/lib/llvm/amdgcn/bitcode/*
+    LibDevicePath = Candidate.Path;
+    llvm::sys::path::append(LibDevicePath, "lib", "llvm", "amdgcn", "bitcode");
+    HasDeviceLibrary = CheckDeviceLib(LibDevicePath, Candidate.StrictChecking);
+    if (HasDeviceLibrary)
+      return;
   }
 }
 
diff --git a/clang/test/Driver/Inputs/rocm-therock/include 
b/clang/test/Driver/Inputs/rocm-therock/include
new file mode 120000
index 0000000000000..13265e5ed3db8
--- /dev/null
+++ b/clang/test/Driver/Inputs/rocm-therock/include
@@ -0,0 +1 @@
+../rocm/include
\ No newline at end of file
diff --git a/clang/test/Driver/Inputs/rocm-therock/lib/llvm/amdgcn 
b/clang/test/Driver/Inputs/rocm-therock/lib/llvm/amdgcn
new file mode 120000
index 0000000000000..79d18ba840474
--- /dev/null
+++ b/clang/test/Driver/Inputs/rocm-therock/lib/llvm/amdgcn
@@ -0,0 +1 @@
+../../../rocm/amdgcn
\ No newline at end of file
diff --git a/clang/test/Driver/Inputs/rocm-therock/share/hip/version 
b/clang/test/Driver/Inputs/rocm-therock/share/hip/version
new file mode 120000
index 0000000000000..62ff49a023cb9
--- /dev/null
+++ b/clang/test/Driver/Inputs/rocm-therock/share/hip/version
@@ -0,0 +1 @@
+../../../rocm/bin/.hipVersion
\ No newline at end of file
diff --git a/clang/test/Driver/hip-device-libs.hip 
b/clang/test/Driver/hip-device-libs.hip
index effce40d67ebd..f5813c06ae600 100644
--- a/clang/test/Driver/hip-device-libs.hip
+++ b/clang/test/Driver/hip-device-libs.hip
@@ -9,7 +9,7 @@
 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
 
 
-// Test subtarget with flushing off by ddefault.
+// Test subtarget with flushing off by default.
 // RUN: %clang -### --target=x86_64-linux-gnu \
 // RUN:  --cuda-gpu-arch=gfx900 \
 // RUN:  --rocm-path=%S/Inputs/rocm \
@@ -85,6 +85,13 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
 
+// Test TheRock toolchain layout
+// RUN: %clang -### --target=x86_64-linux-gnu \
+// RUN:   --offload-arch=gfx803 -nogpuinc \
+// RUN:   --rocm-path=%S/Inputs/rocm-therock \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR-THEROCK
+
 // Test finding device lib in resource dir
 // RUN: %clang -### --target=x86_64-linux-gnu \
 // RUN:   --offload-arch=gfx803 -nogpuinc \
@@ -210,6 +217,7 @@
 
 // RESDIR-SAME: "-mlink-builtin-bitcode" 
"[[DEVICELIB_DIR:[^"]+(/|\\\\)rocm_resource_dir(/|\\\\)lib(64)?(/|\\\\)amdgcn(/|\\\\).*]]ocml.bc"
 // ROCMDIR-SAME: "-mlink-builtin-bitcode" 
"[[DEVICELIB_DIR:[^"]+(/|\\\\)rocm(/|\\\\)amdgcn(/|\\\\).*]]ocml.bc"
+// ROCMDIR-THEROCK-SAME: "-mlink-builtin-bitcode" 
"[[DEVICELIB_DIR:[^"]+(/|\\\\)rocm-therock(/|\\\\)lib(/|\\\\)llvm(/|\\\\)amdgcn(/|\\\\).*]]ocml.bc"
 
 // ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]ockl.bc"
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/170590
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to