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

Joseph Huber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 26 16:49:14 PDT 2022


jhuber6 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.">;
----------------
tra wrote:
> We should be using "--" for the new options.
What's the reason for preferring `--` over `-`? Is it just because `-o` can bind to output?


================
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;
----------------
tra wrote:
> 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`?
Guess I should just use the last argument. Host action is used below, can probably merge these if statements.


================
Comment at: clang/lib/Driver/Driver.cpp:4223
+
+  if (!isa<CompileJobAction>(HostAction) && PL.back() != phases::Preprocess)
+    return HostAction;
----------------
tra wrote:
> 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?
OpenMP requires host IR for the device compile, but `-E` doesn't generate one, but we don't use it for preprocessing.


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