Skip to content

[SPIR-V][DOC] Add 'Use' parameter to TypeJointMatrixINTEL #5944

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

Closed
wants to merge 8 commits into from

Conversation

MrSidims
Copy link
Contributor

@MrSidims MrSidims commented Apr 1, 2022

'Use' is an optional parameter that shows where in a math operation the matrix
is used. It must be the result of a constant instruction with scalar
'integer type'.

Signed-off-by: Dmitry Sidorov [email protected]

'Use' is an optional parameter that shows where in a math operation the matrix
is used. It must be the result of a constant instruction with scalar
'integer type'.

Signed-off-by: Dmitry Sidorov <[email protected]>
@MrSidims MrSidims requested a review from a team as a code owner April 1, 2022 11:45
MrSidims added a commit to KhronosGroup/SPIRV-LLVM-Translator that referenced this pull request Apr 1, 2022
'Use' is an optional parameter that shows where in a math operation the matrix
is used. It must be the result of a constant instruction with scalar
'integer type'.

Spec: intel/llvm#5944

Signed-off-by: Dmitry Sidorov <[email protected]>
vmaksimo pushed a commit to vmaksimo/llvm that referenced this pull request Apr 4, 2022
'Use' is an optional parameter that shows where in a math operation the matrix
is used. It must be the result of a constant instruction with scalar
'integer type'.

Spec: intel#5944

Signed-off-by: Dmitry Sidorov <[email protected]>

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@348da24
@dkhaldi dkhaldi self-requested a review April 4, 2022 15:24
svenvh pushed a commit to svenvh/SPIRV-LLVM-Translator that referenced this pull request Jun 21, 2022
'Use' is an optional parameter that shows where in a math operation the matrix
is used. It must be the result of a constant instruction with scalar
'integer type'.

Spec: intel/llvm#5944

Signed-off-by: Dmitry Sidorov <[email protected]>
(cherry picked from commit 348da24)
svenvh pushed a commit to KhronosGroup/SPIRV-LLVM-Translator that referenced this pull request Jun 22, 2022
'Use' is an optional parameter that shows where in a math operation the matrix
is used. It must be the result of a constant instruction with scalar
'integer type'.

Spec: intel/llvm#5944

Signed-off-by: Dmitry Sidorov <[email protected]>
(cherry picked from commit 348da24)
Quetzonarch pushed a commit to Quetzonarch/SPIRV-LLVM-Translator that referenced this pull request Jul 13, 2022
'Use' is an optional parameter that shows where in a math operation the matrix
is used. It must be the result of a constant instruction with scalar
'integer type'.

Spec: intel/llvm#5944

Signed-off-by: Dmitry Sidorov <[email protected]>


1+|Capability: +
*{capability_name}*
1+| 7 | {OpTypeJointMatrixINTEL_token}
1+| 8 | {OpTypeJointMatrixINTEL_token}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use is an optional argument, which means that operands count is not always 8, it should probably say 7+ instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks!

@@ -192,11 +200,15 @@ It must be the result of a constant instruction. +
+
'Scope' is memory scope for operations on the matrix. It must be the
result of a constant instruction with scalar 'integer type'. +
+
'Use' is an optional parameter that shows where in a math operation the matrix
is used. It must be the result of a constant instruction with scalar
Copy link
Contributor

Choose a reason for hiding this comment

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

Integer type is already defined as scalar in the core spec, so you can simplify this definition and probably spell integer starting with uppercase letter to highlight that you are referring to an existing term.

Also: do we need to explicitly specify that the value is expected to be from Use table above and not just any arbitrary integer (like 42, for example)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well, it makes sense, but "'integer type' scalar" is a commonly used wording across https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.pdf . Regarding the values - added this info, though there is some misalignments in the spec, guess, which should be corrected.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be best to document this similar to the way Scope <id>s are documented:

Must be an <id> of a 32-bit integer scalar. Its value is expected to be one of the values in the table below. If validation rules or the client API require a constant <id>, it is invalid for it to not be one of these values. If non-constant <id> are allowed, behavior is undefined if <id> is not one of these values.

Since the Use is an optional parameter what is the behavior if the optional parameter is omitted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the great suggestion, Ben! I've also aligned Layout parameter with this definition. And I'll adopt it for Scope as well.

Since the Use is an optional parameter what is the behavior if the optional parameter is omitted?

Per new revision it's now a mandatory parameter, before that it was up to the devices' backends to decide.

Signed-off-by: dmitry.sidorov <[email protected]>
@MrSidims MrSidims force-pushed the private/MrSidims/add-matrix-use branch from 85a18d1 to 699248a Compare August 16, 2022 14:50
@MrSidims MrSidims requested a review from AlexeySachkov August 16, 2022 14:54
@bader bader added spec extension All issues/PRs related to extensions specifications Documentation Missing documentation for the code, compiler or runtime features, etc. SPIR-V Issues related to SPIRV-LLVM-Translator labels Sep 6, 2022
Copy link
Contributor

@bashbaug bashbaug left a comment

Choose a reason for hiding this comment

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

Hi, I have a few questions and found a few spelling errors.

Comment on lines 258 to 263
'Layout' indicates how the values loaded from memory are arranged.
It must be the result of a constant instruction. +
+
'Scope' is syncronization scope for operation on the matrix. It must be the
result of a constant instruction with scalar 'integer type'. +
Must be an '<id>' of a 32-bit integer scalar. Its value is expected to be one of
the values in the table 3.XX, Matrix Layout. If validation rules or the client API
require a constant '<id>', it is invalid for it to not be one of these values.
If non-constant '<id>' are allowed, behavior is undefined if '<id>' is not one of
these values. +
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be changed to say that "Layout" indicates how the values in memory are arranged? Presumably the way the values loaded from memory are arranged are indicated by the "Layout" of the OpTypeJointMatrix type Result Type instead.

Also, just to confirm: there are no requirements that the two layouts match, and the full set of combinations must be supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied

Also, just to confirm: there are no requirements that the two layouts match, and the full set of combinations must be supported?

AFAIU yes

@@ -270,11 +306,19 @@ where elements of the matrix must be stored and arranged according to 'Layout'.
'Stride' is the number of elements in memory between beginnings of successive
rows, columns (or words) of the 'Object'. It must be a scalar integer type. +
+
'Layout' indicates how the values stored to memory are arranged. It must be the
result of a constant instruction. +
'Layout' indicates how the values stored to memory are arranged.
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the load instruction, I would find this sentence to be clearer if it were changed to say that it indicates how the values that are stored are arranged in memory (assuming this is the intent).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied

either _Workgroup_ or _Subgroup_ from the table 3.27. Scope <id>. If validation
rules or the client API require a constant '<id>', it is invalid for it to not
be one of these values. If non-constant '<id>' are allowed, behavior is
undefined if '<id>' is not one of these values. +
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing there are some other requirements for the "Use" of the A, B, and C matrix operands that should be documented here? As an example it is probably an error (or, if it cannot be statically checked, behavior is undefined) if the "Use" for the A matrix is MatrixB or Accumulator?

Same goes for all other variants of OpJointMatrixXXMadINTEL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied

| 0 | *MatrixA* | *{capability_name}*
| 1 | *MatrixB* | *{capability_name}*
| 2 | *Accumulator* | *{capability_name}*
| 3 | *Unnecessary* | *{capability_name}*
Copy link
Contributor

Choose a reason for hiding this comment

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

The Unnecessary use is never documented anywhere in this extension. Should it be?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's actually a spec bug, there shouldn't be any Unnecessary value for Use parameter, instead there should be Unused Layout value. I'll update the spec

Signed-off-by: Sidorov, Dmitry <[email protected]>
@MrSidims MrSidims requested a review from bashbaug October 7, 2022 12:50
Signed-off-by: Sidorov, Dmitry <[email protected]>
| 3 | *PackedB* +
Suitable for VNNI instructions | *{capability_name}*
| 4 | *Unused* +
| 3 | *Unused* +
Only valid for _TypeJointMatrixINTEL_ | *{capability_name}*
Copy link
Contributor

Choose a reason for hiding this comment

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

change use names to: A, B, Accumulator
or
MatrixA, matrixB, MatrixAccumulator

@MrSidims MrSidims requested a review from gmlueck November 8, 2022 15:23
Copy link
Contributor

@dkhaldi dkhaldi left a comment

Choose a reason for hiding this comment

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

LGTM

@MrSidims
Copy link
Contributor Author

MrSidims commented Feb 1, 2023

Closing as no longer needed

@MrSidims MrSidims closed this Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Missing documentation for the code, compiler or runtime features, etc. spec extension All issues/PRs related to extensions specifications SPIR-V Issues related to SPIRV-LLVM-Translator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants