diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-05-05 09:09:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-05 09:09:25 -0400 |
| commit | e3e0132743ada1569cefe18bfbf54178330204c4 (patch) | |
| tree | a85b3992f97f67a5520a520dd60677d382ee4ce6 /tests/experimental | |
| parent | ef314f1b417e92b2fd27e3ed7f504a711c49231b (diff) | |
Preliminary Liveness tracking (#2218)
* #include an absolute path didn't work - because paths were taken to always be relative.
* WIP tracking liveness.
* Skeleton around adding liveness instructions.
* Calling into liveness tracking logic.
Adds live start to var insts.
* Liveness macros have initial output.
* Looking at different initialization scenarios.
* Some discussion around liveness.
* WIP for working out liveness end.
* WIP Updated liveness using use lists.
* Is now adding liveness information
* Some small fixes.
* WIP around liveness.
* Seems to output liveness correctly for current scenario.
* Tidy up liveness code.
* Update comment arounds liveness to current status.
* Small fixes to liveness test.
* Add support for call in liveness analysis.
* Improve liveness example with array access.
* Small updates to comments.
* Disable liveness test because inconsistencies with output on CI system.
* Fix some issues brought up in PR.
* Rename liveness instructions.
Diffstat (limited to 'tests/experimental')
| -rw-r--r-- | tests/experimental/liveness/liveness.slang | 80 | ||||
| -rw-r--r-- | tests/experimental/liveness/liveness.slang.expected | 211 |
2 files changed, 291 insertions, 0 deletions
diff --git a/tests/experimental/liveness/liveness.slang b/tests/experimental/liveness/liveness.slang new file mode 100644 index 000000000..d7b7d6ab5 --- /dev/null +++ b/tests/experimental/liveness/liveness.slang @@ -0,0 +1,80 @@ +//DISABLE_TEST:SIMPLE:-target hlsl -entry computeMain -profile cs_6_3 -track-liveness + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +struct SomeStruct +{ + int a; + int x; + // Make it 'big' + int c[100]; +}; + +//TEST_INPUT:ubuffer(data=[1 4 27 17], stride=4):name anotherBuffer +RWStructuredBuffer<int> anotherBuffer; + +SomeStruct makeSomeStruct() +{ + SomeStruct s = {}; + return s; +} + +// A silly function that is in some sense 'slow' +int someSlowFunc(int a) +{ + uint v = a; + for (int i = 0; i < a * 20; ++i) + { + v = ((v >> 1) || (v << 31)) * i; + } + return v; +} + +int somethingElse(inout SomeStruct s) +{ + s.x ++; + return s.x; +} + +int doThing(SomeStruct s) +{ + return s.x * 2 + 1; +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int index = dispatchThreadID.x; + + int res = index; + + for (int i = 0; i < index; ++i) + { + int v = someSlowFunc(index); // s mut not be considered live here. + + SomeStruct s; + SomeStruct t = makeSomeStruct(); + SomeStruct u = {}; + + if (v & 0x100) + { + s.x = anotherBuffer[v & 3]; + t.x = anotherBuffer[v & 3]; + } + else + { + { + SomeStruct x = u; + x.x = anotherBuffer[v & 3] + 1; + u = x; + } + } + + s.c[index & 7]++; + + res += s.x + t.x + u.x + doThing(t) + somethingElse(t) + s.c[2]; + } + + outputBuffer[index] = res; +} diff --git a/tests/experimental/liveness/liveness.slang.expected b/tests/experimental/liveness/liveness.slang.expected new file mode 100644 index 000000000..21e162256 --- /dev/null +++ b/tests/experimental/liveness/liveness.slang.expected @@ -0,0 +1,211 @@ +result code = 0 +standard error = { +} +standard output = { +#ifdef SLANG_HLSL_ENABLE_NVAPI +#include "nvHLSLExtns.h" +#endif + +#pragma pack_matrix(column_major) + +#line 24 "tests/experimental/liveness/liveness.slang" +int someSlowFunc_0(int a_0) +{ + int i_0; + uint v_0; + +#line 26 + uint _S1 = (uint) a_0; + i_0 = int(0); + v_0 = _S1; + for(;;) + { + +#line 27 + if(i_0 < a_0 * int(20)) + { + } + else + { + break; + } + +#line 29 + uint _S2 = (uint) ((int) ((bool) (v_0 >> int(1)) || (bool) (v_0 << int(31))) * i_0); + +#line 27 + int i_1 = i_0 + int(1); + +#line 27 + i_0 = i_1; + v_0 = _S2; + } + + return (int) v_0; +} + + +#line 6 +struct SomeStruct_0 +{ + int a_1; + int x_0; + int c_0[int(100)]; +}; + + +#line 17 +SomeStruct_0 makeSomeStruct_0() +{ + int _S3[int(100)] = { int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0) }; + +#line 19 + SomeStruct_0 s_0 = { int(0), int(0), _S3 }; + return s_0; +} + + +#line 15 +RWStructuredBuffer<int > anotherBuffer_0 : register(u1); + + +#line 40 +int doThing_0(SomeStruct_0 s_1) +{ + return s_1.x_0 * int(2) + int(1); +} + + +#line 34 +int somethingElse_0(inout SomeStruct_0 s_2) +{ + s_2.x_0 = s_2.x_0 + int(1); + return s_2.x_0; +} + + +#line 4 +RWStructuredBuffer<int > outputBuffer_0 : register(u0); + + +#line 46 +[shader("compute")][numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID_0 : SV_DISPATCHTHREADID) +{ + int i_2; + int res_0; + SomeStruct_0 u_0; + +#line 48 + int index_0 = (int) dispatchThreadID_0.x; + + + + i_2 = int(0); + res_0 = index_0; + for(;;) + { + +#line 52 + if(i_2 < index_0) + { + } + else + { + break; + } + +#line 54 + int v_1 = someSlowFunc_0(index_0); + + SomeStruct_0 s_3; + +#line 56 + SLANG_LIVE_START(s_3) + SomeStruct_0 t_0; + +#line 57 + SLANG_LIVE_START(t_0) + +#line 57 + SomeStruct_0 _S4 = makeSomeStruct_0(); + +#line 57 + t_0 = _S4; + int _S5[int(100)] = { int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0), int(0) }; + +#line 58 + SomeStruct_0 u_1 = { int(0), int(0), _S5 }; + + if((bool) (v_1 & int(256))) + { + s_3.x_0 = anotherBuffer_0[(uint) (v_1 & int(3))]; + t_0.x_0 = anotherBuffer_0[(uint) (v_1 & int(3))]; + +#line 60 + u_0 = u_1; + } + else + { + +#line 68 + SomeStruct_0 x_1; + +#line 68 + SLANG_LIVE_START(x_1) + +#line 68 + x_1 = u_1; + x_1.x_0 = anotherBuffer_0[(uint) (v_1 & int(3))] + int(1); + SomeStruct_0 _S6 = x_1; + +#line 70 + SLANG_LIVE_END(x_1) + +#line 60 + u_0 = _S6; + } + +#line 74 + s_3.c_0[index_0 & int(7)] = s_3.c_0[index_0 & int(7)] + int(1); + + int _S7 = s_3.x_0 + t_0.x_0 + u_0.x_0; + +#line 76 + int _S8 = doThing_0(t_0); + +#line 76 + int _S9 = _S7 + _S8; + +#line 76 + int _S10 = somethingElse_0(t_0); + +#line 76 + SLANG_LIVE_END(t_0) + +#line 76 + int _S11 = _S9 + _S10; + +#line 76 + int _S12 = s_3.c_0[int(2)]; + +#line 76 + SLANG_LIVE_END(s_3) + +#line 76 + int res_1 = res_0 + (_S11 + _S12); + +#line 52 + int i_3 = i_2 + int(1); + +#line 52 + i_2 = i_3; + res_0 = res_1; + } + +#line 79 + outputBuffer_0[(uint) index_0] = res_0; + return; +} + +} |
