1 //===- GPUDialect.h - MLIR Dialect for GPU Kernels --------------*- C++ -*-===//
2 //
3 // Part of the LLVM 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/Builders.h"
18 #include "mlir/IR/BuiltinTypes.h"
19 #include "mlir/IR/Dialect.h"
20 #include "mlir/IR/FunctionSupport.h"
21 #include "mlir/IR/OpDefinition.h"
22 #include "mlir/IR/OpImplementation.h"
23 #include "mlir/IR/SymbolTable.h"
24 #include "mlir/Interfaces/SideEffectInterfaces.h"
25 
26 namespace mlir {
27 class FuncOp;
28 
29 namespace gpu {
30 
31 /// Utility class for the GPU dialect to represent triples of `Value`s
32 /// accessible through `.x`, `.y`, and `.z` similarly to CUDA notation.
33 struct KernelDim3 {
34   Value x;
35   Value y;
36   Value z;
37 };
38 
39 class AsyncTokenType
40     : public Type::TypeBase<AsyncTokenType, Type, TypeStorage> {
41 public:
42   // Used for generic hooks in TypeBase.
43   using Base::Base;
44 };
45 
46 // Adds a `gpu.async.token` to the front of the argument list.
47 void addAsyncDependency(Operation *op, Value token);
48 
49 } // end namespace gpu
50 } // end namespace mlir
51 
52 #include "mlir/Dialect/GPU/GPUOpsDialect.h.inc"
53 
54 #include "mlir/Dialect/GPU/GPUOpInterfaces.h.inc"
55 
56 #define GET_OP_CLASSES
57 #include "mlir/Dialect/GPU/GPUOps.h.inc"
58 
59 #endif // MLIR_DIALECT_GPU_GPUDIALECT_H
60