jlebar created this revision. jlebar added a reviewer: tra. jlebar added a subscriber: cfe-commits.
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. https://reviews.llvm.org/D27788 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/Tools.cpp clang/test/Driver/cuda-ptxas-path.cu Index: clang/test/Driver/cuda-ptxas-path.cu =================================================================== --- /dev/null +++ clang/test/Driver/cuda-ptxas-path.cu @@ -0,0 +1,12 @@ +// REQUIRES: clang-driver +// REQUIRES: x86-registered-target +// REQUIRES: nvptx-registered-target + +// RUN: %clang -### --target=i386-unknown-linux \ +// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \ +// RUN: --ptxas-path=/some/path/to/ptxas %s 2>&1 \ +// RUN: | FileCheck %s + +// CHECK-NOT: "ptxas" +// CHECK: "/some/path/to/ptxas" +// CHECK-SAME: "--gpu-name" "sm_20" Index: clang/lib/Driver/Tools.cpp =================================================================== --- clang/lib/Driver/Tools.cpp +++ clang/lib/Driver/Tools.cpp @@ -12075,7 +12075,11 @@ for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas)) CmdArgs.push_back(Args.MakeArgString(A)); - const char *Exec = Args.MakeArgString(TC.GetProgramPath("ptxas")); + const char *Exec; + if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ)) + Exec = A->getValue(); + else + Exec = Args.MakeArgString(TC.GetProgramPath("ptxas")); C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs)); } Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -425,6 +425,8 @@ def no_cuda_noopt_device_debug : Flag<["--"], "no-cuda-noopt-device-debug">; def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group<i_Group>, HelpText<"CUDA installation path">; +def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group<i_Group>, + HelpText<"Path to ptxas (used for compiling CUDA code)">; def fcuda_flush_denormals_to_zero : Flag<["-"], "fcuda-flush-denormals-to-zero">, Flags<[CC1Option]>, HelpText<"Flush denormal floating point values to zero in CUDA device mode.">; def fno_cuda_flush_denormals_to_zero : Flag<["-"], "fno-cuda-flush-denormals-to-zero">;
Index: clang/test/Driver/cuda-ptxas-path.cu =================================================================== --- /dev/null +++ clang/test/Driver/cuda-ptxas-path.cu @@ -0,0 +1,12 @@ +// REQUIRES: clang-driver +// REQUIRES: x86-registered-target +// REQUIRES: nvptx-registered-target + +// RUN: %clang -### --target=i386-unknown-linux \ +// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \ +// RUN: --ptxas-path=/some/path/to/ptxas %s 2>&1 \ +// RUN: | FileCheck %s + +// CHECK-NOT: "ptxas" +// CHECK: "/some/path/to/ptxas" +// CHECK-SAME: "--gpu-name" "sm_20" Index: clang/lib/Driver/Tools.cpp =================================================================== --- clang/lib/Driver/Tools.cpp +++ clang/lib/Driver/Tools.cpp @@ -12075,7 +12075,11 @@ for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas)) CmdArgs.push_back(Args.MakeArgString(A)); - const char *Exec = Args.MakeArgString(TC.GetProgramPath("ptxas")); + const char *Exec; + if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ)) + Exec = A->getValue(); + else + Exec = Args.MakeArgString(TC.GetProgramPath("ptxas")); C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs)); } Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -425,6 +425,8 @@ def no_cuda_noopt_device_debug : Flag<["--"], "no-cuda-noopt-device-debug">; def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group<i_Group>, HelpText<"CUDA installation path">; +def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group<i_Group>, + HelpText<"Path to ptxas (used for compiling CUDA code)">; def fcuda_flush_denormals_to_zero : Flag<["-"], "fcuda-flush-denormals-to-zero">, Flags<[CC1Option]>, HelpText<"Flush denormal floating point values to zero in CUDA device mode.">; def fno_cuda_flush_denormals_to_zero : Flag<["-"], "fno-cuda-flush-denormals-to-zero">;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits