[PATCH] D12893: Augmented CudaHostAction to carry device-side triple.
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 15 17:10:40 PDT 2015
tra created this revision.
tra added a reviewer: echristo.
tra added a subscriber: cfe-commits.
Paves the way for the upcoming patch where host-side compilation will need to know device-side triple.
http://reviews.llvm.org/D12893
Files:
include/clang/Driver/Action.h
lib/Driver/Action.cpp
lib/Driver/Driver.cpp
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1247,13 +1247,18 @@
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;
@@ -1291,12 +1296,6 @@
}
}
- // 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;
@@ -1332,7 +1331,7 @@
// 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,
Index: lib/Driver/Action.cpp
===================================================================
--- lib/Driver/Action.cpp
+++ lib/Driver/Action.cpp
@@ -66,8 +66,10 @@
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)
Index: include/clang/Driver/Action.h
===================================================================
--- include/clang/Driver/Action.h
+++ include/clang/Driver/Action.h
@@ -160,14 +160,16 @@
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; }
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12893.34857.patch
Type: text/x-patch
Size: 3727 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150916/d4550ff1/attachment.bin>
More information about the cfe-commits
mailing list