[PATCH] D147941: [Flang][Driver][OpenMP] Enable flags for filtering of offloading passes in flang
Sergio Afonso via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 10 07:11:14 PDT 2023
skatrak created this revision.
skatrak added reviewers: dpalermo, jsjodin, domada, agozillon, TIFitis, awarzynski.
Herald added subscribers: sunshaoce, guansong, yaxunl.
Herald added a reviewer: sscalpone.
Herald added projects: Flang, All.
skatrak requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, jplehr, sstefan1, jdoerfert.
Herald added a project: clang.
This patch adds support for the "--offload-device-only",
"--offload-host-only" and "--offload-host-device" options to the Flang
driver. These can be used to modify the behavior of the driver to select
which compilation passes are triggered during OpenMP offloading.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D147941
Files:
clang/include/clang/Driver/Options.td
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90
flang/test/Driver/omp-frontend-forwarding.f90
Index: flang/test/Driver/omp-frontend-forwarding.f90
===================================================================
--- flang/test/Driver/omp-frontend-forwarding.f90
+++ flang/test/Driver/omp-frontend-forwarding.f90
@@ -7,6 +7,38 @@
! CHECK-OPENMP: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}}.f90"
! CHECK-OPENMP-NOT: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-device" {{.*}}.f90"
+! Test regular -fopenmp with offload, and pass filtering options
+! RUN: %flang -S -### %s -o %t 2>&1 \
+! RUN: -fopenmp --offload-arch=gfx90a \
+! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN: | FileCheck %s --check-prefix=CHECK-OFFLOAD-HOST-DEVICE
+
+! RUN: %flang -S -### %s -o %t 2>&1 \
+! RUN: -fopenmp --offload-arch=gfx90a --offload-host-device \
+! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN: | FileCheck %s --check-prefix=CHECK-OFFLOAD-HOST-DEVICE
+
+! CHECK-OFFLOAD-HOST-DEVICE: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
+! CHECK-OFFLOAD-HOST-DEVICE-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa"
+! CHECK-OFFLOAD-HOST-DEVICE: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
+
+! RUN: %flang -S -### %s -o %t 2>&1 \
+! RUN: -fopenmp --offload-arch=gfx90a --offload-host-only \
+! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN: | FileCheck %s --check-prefix=CHECK-OFFLOAD-HOST
+
+! CHECK-OFFLOAD-HOST: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
+! CHECK-OFFLOAD-HOST-NOT: "-triple" "amdgcn-amd-amdhsa"
+
+! RUN: %flang -S -### %s -o %t 2>&1 \
+! RUN: -fopenmp --offload-arch=gfx90a --offload-device-only \
+! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN: | FileCheck %s --check-prefix=CHECK-OFFLOAD-DEVICE
+
+! CHECK-OFFLOAD-DEVICE: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
+! CHECK-OFFLOAD-DEVICE-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa"
+! CHECK-OFFLOAD-DEVICE-NOT: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
+
! Test regular -fopenmp with offload for basic fopenmp-is-device flag addition and correct fopenmp
! RUN: %flang -### -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa %s 2>&1 | FileCheck --check-prefixes=CHECK-OPENMP-IS-DEVICE %s
! CHECK-OPENMP-IS-DEVICE: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-device" {{.*}}.f90"
Index: flang/test/Driver/driver-help.f90
===================================================================
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -65,6 +65,9 @@
! HELP-NEXT: -mmlir <value> Additional arguments to forward to MLIR's option processing
! HELP-NEXT: -module-dir <dir> Put MODULE files in <dir>
! HELP-NEXT: -nocpp Disable predefined and command line preprocessor macros
+! HELP-NEXT: --offload-device-only Only compile for the offloading device.
+! HELP-NEXT: --offload-host-device Only compile for the offloading host.
+! HELP-NEXT: --offload-host-only Only compile for the offloading host.
! HELP-NEXT: -o <file> Write output to <file>
! HELP-NEXT: -pedantic Warn on language extensions
! HELP-NEXT: -print-effective-triple Print the effective target triple
Index: flang/test/Driver/driver-help-hidden.f90
===================================================================
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -69,6 +69,9 @@
! CHECK-NEXT: -mmlir <value> Additional arguments to forward to MLIR's option processing
! CHECK-NEXT: -module-dir <dir> Put MODULE files in <dir>
! CHECK-NEXT: -nocpp Disable predefined and command line preprocessor macros
+! CHECK-NEXT: --offload-device-only Only compile for the offloading device.
+! CHECK-NEXT: --offload-host-device Only compile for the offloading host.
+! CHECK-NEXT: --offload-host-only Only compile for the offloading host.
! CHECK-NEXT: -o <file> Write output to <file>
! CHECK-NEXT: -pedantic Warn on language extensions
! CHECK-NEXT: -print-effective-triple Print the effective target triple
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2735,11 +2735,11 @@
MarshallingInfoFlag<LangOpts<"OffloadingNewDriver">>, HelpText<"Use the new driver for offloading compilation.">;
def no_offload_new_driver : Flag<["--"], "no-offload-new-driver">, Flags<[CC1Option]>, Group<f_Group>,
HelpText<"Don't Use the new driver for offloading compilation.">;
-def offload_device_only : Flag<["--"], "offload-device-only">,
+def offload_device_only : Flag<["--"], "offload-device-only">, Flags<[CoreOption, FlangOption]>,
HelpText<"Only compile for the offloading device.">;
-def offload_host_only : Flag<["--"], "offload-host-only">,
+def offload_host_only : Flag<["--"], "offload-host-only">, Flags<[CoreOption, FlangOption]>,
HelpText<"Only compile for the offloading host.">;
-def offload_host_device : Flag<["--"], "offload-host-device">,
+def offload_host_device : Flag<["--"], "offload-host-device">, Flags<[CoreOption, FlangOption]>,
HelpText<"Only compile for the offloading host.">;
def cuda_device_only : Flag<["--"], "cuda-device-only">, Alias<offload_device_only>,
HelpText<"Compile CUDA code for device only">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147941.512141.patch
Type: text/x-patch
Size: 5436 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230410/09a33c5e/attachment-0001.bin>
More information about the cfe-commits
mailing list