diff options
| author | Ayinaki <ayinakidev@gmail.com> | 2026-11-22 15:23:55 +0000 |
|---|---|---|
| committer | Ayinaki <ayinakidev@gmail.com> | 2026-11-22 15:23:55 +0000 |
| commit | 3e38c9837787c43b5c8a73e44932bb29b3243be8 (patch) | |
| tree | 0677c41ee61366b4245a8303109880435644ab2f /tests/test_cfg_structure.py | |
| parent | 89b047cd8fab50675a43d76722a6a8a881f55dc2 (diff) | |
rdna2spirv: bound structured nesting depth with the dispatch-loop form
spirv-val's structured-control-flow checking cost grows roughly with the cube
of the nesting depth: over the 1.0.2.1 corpus the deepest block sits 118
constructs deep and about 85% of validation time is in modules nested 20 or
deeper. cfg_structure.depth() measures the tree and a module deeper than
MAX_STRUCTURED_DEPTH (16) is emitted in the existing flat dispatch-loop form
instead, which emits the same blocks and only changes the routing. Depth
5-12 shows no gain, hence the bound at 16.
Diffstat (limited to 'tests/test_cfg_structure.py')
| -rw-r--r-- | tests/test_cfg_structure.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/test_cfg_structure.py b/tests/test_cfg_structure.py index 78c71f8de..f51fe3e17 100644 --- a/tests/test_cfg_structure.py +++ b/tests/test_cfg_structure.py | |||
| @@ -140,6 +140,13 @@ def test_random_graphs(): | |||
| 140 | _check_random_graphs() | 140 | _check_random_graphs() |
| 141 | 141 | ||
| 142 | 142 | ||
| 143 | def test_depth(): | ||
| 144 | assert S.depth([("block", 0)]) == 0 | ||
| 145 | assert S.depth([("block", 0), ("loop", 1, [("block", 1), ("guard", 2, [("block", 2)])])]) == 2 | ||
| 146 | assert S.depth([]) == 0 | ||
| 147 | assert S.depth(S.structure([[1, 2], [3], [3], []])) == 1 # a diamond is one guard deep | ||
| 148 | |||
| 149 | |||
| 143 | def test_shapes(): | 150 | def test_shapes(): |
| 144 | assert S.structure([[]]) == [("block", 0)] | 151 | assert S.structure([[]]) == [("block", 0)] |
| 145 | assert S.structure([[1], [2], []]) == [("block", 0), ("block", 1), ("block", 2)] # no tests needed | 152 | assert S.structure([[1], [2], []]) == [("block", 0), ("block", 1), ("block", 2)] # no tests needed |