[Mlir-commits] [mlir] [mlir][PartialReductionTilingInterface] Generalize implementation of `tileUsingSCF` for `ReductionTilingStrategy::PartialOuterReduction`. (PR #143467)
Kunwar Grover
llvmlistbot at llvm.org
Mon Jun 23 03:22:36 PDT 2025
================
@@ -165,28 +166,46 @@ static void checkSafeToTileToForall(TilingInterface op,
assert((numThreads.empty() || (numThreads.size() == iterators.size())) &&
"when specified, expected number of threads to use for each loop");
+ bool isParallelTiling = false, isReductionTiling = false;
for (auto [index, iterator, tileSize] :
llvm::enumerate(iterators, tileSizes)) {
- // If num threads is specified, check that it is greater than one only for
- // parallel dimensions.
- if (!numThreads.empty()) {
- if (std::optional<int64_t> constNumThreads =
- getConstantIntValue(numThreads[index])) {
- if (constNumThreads.value() > 1 &&
+ if (!isConstantIntValue(tileSize, 0)) {
+ isParallelTiling |= iterator == utils::IteratorType::parallel;
+ isReductionTiling |= iterator == utils::IteratorType::reduction;
+ }
+
+ if (loopType == scf::SCFTilingOptions::LoopType::ForallOp &&
+ reductionStrategy == ReductionTilingStrategy::FullReduction) {
+ // If num threads is specified, check that it is greater than one only for
+ // parallel dimensions.
+ if (!numThreads.empty()) {
+ if (std::optional<int64_t> constNumThreads =
+ getConstantIntValue(numThreads[index])) {
+ if (constNumThreads.value() > 1 &&
+ iterator != utils::IteratorType::parallel) {
+ op.emitWarning() << "tiling is not thread safe at axis #" << index;
----------------
Groverkss wrote:
scf.reduce is only needed in a parallel loop context, so it we don't emit it in FullReduction, so it does fit there (FullReduction does not have a parallel loop context).
https://github.com/llvm/llvm-project/pull/143467
More information about the Mlir-commits
mailing list