diff options
author | Tom Eccles <tom.eccles@arm.com> | 2024-05-16 15:27:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-16 15:27:59 +0100 |
commit | 74a87548e5b62881108e6cd1fd63b45580fc3097 (patch) | |
tree | dbc67d7788387ec616f3c744f41dd09ee7b2ef03 /llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp | |
parent | 6c7ec6e1e6646fb334064bda6f301fdb52390d9b (diff) | |
download | llvm-74a87548e5b62881108e6cd1fd63b45580fc3097.zip llvm-74a87548e5b62881108e6cd1fd63b45580fc3097.tar.gz llvm-74a87548e5b62881108e6cd1fd63b45580fc3097.tar.bz2 |
[flang][MLIR][OpenMP] make reduction by-ref toggled per variable (#92244)
Fixes #88935
Toggling reduction by-ref broke when multiple reduction clauses were
used. Decisions made for the by-ref status for later clauses could then
invalidate decisions for earlier clauses. For example,
```
reduction(+:scalar,scalar2) reduction(+:array)
```
The first clause would choose by value reduction and generate by-value
reduction regions, but then after this the second clause would force
by-ref to support the array argument. But by the time the second clause
is processed, the first clause has already had the wrong kind of
reduction regions generated.
This is solved by toggling whether a variable should be reduced by
reference per variable. In the above example, this allows only `array`
to be reduced by ref.
Diffstat (limited to 'llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp')
-rw-r--r-- | llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp index 8344bca..3ed3034 100644 --- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp +++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp @@ -4982,8 +4982,10 @@ TEST_F(OpenMPIRBuilderTest, CreateReductions) { OpenMPIRBuilder::ReductionInfo ReductionInfos[] = { {SumType, SumReduced, SumPrivatized, sumReduction, sumAtomicReduction}, {XorType, XorReduced, XorPrivatized, xorReduction, xorAtomicReduction}}; + bool ReduceVariableByRef[] = {false, false}; - OMPBuilder.createReductions(BodyIP, BodyAllocaIP, ReductionInfos); + OMPBuilder.createReductions(BodyIP, BodyAllocaIP, ReductionInfos, + ReduceVariableByRef); Builder.restoreIP(AfterIP); Builder.CreateRetVoid(); @@ -5230,12 +5232,16 @@ TEST_F(OpenMPIRBuilderTest, CreateTwoReductions) { /* NumThreads */ nullptr, OMP_PROC_BIND_default, /* IsCancellable */ false); + bool ReduceVariableByRef[] = {false}; + OMPBuilder.createReductions( FirstBodyIP, FirstBodyAllocaIP, - {{SumType, SumReduced, SumPrivatized, sumReduction, sumAtomicReduction}}); + {{SumType, SumReduced, SumPrivatized, sumReduction, sumAtomicReduction}}, + ReduceVariableByRef); OMPBuilder.createReductions( SecondBodyIP, SecondBodyAllocaIP, - {{XorType, XorReduced, XorPrivatized, xorReduction, xorAtomicReduction}}); + {{XorType, XorReduced, XorPrivatized, xorReduction, xorAtomicReduction}}, + ReduceVariableByRef); Builder.restoreIP(AfterIP); Builder.CreateRetVoid(); |