[PATCH] [cuda] Driver changes to build and stitch together host and device-side CUDA code.

Eric Christopher echristo at gmail.com
Wed May 6 11:36:52 PDT 2015


Mostly requests for comments etc.

This is terrible, I just don't have any better ideas. :)

-eric


================
Comment at: include/clang/Driver/Action.h:142
@@ +141,3 @@
+  const char *GpuArchName;
+  bool AtTopLevel;
+
----------------
AtTopLevel needs to be documented more. It's not clear. Also the usage below.

================
Comment at: lib/Driver/Driver.cpp:1171
@@ -1152,1 +1170,3 @@
 
+// For eash unique --cuda-gpu-arch= argument creates a TY_CUDA_DEVICE input
+// action and then wraps each in CudaDeviceAction paired with appropriate GPU
----------------
"For each"

================
Comment at: lib/Driver/Driver.cpp:1199-1240
@@ +1198,44 @@
+
+  Driver::InputList CudaDeviceInputs;
+  for (unsigned i = 0, e = GpuArchList.size(); i != e; ++i)
+    CudaDeviceInputs.push_back(std::make_pair(types::TY_CUDA_DEVICE, InputArg));
+
+  ActionList CudaDeviceActions;
+  D.BuildActions(TC, Args, CudaDeviceInputs, CudaDeviceActions);
+  assert(GpuArchList.size() == CudaDeviceActions.size() &&
+         "Failed to create actions for all devices");
+
+  bool PartialCompilation = false;
+  bool DeviceOnlyCompilation = Args.hasArg(options::OPT_cuda_device_only);
+  for (unsigned i = 0, e = GpuArchList.size(); i != e; ++i) {
+    if (CudaDeviceActions[i]->getKind() != Action::BackendJobClass) {
+      PartialCompilation = true;
+      break;
+    }
+  }
+
+  if (PartialCompilation || DeviceOnlyCompilation) {
+    // If -o specified we can only work if it's device-only compilation for a
+    // single device.
+    if (Args.hasArg(options::OPT_o) &&
+        (!DeviceOnlyCompilation || GpuArchList.size() > 1)) {
+      D.Diag(clang::diag::err_drv_output_argument_with_multiple_files);
+      return nullptr;
+    }
+    for (unsigned i = 0, e = GpuArchList.size(); i != e; ++i)
+      Actions.push_back(new CudaDeviceAction(
+          std::unique_ptr<Action>(CudaDeviceActions[i]), GpuArchList[i], true));
+    if (DeviceOnlyCompilation)
+      Current.reset(nullptr);
+    return Current;
+  } else {
+    ActionList CudaDeviceJobActions;
+    for (unsigned i = 0, e = GpuArchList.size(); i != e; ++i)
+      CudaDeviceJobActions.push_back(
+          new CudaDeviceAction(std::unique_ptr<Action>(CudaDeviceActions[i]),
+                               GpuArchList[i], false));
+    return std::unique_ptr<Action>(
+        new CudaHostAction(std::move(Current), CudaDeviceJobActions));
+  }
+}
+
----------------
Needs some overarching documentation.

================
Comment at: tools/libclang/CIndex.cpp:3031
@@ -3030,1 +3030,3 @@
 
+  if (!Unit && !ErrUnit) {
+    PTUI->result = CXError_ASTReadError;
----------------
Comment.

http://reviews.llvm.org/D9509

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list