This is an archive of the discontinued LLVM Phabricator instance.

[CUDA][HIP] Fix offloading kind for linking C++ programs
ClosedPublic

Authored by yaxunl on Mar 3 2022, 8:06 AM.

Details

Summary

When both CUDA or HIP programs and C++ programs are passed
to clang driver without -c, C++ programs are treated as CUDA
or HIP program, which is incorrect.

This is because action builder sets the offloading kind of input
job actions to the linking action to be the union of offloading
kind of the input job actions, i.e. if there is one HIP or CUDA
input to the linker, then all the input to the linker is marked
as HIP or CUDA.

To fix this issue, the offload action builder tracks the originating
input argument of each host action, which allows it to determine
the active offload kind of each host action. Then the offload
kind of each input action to the linker can be determined
individually.

Diff Detail

Event Timeline

yaxunl created this revision.Mar 3 2022, 8:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2022, 8:06 AM
yaxunl requested review of this revision.Mar 3 2022, 8:06 AM
tra added a comment.Mar 3 2022, 9:58 AM

We should probably also check what happens when we specify compilation language explicitly: E.g. clang -x cuda a.cu -x c++ b.cc, clang -x cuda a.cu b.cc and clang a.cu -x cuda b.cc.

yaxunl updated this revision to Diff 412989.Mar 4 2022, 5:20 AM

add more tests

tra accepted this revision.Mar 4 2022, 9:56 AM
This revision is now accepted and ready to land.Mar 4 2022, 9:56 AM
This revision was landed with ongoing or failed builds.Mar 4 2022, 12:57 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 4 2022, 12:57 PM