@@ -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);
@@ -1924,17 +1921,25 @@ genTeamsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
1924
1921
// also be a leaf of a composite construct
1925
1922
// ===----------------------------------------------------------------------===//
1926
1923
1927
- static void genStandaloneDistribute (
1928
- lower::AbstractConverter &converter, lower::SymMap &symTable,
1929
- semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
1930
- mlir::Location loc, const ConstructQueue &queue,
1931
- ConstructQueue::const_iterator item, DataSharingProcessor &dsp) {
1924
+ static void genStandaloneDistribute (lower::AbstractConverter &converter,
1925
+ lower::SymMap &symTable,
1926
+ semantics::SemanticsContext &semaCtx,
1927
+ lower::pft::Evaluation &eval,
1928
+ mlir::Location loc,
1929
+ const ConstructQueue &queue,
1930
+ ConstructQueue::const_iterator item) {
1932
1931
lower::StatementContext stmtCtx;
1933
1932
1934
1933
mlir::omp::DistributeOperands distributeClauseOps;
1935
1934
genDistributeClauses (converter, semaCtx, stmtCtx, item->clauses , loc,
1936
1935
distributeClauseOps);
1937
1936
1937
+ // TODO: Support delayed privatization.
1938
+ DataSharingProcessor dsp (converter, semaCtx, item->clauses , eval,
1939
+ /* shouldCollectPreDeterminedSymbols=*/ true ,
1940
+ /* useDelayedPrivatization=*/ false , &symTable);
1941
+ dsp.processStep1 ();
1942
+
1938
1943
mlir::omp::LoopNestOperands loopNestClauseOps;
1939
1944
llvm::SmallVector<const semantics::Symbol *> iv;
1940
1945
genLoopNestClauses (converter, semaCtx, eval, item->clauses , loc,
@@ -1955,8 +1960,7 @@ static void genStandaloneDo(lower::AbstractConverter &converter,
1955
1960
semantics::SemanticsContext &semaCtx,
1956
1961
lower::pft::Evaluation &eval, mlir::Location loc,
1957
1962
const ConstructQueue &queue,
1958
- ConstructQueue::const_iterator item,
1959
- DataSharingProcessor &dsp) {
1963
+ ConstructQueue::const_iterator item) {
1960
1964
lower::StatementContext stmtCtx;
1961
1965
1962
1966
mlir::omp::WsloopOperands wsloopClauseOps;
@@ -1965,6 +1969,12 @@ static void genStandaloneDo(lower::AbstractConverter &converter,
1965
1969
genWsloopClauses (converter, semaCtx, stmtCtx, item->clauses , loc,
1966
1970
wsloopClauseOps, reductionTypes, reductionSyms);
1967
1971
1972
+ // TODO: Support delayed privatization.
1973
+ DataSharingProcessor dsp (converter, semaCtx, item->clauses , eval,
1974
+ /* shouldCollectPreDeterminedSymbols=*/ true ,
1975
+ /* useDelayedPrivatization=*/ false , &symTable);
1976
+ dsp.processStep1 ();
1977
+
1968
1978
mlir::omp::LoopNestOperands loopNestClauseOps;
1969
1979
llvm::SmallVector<const semantics::Symbol *> iv;
1970
1980
genLoopNestClauses (converter, semaCtx, eval, item->clauses , loc,
@@ -2004,11 +2014,16 @@ static void genStandaloneSimd(lower::AbstractConverter &converter,
2004
2014
semantics::SemanticsContext &semaCtx,
2005
2015
lower::pft::Evaluation &eval, mlir::Location loc,
2006
2016
const ConstructQueue &queue,
2007
- ConstructQueue::const_iterator item,
2008
- DataSharingProcessor &dsp) {
2017
+ ConstructQueue::const_iterator item) {
2009
2018
mlir::omp::SimdOperands simdClauseOps;
2010
2019
genSimdClauses (converter, semaCtx, item->clauses , loc, simdClauseOps);
2011
2020
2021
+ // TODO: Support delayed privatization.
2022
+ DataSharingProcessor dsp (converter, semaCtx, item->clauses , eval,
2023
+ /* shouldCollectPreDeterminedSymbols=*/ true ,
2024
+ /* useDelayedPrivatization=*/ false , &symTable);
2025
+ dsp.processStep1 ();
2026
+
2012
2027
mlir::omp::LoopNestOperands loopNestClauseOps;
2013
2028
llvm::SmallVector<const semantics::Symbol *> iv;
2014
2029
genLoopNestClauses (converter, semaCtx, eval, item->clauses , loc,
@@ -2024,11 +2039,13 @@ static void genStandaloneSimd(lower::AbstractConverter &converter,
2024
2039
llvm::omp::Directive::OMPD_simd, dsp);
2025
2040
}
2026
2041
2027
- static void genStandaloneTaskloop (
2028
- lower::AbstractConverter &converter, lower::SymMap &symTable,
2029
- semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2030
- mlir::Location loc, const ConstructQueue &queue,
2031
- ConstructQueue::const_iterator item, DataSharingProcessor &dsp) {
2042
+ static void genStandaloneTaskloop (lower::AbstractConverter &converter,
2043
+ lower::SymMap &symTable,
2044
+ semantics::SemanticsContext &semaCtx,
2045
+ lower::pft::Evaluation &eval,
2046
+ mlir::Location loc,
2047
+ const ConstructQueue &queue,
2048
+ ConstructQueue::const_iterator item) {
2032
2049
TODO (loc, " Taskloop construct" );
2033
2050
}
2034
2051
@@ -2040,7 +2057,7 @@ static void genCompositeDistributeParallelDo(
2040
2057
lower::AbstractConverter &converter, lower::SymMap &symTable,
2041
2058
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2042
2059
mlir::Location loc, const ConstructQueue &queue,
2043
- ConstructQueue::const_iterator item, DataSharingProcessor &dsp ) {
2060
+ ConstructQueue::const_iterator item) {
2044
2061
assert (std::distance (item, queue.end ()) == 3 && " Invalid leaf constructs" );
2045
2062
TODO (loc, " Composite DISTRIBUTE PARALLEL DO" );
2046
2063
}
@@ -2049,16 +2066,18 @@ static void genCompositeDistributeParallelDoSimd(
2049
2066
lower::AbstractConverter &converter, lower::SymMap &symTable,
2050
2067
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2051
2068
mlir::Location loc, const ConstructQueue &queue,
2052
- ConstructQueue::const_iterator item, DataSharingProcessor &dsp ) {
2069
+ ConstructQueue::const_iterator item) {
2053
2070
assert (std::distance (item, queue.end ()) == 4 && " Invalid leaf constructs" );
2054
2071
TODO (loc, " Composite DISTRIBUTE PARALLEL DO SIMD" );
2055
2072
}
2056
2073
2057
- static void genCompositeDistributeSimd (
2058
- lower::AbstractConverter &converter, lower::SymMap &symTable,
2059
- semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2060
- mlir::Location loc, const ConstructQueue &queue,
2061
- ConstructQueue::const_iterator item, DataSharingProcessor &dsp) {
2074
+ static void genCompositeDistributeSimd (lower::AbstractConverter &converter,
2075
+ lower::SymMap &symTable,
2076
+ semantics::SemanticsContext &semaCtx,
2077
+ lower::pft::Evaluation &eval,
2078
+ mlir::Location loc,
2079
+ const ConstructQueue &queue,
2080
+ ConstructQueue::const_iterator item) {
2062
2081
lower::StatementContext stmtCtx;
2063
2082
2064
2083
assert (std::distance (item, queue.end ()) == 2 && " Invalid leaf constructs" );
@@ -2073,6 +2092,12 @@ static void genCompositeDistributeSimd(
2073
2092
mlir::omp::SimdOperands simdClauseOps;
2074
2093
genSimdClauses (converter, semaCtx, simdItem->clauses , loc, simdClauseOps);
2075
2094
2095
+ // TODO: Support delayed privatization.
2096
+ DataSharingProcessor dsp (converter, semaCtx, simdItem->clauses , eval,
2097
+ /* shouldCollectPreDeterminedSymbols=*/ true ,
2098
+ /* useDelayedPrivatization=*/ false , &symTable);
2099
+ dsp.processStep1 ();
2100
+
2076
2101
// Pass the innermost leaf construct's clauses because that's where COLLAPSE
2077
2102
// is placed by construct decomposition.
2078
2103
mlir::omp::LoopNestOperands loopNestClauseOps;
@@ -2109,8 +2134,7 @@ static void genCompositeDoSimd(lower::AbstractConverter &converter,
2109
2134
semantics::SemanticsContext &semaCtx,
2110
2135
lower::pft::Evaluation &eval, mlir::Location loc,
2111
2136
const ConstructQueue &queue,
2112
- ConstructQueue::const_iterator item,
2113
- DataSharingProcessor &dsp) {
2137
+ ConstructQueue::const_iterator item) {
2114
2138
lower::StatementContext stmtCtx;
2115
2139
2116
2140
assert (std::distance (item, queue.end ()) == 2 && " Invalid leaf constructs" );
@@ -2127,6 +2151,12 @@ static void genCompositeDoSimd(lower::AbstractConverter &converter,
2127
2151
mlir::omp::SimdOperands simdClauseOps;
2128
2152
genSimdClauses (converter, semaCtx, simdItem->clauses , loc, simdClauseOps);
2129
2153
2154
+ // TODO: Support delayed privatization.
2155
+ DataSharingProcessor dsp (converter, semaCtx, simdItem->clauses , eval,
2156
+ /* shouldCollectPreDeterminedSymbols=*/ true ,
2157
+ /* useDelayedPrivatization=*/ false , &symTable);
2158
+ dsp.processStep1 ();
2159
+
2130
2160
// Pass the innermost leaf construct's clauses because that's where COLLAPSE
2131
2161
// is placed by construct decomposition.
2132
2162
mlir::omp::LoopNestOperands loopNestClauseOps;
@@ -2157,11 +2187,13 @@ static void genCompositeDoSimd(lower::AbstractConverter &converter,
2157
2187
llvm::omp::Directive::OMPD_do_simd, dsp);
2158
2188
}
2159
2189
2160
- static void genCompositeTaskloopSimd (
2161
- lower::AbstractConverter &converter, lower::SymMap &symTable,
2162
- semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2163
- mlir::Location loc, const ConstructQueue &queue,
2164
- ConstructQueue::const_iterator item, DataSharingProcessor &dsp) {
2190
+ static void genCompositeTaskloopSimd (lower::AbstractConverter &converter,
2191
+ lower::SymMap &symTable,
2192
+ semantics::SemanticsContext &semaCtx,
2193
+ lower::pft::Evaluation &eval,
2194
+ mlir::Location loc,
2195
+ const ConstructQueue &queue,
2196
+ ConstructQueue::const_iterator item) {
2165
2197
assert (std::distance (item, queue.end ()) == 2 && " Invalid leaf constructs" );
2166
2198
TODO (loc, " Composite TASKLOOP SIMD" );
2167
2199
}
@@ -2170,30 +2202,35 @@ static void genCompositeTaskloopSimd(
2170
2202
// Dispatch
2171
2203
// ===----------------------------------------------------------------------===//
2172
2204
2173
- static bool genOMPCompositeDispatch (
2174
- lower::AbstractConverter &converter, lower::SymMap &symTable,
2175
- semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2176
- mlir::Location loc, const ConstructQueue &queue,
2177
- ConstructQueue::const_iterator item, DataSharingProcessor &dsp) {
2205
+ static bool genOMPCompositeDispatch (lower::AbstractConverter &converter,
2206
+ lower::SymMap &symTable,
2207
+ semantics::SemanticsContext &semaCtx,
2208
+ lower::pft::Evaluation &eval,
2209
+ mlir::Location loc,
2210
+ const ConstructQueue &queue,
2211
+ ConstructQueue::const_iterator item) {
2178
2212
using llvm::omp::Directive;
2179
2213
using lower::omp::matchLeafSequence;
2180
2214
2215
+ // TODO: Privatization for composite constructs is currently only done based
2216
+ // on the clauses for their last leaf construct, which may not always be
2217
+ // correct. Consider per-leaf privatization of composite constructs once
2218
+ // delayed privatization is supported by all participating ops.
2181
2219
if (matchLeafSequence (item, queue, Directive::OMPD_distribute_parallel_do))
2182
2220
genCompositeDistributeParallelDo (converter, symTable, semaCtx, eval, loc,
2183
- queue, item, dsp );
2221
+ queue, item);
2184
2222
else if (matchLeafSequence (item, queue,
2185
2223
Directive::OMPD_distribute_parallel_do_simd))
2186
2224
genCompositeDistributeParallelDoSimd (converter, symTable, semaCtx, eval,
2187
- loc, queue, item, dsp );
2225
+ loc, queue, item);
2188
2226
else if (matchLeafSequence (item, queue, Directive::OMPD_distribute_simd))
2189
2227
genCompositeDistributeSimd (converter, symTable, semaCtx, eval, loc, queue,
2190
- item, dsp );
2228
+ item);
2191
2229
else if (matchLeafSequence (item, queue, Directive::OMPD_do_simd))
2192
- genCompositeDoSimd (converter, symTable, semaCtx, eval, loc, queue, item,
2193
- dsp);
2230
+ genCompositeDoSimd (converter, symTable, semaCtx, eval, loc, queue, item);
2194
2231
else if (matchLeafSequence (item, queue, Directive::OMPD_taskloop_simd))
2195
2232
genCompositeTaskloopSimd (converter, symTable, semaCtx, eval, loc, queue,
2196
- item, dsp );
2233
+ item);
2197
2234
else
2198
2235
return false ;
2199
2236
@@ -2208,20 +2245,12 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
2208
2245
ConstructQueue::const_iterator item) {
2209
2246
assert (item != queue.end ());
2210
2247
2211
- std::optional<DataSharingProcessor> loopDsp;
2212
2248
bool loopLeaf = llvm::omp::getDirectiveAssociation (item->id ) ==
2213
2249
llvm::omp::Association::Loop;
2214
2250
if (loopLeaf) {
2215
2251
symTable.pushScope ();
2216
- // TODO: Use one DataSharingProcessor for each leaf of a composite
2217
- // construct.
2218
- loopDsp.emplace (converter, semaCtx, item->clauses , eval,
2219
- /* shouldCollectPreDeterminedSymbols=*/ true ,
2220
- /* useDelayedPrivatization=*/ false , &symTable);
2221
- loopDsp->processStep1 ();
2222
-
2223
2252
if (genOMPCompositeDispatch (converter, symTable, semaCtx, eval, loc, queue,
2224
- item, *loopDsp )) {
2253
+ item)) {
2225
2254
symTable.popScope ();
2226
2255
return ;
2227
2256
}
@@ -2233,11 +2262,10 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
2233
2262
break ;
2234
2263
case llvm::omp::Directive::OMPD_distribute:
2235
2264
genStandaloneDistribute (converter, symTable, semaCtx, eval, loc, queue,
2236
- item, *loopDsp );
2265
+ item);
2237
2266
break ;
2238
2267
case llvm::omp::Directive::OMPD_do:
2239
- genStandaloneDo (converter, symTable, semaCtx, eval, loc, queue, item,
2240
- *loopDsp);
2268
+ genStandaloneDo (converter, symTable, semaCtx, eval, loc, queue, item);
2241
2269
break ;
2242
2270
case llvm::omp::Directive::OMPD_loop:
2243
2271
TODO (loc, " Unhandled directive " + llvm::omp::getOpenMPDirectiveName (dir));
@@ -2266,8 +2294,7 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
2266
2294
// in genBodyOfOp
2267
2295
break ;
2268
2296
case llvm::omp::Directive::OMPD_simd:
2269
- genStandaloneSimd (converter, symTable, semaCtx, eval, loc, queue, item,
2270
- *loopDsp);
2297
+ genStandaloneSimd (converter, symTable, semaCtx, eval, loc, queue, item);
2271
2298
break ;
2272
2299
case llvm::omp::Directive::OMPD_single:
2273
2300
genSingleOp (converter, symTable, semaCtx, eval, loc, queue, item);
@@ -2297,8 +2324,7 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
2297
2324
genTaskgroupOp (converter, symTable, semaCtx, eval, loc, queue, item);
2298
2325
break ;
2299
2326
case llvm::omp::Directive::OMPD_taskloop:
2300
- genStandaloneTaskloop (converter, symTable, semaCtx, eval, loc, queue, item,
2301
- *loopDsp);
2327
+ genStandaloneTaskloop (converter, symTable, semaCtx, eval, loc, queue, item);
2302
2328
break ;
2303
2329
case llvm::omp::Directive::OMPD_taskwait:
2304
2330
genTaskwaitOp (converter, symTable, semaCtx, eval, loc, queue, item);
0 commit comments