-
Notifications
You must be signed in to change notification settings - Fork 745
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
[SYCL] Represent JointMatrixINTEL type as extension type #8343
Conversation
@jcranmer-intel please take a look if implementation like this makes sense |
llvm/docs/SPIRVUsage.rst
Outdated
OpTypeReserveId ``spirv.ReserveId`` (none) | ||
OpTypeQueue ``spirv.Queue`` (none) | ||
OpTypePipe ``spirv.Pipe`` access qualifier | ||
OpTypePipeStorage ``spirv.PipeStorage`` (none) |
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.
Probably, JointMatrixINTEL should also be mentioned here at least in intel/llvm repo
// 'tf32' interpretation is mapped to '0' | ||
return getJointMatrixINTELExtType<true>(CompTy, TemplateArgs, 0); | ||
} else if (LlvmTyName == "bfloat16") { | ||
CompTy = llvm::Type::getInt16Ty(getLLVMContext()); |
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.
LLVM has a bfloat
type, so surely it would make more sense to use that instead of i16
? Or is there something about the JointMatrixINTEL spec that I'm missing?
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 thing is that in SPIR-V we don't have bfloat type (yet?). Instead we have conversion instructions and using short
value as bfloat16 storage. Same for SYCL - here bfloat16
class is a wrapper around int16 storage
. So for the consistency int16
is used here as well, though there is no other reason not to reuse LLVM's bf16
(just because we still will replace it with int16
in SPIR-V). So I lean towards appying this suggestion.
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.
Actually, lets keep i16 to be aligned with SPIR-V spec. Once we have proper SPIR-V bf16 type we can start generating in by DPC++ compiler either here or elsewhere.
) The expected representation is: target("spirv.JointMatrixINTEL", %element_type, %rows%, %cols%, %scope%, %use%, (optional) %element_type_interpretation%) TODO: figure out, how to deal with the switch from old API (Matrix has Layout) to new API (Layout was removed) Depends on: #1799 intel/llvm#8343
The expected representation is: target("spirv.JointMatrixINTEL", %element_type, %rows%, %cols%, %scope%, %use%, (optional) %element_type_interpretation%) TODO: figure out, how to deal with the switch from old API (Matrix has Layout) to new API (Layout was removed) Depends on: intel#1799 intel#8343 Original commit: KhronosGroup/SPIRV-LLVM-Translator@ee03f5f
Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
7707bb0
to
b9529a6
Compare
Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
@intel/dpcpp-cfe-reviewers please take a look |
So, why don't we use built-in type instead of parsing the Matrix type from headers? |
Which one? I don't see the conversation resolved. Until then we need to unblock switch to opaque pointers. |
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.
Well, that is just a switch from one fragile solution to another. A couple of nits to comments, otherwise lgtm.
Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
@intel/llvm-reviewers-runtime please take a look at test changes in sycl directory |
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.
sycl/test/matrix
changes LGTM
// CHECK: @_Z2f2{{.*}}(%spirv.JointMatrixINTEL._long_10_2_0_0 | ||
void f2(__spv::__spirv_JointMatrixINTEL<uint64_t, 10, 2, 0, 0> *matrix) {} | ||
// CHECK: @_Z2f2{{.*}}(target("spirv.JointMatrixINTEL", i64, 10, 2, 0, 0, 0) | ||
void f2(__spv::__spirv_JointMatrixINTEL<uint64_t, 10, 2, 0, 0, 0> *matrix) {} |
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.
@aelovikov-intel here is the test for unsigned. Would you mind if I won't duplicate it in sycl headers?
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.
Hmm, I'm not sure what's the purpose of the SYCL RT tests then, but yes, no need for unsigned there.
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.
Well, matrix API is changing overtime, so having several compilation tests using real headers is good to have. One the extension is stable we will remove them (note, the E2E tests were in different repo and require specific hardware)
@intel/llvm-gatekeepers please help with merge. From what I see and ESIMD tests are known issues reported elsewhere |
@MrSidims - Could you please push a merge commit? Most of these failures should have been fixed on tip, so hopefully we should see fewer CI failures now. |
sure, done! |
…el#8343)" It appears to be, that mem2reg and SROA passes can't handle target extension type properly. It means, that with turned on optimizations alloca/load/store sequences of joint matrix types won't be eliminated. It results in a crash in IGC since it can't handle such case yet. Note, it means that matrix samples compiled with -O0 also don't work now. So we have to (temporary?) revert this patch. This reverts commit 6f8e456.
…9841) This reverts commit 4447a50. Previous attempt: #8343 What changed: One extra patch is being added to the headers: ca0595b with this patch clang won't generate llvm.memcpy for trivial c'tor. So later on inst combine won't replace it with a cast to i64 followed by load + store which SROA + mem2reg won't be able to handle for target extension types. It adds: ConvertSYCLJointMatrixINTELType - Convert SYCL joint_matrix type which is represented as a pointer to a structure to LLVM extension type with the parameters that follow SPIR-V JointMatrixINTEL type. The expected representation is: target("spirv.JointMatrixINTEL", %element_type, %rows%, %cols%, %scope%, %use%, (optional) %element_type_interpretation%) Better approach is to introduce joint matrix type to clang, but it's off the table now, since we are lacking OpenCL spec. Co-authored-by: Joshua Cranmer <joshua.cranmer@intel.com> --------- Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com> Co-authored-by: Alexey Bader <alexey.bader@intel.com>
…ntel#9841) This reverts commit 4447a50. Previous attempt: intel#8343 What changed: One extra patch is being added to the headers: intel@ca0595b with this patch clang won't generate llvm.memcpy for trivial c'tor. So later on inst combine won't replace it with a cast to i64 followed by load + store which SROA + mem2reg won't be able to handle for target extension types. It adds: ConvertSYCLJointMatrixINTELType - Convert SYCL joint_matrix type which is represented as a pointer to a structure to LLVM extension type with the parameters that follow SPIR-V JointMatrixINTEL type. The expected representation is: target("spirv.JointMatrixINTEL", %element_type, %rows%, %cols%, %scope%, %use%, (optional) %element_type_interpretation%) Better approach is to introduce joint matrix type to clang, but it's off the table now, since we are lacking OpenCL spec. Co-authored-by: Joshua Cranmer <joshua.cranmer@intel.com> --------- Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com> Co-authored-by: Alexey Bader <alexey.bader@intel.com>
…get ext type The expected representation is: target("spirv.JointMatrixINTEL", %element_type, %rows%, %cols%, %scope%, %use%, (optional) %element_type_interpretation%) TODO: figure out, how to deal with the switch from old API (Matrix has Layout) to new API (Layout was removed) Depends on: intel/llvm#8343
…get ext type The expected representation is: target("spirv.JointMatrixINTEL", %element_type, %rows%, %cols%, %scope%, %use%, (optional) %element_type_interpretation%) TODO: figure out, how to deal with the switch from old API (Matrix has Layout) to new API (Layout was removed) Depends on: intel/llvm#8343
…get ext type The expected representation is: target("spirv.JointMatrixINTEL", %element_type, %rows%, %cols%, %scope%, %use%, (optional) %element_type_interpretation%) TODO: figure out, how to deal with the switch from old API (Matrix has Layout) to new API (Layout was removed) Depends on: intel/llvm#8343
This patch is build on top of https://reviews.llvm.org/D141008
It adds:
ConvertSYCLJointMatrixINTELType - Convert SYCL joint_matrix type
which is represented as a pointer to a structure to LLVM extension type
with the parameters that follow SPIR-V JointMatrixINTEL type.
The expected representation is:
target("spirv.JointMatrixINTEL", %element_type, %rows%, %cols%, %scope%,
%use%, (optional) %element_type_interpretation%)
Better approach is to introduce joint matrix type to clang, but it's off the table now, since we are lacking OpenCL
spec.
The SPIR-V spec