yum-mirror/glslang

git clone https://git.yummers.dev/yum-mirror/glslang

Jeff BolzImplement GL_NV_cooperative_vector1b65bd60

main
3.2 KiB96 linesraw
1#version 450 core
2#extension GL_KHR_memory_scope_semantics : enable
3#extension GL_NV_cooperative_vector : enable
4#extension GL_EXT_shader_explicit_arithmetic_types : enable
5#extension GL_EXT_buffer_reference : enable
6#extension GL_EXT_nonuniform_qualifier : enable
7
8layout (local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
9
10layout(set = 0, binding = 0) buffer MatrixBuf {
11    float16_t matrixData[];
12} matrixBuf;
13
14layout(set = 0, binding = 0) buffer MatrixBuf2 {
15    int8_t matrixData[];
16} matrixBuf2;
17
18layout(constant_id = 0) const int matrixLayout = gl_CooperativeVectorMatrixLayoutColumnMajorNV;
19
20void main()
21{
22    coopvecNV<float, 5> v = coopvecNV<float, 5>(0.0);
23
24    vec3 x = vec3(1.0), y = vec3(2.0);
25    coopvecNV<float, 5> v2 = coopvecNV<float, 5>(x, y);
26
27    const vec3 x2 = vec3(1.0), y2 = vec3(2.0);
28    coopvecNV<float, 5> v3 = coopvecNV<float, 5>(x2, y2);
29
30    vec3 x3 = vec3(4, 5, 6), y3 = vec3(7, 8, 9);
31
32    coopvecNV<float, 5> v4 = coopvecNV<float, 5>(x3.zyx, y3.zzy);
33
34    coopvecNV<float16_t, 5> v5 = coopvecNV<float16_t, 5>(v4);
35
36    coopvecNV<float, 5> v6;
37
38    v6 = v + v2;
39    v6 = v - v2;
40    v6 = v * v2;
41    v6 = v / v2;
42
43    v6 += v;
44    v6 -= v;
45    v6 *= v;
46    v6 /= v;
47
48    float f;
49    v6 *= f;
50    v6 *= 5.0;
51
52    int len = v6.length();
53
54    v6[0] = f;
55    v6[4] = 5.0;
56
57    f += (v += v)[4];
58    v6 = v;
59
60    coopvecNV<float, 20> v7;
61    coopvecNV<float, 100> v8;
62    coopVecMatMulNV(v8, v7, gl_ComponentTypeFloat16NV, matrixBuf.matrixData, 11, gl_ComponentTypeFloat16NV, 100, 20, gl_CooperativeVectorMatrixLayoutRowMajorNV, false, 300);
63    coopvecNV<int8_t, 20> v9;
64    coopvecNV<int32_t, 100> v10;
65    uint32_t matrixOffset = 11;
66    coopVecMatMulNV(v10, v9, gl_ComponentTypeSignedInt8NV, matrixBuf2.matrixData, matrixOffset, gl_ComponentTypeSignedInt8NV, 100, 20, gl_CooperativeVectorMatrixLayoutColumnMajorNV, true, 300);
67
68    coopvecNV<float16_t, 2> f162 = coopvecNV<float16_t, 2>(v7.length());
69
70    float16_t f16;
71    coopvecNV<float16_t, 1> f161 = coopvecNV<float16_t, 1>(f16);
72
73    coopvecNV<float16_t, 7> v11, v12, v13;
74
75    v11 = max(v11, v12);
76    v11 = min(v11, v12);
77    v11 = step(v11, v12);
78    v11 = clamp(v11, v12, v13);
79    v11 = exp(v11);
80    v11 = log(v11);
81    v11 = tanh(v11);
82    v11 = atan(v11);
83    v11 = fma(v11, v12, v13);
84
85    coopVecMatMulAddNV(v8, v7, gl_ComponentTypeFloat16NV, matrixBuf.matrixData, 11, gl_ComponentTypeFloat16NV, matrixBuf.matrixData, 50, gl_ComponentTypeFloat16NV, 100, 20, gl_CooperativeVectorMatrixLayoutRowMajorNV, false, 300);
86    uint32_t biasOffset = 11;
87    coopVecMatMulAddNV(v10, v9, gl_ComponentTypeSignedInt8NV, matrixBuf2.matrixData, matrixOffset, gl_ComponentTypeSignedInt8NV, matrixBuf2.matrixData, biasOffset, gl_ComponentTypeSignedInt8NV, 100, 20, gl_CooperativeVectorMatrixLayoutColumnMajorNV, true, 300);
88
89    coopvecNV<uint32_t, 20> v14;
90    coopVecMatMulNV(v10, v14, gl_ComponentTypeSignedInt8PackedNV, matrixBuf2.matrixData, matrixOffset, gl_ComponentTypeSignedInt8NV, 100, 20, matrixLayout, true, 300);
91
92    f += (v += v)[len];
93}
94
95coopvecNV<float16_t, 1> foo(coopvecNV<float16_t, 1> x) { return x; }
96coopvecNV<float16_t, 2> foo(coopvecNV<float16_t, 2> x) { return x; }