Skip to content

Commit ddb018f

Browse files
authored
[Clang][NFC] Add alias target for amdgpu-arch-tool and nvptx-arch-tool (#147558)
Summary: These commands both do the same thing and behave like the same tool. Now, the `nvptx-arch` and `amdgpu-arch` tools cause it to only emit architectures for that name.
1 parent a7a7e95 commit ddb018f

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,10 +1173,12 @@ def offload_host_device : Flag<["--"], "offload-host-device">,
11731173
def gpu_use_aux_triple_only : Flag<["--"], "gpu-use-aux-triple-only">,
11741174
InternalDriverOpt, HelpText<"Prepare '-aux-triple' only without populating "
11751175
"'-aux-target-cpu' and '-aux-target-feature'.">;
1176+
def offload_arch_tool_EQ : Joined<["--"], "offload-arch-tool=">,
1177+
HelpText<"Tool used for detecting offloading architectures in the system.">;
11761178
def amdgpu_arch_tool_EQ : Joined<["--"], "amdgpu-arch-tool=">,
1177-
HelpText<"Tool used for detecting AMD GPU arch in the system.">;
1179+
Alias<offload_arch_tool_EQ>;
11781180
def nvptx_arch_tool_EQ : Joined<["--"], "nvptx-arch-tool=">,
1179-
HelpText<"Tool used for detecting NVIDIA GPU arch in the system.">;
1181+
Alias<offload_arch_tool_EQ>;
11801182

11811183
defm gpu_rdc : BoolFOption<"gpu-rdc",
11821184
LangOpts<"GPURelocatableDeviceCode">, DefaultFalse,

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ Expected<SmallVector<std::string>>
836836
AMDGPUToolChain::getSystemGPUArchs(const ArgList &Args) const {
837837
// Detect AMD GPUs availible on the system.
838838
std::string Program;
839-
if (Arg *A = Args.getLastArg(options::OPT_amdgpu_arch_tool_EQ))
839+
if (Arg *A = Args.getLastArg(options::OPT_offload_arch_tool_EQ))
840840
Program = A->getValue();
841841
else
842842
Program = GetProgramPath("amdgpu-arch");

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ Expected<SmallVector<std::string>>
810810
NVPTXToolChain::getSystemGPUArchs(const ArgList &Args) const {
811811
// Detect NVIDIA GPUs availible on the system.
812812
std::string Program;
813-
if (Arg *A = Args.getLastArg(options::OPT_nvptx_arch_tool_EQ))
813+
if (Arg *A = Args.getLastArg(options::OPT_offload_arch_tool_EQ))
814814
Program = A->getValue();
815815
else
816816
Program = GetProgramPath("nvptx-arch");
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
echo "sm_70"
3+
echo "gfx906"
4+
exit 0

clang/test/Driver/openmp-system-arch.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// RUN: cp %S/Inputs/amdgpu-arch/amdgpu_arch_gfx906 %t/
77
// RUN: cp %S/Inputs/nvptx-arch/nvptx_arch_fail %t/
88
// RUN: cp %S/Inputs/nvptx-arch/nvptx_arch_sm_70 %t/
9+
// RUN: cp %S/Inputs/offload-arch/offload_arch_sm_70_gfx906 %t/
910
// RUN: echo '#!/bin/sh' > %t/amdgpu_arch_empty
1011
// RUN: chmod +x %t/amdgpu_arch_fail
1112
// RUN: chmod +x %t/amdgpu_arch_gfx906
@@ -14,6 +15,7 @@
1415
// RUN: chmod +x %t/nvptx_arch_fail
1516
// RUN: chmod +x %t/nvptx_arch_sm_70
1617
// RUN: chmod +x %t/nvptx_arch_empty
18+
// RUN: chmod +x %t/offload_arch_sm_70_gfx906
1719

1820
// case when nvptx-arch and amdgpu-arch return nothing or fails
1921
// RUN: not %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native \
@@ -41,23 +43,23 @@
4143

4244
// case when nvptx-arch succeeds.
4345
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native \
44-
// RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 --amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \
46+
// RUN: --amdgpu-arch-tool=%t/amdgpu_arch_fail --nvptx-arch-tool=%t/nvptx_arch_sm_70 %s 2>&1 \
4547
// RUN: | FileCheck %s --check-prefix=ARCH-SM_70
4648
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
47-
// RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 --amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \
49+
// RUN: --amdgpu-arch-tool=%t/amdgpu_arch_fail --nvptx-arch-tool=%t/nvptx_arch_sm_70 %s 2>&1 \
4850
// RUN: | FileCheck %s --check-prefix=ARCH-SM_70
4951
// ARCH-SM_70: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70"
5052

5153
// case when both nvptx-arch and amdgpu-arch succeed.
5254
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native \
53-
// RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \
55+
// RUN: --offload-arch-tool=%t/offload_arch_sm_70_gfx906 %s 2>&1 \
5456
// RUN: | FileCheck %s --check-prefix=ARCH-SM_70-GFX906
5557
// ARCH-SM_70-GFX906: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906"
5658
// ARCH-SM_70-GFX906: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70"
5759

5860
// case when both nvptx-arch and amdgpu-arch succeed with other archs.
5961
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpulib -fopenmp=libomp --offload-arch=native,sm_75,gfx1030 \
60-
// RUN: --nvptx-arch-tool=%t/nvptx_arch_sm_70 --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 %s 2>&1 \
62+
// RUN: --offload-arch-tool=%t/offload_arch_sm_70_gfx906 %s 2>&1 \
6163
// RUN: | FileCheck %s --check-prefix=ARCH-MULTIPLE
6264
// ARCH-MULTIPLE: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx1030"
6365
// ARCH-MULTIPLE: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906"

0 commit comments

Comments
 (0)