From 17c6c6044965629a3ae7e8ef004cc0b2ca657c55 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 4 Feb 2020 15:19:48 -0500 Subject: CUDA/C++ backend improvements (#1198) * WIP with vector float test. * vector-float test working. * Fixed remaing tests broken with init changes. * Improve 64bit-type-support.md * Disable tests broken on CI system for Dx. * WIP: Make type available for comparison. * Moved type conversion into TypeTextUtil. * Add text/type conversions from DownstreamCompiler to TypeTextUtil. * Allow compaison taking into account type. * Removed quantize in vector-float.slang test. --- tests/bugs/dxbc-double-problem.slang.expected.txt | 1 + .../scalar-double-d3d-intrinsic.slang | 5 +- .../scalar-double-d3d-intrinsic.slang.expected.txt | 1 + .../scalar-double-vk-intrinsic.slang.expected.txt | 1 + .../scalar-int64-literal-problem.slang | 7 +- ...scalar-int64-literal-problem.slang.expected.txt | 8 ++ tests/hlsl-intrinsic/vector-float.slang | 103 +++++++++++++++++++++ .../hlsl-intrinsic/vector-float.slang.expected.txt | 17 ++++ 8 files changed, 138 insertions(+), 5 deletions(-) create mode 100644 tests/hlsl-intrinsic/vector-float.slang create mode 100644 tests/hlsl-intrinsic/vector-float.slang.expected.txt (limited to 'tests') diff --git a/tests/bugs/dxbc-double-problem.slang.expected.txt b/tests/bugs/dxbc-double-problem.slang.expected.txt index 2cffc0e7c..d560391b9 100644 --- a/tests/bugs/dxbc-double-problem.slang.expected.txt +++ b/tests/bugs/dxbc-double-problem.slang.expected.txt @@ -1,3 +1,4 @@ +type: double 0.674277 3.141593 0.017453 diff --git a/tests/hlsl-intrinsic/scalar-double-d3d-intrinsic.slang b/tests/hlsl-intrinsic/scalar-double-d3d-intrinsic.slang index 02bffb7b1..600dfa88d 100644 --- a/tests/hlsl-intrinsic/scalar-double-d3d-intrinsic.slang +++ b/tests/hlsl-intrinsic/scalar-double-d3d-intrinsic.slang @@ -1,8 +1,7 @@ -// It doesn't look like fxc, dxc, vk support double versions of many of the intrinsics, so they are disabled here. - //TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type +// On dx11 this causes a crash on CI (not currently not repeatable on test systems) //DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type -// Fxc doesn't have double intrinsics available +// This is disabled because Dx12/DXBC doing double writes to a structured buffer can fail //DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -output-using-type //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_0 -use-dxil -output-using-type //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type diff --git a/tests/hlsl-intrinsic/scalar-double-d3d-intrinsic.slang.expected.txt b/tests/hlsl-intrinsic/scalar-double-d3d-intrinsic.slang.expected.txt index 60826a847..44f39ae21 100644 --- a/tests/hlsl-intrinsic/scalar-double-d3d-intrinsic.slang.expected.txt +++ b/tests/hlsl-intrinsic/scalar-double-d3d-intrinsic.slang.expected.txt @@ -1,3 +1,4 @@ +type: double 2.850000 2.550000 3.216667 diff --git a/tests/hlsl-intrinsic/scalar-double-vk-intrinsic.slang.expected.txt b/tests/hlsl-intrinsic/scalar-double-vk-intrinsic.slang.expected.txt index 6fd20cd00..b1b17082a 100644 --- a/tests/hlsl-intrinsic/scalar-double-vk-intrinsic.slang.expected.txt +++ b/tests/hlsl-intrinsic/scalar-double-vk-intrinsic.slang.expected.txt @@ -1,3 +1,4 @@ +type: double -105.150000 -46.277573 13.888270 diff --git a/tests/hlsl-intrinsic/scalar-int64-literal-problem.slang b/tests/hlsl-intrinsic/scalar-int64-literal-problem.slang index 71f058dc1..c315e84cd 100644 --- a/tests/hlsl-intrinsic/scalar-int64-literal-problem.slang +++ b/tests/hlsl-intrinsic/scalar-int64-literal-problem.slang @@ -1,12 +1,15 @@ +// Disable the test in general, exists to check the output when the fix is in. + //TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute // No support for int64_t on dx11 (no sm 6.0) //DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute // No support with Dx12 with dxbc. Needs SM6.0 + dxil //DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -profile cs_6_0 -dx12 -use-dxil +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -profile cs_6_0 -dx12 -use-dxil // GLSL notices the narrowing of a 64 bit literal into 32 bits and for it this is an error. //DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute + //TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer RWStructuredBuffer outputBuffer; diff --git a/tests/hlsl-intrinsic/scalar-int64-literal-problem.slang.expected.txt b/tests/hlsl-intrinsic/scalar-int64-literal-problem.slang.expected.txt index e69de29bb..6c2c9dabe 100644 --- a/tests/hlsl-intrinsic/scalar-int64-literal-problem.slang.expected.txt +++ b/tests/hlsl-intrinsic/scalar-int64-literal-problem.slang.expected.txt @@ -0,0 +1,8 @@ +7FFFFFFF +FFFFFFFF +0 +FFFFFFFD +80000000 +FFFFFFFB +0 +FFFFFFF9 diff --git a/tests/hlsl-intrinsic/vector-float.slang b/tests/hlsl-intrinsic/vector-float.slang new file mode 100644 index 000000000..2ca98de6c --- /dev/null +++ b/tests/hlsl-intrinsic/vector-float.slang @@ -0,0 +1,103 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int idx = int(dispatchThreadID.x); + + float vf = idx * (1.0f / (4.0f)); + + float3 f = float3(0.1f, vf, vf + 0.2f); + + // Vector specific + float3 nv = normalize(f); + + + // Operate over all values + float3 ft = {}; + + // fmod + ft += float3(int3(((f % 0.11f) * 100) + 0.5)); + + ft += sin(f); + ft += cos(f); + ft += tan(f); + + ft += asin(f); + ft += acos(f); + ft += atan(f); + + ft += atan2(f, 2.0); + +#if 0 + { + // Disabled because not supported on VK (glsl) in vector form + float3 sf, cf; + sincos(f, sf, cf); + + ft += sf; + ft += cf; + } +#endif + +#if 0 + // Disabled because not supported on VK (glsl) in vector form + ft += rcp(1.0 + f); +#endif + + ft += sign(f - 0.5); + + ft += saturate(f * 4 - 2.0); + + ft += sqrt(f); + ft += rsqrt(1.0f + f); + + ft += exp2(f); + ft += exp(f); + + ft += frac(f * 3); + ft += ceil(f * 5 - 3); + + ft += floor(f * 10 - 7.01); + + ft += trunc(f * 7); + + ft += log(f + 10.0); + ft += log2(f * 3 + 2); + + + { + float v[] = { 1, 10, 100, 1000 }; + ft += int3(log10(float3(v[idx] + vf) + 0.5f)); + } + + + ft += abs(f * 4 - 2.0f); + + ft += min(0.5, f); + ft += max(f, 0.75); + + ft += pow(0.5, f); + + ft += smoothstep(0.2, 0.7, f); + ft += lerp(-100, 100, f); + + ft += clamp(f, 0.1, 0.3); + + ft += step(f, 0.5); + + int3 vi = asint(f - f) + idx; + + ft += float3(vi); + + float4 result = float4(ft + nv, 0) + float4(vf); + + outputBuffer[idx] = result; +} \ No newline at end of file diff --git a/tests/hlsl-intrinsic/vector-float.slang.expected.txt b/tests/hlsl-intrinsic/vector-float.slang.expected.txt new file mode 100644 index 000000000..c2a569574 --- /dev/null +++ b/tests/hlsl-intrinsic/vector-float.slang.expected.txt @@ -0,0 +1,17 @@ +type: float +-64.893356 +-98.276619 +-42.604630 +0.000000 +-62.899876 +-34.338215 +9.949981 +0.250000 +-60.725098 +28.410460 +73.591156 +0.500000 +-58.508228 +93.563255 +138.897034 +0.750000 -- cgit v1.2.3