[Mlir-commits] [mlir] [mlir] Add bufferization option for parallel region check (PR #94645)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jun 6 10:34:14 PDT 2024
https://github.com/Max191 created https://github.com/llvm/llvm-project/pull/94645
Handling parallel region RaW conflicts should usually be the responsibility of the source program, rather than bufferization analysis. However, to preserve current functionality, checks on parallel regions is put behind a bufferization in this PR, which is on by default. Default functionality will not change, but this PR enables the option to leave parallelism checks out of the bufferization analysis.
>From 1623571635ec12b7691b8f3d5d57251fdd324691 Mon Sep 17 00:00:00 2001
From: Max Dawkins <max.dawkins at gmail.com>
Date: Thu, 6 Jun 2024 13:27:43 -0400
Subject: [PATCH] [mlir] Add bufferization option for parallel region check
---
.../mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h | 5 +++++
.../lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h
index 2d8add82383be..2fda091e412ae 100644
--- a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h
+++ b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h
@@ -309,6 +309,11 @@ struct BufferizationOptions {
/// bufferized or not.
bool bufferizeFunctionBoundaries = false;
+ // Specifies whether to account for parallel regions in RaW analysis. If true,
+ // then writes inside of parallel regions that write to buffers defined
+ // outside of the parallel region will be given a new buffer.
+ bool checkParallelRegions = true;
+
/// Certain ops have aliasing OpOperand/OpResult invariants (e.g., scf.for).
/// If this flag is set to `false`, those invariants are no longer enforced
/// with buffer copies.
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp b/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
index 2d329a1f3d889..d0b4e0dd4383e 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
@@ -611,7 +611,7 @@ hasReadAfterWriteInterference(const DenseSet<OpOperand *> &usesRead,
// Before going through the main RaW analysis, find cases where a buffer must
// be privatized due to parallelism. If the result of a write is never read,
// privatization is not necessary (and large parts of the IR are likely dead).
- if (!usesRead.empty()) {
+ if (options.checkParallelRegions && !usesRead.empty()) {
for (OpOperand *uConflictingWrite : usesWrite) {
// Find the allocation point or last write (definition) of the buffer.
// Note: In contrast to `findDefinitions`, this also returns results of
More information about the Mlir-commits
mailing list