Skip to content

Conversation

@llvm-beanz
Copy link
Collaborator

@llvm-beanz llvm-beanz commented Dec 17, 2025

This PR folds in a bunch of changes to address feedback that has been backed up. One big change is the removal of annotateMatrix in favor of type mangling. Using type mangling reduces the need for the compiler to emit and de-duplicate annotateMatrix calls, and aligns more closely to how we'll support this in modern LLVM using target extension types. This is a first step to addressing matrix lifetime issues.

This should remove the need for the annotate matrix calls by mangling
the type annotations into the handle.
* Added transpose compile-time argument to `cast` (Resolves microsoft#653).
* Renamed `Accumulate` operations that operate on memory to
  `InterlockedAccumulate`, and clarify atomicity (Resolves microsoft#744).
* Replaced `SumAccumulate` with new `Accumulate` on A and B matrices
  (Resolves microsoft#755, Resolves microsoft#618).
* Layout for `Matrix::Load` on thread-scope matrices is now compile-time
  constant (Resolves microsoft#681).
* `InterlockedAccumulate` for thead-scope matrices no longer takes a
  layout parameter since it must be OuterProductOptimal.
* Added clarification of matrix stage availability (Resolves microsoft#574).
* Fixed the form of the outerProduct DXIL op to not create a matrix
  (Resolves microsoft#696).
@V-FEXrt
Copy link
Collaborator

V-FEXrt commented Dec 17, 2025

Since this PR is a larger collection of fixups I'll throw anoter comment related to the spec that I noticed that should be quick to fix or reject!

Should matrixQueryAccumulatorLayout take a vector overload here? It doesn't have any parameters and the return type is constant. Only way it would make since is if the value is conditional of the type of the matrix

declare i32 @dx.op.matrixQueryAccumulatorLayout.v[NUM][TY](

typename hlsl::enable_if<Use == MatrixUse::Accumulator && ScopeLocal == Scope,

// When Scope != Thread, the following overloads are available:
template <MatrixUseEnum UseLocal = Use>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this template parameter UseLocal. It's not used except to make sure it's equal to Use (the default) which is required to be equal to MatrixUse::Accumulator. I see it on a number of methods where it's unused. Is this to satisfy some requirement elsewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's how SFINAE works (see: #590 (comment)).

llvm-beanz and others added 3 commits December 18, 2025 11:05
Co-authored-by: Ashley Coleman <ascoleman@microsoft.com>
Co-authored-by: Ashley Coleman <ascoleman@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment