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/compute/half-vector-compare.slang | |
| 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/compute/half-vector-compare.slang')
| -rw-r--r-- | tests/compute/half-vector-compare.slang | 98 |
1 files changed, 98 insertions, 0 deletions
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; +} |
