-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathmatrix_scalar_arithmetic.test
More file actions
107 lines (98 loc) · 2.28 KB
/
matrix_scalar_arithmetic.test
File metadata and controls
107 lines (98 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#--- source.hlsl
RWBuffer<int> In : register(u0);
RWBuffer<int> DivOut : register(u1);
RWBuffer<int> MulOut : register(u2);
RWBuffer<int> AddOut : register(u3);
RWBuffer<int> SubOut : register(u4);
[numthreads(6,1,1)]
void main(uint GI : SV_GroupIndex) {
int2x3 A = int2x3(In[0], In[1], In[2],
In[3], In[4], In[5]);
const uint COLS = 3; // int2x3 => 2 rows, 3 columns
uint row = GI / COLS; // 0..1
uint col = GI % COLS; // 0..2
DivOut[GI] = A[row][col] / 2;
MulOut[GI] = A[row][col] * 2;
AddOut[GI] = A[row][col] + 1;
SubOut[GI] = A[row][col] - 1;
}
//--- pipeline.yaml
---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: In
Format: Int32
Data: [ 2, 4, 6, 8, 10, 12 ]
- Name: DivOut
Format: Int32
FillSize: 24
- Name: MulOut
Format: Int32
FillSize: 24
- Name: AddOut
Format: Int32
FillSize: 24
- Name: SubOut
Format: Int32
FillSize: 24
DescriptorSets:
- Resources:
- Name: In
Kind: RWBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: DivOut
Kind: RWBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
- Name: MulOut
Kind: RWBuffer
DirectXBinding:
Register: 2
Space: 0
VulkanBinding:
Binding: 2
- Name: AddOut
Kind: RWBuffer
DirectXBinding:
Register: 3
Space: 0
VulkanBinding:
Binding: 3
- Name: SubOut
Kind: RWBuffer
DirectXBinding:
Register: 4
Space: 0
VulkanBinding:
Binding: 4
...
#--- end
# Bug https://github.com/llvm/offload-test-suite/issues/538
# RUN: split-file %s %t
# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o | FileCheck %s
# CHECK: Name: In
# CHECK: Format: Int32
# CHECK: Data: [ 2, 4, 6, 8, 10, 12 ]
# CHECK: Name: DivOut
# CHECK: Format: Int32
# CHECK: Data: [ 1, 2, 3, 4, 5, 6 ]
# CHECK: Name: MulOut
# CHECK: Format: Int32
# CHECK: Data: [ 4, 8, 12, 16, 20, 24 ]
# CHECK: Name: AddOut
# CHECK: Format: Int32
# CHECK: Data: [ 3, 5, 7, 9, 11, 13 ]
# CHECK: Name: SubOut
# CHECK: Format: Int32
# CHECK: Data: [ 1, 3, 5, 7, 9, 11 ]