-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[mlir][amdgpu] Add amdgpu.make_dma_descriptor #169407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[mlir][amdgpu] Add amdgpu.make_dma_descriptor #169407
Conversation
🐧 Linux x64 Test Results
|
|
|
||
| let summary = "TODO"; | ||
| let description = [{ | ||
| TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
| custom<DynamicIndexList>($atomic_barrier_dynamic_indices, $atomic_barrier_static_indices) | ||
| `:` type($atomic_barrier_address) `)`)? | ||
| ( `iterate` $global_increment^ `,` $lds_increment `,` $iteration_count )? | ||
| attr-dict `:` qualified(type($base)) `to` type(results) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here
| printer << staticSize.getValue(); | ||
| } else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: return early and no else
| found in TensorLoadToLDSOp and TensorStoreFromLDSOp in the rocdl dialect. | ||
| }]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add an mlir example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping on this
| int64_t staticVal; | ||
| if (parser.parseOptionalInteger(staticVal).has_value()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit/optional: you could push the definition inside the if, since it not used elsewhere
| int64_t staticVal; | |
| if (parser.parseOptionalInteger(staticVal).has_value()) { | |
| if (int64_t staticVal; parser.parseOptionalInteger(staticVal).has_value()) { |
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
| found in TensorLoadToLDSOp and TensorStoreFromLDSOp in the rocdl dialect. | ||
| }]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping on this
| 2D and 3D tensors may be iterated over by setting $global_increment, $lds_increment, and $iteration_count. | ||
| $global_increment determines how much to increment the starting global memory address per iteration in units of the $base's element type. | ||
| $lds_increment determines how much to increment the starting LDS address per iteration in units of the $base's element type. | ||
| $iterate_count determines how many times to iterate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here: can you add a few mlir examples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few examples, I will ask for clarification on iteration.
| OptionalParseResult parseResult = parser.parseOptionalInteger(staticVal); | ||
| if (parseResult.has_value()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: why do we need this as a local variable, instead of using in the if condition like before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| //===----------------------------------------------------------------------===// | ||
|
|
||
| LogicalResult MakeDmaDescriptorOp::verify() { | ||
| if (getGlobalStaticStrides()->back() != 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does something else already guarantee there's at least one element?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kuhar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but wait from a stamp from @krzysz00 before merging
Co-authored-by: Jakub Kuderski <[email protected]>
|
|
||
| // TODO: Define a custom printer, parser to avoid space between $src/%dst and indices. | ||
| let assemblyFormat = [{ | ||
| $src custom<DynamicIndexList>($src_indices, $src_indices_const) `,` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is out of date
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Arguments<(ins | ||
| AMDGPU_TDMBaseType: $base, | ||
| Variadic<Index>: $global_dynamic_sizes, | ||
| OptionalAttr<DenseI64ArrayAttr>: $global_static_sizes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Existing examples of a similar pattern - subview, for example, don't use an optional here
(The static indices array must have a fixed length and use -1 to refer to dynamic dimensions)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| OptionalAttr<IndexAttr>: $every_const, | ||
| Optional<AnyMemRef>: $atomic_barrier_address, | ||
| Variadic<Index>: $atomic_barrier_dynamic_indices, | ||
| OptionalAttr<DenseI64ArrayAttr>: $atomic_barrier_static_indices, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The atomic barrier part is more of a pure memref operation, and should probably just take Variadic<Index> (it's selecting a pointer, unlike all the other bits, which are doing size/strides/offsets subview-style)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Optional<Index>: $pad, | ||
| OptionalAttr<IndexAttr>: $pad_const, | ||
| Optional<Index>: $every, | ||
| OptionalAttr<IndexAttr>: $every_const, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be an optional index - doesn't need attribute splitting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| OptionalAttr<DenseI64ArrayAttr>: $shared_static_sizes, | ||
| Optional<Index>: $pad, | ||
| OptionalAttr<IndexAttr>: $pad_const, | ||
| Optional<Index>: $every, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call this padEvery? Or something else more descriptive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } // namespace | ||
|
|
||
| static ParseResult | ||
| parseDynamicIndex(OpAsmParser &parser, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need this
For the non-vararg cases, we can use an argument.
For the vararg cases (sizes, strides, etc.) we'll want to use the same machinery memref.subview does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (getGlobalStaticStrides()->back() != 1) { | ||
| return emitOpError("strides for the innermost dimension must be 1."); | ||
| } | ||
| return success(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing validation conditions: Number of strides == number of sizes == number of offsets, and the global and LDS tiles have the same dimensions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| attr-dict `:` qualified(type($base)) `->` type(results) | ||
| }]; | ||
|
|
||
| let hasVerifier = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll want the OpFoldResult helpers for combining the static/dynamic parts, I claim.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point here but let's leave that for the next PR which will add the lowering.
No description provided.