MLIR: lib/Dialect/GPU/Transforms/EliminateBarriers.cpp File Reference (original) (raw)
Go to the source code of this file.
Namespaces |
---|
Macros | |
---|---|
#define | GEN_PASS_DEF_GPUELIMINATEBARRIERS |
#define | DEBUG_TYPE "gpu-erase-barriers" |
#define | DEBUG_TYPE_ALIAS "gpu-erase-barries-alias" |
#define | DBGS() (llvm::dbgs() << '[' << DEBUG_TYPE << "] ") |
#define | DBGS_ALIAS() (llvm::dbgs() << '[' << DEBUG_TYPE_ALIAS << "] ") |
Functions | |
---|---|
static bool | isParallelRegionBoundary (Operation *op) |
Returns true if the op is defines the parallel region that is subject to barrier synchronization. More... | |
static bool | isSequentialLoopLike (Operation *op) |
Returns true if the op behaves like a sequential loop, e.g., the control flow "wraps around" from the end of the body region back to its start. More... | |
static bool | hasSingleExecutionBody (Operation *op) |
Returns true if the regions of the op are guaranteed to be executed at most once. More... | |
static bool | producesDistinctBase (Operation *op) |
Returns true if the operation is known to produce a pointer-like object distinct from any other object produced by a similar operation. More... | |
static void | addAllValuelessEffects (SmallVectorImpl< MemoryEffects::EffectInstance > &effects) |
Populates effects with all memory effects without associating them to a specific value. More... | |
static bool | collectEffects (Operation *op, SmallVectorImpl< MemoryEffects::EffectInstance > &effects, bool ignoreBarriers=true) |
Collect the memory effects of the given op in 'effects'. More... | |
static bool | getEffectsBeforeInBlock (Operation *op, SmallVectorImpl< MemoryEffects::EffectInstance > &effects, bool stopAtBarrier) |
Get all effects before the given operation caused by other operations in the same block. More... | |
static bool | getEffectsBefore (Operation *op, SmallVectorImpl< MemoryEffects::EffectInstance > &effects, bool stopAtBarrier) |
Collects memory effects from operations that may be executed before op in a trivial structured control flow, e.g., without branches. More... | |
static bool | getEffectsAfterInBlock (Operation *op, SmallVectorImpl< MemoryEffects::EffectInstance > &effects, bool stopAtBarrier) |
Get all effects after the given operation caused by other operations in the same block. More... | |
static bool | getEffectsAfter (Operation *op, SmallVectorImpl< MemoryEffects::EffectInstance > &effects, bool stopAtBarrier) |
Collects memory effects from operations that may be executed after op in a trivial structured control flow, e.g., without branches. More... | |
static Value | getBase (Value v) |
Looks through known "view-like" ops to find the base memref. More... | |
static bool | isFunctionArgument (Value v) |
Returns true if the value is defined as a function argument. More... | |
static Value | propagatesCapture (Operation *op) |
Returns the operand that the operation "propagates" through it for capture purposes. More... | |
static std::optional< bool > | getKnownCapturingStatus (Operation *op, Value v) |
Returns true if the given operation is known to capture the given value, false if it is known not to capture the given value, nullopt if neither is known. More... | |
static bool | maybeCaptured (Value v) |
Returns true if the value may be captured by any of its users, i.e., if the user may be storing this value into memory. More... | |
static bool | mayAlias (Value first, Value second) |
Returns true if two values may be referencing aliasing memory. More... | |
static bool | mayAlias (MemoryEffects::EffectInstance a, Value v2) |
Returns true if the effect may be affecting memory aliasing the value. More... | |
static bool | mayAlias (MemoryEffects::EffectInstance a, MemoryEffects::EffectInstance b) |
Returns true if the two effects may be affecting aliasing memory. More... | |
static bool | haveConflictingEffects (ArrayRef< MemoryEffects::EffectInstance > beforeEffects, ArrayRef< MemoryEffects::EffectInstance > afterEffects) |
Returns true if any of the "before" effect instances has a conflict with any "after" instance for the purpose of barrier elimination. More... | |
◆ DBGS
#define DBGS | ( | ) | (llvm::dbgs() << '[' << DEBUG_TYPE << "] ") |
---|
◆ DBGS_ALIAS
◆ DEBUG_TYPE
#define DEBUG_TYPE "gpu-erase-barriers"
◆ DEBUG_TYPE_ALIAS
#define DEBUG_TYPE_ALIAS "gpu-erase-barries-alias"
◆ GEN_PASS_DEF_GPUELIMINATEBARRIERS
#define GEN_PASS_DEF_GPUELIMINATEBARRIERS
◆ addAllValuelessEffects()
◆ collectEffects()
◆ getBase()
◆ getEffectsAfter()
Collects memory effects from operations that may be executed after op
in a trivial structured control flow, e.g., without branches.
Stops at the parallel region boundary or at the barrier operation if stopAtBarrier
is set. Returns true
if the memory effects added to effects
are exact, false
if they are a conservative over-approximation. The latter means that effects
contain instances not associated with a specific value.
Definition at line 246 of file EliminateBarriers.cpp.
References addAllValuelessEffects(), mlir::WalkResult::advance(), collectEffects(), mlir::Block::front(), mlir::Operation::getBlock(), mlir::Region::getBlocks(), getEffectsAfterInBlock(), mlir::Block::getParent(), mlir::Operation::getParentOp(), hasSingleExecutionBody(), mlir::Operation::hasTrait(), mlir::WalkResult::interrupt(), isParallelRegionBoundary(), isSequentialLoopLike(), and mlir::Operation::walk().
◆ getEffectsAfterInBlock()
◆ getEffectsBefore()
Collects memory effects from operations that may be executed before op
in a trivial structured control flow, e.g., without branches.
Stops at the parallel region boundary or at the barrier operation if stopAtBarrier
is set. Returns true
if the memory effects added to effects
are exact, false
if they are a conservative over-approximation. The latter means that effects
contain instances not associated with a specific value.
Definition at line 154 of file EliminateBarriers.cpp.
References addAllValuelessEffects(), mlir::WalkResult::advance(), collectEffects(), mlir::Operation::getBlock(), mlir::Region::getBlocks(), getEffectsBeforeInBlock(), mlir::Block::getParent(), mlir::Operation::getParentOp(), mlir::Block::getTerminator(), hasSingleExecutionBody(), mlir::Operation::hasTrait(), mlir::WalkResult::interrupt(), isParallelRegionBoundary(), isSequentialLoopLike(), and mlir::Operation::walk().
◆ getEffectsBeforeInBlock()
◆ getKnownCapturingStatus()
static std::optional getKnownCapturingStatus ( Operation * op, Value v ) | static |
---|
Returns true
if the given operation is known to capture the given value, false
if it is known not to capture the given value, nullopt
if neither is known.
Definition at line 366 of file EliminateBarriers.cpp.
Referenced by maybeCaptured().
◆ hasSingleExecutionBody()
static bool hasSingleExecutionBody ( Operation * op) | static |
---|
Returns true
if the regions of the op are guaranteed to be executed at most once.
Thus, if an operation in one of the nested regions of op
is executed than so are all the other operations in this region.
Definition at line 63 of file EliminateBarriers.cpp.
Referenced by getEffectsAfter(), and getEffectsBefore().
◆ haveConflictingEffects()
Returns true
if any of the "before" effect instances has a conflict with any "after" instance for the purpose of barrier elimination.
The effects are supposed to be limited to a barrier synchronization scope. A conflict exists if effects instances affect aliasing memory locations and at least on of then as a write. As an exception, if the non-write effect is an allocation effect, there is no conflict since we are only expected to see the allocation happening in the same thread and it cannot be accessed from another thread without capture (which we do handle in alias analysis).
Definition at line 536 of file EliminateBarriers.cpp.
References DBGS, and mayAlias().
◆ isFunctionArgument()
static bool isFunctionArgument ( Value v) | static |
---|
◆ isParallelRegionBoundary()
static bool isParallelRegionBoundary ( Operation * op) | static |
---|
◆ isSequentialLoopLike()
static bool isSequentialLoopLike ( Operation * op) | static |
---|
◆ mayAlias() [1/3]
◆ mayAlias() [2/3]
◆ mayAlias() [3/3]
static bool mayAlias ( Value first, Value second ) | static |
---|
Returns true if two values may be referencing aliasing memory.
This is a rather naive and conservative analysis. Values defined by different allocation-like operations as well as values derived from those by casts and views cannot alias each other. Similarly, values defined by allocations inside a function cannot alias function arguments. Global values cannot alias each other or local allocations. Values that are captured, i.e. themselves potentially stored in memory, are considered as aliasing with everything. This seems sufficient to achieve barrier removal in structured control flow, more complex cases would require a proper dataflow analysis.
Definition at line 427 of file EliminateBarriers.cpp.
References DBGS_ALIAS, DEBUG_TYPE_ALIAS, getBase(), mlir::Value::getDefiningOp(), isFunctionArgument(), maybeCaptured(), and producesDistinctBase().
Referenced by mlir::affine::affineScalarReplace(), findUnusedStore(), forwardStoreToLoad(), fuseIfLegal(), mlir::affine::hasNoInterveningEffect(), haveConflictingEffects(), haveNoReadsAfterWriteExceptSameIndex(), isFusionLegal(), loadCSE(), mayAlias(), mlir::scf::naivelyFuseParallelOps(), and verifyDependencies().
◆ maybeCaptured()
static bool maybeCaptured ( Value v) | static |
---|
◆ producesDistinctBase()
static bool producesDistinctBase ( Operation * op) | static |
---|
Returns true
if the operation is known to produce a pointer-like object distinct from any other object produced by a similar operation.
For example, an allocation produces such an object.
Definition at line 70 of file EliminateBarriers.cpp.
Referenced by mayAlias().