From ba9b2785c69c1b8c6d2b4103267b5281815f9f23 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Thu, 30 Jan 2025 00:59:49 -0800 Subject: Support cooperative vector (#6223) * Support cooperative vector without Vulkan-header update Adding a Slang support for cooperative vector. But this commit doesn't have Vulkan-header update. --- tests/cooperative-vector/CoopVec/add.slang | 30 +++++++++ tests/cooperative-vector/CoopVec/array.slang | 25 ++++++++ tests/cooperative-vector/CoopVec/atan.slang | 26 ++++++++ tests/cooperative-vector/CoopVec/clamp.slang | 28 +++++++++ tests/cooperative-vector/CoopVec/comparison.slang | 32 ++++++++++ tests/cooperative-vector/CoopVec/conversion.slang | 28 +++++++++ tests/cooperative-vector/CoopVec/copyFrom.slang | 22 +++++++ tests/cooperative-vector/CoopVec/div.slang | 30 +++++++++ tests/cooperative-vector/CoopVec/exp.slang | 27 ++++++++ tests/cooperative-vector/CoopVec/fill.slang | 21 +++++++ tests/cooperative-vector/CoopVec/fma.slang | 34 ++++++++++ tests/cooperative-vector/CoopVec/inout.slang | 23 +++++++ .../CoopVec/load-store-arbitrary-array-vec.slang | 35 +++++++++++ .../CoopVec/load-store-arbitrary-array.slang | 35 +++++++++++ .../CoopVec/load-store-groupshared.slang | 27 ++++++++ .../CoopVec/load-store-rwbyteaddressbuffer.slang | 22 +++++++ .../CoopVec/load-store-rwstructuredbuffer.slang | 30 +++++++++ tests/cooperative-vector/CoopVec/log.slang | 26 ++++++++ .../CoopVec/matrix-mul-bias-mut.slang | 48 ++++++++++++++ .../CoopVec/matrix-mul-bias-packed-mut.slang | 47 ++++++++++++++ .../CoopVec/matrix-mul-bias-packed.slang | 46 ++++++++++++++ .../CoopVec/matrix-mul-bias-rw-packed.slang | 48 ++++++++++++++ .../CoopVec/matrix-mul-bias-rw.slang | 47 ++++++++++++++ .../matrix-mul-bias-rwbyteaddress-packed.slang | 49 +++++++++++++++ .../matrix-mul-bias-structuredbuffer-packed.slang | 47 ++++++++++++++ .../CoopVec/matrix-mul-bias.slang | 47 ++++++++++++++ .../CoopVec/matrix-mul-byteaddress.slang | 40 ++++++++++++ .../CoopVec/matrix-mul-mut.slang | 41 ++++++++++++ .../CoopVec/matrix-mul-packed-mut.slang | 40 ++++++++++++ .../CoopVec/matrix-mul-packed.slang | 39 ++++++++++++ .../CoopVec/matrix-mul-rw-packed.slang | 41 ++++++++++++ .../cooperative-vector/CoopVec/matrix-mul-rw.slang | 40 ++++++++++++ .../CoopVec/matrix-mul-rwbyteaddress-packed.slang | 41 ++++++++++++ .../matrix-mul-structuredbuffer-packed.slang | 42 +++++++++++++ tests/cooperative-vector/CoopVec/matrix-mul.slang | 40 ++++++++++++ tests/cooperative-vector/CoopVec/max.slang | 30 +++++++++ tests/cooperative-vector/CoopVec/min.slang | 30 +++++++++ tests/cooperative-vector/CoopVec/mod.slang | 46 ++++++++++++++ tests/cooperative-vector/CoopVec/mul.slang | 30 +++++++++ tests/cooperative-vector/CoopVec/out.slang | 24 +++++++ .../CoopVec/outer-product-structuredbuffer.slang | 69 ++++++++++++++++++++ .../cooperative-vector/CoopVec/outer-product.slang | 73 ++++++++++++++++++++++ tests/cooperative-vector/CoopVec/parameter.slang | 22 +++++++ .../reduce-sum-accumulate-structuredbuffer.slang | 41 ++++++++++++ .../CoopVec/reduce-sum-accumulate.slang | 41 ++++++++++++ tests/cooperative-vector/CoopVec/return.slang | 23 +++++++ tests/cooperative-vector/CoopVec/scalar-mul.slang | 25 ++++++++ tests/cooperative-vector/CoopVec/simple.slang | 24 +++++++ tests/cooperative-vector/CoopVec/step.slang | 30 +++++++++ tests/cooperative-vector/CoopVec/struct.slang | 31 +++++++++ tests/cooperative-vector/CoopVec/sub.slang | 30 +++++++++ .../CoopVec/subscript-in-func.slang | 26 ++++++++ tests/cooperative-vector/CoopVec/subscript.slang | 25 ++++++++ tests/cooperative-vector/CoopVec/tanh.slang | 28 +++++++++ tests/cooperative-vector/CoopVec/unary.slang | 25 ++++++++ .../CoopVec/variadic-init-bad-length.slang | 14 +++++ .../CoopVec/variadic-init-cast.slang | 20 ++++++ .../cooperative-vector/CoopVec/variadic-init.slang | 20 ++++++ tests/cooperative-vector/cast.slang | 30 +++++++++ tests/cooperative-vector/cast.slang.glsl | 23 +++++++ tests/cooperative-vector/groupshared-sized.slang | 37 +++++++++++ .../groupshared-sized.slang.glsl | 38 +++++++++++ tests/cooperative-vector/load-store.slang | 13 ++++ tests/cooperative-vector/load-store.slang.glsl | 20 ++++++ tests/cooperative-vector/only-arith.slang | 18 ++++++ tests/cooperative-vector/only-arith.slang.glsl | 16 +++++ .../outer-product-accumulate.slang | 19 ++++++ .../outer-product-accumulate.slang.glsl | 17 +++++ tests/cooperative-vector/simple.slang | 35 +++++++++++ tests/cooperative-vector/simple.slang.glsl | 20 ++++++ 70 files changed, 2257 insertions(+) create mode 100644 tests/cooperative-vector/CoopVec/add.slang create mode 100644 tests/cooperative-vector/CoopVec/array.slang create mode 100644 tests/cooperative-vector/CoopVec/atan.slang create mode 100644 tests/cooperative-vector/CoopVec/clamp.slang create mode 100644 tests/cooperative-vector/CoopVec/comparison.slang create mode 100644 tests/cooperative-vector/CoopVec/conversion.slang create mode 100644 tests/cooperative-vector/CoopVec/copyFrom.slang create mode 100644 tests/cooperative-vector/CoopVec/div.slang create mode 100644 tests/cooperative-vector/CoopVec/exp.slang create mode 100644 tests/cooperative-vector/CoopVec/fill.slang create mode 100644 tests/cooperative-vector/CoopVec/fma.slang create mode 100644 tests/cooperative-vector/CoopVec/inout.slang create mode 100644 tests/cooperative-vector/CoopVec/load-store-arbitrary-array-vec.slang create mode 100644 tests/cooperative-vector/CoopVec/load-store-arbitrary-array.slang create mode 100644 tests/cooperative-vector/CoopVec/load-store-groupshared.slang create mode 100644 tests/cooperative-vector/CoopVec/load-store-rwbyteaddressbuffer.slang create mode 100644 tests/cooperative-vector/CoopVec/load-store-rwstructuredbuffer.slang create mode 100644 tests/cooperative-vector/CoopVec/log.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-bias-mut.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-bias-packed-mut.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-bias-packed.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-bias-rw-packed.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-bias-rw.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-bias-rwbyteaddress-packed.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-bias-structuredbuffer-packed.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-bias.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-byteaddress.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-mut.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-packed-mut.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-packed.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-rw-packed.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-rw.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-rwbyteaddress-packed.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul-structuredbuffer-packed.slang create mode 100644 tests/cooperative-vector/CoopVec/matrix-mul.slang create mode 100644 tests/cooperative-vector/CoopVec/max.slang create mode 100644 tests/cooperative-vector/CoopVec/min.slang create mode 100644 tests/cooperative-vector/CoopVec/mod.slang create mode 100644 tests/cooperative-vector/CoopVec/mul.slang create mode 100644 tests/cooperative-vector/CoopVec/out.slang create mode 100644 tests/cooperative-vector/CoopVec/outer-product-structuredbuffer.slang create mode 100644 tests/cooperative-vector/CoopVec/outer-product.slang create mode 100644 tests/cooperative-vector/CoopVec/parameter.slang create mode 100644 tests/cooperative-vector/CoopVec/reduce-sum-accumulate-structuredbuffer.slang create mode 100644 tests/cooperative-vector/CoopVec/reduce-sum-accumulate.slang create mode 100644 tests/cooperative-vector/CoopVec/return.slang create mode 100644 tests/cooperative-vector/CoopVec/scalar-mul.slang create mode 100644 tests/cooperative-vector/CoopVec/simple.slang create mode 100644 tests/cooperative-vector/CoopVec/step.slang create mode 100644 tests/cooperative-vector/CoopVec/struct.slang create mode 100644 tests/cooperative-vector/CoopVec/sub.slang create mode 100644 tests/cooperative-vector/CoopVec/subscript-in-func.slang create mode 100644 tests/cooperative-vector/CoopVec/subscript.slang create mode 100644 tests/cooperative-vector/CoopVec/tanh.slang create mode 100644 tests/cooperative-vector/CoopVec/unary.slang create mode 100644 tests/cooperative-vector/CoopVec/variadic-init-bad-length.slang create mode 100644 tests/cooperative-vector/CoopVec/variadic-init-cast.slang create mode 100644 tests/cooperative-vector/CoopVec/variadic-init.slang create mode 100644 tests/cooperative-vector/cast.slang create mode 100644 tests/cooperative-vector/cast.slang.glsl create mode 100644 tests/cooperative-vector/groupshared-sized.slang create mode 100644 tests/cooperative-vector/groupshared-sized.slang.glsl create mode 100644 tests/cooperative-vector/load-store.slang create mode 100644 tests/cooperative-vector/load-store.slang.glsl create mode 100644 tests/cooperative-vector/only-arith.slang create mode 100644 tests/cooperative-vector/only-arith.slang.glsl create mode 100644 tests/cooperative-vector/outer-product-accumulate.slang create mode 100644 tests/cooperative-vector/outer-product-accumulate.slang.glsl create mode 100644 tests/cooperative-vector/simple.slang create mode 100644 tests/cooperative-vector/simple.slang.glsl (limited to 'tests') diff --git a/tests/cooperative-vector/CoopVec/add.slang b/tests/cooperative-vector/CoopVec/add.slang new file mode 100644 index 000000000..082d19468 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/add.slang @@ -0,0 +1,30 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: int32_t +// CHECK-NEXT: 1 +// CHECK-NEXT: 3 +// CHECK-NEXT: 5 +// CHECK-NEXT: 7 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4),name=input1 +ByteAddressBuffer input1; + +//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4),name=input2 +ByteAddressBuffer input2; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec1 = coopVecLoad<4, int32_t>(input1); + CoopVec vec2 = coopVecLoad<4, int32_t>(input2); + + let result = vec1 + vec2; + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i]; +} diff --git a/tests/cooperative-vector/CoopVec/array.slang b/tests/cooperative-vector/CoopVec/array.slang new file mode 100644 index 000000000..b63ff2f91 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/array.slang @@ -0,0 +1,25 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation + +// CHECK: type: float +// CHECK-NEXT: 1.000000 +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 3.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 5.000000 +// CHECK-NEXT: 6.000000 +// CHECK-NEXT: 7.000000 +// CHECK-NEXT: 8.000000 + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vecArray[2]; + vecArray[0] = CoopVec(1.0, 2.0, 3.0, 4.0); + vecArray[1] = CoopVec(5.0, 6.0, 7.0, 8.0); + + vecArray[0].store(outputBuffer, 0); + vecArray[1].store(outputBuffer, 16); +} diff --git a/tests/cooperative-vector/CoopVec/atan.slang b/tests/cooperative-vector/CoopVec/atan.slang new file mode 100644 index 000000000..1dfd62986 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/atan.slang @@ -0,0 +1,26 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: float +// CHECK-NEXT: 0.785398 +// CHECK-NEXT: 1.107149 +// CHECK-NEXT: 1.249046 +// CHECK-NEXT: 1.325818 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4),name=input +ByteAddressBuffer input; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec = coopVecLoad<4, float>(input); + + CoopVec result = atan(vec); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/clamp.slang b/tests/cooperative-vector/CoopVec/clamp.slang new file mode 100644 index 000000000..b5639eeb4 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/clamp.slang @@ -0,0 +1,28 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: float +// CHECK-NEXT: 2.0 +// CHECK-NEXT: 2.0 +// CHECK-NEXT: 3.0 +// CHECK-NEXT: 4.0 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 5.0], stride=4),name=input +ByteAddressBuffer input; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec = coopVecLoad<4, float>(input); + CoopVec minVal = CoopVec(2.0); + CoopVec maxVal = CoopVec(4.0); + + CoopVec result = clamp(vec, minVal, maxVal); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/comparison.slang b/tests/cooperative-vector/CoopVec/comparison.slang new file mode 100644 index 000000000..b410176bc --- /dev/null +++ b/tests/cooperative-vector/CoopVec/comparison.slang @@ -0,0 +1,32 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: uint32_t +// CHECK-NEXT: 0 +// CHECK-NEXT: 1 +// CHECK-NEXT: 1 + +//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4),name=input1 +ByteAddressBuffer input1; + +//TEST_INPUT:ubuffer(data=[1.0 3.0 2.0 4.0], stride=4),name=input2 +ByteAddressBuffer input2; + +//TEST_INPUT:ubuffer(data=[0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec1 = coopVecLoad<4, float>(input1); + CoopVec vec2 = coopVecLoad<4, float>(input2); + + uint32_t equals = vec1 == vec2 ? 1 : 0; + uint32_t lessThan = vec1 < vec2 ? 1 : 0; + uint32_t lessThanOrEquals = vec1 <= vec2 ? 1 : 0; + + outputBuffer[0] = equals; + outputBuffer[1] = lessThan; + outputBuffer[2] = lessThanOrEquals; +} diff --git a/tests/cooperative-vector/CoopVec/conversion.slang b/tests/cooperative-vector/CoopVec/conversion.slang new file mode 100644 index 000000000..02d125f58 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/conversion.slang @@ -0,0 +1,28 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: float +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 6.000000 +// CHECK-NEXT: 8.000000 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4),name=input +ByteAddressBuffer input; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let intVec = coopVecLoad<4, int>(input); + let floatVec = CoopVec(intVec); + let uintVec = CoopVec(intVec); + let floatVec2 = CoopVec(uintVec); + + let result = floatVec + floatVec2; + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i]; +} diff --git a/tests/cooperative-vector/CoopVec/copyFrom.slang b/tests/cooperative-vector/CoopVec/copyFrom.slang new file mode 100644 index 000000000..eb8697d33 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/copyFrom.slang @@ -0,0 +1,22 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: int32_t +// CHECK-NEXT: 1 +// CHECK-NEXT: 2 +// CHECK-NEXT: 3 +// CHECK-NEXT: 4 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let v = CoopVec(1,2,3,4); + var result : CoopVec; + result.copyFrom(v); + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/div.slang b/tests/cooperative-vector/CoopVec/div.slang new file mode 100644 index 000000000..6708a54f1 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/div.slang @@ -0,0 +1,30 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: int32_t +// CHECK-NEXT: 2 +// CHECK-NEXT: 1 +// CHECK-NEXT: 1 +// CHECK-NEXT: 0 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[4 3 5 2], stride=4),name=input1 +ByteAddressBuffer input1; + +//TEST_INPUT:ubuffer(data=[2 3 4 5], stride=4),name=input2 +ByteAddressBuffer input2; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec1 = coopVecLoad<4, int32_t>(input1); + CoopVec vec2 = coopVecLoad<4, int32_t>(input2); + + CoopVec result = vec1 / vec2; + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/exp.slang b/tests/cooperative-vector/CoopVec/exp.slang new file mode 100644 index 000000000..f2d3fe716 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/exp.slang @@ -0,0 +1,27 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: float +// CHECK-NEXT: 2.7182 +// CHECK-NEXT: 7.3890 +// CHECK-NEXT: 20.0855 +// CHECK-NEXT: 54.5981 + + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4),name=input +ByteAddressBuffer input; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec = coopVecLoad<4, float>(input); + + CoopVec result = exp(vec); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/fill.slang b/tests/cooperative-vector/CoopVec/fill.slang new file mode 100644 index 000000000..fe36b4ed6 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/fill.slang @@ -0,0 +1,21 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: int32_t +// CHECK-NEXT: 10 +// CHECK-NEXT: 10 +// CHECK-NEXT: 10 +// CHECK-NEXT: 10 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + var result : CoopVec; + result.fill(10); + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/fma.slang b/tests/cooperative-vector/CoopVec/fma.slang new file mode 100644 index 000000000..434cdef32 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/fma.slang @@ -0,0 +1,34 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: float +// CHECK-NEXT: 5.000000 +// CHECK-NEXT: 10.000000 +// CHECK-NEXT: 17.000000 +// CHECK-NEXT: 26.000000 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4),name=input1 +ByteAddressBuffer input1; + +//TEST_INPUT:ubuffer(data=[2.0 3.0 4.0 5.0], stride=4),name=input2 +ByteAddressBuffer input2; + +//TEST_INPUT:ubuffer(data=[3.0 4.0 5.0 6.0], stride=4),name=input3 +ByteAddressBuffer input3; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec1 = coopVecLoad<4, float>(input1); + CoopVec vec2 = coopVecLoad<4, float>(input2); + CoopVec vec3 = coopVecLoad<4, float>(input3); + + CoopVec result = fma(vec1, vec2, vec3); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/inout.slang b/tests/cooperative-vector/CoopVec/inout.slang new file mode 100644 index 000000000..8181a2019 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/inout.slang @@ -0,0 +1,23 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation + +// CHECK: type: float +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 6.000000 +// CHECK-NEXT: 8.000000 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +void doubleCoopVec(inout CoopVec vec) +{ + vec = vec * 2.0; +} + +[numthreads(1, 1, 1)] +void computeMain() +{ + var vec = CoopVec(1.0, 2.0, 3.0, 4.0); + doubleCoopVec(vec); + vec.store(outputBuffer, 0); +} diff --git a/tests/cooperative-vector/CoopVec/load-store-arbitrary-array-vec.slang b/tests/cooperative-vector/CoopVec/load-store-arbitrary-array-vec.slang new file mode 100644 index 000000000..f577ae5f3 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/load-store-arbitrary-array-vec.slang @@ -0,0 +1,35 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -xslang -skip-spirv-validation + +// CHECK: 1 +// CHECK-NEXT: 2 +// CHECK-NEXT: 3 +// CHECK-NEXT: 4 +// CHECK-NEXT: 5 +// CHECK-NEXT: 6 +// CHECK-NEXT: 7 +// CHECK-NEXT: 8 +// CHECK-NEXT: 9 +// CHECK-NEXT: A +// CHECK-NEXT: B +// CHECK-NEXT: C +// CHECK-NEXT: D +// CHECK-NEXT: E +// CHECK-NEXT: F + +//TEST_INPUT:ubuffer(data=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]):name=input +RWByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +groupshared float3[5] temp; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<15, uint32_t>(input); + vec.storeAny(temp); + let result = CoopVec.loadAny(temp); + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/load-store-arbitrary-array.slang b/tests/cooperative-vector/CoopVec/load-store-arbitrary-array.slang new file mode 100644 index 000000000..d8353d1c1 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/load-store-arbitrary-array.slang @@ -0,0 +1,35 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -xslang -skip-spirv-validation + +// CHECK: 1 +// CHECK-NEXT: 2 +// CHECK-NEXT: 3 +// CHECK-NEXT: 4 +// CHECK-NEXT: 5 +// CHECK-NEXT: 6 +// CHECK-NEXT: 7 +// CHECK-NEXT: 8 +// CHECK-NEXT: 9 +// CHECK-NEXT: A +// CHECK-NEXT: B +// CHECK-NEXT: C +// CHECK-NEXT: D +// CHECK-NEXT: E +// CHECK-NEXT: F + +//TEST_INPUT:ubuffer(data=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]):name=input +RWByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +groupshared float[15] temp; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<15, uint32_t>(input); + vec.storeAny(temp); + let result = CoopVec.loadAny(temp); + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i]; +} diff --git a/tests/cooperative-vector/CoopVec/load-store-groupshared.slang b/tests/cooperative-vector/CoopVec/load-store-groupshared.slang new file mode 100644 index 000000000..331c12735 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/load-store-groupshared.slang @@ -0,0 +1,27 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: 1 +// CHECK-NEXT: 2 +// CHECK-NEXT: 3 +// CHECK-NEXT: 4 +// CHECK-NEXT: 5 + +//TEST_INPUT:ubuffer(data=[1 2 3 4 5]):name=input +RWByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0]):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +groupshared uint32_t[5] temp; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<5, uint32_t>(input); + vec.store(temp); + let result = coopVecLoadGroupshared<5>(temp); + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/load-store-rwbyteaddressbuffer.slang b/tests/cooperative-vector/CoopVec/load-store-rwbyteaddressbuffer.slang new file mode 100644 index 000000000..88fed1cd6 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/load-store-rwbyteaddressbuffer.slang @@ -0,0 +1,22 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu + +// CHECK: 1 +// CHECK-NEXT: 2 +// CHECK-NEXT: 3 +// CHECK-NEXT: 4 +// CHECK-NEXT: 5 + +//TEST_INPUT:ubuffer(data=[1 2 3 4 5]):name=input +RWByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0]):out,name=outputBuffer +RWByteAddressBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let result = coopVecLoad<5, uint32_t>(input); + result.store(outputBuffer); +} diff --git a/tests/cooperative-vector/CoopVec/load-store-rwstructuredbuffer.slang b/tests/cooperative-vector/CoopVec/load-store-rwstructuredbuffer.slang new file mode 100644 index 000000000..4b143f5f8 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/load-store-rwstructuredbuffer.slang @@ -0,0 +1,30 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// HLSL doesn't support structured buffers for CoopVec +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 5 +// CHECK-NEXT: 6 +// CHECK-NEXT: 7 +// CHECK-NEXT: 8 +// CHECK-NEXT: 1 +// CHECK-NEXT: 2 +// CHECK-NEXT: 3 +// CHECK-NEXT: 4 + +//TEST_INPUT:ubuffer(data=[1 2 3 4 5 6 7 8], stride=4),name=buf +RWStructuredBuffer inputBuffer; + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let a = coopVecLoad<4>(inputBuffer, 0); + let b = coopVecLoad<4>(inputBuffer, 4*4); + b.store(outputBuffer, 0); + a.store(outputBuffer, 4*4); +} diff --git a/tests/cooperative-vector/CoopVec/log.slang b/tests/cooperative-vector/CoopVec/log.slang new file mode 100644 index 000000000..6428799d1 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/log.slang @@ -0,0 +1,26 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: float +// CHECK-NEXT: 0.000000 +// CHECK-NEXT: 0.693147 +// CHECK-NEXT: 1.098612 +// CHECK-NEXT: 1.386294 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4),name=input +ByteAddressBuffer input; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec = coopVecLoad<4, float>(input); + + CoopVec result = log(vec); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-bias-mut.slang b/tests/cooperative-vector/CoopVec/matrix-mul-bias-mut.slang new file mode 100644 index 000000000..798162c8a --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-bias-mut.slang @@ -0,0 +1,48 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// Disabled because HLSL doesn't support int8 +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 8035 +// CHECK-NEXT: 8076 +// CHECK-NEXT: 8117 +// CHECK-NEXT: 8158 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +ByteAddressBuffer matrix; + +//TEST_INPUT:ubuffer(data=[5 6 7 8], stride=4),name=bias +ByteAddressBuffer bias; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec = coopVecLoad<4, int8_t>(input); + var result = CoopVec(8000); + result.matMulAddAccum( + vec, + CoopVecComponentType::SignedInt8, + matrix, + 0, + CoopVecComponentType::SignedInt8, + bias, + 0, + CoopVecComponentType::SignedInt32, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-bias-packed-mut.slang b/tests/cooperative-vector/CoopVec/matrix-mul-bias-packed-mut.slang new file mode 100644 index 000000000..fdb10703c --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-bias-packed-mut.slang @@ -0,0 +1,47 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: int32_t +// CHECK-NEXT: 8035 +// CHECK-NEXT: 8076 +// CHECK-NEXT: 8117 +// CHECK-NEXT: 8158 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +ByteAddressBuffer matrix; + +//TEST_INPUT:ubuffer(data=[5 6 7 8], stride=4),name=bias +ByteAddressBuffer bias; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<1, int32_t>(input); + var result = CoopVec(8000); + result.matMulAddAccumPacked( + vec, + CoopVecComponentType::SignedInt8Packed, + 4, + matrix, + 0, + CoopVecComponentType::SignedInt8, + bias, + 0, + CoopVecComponentType::SignedInt32, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-bias-packed.slang b/tests/cooperative-vector/CoopVec/matrix-mul-bias-packed.slang new file mode 100644 index 000000000..325a106af --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-bias-packed.slang @@ -0,0 +1,46 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: int32_t +// CHECK-NEXT: 35 +// CHECK-NEXT: 76 +// CHECK-NEXT: 117 +// CHECK-NEXT: 158 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +ByteAddressBuffer matrix; + +//TEST_INPUT:ubuffer(data=[5 6 7 8], stride=4),name=bias +ByteAddressBuffer bias; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<1, int32_t>(input); + let result = coopVecMatMulAddPacked( + vec, + CoopVecComponentType::SignedInt8Packed, + 4, + matrix, + 0, + CoopVecComponentType::SignedInt8, + bias, + 0, + CoopVecComponentType::SignedInt32, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-bias-rw-packed.slang b/tests/cooperative-vector/CoopVec/matrix-mul-bias-rw-packed.slang new file mode 100644 index 000000000..0cd3fa216 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-bias-rw-packed.slang @@ -0,0 +1,48 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// Disabled because HLSL can't multiply from *RW*ByteAddressBuffers +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 35 +// CHECK-NEXT: 76 +// CHECK-NEXT: 117 +// CHECK-NEXT: 158 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +RWByteAddressBuffer matrix; + +//TEST_INPUT:ubuffer(data=[5 6 7 8], stride=4),name=bias +RWByteAddressBuffer bias; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<1, int32_t>(input); + CoopVec result = coopVecMatMulAddPacked( + vec, + CoopVecComponentType::SignedInt8Packed, + 4, + matrix, + 0, + CoopVecComponentType::SignedInt8, + bias, + 0, + CoopVecComponentType::SignedInt32, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-bias-rw.slang b/tests/cooperative-vector/CoopVec/matrix-mul-bias-rw.slang new file mode 100644 index 000000000..e0b743259 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-bias-rw.slang @@ -0,0 +1,47 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// Disabled because HLSL doesn't support int8 +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 35 +// CHECK-NEXT: 76 +// CHECK-NEXT: 117 +// CHECK-NEXT: 158 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +RWByteAddressBuffer matrix; + +//TEST_INPUT:ubuffer(data=[5 6 7 8], stride=4),name=bias +RWByteAddressBuffer bias; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec = coopVecLoad<4, int8_t>(input); + CoopVec result = coopVecMatMulAdd( + vec, + CoopVecComponentType::SignedInt8, + matrix, + 0, + CoopVecComponentType::SignedInt8, + bias, + 0, + CoopVecComponentType::SignedInt32, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-bias-rwbyteaddress-packed.slang b/tests/cooperative-vector/CoopVec/matrix-mul-bias-rwbyteaddress-packed.slang new file mode 100644 index 000000000..d365734c2 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-bias-rwbyteaddress-packed.slang @@ -0,0 +1,49 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// Disabled because HLSL can't multiply from *RW*ByteAddressBuffers +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 35 +// CHECK-NEXT: 76 +// CHECK-NEXT: 117 +// CHECK-NEXT: 158 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +RWByteAddressBuffer matrix; + +//TEST_INPUT:ubuffer(data=[5 6 7 8], stride=4),name=bias +RWByteAddressBuffer bias; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<1, int32_t>(input); + CoopVec result = coopVecMatMulAddPacked( + vec, + CoopVecComponentType::SignedInt8Packed, + 4, + matrix, + 0, + CoopVecComponentType::SignedInt8, + bias, + 0, + CoopVecComponentType::SignedInt32, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} + diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-bias-structuredbuffer-packed.slang b/tests/cooperative-vector/CoopVec/matrix-mul-bias-structuredbuffer-packed.slang new file mode 100644 index 000000000..7b2cf6ee2 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-bias-structuredbuffer-packed.slang @@ -0,0 +1,47 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation + +// These platforms don't support these operations from structured buffers +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 35 +// CHECK-NEXT: 76 +// CHECK-NEXT: 117 +// CHECK-NEXT: 158 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +StructuredBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +StructuredBuffer matrix; + +//TEST_INPUT:ubuffer(data=[5 6 7 8], stride=4),name=bias +StructuredBuffer bias; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<1>(input); + let result = coopVecMatMulAddPacked( + vec, + CoopVecComponentType::SignedInt8Packed, + 4, + matrix, + 0, + CoopVecComponentType::SignedInt8, + bias, + 0, + CoopVecComponentType::SignedInt32, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + result.store(outputBuffer); +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-bias.slang b/tests/cooperative-vector/CoopVec/matrix-mul-bias.slang new file mode 100644 index 000000000..c560af3c0 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-bias.slang @@ -0,0 +1,47 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// Disabled because HLSL doesn't support int8 +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 35 +// CHECK-NEXT: 76 +// CHECK-NEXT: 117 +// CHECK-NEXT: 158 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +ByteAddressBuffer matrix; + +//TEST_INPUT:ubuffer(data=[5 6 7 8], stride=4),name=bias +ByteAddressBuffer bias; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec = coopVecLoad<4, int8_t>(input); + let result = coopVecMatMulAdd( + vec, + CoopVecComponentType::SignedInt8, + matrix, + 0, + CoopVecComponentType::SignedInt8, + bias, + 0, + CoopVecComponentType::SignedInt32, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-byteaddress.slang b/tests/cooperative-vector/CoopVec/matrix-mul-byteaddress.slang new file mode 100644 index 000000000..4059f458c --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-byteaddress.slang @@ -0,0 +1,40 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// Disabled because HLSL doesn't support int8 +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 30 +// CHECK-NEXT: 70 +// CHECK-NEXT: 110 +// CHECK-NEXT: 150 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +ByteAddressBuffer matrix; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec = coopVecLoad<4, int8_t>(input); + let result = coopVecMatMul( + vec, + CoopVecComponentType::SignedInt8, + matrix, + 0, + CoopVecComponentType::SignedInt8, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-mut.slang b/tests/cooperative-vector/CoopVec/matrix-mul-mut.slang new file mode 100644 index 000000000..5f7d63b95 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-mut.slang @@ -0,0 +1,41 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// Disabled because HLSL doesn't support int8 +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 31 +// CHECK-NEXT: 71 +// CHECK-NEXT: 111 +// CHECK-NEXT: 151 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +ByteAddressBuffer matrix; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<4, int8_t>(input); + var result = CoopVec(1); + result.matMulAccum( + vec, + CoopVecComponentType::SignedInt8, + matrix, + 0, + CoopVecComponentType::SignedInt8, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-packed-mut.slang b/tests/cooperative-vector/CoopVec/matrix-mul-packed-mut.slang new file mode 100644 index 000000000..c71854467 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-packed-mut.slang @@ -0,0 +1,40 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type +//Test(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 31 +// CHECK-NEXT: 71 +// CHECK-NEXT: 111 +// CHECK-NEXT: 151 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +ByteAddressBuffer matrix; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<1, int32_t>(input); + var result = CoopVec(1); + result.matMulAccumPacked( + vec, + CoopVecComponentType::SignedInt8Packed, + 4, + matrix, + 0, + CoopVecComponentType::SignedInt8, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-packed.slang b/tests/cooperative-vector/CoopVec/matrix-mul-packed.slang new file mode 100644 index 000000000..e56660561 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-packed.slang @@ -0,0 +1,39 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type +//Test(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 30 +// CHECK-NEXT: 70 +// CHECK-NEXT: 110 +// CHECK-NEXT: 150 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +ByteAddressBuffer matrix; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<1, int32_t>(input); + let result = coopVecMatMulPacked( + vec, + CoopVecComponentType::SignedInt8Packed, + 4, + matrix, + 0, + CoopVecComponentType::SignedInt8, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-rw-packed.slang b/tests/cooperative-vector/CoopVec/matrix-mul-rw-packed.slang new file mode 100644 index 000000000..7ff925427 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-rw-packed.slang @@ -0,0 +1,41 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// Disabled because HLSL can't multiply from *RW*ByteAddressBuffers +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 30 +// CHECK-NEXT: 70 +// CHECK-NEXT: 110 +// CHECK-NEXT: 150 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +RWByteAddressBuffer matrix; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<1, int32_t>(input); + CoopVec result = coopVecMatMulPacked( + vec, + CoopVecComponentType::SignedInt8Packed, + 4, + matrix, + 0, + CoopVecComponentType::SignedInt8, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-rw.slang b/tests/cooperative-vector/CoopVec/matrix-mul-rw.slang new file mode 100644 index 000000000..ddc328580 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-rw.slang @@ -0,0 +1,40 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// Disabled because HLSL doesn't support int8 +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 30 +// CHECK-NEXT: 70 +// CHECK-NEXT: 110 +// CHECK-NEXT: 150 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +RWByteAddressBuffer matrix; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec = coopVecLoad<4, int8_t>(input); + CoopVec result = coopVecMatMul( + vec, + CoopVecComponentType::SignedInt8, + matrix, + 0, + CoopVecComponentType::SignedInt8, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-rwbyteaddress-packed.slang b/tests/cooperative-vector/CoopVec/matrix-mul-rwbyteaddress-packed.slang new file mode 100644 index 000000000..7ff925427 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-rwbyteaddress-packed.slang @@ -0,0 +1,41 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// Disabled because HLSL can't multiply from *RW*ByteAddressBuffers +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 30 +// CHECK-NEXT: 70 +// CHECK-NEXT: 110 +// CHECK-NEXT: 150 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +RWByteAddressBuffer matrix; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<1, int32_t>(input); + CoopVec result = coopVecMatMulPacked( + vec, + CoopVecComponentType::SignedInt8Packed, + 4, + matrix, + 0, + CoopVecComponentType::SignedInt8, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul-structuredbuffer-packed.slang b/tests/cooperative-vector/CoopVec/matrix-mul-structuredbuffer-packed.slang new file mode 100644 index 000000000..756f4366a --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul-structuredbuffer-packed.slang @@ -0,0 +1,42 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation + +// These platforms don't support these operations from structured buffers +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 30 +// CHECK-NEXT: 70 +// CHECK-NEXT: 110 +// CHECK-NEXT: 150 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +StructuredBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +StructuredBuffer matrix; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<1, int32_t>(input); + let result = coopVecMatMulPacked( + vec, + CoopVecComponentType::SignedInt8Packed, + 4, + matrix, + 0, + CoopVecComponentType::SignedInt8, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/matrix-mul.slang b/tests/cooperative-vector/CoopVec/matrix-mul.slang new file mode 100644 index 000000000..0d6f3f6a9 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/matrix-mul.slang @@ -0,0 +1,40 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// Disabled because HLSL doesn't support int8 +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: int32_t +// CHECK-NEXT: 30 +// CHECK-NEXT: 70 +// CHECK-NEXT: 110 +// CHECK-NEXT: 150 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; +//TEST_INPUT:ubuffer(data=[67305985], stride=4),name=input +//[1 2 3 4] +ByteAddressBuffer input; + +//TEST_INPUT:ubuffer(data=[67305985 134678021 202050057 269422093], stride=4),name=matrix +//[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16] +ByteAddressBuffer matrix; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = coopVecLoad<4, int8_t>(input); + let result = coopVecMatMul( + vec, + CoopVecComponentType::SignedInt8, + matrix, + 0, + CoopVecComponentType::SignedInt8, + CoopVecMatrixLayout::RowMajor, + false, + 4 + ); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/max.slang b/tests/cooperative-vector/CoopVec/max.slang new file mode 100644 index 000000000..3b18f7782 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/max.slang @@ -0,0 +1,30 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: float +// CHECK-NEXT: 5.0 +// CHECK-NEXT: 4.0 +// CHECK-NEXT: 3.0 +// CHECK-NEXT: 4.0 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4),name=input1 +ByteAddressBuffer input1; + +//TEST_INPUT:ubuffer(data=[5.0 4.0 2.0 1.0], stride=4),name=input2 +ByteAddressBuffer input2; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec1 = coopVecLoad<4, float>(input1); + CoopVec vec2 = coopVecLoad<4, float>(input2); + + CoopVec result = max(vec1, vec2); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/min.slang b/tests/cooperative-vector/CoopVec/min.slang new file mode 100644 index 000000000..ed4e5e7aa --- /dev/null +++ b/tests/cooperative-vector/CoopVec/min.slang @@ -0,0 +1,30 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: float +// CHECK-NEXT: 1.000000 +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 3.000000 +// CHECK-NEXT: 2.000000 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4),name=input1 +ByteAddressBuffer input1; + +//TEST_INPUT:ubuffer(data=[5.0 4.0 3.0 2.0], stride=4),name=input2 +ByteAddressBuffer input2; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec1 = coopVecLoad<4, float>(input1); + CoopVec vec2 = coopVecLoad<4, float>(input2); + + CoopVec result = min(vec1, vec2); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/mod.slang b/tests/cooperative-vector/CoopVec/mod.slang new file mode 100644 index 000000000..a25516d1a --- /dev/null +++ b/tests/cooperative-vector/CoopVec/mod.slang @@ -0,0 +1,46 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu + +// CHECK: 0 +// CHECK-NEXT: 0 +// CHECK-NEXT: 1 +// CHECK-NEXT: 2 +// CHECK-NEXT: 0 +// CHECK-NEXT: 0 +// CHECK-NEXT: 1 +// CHECK-NEXT: 2 +// CHECK-NEXT: 0 +// CHECK-NEXT: 0 +// CHECK-NEXT: 1 +// CHECK-NEXT: 2 + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer +RWByteAddressBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[4 3 5 7], stride=4),name=input1 +ByteAddressBuffer input1; + +//TEST_INPUT:ubuffer(data=[2 3 4 5], stride=4),name=input2 +ByteAddressBuffer input2; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec1 = coopVecLoad<4, int32_t>(input1); + let vec2 = coopVecLoad<4, int32_t>(input2); + + let vec3 = CoopVec(vec1); + let vec4 = CoopVec(vec2); + + let vec5 = CoopVec(vec1); + let vec6 = CoopVec(vec2); + + let result = vec1 % vec2; + let result2 = CoopVec(vec3 % vec4); + let result3 = CoopVec(vec5 % vec6); + + result.store(outputBuffer); + result2.store(outputBuffer, 16); + result3.store(outputBuffer, 32); +} diff --git a/tests/cooperative-vector/CoopVec/mul.slang b/tests/cooperative-vector/CoopVec/mul.slang new file mode 100644 index 000000000..232421c0d --- /dev/null +++ b/tests/cooperative-vector/CoopVec/mul.slang @@ -0,0 +1,30 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: int32_t +// CHECK-NEXT: 2 +// CHECK-NEXT: 6 +// CHECK-NEXT: 12 +// CHECK-NEXT: 20 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4),name=input1 +ByteAddressBuffer input1; + +//TEST_INPUT:ubuffer(data=[2 3 4 5], stride=4),name=input2 +ByteAddressBuffer input2; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec1 = coopVecLoad<4, int32_t>(input1); + CoopVec vec2 = coopVecLoad<4, int32_t>(input2); + + CoopVec result = vec1 * vec2; + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/out.slang b/tests/cooperative-vector/CoopVec/out.slang new file mode 100644 index 000000000..ec1bd44ac --- /dev/null +++ b/tests/cooperative-vector/CoopVec/out.slang @@ -0,0 +1,24 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation + +// CHECK: type: float +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 6.000000 +// CHECK-NEXT: 8.000000 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +void doubleCoopVec(CoopVec vec, out CoopVec result) +{ + result = vec * 2.0; +} + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = CoopVec(1.0, 2.0, 3.0, 4.0); + CoopVec result; + doubleCoopVec(vec, result); + result.store(outputBuffer, 0); +} diff --git a/tests/cooperative-vector/CoopVec/outer-product-structuredbuffer.slang b/tests/cooperative-vector/CoopVec/outer-product-structuredbuffer.slang new file mode 100644 index 000000000..f050c80b9 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/outer-product-structuredbuffer.slang @@ -0,0 +1,69 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type + +// These platforms don't support these operations into structured buffers +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: half +// CHECK-NEXT: 112.000000 +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 3.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 5.000000 +// CHECK-NEXT: 6.000000 +// CHECK-NEXT: 7.000000 +// CHECK-NEXT: 8.000000 +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 6.000000 +// CHECK-NEXT: 8.000000 +// CHECK-NEXT: 10.000000 +// CHECK-NEXT: 12.000000 +// CHECK-NEXT: 14.000000 +// CHECK-NEXT: 16.000000 +// CHECK-NEXT: 3.000000 +// CHECK-NEXT: 6.000000 +// CHECK-NEXT: 9.000000 +// CHECK-NEXT: 12.000000 +// CHECK-NEXT: 15.000000 +// CHECK-NEXT: 18.000000 +// CHECK-NEXT: 21.000000 +// CHECK-NEXT: 24.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 8.000000 +// CHECK-NEXT: 12.000000 +// CHECK-NEXT: 16.000000 +// CHECK-NEXT: 20.000000 +// CHECK-NEXT: 24.000000 +// CHECK-NEXT: 28.000000 +// CHECK-NEXT: 32.000000 + +//TEST_INPUT:ubuffer(data=[ 0x40003C00 0x44004200 ], stride=4),name=inputA +// [1,2,3,4] +StructuredBuffer inputA; + +//TEST_INPUT:ubuffer(data=[ 0x40003C00 0x44004200 0x46004500 0x48004700 ], stride=4),name=inputB +// [1,2,3,4,5,6,7,8] +StructuredBuffer inputB; + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name=output +RWStructuredBuffer output; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vecA = coopVecLoad<4>(inputA); + let vecB = coopVecLoad<8>(inputB); + + output[0] = half(111); + + coopVecOuterProductAccumulate( + vecA, + vecB, + output, + 0, + 32, + CoopVecMatrixLayout::RowMajor, + CoopVecComponentType::Float16, + ); +} diff --git a/tests/cooperative-vector/CoopVec/outer-product.slang b/tests/cooperative-vector/CoopVec/outer-product.slang new file mode 100644 index 000000000..e59b10e4b --- /dev/null +++ b/tests/cooperative-vector/CoopVec/outer-product.slang @@ -0,0 +1,73 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type + +// HLSL doesn't support the training operations +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// Disabled because of some pecularities stemming from our lowering of half to float +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: half +// CHECK-NEXT: 112.000000 +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 3.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 5.000000 +// CHECK-NEXT: 6.000000 +// CHECK-NEXT: 7.000000 +// CHECK-NEXT: 8.000000 +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 6.000000 +// CHECK-NEXT: 8.000000 +// CHECK-NEXT: 10.000000 +// CHECK-NEXT: 12.000000 +// CHECK-NEXT: 14.000000 +// CHECK-NEXT: 16.000000 +// CHECK-NEXT: 3.000000 +// CHECK-NEXT: 6.000000 +// CHECK-NEXT: 9.000000 +// CHECK-NEXT: 12.000000 +// CHECK-NEXT: 15.000000 +// CHECK-NEXT: 18.000000 +// CHECK-NEXT: 21.000000 +// CHECK-NEXT: 24.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 8.000000 +// CHECK-NEXT: 12.000000 +// CHECK-NEXT: 16.000000 +// CHECK-NEXT: 20.000000 +// CHECK-NEXT: 24.000000 +// CHECK-NEXT: 28.000000 +// CHECK-NEXT: 32.000000 + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=2):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4),name=output +RWByteAddressBuffer output; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vecA; + CoopVec vecB; + for(int i = 0; i < vecA.getCount(); ++i) + vecA[i] = half(i+1); + for(int i = 0; i < vecB.getCount(); ++i) + vecB[i] = half(i+1); + + output.Store(0, half(111)); + + coopVecOuterProductAccumulate( + vecA, + vecB, + output, + 0, + 32, + CoopVecMatrixLayout::RowMajor, + CoopVecComponentType::Float16, + ); + + for(int i = 0; i < vecA.getCount() * vecB.getCount(); ++i) + outputBuffer[i] = output.Load(i * 2); +} diff --git a/tests/cooperative-vector/CoopVec/parameter.slang b/tests/cooperative-vector/CoopVec/parameter.slang new file mode 100644 index 000000000..91e405c45 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/parameter.slang @@ -0,0 +1,22 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation + +// CHECK: type: float +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 6.000000 +// CHECK-NEXT: 8.000000 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +void processCoopVec(CoopVec vec) +{ + (vec * 2.0).store(outputBuffer, 0); +} + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = CoopVec(1.0, 2.0, 3.0, 4.0); + processCoopVec(vec); +} diff --git a/tests/cooperative-vector/CoopVec/reduce-sum-accumulate-structuredbuffer.slang b/tests/cooperative-vector/CoopVec/reduce-sum-accumulate-structuredbuffer.slang new file mode 100644 index 000000000..17c45734e --- /dev/null +++ b/tests/cooperative-vector/CoopVec/reduce-sum-accumulate-structuredbuffer.slang @@ -0,0 +1,41 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +///TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// HLSL doesn't support the training operations +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: half +// CHECK-NEXT: 112.000000 +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 3.000000 +// CHECK-NEXT: 4.000000 + + +//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=2):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4),name=inputA +ByteAddressBuffer inputA; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4),name=output +RWByteAddressBuffer output; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vecA; + for(int i = 0; i < vecA.getCount(); ++i) + vecA[i] = half(i+1); + + output.Store(0, half(111)); + + coopVecReduceSumAccumulate( + vecA, + output, + 0, + ); + + for(int i = 0; i < vecA.getCount(); ++i) + outputBuffer[i] = output.Load(i * 2); +} + diff --git a/tests/cooperative-vector/CoopVec/reduce-sum-accumulate.slang b/tests/cooperative-vector/CoopVec/reduce-sum-accumulate.slang new file mode 100644 index 000000000..17c45734e --- /dev/null +++ b/tests/cooperative-vector/CoopVec/reduce-sum-accumulate.slang @@ -0,0 +1,41 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +///TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// HLSL doesn't support the training operations +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. + +// CHECK: type: half +// CHECK-NEXT: 112.000000 +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 3.000000 +// CHECK-NEXT: 4.000000 + + +//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=2):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4),name=inputA +ByteAddressBuffer inputA; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4),name=output +RWByteAddressBuffer output; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vecA; + for(int i = 0; i < vecA.getCount(); ++i) + vecA[i] = half(i+1); + + output.Store(0, half(111)); + + coopVecReduceSumAccumulate( + vecA, + output, + 0, + ); + + for(int i = 0; i < vecA.getCount(); ++i) + outputBuffer[i] = output.Load(i * 2); +} + diff --git a/tests/cooperative-vector/CoopVec/return.slang b/tests/cooperative-vector/CoopVec/return.slang new file mode 100644 index 000000000..b5c7b52a7 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/return.slang @@ -0,0 +1,23 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation + +// CHECK: type: float +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 6.000000 +// CHECK-NEXT: 8.000000 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +CoopVec doubleCoopVec(CoopVec vec) +{ + return vec * 2.0; +} + +[numthreads(1, 1, 1)] +void computeMain() +{ + let vec = CoopVec(1.0, 2.0, 3.0, 4.0); + let result = doubleCoopVec(vec); + result.store(outputBuffer, 0); +} diff --git a/tests/cooperative-vector/CoopVec/scalar-mul.slang b/tests/cooperative-vector/CoopVec/scalar-mul.slang new file mode 100644 index 000000000..b15654be2 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/scalar-mul.slang @@ -0,0 +1,25 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: float +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 6.000000 +// CHECK-NEXT: 8.000000 + +//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4),name=input1 +ByteAddressBuffer input1; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec = coopVecLoad<4, float>(input1); + CoopVec result = vec * 2.0; + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/simple.slang b/tests/cooperative-vector/CoopVec/simple.slang new file mode 100644 index 000000000..3b65b7c8c --- /dev/null +++ b/tests/cooperative-vector/CoopVec/simple.slang @@ -0,0 +1,24 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: int32_t +// CHECK-NEXT: 1 +// CHECK-NEXT: 2 +// CHECK-NEXT: 3 +// CHECK-NEXT: 4 + +//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4),name=buf +ByteAddressBuffer inputBuffer; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + var result = coopVecLoad<4, int32_t>(inputBuffer); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/step.slang b/tests/cooperative-vector/CoopVec/step.slang new file mode 100644 index 000000000..cfa86df28 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/step.slang @@ -0,0 +1,30 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: float +// CHECK-NEXT: 0.000000 +// CHECK-NEXT: 0.000000 +// CHECK-NEXT: 1.000000 +// CHECK-NEXT: 1.000000 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[2.0 3.0 4.0 5.0], stride=4),name=input1 +ByteAddressBuffer input1; + +//TEST_INPUT:ubuffer(data=[1.0 2.0 5.0 6.0], stride=4),name=input2 +ByteAddressBuffer input2; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec edge = coopVecLoad<4, float>(input1); + CoopVec x = coopVecLoad<4, float>(input2); + + CoopVec result = step(edge, x); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/struct.slang b/tests/cooperative-vector/CoopVec/struct.slang new file mode 100644 index 000000000..6f6b8a4f9 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/struct.slang @@ -0,0 +1,31 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation + +// CHECK: type: float +// CHECK-NEXT: 1.000000 +// CHECK-NEXT: 2.000000 +// CHECK-NEXT: 3.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 5.000000 +// CHECK-NEXT: 6.000000 +// CHECK-NEXT: 7.000000 +// CHECK-NEXT: 8.000000 + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +struct MyStruct +{ + CoopVec vec1; + CoopVec vec2; +}; + +[numthreads(1, 1, 1)] +void computeMain() +{ + MyStruct s; + s.vec1 = CoopVec(1.0, 2.0, 3.0, 4.0); + s.vec2 = CoopVec(5.0, 6.0, 7.0, 8.0); + + s.vec1.store(outputBuffer, 0); + s.vec2.store(outputBuffer, 16); +} diff --git a/tests/cooperative-vector/CoopVec/sub.slang b/tests/cooperative-vector/CoopVec/sub.slang new file mode 100644 index 000000000..ffb4944ed --- /dev/null +++ b/tests/cooperative-vector/CoopVec/sub.slang @@ -0,0 +1,30 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: int32_t +// CHECK-NEXT: 1 +// CHECK-NEXT: 1 +// CHECK-NEXT: 1 +// CHECK-NEXT: 1 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[2 3 4 5], stride=4),name=input1 +ByteAddressBuffer input1; + +//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4),name=input2 +ByteAddressBuffer input2; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec1 = coopVecLoad<4, int32_t>(input1); + CoopVec vec2 = coopVecLoad<4, int32_t>(input2); + + CoopVec result = vec1 - vec2; + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/subscript-in-func.slang b/tests/cooperative-vector/CoopVec/subscript-in-func.slang new file mode 100644 index 000000000..74c7f86c3 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/subscript-in-func.slang @@ -0,0 +1,26 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation + +// CHECK: type: float +// CHECK-NEXT: 1.000000 +// CHECK-NEXT: 4.000000 +// CHECK-NEXT: 9.000000 +// CHECK-NEXT: 16.000000 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +void squareCoopVecElements(CoopVec vec) +{ + for (int i = 0; i < 4; ++i) + { + vec[i] = vec[i] * vec[i]; + } + vec.store(outputBuffer, 0); +} + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec = CoopVec(1.0, 2.0, 3.0, 4.0); + squareCoopVecElements(vec); +} diff --git a/tests/cooperative-vector/CoopVec/subscript.slang b/tests/cooperative-vector/CoopVec/subscript.slang new file mode 100644 index 000000000..c4df93e72 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/subscript.slang @@ -0,0 +1,25 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: int32_t +// CHECK-NEXT: 2 +// CHECK-NEXT: 4 +// CHECK-NEXT: 6 +// CHECK-NEXT: 8 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec; + vec[0] = 2; + vec[1] = vec[0]+2; + vec[2] = vec[1]+2; + vec[3] = vec[2]+2; + + for(int i = 0; i < vec.getCount(); ++i) + outputBuffer[i] = vec[i];; +} diff --git a/tests/cooperative-vector/CoopVec/tanh.slang b/tests/cooperative-vector/CoopVec/tanh.slang new file mode 100644 index 000000000..ed698df6b --- /dev/null +++ b/tests/cooperative-vector/CoopVec/tanh.slang @@ -0,0 +1,28 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// Hilariously low precision because the different APIs don't agree (they're +// not specced to of course, so it's ok) +// CHECK: type: float +// CHECK-NEXT: 0.761 +// CHECK-NEXT: 0.964 +// CHECK-NEXT: 0.995 +// CHECK-NEXT: 0.999 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4),name=input +ByteAddressBuffer input; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec = coopVecLoad<4, float>(input); + + CoopVec result = tanh(vec); + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/unary.slang b/tests/cooperative-vector/CoopVec/unary.slang new file mode 100644 index 000000000..1f577afff --- /dev/null +++ b/tests/cooperative-vector/CoopVec/unary.slang @@ -0,0 +1,25 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -xslang -skip-spirv-validation -xslang -skip-spirv-validation +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: int32_t +// CHECK-NEXT: -1 +// CHECK-NEXT: -2 +// CHECK-NEXT: -3 +// CHECK-NEXT: -4 + +//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4),name=input1 +ByteAddressBuffer input1; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + CoopVec vec1 = coopVecLoad<4, int32_t>(input1); + CoopVec negVec = -vec1; + + for(int i = 0; i < negVec.getCount(); ++i) + outputBuffer[i] = negVec[i];; +} diff --git a/tests/cooperative-vector/CoopVec/variadic-init-bad-length.slang b/tests/cooperative-vector/CoopVec/variadic-init-bad-length.slang new file mode 100644 index 000000000..1f4c92d29 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/variadic-init-bad-length.slang @@ -0,0 +1,14 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -target spirv + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let result = CoopVec(1,2,3,4,5); + // CHECK: error 41400: static assertion failed, number of arguments to CoopVec constructor must match number of elements + + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/variadic-init-cast.slang b/tests/cooperative-vector/CoopVec/variadic-init-cast.slang new file mode 100644 index 000000000..36af7bcd7 --- /dev/null +++ b/tests/cooperative-vector/CoopVec/variadic-init-cast.slang @@ -0,0 +1,20 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: float +// CHECK-NEXT: 1.0 +// CHECK-NEXT: 2.0 +// CHECK-NEXT: 3.0 +// CHECK-NEXT: 4.0 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let result = CoopVec(int(1),half(2),uint(3),double(4)); + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/CoopVec/variadic-init.slang b/tests/cooperative-vector/CoopVec/variadic-init.slang new file mode 100644 index 000000000..6a1f30efc --- /dev/null +++ b/tests/cooperative-vector/CoopVec/variadic-init.slang @@ -0,0 +1,20 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -output-using-type -profile cs_6_8 -Xslang... -Xdxc -Vd -X. +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type + +// CHECK: type: int32_t +// CHECK-NEXT: 1 +// CHECK-NEXT: 2 +// CHECK-NEXT: 3 +// CHECK-NEXT: 4 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain() +{ + let result = CoopVec(1,2,3,4); + for(int i = 0; i < result.getCount(); ++i) + outputBuffer[i] = result[i];; +} diff --git a/tests/cooperative-vector/cast.slang b/tests/cooperative-vector/cast.slang new file mode 100644 index 000000000..263ad5026 --- /dev/null +++ b/tests/cooperative-vector/cast.slang @@ -0,0 +1,30 @@ +//DISABLE_TEST:CROSS_COMPILE: -profile glsl_450+spirv_1_4 -stage compute -entry computeMain -target spirv-assembly + +RWStructuredBuffer outputBuffer; + +StructuredBuffer buf; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + coopvecNV r_int; + coopvecNV r = coopvecNV(r_int); + coopvecNV v = coopvecNV(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/cast.slang.glsl b/tests/cooperative-vector/cast.slang.glsl new file mode 100644 index 000000000..7194c02fc --- /dev/null +++ b/tests/cooperative-vector/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 r_int_0; + coopvecNV _S1 = (coopvecNV((r_int_0))); + coopvecNV r_0 = _S1; + coopvecNV _S2 = (coopvecNV((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/groupshared-sized.slang b/tests/cooperative-vector/groupshared-sized.slang new file mode 100644 index 000000000..74ccac6a2 --- /dev/null +++ b/tests/cooperative-vector/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 outputBuffer; + +groupshared float buf[100]; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + coopvecNV r; + coopvecNV 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/groupshared-sized.slang.glsl b/tests/cooperative-vector/groupshared-sized.slang.glsl new file mode 100644 index 000000000..f1f4b5a27 --- /dev/null +++ b/tests/cooperative-vector/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 r_0; + coopvecNV 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 _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/load-store.slang b/tests/cooperative-vector/load-store.slang new file mode 100644 index 000000000..04a0cd585 --- /dev/null +++ b/tests/cooperative-vector/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 rwBuf; +StructuredBuffer buf; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + coopvecNV r; + coopVecLoadNV(r, rwBuf, 0); + coopVecLoadNV(r, buf, 1); + coopVecStoreNV(r, rwBuf, 2); +} diff --git a/tests/cooperative-vector/load-store.slang.glsl b/tests/cooperative-vector/load-store.slang.glsl new file mode 100644 index 000000000..3844e2ff0 --- /dev/null +++ b/tests/cooperative-vector/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 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/only-arith.slang b/tests/cooperative-vector/only-arith.slang new file mode 100644 index 000000000..8a6d3d0d9 --- /dev/null +++ b/tests/cooperative-vector/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 outputBuffer; + +StructuredBuffer buf; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + coopvecNV r; + coopvecNV v = coopvecNV(1); + r = v + v; + outputBuffer[dispatchThreadID.x] = r[0]; +} diff --git a/tests/cooperative-vector/only-arith.slang.glsl b/tests/cooperative-vector/only-arith.slang.glsl new file mode 100644 index 000000000..db3372d70 --- /dev/null +++ b/tests/cooperative-vector/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 v_0 = coopvecNV(1.0); + const coopvecNV 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/outer-product-accumulate.slang b/tests/cooperative-vector/outer-product-accumulate.slang new file mode 100644 index 000000000..1db30cb0d --- /dev/null +++ b/tests/cooperative-vector/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 op0 = coopvecNV(1); + coopvecNV op1 = coopvecNV(2); + + coopVecOuterProductAccumulateNV( + op0, + op1, + buf, + 0, // firstElement + 4, // matrixStride + gl_CooperativeVectorMatrixLayoutRowMajorNV, + gl_ComponentTypeFloat32NV); +} diff --git a/tests/cooperative-vector/outer-product-accumulate.slang.glsl b/tests/cooperative-vector/outer-product-accumulate.slang.glsl new file mode 100644 index 000000000..09d781824 --- /dev/null +++ b/tests/cooperative-vector/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 _S2 = (coopvecNV((1.0))); + coopvecNV _S3 = (coopvecNV((2.0))); + coopVecOuterProductAccumulateNV((_S2), (_S3), (buf_0)._data, (0U), (4U), (0), (1)); + return; +} + diff --git a/tests/cooperative-vector/simple.slang b/tests/cooperative-vector/simple.slang new file mode 100644 index 000000000..4128f6827 --- /dev/null +++ b/tests/cooperative-vector/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 outputBuffer; + +StructuredBuffer 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 v = coopvecNV(1); + + // CHECK: %[[VAR2:[a-zA-Z0-9_]+]] = OpTypeCooperativeVectorNV %int %uint_8 + coopvecNV 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/simple.slang.glsl b/tests/cooperative-vector/simple.slang.glsl new file mode 100644 index 000000000..cf5f0566e --- /dev/null +++ b/tests/cooperative-vector/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 _S1 = (coopvecNV((1))); + coopvecNV 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; +} -- cgit v1.2.3