[flang-commits] [flang] [mlir] [flang][openmp] Changes for invoking scan Op (PR #123254)
Sergio Afonso via flang-commits
flang-commits at lists.llvm.org
Thu Jan 23 03:48:31 PST 2025
================
@@ -514,18 +515,36 @@ static bool doReductionByRef(mlir::Value reductionVar) {
return false;
}
+mlir::omp::ReductionModifier
+translateReductionModifier(const ReductionModifier &m) {
+ switch (m) {
+ case ReductionModifier::Default:
+ return mlir::omp::ReductionModifier::defaultmod;
+ case ReductionModifier::Inscan:
+ return mlir::omp::ReductionModifier::inscan;
+ case ReductionModifier::Task:
+ return mlir::omp::ReductionModifier::task;
+ }
+ return mlir::omp::ReductionModifier::defaultmod;
+}
+
void ReductionProcessor::addDeclareReduction(
mlir::Location currentLocation, lower::AbstractConverter &converter,
const omp::clause::Reduction &reduction,
llvm::SmallVectorImpl<mlir::Value> &reductionVars,
llvm::SmallVectorImpl<bool> &reduceVarByRef,
llvm::SmallVectorImpl<mlir::Attribute> &reductionDeclSymbols,
- llvm::SmallVectorImpl<const semantics::Symbol *> &reductionSymbols) {
+ llvm::SmallVectorImpl<const semantics::Symbol *> &reductionSymbols,
+ mlir::omp::ReductionModifierAttr *reductionMod) {
----------------
skatrak wrote:
Pass by reference, since the attribute structure must always be present in `ReductionClauseOps`. This might change in the future if we wanted to reuse this function for `in_reduction` or `task_reduction`, but for now it helps us ensure we don't inadvertently dereference an invalid pointer below.
```suggestion
mlir::omp::ReductionModifierAttr &reductionMod) {
```
https://github.com/llvm/llvm-project/pull/123254
More information about the flang-commits
mailing list