ir3: Implement helper invocation optimization
authorConnor Abbott <cwabbott0@gmail.com>
Mon, 31 Jul 2023 17:57:06 +0000 (19:57 +0200)
committerMarge Bot <emma+marge@anholt.net>
Thu, 10 Aug 2023 10:09:28 +0000 (10:09 +0000)
commitaa322a37fcb6ab58c389b48186268af5f041a62c
tree10f4fac4ab67f58994cf60b705660b20db3f1418
parentb9489dea3d8a894e96756a66fdd689d06b0ec6dc
ir3: Implement helper invocation optimization

This kills helper invocations to ensure that subsequent memory accesses
don't fetch unused memory and unnecessary branch divergence from helper
invocations is eliminated.

shader-db results:

total instructions in shared programs: 3840580 -> 3841531 (0.02%)
instructions in affected programs: 278416 -> 279367 (0.34%)
helped: 0
HURT: 744
HURT stats (abs)   min: 1 max: 16 x̄: 1.28 x̃: 1
HURT stats (rel)   min: 0.05% max: 8.51% x̄: 0.75% x̃: 0.39%
95% mean confidence interval for instructions value: 1.22 1.34
95% mean confidence interval for instructions %-change: 0.67% 0.83%
Instructions are HURT.

total nops in shared programs: 866716 -> 867667 (0.11%)
nops in affected programs: 72851 -> 73802 (1.31%)
helped: 0
HURT: 744
HURT stats (abs)   min: 1 max: 16 x̄: 1.28 x̃: 1
HURT stats (rel)   min: 0.17% max: 33.33% x̄: 2.84% x̃: 1.82%
95% mean confidence interval for nops value: 1.22 1.34
95% mean confidence interval for nops %-change: 2.59% 3.08%
Nops are HURT.

total last-baryf in shared programs: 139806 -> 139864 (0.04%)
last-baryf in affected programs: 11772 -> 11830 (0.49%)
helped: 0
HURT: 58
HURT stats (abs)   min: 1 max: 1 x̄: 1.00 x̃: 1
HURT stats (rel)   min: 0.40% max: 5.26% x̄: 0.60% x̃: 0.47%
95% mean confidence interval for last-baryf value: 1.00 1.00
95% mean confidence interval for last-baryf %-change: 0.42% 0.78%
Last-baryf are HURT.

total last-helper in shared programs: 1508295 -> 935561 (-37.97%)
last-helper in affected programs: 1192594 -> 619860 (-48.02%)
helped: 7816
HURT: 3
helped stats (abs) min: 1 max: 1095 x̄: 73.28 x̃: 34
helped stats (rel) min: 0.42% max: 100.00% x̄: 71.91% x̃: 100.00%
HURT stats (abs)   min: 1 max: 11 x̄: 4.67 x̃: 2
HURT stats (rel)   min: 0.80% max: 1.44% x̄: 1.03% x̃: 0.86%
95% mean confidence interval for last-helper value: -75.64 -70.86
95% mean confidence interval for last-helper %-change: -72.67% -71.10%
Last-helper are helped.

fossil-db results:

Totals:
Instrs: 55172795 -> 55189122 (+0.03%)
CodeSize: 108952746 -> 108984452 (+0.03%)
NOPs: 11536680 -> 11553007 (+0.14%)
(ss)-stall: 4166810 -> 4166581 (-0.01%)
(sy)-stall: 15890324 -> 15884974 (-0.03%)
last-baryf: 659588 -> 659633 (+0.01%)
last-helper: 25742996 -> 12601636 (-51.05%); split: -51.05%, +0.00%
Cat0: 12294891 -> 12311218 (+0.13%)

Totals from 39576 (25.22% of 156916) affected shaders:
Instrs: 24200008 -> 24216335 (+0.07%)
CodeSize: 44968736 -> 45000442 (+0.07%)
NOPs: 5854965 -> 5871292 (+0.28%)
(ss)-stall: 2357830 -> 2357601 (-0.01%)
(sy)-stall: 6166670 -> 6161320 (-0.09%)
last-baryf: 590330 -> 590375 (+0.01%)
last-helper: 24160432 -> 11019072 (-54.39%); split: -54.39%, +0.00%

Cat0: 6205561 -> 6221888 (+0.26%)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24433>
src/freedreno/ir3/ir3.h
src/freedreno/ir3/ir3_legalize.c