diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2025-01-30 13:19:13 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-30 13:19:13 -0800 |
| commit | fb052bf4674b55933e6dd9f991c99000c049d216 (patch) | |
| tree | cff94fc924a63fe80ae53cc3a0c15039c171bf7a /tests/cooperative-vector/glsl | |
| parent | 7a8131d312d84f71b1c8776ad83713dea52301f4 (diff) | |
Support cooperative vector including Vulkan-Header (#6228)
* Support cooperative vector including Vulkan-Header
Adding a Slang support for cooperative vector with vulkan-header update.
Diffstat (limited to 'tests/cooperative-vector/glsl')
| -rw-r--r-- | tests/cooperative-vector/glsl/cast.slang | 30 | ||||
| -rw-r--r-- | tests/cooperative-vector/glsl/cast.slang.glsl | 23 | ||||
| -rw-r--r-- | tests/cooperative-vector/glsl/groupshared-sized.slang | 37 | ||||
| -rw-r--r-- | tests/cooperative-vector/glsl/groupshared-sized.slang.glsl | 38 | ||||
| -rw-r--r-- | tests/cooperative-vector/glsl/load-store.slang | 13 | ||||
| -rw-r--r-- | tests/cooperative-vector/glsl/load-store.slang.glsl | 20 | ||||
| -rw-r--r-- | tests/cooperative-vector/glsl/only-arith.slang | 18 | ||||
| -rw-r--r-- | tests/cooperative-vector/glsl/only-arith.slang.glsl | 16 | ||||
| -rw-r--r-- | tests/cooperative-vector/glsl/outer-product-accumulate.slang | 19 | ||||
| -rw-r--r-- | tests/cooperative-vector/glsl/outer-product-accumulate.slang.glsl | 17 | ||||
| -rw-r--r-- | tests/cooperative-vector/glsl/simple.slang | 35 | ||||
| -rw-r--r-- | tests/cooperative-vector/glsl/simple.slang.glsl | 20 |
12 files changed, 286 insertions, 0 deletions
diff --git a/tests/cooperative-vector/glsl/cast.slang b/tests/cooperative-vector/glsl/cast.slang new file mode 100644 index 000000000..263ad5026 --- /dev/null +++ b/tests/cooperative-vector/glsl/cast.slang @@ -0,0 +1,30 @@ +//DISABLE_TEST:CROSS_COMPILE: -profile glsl_450+spirv_1_4 -stage compute -entry computeMain -target spirv-assembly + +RWStructuredBuffer<float> outputBuffer; + +StructuredBuffer<float> buf; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + coopvecNV<int, 8> r_int; + coopvecNV<float, 8> r = coopvecNV<float, 8>(r_int); + coopvecNV<int, 16> v = coopvecNV<int, 16>(1); + int offset = 0; + int layout = gl_CooperativeVectorMatrixLayoutRowMajorNV; + bool transpose = false; + int matrixStride = 4; + coopVecMatMulNV( + r, + v, + gl_ComponentTypeFloat32NV, + buf, + offset, + gl_ComponentTypeFloat32NV, + 8, + 16, + layout, + transpose, + matrixStride); + outputBuffer[dispatchThreadID.x] = r[0]; +} diff --git a/tests/cooperative-vector/glsl/cast.slang.glsl b/tests/cooperative-vector/glsl/cast.slang.glsl new file mode 100644 index 000000000..7194c02fc --- /dev/null +++ b/tests/cooperative-vector/glsl/cast.slang.glsl @@ -0,0 +1,23 @@ +#version 450 +#extension GL_NV_cooperative_vector : require +layout(row_major) uniform; +layout(row_major) buffer; +layout(std430, binding = 1) readonly buffer StructuredBuffer_float_t_0 { + float _data[]; +} buf_0; +layout(std430, binding = 0) buffer StructuredBuffer_float_t_1 { + float _data[]; +} outputBuffer_0; +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; +void main() +{ + coopvecNV<int, 8 > r_int_0; + coopvecNV<float, 8 > _S1 = (coopvecNV<float, 8>((r_int_0))); + coopvecNV<float, 8 > r_0 = _S1; + coopvecNV<int, 16 > _S2 = (coopvecNV<int, 16>((1))); + coopVecMatMulNV((r_0), (_S2), (1), (buf_0)._data, (0U), (1), (8U), (16U), (0), (false), (4U)); + float _S3 = r_0[0U]; + outputBuffer_0._data[gl_GlobalInvocationID.x] = _S3; + return; +} + diff --git a/tests/cooperative-vector/glsl/groupshared-sized.slang b/tests/cooperative-vector/glsl/groupshared-sized.slang new file mode 100644 index 000000000..74ccac6a2 --- /dev/null +++ b/tests/cooperative-vector/glsl/groupshared-sized.slang @@ -0,0 +1,37 @@ +//DISABLE_TEST:CROSS_COMPILE: -profile glsl_450+spirv_1_4 -stage compute -entry computeMain -target spirv-assembly + +RWStructuredBuffer<float> outputBuffer; + +groupshared float buf[100]; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + coopvecNV<float, 8> r; + coopvecNV<int, 16> v; + if(dispatchThreadID.x == 0) + { + for(int i = 0; i < 100; ++i) + { + buf[i] = float(i); + } + } + coopVecLoadNV(v, buf, 0); + int offset = 0; + int layout = gl_CooperativeVectorMatrixLayoutRowMajorNV; + bool transpose = false; + int matrixStride = 4; + coopVecMatMulNV( + r, + v, + gl_ComponentTypeFloat32NV, + buf, + offset, + gl_ComponentTypeFloat32NV, + 8, + 16, + layout, + transpose, + matrixStride); + outputBuffer[dispatchThreadID.x] = r[0]; +} diff --git a/tests/cooperative-vector/glsl/groupshared-sized.slang.glsl b/tests/cooperative-vector/glsl/groupshared-sized.slang.glsl new file mode 100644 index 000000000..f1f4b5a27 --- /dev/null +++ b/tests/cooperative-vector/glsl/groupshared-sized.slang.glsl @@ -0,0 +1,38 @@ +#version 450 +#extension GL_NV_cooperative_vector : require +layout(row_major) uniform; +layout(row_major) buffer; +layout(std430, binding = 0) buffer StructuredBuffer_float_t_0 { + float _data[]; +} outputBuffer_0; +shared float buf_0[100]; + +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; +void main() +{ + coopvecNV<float, 8 > r_0; + coopvecNV<int, 16 > v_0; + uint _S1 = gl_GlobalInvocationID.x; + if(_S1 == 0U) + { + int i_0 = 0; + for(;;) + { + if(i_0 < 100) + { + } + else + { + break; + } + buf_0[i_0] = float(i_0); + i_0 = i_0 + 1; + } + } + coopVecLoadNV((v_0), (buf_0), (0U)); + coopvecNV<int, 16 > _S2 = v_0; + coopVecMatMulNV((r_0), (_S2), (1), (buf_0), (0U), (1), (8U), (16U), (0), (false), (4U)); + float _S3 = r_0[0U]; + outputBuffer_0._data[uint(_S1)] = _S3; + return; +} diff --git a/tests/cooperative-vector/glsl/load-store.slang b/tests/cooperative-vector/glsl/load-store.slang new file mode 100644 index 000000000..04a0cd585 --- /dev/null +++ b/tests/cooperative-vector/glsl/load-store.slang @@ -0,0 +1,13 @@ +//DISABLE_TEST:CROSS_COMPILE: -profile glsl_450+spirv_1_4 -stage compute -entry computeMain -target spirv-assembly + +RWStructuredBuffer<float> rwBuf; +StructuredBuffer<float> buf; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + coopvecNV<float, 8> r; + coopVecLoadNV(r, rwBuf, 0); + coopVecLoadNV(r, buf, 1); + coopVecStoreNV(r, rwBuf, 2); +} diff --git a/tests/cooperative-vector/glsl/load-store.slang.glsl b/tests/cooperative-vector/glsl/load-store.slang.glsl new file mode 100644 index 000000000..3844e2ff0 --- /dev/null +++ b/tests/cooperative-vector/glsl/load-store.slang.glsl @@ -0,0 +1,20 @@ +#version 450 +#extension GL_NV_cooperative_vector : require +layout(row_major) uniform; +layout(row_major) buffer; +layout(std430, binding = 0) buffer StructuredBuffer_float_t_0 { + float _data[]; +} rwBuf_0; +layout(std430, binding = 1) readonly buffer StructuredBuffer_float_t_1 { + float _data[]; +} buf_0; +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; +void main() +{ + coopvecNV<float, 8 > r_0; + coopVecLoadNV((r_0), (rwBuf_0)._data, (0U)); + coopVecLoadNV((r_0), (buf_0)._data, (1U)); + coopVecStoreNV((r_0), (rwBuf_0)._data, (2U)); + return; +} + diff --git a/tests/cooperative-vector/glsl/only-arith.slang b/tests/cooperative-vector/glsl/only-arith.slang new file mode 100644 index 000000000..8a6d3d0d9 --- /dev/null +++ b/tests/cooperative-vector/glsl/only-arith.slang @@ -0,0 +1,18 @@ +//DISABLE_TEST:CROSS_COMPILE: -profile glsl_450+spirv_1_4 -stage compute -entry computeMain -target spirv-assembly + +// Disabled because we don't output the extension because although the +// coopvecNV type is used, it isn't *declared* here (and we don't attach +// requirements to the add operations); + +RWStructuredBuffer<float> outputBuffer; + +StructuredBuffer<float> buf; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + coopvecNV<float, 8> r; + coopvecNV<float, 8> v = coopvecNV<float, 8>(1); + r = v + v; + outputBuffer[dispatchThreadID.x] = r[0]; +} diff --git a/tests/cooperative-vector/glsl/only-arith.slang.glsl b/tests/cooperative-vector/glsl/only-arith.slang.glsl new file mode 100644 index 000000000..db3372d70 --- /dev/null +++ b/tests/cooperative-vector/glsl/only-arith.slang.glsl @@ -0,0 +1,16 @@ +#version 450 +#extension GL_NV_cooperative_vector : require +layout(row_major) uniform; +layout(row_major) buffer; +layout(std430, binding = 0) buffer _S1 { + float _data[]; +} outputBuffer_0; +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; +void main() +{ + const coopvecNV<float, 8 > v_0 = coopvecNV<float, 8 >(1.0); + const coopvecNV<float, 8 > r_0 = v_0 + v_0; + float _S2 = r_0[0U]; + ((outputBuffer_0)._data[(gl_GlobalInvocationID.x)]) = _S2; + return; +} diff --git a/tests/cooperative-vector/glsl/outer-product-accumulate.slang b/tests/cooperative-vector/glsl/outer-product-accumulate.slang new file mode 100644 index 000000000..1db30cb0d --- /dev/null +++ b/tests/cooperative-vector/glsl/outer-product-accumulate.slang @@ -0,0 +1,19 @@ +//DISABLE_TEST:CROSS_COMPILE: -profile glsl_450+spirv_1_4 -stage compute -entry computeMain -target spirv-assembly -emit-spirv-via-glsl + +RWByteAddressBuffer buf; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + coopvecNV<float, 8> op0 = coopvecNV<float, 8>(1); + coopvecNV<float, 16> op1 = coopvecNV<float, 16>(2); + + coopVecOuterProductAccumulateNV( + op0, + op1, + buf, + 0, // firstElement + 4, // matrixStride + gl_CooperativeVectorMatrixLayoutRowMajorNV, + gl_ComponentTypeFloat32NV); +} diff --git a/tests/cooperative-vector/glsl/outer-product-accumulate.slang.glsl b/tests/cooperative-vector/glsl/outer-product-accumulate.slang.glsl new file mode 100644 index 000000000..09d781824 --- /dev/null +++ b/tests/cooperative-vector/glsl/outer-product-accumulate.slang.glsl @@ -0,0 +1,17 @@ +#version 450 +#extension GL_NV_cooperative_vector : require +layout(row_major) uniform; +layout(row_major) buffer; +layout(std430, binding = 0) buffer _S1 +{ + uint _data[]; +} buf_0; +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; +void main() +{ + coopvecNV<float, 8 > _S2 = (coopvecNV<float, 8>((1.0))); + coopvecNV<float, 16 > _S3 = (coopvecNV<float, 16>((2.0))); + coopVecOuterProductAccumulateNV((_S2), (_S3), (buf_0)._data, (0U), (4U), (0), (1)); + return; +} + diff --git a/tests/cooperative-vector/glsl/simple.slang b/tests/cooperative-vector/glsl/simple.slang new file mode 100644 index 000000000..4128f6827 --- /dev/null +++ b/tests/cooperative-vector/glsl/simple.slang @@ -0,0 +1,35 @@ +//DISABLE_TEST:CROSS_COMPILE(filecheck=CHECK): -profile glsl_450+spirv_1_4 -stage compute -entry computeMain -target spirv-assembly -emit-spirv-via-glsl + +RWStructuredBuffer<float> outputBuffer; + +StructuredBuffer<float> buf; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + // CHECK: %[[VAR1:[a-zA-Z0-9_]+]] = OpTypeCooperativeVectorNV %int %uint_16 + // CHECK: OpConstantCompositeReplicateEXT %9 %int_1 + coopvecNV<int, 16> v = coopvecNV<int, 16>(1); + + // CHECK: %[[VAR2:[a-zA-Z0-9_]+]] = OpTypeCooperativeVectorNV %int %uint_8 + coopvecNV<int, 8> r; + int offset = 0; + int layout = gl_CooperativeVectorMatrixLayoutRowMajorNV; + bool transpose = false; + int matrixStride = 4; + + // CHECK: OpCooperativeVectorMatrixMulNV %[[VAR2]] %{{.*}} %int_1 %{{.*}} %uint_0 %int_1 %uint_8 %uint_16 %int_0 %false %uint_4 MatrixBSignedComponentsKHR|MatrixResultSignedComponentsKHR + coopVecMatMulNV( + r, + v, + gl_ComponentTypeFloat32NV, + buf, + offset, + gl_ComponentTypeFloat32NV, + 8, + 16, + layout, + transpose, + matrixStride); + outputBuffer[dispatchThreadID.x] = r[0]; +} diff --git a/tests/cooperative-vector/glsl/simple.slang.glsl b/tests/cooperative-vector/glsl/simple.slang.glsl new file mode 100644 index 000000000..cf5f0566e --- /dev/null +++ b/tests/cooperative-vector/glsl/simple.slang.glsl @@ -0,0 +1,20 @@ +#version 450 +#extension GL_NV_cooperative_vector : require +layout(row_major) uniform; +layout(row_major) buffer; +layout(std430, binding = 1) readonly buffer StructuredBuffer_float_t_0 { + float _data[]; +} buf_0; +layout(std430, binding = 0) buffer StructuredBuffer_float_t_1 { + float _data[]; +} outputBuffer_0; +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; +void main() +{ + coopvecNV<int, 16 > _S1 = (coopvecNV<int, 16>((1))); + coopvecNV<int, 8 > r_0; + coopVecMatMulNV((r_0), (_S1), (1), (buf_0)._data, (0U), (1), (8U), (16U), (0), (false), (4U)); + float _S2 = r_0[0U]; + outputBuffer_0._data[gl_GlobalInvocationID.x] = _S2; + return; +} |
