Skip to content

Comments

Reverse translation of arithmetic instructions for cooperative matrixes#2166

Merged
MrSidims merged 1 commit intoKhronosGroup:mainfrom
vmaksimo:matrix-arithmetic-reverse
Oct 4, 2023
Merged

Reverse translation of arithmetic instructions for cooperative matrixes#2166
MrSidims merged 1 commit intoKhronosGroup:mainfrom
vmaksimo:matrix-arithmetic-reverse

Conversation

@vmaksimo
Copy link
Contributor

@vmaksimo vmaksimo commented Sep 27, 2023

Implement translation via SPIR-V friendly calls, as:

  1. the LLVM instructions are not capable to accept target extension types;
  2. matrix arithmetic instructions require additional carry additional rules, which LLVM can not perform (for example while technically Add for vectors and (flattened) matrices is the same - yet for matrices we need to perform extra checks, also mul instruction is complitely different).

As for now some BE would need to recognize and define what to do with a call to __spirv_FMul(matrixA, matrixB). Better option is to map such SPIR-V to an intrinsic or define an appropriate type in LLVM (hence defining rules for GEP and other instructions) , but it's off the table now.

Implement translation via SPIR-V friendly calls, as the LLVM
instructions are not capable to accept target extension types.
@vmaksimo
Copy link
Contributor Author

Please take a look @MrSidims @asudarsa @LU-JOHN

Copy link
Contributor

@MrSidims MrSidims left a comment

Choose a reason for hiding this comment

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

LGTM, but I will discuss it in the call a bit today.

@MrSidims MrSidims requested a review from svenvh September 28, 2023 11:59
@MrSidims
Copy link
Contributor

MrSidims commented Sep 28, 2023

Implement translation via SPIR-V friendly calls, as the LLVM instructions are not capable to accept target extension types.

While it's true - this justification is a bit incorrect. It should be an example, like SPIR-V FMul is being mapped in LLVM for fmul, but matrix multiplication carries special rules, that LLVM can not handle.

LangRef also says, that:
The two arguments to the ‘fmul’ instruction must be [floating-point](https://llvm.org/docs/LangRef.html#t-floating) or [vector](https://llvm.org/docs/LangRef.html#t-vector) of floating-point values. Both arguments must have identical types.

and we technically could represent matrices as vectors, but this wouldn't make fmul working correct and we kinda need new intrinsic functions, but that is another story.

@MrSidims MrSidims merged commit fdc961f into KhronosGroup:main Oct 4, 2023
vmaksimo added a commit to vmaksimo/SPIRV-LLVM-Translator that referenced this pull request Oct 4, 2023
…es (KhronosGroup#2166)

Implement translation via SPIR-V friendly calls, as:

the LLVM instructions are not capable to accept target extension types;
matrix arithmetic instructions require additional carry additional rules, which LLVM can not perform (for example while technically Add for vectors and (flattened) matrices is the same - yet for matrices we need to perform extra checks, also mul instruction is complitely different).
As for now some BE would need to recognize and define what to do with a call to __spirv_FMul(matrixA, matrixB). Better option is to map such SPIR-V to an intrinsic or define an appropriate type in LLVM (hence defining rules for GEP and other instructions) , but it's off the table now.
MrSidims pushed a commit that referenced this pull request Oct 9, 2023
…es (#2166)

Implement translation via SPIR-V friendly calls, as:

the LLVM instructions are not capable to accept target extension types;
matrix arithmetic instructions require additional carry additional rules, which LLVM can not perform (for example while technically Add for vectors and (flattened) matrices is the same - yet for matrices we need to perform extra checks, also mul instruction is complitely different).
As for now some BE would need to recognize and define what to do with a call to __spirv_FMul(matrixA, matrixB). Better option is to map such SPIR-V to an intrinsic or define an appropriate type in LLVM (hence defining rules for GEP and other instructions) , but it's off the table now.
MrSidims pushed a commit to MrSidims/SPIRV-LLVM-Translator that referenced this pull request Mar 25, 2025
…ooperative matrixes (KhronosGroup#2166)

Implement translation via SPIR-V friendly calls, as:

the LLVM instructions are not capable to accept target extension types;
matrix arithmetic instructions require additional carry additional rules, which LLVM can not perform (for example while technically Add for vectors and (flattened) matrices is the same - yet for matrices we need to perform extra checks, also mul instruction is complitely different).
As for now some BE would need to recognize and define what to do with a call to __spirv_FMul(matrixA, matrixB). Better option is to map such SPIR-V to an intrinsic or define an appropriate type in LLVM (hence defining rules for GEP and other instructions) , but it's off the table now.
MrSidims pushed a commit to MrSidims/SPIRV-LLVM-Translator that referenced this pull request Mar 25, 2025
…ooperative matrixes (KhronosGroup#2166)

Implement translation via SPIR-V friendly calls, as:

the LLVM instructions are not capable to accept target extension types;
matrix arithmetic instructions require additional carry additional rules, which LLVM can not perform (for example while technically Add for vectors and (flattened) matrices is the same - yet for matrices we need to perform extra checks, also mul instruction is complitely different).
As for now some BE would need to recognize and define what to do with a call to __spirv_FMul(matrixA, matrixB). Better option is to map such SPIR-V to an intrinsic or define an appropriate type in LLVM (hence defining rules for GEP and other instructions) , but it's off the table now.
MrSidims pushed a commit to MrSidims/SPIRV-LLVM-Translator that referenced this pull request Mar 25, 2025
…ooperative matrixes (KhronosGroup#2166)

Implement translation via SPIR-V friendly calls, as:

the LLVM instructions are not capable to accept target extension types;
matrix arithmetic instructions require additional carry additional rules, which LLVM can not perform (for example while technically Add for vectors and (flattened) matrices is the same - yet for matrices we need to perform extra checks, also mul instruction is complitely different).
As for now some BE would need to recognize and define what to do with a call to __spirv_FMul(matrixA, matrixB). Better option is to map such SPIR-V to an intrinsic or define an appropriate type in LLVM (hence defining rules for GEP and other instructions) , but it's off the table now.
MrSidims pushed a commit to MrSidims/SPIRV-LLVM-Translator that referenced this pull request Mar 25, 2025
…ooperative matrixes (KhronosGroup#2166)

Implement translation via SPIR-V friendly calls, as:

the LLVM instructions are not capable to accept target extension types;
matrix arithmetic instructions require additional carry additional rules, which LLVM can not perform (for example while technically Add for vectors and (flattened) matrices is the same - yet for matrices we need to perform extra checks, also mul instruction is complitely different).
As for now some BE would need to recognize and define what to do with a call to __spirv_FMul(matrixA, matrixB). Better option is to map such SPIR-V to an intrinsic or define an appropriate type in LLVM (hence defining rules for GEP and other instructions) , but it's off the table now.
MrSidims pushed a commit that referenced this pull request Mar 28, 2025
…ooperative matrixes (#2166)

Implement translation via SPIR-V friendly calls, as:

the LLVM instructions are not capable to accept target extension types;
matrix arithmetic instructions require additional carry additional rules, which LLVM can not perform (for example while technically Add for vectors and (flattened) matrices is the same - yet for matrices we need to perform extra checks, also mul instruction is complitely different).
As for now some BE would need to recognize and define what to do with a call to __spirv_FMul(matrixA, matrixB). Better option is to map such SPIR-V to an intrinsic or define an appropriate type in LLVM (hence defining rules for GEP and other instructions) , but it's off the table now.
MrSidims pushed a commit to MrSidims/SPIRV-LLVM-Translator that referenced this pull request Mar 31, 2025
…ooperative matrixes (KhronosGroup#2166)

Implement translation via SPIR-V friendly calls, as:

the LLVM instructions are not capable to accept target extension types;
matrix arithmetic instructions require additional carry additional rules, which LLVM can not perform (for example while technically Add for vectors and (flattened) matrices is the same - yet for matrices we need to perform extra checks, also mul instruction is complitely different).
As for now some BE would need to recognize and define what to do with a call to __spirv_FMul(matrixA, matrixB). Better option is to map such SPIR-V to an intrinsic or define an appropriate type in LLVM (hence defining rules for GEP and other instructions) , but it's off the table now.
MrSidims pushed a commit to MrSidims/SPIRV-LLVM-Translator that referenced this pull request May 11, 2025
…ooperative matrixes (KhronosGroup#2166)

Implement translation via SPIR-V friendly calls, as:

the LLVM instructions are not capable to accept target extension types;
matrix arithmetic instructions require additional carry additional rules, which LLVM can not perform (for example while technically Add for vectors and (flattened) matrices is the same - yet for matrices we need to perform extra checks, also mul instruction is complitely different).
As for now some BE would need to recognize and define what to do with a call to __spirv_FMul(matrixA, matrixB). Better option is to map such SPIR-V to an intrinsic or define an appropriate type in LLVM (hence defining rules for GEP and other instructions) , but it's off the table now.
MrSidims pushed a commit to MrSidims/SPIRV-LLVM-Translator that referenced this pull request Aug 6, 2025
…ooperative matrixes (KhronosGroup#2166)

Implement translation via SPIR-V friendly calls, as:

the LLVM instructions are not capable to accept target extension types;
matrix arithmetic instructions require additional carry additional rules, which LLVM can not perform (for example while technically Add for vectors and (flattened) matrices is the same - yet for matrices we need to perform extra checks, also mul instruction is complitely different).
As for now some BE would need to recognize and define what to do with a call to __spirv_FMul(matrixA, matrixB). Better option is to map such SPIR-V to an intrinsic or define an appropriate type in LLVM (hence defining rules for GEP and other instructions) , but it's off the table now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants