r248298 - Augmented CudaHostAction to carry device-side triple.
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 22 10:23:13 PDT 2015
Author: tra
Date: Tue Sep 22 12:23:13 2015
New Revision: 248298
URL: http://llvm.org/viewvc/llvm-project?rev=248298&view=rev
Log:
Augmented CudaHostAction to carry device-side triple.
Differential Revision: http://reviews.llvm.org/D12893
Modified:
cfe/trunk/include/clang/Driver/Action.h
cfe/trunk/lib/Driver/Action.cpp
cfe/trunk/lib/Driver/Driver.cpp
Modified: cfe/trunk/include/clang/Driver/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=248298&r1=248297&r2=248298&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Action.h (original)
+++ cfe/trunk/include/clang/Driver/Action.h Tue Sep 22 12:23:13 2015
@@ -160,14 +160,16 @@ public:
class CudaHostAction : public Action {
virtual void anchor();
ActionList DeviceActions;
+ const char *DeviceTriple;
public:
- CudaHostAction(std::unique_ptr<Action> Input,
- const ActionList &DeviceActions);
+ CudaHostAction(std::unique_ptr<Action> Input, const ActionList &DeviceActions,
+ const char *DeviceTriple);
~CudaHostAction() override;
ActionList &getDeviceActions() { return DeviceActions; }
const ActionList &getDeviceActions() const { return DeviceActions; }
+ const char *getDeviceTriple() const { return DeviceTriple; }
static bool classof(const Action *A) { return A->getKind() == CudaHostClass; }
};
Modified: cfe/trunk/lib/Driver/Action.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Action.cpp?rev=248298&r1=248297&r2=248298&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Action.cpp (original)
+++ cfe/trunk/lib/Driver/Action.cpp Tue Sep 22 12:23:13 2015
@@ -66,8 +66,10 @@ CudaDeviceAction::CudaDeviceAction(std::
void CudaHostAction::anchor() {}
CudaHostAction::CudaHostAction(std::unique_ptr<Action> Input,
- const ActionList &DeviceActions)
- : Action(CudaHostClass, std::move(Input)), DeviceActions(DeviceActions) {}
+ const ActionList &DeviceActions,
+ const char *DeviceTriple)
+ : Action(CudaHostClass, std::move(Input)), DeviceActions(DeviceActions),
+ DeviceTriple(DeviceTriple) {}
CudaHostAction::~CudaHostAction() {
for (auto &DA : DeviceActions)
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=248298&r1=248297&r2=248298&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Sep 22 12:23:13 2015
@@ -1246,13 +1246,18 @@ static std::unique_ptr<Action>
buildCudaActions(const Driver &D, const ToolChain &TC, DerivedArgList &Args,
const Arg *InputArg, std::unique_ptr<Action> HostAction,
ActionList &Actions) {
+ // Figure out which NVPTX triple to use for device-side compilation based on
+ // whether host is 64-bit.
+ const char *DeviceTriple = TC.getTriple().isArch64Bit()
+ ? "nvptx64-nvidia-cuda"
+ : "nvptx-nvidia-cuda";
Arg *PartialCompilationArg = Args.getLastArg(options::OPT_cuda_host_only,
options::OPT_cuda_device_only);
// Host-only compilation case.
if (PartialCompilationArg &&
PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only))
return std::unique_ptr<Action>(
- new CudaHostAction(std::move(HostAction), {}));
+ new CudaHostAction(std::move(HostAction), {}, DeviceTriple));
// Collect all cuda_gpu_arch parameters, removing duplicates.
SmallVector<const char *, 4> GpuArchList;
@@ -1290,12 +1295,6 @@ buildCudaActions(const Driver &D, const
}
}
- // Figure out which NVPTX triple to use for device-side compilation based on
- // whether host is 64-bit.
- const char *DeviceTriple = TC.getTriple().isArch64Bit()
- ? "nvptx64-nvidia-cuda"
- : "nvptx-nvidia-cuda";
-
// Figure out what to do with device actions -- pass them as inputs to the
// host action or run each of them independently.
bool DeviceOnlyCompilation = PartialCompilationArg != nullptr;
@@ -1331,7 +1330,7 @@ buildCudaActions(const Driver &D, const
// Return a new host action that incorporates original host action and all
// device actions.
return std::unique_ptr<Action>(
- new CudaHostAction(std::move(HostAction), DeviceActions));
+ new CudaHostAction(std::move(HostAction), DeviceActions, DeviceTriple));
}
void Driver::BuildActions(const ToolChain &TC, DerivedArgList &Args,
More information about the cfe-commits
mailing list