Skip to content

Commit aee3336

Browse files
committed
[Clang][AMDGPU] Search TheRock-based device libraries
TheRock has slightly different path (relative to ROCM_PATH) for device libraries. This commit adds search path for device libraries on a TheRock-based distribution. Signed-off-by: Tsukasa OI <[email protected]>
1 parent bb52fec commit aee3336

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,15 +436,21 @@ void RocmInstallationDetector::detectDeviceLibrary() {
436436
if (HasDeviceLibrary)
437437
return;
438438

439-
// Find device libraries in a legacy ROCm directory structure
440-
// ${ROCM_ROOT}/amdgcn/bitcode/*
439+
// Find device libraries in a ROCm directory structure
441440
auto &ROCmDirs = getInstallationPathCandidates();
442441
for (const auto &Candidate : ROCmDirs) {
442+
// Legacy: ${ROCM_PATH}/amdgcn/bitcode/*
443443
LibDevicePath = Candidate.Path;
444444
llvm::sys::path::append(LibDevicePath, "amdgcn", "bitcode");
445445
HasDeviceLibrary = CheckDeviceLib(LibDevicePath, Candidate.StrictChecking);
446446
if (HasDeviceLibrary)
447447
return;
448+
// TheRock: ${ROCM_PATH}/lib/llvm/amdgcn/bitcode/*
449+
LibDevicePath = Candidate.Path;
450+
llvm::sys::path::append(LibDevicePath, "lib", "llvm", "amdgcn", "bitcode");
451+
HasDeviceLibrary = CheckDeviceLib(LibDevicePath, Candidate.StrictChecking);
452+
if (HasDeviceLibrary)
453+
return;
448454
}
449455
}
450456

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../rocm/bin
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../rocm/include
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../rocm/amdgcn

clang/test/Driver/hip-device-libs.hip

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@
8585
// RUN: %S/Inputs/hip_multiple_inputs/b.hip \
8686
// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
8787

88+
// Test TheRock toolchain layout
89+
// RUN: %clang -### --target=x86_64-linux-gnu \
90+
// RUN: --offload-arch=gfx803 -nogpuinc \
91+
// RUN: --rocm-path=%S/Inputs/rocm-therock \
92+
// RUN: %S/Inputs/hip_multiple_inputs/b.hip \
93+
// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR-THEROCK
94+
8895
// Test finding device lib in resource dir
8996
// RUN: %clang -### --target=x86_64-linux-gnu \
9097
// RUN: --offload-arch=gfx803 -nogpuinc \
@@ -210,6 +217,7 @@
210217

211218
// RESDIR-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR:[^"]+(/|\\\\)rocm_resource_dir(/|\\\\)lib(64)?(/|\\\\)amdgcn(/|\\\\).*]]ocml.bc"
212219
// ROCMDIR-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR:[^"]+(/|\\\\)rocm(/|\\\\)amdgcn(/|\\\\).*]]ocml.bc"
220+
// ROCMDIR-THEROCK-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR:[^"]+(/|\\\\)rocm-therock(/|\\\\)lib(/|\\\\)llvm(/|\\\\)amdgcn(/|\\\\).*]]ocml.bc"
213221

214222
// ALL-SAME: "-mlink-builtin-bitcode" "[[DEVICELIB_DIR]]ockl.bc"
215223

0 commit comments

Comments
 (0)