19static constexpr uint64_t
kMaxDim = std::numeric_limits<uint32_t>::max();
26 unsigned width = IndexType::kInternalStorageBitWidth;
31static uint64_t
zext(uint32_t arg) {
return static_cast<uint64_t
>(arg); }
42 llvm_unreachable(
"All dimension enum cases handled above");
45static std::optional<uint32_t>
49 case DimensionKind::Other:
51 case DimensionKind::Block:
52 bounds =
func.getKnownBlockSizeAttr();
54 case DimensionKind::Grid:
55 bounds =
func.getKnownGridSizeAttr();
57 case DimensionKind::Cluster:
58 bounds =
func.getKnownClusterSizeAttr();
63 if (bounds.size() <=
static_cast<uint32_t
>(dim))
65 return bounds[
static_cast<uint32_t
>(dim)];
74 if (bounds.size() <=
static_cast<uint32_t
>(dim))
76 return bounds[
static_cast<uint32_t
>(dim)];
79std::optional<uint32_t>
85 case DimensionKind::Other:
87 case DimensionKind::Block:
88 bounds = launch.getBlockSizeOperandValues();
90 case DimensionKind::Grid:
91 bounds = launch.getGridSizeOperandValues();
93 case DimensionKind::Cluster:
94 if (launch.hasClusterSize()) {
95 auto clusterBounds = launch.getClusterSizeOperandValues();
97 bounds = *clusterBounds;
104 return value.getZExtValue();
115 case DimensionKind::Other:
117 case DimensionKind::Block:
118 attrName = GPUDialect::KnownBlockSizeAttrHelper::getNameStr();
120 case DimensionKind::Grid:
121 attrName = GPUDialect::KnownGridSizeAttrHelper::getNameStr();
123 case DimensionKind::Cluster:
124 attrName = GPUDialect::KnownClusterSizeAttrHelper::getNameStr();
129 return discardableAttr;
138 max = specified->getZExtValue();
146 return setResultRange(getResult(),
151 max = specified->getZExtValue();
159 max = specified->getZExtValue();
170 max = specified->getZExtValue();
176 std::optional<uint32_t> knownVal =
179 return setResultRange(getResult(),
184 max = specified->getZExtValue();
195 max = specified->getZExtValue();
201 std::optional<uint32_t> knownVal =
204 return setResultRange(getResult(),
208 max = specified->getZExtValue();
216 *
this, DimensionKind::Block, getDimension()))
219 max = specified->getZExtValue();
227 max = specified->getZExtValue();
235 max = specified->getZExtValue();
242 return setResultRange(getResult(),
245 uint64_t blockDimMax =
zext(
248 uint64_t gridDimMax =
zext(
251 setResultRange(getResult(),
259 max = specified->getZExtValue();
267 max = specified->getZExtValue();
275 if (argRange.
umin().getBitWidth() != IndexType::kInternalStorageBitWidth)
279 setResultRange(dimResult, dimRange);
282 setResultRange(idxResult, idxRange);
285 argRanges = argRanges.drop_front(getAsyncDependencies().size());
288 setRange(argRanges[0], gridDims.
x, blockIds.
x);
289 setRange(argRanges[1], gridDims.
y, blockIds.
y);
290 setRange(argRanges[2], gridDims.
z, blockIds.
z);
293 setRange(argRanges[3], blockDims.
x, threadIds.
x);
294 setRange(argRanges[4], blockDims.
y, threadIds.
y);
295 setRange(argRanges[5], blockDims.
z, threadIds.
z);
static std::optional< int64_t > getUpperBound(Value iv)
Gets the constant upper bound on an affine.for iv.
static std::optional< uint32_t > getKnownLaunchAttr(GPUFuncOp func, DimensionKind dims, Dimension dim)
static Value valueByDim(KernelDim3 dims, Dimension dim)
static constexpr uint64_t kMaxClusterDim
static constexpr uint64_t kMaxDim
static uint64_t zext(uint32_t arg)
static ConstantIntRanges getIndexRange(uint64_t umin, uint64_t umax)
static constexpr uint64_t kMaxSubgroupSize
static Value max(ImplicitLocOpBuilder &builder, Value value, Value bound)
A set of arbitrary-precision integers representing bounds on a given integer value.
static ConstantIntRanges fromUnsigned(const APInt &umin, const APInt &umax)
Create an ConstantIntRanges with the unsigned minimum and maximum equal to umin and umax and the sign...
ConstantIntRanges intersection(const ConstantIntRanges &other) const
Returns the intersection (computed separately for signed and unsigned bounds) of this range and other...
const APInt & umax() const
The maximum value of an integer when it is interpreted as unsigned.
const APInt & umin() const
The minimum value of an integer when it is interpreted as unsigned.
Operation is the basic unit of execution within MLIR.
OpTy getParentOfType()
Return the closest surrounding parent operation that is of type 'OpTy'.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
std::optional< uint32_t > getKnownDimensionSizeAround(Operation *op, DimensionKind kind, Dimension dim)
Retrieve the constant bounds for a given dimension and dimension kind from the context surrounding op...
SmallVector< unsigned > getBlockSize(AffineMap dimToLvl)
Given the dimToLvl map, returns the block sizes in a vector.
Include the generated interface declarations.
bool matchPattern(Value value, const Pattern &pattern)
Entry point for matching a pattern over a Value.
detail::constant_int_value_binder m_ConstantInt(IntegerAttr::ValueType *bind_value)
Matches a constant holding a scalar/vector/tensor integer (splat) and writes the integer value to bin...
llvm::function_ref< void(Value, const ConstantIntRanges &)> SetIntRangeFn
The type of the setResultRanges callback provided to ops implementing InferIntRangeInterface.
detail::DenseArrayAttrImpl< int32_t > DenseI32ArrayAttr
Utility class for the GPU dialect to represent triples of Values accessible through ....