"vscode:/vscode.git/clone" did not exist on "ea32ca702b1d81ea3bf7bebb8fcd3c897f61df5d"
builtin.h 5.3 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
/*!
 * \file tl/op/builtin.h
 * \brief Builtin intrinsics.
 *
 */

#ifndef TVM_TL_OP_BUILTIN_H_
#define TVM_TL_OP_BUILTIN_H_

#include "op.h"
11
#include <tvm/ir/transform.h>
12
13
14
15

namespace tvm {
namespace tl {

16
static constexpr const char *kDisableTMALower = "tl.disable_tma_lower";
17
18
static constexpr const char *kDisableWarpSpecialized =
    "tl.disable_warp_specialized";
19
20
static constexpr const char *kConfigIndexBitwidth = "tl.config_index_bitwidth";

21
22
23
/*!
 * \brief tvm intrinsics for TMADescriptor creation for tiled load
 *
24
25
26
 * CuTensorMap* CreateTMADescriptorOp(data_type, rank, global_addr,
 * global_shape..., global_stride..., smem_box..., smem_stride..., interleave,
 * swizzle, l2_promotion, oob_fill)
27
28
 *
 */
29
const Op &CreateTMADescriptorOp();
30
31
32
33

/*!
 * \brief tvm intrinsics for TMADescriptor creation for image to column load
 *
34
35
36
37
 * CuTensorMap* CreateTMAIm2ColDescriptorOp(data_type, rank, global_addr,
 * global_shape..., global_stride..., elem_stride..., lower_corner...,
 * upper_corner..., smme_box_pixel, smem_box_channel, interleave, swizzle,
 * l2_promotion, oob_fill)
38
39
 *
 */
40
const Op &CreateTMAIm2ColDescriptorOp();
41
42
43
44

/*!
 * \brief Create a list of mbarrier with num_threads
 *
45
 * CreateListofMBarrierOp(num_threads0, num_threads1, ...)
46
47
 *
 */
48
const Op &CreateListofMBarrierOp();
49
50
51
52
53
54
55

/*!
 * \brief Get the mbarrier with barrier_id
 *
 * int64_t* GetMBarrier(barrier_id)
 *
 */
56
const Op &GetMBarrierOp();
57
58

/*!
59
60
 * \brief tvm intrinsics for loading data from global tensor descriptor to
 * shared memory
61
62
63
64
 *
 * TMALoadOp(descriptor, mbarrier, smem_data, coord_0, coord_1, ...)
 *
 */
65
const Op &TMALoadOp();
66
67

/*!
68
69
 * \brief tvm intrinsics for loading image from global tensor to columns in
 * shared memory
70
 *
71
72
 * TMALoadOp(descriptor, mbarrier, smem_data, coord_0, coord_1, ...,
 * image_offset, ...)
73
74
 *
 */
75
const Op &TMALoadIm2ColOp();
76
77

/*!
78
79
 * \brief tvm intrinsics for storing data from shared memory to global tensor
 * descriptor
80
81
82
83
 *
 * TMAStoreOp(descriptor, smem_data, coord_0, coord_1, ...)
 *
 */
84
const Op &TMAStoreOp();
85
86
87
88
89
90
91

/*!
 * \brief tvm intrinsics for mbarrier wait with parity bit
 *
 * MBarrierWaitParity(mbarrier, parity)
 *
 */
92
const Op &MBarrierWaitParity();
93
94
95
96
97
98
99

/*!
 * \brief tvm intrinsics for mbarrier expect tx
 *
 * MBarrierExpectTX(mbarrier, transaction_bytes)
 *
 */
100
const Op &MBarrierExpectTX();
101
102
103
104
105
106
107

/*!
 * \brief tvm intrinsics for ldmatrix
 *
 * LDMatrixOp(transposed, num, shared_addr, local_addr)
 *
 */
108
const Op &LDMatrixOp();
109
110
111
112
113
114
115

/*!
 * \brief tvm intrinsics for stmatrix
 *
 * LDMatrixOp(transposed, num, shared_addr, int32_values...)
 *
 */
116
const Op &STMatrixOp();
117
118
119
120
121
122
123

/*!
 * \brief Pack two b16 value into a b32 value
 *
 * int32 PackB16Op(b16_value, b16_value)
 *
 */
124
const Op &PackB16Op();
125
126
127
128
129
130
131

/*!
 * \brief Similar to __syncthreads(), but can be used to sync partial threads
 *
 * SyncThreadsPartialOp(num_partial_threads or mbarrier)
 *
 */
132
const Op &SyncThreadsPartialOp();
133
134
135
136
137
138
139

/*!
 * \brief Issue a shared memory fence for async operations
 *
 * FenceProxyAsync()
 *
 */
140
const Op &FenceProxyAsyncOp();
141

142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*!
 * \brief Indicate arrival of warp issuing TMA_STORE
 *
 * TMAStoreArrive()
 *
 */
const Op &TMAStoreArrive();

/*!
 * \brief Wait for TMA_STORE to finish
 *
 * TMAStoreWait()
 *
 */
const Op &TMAStoreWait();

158
159
160
161
162
163
/*!
 * \brief Set reg hint for warp-specialized branched
 *
 * SetMaxNRegInc(num_reg, is_inc)
 *
 */
164
const Op &SetMaxNReg();
165

166
167
168
169
170
171
172
173
/*!
 * \brief No set reg hint for warp-specialized branched
 *
 * NoSetMaxNReg()
 *
 */
const Op &NoSetMaxNReg();

174
175
176
177
178
179
/*!
 * \brief Wait the previous wgmma to finish
 *
 * WaitWgmma(num_mma)
 *
 */
180
const Op &WaitWgmma();
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229

/*!
 * \brief tvm intrinsic for amd matrix core mfma instructions.
 *
 *  void tvm_mfma(StringImm shape, StringImm A_layout, StringImm B_layout,
 *               StringImm A_dtype, StringImm B_dtype, StringImm C_dtype,
 *               Var multiplicand_a, Expr a_index,
 *               Var multiplicand_b, Expr b_index,
 *               Var accumulator, Expr c_index);
 */
TVM_DLL const Op &tvm_mfma();

/*!
 * \brief tvm intrinsic for storing the result of AMD MFMA into a destination
 * pointer.
 *
 *        There is no real instruction that does that, but we want to hide
 * details of complex index manipulation behind this intrinsic to simplify TIR
 * lowering passes (e.g. LowerWarpMemory) like cuda ptx backend does.
 *
 * void tvm_mfma_store(IntImm m, IntImm n, Var dst_ptr, Var src_ptr, Expr
 * src_offset, Var dst_stride);
 */
TVM_DLL const Op &tvm_mfma_store();

/*!
 * \brief tvm intrinsic for amd rdna matrix core instructions.
 *
 *  void tvm_rdna_wmma(StringImm shape, StringImm A_layout, StringImm B_layout,
 *               StringImm A_dtype, StringImm B_dtype, StringImm C_dtype,
 *               Var multiplicand_a, Expr a_index,
 *               Var multiplicand_b, Expr b_index,
 *               Var accumulator, Expr c_index);
 */
TVM_DLL const Op &tvm_rdna_wmma();

/*!
 * \brief tvm intrinsic for storing the result of AMD RDNA WMMA into a
 * destination pointer.
 *
 *        There is no real instruction that does that, but we want to hide
 * details of complex index manipulation behind this intrinsic to simplify TIR
 * lowering passes (e.g. LowerWarpMemory) like cuda ptx backend does.
 *
 * void tvm_rdna_wmma_store(IntImm m, IntImm n, Var dst_ptr, Var src_ptr, Expr
 * src_offset, Var dst_stride);
 */
TVM_DLL const Op &tvm_rdna_wmma_store();

230
231
} // namespace tl
} // namespace tvm
232

233
#endif //  TVM_TL_OP_BUILTIN_H_