MLIR  16.0.0git
Functions
ParallelLoopFusion.cpp File Reference
#include "PassDetail.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/SCF/Transforms/Passes.h"
#include "mlir/Dialect/SCF/Transforms/Transforms.h"
#include "mlir/IR/BlockAndValueMapping.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/OpDefinition.h"
+ Include dependency graph for ParallelLoopFusion.cpp:

Go to the source code of this file.

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 BlockAndValueMapping &firstToSecondPloopIndices)
 Checks if the parallel loops have mixed access to the same buffers. More...
 
static LogicalResult verifyDependencies (ParallelOp firstPloop, ParallelOp secondPloop, const BlockAndValueMapping &firstToSecondPloopIndices)
 Analyzes dependencies in the most primitive way by checking simple read and write patterns. More...
 
static bool isFusionLegal (ParallelOp firstPloop, ParallelOp secondPloop, const BlockAndValueMapping &firstToSecondPloopIndices)
 
static void fuseIfLegal (ParallelOp firstPloop, ParallelOp secondPloop, OpBuilder b)
 Prepends operations of firstPloop's body into secondPloop's body. More...
 

Function Documentation

◆ equalIterationSpaces()

static bool equalIterationSpaces ( ParallelOp  firstPloop,
ParallelOp  secondPloop 
)
static

Verify equal iteration spaces.

Definition at line 33 of file ParallelLoopFusion.cpp.

Referenced by isFusionLegal().

◆ fuseIfLegal()

static void fuseIfLegal ( ParallelOp  firstPloop,
ParallelOp  secondPloop,
OpBuilder  b 
)
static

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

Definition at line 118 of file ParallelLoopFusion.cpp.

References mlir::OpBuilder::clone(), mlir::Operation::erase(), isFusionLegal(), mlir::BlockAndValueMapping::map(), and mlir::OpBuilder::setInsertionPointToStart().

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

◆ hasNestedParallelOp()

static bool hasNestedParallelOp ( ParallelOp  ploop)
static

Verify there are no nested ParallelOps.

Definition at line 26 of file ParallelLoopFusion.cpp.

References mlir::WalkResult::interrupt().

Referenced by isFusionLegal().

◆ haveNoReadsAfterWriteExceptSameIndex()

static bool haveNoReadsAfterWriteExceptSameIndex ( ParallelOp  firstPloop,
ParallelOp  secondPloop,
const BlockAndValueMapping firstToSecondPloopIndices 
)
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 53 of file ParallelLoopFusion.cpp.

References mlir::WalkResult::advance(), mlir::WalkResult::interrupt(), and mlir::BlockAndValueMapping::lookupOrDefault().

Referenced by verifyDependencies().

◆ isFusionLegal()

static bool isFusionLegal ( ParallelOp  firstPloop,
ParallelOp  secondPloop,
const BlockAndValueMapping firstToSecondPloopIndices 
)
static

◆ verifyDependencies()

static LogicalResult verifyDependencies ( ParallelOp  firstPloop,
ParallelOp  secondPloop,
const BlockAndValueMapping firstToSecondPloopIndices 
)
static

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

Definition at line 94 of file ParallelLoopFusion.cpp.

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

Referenced by isFusionLegal().