Skip to content

Commit aff90c1

Browse files
authored
[SM6.10] Add LinAlgMatrix ops validation tests for all stages (microsoft#8242)
Adds IR validation tests for all Matrix LinAlg ops for all stages. Part of microsoft#8211
1 parent 54c21f7 commit aff90c1

10 files changed

Lines changed: 2292 additions & 0 deletions

File tree

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
; REQUIRES: dxil-1-10
2+
; RUN: %dxv %s 2>&1 | FileCheck %s
3+
4+
; CHECK: Validation succeeded.
5+
6+
target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64"
7+
target triple = "dxil-ms-dx"
8+
9+
%dx.types.Handle = type { i8* }
10+
%dx.types.ResBind = type { i32, i32, i32, i8 }
11+
%struct.AmpPayload.0 = type { [2 x float] }
12+
%dx.types.LinAlgMatrixC4M5N4U2S2 = type { i8* }
13+
%dx.types.LinAlgMatrixC4M5N4U0S2 = type { i8* }
14+
%dx.types.LinAlgMatrixC4M4N5U1S2 = type { i8* }
15+
%dx.types.ResourceProperties = type { i32, i32 }
16+
%struct.RWByteAddressBuffer = type { i32 }
17+
18+
@"\01?SharedArr@@3PAMA" = external addrspace(3) global [64 x float], align 4
19+
20+
define void @mainAS() {
21+
22+
%1 = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 0, i32 0, i32 0, i8 1 }, i32 0, i1 false) ; CreateHandleFromBinding(bind,index,nonUniformIndex)
23+
%handle = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %1, %dx.types.ResourceProperties { i32 4107, i32 0 }) ; AnnotateHandle(res,props) resource: RWByteAddressBuffer
24+
25+
;
26+
; Built-ins allowed in all stages
27+
;
28+
29+
; dx.op.linAlgMatrixAccumulate
30+
%v1 = call %dx.types.LinAlgMatrixC4M5N4U2S2 @dx.op.linAlgMatrixAccumulate.mC4M5N4U2S2.mC4M5N4U0S2.mC4M4N5U1S2(i32 -2147483624, %dx.types.LinAlgMatrixC4M5N4U0S2 undef, %dx.types.LinAlgMatrixC4M4N5U1S2 undef) ; LinAlgMatrixAccumulate(matrixLHS,matrixRHS)
31+
32+
; dx.op.linAlgMatrixAccumulateToDescriptor
33+
call void @dx.op.linAlgMatrixAccumulateToDescriptor.mC4M5N4U0S2(i32 -2147483621, %dx.types.LinAlgMatrixC4M5N4U0S2 undef, %dx.types.Handle %handle, i32 1, i32 2, i32 3) ; LinAlgMatrixAccumulateToDescriptor(matrix,handle,offset,stride,layout)
34+
35+
; dx.op.linAlgMatrixLength
36+
%v2 = call i32 @dx.op.linAlgMatrixLength.mC4M5N4U0S2(i32 -2147483632, %dx.types.LinAlgMatrixC4M5N4U0S2 undef) ; LinAlgMatrixLength(matrix)
37+
38+
; dx.op.linAlgMatrixLoadFromDescriptor
39+
%v3 = call %dx.types.LinAlgMatrixC4M5N4U0S2 @dx.op.linAlgMatrixLoadFromDescriptor.mC4M5N4U0S2(i32 -2147483634, %dx.types.Handle %handle, i32 5, i32 5, i32 5) ; LinAlgMatrixLoadFromDescriptor(handle,offset,stride,layout)
40+
41+
; dx.op.linAlgMatrixOuterProduct
42+
%v4 = call %dx.types.LinAlgMatrixC4M5N4U0S2 @dx.op.linAlgMatrixOuterProduct.mC4M5N4U0S2.v4i32.v4i32(i32 -2147483619, <4 x i32> <i32 9, i32 9, i32 9, i32 9>, <4 x i32> <i32 3, i32 3, i32 3, i32 3>) ; LinAlgMatrixOuterProduct(vectorA,vectorB)
43+
44+
; dx.op.linAlgMatrixQueryAccumulatorLayout
45+
%v5 = call i32 @dx.op.linAlgMatrixQueryAccumulatorLayout(i32 -2147483626) ; LinAlgMatrixQueryAccumulatorLayout()
46+
47+
; dx.op.linAlgMatVecMul
48+
%v6 = call <4 x i32> @dx.op.linAlgMatVecMul.v4i32.mC4M5N4U0S2.v4i32(i32 -2147483623, %dx.types.LinAlgMatrixC4M5N4U0S2 %v4, <4 x i32> <i32 9, i32 9, i32 9, i32 9>, i32 1) ; LinAlgMatVecMul(matrix,inputVector,interpretation)
49+
50+
; dx.op.linAlgMatVecMulAdd
51+
%v7 = call <4 x i32> @dx.op.linAlgMatVecMulAdd.v4i32.mC4M5N4U0S2.v4i32.v4i32(i32 -2147483622, %dx.types.LinAlgMatrixC4M5N4U0S2 %v4, <4 x i32> <i32 9, i32 9, i32 9, i32 9>, i32 2, <4 x i32> <i32 7, i32 7, i32 7, i32 7>, i32 3) ; LinAlgMatVecMulAdd(matrix,inputVector,inputInterpretation,biasVector,biasInterpretation)
52+
53+
;
54+
; Built-ins restricted to compute, mesh and amplification shaders
55+
;
56+
57+
; dx.op.linAlgCopyConvertMatrix
58+
%v8 = call %dx.types.LinAlgMatrixC4M4N5U1S2 @dx.op.linAlgCopyConvertMatrix.mC4M4N5U1S2.mC4M5N4U0S2(i32 -2147483635, %dx.types.LinAlgMatrixC4M5N4U0S2 %v4, i1 true) ; LinAlgCopyConvertMatrix(srcMatrix,transpose)
59+
60+
; dx.op.linAlgFillMatrix
61+
%v9 = call %dx.types.LinAlgMatrixC4M5N4U0S2 @dx.op.linAlgFillMatrix.mC4M5N4U0S2.i32(i32 -2147483636, i32 15) ; LinAlgFillMatrix(value)
62+
63+
; dx.op.linAlgMatrixGetCoordinate
64+
%v10 = call <2 x i32> @dx.op.linAlgMatrixGetCoordinate.mC4M5N4U0S2(i32 -2147483631, %dx.types.LinAlgMatrixC4M5N4U0S2 %v9, i32 0) ; LinAlgMatrixGetCoordinate(matrix,threadLocalIndex)
65+
66+
; dx.op.linAlgMatrixGetElement
67+
%v11 = call float @dx.op.linAlgMatrixGetElement.f32.mC4M5N4U0S2(i32 -2147483630, %dx.types.LinAlgMatrixC4M5N4U0S2 %v9, i32 0) ; LinAlgMatrixGetElement(matrix,threadLocalIndex)
68+
69+
; dx.op.linAlgMatrixMultiply
70+
%v12 = call %dx.types.LinAlgMatrixC4M5N4U2S2 @dx.op.linAlgMatrixMultiply.mC4M5N4U2S2.mC4M5N4U0S2.mC4M4N5U1S2(i32 -2147483625, %dx.types.LinAlgMatrixC4M5N4U0S2 %v9, %dx.types.LinAlgMatrixC4M4N5U1S2 %v8) ; LinAlgMatrixMultiply(matrixA,matrixB)
71+
72+
; dx.op.linAlgMatrixMultiplyAccumulate
73+
%v13 = call %dx.types.LinAlgMatrixC4M5N4U2S2 @dx.op.linAlgMatrixMultiplyAccumulate.mC4M5N4U2S2.mC4M5N4U0S2.mC4M4N5U1S2.mC4M5N4U2S2(i32 -2147483637, %dx.types.LinAlgMatrixC4M5N4U0S2 %v9, %dx.types.LinAlgMatrixC4M4N5U1S2 %v8, %dx.types.LinAlgMatrixC4M5N4U2S2 %v12) ; LinAlgMatrixMultiplyAccumulate(matrixA,matrixB,matrixC)
74+
75+
; dx.op.linAlgMatrixSetElement
76+
%v14 = call %dx.types.LinAlgMatrixC4M5N4U0S2 @dx.op.linAlgMatrixSetElement.mC4M5N4U0S2.mC4M5N4U0S2.i32(i32 -2147483629, %dx.types.LinAlgMatrixC4M5N4U0S2 %v9, i32 1, i32 1) ; LinAlgMatrixSetElement(matrix,threadLocalIndex,value)
77+
78+
; dx.op.linAlgMatrixStoreToDescriptor
79+
call void @dx.op.linAlgMatrixStoreToDescriptor.mC4M5N4U0S2(i32 -2147483628, %dx.types.LinAlgMatrixC4M5N4U0S2 %v14, %dx.types.Handle %handle, i32 1, i32 2, i32 3) ; LinAlgMatrixStoreToDescriptor(matrix,handle,offset,stride,layout)
80+
81+
; dx.op.linAlgMatrixAccumulateToMemory
82+
call void @dx.op.linAlgMatrixAccumulateToMemory.mC4M5N4U0S2.f32(i32 -2147483620, %dx.types.LinAlgMatrixC4M5N4U0S2 %v14, float addrspace(3)* getelementptr inbounds ([64 x float], [64 x float] addrspace(3)* @"\01?SharedArr@@3PAMA", i32 0, i32 0), i32 0, i32 0, i32 0) ; LinAlgMatrixAccumulateToMemory(matrix,memory,offset,stride,layout)
83+
84+
; dx.op.linAlgMatrixLoadFromMemory
85+
%v15 = call %dx.types.LinAlgMatrixC4M5N4U0S2 @dx.op.linAlgMatrixLoadFromMemory.mC4M5N4U0S2.f32(i32 -2147483633, float addrspace(3)* getelementptr inbounds ([64 x float], [64 x float] addrspace(3)* @"\01?SharedArr@@3PAMA", i32 0, i32 0), i32 0, i32 0, i32 0) ; LinAlgMatrixLoadFromMemory(memory,offset,stride,layout)
86+
87+
; dx.op.linAlgMatrixStoreToMemory
88+
call void @dx.op.linAlgMatrixStoreToMemory.mC4M5N4U0S2.f32(i32 -2147483627, %dx.types.LinAlgMatrixC4M5N4U0S2 %v15, float addrspace(3)* getelementptr inbounds ([64 x float], [64 x float] addrspace(3)* @"\01?SharedArr@@3PAMA", i32 0, i32 0), i32 0, i32 0, i32 0) ; LinAlgMatrixStoreToMemory(matrix,memory,offset,stride,layout)
89+
90+
%2 = alloca %struct.AmpPayload.0, align 8
91+
call void @dx.op.dispatchMesh.struct.AmpPayload.0(i32 173, i32 8, i32 1, i32 1, %struct.AmpPayload.0* nonnull %2) ; DispatchMesh(threadGroupCountX,threadGroupCountY,threadGroupCountZ,payload)
92+
93+
ret void
94+
}
95+
96+
; Function Attrs: nounwind
97+
declare %dx.types.LinAlgMatrixC4M5N4U2S2 @dx.op.linAlgMatrixMultiply.mC4M5N4U2S2.mC4M5N4U0S2.mC4M4N5U1S2(i32, %dx.types.LinAlgMatrixC4M5N4U0S2, %dx.types.LinAlgMatrixC4M4N5U1S2) #0
98+
99+
; Function Attrs: nounwind
100+
declare %dx.types.LinAlgMatrixC4M5N4U2S2 @dx.op.linAlgMatrixAccumulate.mC4M5N4U2S2.mC4M5N4U0S2.mC4M4N5U1S2(i32, %dx.types.LinAlgMatrixC4M5N4U0S2, %dx.types.LinAlgMatrixC4M4N5U1S2) #0
101+
102+
; Function Attrs: nounwind
103+
declare void @dx.op.linAlgMatrixStoreToDescriptor.mC4M5N4U0S2(i32, %dx.types.LinAlgMatrixC4M5N4U0S2, %dx.types.Handle, i32, i32, i32) #0
104+
105+
; Function Attrs: nounwind
106+
declare void @dx.op.linAlgMatrixAccumulateToDescriptor.mC4M5N4U0S2(i32, %dx.types.LinAlgMatrixC4M5N4U0S2, %dx.types.Handle, i32, i32, i32) #0
107+
108+
; Function Attrs: nounwind
109+
declare i32 @dx.op.linAlgMatrixLength.mC4M5N4U0S2(i32, %dx.types.LinAlgMatrixC4M5N4U0S2) #0
110+
111+
; Function Attrs: nounwind
112+
declare %dx.types.LinAlgMatrixC4M5N4U0S2 @dx.op.linAlgMatrixLoadFromDescriptor.mC4M5N4U0S2(i32, %dx.types.Handle, i32, i32, i32) #0
113+
114+
; Function Attrs: nounwind
115+
declare %dx.types.LinAlgMatrixC4M5N4U0S2 @dx.op.linAlgMatrixOuterProduct.mC4M5N4U0S2.v4i32.v4i32(i32, <4 x i32>, <4 x i32>) #0
116+
117+
; Function Attrs: nounwind
118+
declare i32 @dx.op.linAlgMatrixQueryAccumulatorLayout(i32) #0
119+
120+
; Function Attrs: nounwind
121+
declare <4 x i32> @dx.op.linAlgMatVecMul.v4i32.mC4M5N4U0S2.v4i32(i32, %dx.types.LinAlgMatrixC4M5N4U0S2, <4 x i32>, i32) #0
122+
123+
; Function Attrs: nounwind
124+
declare <4 x i32> @dx.op.linAlgMatVecMulAdd.v4i32.mC4M5N4U0S2.v4i32.v4i32(i32, %dx.types.LinAlgMatrixC4M5N4U0S2, <4 x i32>, i32, <4 x i32>, i32) #0
125+
126+
; Function Attrs: nounwind
127+
declare %dx.types.LinAlgMatrixC4M4N5U1S2 @dx.op.linAlgCopyConvertMatrix.mC4M4N5U1S2.mC4M5N4U0S2(i32, %dx.types.LinAlgMatrixC4M5N4U0S2, i1) #0
128+
129+
; Function Attrs: nounwind
130+
declare %dx.types.LinAlgMatrixC4M5N4U0S2 @dx.op.linAlgFillMatrix.mC4M5N4U0S2.i32(i32, i32) #0
131+
132+
; Function Attrs: nounwind
133+
declare <2 x i32> @dx.op.linAlgMatrixGetCoordinate.mC4M5N4U0S2(i32, %dx.types.LinAlgMatrixC4M5N4U0S2, i32) #0
134+
135+
; Function Attrs: nounwind
136+
declare float @dx.op.linAlgMatrixGetElement.f32.mC4M5N4U0S2(i32, %dx.types.LinAlgMatrixC4M5N4U0S2, i32) #0
137+
138+
; Function Attrs: nounwind
139+
declare %dx.types.LinAlgMatrixC4M5N4U2S2 @dx.op.linAlgMatrixMultiplyAccumulate.mC4M5N4U2S2.mC4M5N4U0S2.mC4M4N5U1S2.mC4M5N4U2S2(i32, %dx.types.LinAlgMatrixC4M5N4U0S2, %dx.types.LinAlgMatrixC4M4N5U1S2, %dx.types.LinAlgMatrixC4M5N4U2S2) #0
140+
141+
; Function Attrs: nounwind
142+
declare %dx.types.LinAlgMatrixC4M5N4U0S2 @dx.op.linAlgMatrixSetElement.mC4M5N4U0S2.mC4M5N4U0S2.i32(i32, %dx.types.LinAlgMatrixC4M5N4U0S2, i32, i32) #0
143+
144+
; Function Attrs: nounwind
145+
declare void @dx.op.linAlgMatrixStoreToMemory.mC4M5N4U0S2.f32(i32, %dx.types.LinAlgMatrixC4M5N4U0S2, float addrspace(3)*, i32, i32, i32) #0
146+
147+
; Function Attrs: nounwind
148+
declare void @dx.op.linAlgMatrixAccumulateToMemory.mC4M5N4U0S2.f32(i32, %dx.types.LinAlgMatrixC4M5N4U0S2, float addrspace(3)*, i32, i32, i32) #0
149+
150+
; Function Attrs: nounwind
151+
declare %dx.types.LinAlgMatrixC4M5N4U0S2 @dx.op.linAlgMatrixLoadFromMemory.mC4M5N4U0S2.f32(i32, float addrspace(3)*, i32, i32, i32) #0
152+
153+
; Function Attrs: nounwind readnone
154+
declare %dx.types.Handle @dx.op.annotateHandle(i32, %dx.types.Handle, %dx.types.ResourceProperties) #1
155+
156+
; Function Attrs: nounwind readnone
157+
declare %dx.types.Handle @dx.op.createHandleFromBinding(i32, %dx.types.ResBind, i32, i1) #1
158+
159+
; Function Attrs: nounwind
160+
declare void @dx.op.dispatchMesh.struct.AmpPayload.0(i32, i32, i32, i32, %struct.AmpPayload.0*) #0
161+
162+
attributes #0 = { nounwind }
163+
attributes #1 = { nounwind readnone }
164+
165+
!dx.targetTypes = !{!0, !1, !2}
166+
!llvm.ident = !{!3}
167+
!dx.version = !{!4}
168+
!dx.valver = !{!4}
169+
!dx.shaderModel = !{!5}
170+
!dx.resources = !{!6}
171+
!dx.entryPoints = !{!9}
172+
173+
!0 = !{%dx.types.LinAlgMatrixC4M5N4U0S2 undef, i32 4, i32 5, i32 4, i32 0, i32 2}
174+
!1 = !{%dx.types.LinAlgMatrixC4M4N5U1S2 undef, i32 4, i32 4, i32 5, i32 1, i32 2}
175+
!2 = !{%dx.types.LinAlgMatrixC4M5N4U2S2 undef, i32 4, i32 5, i32 4, i32 2, i32 2}
176+
!3 = !{!"dxc(private) 1.9.0.15241 (main, 1f63535ae)"}
177+
!4 = !{i32 1, i32 10}
178+
!5 = !{!"as", i32 6, i32 10}
179+
!6 = !{null, !7, null, null}
180+
!7 = !{!8}
181+
!8 = !{i32 0, %struct.RWByteAddressBuffer* undef, !"", i32 0, i32 0, i32 1, i32 11, i1 false, i1 false, i1 false, null}
182+
!9 = !{void ()* @mainAS, !"mainAS", null, !6, !10}
183+
!10 = !{i32 0, i64 8589934608, i32 10, !11}
184+
!11 = !{!12, i32 8}
185+
!12 = !{i32 8, i32 1, i32 1}

0 commit comments

Comments
 (0)