@@ -1044,7 +1044,6 @@ static void genDistributeClauses(lower::AbstractConverter &converter,
1044
1044
cp.processAllocate (clauseOps);
1045
1045
cp.processDistSchedule (stmtCtx, clauseOps);
1046
1046
cp.processOrder (clauseOps);
1047
- // TODO Support delayed privatization.
1048
1047
}
1049
1048
1050
1049
static void genFlushClauses (lower::AbstractConverter &converter,
@@ -1128,7 +1127,6 @@ static void genSimdClauses(lower::AbstractConverter &converter,
1128
1127
cp.processSafelen (clauseOps);
1129
1128
cp.processSimdlen (clauseOps);
1130
1129
1131
- // TODO Support delayed privatization.
1132
1130
cp.processTODO <clause::Linear, clause::Nontemporal>(
1133
1131
loc, llvm::omp::Directive::OMPD_simd);
1134
1132
}
@@ -1299,7 +1297,6 @@ static void genWsloopClauses(
1299
1297
cp.processOrdered (clauseOps);
1300
1298
cp.processReduction (loc, clauseOps, &reductionTypes, &reductionSyms);
1301
1299
cp.processSchedule (stmtCtx, clauseOps);
1302
- // TODO Support delayed privatization.
1303
1300
1304
1301
cp.processTODO <clause::Allocate, clause::Linear>(
1305
1302
loc, llvm::omp::Directive::OMPD_do);
@@ -1918,17 +1915,25 @@ genTeamsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
1918
1915
// also be a leaf of a composite construct
1919
1916
// ===----------------------------------------------------------------------===//
1920
1917
1921
- static void genStandaloneDistribute (
1922
- lower::AbstractConverter &converter, lower::SymMap &symTable,
1923
- semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
1924
- mlir::Location loc, const ConstructQueue &queue,
1925
- ConstructQueue::const_iterator item, DataSharingProcessor &dsp) {
1918
+ static void genStandaloneDistribute (lower::AbstractConverter &converter,
1919
+ lower::SymMap &symTable,
1920
+ semantics::SemanticsContext &semaCtx,
1921
+ lower::pft::Evaluation &eval,
1922
+ mlir::Location loc,
1923
+ const ConstructQueue &queue,
1924
+ ConstructQueue::const_iterator item) {
1926
1925
lower::StatementContext stmtCtx;
1927
1926
1928
1927
mlir::omp::DistributeOperands distributeClauseOps;
1929
1928
genDistributeClauses (converter, semaCtx, stmtCtx, item->clauses , loc,
1930
1929
distributeClauseOps);
1931
1930
1931
+ // TODO: Support delayed privatization.
1932
+ DataSharingProcessor dsp (converter, semaCtx, item->clauses , eval,
1933
+ /* shouldCollectPreDeterminedSymbols=*/ true ,
1934
+ /* useDelayedPrivatization=*/ false , &symTable);
1935
+ dsp.processStep1 ();
1936
+
1932
1937
mlir::omp::LoopNestOperands loopNestClauseOps;
1933
1938
llvm::SmallVector<const semantics::Symbol *> iv;
1934
1939
genLoopNestClauses (converter, semaCtx, eval, item->clauses , loc,
@@ -1949,8 +1954,7 @@ static void genStandaloneDo(lower::AbstractConverter &converter,
1949
1954
semantics::SemanticsContext &semaCtx,
1950
1955
lower::pft::Evaluation &eval, mlir::Location loc,
1951
1956
const ConstructQueue &queue,
1952
- ConstructQueue::const_iterator item,
1953
- DataSharingProcessor &dsp) {
1957
+ ConstructQueue::const_iterator item) {
1954
1958
lower::StatementContext stmtCtx;
1955
1959
1956
1960
mlir::omp::WsloopOperands wsloopClauseOps;
@@ -1959,6 +1963,12 @@ static void genStandaloneDo(lower::AbstractConverter &converter,
1959
1963
genWsloopClauses (converter, semaCtx, stmtCtx, item->clauses , loc,
1960
1964
wsloopClauseOps, reductionTypes, reductionSyms);
1961
1965
1966
+ // TODO: Support delayed privatization.
1967
+ DataSharingProcessor dsp (converter, semaCtx, item->clauses , eval,
1968
+ /* shouldCollectPreDeterminedSymbols=*/ true ,
1969
+ /* useDelayedPrivatization=*/ false , &symTable);
1970
+ dsp.processStep1 ();
1971
+
1962
1972
mlir::omp::LoopNestOperands loopNestClauseOps;
1963
1973
llvm::SmallVector<const semantics::Symbol *> iv;
1964
1974
genLoopNestClauses (converter, semaCtx, eval, item->clauses , loc,
@@ -1998,11 +2008,16 @@ static void genStandaloneSimd(lower::AbstractConverter &converter,
1998
2008
semantics::SemanticsContext &semaCtx,
1999
2009
lower::pft::Evaluation &eval, mlir::Location loc,
2000
2010
const ConstructQueue &queue,
2001
- ConstructQueue::const_iterator item,
2002
- DataSharingProcessor &dsp) {
2011
+ ConstructQueue::const_iterator item) {
2003
2012
mlir::omp::SimdOperands simdClauseOps;
2004
2013
genSimdClauses (converter, semaCtx, item->clauses , loc, simdClauseOps);
2005
2014
2015
+ // TODO: Support delayed privatization.
2016
+ DataSharingProcessor dsp (converter, semaCtx, item->clauses , eval,
2017
+ /* shouldCollectPreDeterminedSymbols=*/ true ,
2018
+ /* useDelayedPrivatization=*/ false , &symTable);
2019
+ dsp.processStep1 ();
2020
+
2006
2021
mlir::omp::LoopNestOperands loopNestClauseOps;
2007
2022
llvm::SmallVector<const semantics::Symbol *> iv;
2008
2023
genLoopNestClauses (converter, semaCtx, eval, item->clauses , loc,
@@ -2018,11 +2033,13 @@ static void genStandaloneSimd(lower::AbstractConverter &converter,
2018
2033
llvm::omp::Directive::OMPD_simd, dsp);
2019
2034
}
2020
2035
2021
- static void genStandaloneTaskloop (
2022
- lower::AbstractConverter &converter, lower::SymMap &symTable,
2023
- semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2024
- mlir::Location loc, const ConstructQueue &queue,
2025
- ConstructQueue::const_iterator item, DataSharingProcessor &dsp) {
2036
+ static void genStandaloneTaskloop (lower::AbstractConverter &converter,
2037
+ lower::SymMap &symTable,
2038
+ semantics::SemanticsContext &semaCtx,
2039
+ lower::pft::Evaluation &eval,
2040
+ mlir::Location loc,
2041
+ const ConstructQueue &queue,
2042
+ ConstructQueue::const_iterator item) {
2026
2043
TODO (loc, " Taskloop construct" );
2027
2044
}
2028
2045
@@ -2034,7 +2051,7 @@ static void genCompositeDistributeParallelDo(
2034
2051
lower::AbstractConverter &converter, lower::SymMap &symTable,
2035
2052
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2036
2053
mlir::Location loc, const ConstructQueue &queue,
2037
- ConstructQueue::const_iterator item, DataSharingProcessor &dsp ) {
2054
+ ConstructQueue::const_iterator item) {
2038
2055
assert (std::distance (item, queue.end ()) == 3 && " Invalid leaf constructs" );
2039
2056
TODO (loc, " Composite DISTRIBUTE PARALLEL DO" );
2040
2057
}
@@ -2043,16 +2060,18 @@ static void genCompositeDistributeParallelDoSimd(
2043
2060
lower::AbstractConverter &converter, lower::SymMap &symTable,
2044
2061
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2045
2062
mlir::Location loc, const ConstructQueue &queue,
2046
- ConstructQueue::const_iterator item, DataSharingProcessor &dsp ) {
2063
+ ConstructQueue::const_iterator item) {
2047
2064
assert (std::distance (item, queue.end ()) == 4 && " Invalid leaf constructs" );
2048
2065
TODO (loc, " Composite DISTRIBUTE PARALLEL DO SIMD" );
2049
2066
}
2050
2067
2051
- static void genCompositeDistributeSimd (
2052
- lower::AbstractConverter &converter, lower::SymMap &symTable,
2053
- semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2054
- mlir::Location loc, const ConstructQueue &queue,
2055
- ConstructQueue::const_iterator item, DataSharingProcessor &dsp) {
2068
+ static void genCompositeDistributeSimd (lower::AbstractConverter &converter,
2069
+ lower::SymMap &symTable,
2070
+ semantics::SemanticsContext &semaCtx,
2071
+ lower::pft::Evaluation &eval,
2072
+ mlir::Location loc,
2073
+ const ConstructQueue &queue,
2074
+ ConstructQueue::const_iterator item) {
2056
2075
lower::StatementContext stmtCtx;
2057
2076
2058
2077
assert (std::distance (item, queue.end ()) == 2 && " Invalid leaf constructs" );
@@ -2067,6 +2086,12 @@ static void genCompositeDistributeSimd(
2067
2086
mlir::omp::SimdOperands simdClauseOps;
2068
2087
genSimdClauses (converter, semaCtx, simdItem->clauses , loc, simdClauseOps);
2069
2088
2089
+ // TODO: Support delayed privatization.
2090
+ DataSharingProcessor dsp (converter, semaCtx, simdItem->clauses , eval,
2091
+ /* shouldCollectPreDeterminedSymbols=*/ true ,
2092
+ /* useDelayedPrivatization=*/ false , &symTable);
2093
+ dsp.processStep1 ();
2094
+
2070
2095
// Pass the innermost leaf construct's clauses because that's where COLLAPSE
2071
2096
// is placed by construct decomposition.
2072
2097
mlir::omp::LoopNestOperands loopNestClauseOps;
@@ -2103,8 +2128,7 @@ static void genCompositeDoSimd(lower::AbstractConverter &converter,
2103
2128
semantics::SemanticsContext &semaCtx,
2104
2129
lower::pft::Evaluation &eval, mlir::Location loc,
2105
2130
const ConstructQueue &queue,
2106
- ConstructQueue::const_iterator item,
2107
- DataSharingProcessor &dsp) {
2131
+ ConstructQueue::const_iterator item) {
2108
2132
lower::StatementContext stmtCtx;
2109
2133
2110
2134
assert (std::distance (item, queue.end ()) == 2 && " Invalid leaf constructs" );
@@ -2121,6 +2145,12 @@ static void genCompositeDoSimd(lower::AbstractConverter &converter,
2121
2145
mlir::omp::SimdOperands simdClauseOps;
2122
2146
genSimdClauses (converter, semaCtx, simdItem->clauses , loc, simdClauseOps);
2123
2147
2148
+ // TODO: Support delayed privatization.
2149
+ DataSharingProcessor dsp (converter, semaCtx, simdItem->clauses , eval,
2150
+ /* shouldCollectPreDeterminedSymbols=*/ true ,
2151
+ /* useDelayedPrivatization=*/ false , &symTable);
2152
+ dsp.processStep1 ();
2153
+
2124
2154
// Pass the innermost leaf construct's clauses because that's where COLLAPSE
2125
2155
// is placed by construct decomposition.
2126
2156
mlir::omp::LoopNestOperands loopNestClauseOps;
@@ -2151,11 +2181,13 @@ static void genCompositeDoSimd(lower::AbstractConverter &converter,
2151
2181
llvm::omp::Directive::OMPD_do_simd, dsp);
2152
2182
}
2153
2183
2154
- static void genCompositeTaskloopSimd (
2155
- lower::AbstractConverter &converter, lower::SymMap &symTable,
2156
- semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2157
- mlir::Location loc, const ConstructQueue &queue,
2158
- ConstructQueue::const_iterator item, DataSharingProcessor &dsp) {
2184
+ static void genCompositeTaskloopSimd (lower::AbstractConverter &converter,
2185
+ lower::SymMap &symTable,
2186
+ semantics::SemanticsContext &semaCtx,
2187
+ lower::pft::Evaluation &eval,
2188
+ mlir::Location loc,
2189
+ const ConstructQueue &queue,
2190
+ ConstructQueue::const_iterator item) {
2159
2191
assert (std::distance (item, queue.end ()) == 2 && " Invalid leaf constructs" );
2160
2192
TODO (loc, " Composite TASKLOOP SIMD" );
2161
2193
}
@@ -2164,30 +2196,35 @@ static void genCompositeTaskloopSimd(
2164
2196
// Dispatch
2165
2197
// ===----------------------------------------------------------------------===//
2166
2198
2167
- static bool genOMPCompositeDispatch (
2168
- lower::AbstractConverter &converter, lower::SymMap &symTable,
2169
- semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2170
- mlir::Location loc, const ConstructQueue &queue,
2171
- ConstructQueue::const_iterator item, DataSharingProcessor &dsp) {
2199
+ static bool genOMPCompositeDispatch (lower::AbstractConverter &converter,
2200
+ lower::SymMap &symTable,
2201
+ semantics::SemanticsContext &semaCtx,
2202
+ lower::pft::Evaluation &eval,
2203
+ mlir::Location loc,
2204
+ const ConstructQueue &queue,
2205
+ ConstructQueue::const_iterator item) {
2172
2206
using llvm::omp::Directive;
2173
2207
using lower::omp::matchLeafSequence;
2174
2208
2209
+ // TODO: Privatization for composite constructs is currently only done based
2210
+ // on the clauses for their last leaf construct, which may not always be
2211
+ // correct. Consider per-leaf privatization of composite constructs once
2212
+ // delayed privatization is supported by all participating ops.
2175
2213
if (matchLeafSequence (item, queue, Directive::OMPD_distribute_parallel_do))
2176
2214
genCompositeDistributeParallelDo (converter, symTable, semaCtx, eval, loc,
2177
- queue, item, dsp );
2215
+ queue, item);
2178
2216
else if (matchLeafSequence (item, queue,
2179
2217
Directive::OMPD_distribute_parallel_do_simd))
2180
2218
genCompositeDistributeParallelDoSimd (converter, symTable, semaCtx, eval,
2181
- loc, queue, item, dsp );
2219
+ loc, queue, item);
2182
2220
else if (matchLeafSequence (item, queue, Directive::OMPD_distribute_simd))
2183
2221
genCompositeDistributeSimd (converter, symTable, semaCtx, eval, loc, queue,
2184
- item, dsp );
2222
+ item);
2185
2223
else if (matchLeafSequence (item, queue, Directive::OMPD_do_simd))
2186
- genCompositeDoSimd (converter, symTable, semaCtx, eval, loc, queue, item,
2187
- dsp);
2224
+ genCompositeDoSimd (converter, symTable, semaCtx, eval, loc, queue, item);
2188
2225
else if (matchLeafSequence (item, queue, Directive::OMPD_taskloop_simd))
2189
2226
genCompositeTaskloopSimd (converter, symTable, semaCtx, eval, loc, queue,
2190
- item, dsp );
2227
+ item);
2191
2228
else
2192
2229
return false ;
2193
2230
@@ -2202,20 +2239,12 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
2202
2239
ConstructQueue::const_iterator item) {
2203
2240
assert (item != queue.end ());
2204
2241
2205
- std::optional<DataSharingProcessor> loopDsp;
2206
2242
bool loopLeaf = llvm::omp::getDirectiveAssociation (item->id ) ==
2207
2243
llvm::omp::Association::Loop;
2208
2244
if (loopLeaf) {
2209
2245
symTable.pushScope ();
2210
- // TODO: Use one DataSharingProcessor for each leaf of a composite
2211
- // construct.
2212
- loopDsp.emplace (converter, semaCtx, item->clauses , eval,
2213
- /* shouldCollectPreDeterminedSymbols=*/ true ,
2214
- /* useDelayedPrivatization=*/ false , &symTable);
2215
- loopDsp->processStep1 ();
2216
-
2217
2246
if (genOMPCompositeDispatch (converter, symTable, semaCtx, eval, loc, queue,
2218
- item, *loopDsp )) {
2247
+ item)) {
2219
2248
symTable.popScope ();
2220
2249
return ;
2221
2250
}
@@ -2227,11 +2256,10 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
2227
2256
break ;
2228
2257
case llvm::omp::Directive::OMPD_distribute:
2229
2258
genStandaloneDistribute (converter, symTable, semaCtx, eval, loc, queue,
2230
- item, *loopDsp );
2259
+ item);
2231
2260
break ;
2232
2261
case llvm::omp::Directive::OMPD_do:
2233
- genStandaloneDo (converter, symTable, semaCtx, eval, loc, queue, item,
2234
- *loopDsp);
2262
+ genStandaloneDo (converter, symTable, semaCtx, eval, loc, queue, item);
2235
2263
break ;
2236
2264
case llvm::omp::Directive::OMPD_loop:
2237
2265
TODO (loc, " Unhandled directive " + llvm::omp::getOpenMPDirectiveName (dir));
@@ -2260,8 +2288,7 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
2260
2288
// in genBodyOfOp
2261
2289
break ;
2262
2290
case llvm::omp::Directive::OMPD_simd:
2263
- genStandaloneSimd (converter, symTable, semaCtx, eval, loc, queue, item,
2264
- *loopDsp);
2291
+ genStandaloneSimd (converter, symTable, semaCtx, eval, loc, queue, item);
2265
2292
break ;
2266
2293
case llvm::omp::Directive::OMPD_single:
2267
2294
genSingleOp (converter, symTable, semaCtx, eval, loc, queue, item);
@@ -2291,8 +2318,7 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
2291
2318
genTaskgroupOp (converter, symTable, semaCtx, eval, loc, queue, item);
2292
2319
break ;
2293
2320
case llvm::omp::Directive::OMPD_taskloop:
2294
- genStandaloneTaskloop (converter, symTable, semaCtx, eval, loc, queue, item,
2295
- *loopDsp);
2321
+ genStandaloneTaskloop (converter, symTable, semaCtx, eval, loc, queue, item);
2296
2322
break ;
2297
2323
case llvm::omp::Directive::OMPD_taskwait:
2298
2324
genTaskwaitOp (converter, symTable, semaCtx, eval, loc, queue, item);
0 commit comments