Debian Codegraph @

flang/test/Lower/OpenMP/delayed-privatization-array.f90

raw
1 ! Test delayed privatization for arrays.
2
3 ! RUN: split-file %s %t
4
5 ! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --openmp-enable-delayed-privatization \
6 ! RUN: -o - %t/one_dim_array.f90 2>&1 | FileCheck %s --check-prefix=ONE_DIM
7 ! RUN: bbc -emit-hlfir -fopenmp --openmp-enable-delayed-privatization -o - \
8 ! RUN: %t/one_dim_array.f90 2>&1 | FileCheck %s --check-prefix=ONE_DIM
9
10 ! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --openmp-enable-delayed-privatization \
11 ! RUN: -o - %t/two_dim_array.f90 2>&1 | FileCheck %s --check-prefix=TWO_DIM
12 ! RUN: bbc -emit-hlfir -fopenmp --openmp-enable-delayed-privatization -o - \
13 ! RUN: %t/two_dim_array.f90 2>&1 | FileCheck %s --check-prefix=TWO_DIM
14
15 ! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --openmp-enable-delayed-privatization \
16 ! RUN: -o - %t/one_dim_array_default_lb.f90 2>&1 | FileCheck %s --check-prefix=ONE_DIM_DEFAULT_LB
17 ! RUN: bbc -emit-hlfir -fopenmp --openmp-enable-delayed-privatization -o - \
18 ! RUN: %t/one_dim_array_default_lb.f90 2>&1 | FileCheck %s --check-prefix=ONE_DIM_DEFAULT_LB
19
20 !--- one_dim_array.f90
21 subroutine delayed_privatization_private_1d(var1, l1, u1)
22 implicit none
23 integer(8):: l1, u1
24 integer, dimension(l1:u1) :: var1
25
26 !$omp parallel firstprivate(var1)
27 var1(l1 + 1) = 10
28 !$omp end parallel
29 end subroutine
30
31 ! ONE_DIM-LABEL: omp.private {type = firstprivate}
32 ! ONE_DIM-SAME: @[[PRIVATIZER_SYM:.*]] : [[TYPE:!fir.box<!fir.array<\?xi32>>]] alloc {
33
34 ! ONE_DIM-NEXT: ^bb0(%[[PRIV_ARG:.*]]: [[TYPE]]):
35
36 ! ONE_DIM: %[[C0:.*]] = arith.constant 0 : index
37 ! ONE_DIM-NEXT: %[[DIMS:.*]]:3 = fir.box_dims %[[PRIV_ARG]], %[[C0]] : ([[TYPE]], index) -> (index, index, index)
38 ! ONE_DIM: %[[PRIV_ALLOCA:.*]] = fir.alloca !fir.array<{{\?}}xi32>
39 ! ONE_DIM-NEXT: %[[SHAPE_SHIFT:.*]] = fir.shape_shift %[[DIMS]]#0, %[[DIMS]]#1 : (index, index) -> !fir.shapeshift<1>
40 ! ONE_DIM-NEXT: %[[PRIV_DECL:.*]]:2 = hlfir.declare %[[PRIV_ALLOCA]](%[[SHAPE_SHIFT]]) {uniq_name = "_QFdelayed_privatization_private_1dEvar1"}
41 ! ONE_DIM-NEXT: omp.yield(%[[PRIV_DECL]]#0 : [[TYPE]])
42
43 ! ONE_DIM-NEXT: } copy {
44 ! ONE_DIM-NEXT: ^bb0(%[[PRIV_ORIG_ARG:.*]]: [[TYPE]], %[[PRIV_PRIV_ARG:.*]]: [[TYPE]]):
45 ! ONE_DIM-NEXT: hlfir.assign %[[PRIV_ORIG_ARG]] to %[[PRIV_PRIV_ARG]] temporary_lhs
46 ! ONE_DIM-NEXT: omp.yield(%[[PRIV_PRIV_ARG]] : [[TYPE]])
47 ! ONE_DIM-NEXT: }
48
49 !--- two_dim_array.f90
50 subroutine delayed_privatization_private_2d(var1, l1, u1, l2, u2)
51 implicit none
52 integer(8):: l1, u1, l2, u2
53 integer, dimension(l1:u1, l2:u2) :: var1
54
55 !$omp parallel firstprivate(var1)
56 var1(l1 + 1, u2) = 10
57 !$omp end parallel
58 end subroutine
59
60 ! TWO_DIM-LABEL: omp.private {type = firstprivate}
61 ! TWO_DIM-SAME: @[[PRIVATIZER_SYM:.*]] : [[TYPE:!fir.box<!fir.array<\?x\?xi32>>]] alloc {
62
63 ! TWO_DIM-NEXT: ^bb0(%[[PRIV_ARG:.*]]: [[TYPE]]):
64 ! TWO_DIM: %[[C0:.*]] = arith.constant 0 : index
65 ! TWO_DIM-NEXT: %[[DIMS0:.*]]:3 = fir.box_dims %[[PRIV_ARG]], %[[C0]] : ([[TYPE]], index) -> (index, index, index)
66
67 ! TWO_DIM-NEXT: %[[C1:.*]] = arith.constant 1 : index
68 ! TWO_DIM-NEXT: %[[DIMS1:.*]]:3 = fir.box_dims %[[PRIV_ARG]], %[[C1]] : ([[TYPE]], index) -> (index, index, index)
69
70 ! TWO_DIM-NEXT: %[[PRIV_ALLOCA:.*]] = fir.alloca !fir.array<{{\?}}x{{\?}}xi32>, %[[DIMS0]]#1, %[[DIMS1]]#1 {bindc_name = "var1", pinned, uniq_name = "_QFdelayed_privatization_private_2dEvar1"}
71 ! TWO_DIM-NEXT: %[[SHAPE_SHIFT:.*]] = fir.shape_shift %[[DIMS0]]#0, %[[DIMS0]]#1, %[[DIMS1]]#0, %[[DIMS1]]#1 : (index, index, index, index) -> !fir.shapeshift<2>
72
73 ! TWO_DIM-NEXT: %[[PRIV_DECL:.*]]:2 = hlfir.declare %[[PRIV_ALLOCA]](%[[SHAPE_SHIFT]]) {uniq_name = "_QFdelayed_privatization_private_2dEvar1"}
74 ! TWO_DIM-NEXT: omp.yield(%[[PRIV_DECL]]#0 : [[TYPE]])
75
76 ! TWO_DIM-NEXT: } copy {
77 ! TWO_DIM-NEXT: ^bb0(%[[PRIV_ORIG_ARG:.*]]: [[TYPE]], %[[PRIV_PRIV_ARG:.*]]: [[TYPE]]):
78 ! TWO_DIM-NEXT: hlfir.assign %[[PRIV_ORIG_ARG]] to %[[PRIV_PRIV_ARG]] temporary_lhs
79 ! TWO_DIM-NEXT: omp.yield(%[[PRIV_PRIV_ARG]] : [[TYPE]])
80 ! TWO_DIM-NEXT: }
81
82 !--- one_dim_array_default_lb.f90
83 program main
84 implicit none
85 integer, dimension(10) :: var1
86
87 !$omp parallel private(var1)
88 var1(1) = 10
89 !$omp end parallel
90 end program
91
92 ! ONE_DIM_DEFAULT_LB-LABEL: omp.private {type = private}
93 ! ONE_DIM_DEFAULT_LB-SAME: @[[PRIVATIZER_SYM:.*]] : [[TYPE:!fir.ref<!fir.array<10xi32>>]] alloc {
94
95 ! ONE_DIM_DEFAULT_LB-NEXT: ^bb0(%[[PRIV_ARG:.*]]: [[TYPE]]):
96
97 ! ONE_DIM_DEFAULT_LB: %[[C10:.*]] = arith.constant 10 : index
98 ! ONE_DIM_DEFAULT_LB: %[[PRIV_ALLOCA:.*]] = fir.alloca !fir.array<10xi32>
99 ! ONE_DIM_DEFAULT_LB: %[[SHAPE:.*]] = fir.shape %[[C10]] : (index) -> !fir.shape<1>
100 ! ONE_DIM_DEFAULT_LB: hlfir.declare %[[PRIV_ALLOCA]](%[[SHAPE]])