MLIR 22.0.0git
Promotion.cpp File Reference
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Linalg/Passes.h"
#include "mlir/Dialect/Linalg/Transforms/Transforms.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/Interfaces/ValueBoundsOpInterface.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Transforms/FoldUtils.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Debug.h"

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "linalg-promotion"

Functions

static Value allocBuffer (ImplicitLocOpBuilder &b, const LinalgPromotionOptions &options, Type elementType, Value allocSize, DataLayout &layout, std::optional< unsigned > alignment=std::nullopt)
 Alloc a new buffer of size * width i8; where width is given by the data layout for elementType.
static std::optional< ValuedefaultAllocBufferCallBack (const LinalgPromotionOptions &options, OpBuilder &builder, memref::SubViewOp subView, ArrayRef< Value > boundingSubViewSize, std::optional< unsigned > alignment, DataLayout &layout)
 Default allocation callback function.
static LogicalResult defaultDeallocBufferCallBack (const LinalgPromotionOptions &options, OpBuilder &b, Value fullLocalView)
 Default implementation of deallocation of the buffer use for promotion.
static FailureOr< MapVector< int64_t, PromotionInfo > > promoteSubViews (ImplicitLocOpBuilder &b, LinalgOpInstancePromotionOptions options, DataLayout &layout)
static FailureOr< LinalgOp > promoteSubViews (ImplicitLocOpBuilder &b, LinalgOp op, LinalgOpInstancePromotionOptions options, DataLayout &layout)
static std::optional< ValueallocateSubviewGPUMemoryInAddressSpace (OpBuilder &builder, memref::SubViewOp subview, ArrayRef< Value > sizeBounds, gpu::AddressSpace addressSpace)
 Allocate the given subview to a memory address space in GPU by creating a allocation operation and setting the memref type address space to desired address space.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "linalg-promotion"

Definition at line 37 of file Promotion.cpp.

Function Documentation

◆ allocateSubviewGPUMemoryInAddressSpace()

std::optional< Value > allocateSubviewGPUMemoryInAddressSpace ( OpBuilder & builder,
memref::SubViewOp subview,
ArrayRef< Value > sizeBounds,
gpu::AddressSpace addressSpace )
static

Allocate the given subview to a memory address space in GPU by creating a allocation operation and setting the memref type address space to desired address space.

Definition at line 436 of file Promotion.cpp.

References mlir::Builder::getContext(), mlir::m_ConstantInt(), mlir::matchPattern(), and mlir::OpBuilder::setInsertionPointToStart().

Referenced by mlir::linalg::allocateGPUPrivateMemory(), and mlir::linalg::allocateWorkgroupMemory().

◆ allocBuffer()

Value allocBuffer ( ImplicitLocOpBuilder & b,
const LinalgPromotionOptions & options,
Type elementType,
Value allocSize,
DataLayout & layout,
std::optional< unsigned > alignment = std::nullopt )
static

Alloc a new buffer of size * width i8; where width is given by the data layout for elementType.

Use AllocOp or AllocaOp depending on options. Take an optional alignment.

Definition at line 43 of file Promotion.cpp.

References b, mlir::arith::ConstantIndexOp::create(), mlir::getConstantIntValue(), mlir::DataLayout::getTypeSize(), mul, options, and mlir::MemRefType::Builder::setMemorySpace().

Referenced by defaultAllocBufferCallBack().

◆ defaultAllocBufferCallBack()

std::optional< Value > defaultAllocBufferCallBack ( const LinalgPromotionOptions & options,
OpBuilder & builder,
memref::SubViewOp subView,
ArrayRef< Value > boundingSubViewSize,
std::optional< unsigned > alignment,
DataLayout & layout )
static

Default allocation callback function.

This allocates a promoted buffer when no call back to do so is provided. The default is to allocate a memref<..xi8> and return a view to get a memref type of shape boundingSubViewSize.

Definition at line 88 of file Promotion.cpp.

References allocBuffer(), b, mlir::arith::ConstantIndexOp::create(), options, and mlir::MemRefType::Builder::setMemorySpace().

◆ defaultDeallocBufferCallBack()

LogicalResult defaultDeallocBufferCallBack ( const LinalgPromotionOptions & options,
OpBuilder & b,
Value fullLocalView )
static

Default implementation of deallocation of the buffer use for promotion.

It expects to get the same value that the default allocation method returned, i.e. result of a ViewOp.

Definition at line 121 of file Promotion.cpp.

References b, mlir::Value::getDefiningOp(), options, and success().

◆ promoteSubViews() [1/2]

FailureOr< LinalgOp > promoteSubViews ( ImplicitLocOpBuilder & b,
LinalgOp op,
LinalgOpInstancePromotionOptions options,
DataLayout & layout )
static

Definition at line 347 of file Promotion.cpp.

References b, options, and mlir::linalg::promoteSubViews().

◆ promoteSubViews() [2/2]

FailureOr< MapVector< int64_t, PromotionInfo > > promoteSubViews ( ImplicitLocOpBuilder & b,
LinalgOpInstancePromotionOptions options,
DataLayout & layout )
static

Definition at line 288 of file Promotion.cpp.

References b, options, and mlir::linalg::promoteSubviewAsNewBuffer().