MLIR  19.0.0git
Macros | Functions
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/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/AffineExprVisitor.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/ImplicitLocOpBuilder.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/CommandLine.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. More...
 
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. More...
 
static LogicalResult defaultDeallocBufferCallBack (const LinalgPromotionOptions &options, OpBuilder &b, Value fullLocalView)
 Default implementation of deallocation of the buffer use for promotion. More...
 
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. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "linalg-promotion"

Definition at line 42 of file Promotion.cpp.

Function Documentation

◆ allocateSubviewGPUMemoryInAddressSpace()

static 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 437 of file Promotion.cpp.

References mlir::OpBuilder::create(), mlir::get(), mlir::Builder::getContext(), mlir::m_ConstantInt(), mlir::matchPattern(), and mlir::OpBuilder::setInsertionPoint().

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

◆ allocBuffer()

static 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 48 of file Promotion.cpp.

References mlir::ImplicitLocOpBuilder::create(), mlir::ImplicitLocOpBuilder::createOrFold(), mlir::get(), mlir::getConstantIntValue(), mlir::Builder::getI64IntegerAttr(), mlir::Builder::getIntegerType(), mlir::DataLayout::getTypeSize(), options, and mlir::MemRefType::Builder::setMemorySpace().

Referenced by defaultAllocBufferCallBack().

◆ defaultAllocBufferCallBack()

static 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 93 of file Promotion.cpp.

References allocBuffer(), mlir::ImplicitLocOpBuilder::create(), mlir::ImplicitLocOpBuilder::createOrFold(), mlir::detail::enumerate(), mlir::get(), options, and mlir::MemRefType::Builder::setMemorySpace().

◆ defaultDeallocBufferCallBack()

static 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 126 of file Promotion.cpp.

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

◆ promoteSubViews() [1/2]

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

Definition at line 348 of file Promotion.cpp.

◆ promoteSubViews() [2/2]

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