[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
Wed Apr 27 12:37:06 PDT 2022


jhuber6 added inline comments.


================
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:
> jhuber6 wrote:
> > 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.
> I guess the general idea is to avoid the ambiguity about what controls the behavior of the function. Is that the `Args`, or the `HostAction`?
> Ideally I'd prefer to parse command line options once, save results somewhere we could use them and then use those flargs to control the behavior, regardless of which options were used to specify it. E.g. CUDA/HIPActionBuilder classes have these member fields:
> ```
>   bool CompileHostOnly = false;
>   bool CompileDeviceOnly = false;
> 
> ...
>       Arg *PartialCompilationArg = Args.getLastArg(
>           options::OPT_cuda_host_only, options::OPT_cuda_device_only,
>           options::OPT_cuda_compile_host_device);
>       CompileHostOnly = PartialCompilationArg &&
>                         PartialCompilationArg->getOption().matches(
>                             options::OPT_cuda_host_only);
>       CompileDeviceOnly = PartialCompilationArg &&
>                           PartialCompilationArg->getOption().matches(
>                               options::OPT_cuda_device_only);
> ...
> ```
> 
I more or less copied that below, but I suppose we are recalculating them each phase. We don't have a monolithic class with my new implementation, but I suppose I could add these to the Compilation or something if we don't want to recalculate it. Beside that, does anything else seem amiss?


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