Skip to content

Commit 3cf2546

Browse files
author
Justin Lebar
committedDec 15, 2016
[CUDA] Add --ptxas-path= flag.
Summary: This lets you build with one CUDA installation but use ptxas from another install. This is useful e.g. if you want to avoid bugs in an old ptxas without actually upgrading wholesale to a newer CUDA version. Reviewers: tra Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27788 llvm-svn: 289847
1 parent a97358b commit 3cf2546

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed
 

‎clang/include/clang/Driver/Options.td

+2
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ def no_cuda_version_check : Flag<["--"], "no-cuda-version-check">,
425425
def no_cuda_noopt_device_debug : Flag<["--"], "no-cuda-noopt-device-debug">;
426426
def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group<i_Group>,
427427
HelpText<"CUDA installation path">;
428+
def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group<i_Group>,
429+
HelpText<"Path to ptxas (used for compiling CUDA code)">;
428430
def fcuda_flush_denormals_to_zero : Flag<["-"], "fcuda-flush-denormals-to-zero">,
429431
Flags<[CC1Option]>, HelpText<"Flush denormal floating point values to zero in CUDA device mode.">;
430432
def fno_cuda_flush_denormals_to_zero : Flag<["-"], "fno-cuda-flush-denormals-to-zero">;

‎clang/lib/Driver/Tools.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -12105,7 +12105,11 @@ void NVPTX::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
1210512105
for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
1210612106
CmdArgs.push_back(Args.MakeArgString(A));
1210712107

12108-
const char *Exec = Args.MakeArgString(TC.GetProgramPath("ptxas"));
12108+
const char *Exec;
12109+
if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
12110+
Exec = A->getValue();
12111+
else
12112+
Exec = Args.MakeArgString(TC.GetProgramPath("ptxas"));
1210912113
C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
1211012114
}
1211112115

‎clang/test/Driver/cuda-ptxas-path.cu

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// REQUIRES: clang-driver
2+
// REQUIRES: x86-registered-target
3+
// REQUIRES: nvptx-registered-target
4+
5+
// RUN: %clang -### --target=i386-unknown-linux \
6+
// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
7+
// RUN: --ptxas-path=/some/path/to/ptxas %s 2>&1 \
8+
// RUN: | FileCheck %s
9+
10+
// CHECK-NOT: "ptxas"
11+
// CHECK: "/some/path/to/ptxas"
12+
// CHECK-SAME: "--gpu-name" "sm_20"

0 commit comments

Comments
 (0)
Please sign in to comment.