@@ -6,6 +6,7 @@ include "triton/Dialect/TritonGPU/IR/TritonGPUTypes.td"
6
6
include "triton/Dialect/Triton/IR/TritonTypes.td"
7
7
include "mlir/IR/OpBase.td"
8
8
include "mlir/Interfaces/SideEffectInterfaces.td"
9
+ include "triton/Dialect/TritonInstrument/IR/TritonInstrumentAttrDefs.td"
9
10
10
11
//
11
12
// Interfaces
@@ -33,33 +34,43 @@ def TTI_ExperimentalAssertInThreadOp : TTI_Op<"experimental_assert_in_thread", [
33
34
}
34
35
35
36
36
- def TTI_ExperimentalSharedBufferPointersOp : TTI_Op<"experimental_shared_buffer_pointers ", [Pure]> {
37
+ def TTI_ExperimentalBufferPointersOp : TTI_Op<"experimental_buffer_pointers ", [Pure]> {
37
38
let summary = "definte an array of pointers to shared memory buffers";
38
39
let description = [{
39
40
Create a tensor of pointers to shared memory buffers.
40
41
}];
41
- let arguments = (ins DenseI32ArrayAttr:$offsets);
42
+ let arguments = (ins DenseI32ArrayAttr:$offsets, TT_MemTypeAttr:$memType );
42
43
let results = (outs TT_Tensor:$result);
43
44
let assemblyFormat = [{
44
- attr-dict `:` type($result)
45
+ $offsets `,` $memType attr-dict `:` type($result)
45
46
}];
46
47
}
47
48
48
49
49
50
def TTI_ExperimentalCheckOutstandingWritesOp : TTI_Op<"experimental_check_outstanding_writes", [MemoryEffects<[MemWrite<GlobalMemory>]>]> {
50
51
let summary = "check if there are outstanding writes to a buffer guarded by a mbar";
51
52
let description = [{
52
- Check if there are outstanding writes to a buffer guarded by a mbar.
53
+ Check if the writeState tensor has non-zero value associated with the buffer.
54
+
55
+ `writeState` is a tensor of 8b bitfields, where:
56
+ - bit 0: 1 if the buffer is being written to
57
+ - bit 1: 1 if the write is *not* hwPipelined
58
+
59
+ If hwPipelined is true, shift the bitfield by 1 to check the second bit - this
60
+ means that the error won't be triggered if another pipelined write is outstanding.
53
61
}];
54
62
let arguments = (ins
55
63
TTG_MemDescType:$buf,
56
64
TT_Tensor:$buffers,
57
65
TT_PtrLike:$writeBars,
58
66
TypeAttr:$writeBarsType,
67
+ TT_PtrLike:$writeState,
68
+ TypeAttr:$writeStateType,
69
+ I1Attr:$hwPipelined,
59
70
Optional<I1>:$pred
60
71
);
61
72
let assemblyFormat = [{
62
- $buf `{` $buffers `,` $writeBars `(` $writeBarsType `)` `}` (`,` $pred^)? attr-dict `:` type($buf) `,` type($buffers) `,` type($writeBars)
73
+ $buf `{` $buffers `,` $writeBars `(` $writeBarsType `)` `,` $writeState `(` $writeStateType `)` ` }` (`,` $pred^)? `pipelined` $hwPipelined attr-dict `:` type($buf) `,` type($buffers) `,` type($writeBars) `,` type($writeState )
63
74
}];
64
75
let hasVerifier = 1;
65
76
}
@@ -87,18 +98,49 @@ def TTI_ExperimentalCheckOutstandingReadsOp : TTI_Op<"experimental_check_outstan
87
98
def TTI_ExperimentalMarkAsWriteOp : TTI_Op<"experimental_mark_as_write", [MemoryEffects<[MemWrite<GlobalMemory>]>]> {
88
99
let summary = "mark a buffer as being written to using mbar as a guard";
89
100
let description = [{
90
- Mark a buffer as being written to using mbar as a guard.
101
+ Mark a buffer as being written to. It is not yet tracked by a barrier, until
102
+ `commit_write_with_barrier` is called, at which point all the buffers being written
103
+ to are marked as tracked by the barrier.
104
+
105
+ `writeState` is a tensor of 8b bitfields, where:
106
+ - bit 0: 1 if the buffer is being written to
107
+ - bit 1: 1 if the write is *not* hwPipelined
108
+
109
+ If hwPipelined is true, the write won't trigger an error if another pipelined
110
+ write is executed later without waiting for the barrier.
91
111
}];
92
112
let arguments = (ins
93
113
TTG_MemDescType:$buf,
94
- TTG_MemDescType:$mbar,
95
114
TT_Tensor:$buffers,
115
+ TT_PtrLike:$writeState,
116
+ TypeAttr:$writeStateType,
117
+ I1Attr:$hwPipelined,
118
+ Optional<I1>:$pred
119
+ );
120
+ let assemblyFormat = [{
121
+ $buf `{` $buffers `,` $writeState `(` $writeStateType `)` `}` (`,` $pred^)? `pipelined` $hwPipelined attr-dict `:` type($buf) `,` type($buffers) `,` type($writeState)
122
+ }];
123
+ let hasVerifier = 1;
124
+ }
125
+
126
+
127
+ def TTI_ExperimentalCommitWriteWithBarrierOp : TTI_Op<"experimental_commit_write_with_barrier", [MemoryEffects<[MemWrite<GlobalMemory>]>]> {
128
+ let summary = "Mark all buffers being currently written as tracked by the barrier.";
129
+ let description = [{
130
+ For all buffers currently marked in writeState tensor, mark them as tracked by the mbar in
131
+ writeBars tensor.
132
+ }];
133
+ let arguments = (ins
134
+ TTG_MemDescType:$mbar,
135
+ TT_Tensor:$barriers,
96
136
TT_PtrLike:$writeBars,
97
137
TypeAttr:$writeBarsType,
138
+ TT_PtrLike:$writeState,
139
+ TypeAttr:$writeStateType,
98
140
Optional<I1>:$pred
99
141
);
100
142
let assemblyFormat = [{
101
- $buf ` ,` $mbar `{ ` $buffers ` ,` $writeBars `(` $writeBarsType `)` `}` (`,` $pred^)? attr-dict `:` type($buf ) `,` type($mbar ) `,` type($buffers ) `,` type($writeBars )
143
+ $mbar `{` $barriers ` ,` $writeBars `( ` $writeBarsType `)` ` ,` $writeState `(` $writeStateType `)` `}` (`,` $pred^)? attr-dict `:` type($mbar ) `,` type($barriers ) `,` type($writeBars ) `,` type($writeState )
102
144
}];
103
145
let hasVerifier = 1;
104
146
}
@@ -132,13 +174,17 @@ def TTI_ExperimentalClearWriteBarrierOp : TTI_Op<"experimental_clear_write_barri
132
174
}];
133
175
let arguments = (ins
134
176
TTG_MemDescType:$mbar,
177
+ TT_Tensor:$barriers,
135
178
TT_PtrLike:$writeBars,
136
179
TypeAttr:$writeBarsType,
180
+ TT_PtrLike:$writeState,
181
+ TypeAttr:$writeStateType,
137
182
Optional<I1>:$pred
138
183
);
139
184
let assemblyFormat = [{
140
- $mbar `{` $writeBars `(` $writeBarsType `)` `}` (`,` $pred^)? attr-dict `:` type($mbar) `,` type($writeBars)
185
+ $mbar `{` $barriers `,` $ writeBars `(` $writeBarsType `)` `,` $writeState `(` $writeStateType `)` ` }` (`,` $pred^)? attr-dict `:` type($mbar) `,` type($barriers) `,` type($ writeBars) `,` type($writeState )
141
186
}];
187
+ let hasVerifier = 1;
142
188
}
143
189
144
190
@@ -160,6 +206,27 @@ def TTI_ExperimentalClearReadBarrierOp : TTI_Op<"experimental_clear_read_barrier
160
206
let hasVerifier = 1;
161
207
}
162
208
209
+
210
+ def TTI_ExperimentalCheckBarrierWritesClearedOp : TTI_Op<"experimental_check_barrier_writes_cleared", [MemoryEffects<[MemWrite<GlobalMemory>]>]> {
211
+ let summary = "verify that the barrier is not used to track any writes";
212
+ let description = [{
213
+ Verify that the barrier is not used to track any writes.
214
+ }];
215
+ let arguments = (ins
216
+ TTG_MemDescType:$mbar,
217
+ TT_Tensor:$barriers,
218
+ TT_PtrLike:$writeBars,
219
+ TypeAttr:$writeBarsType,
220
+ Optional<I1>:$pred
221
+ );
222
+ let assemblyFormat = [{
223
+ $mbar `{` $barriers `,` $writeBars `(` $writeBarsType `)` `}` (`,` $pred^)? attr-dict `:` type($mbar) `,` type($barriers) `,` type($writeBars)
224
+ }];
225
+ let hasVerifier = 1;
226
+ }
227
+
228
+
229
+ // TODO: Potentially resolve the naming/functionality clash with commit_write_with_barrier
163
230
def TTI_ExperimentalStageWriteForCommitOp : TTI_Op<"experimental_stage_write_for_commit", [MemoryEffects<[MemWrite<GlobalMemory>]>]> {
164
231
let summary = "Preapre to an async copy of a buffer. Staged until commit_group is called.";
165
232
let description = [{
0 commit comments