MLIR  16.0.0git
Classes | Macros | Enumerations | Functions
GPUDialect.cpp File Reference
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/FunctionImplementation.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "mlir/Transforms/InliningUtils.h"
#include "llvm/ADT/TypeSwitch.h"
#include "mlir/Dialect/GPU/IR/GPUOpsDialect.cpp.inc"
#include "mlir/Dialect/GPU/IR/GPUOps.cpp.inc"
#include "mlir/Dialect/GPU/IR/GPUOpsAttributes.cpp.inc"
#include "mlir/Dialect/GPU/IR/GPUOpInterfaces.cpp.inc"
#include "mlir/Dialect/GPU/IR/GPUOpsEnums.cpp.inc"
+ Include dependency graph for GPUDialect.cpp:

Go to the source code of this file.

Classes

struct  FoldLaunchArguments
 Simplify the gpu.launch when the range of a thread or block ID is trivially known to be one. More...
 

Macros

#define GET_OP_LIST
 
#define GET_ATTRDEF_LIST
 
#define GET_ATTRDEF_CLASSES
 
#define GET_OP_CLASSES
 

Enumerations

enum  GPUMemorySpace { kGenericMemorySpace = 0, kGlobalMemorySpace = 1, kSharedMemorySpace = 3 }
 GPU memory space identifiers. More...
 

Functions

static ParseResult parseAsyncDependencies (OpAsmParser &parser, Type &asyncTokenType, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &asyncDependencies)
 Parses an optional list of async operands with an optional leading keyword. More...
 
static void printAsyncDependencies (OpAsmPrinter &printer, Operation *op, Type asyncTokenType, OperandRange asyncDependencies)
 Prints optional async dependencies with its leading keyword. More...
 
static ParseResult parseAllReduceOperation (AsmParser &parser, AllReduceOperationAttr &attr)
 
static void printAllReduceOperation (AsmPrinter &printer, Operation *op, AllReduceOperationAttr attr)
 
static void printSizeAssignment (OpAsmPrinter &p, KernelDim3 size, KernelDim3 operands, KernelDim3 ids)
 
static ParseResult parseSizeAssignment (OpAsmParser &parser, MutableArrayRef< OpAsmParser::UnresolvedOperand > sizes, MutableArrayRef< OpAsmParser::UnresolvedOperand > regionSizes, MutableArrayRef< OpAsmParser::UnresolvedOperand > indices)
 
static ParseResult parseLaunchFuncOperands (OpAsmParser &parser, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &argNames, SmallVectorImpl< Type > &argTypes)
 
static void printLaunchFuncOperands (OpAsmPrinter &printer, Operation *, OperandRange operands, TypeRange types)
 
static ParseResult parseAttributions (OpAsmParser &parser, StringRef keyword, SmallVectorImpl< OpAsmParser::Argument > &args)
 Parses a GPU function memory attribution. More...
 
static void printAttributions (OpAsmPrinter &p, StringRef keyword, ArrayRef< BlockArgument > values)
 
static LogicalResult verifyAttributions (Operation *op, ArrayRef< BlockArgument > attributions, unsigned memorySpace)
 
static bool isLastMemrefDimUnitStride (MemRefType type)
 Return true if the last dimension of the MemRefType has unit stride. More...
 
static LogicalResult foldMemRefCast (Operation *op)
 This is a common class used for patterns of the form "someop(memrefcast) -> someop". More...
 

Macro Definition Documentation

◆ GET_ATTRDEF_CLASSES

#define GET_ATTRDEF_CLASSES

Definition at line 1401 of file GPUDialect.cpp.

◆ GET_ATTRDEF_LIST

#define GET_ATTRDEF_LIST

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 1404 of file GPUDialect.cpp.

◆ GET_OP_LIST

#define GET_OP_LIST

Enumeration Type Documentation

◆ GPUMemorySpace

GPU memory space identifiers.

Enumerator
kGenericMemorySpace 

Generic memory space identifier.

kGlobalMemorySpace 

Global memory space identifier.

kSharedMemorySpace 

Shared memory space identifier.

Definition at line 89 of file GPUDialect.cpp.

Function Documentation

◆ foldMemRefCast()

static LogicalResult foldMemRefCast ( Operation op)
static

This is a common class used for patterns of the form "someop(memrefcast) -> someop".

It folds the source of any memref.cast into the root operation directly.

Definition at line 1246 of file GPUDialect.cpp.

References mlir::RewritePatternSet::add(), mlir::RewriterBase::eraseOp(), mlir::failure(), mlir::Value::getDefiningOp(), mlir::Operation::getNumOperands(), mlir::Operation::getOpOperands(), mlir::OpRewritePattern< SourceOp >::OpRewritePattern(), mlir::RewriterBase::replaceOp(), mlir::success(), value, and mlir::verify().

◆ isLastMemrefDimUnitStride()

static bool isLastMemrefDimUnitStride ( MemRefType  type)
static

Return true if the last dimension of the MemRefType has unit stride.

Also return true for memrefs with no strides.

Definition at line 1154 of file GPUDialect.cpp.

References mlir::failed(), mlir::getStridesAndOffset(), and mlir::verify().

◆ parseAllReduceOperation()

static ParseResult parseAllReduceOperation ( AsmParser parser,
AllReduceOperationAttr &  attr 
)
static

◆ parseAsyncDependencies()

static ParseResult parseAsyncDependencies ( OpAsmParser parser,
Type asyncTokenType,
SmallVectorImpl< OpAsmParser::UnresolvedOperand > &  asyncDependencies 
)
static

Parses an optional list of async operands with an optional leading keyword.

(async)? ([ ssa-id-list ])?

This method is used by the tablegen assembly format for async ops as well.

Definition at line 278 of file GPUDialect.cpp.

References mlir::AsmParser::emitError(), mlir::AsmParser::getBuilder(), mlir::AsmParser::getCurrentLocation(), mlir::OpAsmParser::getNumResults(), mlir::Builder::getType(), mlir::AsmParser::OptionalSquare, mlir::OpAsmParser::parseOperandList(), mlir::AsmParser::parseOptionalKeyword(), and mlir::succeeded().

Referenced by parseSizeAssignment().

◆ parseAttributions()

static ParseResult parseAttributions ( OpAsmParser parser,
StringRef  keyword,
SmallVectorImpl< OpAsmParser::Argument > &  args 
)
static

◆ parseLaunchFuncOperands()

static ParseResult parseLaunchFuncOperands ( OpAsmParser parser,
SmallVectorImpl< OpAsmParser::UnresolvedOperand > &  argNames,
SmallVectorImpl< Type > &  argTypes 
)
static

◆ parseSizeAssignment()

◆ printAllReduceOperation()

static void printAllReduceOperation ( AsmPrinter printer,
Operation op,
AllReduceOperationAttr  attr 
)
static

Definition at line 361 of file GPUDialect.cpp.

◆ printAsyncDependencies()

static void printAsyncDependencies ( OpAsmPrinter printer,
Operation op,
Type  asyncTokenType,
OperandRange  asyncDependencies 
)
static

Prints optional async dependencies with its leading keyword.

(async)? ([ ssa-id-list ])?

Definition at line 294 of file GPUDialect.cpp.

References mlir::emitError(), and mlir::success().

◆ printAttributions()

static void printAttributions ( OpAsmPrinter p,
StringRef  keyword,
ArrayRef< BlockArgument values 
)
static

◆ printLaunchFuncOperands()

static void printLaunchFuncOperands ( OpAsmPrinter printer,
Operation ,
OperandRange  operands,
TypeRange  types 
)
static

◆ printSizeAssignment()

static void printSizeAssignment ( OpAsmPrinter p,
KernelDim3  size,
KernelDim3  operands,
KernelDim3  ids 
)
static

◆ verifyAttributions()

static LogicalResult verifyAttributions ( Operation op,
ArrayRef< BlockArgument attributions,
unsigned  memorySpace 
)
static