diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-03-09 20:03:42 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-10 00:03:42 +0000 |
| commit | 721d2e8a2d457081cd3d9b081979d436b7002c2c (patch) | |
| tree | 57a1872eb9751c5f14a18c810ec219713351bdf6 /tests | |
| parent | 7e0aa9315f7f65033229c1f76d7df47ccd2da3d0 (diff) | |
CUDA Wave intrinsic vector/matrix support (#1267)
* Distinguish between __activeMask and _getConvergedMask().
Remove need to pass in mask to CUDA wave impls.
* Add support for vector/matrix Wave intrinsics for CUDA.
Fix issue with CUDA parsing of errors.
* Fix typo.
Make WaveReadLineAt and WaveReadFirst work for vector/matrix types.
* Fix typo.
* Added equality wave intrinsic test.
* Fix some typos
* Added wave-lane-at.slang
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/hlsl-intrinsic/wave-equality.slang | 31 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/wave-equality.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/wave-lane-at.slang | 41 | ||||
| -rw-r--r-- | tests/hlsl-intrinsic/wave-lane-at.slang.expected.txt | 4 |
4 files changed, 80 insertions, 0 deletions
diff --git a/tests/hlsl-intrinsic/wave-equality.slang b/tests/hlsl-intrinsic/wave-equality.slang new file mode 100644 index 000000000..d12d8cfbc --- /dev/null +++ b/tests/hlsl-intrinsic/wave-equality.slang @@ -0,0 +1,31 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -profile cs_6_0 +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute +//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int idx = int(dispatchThreadID.x); + + int value = 0; + + // Scalar + + value |= WaveActiveAllEqual(idx * 0 + 1) ? 1 : 0; // true + value |= WaveActiveAllEqual(idx & 2) ? 2 : 0; // false + + // Vector + + int2 v0 = int2(idx & 0xf0, (idx & 0xf00) + 1); // (0, 1) + int2 v1 = int2(idx & 2, (idx & 2) + 1); + + value |= WaveActiveAllEqual(v0) ? 0x10 : 0; // true + value |= WaveActiveAllEqual(v1) ? 0x20 : 0; // false + + outputBuffer[idx] = value; +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/wave-equality.slang.expected.txt b/tests/hlsl-intrinsic/wave-equality.slang.expected.txt new file mode 100644 index 000000000..2bf571888 --- /dev/null +++ b/tests/hlsl-intrinsic/wave-equality.slang.expected.txt @@ -0,0 +1,4 @@ +11 +11 +11 +11 diff --git a/tests/hlsl-intrinsic/wave-lane-at.slang b/tests/hlsl-intrinsic/wave-lane-at.slang new file mode 100644 index 000000000..ca05d985d --- /dev/null +++ b/tests/hlsl-intrinsic/wave-lane-at.slang @@ -0,0 +1,41 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -profile cs_6_0 +// Disabled because on GLSL targets the lane index *must* be a const expr - and in this test it is not. +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute +//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int idx = int(dispatchThreadID.x); + + int value = 0; + + // Scalar + + value += WaveReadLaneAt(idx, (idx + 1) & 3); + + // vector + + { + float2 v = float2(idx + 1, idx + 2); + float2 readValue = WaveReadLaneAt(v, (idx - 1) & 3); + + value += int(readValue[0] + readValue[1]); + } + + // matrix + { + matrix<int, 2, 2> v = matrix<int, 2, 2>(idx, idx - 1, idx * 3, idx - 2); + + matrix<int, 2, 2> readValue = WaveReadLaneAt(v, (idx - 1) & 3); + + value += int(readValue[0][0] + readValue[0][1] + readValue[1][0] + readValue[1][1]); + } + + outputBuffer[idx] = value; +}
\ No newline at end of file diff --git a/tests/hlsl-intrinsic/wave-lane-at.slang.expected.txt b/tests/hlsl-intrinsic/wave-lane-at.slang.expected.txt new file mode 100644 index 000000000..a327b0804 --- /dev/null +++ b/tests/hlsl-intrinsic/wave-lane-at.slang.expected.txt @@ -0,0 +1,4 @@ +19 +2 +B +10 |
