MLIR: lib/Dialect/GPU/Transforms/KernelOutlining.cpp File Reference (original) (raw)

Go to the source code of this file.

Namespaces
Functions
template
static void createForAllDimensions (OpBuilder &builder, Location loc, SmallVectorImpl< Value > &values)
static void injectGpuIndexOperations (Location loc, Region &launchFuncOpBody, Region &launchOpBody, IRMapping &map, bool hasCluster=false)
Adds operations generating block/thread ids and grid/block dimensions at the beginning of the launchFuncOpBody region. More...
static bool isLikelyAnIndexComputation (Operation *op)
Identifies operations that are beneficial to sink into kernels. More...
static bool extractBeneficiaryOps (Operation *op, const SetVector< Value > &existingDependencies, SetVector< Operation * > &beneficiaryOps, llvm::SmallPtrSetImpl< Value > &availableValues, llvm::function_ref< bool(Operation *)> isSinkingBeneficiary)
For a given operation op, computes whether it is beneficial to sink the operation into the kernel. More...
static DenseI32ArrayAttr maybeConstantDimsAttr (gpu::KernelDim3 dims)
Return the provided KernelDim3 as an array of i32 constants if possible. More...
static gpu::GPUFuncOp outlineKernelFuncImpl (gpu::LaunchOp launchOp, StringRef kernelFnName, SetVector< Value > &operands)
Outline the gpu.launch operation body into a kernel function. More...
static void convertToLaunchFuncOp (gpu::LaunchOp launchOp, gpu::GPUFuncOp kernelFunc, ValueRange operands)
Replace gpu.launch operations with an gpu.launch_func operation launching kernelFunc. More...

GEN_PASS_DEF_GPUKERNELOUTLININGPASS

#define GEN_PASS_DEF_GPUKERNELOUTLININGPASS

GEN_PASS_DEF_GPULAUNCHSINKINDEXCOMPUTATIONSPASS

#define GEN_PASS_DEF_GPULAUNCHSINKINDEXCOMPUTATIONSPASS

convertToLaunchFuncOp()

static void convertToLaunchFuncOp ( gpu::LaunchOp launchOp, gpu::GPUFuncOp kernelFunc, ValueRange operands ) static

createForAllDimensions()

extractBeneficiaryOps()

For a given operation op, computes whether it is beneficial to sink the operation into the kernel.

An operation can be sunk if doing so does not introduce new kernel arguments. Whether a value is already available in the kernel (and hence does not introduce new arguments) is checked by querying existingDependencies and availableValues. If an operand is not yet available, we recursively check whether it can be made available by siking its defining op. Operations that are indentified for sinking are added to beneficiaryOps in the order they should appear in the kernel. Furthermore, availableValues is updated with results that will be available after sinking the identified ops.

Definition at line 92 of file KernelOutlining.cpp.

References mlir::Operation::getOperands(), and mlir::Operation::getResults().

Referenced by mlir::sinkOperationsIntoLaunchOp().

injectGpuIndexOperations()

static void injectGpuIndexOperations ( Location loc, Region & launchFuncOpBody, Region & launchOpBody, IRMapping & map, bool hasCluster = false ) static

isLikelyAnIndexComputation()

static bool isLikelyAnIndexComputation ( Operation * op) static

maybeConstantDimsAttr()

outlineKernelFuncImpl()

static gpu::GPUFuncOp outlineKernelFuncImpl ( gpu::LaunchOp launchOp, StringRef kernelFnName, SetVector< Value > & operands ) static

Outline the gpu.launch operation body into a kernel function.

Replace gpu.terminator operations by gpu.return in the generated function. Set block and grid size bounds if known.

Definition at line 178 of file KernelOutlining.cpp.

References mlir::Region::cloneInto(), mlir::OpBuilder::create(), mlir::detail::enumerate(), mlir::Block::erase(), mlir::Operation::erase(), mlir::Region::front(), mlir::get(), mlir::Block::getArgument(), mlir::Block::getOperations(), mlir::Block::getTerminator(), mlir::Builder::getUnitAttr(), mlir::getUsedValuesDefinedAbove(), injectGpuIndexOperations(), mlir::IRMapping::lookup(), mlir::IRMapping::map(), maybeConstantDimsAttr(), and mlir::Operation::setAttr().

Referenced by mlir::outlineKernelFunc().