This is an archive of the discontinued LLVM Phabricator instance.

[Clang][clang-nvlink-wrapper] Pass nvlink path to the wrapper
ClosedPublic

Authored by saiislam on Oct 9 2021, 5:14 AM.

Details

Summary

Added support of a "--nvlink-path=" option in clang-nvlink-wrapper which
takes the path of nvlink binary.

Static Device Library support for OpenMP (D105191) now searches for
nvlink binary and passes its location via this option. In absence
of this option, nvlink binary is searched in locations in PATH.

Diff Detail

Event Timeline

saiislam requested review of this revision.Oct 9 2021, 5:14 AM
saiislam created this revision.
Herald added a project: Restricted Project. · View Herald Transcript
Meinersbur requested changes to this revision.Oct 9 2021, 5:49 PM

Thanks for the path, but command line parsing should be done properly.

clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp
51

I suggest a more descriptive flag, path is too general, like --nvlink or --nvlink-command (bugpoint uses --opt-command for the path to opt)

124

[nit] unrelated whitespace change

151

cl::ParseCommandLineOptions(argc, argv,"Program description") must have been called beforehand to make this work.

171

This way of parsing does not use the declared NvlinkUserPath option. Use cl::ParseCommandLineOptions do parse the arguments and

cl::list<std::string> InputFiles(cl::Positional, cl::desc("<input files>..."));

to catch all non-option arguments.

The way it is done here also does not catch the --path <nvlink> (without equal sign) syntax.

This revision now requires changes to proceed.Oct 9 2021, 5:49 PM
saiislam updated this revision to Diff 378630.Oct 11 2021, 5:05 AM
saiislam marked 4 inline comments as done.
  1. Changed the option from path to nvlink-command.
  2. Command line arguments are now parsed using proper API.
saiislam edited the summary of this revision. (Show Details)Oct 11 2021, 5:06 AM
saiislam updated this revision to Diff 378633.Oct 11 2021, 5:11 AM

Fixed typo

Meinersbur accepted this revision.Oct 11 2021, 10:25 AM

Some nitpicks, but it fixes the build, so LGTM.

clang/lib/Driver/ToolChains/Cuda.cpp
617

[style] LLVM's coding standard does not use almost-always-auto.

It's not immediately obvious here, does GetProgramPath look into the BinPath detected by CudaInstallationDetector? I applied the patch locally to http://meinersbur.de:8011/#/builders/1 and it actually does work.

clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp
169–170
This revision is now accepted and ready to land.Oct 11 2021, 10:25 AM
tra added a subscriber: tra.Oct 11 2021, 10:44 AM
tra added inline comments.
clang/lib/Driver/ToolChains/Cuda.cpp
620

Nit: the variables above are used only once. It would be fine to just push_back(MakeArgString(GetProgramPath())).

clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp
50

Nit. Clang already has --ptxas-path= option. It may be worth using -path suffix here for consistency, too.

169–170

Nit: for (const std::string &Arg : NVArgs) to avoid unnecessary copies.

saiislam updated this revision to Diff 378978.Oct 12 2021, 5:14 AM
saiislam marked 5 inline comments as done.

Thanks, Michael and Artem!

  1. Changed nvlink-command to nvlink-path.
  2. Answered queries and done refactoring as suggested.
saiislam edited the summary of this revision. (Show Details)Oct 12 2021, 5:14 AM
saiislam updated this revision to Diff 378979.Oct 12 2021, 5:16 AM

clang-format(ed).

Meinersbur accepted this revision.Oct 12 2021, 8:59 AM
saiislam added inline comments.Oct 12 2021, 9:16 AM
clang/lib/Driver/ToolChains/Cuda.cpp
617

Yes, you are right. CudaToolChain constructor initializes binary paths obtained from CudaInstallationDetector which is used by this call.

clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp
50

changed it to --nvlink-path