Skip to content

Commit d325951

Browse files
committed
merge main into amd-staging
2 parents f37bb13 + a361cde commit d325951

File tree

3 files changed

+70
-20
lines changed

3 files changed

+70
-20
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3094,12 +3094,16 @@ static mlir::omp::DistributeOp genCompositeDistributeSimd(
30943094
genSimdClauses(converter, semaCtx, simdItem->clauses, loc, simdClauseOps,
30953095
simdReductionSyms);
30963096

3097-
// TODO: Support delayed privatization.
3098-
DataSharingProcessor dsp(converter, semaCtx, simdItem->clauses, eval,
3099-
/*shouldCollectPreDeterminedSymbols=*/true,
3100-
/*useDelayedPrivatization=*/false, symTable);
3101-
dsp.processStep1();
3102-
dsp.processStep2();
3097+
DataSharingProcessor distributeItemDSP(
3098+
converter, semaCtx, distributeItem->clauses, eval,
3099+
/*shouldCollectPreDeterminedSymbols=*/false,
3100+
/*useDelayedPrivatization=*/true, symTable);
3101+
distributeItemDSP.processStep1(&distributeClauseOps);
3102+
3103+
DataSharingProcessor simdItemDSP(converter, semaCtx, simdItem->clauses, eval,
3104+
/*shouldCollectPreDeterminedSymbols=*/true,
3105+
/*useDelayedPrivatization=*/true, symTable);
3106+
simdItemDSP.processStep1(&simdClauseOps);
31033107

31043108
// Pass the innermost leaf construct's clauses because that's where COLLAPSE
31053109
// is placed by construct decomposition.
@@ -3110,13 +3114,15 @@ static mlir::omp::DistributeOp genCompositeDistributeSimd(
31103114

31113115
// Operation creation.
31123116
EntryBlockArgs distributeArgs;
3113-
// TODO: Add private syms and vars.
3117+
distributeArgs.priv.syms = distributeItemDSP.getDelayedPrivSymbols();
3118+
distributeArgs.priv.vars = distributeClauseOps.privateVars;
31143119
auto distributeOp = genWrapperOp<mlir::omp::DistributeOp>(
31153120
converter, loc, distributeClauseOps, distributeArgs);
31163121
distributeOp.setComposite(/*val=*/true);
31173122

31183123
EntryBlockArgs simdArgs;
3119-
// TODO: Add private syms and vars.
3124+
simdArgs.priv.syms = simdItemDSP.getDelayedPrivSymbols();
3125+
simdArgs.priv.vars = simdClauseOps.privateVars;
31203126
simdArgs.reduction.syms = simdReductionSyms;
31213127
simdArgs.reduction.vars = simdClauseOps.reductionVars;
31223128
auto simdOp =
@@ -3126,7 +3132,7 @@ static mlir::omp::DistributeOp genCompositeDistributeSimd(
31263132
genLoopNestOp(converter, symTable, semaCtx, eval, loc, queue, simdItem,
31273133
loopNestClauseOps, iv,
31283134
{{distributeOp, distributeArgs}, {simdOp, simdArgs}},
3129-
llvm::omp::Directive::OMPD_distribute_simd, dsp);
3135+
llvm::omp::Directive::OMPD_distribute_simd, simdItemDSP);
31303136
return distributeOp;
31313137
}
31323138

@@ -3150,12 +3156,16 @@ static mlir::omp::WsloopOp genCompositeDoSimd(
31503156
genSimdClauses(converter, semaCtx, simdItem->clauses, loc, simdClauseOps,
31513157
simdReductionSyms);
31523158

3153-
// TODO: Support delayed privatization.
3154-
DataSharingProcessor dsp(converter, semaCtx, simdItem->clauses, eval,
3155-
/*shouldCollectPreDeterminedSymbols=*/true,
3156-
/*useDelayedPrivatization=*/false, symTable);
3157-
dsp.processStep1();
3158-
dsp.processStep2();
3159+
DataSharingProcessor wsloopItemDSP(
3160+
converter, semaCtx, doItem->clauses, eval,
3161+
/*shouldCollectPreDeterminedSymbols=*/false,
3162+
/*useDelayedPrivatization=*/true, symTable);
3163+
wsloopItemDSP.processStep1(&wsloopClauseOps);
3164+
3165+
DataSharingProcessor simdItemDSP(converter, semaCtx, simdItem->clauses, eval,
3166+
/*shouldCollectPreDeterminedSymbols=*/true,
3167+
/*useDelayedPrivatization=*/true, symTable);
3168+
simdItemDSP.processStep1(&simdClauseOps);
31593169

31603170
// Pass the innermost leaf construct's clauses because that's where COLLAPSE
31613171
// is placed by construct decomposition.
@@ -3166,15 +3176,17 @@ static mlir::omp::WsloopOp genCompositeDoSimd(
31663176

31673177
// Operation creation.
31683178
EntryBlockArgs wsloopArgs;
3169-
// TODO: Add private syms and vars.
3179+
wsloopArgs.priv.syms = wsloopItemDSP.getDelayedPrivSymbols();
3180+
wsloopArgs.priv.vars = wsloopClauseOps.privateVars;
31703181
wsloopArgs.reduction.syms = wsloopReductionSyms;
31713182
wsloopArgs.reduction.vars = wsloopClauseOps.reductionVars;
31723183
auto wsloopOp = genWrapperOp<mlir::omp::WsloopOp>(
31733184
converter, loc, wsloopClauseOps, wsloopArgs);
31743185
wsloopOp.setComposite(/*val=*/true);
31753186

31763187
EntryBlockArgs simdArgs;
3177-
// TODO: Add private syms and vars.
3188+
simdArgs.priv.syms = simdItemDSP.getDelayedPrivSymbols();
3189+
simdArgs.priv.vars = simdClauseOps.privateVars;
31783190
simdArgs.reduction.syms = simdReductionSyms;
31793191
simdArgs.reduction.vars = simdClauseOps.reductionVars;
31803192
auto simdOp =
@@ -3184,7 +3196,7 @@ static mlir::omp::WsloopOp genCompositeDoSimd(
31843196
genLoopNestOp(converter, symTable, semaCtx, eval, loc, queue, simdItem,
31853197
loopNestClauseOps, iv,
31863198
{{wsloopOp, wsloopArgs}, {simdOp, simdArgs}},
3187-
llvm::omp::Directive::OMPD_do_simd, dsp);
3199+
llvm::omp::Directive::OMPD_do_simd, simdItemDSP);
31883200
return wsloopOp;
31893201
}
31903202

flang/test/Lower/OpenMP/distribute-simd.f90

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
subroutine distribute_simd_aligned(A)
88
use iso_c_binding
99
type(c_ptr) :: A
10-
10+
1111
!$omp teams
1212

1313
! CHECK: omp.distribute
@@ -57,3 +57,22 @@ subroutine distribute_simd_simdlen()
5757

5858
!$omp end teams
5959
end subroutine distribute_simd_simdlen
60+
61+
! CHECK-LABEL: func.func @_QPdistribute_simd_private(
62+
subroutine distribute_simd_private()
63+
integer, allocatable :: tmp
64+
! CHECK: omp.teams
65+
!$omp teams
66+
! CHECK: omp.distribute
67+
! CHECK: omp.simd
68+
! CHECK-SAME: private(@[[PRIV_BOX_SYM:.*]] %{{.*}} -> %[[PRIV_BOX:.*]], @[[PRIV_IVAR_SYM:.*]] %{{.*}} -> %[[PRIV_IVAR:.*]] : !fir.ref<!fir.box<!fir.heap<i32>>>, !fir.ref<i32>)
69+
! CHECK-NEXT: omp.loop_nest (%[[IVAR:.*]]) : i32
70+
!$omp distribute simd private(tmp)
71+
do index_ = 1, 10
72+
! CHECK: %[[PRIV_BOX_DECL:.*]]:2 = hlfir.declare %[[PRIV_BOX]]
73+
! CHECK: %[[PRIV_IVAR_DECL:.*]]:2 = hlfir.declare %[[PRIV_IVAR]]
74+
! CHECK: hlfir.assign %[[IVAR]] to %[[PRIV_IVAR_DECL]]#0
75+
end do
76+
!$omp end distribute simd
77+
!$omp end teams
78+
end subroutine distribute_simd_private

flang/test/Lower/OpenMP/wsloop-simd.f90

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
subroutine do_simd_aligned(A)
88
use iso_c_binding
99
type(c_ptr) :: A
10-
10+
1111
! CHECK: omp.wsloop
1212
! CHECK-NOT: aligned({{.*}})
1313
! CHECK-SAME: {
@@ -66,3 +66,22 @@ subroutine do_simd_reduction()
6666
end do
6767
!$omp end do simd
6868
end subroutine do_simd_reduction
69+
70+
! CHECK-LABEL: func.func @_QPdo_simd_private(
71+
subroutine do_simd_private()
72+
integer, allocatable :: tmp
73+
! CHECK: omp.wsloop
74+
! CHECK-NEXT: omp.simd
75+
! CHECK-SAME: private(@[[PRIV_BOX_SYM:.*]] %{{.*}} -> %[[PRIV_BOX:.*]], @[[PRIV_IVAR_SYM:.*]] %{{.*}} -> %[[PRIV_IVAR:.*]] : !fir.ref<!fir.box<!fir.heap<i32>>>, !fir.ref<i32>)
76+
! CHECK-NEXT: omp.loop_nest (%[[IVAR:.*]]) : i32
77+
!$omp do simd private(tmp)
78+
do i=1, 10
79+
! CHECK: %[[PRIV_BOX_DECL:.*]]:2 = hlfir.declare %[[PRIV_BOX]]
80+
! CHECK: %[[PRIV_IVAR_DECL:.*]]:2 = hlfir.declare %[[PRIV_IVAR]]
81+
! CHECK: hlfir.assign %[[IVAR]] to %[[PRIV_IVAR_DECL]]#0
82+
! CHECK: %[[PRIV_BOX_LOAD:.*]] = fir.load %[[PRIV_BOX_DECL]]
83+
! CHECK: hlfir.assign %{{.*}} to %[[PRIV_BOX_DECL]]#0
84+
! CHECK: omp.yield
85+
tmp = tmp + 1
86+
end do
87+
end subroutine do_simd_private

0 commit comments

Comments
 (0)