[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 14:00:46 PDT 2022

jhuber6 added inline comments.

Comment at: clang/include/clang/Driver/Options.td:2535-2538
+def foffload_device_only : Flag<["-"], "foffload-device-only">,
+  HelpText<"Only compile for the offloading device.">;
+def foffload_host_only : Flag<["-"], "foffload-host-only">,
+  HelpText<"Only compile for the offloading host.">;
tra wrote:
> jhuber6 wrote:
> > tra wrote:
> > > We should probably alias `--cuda-host-only`/`--cuda-device-only` to these.
> > Unfortunately I can't make these a strict alias for `-foffload-host-only`/`-foffload-device-only` without breaking their current usage. I could just check them along with these new versions, but that makes it a little cluttered.
> Could you give me an example why we can use just one set of options to control host-only and device-only compilation?
> Is that because we also have `--cuda-compile-host-device`?
> Or is it because `-f` options have `-fno-` variants to override them, while `--cuda-host/device-only` don't, so we can't just mark them as an alias in Options.td?
> To think of it, those are just facets of the same issue -- difference in the options syntax.
> I do not see semantic differences between the existing options and -foffload-*-only.
> E.g. I believe you could've used --cuda-host-only and --cuda-device-only  instead of -foffload-*-only without the loss of functionality of your patch.
I could have used those options, but this applies in general to the new driver, so it wouldn't be intuitive if we used `--cuda-device-only` when offloading to x86_64 with OpenMP for example. The problem is that the `--cuda-device-only` is already used in the current offloading driver so if I just make it an alias to this option it won't work. I was hoping to avoid touching the old driver, but I guess I could go back and replace all uses of `--cuda-host/device-only` with these new options. Also I did forget to add the `fno-` variants for these and use them correctly. I'm not sure if there's an explicit reason to, but everything else in the OpenMP world uses `-f` prefixes so I'm mostly just sticking with that.

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list