================
@@ -5229,64 +5210,83 @@ Driver::BuildOffloadingActions(Compilation &C,
llvm::opt::DerivedArgList &Args,
}
}
- // HIP code in device-only non-RDC mode will bundle the output if it invoked
- // the linker or if the user explicitly requested it.
+ // HIP code in device-only non-RDC mode will bundle linked output by default
+ // or bundle any output if the user explicitly requested it.
bool ShouldBundleHIP =
- Args.hasFlag(options::OPT_gpu_bundle_output,
- options::OPT_no_gpu_bundle_output, false) ||
- (!Args.getLastArg(options::OPT_no_gpu_bundle_output) && HIPNoRDC &&
- offloadDeviceOnly() && llvm::none_of(OffloadActions, [](Action *A) {
- return A->getType() != types::TY_Image;
- }));
+ BundleGPUOutput &&
+ (HasGPUOutputBundleOption ||
+ (HIPNoRDC && offloadDeviceOnly() &&
+ (HIPDeviceOnlyNeedsLink || llvm::none_of(OffloadActions, [](Action *A)
{
+ return A->getType() != types::TY_Image;
+ }))));
// All kinds exit now in device-only mode except for non-RDC mode HIP.
- if (offloadDeviceOnly() && !ShouldBundleHIP)
+ if (offloadDeviceOnly() && !ShouldBundleHIP && !HIPDeviceOnlyNeedsLink)
return C.MakeAction<OffloadAction>(DDeps, types::TY_Nothing);
if (OffloadActions.empty())
return HostAction;
OffloadAction::DeviceDependences DDep;
- if (!UsesLLVMOffloading && C.isOffloadingHostKind(Action::OFK_Cuda) &&
- (!Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, false) ||
- Args.hasArg(options::OPT_cuda_emit_nvcc_abi))) {
- // If we are not in RDC-mode or are targeting the NVCC ABI we just emit the
- // final CUDA fatbinary for each translation unit without any linking.
+ if (C.isOffloadingHostKind(Action::OFK_Cuda) &&
+ !Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, false)) {
+ // If we are not in RDC-mode we just emit the final CUDA fatbinary for
+ // each translation unit without requiring any linking.
Action *FatbinAction =
C.MakeAction<LinkJobAction>(OffloadActions, types::TY_CUDA_FATBIN);
DDep.add(*FatbinAction, *C.getSingleOffloadToolChain<Action::OFK_Cuda>(),
/*BA=*/{}, Action::OFK_Cuda);
- } else if (!UsesLLVMOffloading && HIPNoRDC && offloadDeviceOnly()) {
- // If we are in device-only non-RDC-mode we just emit the final HIP
- // fatbinary for each translation unit, linking each input individually.
- Action *FatbinAction =
- C.MakeAction<LinkJobAction>(OffloadActions, types::TY_HIP_FATBIN);
- DDep.add(*FatbinAction,
- *C.getOffloadToolChains<Action::OFK_HIP>().first->second,
- /*BA=*/{}, Action::OFK_HIP);
- } else if (!UsesLLVMOffloading && HIPNoRDC) {
+ } else if (HIPNoRDC) {
// Host + device assembly: defer to clang-offload-bundler (see
// BuildActions).
- if (HIPAsmBundleDeviceOut &&
+ if (!offloadDeviceOnly() && HIPAsmBundleDeviceOut &&
shouldBundleHIPAsmWithNewDriver(C, Args, C.getDriver())) {
for (Action *OA : OffloadActions)
HIPAsmBundleDeviceOut->push_back(OA);
return HostAction;
}
- // Package all the offloading actions into a single output that can be
- // embedded in the host and linked.
- Action *PackagerAction =
- C.MakeAction<OffloadPackagerJobAction>(OffloadActions,
types::TY_Image);
- // For HIP non-RDC compilation, wrap the device binary with linker wrapper
- // before bundling with host code. Do not bind a specific GPU arch here,
- // as the packaged image may contain entries for multiple GPUs.
- ActionList AL{PackagerAction};
- PackagerAction =
- C.MakeAction<LinkerWrapperJobAction>(AL, types::TY_HIP_FATBIN);
- DDep.add(*PackagerAction,
- *C.getOffloadToolChains<Action::OFK_HIP>().first->second,
- /*BA=*/{}, Action::OFK_HIP);
+ Action *DeviceOutputAction;
+ if (offloadDeviceOnly() && !HIPDeviceOnlyNeedsLink) {
----------------
jhuber6 wrote:
Does this need to be this complicated? This was a simple line and now it's a
big mess of control flow and loops. I'm assuming this is a consequence of me
requesting the linker wrapper remain a single output tool? (i.e. like a linker).
Is this immediately necessary? I.e. could we split it into a separate PR if
this is just about getting PGO working under this context?
https://github.com/llvm/llvm-project/pull/211675
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits