-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[flang][OpenMP] Support delayed privatisation for composite do simd #150979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flang][OpenMP] Support delayed privatisation for composite do simd #150979
Conversation
Implement the lowering for delayed privatisation for composite "do simd" constructs. Fixes new crashes previously masked by simd information on composite constructs being ignored, such as llvm#150975. Signed-off-by: Kajetan Puchalski <[email protected]>
@llvm/pr-subscribers-flang-openmp @llvm/pr-subscribers-flang-fir-hlfir Author: Kajetan Puchalski (mrkajetanp) ChangesImplement the lowering for delayed privatisation for composite "do simd" constructs. Fixes new crashes previously masked by simd information on composite constructs being ignored, such as llvm#150975. Fixes llvm#150975. Full diff: https://github.com/llvm/llvm-project/pull/150979.diff 2 Files Affected:
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 12089d6caa5fe..416676485cb56 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -3200,11 +3200,16 @@ static mlir::omp::WsloopOp genCompositeDoSimd(
genSimdClauses(converter, semaCtx, simdItem->clauses, loc, simdClauseOps,
simdReductionSyms);
- // TODO: Support delayed privatization.
- DataSharingProcessor dsp(converter, semaCtx, simdItem->clauses, eval,
- /*shouldCollectPreDeterminedSymbols=*/true,
- /*useDelayedPrivatization=*/false, symTable);
- dsp.processStep1();
+ DataSharingProcessor wsloopItemDSP(
+ converter, semaCtx, doItem->clauses, eval,
+ /*shouldCollectPreDeterminedSymbols=*/false,
+ /*useDelayedPrivatization=*/true, symTable);
+ wsloopItemDSP.processStep1(&wsloopClauseOps);
+
+ DataSharingProcessor simdItemDSP(converter, semaCtx, simdItem->clauses, eval,
+ /*shouldCollectPreDeterminedSymbols=*/true,
+ /*useDelayedPrivatization=*/true, symTable);
+ simdItemDSP.processStep1(&simdClauseOps);
// Pass the innermost leaf construct's clauses because that's where COLLAPSE
// is placed by construct decomposition.
@@ -3215,7 +3220,8 @@ static mlir::omp::WsloopOp genCompositeDoSimd(
// Operation creation.
EntryBlockArgs wsloopArgs;
- // TODO: Add private syms and vars.
+ wsloopArgs.priv.syms = wsloopItemDSP.getDelayedPrivSymbols();
+ wsloopArgs.priv.vars = wsloopClauseOps.privateVars;
wsloopArgs.reduction.syms = wsloopReductionSyms;
wsloopArgs.reduction.vars = wsloopClauseOps.reductionVars;
auto wsloopOp = genWrapperOp<mlir::omp::WsloopOp>(
@@ -3223,7 +3229,8 @@ static mlir::omp::WsloopOp genCompositeDoSimd(
wsloopOp.setComposite(/*val=*/true);
EntryBlockArgs simdArgs;
- // TODO: Add private syms and vars.
+ simdArgs.priv.syms = simdItemDSP.getDelayedPrivSymbols();
+ simdArgs.priv.vars = simdClauseOps.privateVars;
simdArgs.reduction.syms = simdReductionSyms;
simdArgs.reduction.vars = simdClauseOps.reductionVars;
auto simdOp =
@@ -3233,7 +3240,7 @@ static mlir::omp::WsloopOp genCompositeDoSimd(
genLoopNestOp(converter, symTable, semaCtx, eval, loc, queue, simdItem,
loopNestClauseOps, iv,
{{wsloopOp, wsloopArgs}, {simdOp, simdArgs}},
- llvm::omp::Directive::OMPD_do_simd, dsp);
+ llvm::omp::Directive::OMPD_do_simd, simdItemDSP);
return wsloopOp;
}
diff --git a/flang/test/Lower/OpenMP/wsloop-simd.f90 b/flang/test/Lower/OpenMP/wsloop-simd.f90
index 49a9a523e11fe..d26e93d9a5113 100644
--- a/flang/test/Lower/OpenMP/wsloop-simd.f90
+++ b/flang/test/Lower/OpenMP/wsloop-simd.f90
@@ -7,7 +7,7 @@
subroutine do_simd_aligned(A)
use iso_c_binding
type(c_ptr) :: A
-
+
! CHECK: omp.wsloop
! CHECK-NOT: aligned({{.*}})
! CHECK-SAME: {
@@ -66,3 +66,22 @@ subroutine do_simd_reduction()
end do
!$omp end do simd
end subroutine do_simd_reduction
+
+! CHECK-LABEL: func.func @_QPdo_simd_private(
+subroutine do_simd_private()
+ integer, allocatable :: tmp
+ ! CHECK: omp.wsloop
+ ! CHECK-NEXT: omp.simd
+ ! CHECK-SAME: private(@[[PRIV_BOX_SYM:.*]] %{{.*}} -> %[[PRIV_BOX:.*]], @[[PRIV_IVAR_SYM:.*]] %{{.*}} -> %[[PRIV_IVAR:.*]] : !fir.ref<!fir.box<!fir.heap<i32>>>, !fir.ref<i32>)
+ ! CHECK-NEXT: omp.loop_nest (%[[IVAR:.*]]) : i32
+ !$omp do simd private(tmp)
+ do i=1, 10
+ ! CHECK: %[[PRIV_BOX_DECL:.*]]:2 = hlfir.declare %[[PRIV_BOX]]
+ ! CHECK: %[[PRIV_IVAR_DECL:.*]]:2 = hlfir.declare %[[PRIV_IVAR]]
+ ! CHECK: hlfir.assign %[[IVAR]] to %[[PRIV_IVAR_DECL]]#0
+ ! CHECK: %[[PRIV_BOX_LOAD:.*]] = fir.load %[[PRIV_BOX_DECL]]
+ ! CHECK: hlfir.assign %{{.*}} to %[[PRIV_BOX_DECL]]#0
+ ! CHECK: omp.yield
+ tmp = tmp + 1
+ end do
+end subroutine do_simd_private
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for the other one, did you run Fujitsu and gfortran tests?
Yep, same story :) |
…o simd (llvm#150979)" This reverts commit c059147.
…posite do simd (llvm#150979)"" This reverts commit 26db529.
…omposite do simd (llvm#150979) (llvm#3448)
Implement the lowering for delayed privatisation for composite "do simd" constructs. Fixes new crashes previously masked by simd information on composite constructs being ignored, such as #150975.
Fixes #150975.