From 31c7abcc27a33d63ac8d335387a0ce7b3ad74954 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 18 Sep 2019 11:40:59 -0400 Subject: Improvements to testing and ABI for CPU (#1057) * WIP: Improving CPU performance/ABI * Optionally output code on CPU for groupThreadID and groupID. * Added ability to set compute dispatch size on command line for render-test. Dispatch compute tests taking into account dispatch size. Added test for semantics are working. * Test using GroupRange. * Fix problem with adding \n for externa diagnostic - to do it if there isn't a \n at the end. Change the ouput order (put result before) so last value is diagnostic string. * Made GroupRange the default exposed CPU ABI entry point style. Removed CPU_EXECUTE test style -as tested via the now cross platform render-test * Split out execution from setup for execution to improve perf. * For better code coverage/testing test all styles of CPU compute entry point. * Improve documentation for ABI changes for CPU code. Add 'expecting' to error message from review. * Fix small typos. --- tests/cross-compile/cpp-execute-simple.slang | 14 --- .../cpp-execute-simple.slang.expected | 1 - tests/cross-compile/cpp-execute.slang | 107 --------------------- tests/cross-compile/cpp-execute.slang.expected | 1 - 4 files changed, 123 deletions(-) delete mode 100644 tests/cross-compile/cpp-execute-simple.slang delete mode 100644 tests/cross-compile/cpp-execute-simple.slang.expected delete mode 100644 tests/cross-compile/cpp-execute.slang delete mode 100644 tests/cross-compile/cpp-execute.slang.expected (limited to 'tests') diff --git a/tests/cross-compile/cpp-execute-simple.slang b/tests/cross-compile/cpp-execute-simple.slang deleted file mode 100644 index 72c77b653..000000000 --- a/tests/cross-compile/cpp-execute-simple.slang +++ /dev/null @@ -1,14 +0,0 @@ -//TEST:CPU_EXECUTE: -profile cs_5_0 -entry computeMain -target sharedlib - -//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out -RWStructuredBuffer outputBuffer; - - -[numthreads(4, 1, 1)] -void computeMain( - uint3 dispatchThreadID : SV_DispatchThreadID) -{ - uint tid = dispatchThreadID.x; - - outputBuffer[tid] = int(tid * tid); -} \ No newline at end of file diff --git a/tests/cross-compile/cpp-execute-simple.slang.expected b/tests/cross-compile/cpp-execute-simple.slang.expected deleted file mode 100644 index b84777e95..000000000 --- a/tests/cross-compile/cpp-execute-simple.slang.expected +++ /dev/null @@ -1 +0,0 @@ -0, 1, 4, 9 diff --git a/tests/cross-compile/cpp-execute.slang b/tests/cross-compile/cpp-execute.slang deleted file mode 100644 index 2700aa49f..000000000 --- a/tests/cross-compile/cpp-execute.slang +++ /dev/null @@ -1,107 +0,0 @@ -//TEST:CPU_EXECUTE: -profile cs_5_0 -entry computeMain -target sharedlib - -enum Color -{ - Red, - Green = 2, - Blue, -} - -int test(int val) -{ - Color c = Color.Red; - - if(val > 1) - { - c = Color.Green; - } - - if(c == Color.Red) - { - if(val & 1) - { - c = Color.Blue; - } - } - - switch(c) - { - case Color.Red: - val = 1; - break; - - case Color.Green: - val = 2; - break; - - case Color.Blue: - val = 3; - break; - - default: - val = -1; - break; - } - - return (val << 4) + int(c); -} - -float sum(float a[3]) -{ - float total = a[0]; - for (int i = 1; i < 3; ++i) - { - total += a[i]; - } - return total; -} - -struct Thing -{ - int a; - float b; -}; - -//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out -RWStructuredBuffer outputBuffer; - -[numthreads(4, 1, 1)] -void computeMain( - uint3 dispatchThreadID : SV_DispatchThreadID) -{ - uint tid = dispatchThreadID.x; - - Thing thing = { 10, -1.0 }; - - float array[3] = { thing.a, 2, 3}; - - float anotherArray[] = { 1, 2, 5 }; - - array[0] += anotherArray[1]; - - matrix mat = { { sum(array), 1, 2 }, { 3, 4, 5} }; - vector vec = { float(tid + 1), float(tid + 2) }; - - vector vec2 = max(sin(mul(vec, mat)), float3(1, 2, -1)); - vector vec3 = mul(vec, mat); - - float3 vec4 = lerp(vec2, vec3, float3(tid * (1.0f / 4), 1, 1)); - - float3 crossVec = normalize(cross(vec4, vec4)); - - vec2.x = fmod(crossVec.y, crossVec.x); - - vec2 = fmod(vec2, crossVec); - - vec2 += (-vec2.zyx) * 2 + crossVec * length(crossVec) + reflect(vec4, normalize(crossVec)); - - vector z = vec2 > 0; - - int val = (int(tid) + (any(z) ? 1 : 0) + (all(z) ? 2 : 0)) % 100; - - val = asint(asfloat(asuint(asfloat(val)))); - - val = test(val); - - outputBuffer[tid] = val + int(dot(vec2, vec4)); -} \ No newline at end of file diff --git a/tests/cross-compile/cpp-execute.slang.expected b/tests/cross-compile/cpp-execute.slang.expected deleted file mode 100644 index 65e3ed534..000000000 --- a/tests/cross-compile/cpp-execute.slang.expected +++ /dev/null @@ -1 +0,0 @@ --2147483632, -2147483597, -2147483614, -2147483614 -- cgit v1.2.3