Debian Codegraph @

flang/test/Transforms/DoConcurrent/locality_specifiers_init_dealloc.mlir

raw
1 // Tests mapping `local` locality specifier to `private` clauses for non-empty
2 // `init` and `dealloc` regions.
3
4 // RUN: fir-opt --omp-do-concurrent-conversion="map-to=host" %s | FileCheck %s
5
6 func.func @my_allocator(%arg0: !fir.ref<!fir.box<!fir.array<10xf32>>>, %arg1: !fir.ref<!fir.box<!fir.array<10xf32>>>) {
7 return
8 }
9
10 func.func @my_deallocator(%arg0: !fir.ref<!fir.box<!fir.array<10xf32>>>) {
11 return
12 }
13
14 fir.local {type = local} @_QFlocal_assocEaa_private_box_10xf32 : !fir.box<!fir.array<10xf32>> init {
15 ^bb0(%arg0: !fir.ref<!fir.box<!fir.array<10xf32>>>, %arg1: !fir.ref<!fir.box<!fir.array<10xf32>>>):
16 fir.call @my_allocator(%arg0, %arg1) : (!fir.ref<!fir.box<!fir.array<10xf32>>>, !fir.ref<!fir.box<!fir.array<10xf32>>>) -> ()
17 fir.yield(%arg1 : !fir.ref<!fir.box<!fir.array<10xf32>>>)
18 } dealloc {
19 ^bb0(%arg0: !fir.ref<!fir.box<!fir.array<10xf32>>>):
20 fir.call @my_deallocator(%arg0) : (!fir.ref<!fir.box<!fir.array<10xf32>>>) -> ()
21 fir.yield
22 }
23
24 func.func @_QPlocal_assoc() {
25 %0 = fir.alloca !fir.box<!fir.array<10xf32>>
26 %c1 = arith.constant 1 : index
27
28 fir.do_concurrent {
29 %9 = fir.alloca i32 {bindc_name = "i"}
30 %10:2 = hlfir.declare %9 {uniq_name = "_QFlocal_assocEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
31 fir.do_concurrent.loop (%arg0) = (%c1) to (%c1) step (%c1) local(@_QFlocal_assocEaa_private_box_10xf32 %0 -> %arg1 : !fir.ref<!fir.box<!fir.array<10xf32>>>) {
32 %11 = fir.convert %arg0 : (index) -> i32
33 fir.store %11 to %10#0 : !fir.ref<i32>
34 }
35 }
36
37 return
38 }
39
40 // CHECK: omp.private {type = private} @[[PRIVATIZER:.*]] : !fir.box<!fir.array<10xf32>> init {
41 // CHECK-NEXT: ^bb0(%[[ORIG_ARG:.*]]: !{{.*}}, %[[PRIV_ARG:.*]]: !{{.*}}):
42 // CHECK-NEXT: fir.call @my_allocator(%[[ORIG_ARG]], %[[PRIV_ARG]]) : ({{.*}}) -> ()
43 // CHECK-NEXT: omp.yield(%[[PRIV_ARG]] : {{.*}})
44 // CHECK-NEXT: } dealloc {
45 // CHECK-NEXT: ^bb0(%[[PRIV_ARG:.*]]: !{{.*}}):
46 // CHECK-NEXT: fir.call @my_deallocator(%[[PRIV_ARG]]) : ({{.*}}) -> ()
47 // CHECK-NEXT: omp.yield
48 // CHECK-NEXT: }
49
50 // CHECK: %[[LOCAL_ALLOC:.*]] = fir.alloca !fir.box<!fir.array<10xf32>>
51 // CHECK: omp.wsloop private(@[[PRIVATIZER]] %[[LOCAL_ALLOC]] -> %{{.*}} : !{{.*}})