Skip to content

Commit 0fb6fb9

Browse files
Revert "Revert "[flang][OpenMP] Support delayed privatisation for composite distribute simd (llvm#151169)""
This reverts commit ec0e40b.
1 parent ae68759 commit 0fb6fb9

File tree

2 files changed

+39
-10
lines changed

2 files changed

+39
-10
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3088,12 +3088,20 @@ static mlir::omp::DistributeOp genCompositeDistributeSimd(
30883088
genSimdClauses(converter, semaCtx, simdItem->clauses, loc, simdClauseOps,
30893089
simdReductionSyms);
30903090

3091-
// TODO: Support delayed privatization.
3092-
DataSharingProcessor dsp(converter, semaCtx, simdItem->clauses, eval,
3093-
/*shouldCollectPreDeterminedSymbols=*/true,
3094-
/*useDelayedPrivatization=*/false, symTable);
3095-
dsp.processStep1();
3096-
dsp.processStep2();
3091+
3092+
DataSharingProcessor distributeItemDSP(
3093+
converter, semaCtx, distributeItem->clauses, eval,
3094+
/*shouldCollectPreDeterminedSymbols=*/false,
3095+
/*useDelayedPrivatization=*/true, symTable);
3096+
distributeItemDSP.processStep1();
3097+
distributeItemDSP.processStep2(&distributeClauseOps);
3098+
3099+
DataSharingProcessor simdItemDSP(converter, semaCtx, simdItem->clauses, eval,
3100+
/*shouldCollectPreDeterminedSymbols=*/true,
3101+
/*useDelayedPrivatization=*/true, symTable);
3102+
simdItemDSP.processStep1();
3103+
simdItemDSP.processStep2(&simdClauseOps);
3104+
30973105
// Pass the innermost leaf construct's clauses because that's where COLLAPSE
30983106
// is placed by construct decomposition.
30993107
mlir::omp::LoopNestOperands loopNestClauseOps;
@@ -3103,13 +3111,15 @@ static mlir::omp::DistributeOp genCompositeDistributeSimd(
31033111

31043112
// Operation creation.
31053113
EntryBlockArgs distributeArgs;
3106-
// TODO: Add private syms and vars.
3114+
distributeArgs.priv.syms = distributeItemDSP.getDelayedPrivSymbols();
3115+
distributeArgs.priv.vars = distributeClauseOps.privateVars;
31073116
auto distributeOp = genWrapperOp<mlir::omp::DistributeOp>(
31083117
converter, loc, distributeClauseOps, distributeArgs);
31093118
distributeOp.setComposite(/*val=*/true);
31103119

31113120
EntryBlockArgs simdArgs;
3112-
// TODO: Add private syms and vars.
3121+
simdArgs.priv.syms = simdItemDSP.getDelayedPrivSymbols();
3122+
simdArgs.priv.vars = simdClauseOps.privateVars;
31133123
simdArgs.reduction.syms = simdReductionSyms;
31143124
simdArgs.reduction.vars = simdClauseOps.reductionVars;
31153125
auto simdOp =
@@ -3119,7 +3129,7 @@ static mlir::omp::DistributeOp genCompositeDistributeSimd(
31193129
genLoopNestOp(converter, symTable, semaCtx, eval, loc, queue, simdItem,
31203130
loopNestClauseOps, iv,
31213131
{{distributeOp, distributeArgs}, {simdOp, simdArgs}},
3122-
llvm::omp::Directive::OMPD_distribute_simd, dsp);
3132+
llvm::omp::Directive::OMPD_distribute_simd, simdItemDSP);
31233133
return distributeOp;
31243134
}
31253135

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

0 commit comments

Comments
 (0)