This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Change default triple to LLVM_HOST_TRIPLE for the CUDA toolchain
ClosedPublic

Authored by jhuber6 on May 8 2023, 12:06 PM.

Details

Summary

When cross-compiling NVPTX we use the triple to indicate which paths to
search for the CUDA toolchain. Currently this uses the default target
triple. This might not be exactly correct, as this is the default triple
used to compile binaries, not the host system. We want the host triple
because it indicates which folders should hold CUDA.

Diff Detail

Event Timeline

jhuber6 created this revision.May 8 2023, 12:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 8 2023, 12:06 PM
Herald added a subscriber: mattd. · View Herald Transcript
jhuber6 requested review of this revision.May 8 2023, 12:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 8 2023, 12:06 PM
tra added a comment.May 8 2023, 12:29 PM

The change may be an improvement, but we may still have a potential issue here.

E.g. ideally we may want to be able to cross-compile a CUDA app on a powerpc or ARM build host targeting NVIDIA GPU on a x86 host. So, the compilation tools would need to be found for the powerpc/arm host, but the the pair of triples used during compilation would have to be x86 and nvptx.

In this situation the LLVM_HOST_TRIPLE would not be the right triple at all. Does OpenMP currently handle the cross-compilation scenario above?

The change may be an improvement, but we may still have a potential issue here.

E.g. ideally we may want to be able to cross-compile a CUDA app on a powerpc or ARM build host targeting NVIDIA GPU on a x86 host. So, the compilation tools would need to be found for the powerpc/arm host, but the the pair of triples used during compilation would have to be x86 and nvptx.

So, this triple is only used for locating the CUDA library itself. In that case it's generally assumed that it will match whatever file structure the host computer is using. Specifically, right now all it's used for is HostTriple.isOSWindows().

In this situation the LLVM_HOST_TRIPLE would not be the right triple at all. Does OpenMP currently handle the cross-compilation scenario above?

I don't think anyone's tried OpenMP with cross compilation. Most likely because it's only supported on Linux currently. I actually don't know what would happen if you tried.

tra accepted this revision.May 8 2023, 12:58 PM

right now all it's used for is HostTriple.isOSWindows()

OK.

In that case we may want to rename the parameter to BuildHostTriple to make it clear which host we have in mind.

This revision is now accepted and ready to land.May 8 2023, 12:58 PM
This revision was landed with ongoing or failed builds.May 8 2023, 1:55 PM
This revision was automatically updated to reflect the committed changes.