Skip to content

Commit 9971aef

Browse files
authored
[Flang][OpenMP][Driver][Test] Fix the omp-driver-offload-test commands (#66926)
Since the changes to -### to correctly return error codes in D156363, some additions of the not lit keyword and perhaps some changes to how fopenmp-targets is handled; the test omp-driver-offload.f90 has become a little susceptible to what appears to be sporadic failures. This was because if certain environment variables are set for AMD devices some of the commands succeed happily and the not check causes the test to fail. Whereas, if they were not set the tests would fail and the not test would succeed, allowing the test to pass provided you were not targeting AMD hardware while running the test. When the environment variables for AMD hardware are set the compiler could find the correct offload architecture to compile for, allowing the command to succeed. However, when not set it'd fail as it can't detect the offload architecture. The solution to this is to specify an AMD architecture via --offload-arch so it always passes, the architecture doesn't really matter, I've chosen to select gfx90a.
1 parent f2f61a9 commit 9971aef

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

flang/test/Driver/omp-driver-offload.f90

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
! Test that flang-new OpenMP and OpenMP offload related
22
! commands forward or expand to the appropriate commands
3-
! for flang-new -fc1 as expected.
3+
! for flang-new -fc1 as expected. Assumes a gfx90a, aarch64,
4+
! and sm_70 architecture, but doesn't require one to be
5+
! installed or compiled for, just testing the appropriate
6+
! generation of jobs are created with the correct
7+
! corresponding arguments.
48

59
! Test regular -fopenmp with no offload
610
! RUN: %flang -### -fopenmp %s 2>&1 | FileCheck --check-prefixes=CHECK-OPENMP %s
@@ -44,7 +48,7 @@
4448
! OFFLOAD-DEVICE-NOT: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu"
4549

4650
! Test regular -fopenmp with offload for basic fopenmp-is-target-device flag addition and correct fopenmp
47-
! RUN: not %flang -### -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa %s 2>&1 | FileCheck --check-prefixes=CHECK-OPENMP-IS-TARGET-DEVICE %s
51+
! RUN: %flang -### -fopenmp --offload-arch=gfx90a -fopenmp-targets=amdgcn-amd-amdhsa %s 2>&1 | FileCheck --check-prefixes=CHECK-OPENMP-IS-TARGET-DEVICE %s
4852
! CHECK-OPENMP-IS-TARGET-DEVICE: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" {{.*}}.f90"
4953

5054
! Testing appropriate flags are gnerated and appropriately assigned by the driver when offloading
@@ -58,44 +62,51 @@
5862
! OPENMP-OFFLOAD-ARGS-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" {{.*}} "-fopenmp" {{.*}} "-fembed-offload-object={{.*}}.out" {{.*}}.bc"
5963

6064
! Test -fopenmp with offload for RTL Flag Options
61-
! RUN: not %flang -### %s -o %t 2>&1 \
62-
! RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
65+
! RUN: %flang -### %s -o %t 2>&1 \
66+
! RUN: -fopenmp --offload-arch=gfx90a \
67+
! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
6368
! RUN: -fopenmp-assume-threads-oversubscription \
6469
! RUN: | FileCheck %s --check-prefixes=CHECK-THREADS-OVS
6570
! CHECK-THREADS-OVS: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" "-fopenmp-assume-threads-oversubscription" {{.*}}.f90"
6671

67-
! RUN: not %flang -### %s -o %t 2>&1 \
68-
! RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
72+
! RUN: %flang -### %s -o %t 2>&1 \
73+
! RUN: -fopenmp --offload-arch=gfx90a \
74+
! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
6975
! RUN: -fopenmp-assume-teams-oversubscription \
7076
! RUN: | FileCheck %s --check-prefixes=CHECK-TEAMS-OVS
7177
! CHECK-TEAMS-OVS: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" "-fopenmp-assume-teams-oversubscription" {{.*}}.f90"
7278

73-
! RUN: not %flang -### %s -o %t 2>&1 \
74-
! RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
79+
! RUN: %flang -### %s -o %t 2>&1 \
80+
! RUN: -fopenmp --offload-arch=gfx90a \
81+
! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
7582
! RUN: -fopenmp-assume-no-nested-parallelism \
7683
! RUN: | FileCheck %s --check-prefixes=CHECK-NEST-PAR
7784
! CHECK-NEST-PAR: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" "-fopenmp-assume-no-nested-parallelism" {{.*}}.f90"
7885

79-
! RUN: not %flang -### %s -o %t 2>&1 \
80-
! RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
86+
! RUN: %flang -### %s -o %t 2>&1 \
87+
! RUN: -fopenmp --offload-arch=gfx90a \
88+
! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
8189
! RUN: -fopenmp-assume-no-thread-state \
8290
! RUN: | FileCheck %s --check-prefixes=CHECK-THREAD-STATE
8391
! CHECK-THREAD-STATE: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" "-fopenmp-assume-no-thread-state" {{.*}}.f90"
8492

85-
! RUN: not %flang -### %s -o %t 2>&1 \
86-
! RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
93+
! RUN: %flang -### %s -o %t 2>&1 \
94+
! RUN: -fopenmp --offload-arch=gfx90a \
95+
! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
8796
! RUN: -fopenmp-target-debug \
8897
! RUN: | FileCheck %s --check-prefixes=CHECK-TARGET-DEBUG
8998
! CHECK-TARGET-DEBUG: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" "-fopenmp-target-debug" {{.*}}.f90"
9099

91-
! RUN: not %flang -### %s -o %t 2>&1 \
92-
! RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
100+
! RUN: %flang -### %s -o %t 2>&1 \
101+
! RUN: -fopenmp --offload-arch=gfx90a \
102+
! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
93103
! RUN: -fopenmp-target-debug \
94104
! RUN: | FileCheck %s --check-prefixes=CHECK-TARGET-DEBUG
95105
! CHECK-TARGET-DEBUG-EQ: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-target-device" "-fopenmp-target-debug=111" {{.*}}.f90"
96106

97-
! RUN: not %flang -S -### %s -o %t 2>&1 \
98-
! RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
107+
! RUN: %flang -S -### %s -o %t 2>&1 \
108+
! RUN: -fopenmp --offload-arch=gfx90a \
109+
! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
99110
! RUN: -fopenmp-target-debug -fopenmp-assume-threads-oversubscription \
100111
! RUN: -fopenmp-assume-teams-oversubscription -fopenmp-assume-no-nested-parallelism \
101112
! RUN: -fopenmp-assume-no-thread-state \
@@ -104,8 +115,9 @@
104115
! CHECK-RTL-ALL: "-fopenmp-assume-threads-oversubscription" "-fopenmp-assume-no-thread-state" "-fopenmp-assume-no-nested-parallelism"
105116
! CHECK-RTL-ALL: {{.*}}.f90"
106117

107-
! RUN: not %flang -### %s -o %t 2>&1 \
108-
! RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
118+
! RUN: %flang -### %s -o %t 2>&1 \
119+
! RUN: -fopenmp --offload-arch=gfx90a \
120+
! RUN: -fopenmp-targets=amdgcn-amd-amdhsa \
109121
! RUN: -fopenmp-version=45 \
110122
! RUN: | FileCheck %s --check-prefixes=CHECK-OPENMP-VERSION
111123
! CHECK-OPENMP-VERSION: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" "-fopenmp-version=45" {{.*}}.f90"

0 commit comments

Comments
 (0)