MLIR 22.0.0git
ParallelLoopFusion.cpp File Reference

Go to the source code of this file.

Classes

class  mlir::impl::SCFParallelLoopFusionBase< DerivedT >

Namespaces

namespace  mlir
 Include the generated interface declarations.
namespace  mlir::impl
 Attribute collections provide a dictionary-like interface.

Macros

#define GEN_PASS_DEF_SCFPARALLELLOOPFUSION

Functions

static bool hasNestedParallelOp (ParallelOp ploop)
 Verify there are no nested ParallelOps.
static bool equalIterationSpaces (ParallelOp firstPloop, ParallelOp secondPloop)
 Verify equal iteration spaces.
static bool haveNoReadsAfterWriteExceptSameIndex (ParallelOp firstPloop, ParallelOp secondPloop, const IRMapping &firstToSecondPloopIndices, llvm::function_ref< bool(Value, Value)> mayAlias)
 Checks if the parallel loops have mixed access to the same buffers.
static LogicalResult verifyDependencies (ParallelOp firstPloop, ParallelOp secondPloop, const IRMapping &firstToSecondPloopIndices, llvm::function_ref< bool(Value, Value)> mayAlias)
 Analyzes dependencies in the most primitive way by checking simple read and write patterns.
static bool isFusionLegal (ParallelOp firstPloop, ParallelOp secondPloop, const IRMapping &firstToSecondPloopIndices, llvm::function_ref< bool(Value, Value)> mayAlias)
static void fuseIfLegal (ParallelOp firstPloop, ParallelOp &secondPloop, OpBuilder builder, llvm::function_ref< bool(Value, Value)> mayAlias)
 Prepends operations of firstPloop's body into secondPloop's body.

Macro Definition Documentation

◆ GEN_PASS_DEF_SCFPARALLELLOOPFUSION

#define GEN_PASS_DEF_SCFPARALLELLOOPFUSION

Definition at line 26 of file ParallelLoopFusion.cpp.

Function Documentation

◆ equalIterationSpaces()

bool equalIterationSpaces ( ParallelOp firstPloop,
ParallelOp secondPloop )
static

Verify equal iteration spaces.

Definition at line 41 of file ParallelLoopFusion.cpp.

References lhs, and rhs.

Referenced by isFusionLegal().

◆ fuseIfLegal()

void fuseIfLegal ( ParallelOp firstPloop,
ParallelOp & secondPloop,
OpBuilder builder,
llvm::function_ref< bool(Value, Value)> mayAlias )
static

Prepends operations of firstPloop's body into secondPloop's body.

Updates secondPloop with new loop.

Definition at line 166 of file ParallelLoopFusion.cpp.

References b, mlir::Block::begin(), mlir::Block::front(), mlir::Block::getArguments(), mlir::Block::getTerminator(), mlir::Operation::getUsers(), isFusionLegal(), mlir::IRMapping::map(), mayAlias(), and mlir::DominanceInfo::properlyDominates().

Referenced by mlir::scf::naivelyFuseParallelOps().

◆ hasNestedParallelOp()

bool hasNestedParallelOp ( ParallelOp ploop)
static

Verify there are no nested ParallelOps.

Definition at line 34 of file ParallelLoopFusion.cpp.

References mlir::WalkResult::interrupt().

Referenced by isFusionLegal().

◆ haveNoReadsAfterWriteExceptSameIndex()

bool haveNoReadsAfterWriteExceptSameIndex ( ParallelOp firstPloop,
ParallelOp secondPloop,
const IRMapping & firstToSecondPloopIndices,
llvm::function_ref< bool(Value, Value)> mayAlias )
static

Checks if the parallel loops have mixed access to the same buffers.

Returns true if the first parallel loop writes to the same indices that the second loop reads.

Definition at line 61 of file ParallelLoopFusion.cpp.

References mlir::WalkResult::advance(), mlir::Value::getDefiningOp(), mlir::OperationEquivalence::IgnoreLocations, mlir::WalkResult::interrupt(), mlir::OperationEquivalence::isEquivalentTo(), mlir::isMemoryEffectFree(), load, mlir::IRMapping::lookupOrDefault(), mayAlias(), and success().

Referenced by verifyDependencies().

◆ isFusionLegal()

bool isFusionLegal ( ParallelOp firstPloop,
ParallelOp secondPloop,
const IRMapping & firstToSecondPloopIndices,
llvm::function_ref< bool(Value, Value)> mayAlias )
static

◆ verifyDependencies()

LogicalResult verifyDependencies ( ParallelOp firstPloop,
ParallelOp secondPloop,
const IRMapping & firstToSecondPloopIndices,
llvm::function_ref< bool(Value, Value)> mayAlias )
static

Analyzes dependencies in the most primitive way by checking simple read and write patterns.

Definition at line 140 of file ParallelLoopFusion.cpp.

References haveNoReadsAfterWriteExceptSameIndex(), mlir::IRMapping::map(), mayAlias(), and success().

Referenced by isFusionLegal().