Skip to content

Commit e2e4328

Browse files
ergawyronlieb
authored andcommitted
[flang][OpenMP] Update do concurrent mapping pass to use fir.do_concurrent op
This PR updates the `do concurrent` to OpenMP mapping pass to use the newly added `fir.do_concurrent` ops that were recently added upstream instead of handling nests of `fir.do_loop ... unordered` ops. Parent PR: https://github.com/AMD-Lightning-Internal/llvm-project/pull/1919.
1 parent 6e32000 commit e2e4328

12 files changed

+140
-442
lines changed

flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp

Lines changed: 91 additions & 285 deletions
Large diffs are not rendered by default.

flang/test/Transforms/DoConcurrent/basic_device.mlir

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: fir-opt --omp-do-concurrent-conversion="map-to=device" %s -o - | FileCheck %s
22

33
func.func @do_concurrent_basic() attributes {fir.bindc_name = "do_concurrent_basic"} {
4-
%0 = fir.alloca i32 {bindc_name = "i"}
5-
%1:2 = hlfir.declare %0 {uniq_name = "_QFEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
64
%2 = fir.address_of(@_QFEa) : !fir.ref<!fir.array<10xi32>>
75
%c10 = arith.constant 10 : index
86
%3 = fir.shape %c10 : (index) -> !fir.shape<1>
@@ -19,14 +17,18 @@ func.func @do_concurrent_basic() attributes {fir.bindc_name = "do_concurrent_bas
1917
// CHECK: omp.distribute
2018
// CHECK: omp.wsloop
2119
// CHECK: omp.loop_nest
22-
fir.do_loop %arg0 = %7 to %8 step %c1 unordered {
23-
%13 = fir.convert %arg0 : (index) -> i32
24-
fir.store %13 to %1#1 : !fir.ref<i32>
25-
%14 = fir.load %1#0 : !fir.ref<i32>
26-
%15 = fir.load %1#0 : !fir.ref<i32>
27-
%16 = fir.convert %15 : (i32) -> i64
28-
%17 = hlfir.designate %4#0 (%16) : (!fir.ref<!fir.array<10xi32>>, i64) -> !fir.ref<i32>
29-
hlfir.assign %14 to %17 : i32, !fir.ref<i32>
20+
fir.do_concurrent {
21+
%0 = fir.alloca i32 {bindc_name = "i"}
22+
%1:2 = hlfir.declare %0 {uniq_name = "_QFEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
23+
fir.do_concurrent.loop (%arg0) = (%7) to (%8) step (%c1) {
24+
%13 = fir.convert %arg0 : (index) -> i32
25+
fir.store %13 to %1#1 : !fir.ref<i32>
26+
%14 = fir.load %1#0 : !fir.ref<i32>
27+
%15 = fir.load %1#0 : !fir.ref<i32>
28+
%16 = fir.convert %15 : (i32) -> i64
29+
%17 = hlfir.designate %4#0 (%16) : (!fir.ref<!fir.array<10xi32>>, i64) -> !fir.ref<i32>
30+
hlfir.assign %14 to %17 : i32, !fir.ref<i32>
31+
}
3032
}
3133

3234
return

flang/test/Transforms/DoConcurrent/basic_host.f90

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
! Fails until we update the pass to use the `fir.do_concurrent` op.
2-
! XFAIL: *
3-
41
! Tests mapping of a basic `do concurrent` loop to `!$omp parallel do`.
52

63
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fdo-concurrent-to-openmp=host %s -o - \

flang/test/Transforms/DoConcurrent/basic_host.mlir

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
func.func @do_concurrent_basic() attributes {fir.bindc_name = "do_concurrent_basic"} {
77
// CHECK: %[[ARR:.*]]:2 = hlfir.declare %{{.*}}(%{{.*}}) {uniq_name = "_QFEa"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
88

9-
%0 = fir.alloca i32 {bindc_name = "i"}
10-
%1:2 = hlfir.declare %0 {uniq_name = "_QFEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
119
%2 = fir.address_of(@_QFEa) : !fir.ref<!fir.array<10xi32>>
1210
%c10 = arith.constant 10 : index
1311
%3 = fir.shape %c10 : (index) -> !fir.shape<1>
@@ -46,14 +44,18 @@ func.func @do_concurrent_basic() attributes {fir.bindc_name = "do_concurrent_bas
4644

4745
// CHECK-NEXT: omp.terminator
4846
// CHECK-NEXT: }
49-
fir.do_loop %arg0 = %7 to %8 step %c1 unordered {
50-
%13 = fir.convert %arg0 : (index) -> i32
51-
fir.store %13 to %1#1 : !fir.ref<i32>
52-
%14 = fir.load %1#0 : !fir.ref<i32>
53-
%15 = fir.load %1#0 : !fir.ref<i32>
54-
%16 = fir.convert %15 : (i32) -> i64
55-
%17 = hlfir.designate %4#0 (%16) : (!fir.ref<!fir.array<10xi32>>, i64) -> !fir.ref<i32>
56-
hlfir.assign %14 to %17 : i32, !fir.ref<i32>
47+
fir.do_concurrent {
48+
%0 = fir.alloca i32 {bindc_name = "i"}
49+
%1:2 = hlfir.declare %0 {uniq_name = "_QFEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
50+
fir.do_concurrent.loop (%arg0) = (%7) to (%8) step (%c1) {
51+
%13 = fir.convert %arg0 : (index) -> i32
52+
fir.store %13 to %1#1 : !fir.ref<i32>
53+
%14 = fir.load %1#0 : !fir.ref<i32>
54+
%15 = fir.load %1#0 : !fir.ref<i32>
55+
%16 = fir.convert %15 : (i32) -> i64
56+
%17 = hlfir.designate %4#0 (%16) : (!fir.ref<!fir.array<10xi32>>, i64) -> !fir.ref<i32>
57+
hlfir.assign %14 to %17 : i32, !fir.ref<i32>
58+
}
5759
}
5860

5961
// CHECK-NOT: fir.do_loop

flang/test/Transforms/DoConcurrent/host_eval.f90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ end program do_concurrent_host_eval
3232
! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[I_LB_MAP:[^,]+]],
3333
! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[I_UB_MAP:[^,]+]],
3434
! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[I_ST_MAP:[^,]+]],
35-
! DEVICE-SAME: %{{[^[:space:]]+}} -> %{{[^,]+}},
36-
! DEVICE-SAME: %{{[^[:space:]]+}} -> %{{[^,]+}},
35+
3736
! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[J_LB_MAP:[^,]+]],
3837
! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[J_UB_MAP:[^,]+]],
39-
! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[J_ST_MAP:[^,]+]] : {{.*}})
38+
! DEVICE-SAME: %{{[^[:space:]]+}} -> %[[J_ST_MAP:[^,]+]],
39+
40+
! DEVICE-SAME: %{{[^[:space:]]+}} -> %{{[^,]+}},
41+
! DEVICE-SAME: %{{[^[:space:]]+}} -> %{{[^,]+}} : {{.*}})
4042

4143
! DEVICE: %[[I_LB_DECL:.*]]:2 = hlfir.declare %[[I_LB_MAP]]
4244
! DEVICE: %[[I_LB:.*]] = fir.load %[[I_LB_DECL]]#1 : !fir.ref<index>

flang/test/Transforms/DoConcurrent/locally_destroyed_temp.f90

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
! Fails until we update the pass to use the `fir.do_concurrent` op.
2-
! XFAIL: *
3-
41
! Tests that "loop-local values" are properly handled by localizing them to the
52
! body of the loop nest. See `collectLoopLocalValues` and `localizeLoopLocalValue`
63
! for a definition of "loop-local values" and how they are handled.

flang/test/Transforms/DoConcurrent/loop_nest_test.f90

Lines changed: 0 additions & 92 deletions
This file was deleted.

flang/test/Transforms/DoConcurrent/map_shape_info.f90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
! Tests mapping of a basic `do concurrent` loop to
32
! `!$omp target teams distribute parallel do`.
43

flang/test/Transforms/DoConcurrent/multiple_iteration_ranges.f90

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
! Fails until we update the pass to use the `fir.do_concurrent` op.
2-
! XFAIL: *
3-
41
! Tests mapping of a `do concurrent` loop with multiple iteration ranges.
52

63
! RUN: split-file %s %t

flang/test/Transforms/DoConcurrent/non_const_bounds.f90

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
! Fails until we update the pass to use the `fir.do_concurrent` op.
2-
! XFAIL: *
3-
41
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fdo-concurrent-to-openmp=host %s -o - \
52
! RUN: | FileCheck %s
63

0 commit comments

Comments
 (0)