Skip to content

Commit e8173c7

Browse files
committed
[mlir] Add bufferization option for parallel region check
1 parent 503fb1a commit e8173c7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@ struct BufferizationOptions {
309309
/// bufferized or not.
310310
bool bufferizeFunctionBoundaries = false;
311311

312+
// Specifies whether to account for parallel regions in RaW analysis. If true,
313+
// then writes inside of parallel regions that write to buffers defined
314+
// outside of the parallel region will be given a new buffer.
315+
bool checkParallelRegions = true;
316+
312317
/// Certain ops have aliasing OpOperand/OpResult invariants (e.g., scf.for).
313318
/// If this flag is set to `false`, those invariants are no longer enforced
314319
/// with buffer copies.

mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ hasReadAfterWriteInterference(const DenseSet<OpOperand *> &usesRead,
611611
// Before going through the main RaW analysis, find cases where a buffer must
612612
// be privatized due to parallelism. If the result of a write is never read,
613613
// privatization is not necessary (and large parts of the IR are likely dead).
614-
if (!usesRead.empty()) {
614+
if (options.checkParallelRegions && !usesRead.empty()) {
615615
for (OpOperand *uConflictingWrite : usesWrite) {
616616
// Find the allocation point or last write (definition) of the buffer.
617617
// Note: In contrast to `findDefinitions`, this also returns results of

0 commit comments

Comments
 (0)