diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2021-05-04 16:24:51 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-04 13:24:51 -0700 |
| commit | 731f1fc6b26659dc8f62fbc1969c076b78ada24f (patch) | |
| tree | 9fcc4d1d931049edeabe3cea46d0bd6942956042 /tests | |
| parent | dc571f1291f6b82b189a0db52c0468ae2fc7af4b (diff) | |
CUDA half comparison support (#1834)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Split out StringEscapeUtil.
* Added StringEscapeUtil.
* Fix typo in unix quoting type.
* Small comment improvements.
* Try to fix linux linking issue.
* Fix typo.
* Attempt to fix linux link issue.
* Update VS proj even though nothing really changed.
* Fix another typo issue.
* Fix for windows issue.
Fixed bug.
* Make separate Utils for escaping.
* Fix typo.
* Split out into StringEscapeHandler.
* Windows shell does handle removing quotes (so remove code to remove them).
* Handle unescaping if not initiating using the shell.
* Slight improvement around shell like decoding.
* Simplify command extraction.
* Add shared-library category type.
* Fix bug in command extraction.
* Typo in transcendental category.
* Enable unit-test on in smoke test category.
* Make parsing failing output as a failing test.
* Fixes for transcendental tests. Disable tests that do not work.
* Changed category parsing.
* Removed the TestResult parameter from _gatherTestsForFile.
Made testsList only output.
* Remove testing if all tests were disabled.
* Make args of CommandLine always unescaped.
* Add category.
* Don't need escaping on unix/linux.
* Remove some no longer used functions.
* Add requireSMVersion to CUDAExtensionTracker.
* half-calc.slang now works for CUDA.
* bit-cast-16-bit works on CUDA.
* WIP handling of CUDA vector<half> types.
* Half swizzle CUDA.
* Half vector test.
* Fix swizzle half bug.
* Fix compilation issue with narrowing to Index.
* Add unary ops.
* Add some vector scalar maths ops.
* Add half vector conversions for CUDA.
* Fix erroneous comment.
* Support for half comparisons.
* First pass test for half compare.
* Fix bug in CUDA specialized emit control.
Updated tests to have pre and post inc/dec.
* Removed unneeded parts of the cuda prelude.
* Half structured buffer works on CUDA.
Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/half-calc.slang | 4 | ||||
| -rw-r--r-- | tests/compute/half-calc.slang.expected.txt | 8 | ||||
| -rw-r--r-- | tests/compute/half-structured-buffer.slang | 2 | ||||
| -rw-r--r-- | tests/compute/half-vector-calc.slang | 4 | ||||
| -rw-r--r-- | tests/compute/half-vector-calc.slang.expected.txt | 8 | ||||
| -rw-r--r-- | tests/compute/half-vector-compare.slang | 98 | ||||
| -rw-r--r-- | tests/compute/half-vector-compare.slang.expected.txt | 5 |
7 files changed, 121 insertions, 8 deletions
diff --git a/tests/compute/half-calc.slang b/tests/compute/half-calc.slang index e0dd01315..0f321ef98 100644 --- a/tests/compute/half-calc.slang +++ b/tests/compute/half-calc.slang @@ -29,5 +29,9 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) v += half(1.0f); v += offset; + v++; + --v; + v--; + outputBuffer[tid] = v; }
\ No newline at end of file diff --git a/tests/compute/half-calc.slang.expected.txt b/tests/compute/half-calc.slang.expected.txt index 2915a0dbc..389e44adf 100644 --- a/tests/compute/half-calc.slang.expected.txt +++ b/tests/compute/half-calc.slang.expected.txt @@ -1,4 +1,4 @@ -3F800000 -40800000 -40E00000 -41200000 +0 +40400000 +40C00000 +41100000 diff --git a/tests/compute/half-structured-buffer.slang b/tests/compute/half-structured-buffer.slang index db0837d53..e701bb0fa 100644 --- a/tests/compute/half-structured-buffer.slang +++ b/tests/compute/half-structured-buffer.slang @@ -1,4 +1,6 @@ //TEST(compute):COMPARE_COMPUTE:-vk -compute -profile cs_6_2 -render-features half -shaderobj +//TEST(compute):COMPARE_COMPUTE:-cuda -compute -render-features half -shaderobj + //Disable on Dx12 for now - because writing to structured buffer produces unexpected results //TEST_DISABLED(compute):COMPARE_COMPUTE:-dx12 -compute -use-dxil -profile cs_6_2 -render-features half -shaderobj diff --git a/tests/compute/half-vector-calc.slang b/tests/compute/half-vector-calc.slang index 3ae204796..b145e27ec 100644 --- a/tests/compute/half-vector-calc.slang +++ b/tests/compute/half-vector-calc.slang @@ -23,6 +23,10 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) v1 += v2.wzy; v2 += v0.xyxy; + v1 ++; + --v2; + v3++; + // Unary v2 = +v2.yxwz; v2 = -v2.zwxy; diff --git a/tests/compute/half-vector-calc.slang.expected.txt b/tests/compute/half-vector-calc.slang.expected.txt index 49c339529..2e80e4e2a 100644 --- a/tests/compute/half-vector-calc.slang.expected.txt +++ b/tests/compute/half-vector-calc.slang.expected.txt @@ -1,5 +1,5 @@ type: float -30.000000 -161.500000 -492.000000 -1021.500000 +73.000000 +206.500000 +539.000000 +1070.000000 diff --git a/tests/compute/half-vector-compare.slang b/tests/compute/half-vector-compare.slang new file mode 100644 index 000000000..5f4670456 --- /dev/null +++ b/tests/compute/half-vector-compare.slang @@ -0,0 +1,98 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE:-dx12 -compute -output-using-type -use-dxil -profile cs_6_2 -render-features half -shaderobj +//TEST(compute):COMPARE_COMPUTE:-vk -compute -output-using-type -profile cs_6_2 -render-features half -shaderobj +//TEST(compute):COMPARE_COMPUTE:-cuda -compute -output-using-type -render-features half -shaderobj + +// Test for doing a calculation using half + +//TEST_INPUT:ubuffer(data=[0.2 10.0 12.0 16.0], stride=4):name=inputBuffer +RWStructuredBuffer<int> inputBuffer; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<float> outputBuffer; + +struct Values +{ + __init(int index) + { + m_index = index; + } + + [mutating] half next() + { + float v = inputBuffer[m_index & 3]; + m_index++; + return half(v); + } + + int m_index = 0; +}; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + Values values = Values(int(tid)); + + int r = 0; + + half s0 = values.next(); + half s1 = values.next(); + + if (s0 < s1) + { + r += 0x1; + } + + half2 h2_0 = half2(values.next(), values.next()); + half2 h2_1 = half2(values.next(), values.next()); + + if (any(h2_0 < h2_1)) + { + r += 0x2; + } + + if (all(h2_0 < h2_1)) + { + r += 0x4; + } + + half3 h3_0 = half3(values.next(), values.next(), values.next()); + half3 h3_1 = half3(values.next(), values.next(), values.next()); + + if (any(h3_0 > h3_1)) + { + r += 0x8; + } + + if (all(h3_0 <= h3_1)) + { + r += 0x10; + } + + half4 h4_0 = half4(values.next(), values.next(), values.next(), values.next()); + half4 h4_1 = half4(values.next(), values.next(), values.next(), values.next()); + + + if (any(h4_0 > h4_1)) + { + r += 0x8; + } + + if (all(h4_0 <= h4_1)) + { + r += 0x10; + } + + if (any(!(h4_0 == h4_1))) + { + r += 0x20; + } + + if (all(h4_0 != h4_1)) + { + r += 0x40; + } + + outputBuffer[tid] = r; +} diff --git a/tests/compute/half-vector-compare.slang.expected.txt b/tests/compute/half-vector-compare.slang.expected.txt new file mode 100644 index 000000000..51c83b301 --- /dev/null +++ b/tests/compute/half-vector-compare.slang.expected.txt @@ -0,0 +1,5 @@ +type: float +32.000000 +32.000000 +32.000000 +32.000000 |
