[PATCH] D124220: [OpenMP] Add options to only compile the host or device when offloading

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 26 16:46:14 PDT 2022


tra added inline comments.


================
Comment at: clang/include/clang/Driver/Options.td:2527
   HelpText<"Use the static host OpenMP runtime while linking.">;
+def offload_device_only : Flag<["-"], "offload-device-only">,
+  HelpText<"Only compile for the offloading device.">;
----------------
We should be using "--" for the new options.


================
Comment at: clang/lib/Driver/Driver.cpp:4205
 
   // Claim --cuda-host-only and --cuda-compile-host-device, which may be passed
   // to non-CUDA compilations and should not trigger warnings there.
----------------
Comment may need updating.


================
Comment at: clang/lib/Driver/Driver.cpp:4215
                                        Action *HostAction) const {
-  if (!isa<CompileJobAction>(HostAction))
+  if (Args.hasArg(options::OPT_offload_host_only))
     return HostAction;
----------------
This will not always be correct. E.g. `--offload-host-only --offload-host-device` would be true here, but we would still want to compile for both and device.

Is there a reason we can no longer rely on `HostAction`?


================
Comment at: clang/lib/Driver/Driver.cpp:4223
+
+  if (!isa<CompileJobAction>(HostAction) && PL.back() != phases::Preprocess)
+    return HostAction;
----------------
This could use a comment. I don't quite understand what we're doing here and why.
Only doing host-side preprocessing  if -E is passed?


================
Comment at: clang/lib/Driver/Driver.cpp:4278
 
+  if (Args.hasArg(options::OPT_offload_device_only))
+    return C.MakeAction<OffloadAction>(DDeps, types::TY_Nothing);
----------------
Same problem as with the host-checking above.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124220/new/

https://reviews.llvm.org/D124220



More information about the cfe-commits mailing list