MLIR  19.0.0git
Namespaces | Macros | Functions
ParallelLoopFusion.cpp File Reference
#include "mlir/Dialect/SCF/Transforms/Passes.h"
#include "mlir/Analysis/AliasAnalysis.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/SCF/Transforms/Transforms.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/OperationSupport.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "mlir/Dialect/SCF/Transforms/Passes.h.inc"

Go to the source code of this file.

Namespaces

 mlir
 Include the generated interface declarations.
 

Macros

#define GEN_PASS_DEF_SCFPARALLELLOOPFUSION
 

Functions

static bool hasNestedParallelOp (ParallelOp ploop)
 Verify there are no nested ParallelOps. More...
 
static bool equalIterationSpaces (ParallelOp firstPloop, ParallelOp secondPloop)
 Verify equal iteration spaces. More...
 
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. More...
 
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. More...
 
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. More...
 

Macro Definition Documentation

◆ GEN_PASS_DEF_SCFPARALLELLOOPFUSION

#define GEN_PASS_DEF_SCFPARALLELLOOPFUSION

Definition at line 26 of file ParallelLoopFusion.cpp.

Function Documentation

◆ equalIterationSpaces()

static bool equalIterationSpaces ( ParallelOp  firstPloop,
ParallelOp  secondPloop 
)
static

Verify equal iteration spaces.

Definition at line 41 of file ParallelLoopFusion.cpp.

Referenced by isFusionLegal().

◆ fuseIfLegal()

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

◆ hasNestedParallelOp()

static 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()

static 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::WalkResult::interrupt(), and mayAlias().

Referenced by verifyDependencies().

◆ isFusionLegal()

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

◆ verifyDependencies()

static 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 139 of file ParallelLoopFusion.cpp.

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

Referenced by isFusionLegal().