[Mlir-commits] [flang] [mlir] [MLIR][OpenMP] Add scan reduction lowering to llvm (PR #165788)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Nov 7 11:02:46 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- flang/lib/Lower/OpenMP/OpenMP.cpp mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index edc4f1d25..2f4f7c3a2 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -2327,20 +2327,22 @@ genScanOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
genScanClauses(converter, semaCtx, item->clauses, loc, clauseOps);
mlir::omp::ScanOp scanOp = mlir::omp::ScanOp::create(
converter.getFirOpBuilder(), converter.getCurrentLocation(), clauseOps);
-
- /// Scan redution is not implemented with nested workshare loops, linear clause, tiling
+
+ /// Scan redution is not implemented with nested workshare loops, linear
+ /// clause, tiling
mlir::omp::LoopNestOp loopNestOp =
scanOp->getParentOfType<mlir::omp::LoopNestOp>();
- mlir::omp::WsloopOp wsLoopOp =
- scanOp->getParentOfType<mlir::omp::WsloopOp>();
- bool isNested = (loopNestOp.getNumLoops() > 1) || (wsLoopOp && (wsLoopOp->getParentOfType<mlir::omp::WsloopOp>()));
- if(isNested)
+ mlir::omp::WsloopOp wsLoopOp = scanOp->getParentOfType<mlir::omp::WsloopOp>();
+ bool isNested =
+ (loopNestOp.getNumLoops() > 1) ||
+ (wsLoopOp && (wsLoopOp->getParentOfType<mlir::omp::WsloopOp>()));
+ if (isNested)
TODO(loc, "Scan directive inside nested workshare loops");
- if(wsLoopOp && !wsLoopOp.getLinearVars().empty())
+ if (wsLoopOp && !wsLoopOp.getLinearVars().empty())
TODO(loc, "Scan directive with linear clause");
- if(loopNestOp.getTileSizes())
+ if (loopNestOp.getTileSizes())
TODO(loc, "Scan directive with loop tiling");
-
+
// All loop indices should be loaded after the scan construct as otherwise,
// it would result in using the index variable across scan directive.
// (`Intra-iteration dependences from a statement in the structured
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 0f611d10e..f09b3d9d5 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -2753,7 +2753,8 @@ convertOmpWsloop(Operation &opInst, llvm::IRBuilderBase &builder,
}
if (isInScanRegion)
- assert(wsloopOp.getLinearVars().empty() && "Linear clause support is not enabled with scan reduction");
+ assert(wsloopOp.getLinearVars().empty() &&
+ "Linear clause support is not enabled with scan reduction");
// For Scan loops input loop need not pop cancellation CB and hence, it is set
// false for the first loop
bool inputScanLoop = isInScanRegion;
@@ -3260,7 +3261,8 @@ convertOmpLoopNest(Operation &opInst, llvm::IRBuilderBase &builder,
return WalkResult::interrupt();
});
builder.restoreIP(scanLoop->getAfterIP());
- assert(loopOp.getTileSizes()->empty() && "Tiling is not implemented with scan reduction");
+ assert(loopOp.getTileSizes()->empty() &&
+ "Tiling is not implemented with scan reduction");
// TODO: tiling and collapse are not yet implemented for scan reduction
return success();
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/165788
More information about the Mlir-commits
mailing list