Skip to content

Commit d0c9a15

Browse files
committed
Add JointMatrixGetElementCoordINTEL instruction
The instruction returns (Row, Column) coordinate of dynamically selected element of a matrix Updated version of the spec is here intel/llvm#8175 Instruction correctness checks and get coord related capability will be added later among non-backward compatible changes. Signed-off-by: Sidorov, Dmitry <[email protected]>
1 parent 35f8b4d commit d0c9a15

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

lib/SPIRV/libSPIRV/SPIRVInstruction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3325,6 +3325,7 @@ _SPIRV_OP(JointMatrixLoad, true, 6, true)
33253325
_SPIRV_OP(JointMatrixStore, false, 5, true)
33263326
_SPIRV_OP(JointMatrixMad, true, 7)
33273327
_SPIRV_OP(JointMatrixWorkItemLength, true, 4)
3328+
_SPIRV_OP(JointMatrixGetElementCoord, true, 5)
33283329
#undef _SPIRV_OP
33293330

33303331
class SPIRVSplitBarrierINTELBase : public SPIRVInstTemplateBase {

lib/SPIRV/libSPIRV/SPIRVOpCodeEnumInternal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ _SPIRV_OP_INTERNAL(JointMatrixStoreINTEL, internal::OpJointMatrixStoreINTEL)
1111
_SPIRV_OP_INTERNAL(JointMatrixMadINTEL, internal::OpJointMatrixMadINTEL)
1212
_SPIRV_OP_INTERNAL(JointMatrixWorkItemLengthINTEL,
1313
internal::OpJointMatrixWorkItemLengthINTEL)
14+
_SPIRV_OP_INTERNAL(JointMatrixGetElementCoordINTEL,
15+
internal::OpJointMatrixGetElementCoordINTEL)
1416
_SPIRV_OP_INTERNAL(ComplexFMulINTEL, internal::ComplexFMulINTEL)
1517
_SPIRV_OP_INTERNAL(ComplexFDivINTEL, internal::ComplexFDivINTEL)
1618
_SPIRV_OP_INTERNAL(MaskedGatherINTEL, internal::OpMaskedGatherINTEL)

lib/SPIRV/libSPIRV/spirv_internal.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ enum InternalOp {
4949
IOpConvertFToTF32INTEL = 6426,
5050
IOpMaskedGatherINTEL = 6428,
5151
IOpMaskedScatterINTEL = 6429,
52+
IOpJointMatrixGetElementCoordINTEL = 6440,
5253
IOpPrev = OpMax - 2,
5354
IOpForward
5455
};
@@ -106,6 +107,8 @@ _SPIRV_OP(Op, JointMatrixLoadINTEL)
106107
_SPIRV_OP(Op, JointMatrixStoreINTEL)
107108
_SPIRV_OP(Op, JointMatrixMadINTEL)
108109
_SPIRV_OP(Op, JointMatrixWorkItemLengthINTEL)
110+
_SPIRV_OP(Op, JointMatrixGetElementCoordINTEL)
111+
109112
_SPIRV_OP(Capability, HWThreadQueryINTEL)
110113
_SPIRV_OP(BuiltIn, SubDeviceIDINTEL)
111114
_SPIRV_OP(BuiltIn, GlobalHWThreadIDINTEL)

test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_element.ll

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,25 @@
55
; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
66
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM
77

8-
; CHECK-SPIRV: Capability JointMatrixINTEL
9-
; CHECK-SPIRV: Extension "SPV_INTEL_joint_matrix"
10-
; CHECK-SPIRV: TypeInt [[#TypeInt:]] 64
11-
; CHECK-SPIRV: TypeFloat [[#TypeFloat:]] 32
12-
; CHECK-SPIRV: TypeJointMatrixINTEL [[#TypeMatrix:]] [[#TypeFloat]] [[#]] [[#]] [[#]] [[#]]
8+
; CHECK-SPIRV-DAG: Capability JointMatrixINTEL
9+
; CHECK-SPIRV-DAG: Extension "SPV_INTEL_joint_matrix"
10+
; CHECK-SPIRV-DAG: TypeInt [[#TypeInt32:]] 32
11+
; CHECK-SPIRV-DAG: TypeInt [[#TypeInt64:]] 64
12+
; CHECK-SPIRV-DAG: TypeFloat [[#TypeFloat:]] 32
13+
; CHECK-SPIRV-DAG: TypeJointMatrixINTEL [[#TypeMatrix:]] [[#TypeFloat]] [[#]] [[#]] [[#]] [[#]]
14+
; CHECK-SPIRV-DAG: TypeVector [[#TypeVec:]] [[#TypeInt32]] 2
1315
; CHECK-SPIRV: Phi [[#TypeMatrix]] [[#Matrix:]]
14-
; CHECK-SPIRV: JointMatrixWorkItemLengthINTEL [[#TypeInt]] [[#]] [[#Matrix]]
16+
; CHECK-SPIRV: JointMatrixWorkItemLengthINTEL [[#TypeInt64]] [[#]] [[#Matrix]]
1517
; CHECK-SPIRV: VectorExtractDynamic [[#TypeFloat]] [[#]] [[#Matrix]] [[#Index:]]
1618
; CHECK-SPIRV: FMul [[#TypeFloat]] [[#NewVal:]] [[#]] [[#]]
1719
; CHECK-SPIRV: VectorInsertDynamic [[#TypeMatrix]] [[#]] [[#Matrix]] [[#NewVal]] [[#Index]]
20+
; CHECK-SPIRV: JointMatrixGetElementCoordINTEL [[#TypeVec]] [[#]] [[#Matrix]] [[#Index]]
1821

1922
; CHECK-LLVM: [[Length:%.*]] = call spir_func i64 @_Z38__spirv_JointMatrixWorkItemLengthINTELPU3AS141__spirv_JointMatrixINTEL__float_16_16_0_3(ptr addrspace(1) [[Matrix:%.*]])
2023
; CHECK-LLVM: [[Elem:%.*]] = call spir_func float @_Z28__spirv_VectorExtractDynamicPU3AS141__spirv_JointMatrixINTEL__float_16_16_0_3l(ptr addrspace(1) [[Matrix]], i64 [[Index:%.*]])
2124
; CHECK-LLVM: [[NewVal:%.*]] = fmul float [[Elem]], 5.000000e+00
2225
; CHECK-LLVM: {{%.*}} = call spir_func ptr addrspace(1) @_Z27__spirv_VectorInsertDynamicPU3AS141__spirv_JointMatrixINTEL__float_16_16_0_3fl(ptr addrspace(1) [[Matrix]], float [[NewVal]], i64 [[Index]])
26+
; CHECK-LLVM: {{%.*}} = call spir_func <2 x i32> @_Z39__spirv_JointMatrixGetElementCoordINTELPU3AS141__spirv_JointMatrixINTEL__float_16_16_0_3l(ptr addrspace(1) [[Matrix]], i64 [[Index]])
2327

2428
source_filename = "/work/tmp/matrix-slice.cpp"
2529
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
@@ -69,6 +73,7 @@ for.body.i: ; preds = %for.cond.i
6973
%call.i.i = tail call spir_func float @_Z28__spirv_VectorExtractDynamicIfLm16ELm16ELN5__spv12MatrixLayoutE0ELNS0_5Scope4FlagE3EmET_PNS0_24__spirv_JointMatrixINTELIS4_XT0_EXT1_EXT2_EXT3_EEET4_(%spirv.JointMatrixINTEL._float_16_16_0_3 addrspace(4)* %A.sroa.0.0.i, i64 %conv.i) #2
7074
%mul.i.i = fmul float %call.i.i, 5.000000e+00
7175
%call5.i.i = tail call spir_func %spirv.JointMatrixINTEL._float_16_16_0_3 addrspace(4)* @_Z27__spirv_VectorInsertDynamicIfLm16ELm16ELN5__spv12MatrixLayoutE0ELNS0_5Scope4FlagE3EmEPNS0_24__spirv_JointMatrixINTELIT_XT0_EXT1_EXT2_EXT3_EEES7_T4_S5_(%spirv.JointMatrixINTEL._float_16_16_0_3 addrspace(4)* %A.sroa.0.0.i, float %mul.i.i, i64 %conv.i) #2
76+
%call6 = tail call spir_func <2 x i32> @_Z39__spirv_JointMatrixGetElementCoordINTELIaLm8ELm32ELN5__spv9MatrixUseE0ELNS0_12MatrixLayoutE0ELNS0_5Scope4FlagE3EEDv2_jPNS0_24__spirv_JointMatrixINTELIT_XT0_EXT1_EXT3_EXT4_EXT2_EEEm(%spirv.JointMatrixINTEL._float_16_16_0_3 addrspace(4)* %A.sroa.0.0.i, i64 %conv.i) #2
7277
%inc.i = add nuw nsw i32 %i.0.i, 1
7378
br label %for.cond.i, !llvm.loop !7
7479

@@ -92,6 +97,9 @@ declare dso_local spir_func %spirv.JointMatrixINTEL._float_16_16_0_3 addrspace(4
9297
; Function Attrs: convergent
9398
declare dso_local spir_func void @_Z29__spirv_JointMatrixStoreINTELIfLm16ELm16ELN5__spv12MatrixLayoutE0ELNS0_5Scope4FlagE3EEvPT_PNS0_24__spirv_JointMatrixINTELIS4_XT0_EXT1_EXT2_EXT3_EEEmS1_S3_i(float addrspace(4)*, %spirv.JointMatrixINTEL._float_16_16_0_3 addrspace(4)*, i64, i32, i32, i32) local_unnamed_addr #1
9499

100+
; Function Attrs: convergent
101+
declare dso_local spir_func <2 x i32> @_Z39__spirv_JointMatrixGetElementCoordINTELIaLm8ELm32ELN5__spv9MatrixUseE0ELNS0_12MatrixLayoutE0ELNS0_5Scope4FlagE3EEDv2_jPNS0_24__spirv_JointMatrixINTELIT_XT0_EXT1_EXT3_EXT4_EXT2_EEEm(%spirv.JointMatrixINTEL._float_16_16_0_3 addrspace(4)*, i64) #2
102+
95103
attributes #0 = { convergent norecurse "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "sycl-module-id"="/work/tmp/matrix-slice.cpp" "uniform-work-group-size"="true" }
96104
attributes #1 = { convergent "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
97105
attributes #2 = { convergent }

0 commit comments

Comments
 (0)