My Project
GPUDialect.h
Go to the documentation of this file.
1 //===- GPUDialect.h - MLIR Dialect for GPU Kernels --------------*- C++ -*-===//
2 //
3 // Part of the MLIR Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the GPU kernel-related operations and puts them in the
10 // corresponding dialect.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_DIALECT_GPU_GPUDIALECT_H
15 #define MLIR_DIALECT_GPU_GPUDIALECT_H
16 
17 #include "mlir/IR/Dialect.h"
19 #include "mlir/IR/OpDefinition.h"
21 #include "mlir/IR/SymbolTable.h"
22 
23 namespace mlir {
24 class FuncOp;
25 
26 namespace gpu {
27 
30 class GPUDialect : public Dialect {
31 public:
33  explicit GPUDialect(MLIRContext *context);
35  static StringRef getDialectNamespace() { return "gpu"; }
36 
39  static StringRef getContainerModuleAttrName() {
40  return "gpu.container_module";
41  }
42 
44  static StringRef getDialectName();
45 
47  static StringRef getKernelFuncAttrName() { return "gpu.kernel"; }
48 
50  static StringRef getKernelModuleAttrName() { return "gpu.kernel_module"; }
51 
54  static bool isKernel(Operation *op);
55 
58  // TODO(zinenko,herhut): consider generalizing this.
59  static unsigned getNumWorkgroupDimensions() { return 3; }
60 
63  static unsigned getWorkgroupAddressSpace() { return 3; }
64 
67  static unsigned getPrivateAddressSpace() { return 5; }
68 
70  NamedAttribute attr) override;
71 };
72 
75 struct KernelDim3 {
79 };
80 
81 #define GET_OP_CLASSES
82 #include "mlir/Dialect/GPU/GPUOps.h.inc"
83 
84 } // end namespace gpu
85 } // end namespace mlir
86 
87 #endif // MLIR_DIALECT_GPU_GPUDIALECT_H
Definition: InferTypeOpInterface.cpp:20
Definition: Operation.h:27
static StringRef getContainerModuleAttrName()
Definition: GPUDialect.h:39
static bool isKernel(Operation *op)
Definition: GPUDialect.cpp:33
static unsigned getNumWorkgroupDimensions()
Definition: GPUDialect.h:59
static StringRef getKernelFuncAttrName()
Get the name of the attribute used to annotate external kernel functions.
Definition: GPUDialect.h:47
Definition: GPUDialect.h:30
Value z
Definition: GPUDialect.h:78
Value x
Definition: GPUDialect.h:76
static StringRef getDialectName()
Get the canonical string name of the dialect.
Definition: GPUDialect.cpp:31
std::pair< Identifier, Attribute > NamedAttribute
Definition: Attributes.h:264
GPUDialect(MLIRContext *context)
Create the dialect in the given context.
Definition: GPUDialect.cpp:38
Definition: LogicalResult.h:18
Value y
Definition: GPUDialect.h:77
Definition: Dialect.h:39
Definition: GPUDialect.h:75
Definition: Value.h:38
static unsigned getWorkgroupAddressSpace()
Definition: GPUDialect.h:63
LogicalResult verifyOperationAttribute(Operation *op, NamedAttribute attr) override
Definition: GPUDialect.cpp:46
static StringRef getKernelModuleAttrName()
Get the name of the attribute used to annotate kernel modules.
Definition: GPUDialect.h:50
Definition: MLIRContext.h:34
static unsigned getPrivateAddressSpace()
Definition: GPUDialect.h:67
static StringRef getDialectNamespace()
Get dialect namespace.
Definition: GPUDialect.h:35