forked from OSchip/llvm-project
[OpenMP] Customize CUDA-based tool chain selection
Summary: This patch provides a generic way of selecting CUDA based tool chains as host-device pairs. Reviewers: arpith-jacob, caomhin, carlo.bertolli, ABataev, Hahnfeld, jlebar, hfinkel, tstellar Reviewed By: Hahnfeld Subscribers: rengolin, cfe-commits Differential Revision: https://reviews.llvm.org/D29658 llvm-svn: 307271
This commit is contained in:
parent
3e1909d797
commit
6a5df72a82
|
@ -572,8 +572,22 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
|
|||
if (TT.getArch() == llvm::Triple::UnknownArch)
|
||||
Diag(clang::diag::err_drv_invalid_omp_target) << Val;
|
||||
else {
|
||||
const ToolChain &TC = getToolChain(C.getInputArgs(), TT);
|
||||
C.addOffloadDeviceToolChain(&TC, Action::OFK_OpenMP);
|
||||
const ToolChain *TC;
|
||||
// CUDA toolchains have to be selected differently. They pair host
|
||||
// and device in their implementation.
|
||||
if (TT.isNVPTX()) {
|
||||
const ToolChain *HostTC =
|
||||
C.getSingleOffloadToolChain<Action::OFK_Host>();
|
||||
assert(HostTC && "Host toolchain should be always defined.");
|
||||
auto &CudaTC =
|
||||
ToolChains[TT.str() + "/" + HostTC->getTriple().str()];
|
||||
if (!CudaTC)
|
||||
CudaTC = llvm::make_unique<toolchains::CudaToolChain>(
|
||||
*this, TT, *HostTC, C.getInputArgs());
|
||||
TC = CudaTC.get();
|
||||
} else
|
||||
TC = &getToolChain(C.getInputArgs(), TT);
|
||||
C.addOffloadDeviceToolChain(TC, Action::OFK_OpenMP);
|
||||
}
|
||||
}
|
||||
} else
|
||||
|
|
Loading…
Reference in New Issue