MLIR  20.0.0git
Namespaces | Macros | Functions
Utils.cpp File Reference
#include "mlir/Dialect/GPU/TransformOps/Utils.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/GPU/TransformOps/GPUTransformOps.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/IR/DeviceMappingInterface.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/Transform/IR/TransformDialect.h"
#include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/IR/AffineExpr.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/Value.h"
#include "mlir/IR/Visitors.h"
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Debug.h"

Go to the source code of this file.

Namespaces

 mlir
 Include the generated interface declarations.
 
 mlir::transform
 
 mlir::transform::gpu
 

Macros

#define DEBUG_TYPE   "gpu-transforms"
 
#define DBGS()   (llvm::dbgs() << '[' << DEBUG_TYPE << "] ")
 
#define LDBG(X)   LLVM_DEBUG(DBGS() << (X) << "\n")
 
#define DBGS_ALIAS()   (llvm::dbgs() << '[' << DEBUG_TYPE_ALIAS << "] ")
 

Functions

template<typename ThreadOrBlockIdOp >
static Value buildLinearId (RewriterBase &rewriter, Location loc, ArrayRef< OpFoldResult > originalBasisOfr)
 Return a flattened thread id for the workgroup with given sizes. More...
 
template<typename ThreadOrBlockIdOp >
static GpuIdBuilderFnType commonLinearIdBuilderFn (int64_t multiplicity=1)
 Create a linear id builder that takes the originalBasisOfr and decompose it in the basis of forallMappingSizes. More...
 
template<typename ThreadOrBlockIdOp >
static GpuIdBuilderFnType common3DIdBuilderFn (int64_t multiplicity=1)
 Create a simple 3-D id builder that takes the originalBasisOfr The 3-D id builder returns a 3-D vector of ids for indexing and 3-D sizes. More...
 
DiagnosedSilenceableFailure mlir::transform::gpu::checkGpuLimits (TransformOpInterface transformOp, std::optional< int64_t > gridDimX, std::optional< int64_t > gridDimY, std::optional< int64_t > gridDimZ, std::optional< int64_t > blockDimX, std::optional< int64_t > blockDimY, std::optional< int64_t > blockDimZ)
 Determine if the size of the kernel configuration is supported by the GPU architecture being used. More...
 
DiagnosedSilenceableFailure mlir::transform::gpu::createGpuLaunch (RewriterBase &rewriter, Location loc, TransformOpInterface transformOp, LaunchOp &launchOp, std::optional< int64_t > gridDimX, std::optional< int64_t > gridDimY, std::optional< int64_t > gridDimZ, std::optional< int64_t > blockDimX, std::optional< int64_t > blockDimY, std::optional< int64_t > blockDimZ)
 
DiagnosedSilenceableFailure mlir::transform::gpu::alterGpuLaunch (RewriterBase &rewriter, LaunchOp gpuLaunch, TransformOpInterface transformOp, std::optional< int64_t > gridDimX, std::optional< int64_t > gridDimY, std::optional< int64_t > gridDimZ, std::optional< int64_t > blockDimX, std::optional< int64_t > blockDimY, std::optional< int64_t > blockDimZ)
 Alter kernel configuration of the given kernel. More...
 

Macro Definition Documentation

◆ DBGS

#define DBGS ( )    (llvm::dbgs() << '[' << DEBUG_TYPE << "] ")

Definition at line 44 of file Utils.cpp.

◆ DBGS_ALIAS

#define DBGS_ALIAS ( )    (llvm::dbgs() << '[' << DEBUG_TYPE_ALIAS << "] ")

Definition at line 46 of file Utils.cpp.

◆ DEBUG_TYPE

#define DEBUG_TYPE   "gpu-transforms"

Definition at line 42 of file Utils.cpp.

◆ LDBG

#define LDBG (   X)    LLVM_DEBUG(DBGS() << (X) << "\n")

Definition at line 45 of file Utils.cpp.

Function Documentation

◆ buildLinearId()

template<typename ThreadOrBlockIdOp >
static Value buildLinearId ( RewriterBase rewriter,
Location  loc,
ArrayRef< OpFoldResult originalBasisOfr 
)
static

◆ common3DIdBuilderFn()

template<typename ThreadOrBlockIdOp >
static GpuIdBuilderFnType common3DIdBuilderFn ( int64_t  multiplicity = 1)
static

Create a simple 3-D id builder that takes the originalBasisOfr The 3-D id builder returns a 3-D vector of ids for indexing and 3-D sizes.

  • ids for predicate generation.

Definition at line 135 of file Utils.cpp.

References mlir::OpBuilder::create(), mlir::AffineExpr::floorDiv(), mlir::getAffineDimExpr(), mlir::Builder::getContext(), mlir::Builder::getIndexType(), and mlir::affine::makeComposedFoldedAffineApply().

◆ commonLinearIdBuilderFn()

template<typename ThreadOrBlockIdOp >
static GpuIdBuilderFnType commonLinearIdBuilderFn ( int64_t  multiplicity = 1)
static

Create a linear id builder that takes the originalBasisOfr and decompose it in the basis of forallMappingSizes.

The linear id builder returns an n-D vector of ids for indexing and 1-D size + id for predicate generation.

Definition at line 78 of file Utils.cpp.

References mlir::computeProduct(), mlir::computeStrides(), DBGS, mlir::delinearize(), mlir::AffineExpr::floorDiv(), mlir::getAffineDimExpr(), mlir::getAsIndexOpFoldResult(), mlir::Builder::getContext(), mlir::affine::makeComposedAffineApply(), and mlir::affine::makeComposedFoldedAffineApply().