[PATCH] D119841: [OpenMP] Pass AMDGPU math libraries into the linker wrapper
Joseph Huber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 16 13:41:12 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG64ecdc1cb168: [OpenMP] Pass AMDGPU math libraries into the linker wrapper (authored by jhuber6).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119841/new/
https://reviews.llvm.org/D119841
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/amdgpu-openmp-toolchain.c
Index: clang/test/Driver/amdgpu-openmp-toolchain.c
===================================================================
--- clang/test/Driver/amdgpu-openmp-toolchain.c
+++ clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -77,3 +77,6 @@
// RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -lm --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode %s 2>&1 | FileCheck %s --check-prefix=CHECK-LIB-DEVICE
// CHECK-LIB-DEVICE: {{.*}}llvm-link{{.*}}ocml.bc"{{.*}}ockl.bc"{{.*}}oclc_daz_opt_on.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_803.bc"
+
+// RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -lm --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode -fopenmp-new-driver %s 2>&1 | FileCheck %s --check-prefix=CHECK-LIB-DEVICE-NEW
+// CHECK-LIB-DEVICE-NEW: {{.*}}clang-linker-wrapper{{.*}}-target-library=amdgcn-amd-amdhsa-gfx803={{.*}}ocml.bc"{{.*}}ockl.bc"{{.*}}oclc_daz_opt_on.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_803.bc"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -8199,6 +8199,29 @@
}
}
+ // Get the AMDGPU math libraries.
+ // FIXME: This method is bad, remove once AMDGPU has a proper math library
+ // (see AMDGCN::OpenMPLinker::constructLLVMLinkCommand).
+ for (auto &I : llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
+ const ToolChain *TC = I.second;
+
+ if (!TC->getTriple().isAMDGPU() || Args.hasArg(options::OPT_nogpulib))
+ continue;
+
+ const ArgList &TCArgs = C.getArgsForToolChain(TC, "", Action::OFK_OpenMP);
+ StringRef Arch = TCArgs.getLastArgValue(options::OPT_march_EQ);
+ const toolchains::ROCMToolChain RocmTC(TC->getDriver(), TC->getTriple(),
+ TCArgs);
+
+ SmallVector<std::string, 12> BCLibs =
+ RocmTC.getCommonDeviceLibNames(TCArgs, Arch.str());
+
+ for (StringRef LibName : BCLibs)
+ CmdArgs.push_back(
+ Args.MakeArgString("-target-library=" + TC->getTripleString() + "-" +
+ Arch + "=" + LibName));
+ }
+
if (D.isUsingLTO(/* IsOffload */ true)) {
// Pass in target features for each toolchain.
for (auto &I :
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119841.409397.patch
Type: text/x-patch
Size: 2672 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220216/c3eddf1d/attachment-0001.bin>
More information about the cfe-commits
mailing list