mesa/src/compiler/nir/nir_opt_gcm.c

865 lines
29 KiB
C
Raw Normal View History

/*
* Copyright © 2014 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* Authors:
* Jason Ekstrand (jason@jlekstrand.net)
*
*/
#include "nir.h"
#include "nir_instr_set.h"
/*
* Implements Global Code Motion. A description of GCM can be found in
* "Global Code Motion; Global Value Numbering" by Cliff Click.
* Unfortunately, the algorithm presented in the paper is broken in a
* number of ways. The algorithm used here differs substantially from the
* one in the paper but it is, in my opinion, much easier to read and
* verify correcness.
*/
nir: add heuristic for instructions in loops with GCM Moving instructions out of large loops tends to cause excessive spilling. This appears to be a good limit. In future it might make sense to make this a NIR options so other drivers can set their own limits. Tiger Lake total instructions in shared programs: 20930180 -> 20926952 (-0.02%) instructions in affected programs: 280768 -> 277540 (-1.15%) helped: 734 HURT: 192 helped stats (abs) min: 1 max: 61 x̄: 5.16 x̃: 4 helped stats (rel) min: 0.04% max: 10.64% x̄: 3.23% x̃: 3.14% HURT stats (abs) min: 1 max: 52 x̄: 2.90 x̃: 1 HURT stats (rel) min: 0.03% max: 9.76% x̄: 1.13% x̃: 0.61% 95% mean confidence interval for instructions value: -3.89 -3.08 95% mean confidence interval for instructions %-change: -2.49% -2.16% Instructions are helped. total cycles in shared programs: 841825217 -> 838817552 (-0.36%) cycles in affected programs: 122088078 -> 119080413 (-2.46%) helped: 941 HURT: 100 helped stats (abs) min: 1 max: 160080 x̄: 3274.31 x̃: 2660 helped stats (rel) min: <.01% max: 41.64% x̄: 5.50% x̃: 4.80% HURT stats (abs) min: 1 max: 41856 x̄: 734.62 x̃: 26 HURT stats (rel) min: <.01% max: 7.29% x̄: 0.44% x̃: 0.27% 95% mean confidence interval for cycles value: -3236.56 -2541.85 95% mean confidence interval for cycles %-change: -5.26% -4.60% Cycles are helped. total sends in shared programs: 977905 -> 977782 (-0.01%) sends in affected programs: 2279 -> 2156 (-5.40%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.93% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.42% -6.45% Sends are helped. LOST: 2 GAINED: 0 Ice Lake total instructions in shared programs: 19865361 -> 19861747 (-0.02%) instructions in affected programs: 185789 -> 182175 (-1.95%) helped: 593 HURT: 47 helped stats (abs) min: 1 max: 27 x̄: 6.17 x̃: 4 helped stats (rel) min: 0.19% max: 8.65% x̄: 4.53% x̃: 4.60% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.23% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -5.93 -5.37 95% mean confidence interval for instructions %-change: -4.32% -4.06% Instructions are helped. total loops in shared programs: 6120 -> 6117 (-0.05%) loops in affected programs: 6 -> 3 (-50.00%) helped: 3 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% total cycles in shared programs: 961777176 -> 959404350 (-0.25%) cycles in affected programs: 172224180 -> 169851354 (-1.38%) helped: 936 HURT: 80 helped stats (abs) min: 1 max: 9566 x̄: 2621.08 x̃: 2550 helped stats (rel) min: <.01% max: 41.77% x̄: 4.22% x̃: 3.84% HURT stats (abs) min: 1 max: 59146 x̄: 1006.34 x̃: 24 HURT stats (rel) min: <.01% max: 3.78% x̄: 0.44% x̃: 0.25% 95% mean confidence interval for cycles value: -2513.72 -2157.20 95% mean confidence interval for cycles %-change: -4.13% -3.57% Cycles are helped. total sends in shared programs: 1019995 -> 1019872 (-0.01%) sends in affected programs: 2283 -> 2160 (-5.39%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.39% -6.42% Sends are helped. LOST: 4 GAINED: 0 Skylake total instructions in shared programs: 17994337 -> 17993846 (<.01%) instructions in affected programs: 146294 -> 145803 (-0.34%) helped: 190 HURT: 47 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.14% max: 4.29% x̄: 1.08% x̃: 0.90% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.22% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -2.30 -1.84 95% mean confidence interval for instructions %-change: -0.95% -0.74% Instructions are helped. total loops in shared programs: 6029 -> 6023 (-0.10%) loops in affected programs: 12 -> 6 (-50.00%) helped: 6 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 939062940 -> 938023548 (-0.11%) cycles in affected programs: 169671482 -> 168632090 (-0.61%) helped: 980 HURT: 134 helped stats (abs) min: 1 max: 25000 x̄: 1075.57 x̃: 1052 helped stats (rel) min: <.01% max: 42.75% x̄: 2.51% x̃: 1.32% HURT stats (abs) min: 1 max: 837 x̄: 109.45 x̃: 20 HURT stats (rel) min: <.01% max: 5.71% x̄: 0.73% x̃: 0.21% 95% mean confidence interval for cycles value: -1005.89 -860.17 95% mean confidence interval for cycles %-change: -2.39% -1.84% Cycles are helped. total sends in shared programs: 1026848 -> 1026724 (-0.01%) sends in affected programs: 2302 -> 2178 (-5.39%) helped: 120 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.40% -6.43% Sends are helped. LOST: 1 GAINED: 1 Broadwell total instructions in shared programs: 17605621 -> 17605154 (<.01%) instructions in affected programs: 145691 -> 145224 (-0.32%) helped: 184 HURT: 48 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.13% max: 4.29% x̄: 1.09% x̃: 0.93% HURT stats (abs) min: 1 max: 7 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 0.48% x̄: 0.12% x̃: 0.04% 95% mean confidence interval for instructions value: -2.26 -1.77 95% mean confidence interval for instructions %-change: -0.95% -0.73% Instructions are helped. total loops in shared programs: 5968 -> 5963 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 1000679489 -> 998592756 (-0.21%) cycles in affected programs: 173421234 -> 171334501 (-1.20%) helped: 993 HURT: 153 helped stats (abs) min: 1 max: 766608 x̄: 2118.49 x̃: 1080 helped stats (rel) min: <.01% max: 54.61% x̄: 2.61% x̃: 1.73% HURT stats (abs) min: 1 max: 2200 x̄: 110.61 x̃: 11 HURT stats (rel) min: <.01% max: 5.68% x̄: 0.63% x̃: 0.06% 95% mean confidence interval for cycles value: -3191.23 -450.54 95% mean confidence interval for cycles %-change: -2.47% -1.89% Cycles are helped. total sends in shared programs: 996341 -> 996222 (-0.01%) sends in affected programs: 2151 -> 2032 (-5.53%) helped: 115 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 7.07% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.55% -6.58% Sends are helped. Haswell total instructions in shared programs: 16038375 -> 16038121 (<.01%) instructions in affected programs: 216797 -> 216543 (-0.12%) helped: 185 HURT: 217 helped stats (abs) min: 1 max: 12 x̄: 2.84 x̃: 3 helped stats (rel) min: 0.13% max: 4.23% x̄: 1.30% x̃: 1.20% HURT stats (abs) min: 1 max: 6 x̄: 1.25 x̃: 1 HURT stats (rel) min: 0.03% max: 5.66% x̄: 0.61% x̃: 0.40% 95% mean confidence interval for instructions value: -0.85 -0.41 95% mean confidence interval for instructions %-change: -0.40% -0.14% Instructions are helped. total loops in shared programs: 5947 -> 5942 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 967655093 -> 965746713 (-0.20%) cycles in affected programs: 197288924 -> 195380544 (-0.97%) helped: 950 HURT: 195 helped stats (abs) min: 1 max: 782820 x̄: 2274.79 x̃: 1260 helped stats (rel) min: <.01% max: 54.26% x̄: 3.02% x̃: 1.71% HURT stats (abs) min: 1 max: 15790 x̄: 1295.73 x̃: 21 HURT stats (rel) min: <.01% max: 119.85% x̄: 7.76% x̃: 0.11% 95% mean confidence interval for cycles value: -3014.22 -319.19 95% mean confidence interval for cycles %-change: -1.83% -0.55% Cycles are helped. total sends in shared programs: 934894 -> 934765 (-0.01%) sends in affected programs: 2192 -> 2063 (-5.89%) helped: 115 HURT: 2 helped stats (abs) min: 1 max: 4 x̄: 1.14 x̃: 1 helped stats (rel) min: 0.60% max: 28.57% x̄: 7.68% x̃: 6.67% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 16.67% max: 16.67% x̄: 16.67% x̃: 16.67% 95% mean confidence interval for sends value: -1.23 -0.98 95% mean confidence interval for sends %-change: -8.28% -6.24% Sends are helped. LOST: 1 GAINED: 18 Ivy Bridge total instructions in shared programs: 15269357 -> 15269398 (<.01%) instructions in affected programs: 190484 -> 190525 (0.02%) helped: 77 HURT: 206 helped stats (abs) min: 1 max: 6 x̄: 2.47 x̃: 3 helped stats (rel) min: 0.14% max: 5.31% x̄: 1.46% x̃: 1.65% HURT stats (abs) min: 1 max: 3 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 2.38% x̄: 0.42% x̃: 0.40% 95% mean confidence interval for instructions value: -0.06 0.35 95% mean confidence interval for instructions %-change: -0.21% 0.03% Inconclusive result (value mean confidence interval includes 0). total loops in shared programs: 4001 -> 3996 (-0.12%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 562045564 -> 561063543 (-0.17%) cycles in affected programs: 200924872 -> 199942851 (-0.49%) helped: 748 HURT: 160 helped stats (abs) min: 2 max: 14926 x̄: 1692.94 x̃: 1620 helped stats (rel) min: <.01% max: 53.29% x̄: 3.17% x̃: 1.87% HURT stats (abs) min: 2 max: 15726 x̄: 1776.86 x̃: 36 HURT stats (rel) min: <.01% max: 114.43% x̄: 10.66% x̃: 0.21% 95% mean confidence interval for cycles value: -1237.33 -925.71 95% mean confidence interval for cycles %-change: -1.54% 0.08% Inconclusive result (%-change mean confidence interval includes 0). total sends in shared programs: 893348 -> 893330 (<.01%) sends in affected programs: 187 -> 169 (-9.63%) helped: 14 HURT: 0 helped stats (abs) min: 1 max: 2 x̄: 1.29 x̃: 1 helped stats (rel) min: 4.08% max: 22.22% x̄: 11.70% x̃: 10.10% 95% mean confidence interval for sends value: -1.56 -1.02 95% mean confidence interval for sends %-change: -14.92% -8.48% Sends are helped. LOST: 1 GAINED: 19 Sandy Bridge total instructions in shared programs: 11785227 -> 11785774 (<.01%) instructions in affected programs: 78403 -> 78950 (0.70%) helped: 65 HURT: 505 helped stats (abs) min: 1 max: 4 x̄: 2.22 x̃: 3 helped stats (rel) min: 0.14% max: 4.17% x̄: 1.19% x̃: 1.38% HURT stats (abs) min: 1 max: 5 x̄: 1.37 x̃: 1 HURT stats (rel) min: 0.24% max: 3.33% x̄: 1.57% x̃: 1.72% 95% mean confidence interval for instructions value: 0.85 1.07 95% mean confidence interval for instructions %-change: 1.16% 1.36% Instructions are HURT. total loops in shared programs: 2441 -> 2437 (-0.16%) loops in affected programs: 8 -> 4 (-50.00%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 497178796 -> 496669298 (-0.10%) cycles in affected programs: 51483322 -> 50973824 (-0.99%) helped: 476 HURT: 137 helped stats (abs) min: 2 max: 7502 x̄: 1079.36 x̃: 1260 helped stats (rel) min: <.01% max: 42.50% x̄: 2.31% x̃: 0.86% HURT stats (abs) min: 2 max: 754 x̄: 31.23 x̃: 18 HURT stats (rel) min: <.01% max: 3.01% x̄: 0.09% x̃: 0.02% 95% mean confidence interval for cycles value: -901.99 -760.32 95% mean confidence interval for cycles %-change: -2.20% -1.36% Cycles are helped. total sends in shared programs: 642919 -> 642915 (<.01%) sends in affected programs: 32 -> 28 (-12.50%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 11.11% max: 14.29% x̄: 12.70% x̃: 12.70% 95% mean confidence interval for sends value: -1.00 -1.00 95% mean confidence interval for sends %-change: -15.61% -9.78% Sends are helped. Iron Lake total instructions in shared programs: 8180061 -> 8180248 (<.01%) instructions in affected programs: 65004 -> 65191 (0.29%) helped: 59 HURT: 253 helped stats (abs) min: 1 max: 4 x̄: 2.24 x̃: 3 helped stats (rel) min: 0.16% max: 2.23% x̄: 1.04% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.26 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.93% x̃: 0.60% 95% mean confidence interval for instructions value: 0.43 0.77 95% mean confidence interval for instructions %-change: 0.45% 0.68% Instructions are HURT. total loops in shared programs: 863 -> 861 (-0.23%) loops in affected programs: 4 -> 2 (-50.00%) helped: 2 HURT: 0 total cycles in shared programs: 239357490 -> 238907668 (-0.19%) cycles in affected programs: 17314006 -> 16864184 (-2.60%) helped: 176 HURT: 34 helped stats (abs) min: 4 max: 13400 x̄: 2558.05 x̃: 2920 helped stats (rel) min: 0.01% max: 35.58% x̄: 3.76% x̃: 2.69% HURT stats (abs) min: 2 max: 14 x̄: 11.59 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2440.68 -1843.34 95% mean confidence interval for cycles %-change: -3.78% -2.51% Cycles are helped. GM45 total instructions in shared programs: 4985293 -> 4985401 (<.01%) instructions in affected programs: 58807 -> 58915 (0.18%) helped: 57 HURT: 202 helped stats (abs) min: 1 max: 4 x̄: 2.26 x̃: 3 helped stats (rel) min: 0.15% max: 2.23% x̄: 1.06% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.17 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.76% x̃: 0.48% 95% mean confidence interval for instructions value: 0.22 0.61 95% mean confidence interval for instructions %-change: 0.24% 0.48% Instructions are HURT. total loops in shared programs: 639 -> 638 (-0.16%) loops in affected programs: 2 -> 1 (-50.00%) helped: 1 HURT: 0 total cycles in shared programs: 153794236 -> 153546274 (-0.16%) cycles in affected programs: 9947778 -> 9699816 (-2.49%) helped: 110 HURT: 31 helped stats (abs) min: 4 max: 13400 x̄: 2257.51 x̃: 1796 helped stats (rel) min: 0.01% max: 35.58% x̄: 4.33% x̃: 2.45% HURT stats (abs) min: 2 max: 14 x̄: 11.74 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2113.77 -1403.42 95% mean confidence interval for cycles %-change: -4.27% -2.47% Cycles are helped. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2899 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12064>
2021-07-26 23:25:58 +10:00
/* This is used to stop GCM moving instruction out of a loop if the loop
* contains too many instructions and moving them would create excess spilling.
*
* TODO: Figure out a better way to decide if we should remove instructions from
* a loop.
*/
#define MAX_LOOP_INSTRUCTIONS 100
struct gcm_block_info {
/* Number of loops this block is inside */
unsigned loop_depth;
nir/gcm: fix pushing instructions into if blocks The previous logic would just set the block to the instructions original location if we couldn't evict it from a loop. For now we only push const loads to a later block inside ifs but we can add more heuristics later. This change helps a hand full of shaders but also stops a CTS regression caused by excess spilling after a series I'm working on to disable more of the GLSL IR optimisation passes. Shader-db results iris (BDW): total instructions in shared programs: 17529759 -> 17529749 (<.01%) instructions in affected programs: 15929 -> 15919 (-0.06%) helped: 5 HURT: 2 helped stats (abs) min: 1 max: 5 x̄: 2.40 x̃: 2 helped stats (rel) min: 0.06% max: 0.15% x̄: 0.11% x̃: 0.12% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.06% max: 0.06% x̄: 0.06% x̃: 0.06% 95% mean confidence interval for instructions value: -3.34 0.49 95% mean confidence interval for instructions %-change: -0.14% 0.02% Inconclusive result (value mean confidence interval includes 0). total cycles in shared programs: 861109994 -> 861099681 (<.01%) cycles in affected programs: 7027698 -> 7017385 (-0.15%) helped: 95 HURT: 72 helped stats (abs) min: 1 max: 7995 x̄: 138.54 x̃: 9 helped stats (rel) min: <.01% max: 15.96% x̄: 0.54% x̃: 0.11% HURT stats (abs) min: 1 max: 474 x̄: 39.56 x̃: 12 HURT stats (rel) min: <.01% max: 1.17% x̄: 0.20% x̃: 0.11% 95% mean confidence interval for cycles value: -159.05 35.54 95% mean confidence interval for cycles %-change: -0.45% 0.01% Inconclusive result (value mean confidence interval includes 0). total spills in shared programs: 17606 -> 17605 (<.01%) spills in affected programs: 323 -> 322 (-0.31%) helped: 1 HURT: 0 total fills in shared programs: 22599 -> 22598 (<.01%) fills in affected programs: 1348 -> 1347 (-0.07%) helped: 1 HURT: 0 Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14940>
2022-02-07 19:10:13 +11:00
/* Number of ifs this block is inside */
unsigned if_depth;
nir: add heuristic for instructions in loops with GCM Moving instructions out of large loops tends to cause excessive spilling. This appears to be a good limit. In future it might make sense to make this a NIR options so other drivers can set their own limits. Tiger Lake total instructions in shared programs: 20930180 -> 20926952 (-0.02%) instructions in affected programs: 280768 -> 277540 (-1.15%) helped: 734 HURT: 192 helped stats (abs) min: 1 max: 61 x̄: 5.16 x̃: 4 helped stats (rel) min: 0.04% max: 10.64% x̄: 3.23% x̃: 3.14% HURT stats (abs) min: 1 max: 52 x̄: 2.90 x̃: 1 HURT stats (rel) min: 0.03% max: 9.76% x̄: 1.13% x̃: 0.61% 95% mean confidence interval for instructions value: -3.89 -3.08 95% mean confidence interval for instructions %-change: -2.49% -2.16% Instructions are helped. total cycles in shared programs: 841825217 -> 838817552 (-0.36%) cycles in affected programs: 122088078 -> 119080413 (-2.46%) helped: 941 HURT: 100 helped stats (abs) min: 1 max: 160080 x̄: 3274.31 x̃: 2660 helped stats (rel) min: <.01% max: 41.64% x̄: 5.50% x̃: 4.80% HURT stats (abs) min: 1 max: 41856 x̄: 734.62 x̃: 26 HURT stats (rel) min: <.01% max: 7.29% x̄: 0.44% x̃: 0.27% 95% mean confidence interval for cycles value: -3236.56 -2541.85 95% mean confidence interval for cycles %-change: -5.26% -4.60% Cycles are helped. total sends in shared programs: 977905 -> 977782 (-0.01%) sends in affected programs: 2279 -> 2156 (-5.40%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.93% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.42% -6.45% Sends are helped. LOST: 2 GAINED: 0 Ice Lake total instructions in shared programs: 19865361 -> 19861747 (-0.02%) instructions in affected programs: 185789 -> 182175 (-1.95%) helped: 593 HURT: 47 helped stats (abs) min: 1 max: 27 x̄: 6.17 x̃: 4 helped stats (rel) min: 0.19% max: 8.65% x̄: 4.53% x̃: 4.60% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.23% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -5.93 -5.37 95% mean confidence interval for instructions %-change: -4.32% -4.06% Instructions are helped. total loops in shared programs: 6120 -> 6117 (-0.05%) loops in affected programs: 6 -> 3 (-50.00%) helped: 3 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% total cycles in shared programs: 961777176 -> 959404350 (-0.25%) cycles in affected programs: 172224180 -> 169851354 (-1.38%) helped: 936 HURT: 80 helped stats (abs) min: 1 max: 9566 x̄: 2621.08 x̃: 2550 helped stats (rel) min: <.01% max: 41.77% x̄: 4.22% x̃: 3.84% HURT stats (abs) min: 1 max: 59146 x̄: 1006.34 x̃: 24 HURT stats (rel) min: <.01% max: 3.78% x̄: 0.44% x̃: 0.25% 95% mean confidence interval for cycles value: -2513.72 -2157.20 95% mean confidence interval for cycles %-change: -4.13% -3.57% Cycles are helped. total sends in shared programs: 1019995 -> 1019872 (-0.01%) sends in affected programs: 2283 -> 2160 (-5.39%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.39% -6.42% Sends are helped. LOST: 4 GAINED: 0 Skylake total instructions in shared programs: 17994337 -> 17993846 (<.01%) instructions in affected programs: 146294 -> 145803 (-0.34%) helped: 190 HURT: 47 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.14% max: 4.29% x̄: 1.08% x̃: 0.90% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.22% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -2.30 -1.84 95% mean confidence interval for instructions %-change: -0.95% -0.74% Instructions are helped. total loops in shared programs: 6029 -> 6023 (-0.10%) loops in affected programs: 12 -> 6 (-50.00%) helped: 6 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 939062940 -> 938023548 (-0.11%) cycles in affected programs: 169671482 -> 168632090 (-0.61%) helped: 980 HURT: 134 helped stats (abs) min: 1 max: 25000 x̄: 1075.57 x̃: 1052 helped stats (rel) min: <.01% max: 42.75% x̄: 2.51% x̃: 1.32% HURT stats (abs) min: 1 max: 837 x̄: 109.45 x̃: 20 HURT stats (rel) min: <.01% max: 5.71% x̄: 0.73% x̃: 0.21% 95% mean confidence interval for cycles value: -1005.89 -860.17 95% mean confidence interval for cycles %-change: -2.39% -1.84% Cycles are helped. total sends in shared programs: 1026848 -> 1026724 (-0.01%) sends in affected programs: 2302 -> 2178 (-5.39%) helped: 120 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.40% -6.43% Sends are helped. LOST: 1 GAINED: 1 Broadwell total instructions in shared programs: 17605621 -> 17605154 (<.01%) instructions in affected programs: 145691 -> 145224 (-0.32%) helped: 184 HURT: 48 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.13% max: 4.29% x̄: 1.09% x̃: 0.93% HURT stats (abs) min: 1 max: 7 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 0.48% x̄: 0.12% x̃: 0.04% 95% mean confidence interval for instructions value: -2.26 -1.77 95% mean confidence interval for instructions %-change: -0.95% -0.73% Instructions are helped. total loops in shared programs: 5968 -> 5963 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 1000679489 -> 998592756 (-0.21%) cycles in affected programs: 173421234 -> 171334501 (-1.20%) helped: 993 HURT: 153 helped stats (abs) min: 1 max: 766608 x̄: 2118.49 x̃: 1080 helped stats (rel) min: <.01% max: 54.61% x̄: 2.61% x̃: 1.73% HURT stats (abs) min: 1 max: 2200 x̄: 110.61 x̃: 11 HURT stats (rel) min: <.01% max: 5.68% x̄: 0.63% x̃: 0.06% 95% mean confidence interval for cycles value: -3191.23 -450.54 95% mean confidence interval for cycles %-change: -2.47% -1.89% Cycles are helped. total sends in shared programs: 996341 -> 996222 (-0.01%) sends in affected programs: 2151 -> 2032 (-5.53%) helped: 115 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 7.07% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.55% -6.58% Sends are helped. Haswell total instructions in shared programs: 16038375 -> 16038121 (<.01%) instructions in affected programs: 216797 -> 216543 (-0.12%) helped: 185 HURT: 217 helped stats (abs) min: 1 max: 12 x̄: 2.84 x̃: 3 helped stats (rel) min: 0.13% max: 4.23% x̄: 1.30% x̃: 1.20% HURT stats (abs) min: 1 max: 6 x̄: 1.25 x̃: 1 HURT stats (rel) min: 0.03% max: 5.66% x̄: 0.61% x̃: 0.40% 95% mean confidence interval for instructions value: -0.85 -0.41 95% mean confidence interval for instructions %-change: -0.40% -0.14% Instructions are helped. total loops in shared programs: 5947 -> 5942 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 967655093 -> 965746713 (-0.20%) cycles in affected programs: 197288924 -> 195380544 (-0.97%) helped: 950 HURT: 195 helped stats (abs) min: 1 max: 782820 x̄: 2274.79 x̃: 1260 helped stats (rel) min: <.01% max: 54.26% x̄: 3.02% x̃: 1.71% HURT stats (abs) min: 1 max: 15790 x̄: 1295.73 x̃: 21 HURT stats (rel) min: <.01% max: 119.85% x̄: 7.76% x̃: 0.11% 95% mean confidence interval for cycles value: -3014.22 -319.19 95% mean confidence interval for cycles %-change: -1.83% -0.55% Cycles are helped. total sends in shared programs: 934894 -> 934765 (-0.01%) sends in affected programs: 2192 -> 2063 (-5.89%) helped: 115 HURT: 2 helped stats (abs) min: 1 max: 4 x̄: 1.14 x̃: 1 helped stats (rel) min: 0.60% max: 28.57% x̄: 7.68% x̃: 6.67% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 16.67% max: 16.67% x̄: 16.67% x̃: 16.67% 95% mean confidence interval for sends value: -1.23 -0.98 95% mean confidence interval for sends %-change: -8.28% -6.24% Sends are helped. LOST: 1 GAINED: 18 Ivy Bridge total instructions in shared programs: 15269357 -> 15269398 (<.01%) instructions in affected programs: 190484 -> 190525 (0.02%) helped: 77 HURT: 206 helped stats (abs) min: 1 max: 6 x̄: 2.47 x̃: 3 helped stats (rel) min: 0.14% max: 5.31% x̄: 1.46% x̃: 1.65% HURT stats (abs) min: 1 max: 3 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 2.38% x̄: 0.42% x̃: 0.40% 95% mean confidence interval for instructions value: -0.06 0.35 95% mean confidence interval for instructions %-change: -0.21% 0.03% Inconclusive result (value mean confidence interval includes 0). total loops in shared programs: 4001 -> 3996 (-0.12%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 562045564 -> 561063543 (-0.17%) cycles in affected programs: 200924872 -> 199942851 (-0.49%) helped: 748 HURT: 160 helped stats (abs) min: 2 max: 14926 x̄: 1692.94 x̃: 1620 helped stats (rel) min: <.01% max: 53.29% x̄: 3.17% x̃: 1.87% HURT stats (abs) min: 2 max: 15726 x̄: 1776.86 x̃: 36 HURT stats (rel) min: <.01% max: 114.43% x̄: 10.66% x̃: 0.21% 95% mean confidence interval for cycles value: -1237.33 -925.71 95% mean confidence interval for cycles %-change: -1.54% 0.08% Inconclusive result (%-change mean confidence interval includes 0). total sends in shared programs: 893348 -> 893330 (<.01%) sends in affected programs: 187 -> 169 (-9.63%) helped: 14 HURT: 0 helped stats (abs) min: 1 max: 2 x̄: 1.29 x̃: 1 helped stats (rel) min: 4.08% max: 22.22% x̄: 11.70% x̃: 10.10% 95% mean confidence interval for sends value: -1.56 -1.02 95% mean confidence interval for sends %-change: -14.92% -8.48% Sends are helped. LOST: 1 GAINED: 19 Sandy Bridge total instructions in shared programs: 11785227 -> 11785774 (<.01%) instructions in affected programs: 78403 -> 78950 (0.70%) helped: 65 HURT: 505 helped stats (abs) min: 1 max: 4 x̄: 2.22 x̃: 3 helped stats (rel) min: 0.14% max: 4.17% x̄: 1.19% x̃: 1.38% HURT stats (abs) min: 1 max: 5 x̄: 1.37 x̃: 1 HURT stats (rel) min: 0.24% max: 3.33% x̄: 1.57% x̃: 1.72% 95% mean confidence interval for instructions value: 0.85 1.07 95% mean confidence interval for instructions %-change: 1.16% 1.36% Instructions are HURT. total loops in shared programs: 2441 -> 2437 (-0.16%) loops in affected programs: 8 -> 4 (-50.00%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 497178796 -> 496669298 (-0.10%) cycles in affected programs: 51483322 -> 50973824 (-0.99%) helped: 476 HURT: 137 helped stats (abs) min: 2 max: 7502 x̄: 1079.36 x̃: 1260 helped stats (rel) min: <.01% max: 42.50% x̄: 2.31% x̃: 0.86% HURT stats (abs) min: 2 max: 754 x̄: 31.23 x̃: 18 HURT stats (rel) min: <.01% max: 3.01% x̄: 0.09% x̃: 0.02% 95% mean confidence interval for cycles value: -901.99 -760.32 95% mean confidence interval for cycles %-change: -2.20% -1.36% Cycles are helped. total sends in shared programs: 642919 -> 642915 (<.01%) sends in affected programs: 32 -> 28 (-12.50%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 11.11% max: 14.29% x̄: 12.70% x̃: 12.70% 95% mean confidence interval for sends value: -1.00 -1.00 95% mean confidence interval for sends %-change: -15.61% -9.78% Sends are helped. Iron Lake total instructions in shared programs: 8180061 -> 8180248 (<.01%) instructions in affected programs: 65004 -> 65191 (0.29%) helped: 59 HURT: 253 helped stats (abs) min: 1 max: 4 x̄: 2.24 x̃: 3 helped stats (rel) min: 0.16% max: 2.23% x̄: 1.04% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.26 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.93% x̃: 0.60% 95% mean confidence interval for instructions value: 0.43 0.77 95% mean confidence interval for instructions %-change: 0.45% 0.68% Instructions are HURT. total loops in shared programs: 863 -> 861 (-0.23%) loops in affected programs: 4 -> 2 (-50.00%) helped: 2 HURT: 0 total cycles in shared programs: 239357490 -> 238907668 (-0.19%) cycles in affected programs: 17314006 -> 16864184 (-2.60%) helped: 176 HURT: 34 helped stats (abs) min: 4 max: 13400 x̄: 2558.05 x̃: 2920 helped stats (rel) min: 0.01% max: 35.58% x̄: 3.76% x̃: 2.69% HURT stats (abs) min: 2 max: 14 x̄: 11.59 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2440.68 -1843.34 95% mean confidence interval for cycles %-change: -3.78% -2.51% Cycles are helped. GM45 total instructions in shared programs: 4985293 -> 4985401 (<.01%) instructions in affected programs: 58807 -> 58915 (0.18%) helped: 57 HURT: 202 helped stats (abs) min: 1 max: 4 x̄: 2.26 x̃: 3 helped stats (rel) min: 0.15% max: 2.23% x̄: 1.06% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.17 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.76% x̃: 0.48% 95% mean confidence interval for instructions value: 0.22 0.61 95% mean confidence interval for instructions %-change: 0.24% 0.48% Instructions are HURT. total loops in shared programs: 639 -> 638 (-0.16%) loops in affected programs: 2 -> 1 (-50.00%) helped: 1 HURT: 0 total cycles in shared programs: 153794236 -> 153546274 (-0.16%) cycles in affected programs: 9947778 -> 9699816 (-2.49%) helped: 110 HURT: 31 helped stats (abs) min: 4 max: 13400 x̄: 2257.51 x̃: 1796 helped stats (rel) min: 0.01% max: 35.58% x̄: 4.33% x̃: 2.45% HURT stats (abs) min: 2 max: 14 x̄: 11.74 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2113.77 -1403.42 95% mean confidence interval for cycles %-change: -4.27% -2.47% Cycles are helped. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2899 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12064>
2021-07-26 23:25:58 +10:00
unsigned loop_instr_count;
/* The loop the block is nested inside or NULL */
nir_loop *loop;
/* The last instruction inserted into this block. This is used as we
* traverse the instructions and insert them back into the program to
* put them in the right order.
*/
nir_instr *last_instr;
};
struct gcm_instr_info {
nir_block *early_block;
};
/* Flags used in the instr->pass_flags field for various instruction states */
enum {
GCM_INSTR_PINNED = (1 << 0),
GCM_INSTR_SCHEDULE_EARLIER_ONLY = (1 << 1),
GCM_INSTR_SCHEDULED_EARLY = (1 << 2),
GCM_INSTR_SCHEDULED_LATE = (1 << 3),
GCM_INSTR_PLACED = (1 << 4),
};
struct gcm_state {
nir_function_impl *impl;
nir_instr *instr;
bool progress;
/* The list of non-pinned instructions. As we do the late scheduling,
* we pull non-pinned instructions out of their blocks and place them in
* this list. This saves us from having linked-list problems when we go
* to put instructions back in their blocks.
*/
struct exec_list instrs;
struct gcm_block_info *blocks;
unsigned num_instrs;
struct gcm_instr_info *instr_infos;
};
nir: add heuristic for instructions in loops with GCM Moving instructions out of large loops tends to cause excessive spilling. This appears to be a good limit. In future it might make sense to make this a NIR options so other drivers can set their own limits. Tiger Lake total instructions in shared programs: 20930180 -> 20926952 (-0.02%) instructions in affected programs: 280768 -> 277540 (-1.15%) helped: 734 HURT: 192 helped stats (abs) min: 1 max: 61 x̄: 5.16 x̃: 4 helped stats (rel) min: 0.04% max: 10.64% x̄: 3.23% x̃: 3.14% HURT stats (abs) min: 1 max: 52 x̄: 2.90 x̃: 1 HURT stats (rel) min: 0.03% max: 9.76% x̄: 1.13% x̃: 0.61% 95% mean confidence interval for instructions value: -3.89 -3.08 95% mean confidence interval for instructions %-change: -2.49% -2.16% Instructions are helped. total cycles in shared programs: 841825217 -> 838817552 (-0.36%) cycles in affected programs: 122088078 -> 119080413 (-2.46%) helped: 941 HURT: 100 helped stats (abs) min: 1 max: 160080 x̄: 3274.31 x̃: 2660 helped stats (rel) min: <.01% max: 41.64% x̄: 5.50% x̃: 4.80% HURT stats (abs) min: 1 max: 41856 x̄: 734.62 x̃: 26 HURT stats (rel) min: <.01% max: 7.29% x̄: 0.44% x̃: 0.27% 95% mean confidence interval for cycles value: -3236.56 -2541.85 95% mean confidence interval for cycles %-change: -5.26% -4.60% Cycles are helped. total sends in shared programs: 977905 -> 977782 (-0.01%) sends in affected programs: 2279 -> 2156 (-5.40%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.93% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.42% -6.45% Sends are helped. LOST: 2 GAINED: 0 Ice Lake total instructions in shared programs: 19865361 -> 19861747 (-0.02%) instructions in affected programs: 185789 -> 182175 (-1.95%) helped: 593 HURT: 47 helped stats (abs) min: 1 max: 27 x̄: 6.17 x̃: 4 helped stats (rel) min: 0.19% max: 8.65% x̄: 4.53% x̃: 4.60% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.23% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -5.93 -5.37 95% mean confidence interval for instructions %-change: -4.32% -4.06% Instructions are helped. total loops in shared programs: 6120 -> 6117 (-0.05%) loops in affected programs: 6 -> 3 (-50.00%) helped: 3 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% total cycles in shared programs: 961777176 -> 959404350 (-0.25%) cycles in affected programs: 172224180 -> 169851354 (-1.38%) helped: 936 HURT: 80 helped stats (abs) min: 1 max: 9566 x̄: 2621.08 x̃: 2550 helped stats (rel) min: <.01% max: 41.77% x̄: 4.22% x̃: 3.84% HURT stats (abs) min: 1 max: 59146 x̄: 1006.34 x̃: 24 HURT stats (rel) min: <.01% max: 3.78% x̄: 0.44% x̃: 0.25% 95% mean confidence interval for cycles value: -2513.72 -2157.20 95% mean confidence interval for cycles %-change: -4.13% -3.57% Cycles are helped. total sends in shared programs: 1019995 -> 1019872 (-0.01%) sends in affected programs: 2283 -> 2160 (-5.39%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.39% -6.42% Sends are helped. LOST: 4 GAINED: 0 Skylake total instructions in shared programs: 17994337 -> 17993846 (<.01%) instructions in affected programs: 146294 -> 145803 (-0.34%) helped: 190 HURT: 47 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.14% max: 4.29% x̄: 1.08% x̃: 0.90% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.22% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -2.30 -1.84 95% mean confidence interval for instructions %-change: -0.95% -0.74% Instructions are helped. total loops in shared programs: 6029 -> 6023 (-0.10%) loops in affected programs: 12 -> 6 (-50.00%) helped: 6 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 939062940 -> 938023548 (-0.11%) cycles in affected programs: 169671482 -> 168632090 (-0.61%) helped: 980 HURT: 134 helped stats (abs) min: 1 max: 25000 x̄: 1075.57 x̃: 1052 helped stats (rel) min: <.01% max: 42.75% x̄: 2.51% x̃: 1.32% HURT stats (abs) min: 1 max: 837 x̄: 109.45 x̃: 20 HURT stats (rel) min: <.01% max: 5.71% x̄: 0.73% x̃: 0.21% 95% mean confidence interval for cycles value: -1005.89 -860.17 95% mean confidence interval for cycles %-change: -2.39% -1.84% Cycles are helped. total sends in shared programs: 1026848 -> 1026724 (-0.01%) sends in affected programs: 2302 -> 2178 (-5.39%) helped: 120 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.40% -6.43% Sends are helped. LOST: 1 GAINED: 1 Broadwell total instructions in shared programs: 17605621 -> 17605154 (<.01%) instructions in affected programs: 145691 -> 145224 (-0.32%) helped: 184 HURT: 48 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.13% max: 4.29% x̄: 1.09% x̃: 0.93% HURT stats (abs) min: 1 max: 7 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 0.48% x̄: 0.12% x̃: 0.04% 95% mean confidence interval for instructions value: -2.26 -1.77 95% mean confidence interval for instructions %-change: -0.95% -0.73% Instructions are helped. total loops in shared programs: 5968 -> 5963 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 1000679489 -> 998592756 (-0.21%) cycles in affected programs: 173421234 -> 171334501 (-1.20%) helped: 993 HURT: 153 helped stats (abs) min: 1 max: 766608 x̄: 2118.49 x̃: 1080 helped stats (rel) min: <.01% max: 54.61% x̄: 2.61% x̃: 1.73% HURT stats (abs) min: 1 max: 2200 x̄: 110.61 x̃: 11 HURT stats (rel) min: <.01% max: 5.68% x̄: 0.63% x̃: 0.06% 95% mean confidence interval for cycles value: -3191.23 -450.54 95% mean confidence interval for cycles %-change: -2.47% -1.89% Cycles are helped. total sends in shared programs: 996341 -> 996222 (-0.01%) sends in affected programs: 2151 -> 2032 (-5.53%) helped: 115 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 7.07% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.55% -6.58% Sends are helped. Haswell total instructions in shared programs: 16038375 -> 16038121 (<.01%) instructions in affected programs: 216797 -> 216543 (-0.12%) helped: 185 HURT: 217 helped stats (abs) min: 1 max: 12 x̄: 2.84 x̃: 3 helped stats (rel) min: 0.13% max: 4.23% x̄: 1.30% x̃: 1.20% HURT stats (abs) min: 1 max: 6 x̄: 1.25 x̃: 1 HURT stats (rel) min: 0.03% max: 5.66% x̄: 0.61% x̃: 0.40% 95% mean confidence interval for instructions value: -0.85 -0.41 95% mean confidence interval for instructions %-change: -0.40% -0.14% Instructions are helped. total loops in shared programs: 5947 -> 5942 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 967655093 -> 965746713 (-0.20%) cycles in affected programs: 197288924 -> 195380544 (-0.97%) helped: 950 HURT: 195 helped stats (abs) min: 1 max: 782820 x̄: 2274.79 x̃: 1260 helped stats (rel) min: <.01% max: 54.26% x̄: 3.02% x̃: 1.71% HURT stats (abs) min: 1 max: 15790 x̄: 1295.73 x̃: 21 HURT stats (rel) min: <.01% max: 119.85% x̄: 7.76% x̃: 0.11% 95% mean confidence interval for cycles value: -3014.22 -319.19 95% mean confidence interval for cycles %-change: -1.83% -0.55% Cycles are helped. total sends in shared programs: 934894 -> 934765 (-0.01%) sends in affected programs: 2192 -> 2063 (-5.89%) helped: 115 HURT: 2 helped stats (abs) min: 1 max: 4 x̄: 1.14 x̃: 1 helped stats (rel) min: 0.60% max: 28.57% x̄: 7.68% x̃: 6.67% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 16.67% max: 16.67% x̄: 16.67% x̃: 16.67% 95% mean confidence interval for sends value: -1.23 -0.98 95% mean confidence interval for sends %-change: -8.28% -6.24% Sends are helped. LOST: 1 GAINED: 18 Ivy Bridge total instructions in shared programs: 15269357 -> 15269398 (<.01%) instructions in affected programs: 190484 -> 190525 (0.02%) helped: 77 HURT: 206 helped stats (abs) min: 1 max: 6 x̄: 2.47 x̃: 3 helped stats (rel) min: 0.14% max: 5.31% x̄: 1.46% x̃: 1.65% HURT stats (abs) min: 1 max: 3 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 2.38% x̄: 0.42% x̃: 0.40% 95% mean confidence interval for instructions value: -0.06 0.35 95% mean confidence interval for instructions %-change: -0.21% 0.03% Inconclusive result (value mean confidence interval includes 0). total loops in shared programs: 4001 -> 3996 (-0.12%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 562045564 -> 561063543 (-0.17%) cycles in affected programs: 200924872 -> 199942851 (-0.49%) helped: 748 HURT: 160 helped stats (abs) min: 2 max: 14926 x̄: 1692.94 x̃: 1620 helped stats (rel) min: <.01% max: 53.29% x̄: 3.17% x̃: 1.87% HURT stats (abs) min: 2 max: 15726 x̄: 1776.86 x̃: 36 HURT stats (rel) min: <.01% max: 114.43% x̄: 10.66% x̃: 0.21% 95% mean confidence interval for cycles value: -1237.33 -925.71 95% mean confidence interval for cycles %-change: -1.54% 0.08% Inconclusive result (%-change mean confidence interval includes 0). total sends in shared programs: 893348 -> 893330 (<.01%) sends in affected programs: 187 -> 169 (-9.63%) helped: 14 HURT: 0 helped stats (abs) min: 1 max: 2 x̄: 1.29 x̃: 1 helped stats (rel) min: 4.08% max: 22.22% x̄: 11.70% x̃: 10.10% 95% mean confidence interval for sends value: -1.56 -1.02 95% mean confidence interval for sends %-change: -14.92% -8.48% Sends are helped. LOST: 1 GAINED: 19 Sandy Bridge total instructions in shared programs: 11785227 -> 11785774 (<.01%) instructions in affected programs: 78403 -> 78950 (0.70%) helped: 65 HURT: 505 helped stats (abs) min: 1 max: 4 x̄: 2.22 x̃: 3 helped stats (rel) min: 0.14% max: 4.17% x̄: 1.19% x̃: 1.38% HURT stats (abs) min: 1 max: 5 x̄: 1.37 x̃: 1 HURT stats (rel) min: 0.24% max: 3.33% x̄: 1.57% x̃: 1.72% 95% mean confidence interval for instructions value: 0.85 1.07 95% mean confidence interval for instructions %-change: 1.16% 1.36% Instructions are HURT. total loops in shared programs: 2441 -> 2437 (-0.16%) loops in affected programs: 8 -> 4 (-50.00%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 497178796 -> 496669298 (-0.10%) cycles in affected programs: 51483322 -> 50973824 (-0.99%) helped: 476 HURT: 137 helped stats (abs) min: 2 max: 7502 x̄: 1079.36 x̃: 1260 helped stats (rel) min: <.01% max: 42.50% x̄: 2.31% x̃: 0.86% HURT stats (abs) min: 2 max: 754 x̄: 31.23 x̃: 18 HURT stats (rel) min: <.01% max: 3.01% x̄: 0.09% x̃: 0.02% 95% mean confidence interval for cycles value: -901.99 -760.32 95% mean confidence interval for cycles %-change: -2.20% -1.36% Cycles are helped. total sends in shared programs: 642919 -> 642915 (<.01%) sends in affected programs: 32 -> 28 (-12.50%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 11.11% max: 14.29% x̄: 12.70% x̃: 12.70% 95% mean confidence interval for sends value: -1.00 -1.00 95% mean confidence interval for sends %-change: -15.61% -9.78% Sends are helped. Iron Lake total instructions in shared programs: 8180061 -> 8180248 (<.01%) instructions in affected programs: 65004 -> 65191 (0.29%) helped: 59 HURT: 253 helped stats (abs) min: 1 max: 4 x̄: 2.24 x̃: 3 helped stats (rel) min: 0.16% max: 2.23% x̄: 1.04% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.26 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.93% x̃: 0.60% 95% mean confidence interval for instructions value: 0.43 0.77 95% mean confidence interval for instructions %-change: 0.45% 0.68% Instructions are HURT. total loops in shared programs: 863 -> 861 (-0.23%) loops in affected programs: 4 -> 2 (-50.00%) helped: 2 HURT: 0 total cycles in shared programs: 239357490 -> 238907668 (-0.19%) cycles in affected programs: 17314006 -> 16864184 (-2.60%) helped: 176 HURT: 34 helped stats (abs) min: 4 max: 13400 x̄: 2558.05 x̃: 2920 helped stats (rel) min: 0.01% max: 35.58% x̄: 3.76% x̃: 2.69% HURT stats (abs) min: 2 max: 14 x̄: 11.59 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2440.68 -1843.34 95% mean confidence interval for cycles %-change: -3.78% -2.51% Cycles are helped. GM45 total instructions in shared programs: 4985293 -> 4985401 (<.01%) instructions in affected programs: 58807 -> 58915 (0.18%) helped: 57 HURT: 202 helped stats (abs) min: 1 max: 4 x̄: 2.26 x̃: 3 helped stats (rel) min: 0.15% max: 2.23% x̄: 1.06% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.17 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.76% x̃: 0.48% 95% mean confidence interval for instructions value: 0.22 0.61 95% mean confidence interval for instructions %-change: 0.24% 0.48% Instructions are HURT. total loops in shared programs: 639 -> 638 (-0.16%) loops in affected programs: 2 -> 1 (-50.00%) helped: 1 HURT: 0 total cycles in shared programs: 153794236 -> 153546274 (-0.16%) cycles in affected programs: 9947778 -> 9699816 (-2.49%) helped: 110 HURT: 31 helped stats (abs) min: 4 max: 13400 x̄: 2257.51 x̃: 1796 helped stats (rel) min: 0.01% max: 35.58% x̄: 4.33% x̃: 2.45% HURT stats (abs) min: 2 max: 14 x̄: 11.74 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2113.77 -1403.42 95% mean confidence interval for cycles %-change: -4.27% -2.47% Cycles are helped. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2899 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12064>
2021-07-26 23:25:58 +10:00
static unsigned
get_loop_instr_count(struct exec_list *cf_list)
{
unsigned loop_instr_count = 0;
foreach_list_typed(nir_cf_node, node, node, cf_list) {
switch (node->type) {
case nir_cf_node_block: {
nir_block *block = nir_cf_node_as_block(node);
nir_foreach_instr(instr, block) {
loop_instr_count++;
}
break;
}
case nir_cf_node_if: {
nir_if *if_stmt = nir_cf_node_as_if(node);
loop_instr_count += get_loop_instr_count(&if_stmt->then_list);
loop_instr_count += get_loop_instr_count(&if_stmt->else_list);
break;
}
case nir_cf_node_loop: {
nir_loop *loop = nir_cf_node_as_loop(node);
loop_instr_count += get_loop_instr_count(&loop->body);
break;
}
default:
unreachable("Invalid CF node type");
}
}
return loop_instr_count;
}
/* Recursively walks the CFG and builds the block_info structure */
static void
gcm_build_block_info(struct exec_list *cf_list, struct gcm_state *state,
nir/gcm: fix pushing instructions into if blocks The previous logic would just set the block to the instructions original location if we couldn't evict it from a loop. For now we only push const loads to a later block inside ifs but we can add more heuristics later. This change helps a hand full of shaders but also stops a CTS regression caused by excess spilling after a series I'm working on to disable more of the GLSL IR optimisation passes. Shader-db results iris (BDW): total instructions in shared programs: 17529759 -> 17529749 (<.01%) instructions in affected programs: 15929 -> 15919 (-0.06%) helped: 5 HURT: 2 helped stats (abs) min: 1 max: 5 x̄: 2.40 x̃: 2 helped stats (rel) min: 0.06% max: 0.15% x̄: 0.11% x̃: 0.12% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.06% max: 0.06% x̄: 0.06% x̃: 0.06% 95% mean confidence interval for instructions value: -3.34 0.49 95% mean confidence interval for instructions %-change: -0.14% 0.02% Inconclusive result (value mean confidence interval includes 0). total cycles in shared programs: 861109994 -> 861099681 (<.01%) cycles in affected programs: 7027698 -> 7017385 (-0.15%) helped: 95 HURT: 72 helped stats (abs) min: 1 max: 7995 x̄: 138.54 x̃: 9 helped stats (rel) min: <.01% max: 15.96% x̄: 0.54% x̃: 0.11% HURT stats (abs) min: 1 max: 474 x̄: 39.56 x̃: 12 HURT stats (rel) min: <.01% max: 1.17% x̄: 0.20% x̃: 0.11% 95% mean confidence interval for cycles value: -159.05 35.54 95% mean confidence interval for cycles %-change: -0.45% 0.01% Inconclusive result (value mean confidence interval includes 0). total spills in shared programs: 17606 -> 17605 (<.01%) spills in affected programs: 323 -> 322 (-0.31%) helped: 1 HURT: 0 total fills in shared programs: 22599 -> 22598 (<.01%) fills in affected programs: 1348 -> 1347 (-0.07%) helped: 1 HURT: 0 Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14940>
2022-02-07 19:10:13 +11:00
nir_loop *loop, unsigned loop_depth, unsigned if_depth,
nir: add heuristic for instructions in loops with GCM Moving instructions out of large loops tends to cause excessive spilling. This appears to be a good limit. In future it might make sense to make this a NIR options so other drivers can set their own limits. Tiger Lake total instructions in shared programs: 20930180 -> 20926952 (-0.02%) instructions in affected programs: 280768 -> 277540 (-1.15%) helped: 734 HURT: 192 helped stats (abs) min: 1 max: 61 x̄: 5.16 x̃: 4 helped stats (rel) min: 0.04% max: 10.64% x̄: 3.23% x̃: 3.14% HURT stats (abs) min: 1 max: 52 x̄: 2.90 x̃: 1 HURT stats (rel) min: 0.03% max: 9.76% x̄: 1.13% x̃: 0.61% 95% mean confidence interval for instructions value: -3.89 -3.08 95% mean confidence interval for instructions %-change: -2.49% -2.16% Instructions are helped. total cycles in shared programs: 841825217 -> 838817552 (-0.36%) cycles in affected programs: 122088078 -> 119080413 (-2.46%) helped: 941 HURT: 100 helped stats (abs) min: 1 max: 160080 x̄: 3274.31 x̃: 2660 helped stats (rel) min: <.01% max: 41.64% x̄: 5.50% x̃: 4.80% HURT stats (abs) min: 1 max: 41856 x̄: 734.62 x̃: 26 HURT stats (rel) min: <.01% max: 7.29% x̄: 0.44% x̃: 0.27% 95% mean confidence interval for cycles value: -3236.56 -2541.85 95% mean confidence interval for cycles %-change: -5.26% -4.60% Cycles are helped. total sends in shared programs: 977905 -> 977782 (-0.01%) sends in affected programs: 2279 -> 2156 (-5.40%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.93% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.42% -6.45% Sends are helped. LOST: 2 GAINED: 0 Ice Lake total instructions in shared programs: 19865361 -> 19861747 (-0.02%) instructions in affected programs: 185789 -> 182175 (-1.95%) helped: 593 HURT: 47 helped stats (abs) min: 1 max: 27 x̄: 6.17 x̃: 4 helped stats (rel) min: 0.19% max: 8.65% x̄: 4.53% x̃: 4.60% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.23% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -5.93 -5.37 95% mean confidence interval for instructions %-change: -4.32% -4.06% Instructions are helped. total loops in shared programs: 6120 -> 6117 (-0.05%) loops in affected programs: 6 -> 3 (-50.00%) helped: 3 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% total cycles in shared programs: 961777176 -> 959404350 (-0.25%) cycles in affected programs: 172224180 -> 169851354 (-1.38%) helped: 936 HURT: 80 helped stats (abs) min: 1 max: 9566 x̄: 2621.08 x̃: 2550 helped stats (rel) min: <.01% max: 41.77% x̄: 4.22% x̃: 3.84% HURT stats (abs) min: 1 max: 59146 x̄: 1006.34 x̃: 24 HURT stats (rel) min: <.01% max: 3.78% x̄: 0.44% x̃: 0.25% 95% mean confidence interval for cycles value: -2513.72 -2157.20 95% mean confidence interval for cycles %-change: -4.13% -3.57% Cycles are helped. total sends in shared programs: 1019995 -> 1019872 (-0.01%) sends in affected programs: 2283 -> 2160 (-5.39%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.39% -6.42% Sends are helped. LOST: 4 GAINED: 0 Skylake total instructions in shared programs: 17994337 -> 17993846 (<.01%) instructions in affected programs: 146294 -> 145803 (-0.34%) helped: 190 HURT: 47 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.14% max: 4.29% x̄: 1.08% x̃: 0.90% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.22% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -2.30 -1.84 95% mean confidence interval for instructions %-change: -0.95% -0.74% Instructions are helped. total loops in shared programs: 6029 -> 6023 (-0.10%) loops in affected programs: 12 -> 6 (-50.00%) helped: 6 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 939062940 -> 938023548 (-0.11%) cycles in affected programs: 169671482 -> 168632090 (-0.61%) helped: 980 HURT: 134 helped stats (abs) min: 1 max: 25000 x̄: 1075.57 x̃: 1052 helped stats (rel) min: <.01% max: 42.75% x̄: 2.51% x̃: 1.32% HURT stats (abs) min: 1 max: 837 x̄: 109.45 x̃: 20 HURT stats (rel) min: <.01% max: 5.71% x̄: 0.73% x̃: 0.21% 95% mean confidence interval for cycles value: -1005.89 -860.17 95% mean confidence interval for cycles %-change: -2.39% -1.84% Cycles are helped. total sends in shared programs: 1026848 -> 1026724 (-0.01%) sends in affected programs: 2302 -> 2178 (-5.39%) helped: 120 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.40% -6.43% Sends are helped. LOST: 1 GAINED: 1 Broadwell total instructions in shared programs: 17605621 -> 17605154 (<.01%) instructions in affected programs: 145691 -> 145224 (-0.32%) helped: 184 HURT: 48 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.13% max: 4.29% x̄: 1.09% x̃: 0.93% HURT stats (abs) min: 1 max: 7 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 0.48% x̄: 0.12% x̃: 0.04% 95% mean confidence interval for instructions value: -2.26 -1.77 95% mean confidence interval for instructions %-change: -0.95% -0.73% Instructions are helped. total loops in shared programs: 5968 -> 5963 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 1000679489 -> 998592756 (-0.21%) cycles in affected programs: 173421234 -> 171334501 (-1.20%) helped: 993 HURT: 153 helped stats (abs) min: 1 max: 766608 x̄: 2118.49 x̃: 1080 helped stats (rel) min: <.01% max: 54.61% x̄: 2.61% x̃: 1.73% HURT stats (abs) min: 1 max: 2200 x̄: 110.61 x̃: 11 HURT stats (rel) min: <.01% max: 5.68% x̄: 0.63% x̃: 0.06% 95% mean confidence interval for cycles value: -3191.23 -450.54 95% mean confidence interval for cycles %-change: -2.47% -1.89% Cycles are helped. total sends in shared programs: 996341 -> 996222 (-0.01%) sends in affected programs: 2151 -> 2032 (-5.53%) helped: 115 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 7.07% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.55% -6.58% Sends are helped. Haswell total instructions in shared programs: 16038375 -> 16038121 (<.01%) instructions in affected programs: 216797 -> 216543 (-0.12%) helped: 185 HURT: 217 helped stats (abs) min: 1 max: 12 x̄: 2.84 x̃: 3 helped stats (rel) min: 0.13% max: 4.23% x̄: 1.30% x̃: 1.20% HURT stats (abs) min: 1 max: 6 x̄: 1.25 x̃: 1 HURT stats (rel) min: 0.03% max: 5.66% x̄: 0.61% x̃: 0.40% 95% mean confidence interval for instructions value: -0.85 -0.41 95% mean confidence interval for instructions %-change: -0.40% -0.14% Instructions are helped. total loops in shared programs: 5947 -> 5942 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 967655093 -> 965746713 (-0.20%) cycles in affected programs: 197288924 -> 195380544 (-0.97%) helped: 950 HURT: 195 helped stats (abs) min: 1 max: 782820 x̄: 2274.79 x̃: 1260 helped stats (rel) min: <.01% max: 54.26% x̄: 3.02% x̃: 1.71% HURT stats (abs) min: 1 max: 15790 x̄: 1295.73 x̃: 21 HURT stats (rel) min: <.01% max: 119.85% x̄: 7.76% x̃: 0.11% 95% mean confidence interval for cycles value: -3014.22 -319.19 95% mean confidence interval for cycles %-change: -1.83% -0.55% Cycles are helped. total sends in shared programs: 934894 -> 934765 (-0.01%) sends in affected programs: 2192 -> 2063 (-5.89%) helped: 115 HURT: 2 helped stats (abs) min: 1 max: 4 x̄: 1.14 x̃: 1 helped stats (rel) min: 0.60% max: 28.57% x̄: 7.68% x̃: 6.67% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 16.67% max: 16.67% x̄: 16.67% x̃: 16.67% 95% mean confidence interval for sends value: -1.23 -0.98 95% mean confidence interval for sends %-change: -8.28% -6.24% Sends are helped. LOST: 1 GAINED: 18 Ivy Bridge total instructions in shared programs: 15269357 -> 15269398 (<.01%) instructions in affected programs: 190484 -> 190525 (0.02%) helped: 77 HURT: 206 helped stats (abs) min: 1 max: 6 x̄: 2.47 x̃: 3 helped stats (rel) min: 0.14% max: 5.31% x̄: 1.46% x̃: 1.65% HURT stats (abs) min: 1 max: 3 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 2.38% x̄: 0.42% x̃: 0.40% 95% mean confidence interval for instructions value: -0.06 0.35 95% mean confidence interval for instructions %-change: -0.21% 0.03% Inconclusive result (value mean confidence interval includes 0). total loops in shared programs: 4001 -> 3996 (-0.12%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 562045564 -> 561063543 (-0.17%) cycles in affected programs: 200924872 -> 199942851 (-0.49%) helped: 748 HURT: 160 helped stats (abs) min: 2 max: 14926 x̄: 1692.94 x̃: 1620 helped stats (rel) min: <.01% max: 53.29% x̄: 3.17% x̃: 1.87% HURT stats (abs) min: 2 max: 15726 x̄: 1776.86 x̃: 36 HURT stats (rel) min: <.01% max: 114.43% x̄: 10.66% x̃: 0.21% 95% mean confidence interval for cycles value: -1237.33 -925.71 95% mean confidence interval for cycles %-change: -1.54% 0.08% Inconclusive result (%-change mean confidence interval includes 0). total sends in shared programs: 893348 -> 893330 (<.01%) sends in affected programs: 187 -> 169 (-9.63%) helped: 14 HURT: 0 helped stats (abs) min: 1 max: 2 x̄: 1.29 x̃: 1 helped stats (rel) min: 4.08% max: 22.22% x̄: 11.70% x̃: 10.10% 95% mean confidence interval for sends value: -1.56 -1.02 95% mean confidence interval for sends %-change: -14.92% -8.48% Sends are helped. LOST: 1 GAINED: 19 Sandy Bridge total instructions in shared programs: 11785227 -> 11785774 (<.01%) instructions in affected programs: 78403 -> 78950 (0.70%) helped: 65 HURT: 505 helped stats (abs) min: 1 max: 4 x̄: 2.22 x̃: 3 helped stats (rel) min: 0.14% max: 4.17% x̄: 1.19% x̃: 1.38% HURT stats (abs) min: 1 max: 5 x̄: 1.37 x̃: 1 HURT stats (rel) min: 0.24% max: 3.33% x̄: 1.57% x̃: 1.72% 95% mean confidence interval for instructions value: 0.85 1.07 95% mean confidence interval for instructions %-change: 1.16% 1.36% Instructions are HURT. total loops in shared programs: 2441 -> 2437 (-0.16%) loops in affected programs: 8 -> 4 (-50.00%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 497178796 -> 496669298 (-0.10%) cycles in affected programs: 51483322 -> 50973824 (-0.99%) helped: 476 HURT: 137 helped stats (abs) min: 2 max: 7502 x̄: 1079.36 x̃: 1260 helped stats (rel) min: <.01% max: 42.50% x̄: 2.31% x̃: 0.86% HURT stats (abs) min: 2 max: 754 x̄: 31.23 x̃: 18 HURT stats (rel) min: <.01% max: 3.01% x̄: 0.09% x̃: 0.02% 95% mean confidence interval for cycles value: -901.99 -760.32 95% mean confidence interval for cycles %-change: -2.20% -1.36% Cycles are helped. total sends in shared programs: 642919 -> 642915 (<.01%) sends in affected programs: 32 -> 28 (-12.50%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 11.11% max: 14.29% x̄: 12.70% x̃: 12.70% 95% mean confidence interval for sends value: -1.00 -1.00 95% mean confidence interval for sends %-change: -15.61% -9.78% Sends are helped. Iron Lake total instructions in shared programs: 8180061 -> 8180248 (<.01%) instructions in affected programs: 65004 -> 65191 (0.29%) helped: 59 HURT: 253 helped stats (abs) min: 1 max: 4 x̄: 2.24 x̃: 3 helped stats (rel) min: 0.16% max: 2.23% x̄: 1.04% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.26 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.93% x̃: 0.60% 95% mean confidence interval for instructions value: 0.43 0.77 95% mean confidence interval for instructions %-change: 0.45% 0.68% Instructions are HURT. total loops in shared programs: 863 -> 861 (-0.23%) loops in affected programs: 4 -> 2 (-50.00%) helped: 2 HURT: 0 total cycles in shared programs: 239357490 -> 238907668 (-0.19%) cycles in affected programs: 17314006 -> 16864184 (-2.60%) helped: 176 HURT: 34 helped stats (abs) min: 4 max: 13400 x̄: 2558.05 x̃: 2920 helped stats (rel) min: 0.01% max: 35.58% x̄: 3.76% x̃: 2.69% HURT stats (abs) min: 2 max: 14 x̄: 11.59 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2440.68 -1843.34 95% mean confidence interval for cycles %-change: -3.78% -2.51% Cycles are helped. GM45 total instructions in shared programs: 4985293 -> 4985401 (<.01%) instructions in affected programs: 58807 -> 58915 (0.18%) helped: 57 HURT: 202 helped stats (abs) min: 1 max: 4 x̄: 2.26 x̃: 3 helped stats (rel) min: 0.15% max: 2.23% x̄: 1.06% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.17 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.76% x̃: 0.48% 95% mean confidence interval for instructions value: 0.22 0.61 95% mean confidence interval for instructions %-change: 0.24% 0.48% Instructions are HURT. total loops in shared programs: 639 -> 638 (-0.16%) loops in affected programs: 2 -> 1 (-50.00%) helped: 1 HURT: 0 total cycles in shared programs: 153794236 -> 153546274 (-0.16%) cycles in affected programs: 9947778 -> 9699816 (-2.49%) helped: 110 HURT: 31 helped stats (abs) min: 4 max: 13400 x̄: 2257.51 x̃: 1796 helped stats (rel) min: 0.01% max: 35.58% x̄: 4.33% x̃: 2.45% HURT stats (abs) min: 2 max: 14 x̄: 11.74 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2113.77 -1403.42 95% mean confidence interval for cycles %-change: -4.27% -2.47% Cycles are helped. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2899 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12064>
2021-07-26 23:25:58 +10:00
unsigned loop_instr_count)
{
foreach_list_typed(nir_cf_node, node, node, cf_list) {
switch (node->type) {
case nir_cf_node_block: {
nir_block *block = nir_cf_node_as_block(node);
nir/gcm: fix pushing instructions into if blocks The previous logic would just set the block to the instructions original location if we couldn't evict it from a loop. For now we only push const loads to a later block inside ifs but we can add more heuristics later. This change helps a hand full of shaders but also stops a CTS regression caused by excess spilling after a series I'm working on to disable more of the GLSL IR optimisation passes. Shader-db results iris (BDW): total instructions in shared programs: 17529759 -> 17529749 (<.01%) instructions in affected programs: 15929 -> 15919 (-0.06%) helped: 5 HURT: 2 helped stats (abs) min: 1 max: 5 x̄: 2.40 x̃: 2 helped stats (rel) min: 0.06% max: 0.15% x̄: 0.11% x̃: 0.12% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.06% max: 0.06% x̄: 0.06% x̃: 0.06% 95% mean confidence interval for instructions value: -3.34 0.49 95% mean confidence interval for instructions %-change: -0.14% 0.02% Inconclusive result (value mean confidence interval includes 0). total cycles in shared programs: 861109994 -> 861099681 (<.01%) cycles in affected programs: 7027698 -> 7017385 (-0.15%) helped: 95 HURT: 72 helped stats (abs) min: 1 max: 7995 x̄: 138.54 x̃: 9 helped stats (rel) min: <.01% max: 15.96% x̄: 0.54% x̃: 0.11% HURT stats (abs) min: 1 max: 474 x̄: 39.56 x̃: 12 HURT stats (rel) min: <.01% max: 1.17% x̄: 0.20% x̃: 0.11% 95% mean confidence interval for cycles value: -159.05 35.54 95% mean confidence interval for cycles %-change: -0.45% 0.01% Inconclusive result (value mean confidence interval includes 0). total spills in shared programs: 17606 -> 17605 (<.01%) spills in affected programs: 323 -> 322 (-0.31%) helped: 1 HURT: 0 total fills in shared programs: 22599 -> 22598 (<.01%) fills in affected programs: 1348 -> 1347 (-0.07%) helped: 1 HURT: 0 Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14940>
2022-02-07 19:10:13 +11:00
state->blocks[block->index].if_depth = if_depth;
state->blocks[block->index].loop_depth = loop_depth;
nir: add heuristic for instructions in loops with GCM Moving instructions out of large loops tends to cause excessive spilling. This appears to be a good limit. In future it might make sense to make this a NIR options so other drivers can set their own limits. Tiger Lake total instructions in shared programs: 20930180 -> 20926952 (-0.02%) instructions in affected programs: 280768 -> 277540 (-1.15%) helped: 734 HURT: 192 helped stats (abs) min: 1 max: 61 x̄: 5.16 x̃: 4 helped stats (rel) min: 0.04% max: 10.64% x̄: 3.23% x̃: 3.14% HURT stats (abs) min: 1 max: 52 x̄: 2.90 x̃: 1 HURT stats (rel) min: 0.03% max: 9.76% x̄: 1.13% x̃: 0.61% 95% mean confidence interval for instructions value: -3.89 -3.08 95% mean confidence interval for instructions %-change: -2.49% -2.16% Instructions are helped. total cycles in shared programs: 841825217 -> 838817552 (-0.36%) cycles in affected programs: 122088078 -> 119080413 (-2.46%) helped: 941 HURT: 100 helped stats (abs) min: 1 max: 160080 x̄: 3274.31 x̃: 2660 helped stats (rel) min: <.01% max: 41.64% x̄: 5.50% x̃: 4.80% HURT stats (abs) min: 1 max: 41856 x̄: 734.62 x̃: 26 HURT stats (rel) min: <.01% max: 7.29% x̄: 0.44% x̃: 0.27% 95% mean confidence interval for cycles value: -3236.56 -2541.85 95% mean confidence interval for cycles %-change: -5.26% -4.60% Cycles are helped. total sends in shared programs: 977905 -> 977782 (-0.01%) sends in affected programs: 2279 -> 2156 (-5.40%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.93% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.42% -6.45% Sends are helped. LOST: 2 GAINED: 0 Ice Lake total instructions in shared programs: 19865361 -> 19861747 (-0.02%) instructions in affected programs: 185789 -> 182175 (-1.95%) helped: 593 HURT: 47 helped stats (abs) min: 1 max: 27 x̄: 6.17 x̃: 4 helped stats (rel) min: 0.19% max: 8.65% x̄: 4.53% x̃: 4.60% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.23% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -5.93 -5.37 95% mean confidence interval for instructions %-change: -4.32% -4.06% Instructions are helped. total loops in shared programs: 6120 -> 6117 (-0.05%) loops in affected programs: 6 -> 3 (-50.00%) helped: 3 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% total cycles in shared programs: 961777176 -> 959404350 (-0.25%) cycles in affected programs: 172224180 -> 169851354 (-1.38%) helped: 936 HURT: 80 helped stats (abs) min: 1 max: 9566 x̄: 2621.08 x̃: 2550 helped stats (rel) min: <.01% max: 41.77% x̄: 4.22% x̃: 3.84% HURT stats (abs) min: 1 max: 59146 x̄: 1006.34 x̃: 24 HURT stats (rel) min: <.01% max: 3.78% x̄: 0.44% x̃: 0.25% 95% mean confidence interval for cycles value: -2513.72 -2157.20 95% mean confidence interval for cycles %-change: -4.13% -3.57% Cycles are helped. total sends in shared programs: 1019995 -> 1019872 (-0.01%) sends in affected programs: 2283 -> 2160 (-5.39%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.39% -6.42% Sends are helped. LOST: 4 GAINED: 0 Skylake total instructions in shared programs: 17994337 -> 17993846 (<.01%) instructions in affected programs: 146294 -> 145803 (-0.34%) helped: 190 HURT: 47 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.14% max: 4.29% x̄: 1.08% x̃: 0.90% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.22% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -2.30 -1.84 95% mean confidence interval for instructions %-change: -0.95% -0.74% Instructions are helped. total loops in shared programs: 6029 -> 6023 (-0.10%) loops in affected programs: 12 -> 6 (-50.00%) helped: 6 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 939062940 -> 938023548 (-0.11%) cycles in affected programs: 169671482 -> 168632090 (-0.61%) helped: 980 HURT: 134 helped stats (abs) min: 1 max: 25000 x̄: 1075.57 x̃: 1052 helped stats (rel) min: <.01% max: 42.75% x̄: 2.51% x̃: 1.32% HURT stats (abs) min: 1 max: 837 x̄: 109.45 x̃: 20 HURT stats (rel) min: <.01% max: 5.71% x̄: 0.73% x̃: 0.21% 95% mean confidence interval for cycles value: -1005.89 -860.17 95% mean confidence interval for cycles %-change: -2.39% -1.84% Cycles are helped. total sends in shared programs: 1026848 -> 1026724 (-0.01%) sends in affected programs: 2302 -> 2178 (-5.39%) helped: 120 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.40% -6.43% Sends are helped. LOST: 1 GAINED: 1 Broadwell total instructions in shared programs: 17605621 -> 17605154 (<.01%) instructions in affected programs: 145691 -> 145224 (-0.32%) helped: 184 HURT: 48 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.13% max: 4.29% x̄: 1.09% x̃: 0.93% HURT stats (abs) min: 1 max: 7 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 0.48% x̄: 0.12% x̃: 0.04% 95% mean confidence interval for instructions value: -2.26 -1.77 95% mean confidence interval for instructions %-change: -0.95% -0.73% Instructions are helped. total loops in shared programs: 5968 -> 5963 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 1000679489 -> 998592756 (-0.21%) cycles in affected programs: 173421234 -> 171334501 (-1.20%) helped: 993 HURT: 153 helped stats (abs) min: 1 max: 766608 x̄: 2118.49 x̃: 1080 helped stats (rel) min: <.01% max: 54.61% x̄: 2.61% x̃: 1.73% HURT stats (abs) min: 1 max: 2200 x̄: 110.61 x̃: 11 HURT stats (rel) min: <.01% max: 5.68% x̄: 0.63% x̃: 0.06% 95% mean confidence interval for cycles value: -3191.23 -450.54 95% mean confidence interval for cycles %-change: -2.47% -1.89% Cycles are helped. total sends in shared programs: 996341 -> 996222 (-0.01%) sends in affected programs: 2151 -> 2032 (-5.53%) helped: 115 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 7.07% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.55% -6.58% Sends are helped. Haswell total instructions in shared programs: 16038375 -> 16038121 (<.01%) instructions in affected programs: 216797 -> 216543 (-0.12%) helped: 185 HURT: 217 helped stats (abs) min: 1 max: 12 x̄: 2.84 x̃: 3 helped stats (rel) min: 0.13% max: 4.23% x̄: 1.30% x̃: 1.20% HURT stats (abs) min: 1 max: 6 x̄: 1.25 x̃: 1 HURT stats (rel) min: 0.03% max: 5.66% x̄: 0.61% x̃: 0.40% 95% mean confidence interval for instructions value: -0.85 -0.41 95% mean confidence interval for instructions %-change: -0.40% -0.14% Instructions are helped. total loops in shared programs: 5947 -> 5942 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 967655093 -> 965746713 (-0.20%) cycles in affected programs: 197288924 -> 195380544 (-0.97%) helped: 950 HURT: 195 helped stats (abs) min: 1 max: 782820 x̄: 2274.79 x̃: 1260 helped stats (rel) min: <.01% max: 54.26% x̄: 3.02% x̃: 1.71% HURT stats (abs) min: 1 max: 15790 x̄: 1295.73 x̃: 21 HURT stats (rel) min: <.01% max: 119.85% x̄: 7.76% x̃: 0.11% 95% mean confidence interval for cycles value: -3014.22 -319.19 95% mean confidence interval for cycles %-change: -1.83% -0.55% Cycles are helped. total sends in shared programs: 934894 -> 934765 (-0.01%) sends in affected programs: 2192 -> 2063 (-5.89%) helped: 115 HURT: 2 helped stats (abs) min: 1 max: 4 x̄: 1.14 x̃: 1 helped stats (rel) min: 0.60% max: 28.57% x̄: 7.68% x̃: 6.67% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 16.67% max: 16.67% x̄: 16.67% x̃: 16.67% 95% mean confidence interval for sends value: -1.23 -0.98 95% mean confidence interval for sends %-change: -8.28% -6.24% Sends are helped. LOST: 1 GAINED: 18 Ivy Bridge total instructions in shared programs: 15269357 -> 15269398 (<.01%) instructions in affected programs: 190484 -> 190525 (0.02%) helped: 77 HURT: 206 helped stats (abs) min: 1 max: 6 x̄: 2.47 x̃: 3 helped stats (rel) min: 0.14% max: 5.31% x̄: 1.46% x̃: 1.65% HURT stats (abs) min: 1 max: 3 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 2.38% x̄: 0.42% x̃: 0.40% 95% mean confidence interval for instructions value: -0.06 0.35 95% mean confidence interval for instructions %-change: -0.21% 0.03% Inconclusive result (value mean confidence interval includes 0). total loops in shared programs: 4001 -> 3996 (-0.12%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 562045564 -> 561063543 (-0.17%) cycles in affected programs: 200924872 -> 199942851 (-0.49%) helped: 748 HURT: 160 helped stats (abs) min: 2 max: 14926 x̄: 1692.94 x̃: 1620 helped stats (rel) min: <.01% max: 53.29% x̄: 3.17% x̃: 1.87% HURT stats (abs) min: 2 max: 15726 x̄: 1776.86 x̃: 36 HURT stats (rel) min: <.01% max: 114.43% x̄: 10.66% x̃: 0.21% 95% mean confidence interval for cycles value: -1237.33 -925.71 95% mean confidence interval for cycles %-change: -1.54% 0.08% Inconclusive result (%-change mean confidence interval includes 0). total sends in shared programs: 893348 -> 893330 (<.01%) sends in affected programs: 187 -> 169 (-9.63%) helped: 14 HURT: 0 helped stats (abs) min: 1 max: 2 x̄: 1.29 x̃: 1 helped stats (rel) min: 4.08% max: 22.22% x̄: 11.70% x̃: 10.10% 95% mean confidence interval for sends value: -1.56 -1.02 95% mean confidence interval for sends %-change: -14.92% -8.48% Sends are helped. LOST: 1 GAINED: 19 Sandy Bridge total instructions in shared programs: 11785227 -> 11785774 (<.01%) instructions in affected programs: 78403 -> 78950 (0.70%) helped: 65 HURT: 505 helped stats (abs) min: 1 max: 4 x̄: 2.22 x̃: 3 helped stats (rel) min: 0.14% max: 4.17% x̄: 1.19% x̃: 1.38% HURT stats (abs) min: 1 max: 5 x̄: 1.37 x̃: 1 HURT stats (rel) min: 0.24% max: 3.33% x̄: 1.57% x̃: 1.72% 95% mean confidence interval for instructions value: 0.85 1.07 95% mean confidence interval for instructions %-change: 1.16% 1.36% Instructions are HURT. total loops in shared programs: 2441 -> 2437 (-0.16%) loops in affected programs: 8 -> 4 (-50.00%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 497178796 -> 496669298 (-0.10%) cycles in affected programs: 51483322 -> 50973824 (-0.99%) helped: 476 HURT: 137 helped stats (abs) min: 2 max: 7502 x̄: 1079.36 x̃: 1260 helped stats (rel) min: <.01% max: 42.50% x̄: 2.31% x̃: 0.86% HURT stats (abs) min: 2 max: 754 x̄: 31.23 x̃: 18 HURT stats (rel) min: <.01% max: 3.01% x̄: 0.09% x̃: 0.02% 95% mean confidence interval for cycles value: -901.99 -760.32 95% mean confidence interval for cycles %-change: -2.20% -1.36% Cycles are helped. total sends in shared programs: 642919 -> 642915 (<.01%) sends in affected programs: 32 -> 28 (-12.50%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 11.11% max: 14.29% x̄: 12.70% x̃: 12.70% 95% mean confidence interval for sends value: -1.00 -1.00 95% mean confidence interval for sends %-change: -15.61% -9.78% Sends are helped. Iron Lake total instructions in shared programs: 8180061 -> 8180248 (<.01%) instructions in affected programs: 65004 -> 65191 (0.29%) helped: 59 HURT: 253 helped stats (abs) min: 1 max: 4 x̄: 2.24 x̃: 3 helped stats (rel) min: 0.16% max: 2.23% x̄: 1.04% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.26 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.93% x̃: 0.60% 95% mean confidence interval for instructions value: 0.43 0.77 95% mean confidence interval for instructions %-change: 0.45% 0.68% Instructions are HURT. total loops in shared programs: 863 -> 861 (-0.23%) loops in affected programs: 4 -> 2 (-50.00%) helped: 2 HURT: 0 total cycles in shared programs: 239357490 -> 238907668 (-0.19%) cycles in affected programs: 17314006 -> 16864184 (-2.60%) helped: 176 HURT: 34 helped stats (abs) min: 4 max: 13400 x̄: 2558.05 x̃: 2920 helped stats (rel) min: 0.01% max: 35.58% x̄: 3.76% x̃: 2.69% HURT stats (abs) min: 2 max: 14 x̄: 11.59 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2440.68 -1843.34 95% mean confidence interval for cycles %-change: -3.78% -2.51% Cycles are helped. GM45 total instructions in shared programs: 4985293 -> 4985401 (<.01%) instructions in affected programs: 58807 -> 58915 (0.18%) helped: 57 HURT: 202 helped stats (abs) min: 1 max: 4 x̄: 2.26 x̃: 3 helped stats (rel) min: 0.15% max: 2.23% x̄: 1.06% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.17 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.76% x̃: 0.48% 95% mean confidence interval for instructions value: 0.22 0.61 95% mean confidence interval for instructions %-change: 0.24% 0.48% Instructions are HURT. total loops in shared programs: 639 -> 638 (-0.16%) loops in affected programs: 2 -> 1 (-50.00%) helped: 1 HURT: 0 total cycles in shared programs: 153794236 -> 153546274 (-0.16%) cycles in affected programs: 9947778 -> 9699816 (-2.49%) helped: 110 HURT: 31 helped stats (abs) min: 4 max: 13400 x̄: 2257.51 x̃: 1796 helped stats (rel) min: 0.01% max: 35.58% x̄: 4.33% x̃: 2.45% HURT stats (abs) min: 2 max: 14 x̄: 11.74 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2113.77 -1403.42 95% mean confidence interval for cycles %-change: -4.27% -2.47% Cycles are helped. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2899 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12064>
2021-07-26 23:25:58 +10:00
state->blocks[block->index].loop_instr_count = loop_instr_count;
state->blocks[block->index].loop = loop;
break;
}
case nir_cf_node_if: {
nir_if *if_stmt = nir_cf_node_as_if(node);
nir/gcm: fix pushing instructions into if blocks The previous logic would just set the block to the instructions original location if we couldn't evict it from a loop. For now we only push const loads to a later block inside ifs but we can add more heuristics later. This change helps a hand full of shaders but also stops a CTS regression caused by excess spilling after a series I'm working on to disable more of the GLSL IR optimisation passes. Shader-db results iris (BDW): total instructions in shared programs: 17529759 -> 17529749 (<.01%) instructions in affected programs: 15929 -> 15919 (-0.06%) helped: 5 HURT: 2 helped stats (abs) min: 1 max: 5 x̄: 2.40 x̃: 2 helped stats (rel) min: 0.06% max: 0.15% x̄: 0.11% x̃: 0.12% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.06% max: 0.06% x̄: 0.06% x̃: 0.06% 95% mean confidence interval for instructions value: -3.34 0.49 95% mean confidence interval for instructions %-change: -0.14% 0.02% Inconclusive result (value mean confidence interval includes 0). total cycles in shared programs: 861109994 -> 861099681 (<.01%) cycles in affected programs: 7027698 -> 7017385 (-0.15%) helped: 95 HURT: 72 helped stats (abs) min: 1 max: 7995 x̄: 138.54 x̃: 9 helped stats (rel) min: <.01% max: 15.96% x̄: 0.54% x̃: 0.11% HURT stats (abs) min: 1 max: 474 x̄: 39.56 x̃: 12 HURT stats (rel) min: <.01% max: 1.17% x̄: 0.20% x̃: 0.11% 95% mean confidence interval for cycles value: -159.05 35.54 95% mean confidence interval for cycles %-change: -0.45% 0.01% Inconclusive result (value mean confidence interval includes 0). total spills in shared programs: 17606 -> 17605 (<.01%) spills in affected programs: 323 -> 322 (-0.31%) helped: 1 HURT: 0 total fills in shared programs: 22599 -> 22598 (<.01%) fills in affected programs: 1348 -> 1347 (-0.07%) helped: 1 HURT: 0 Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14940>
2022-02-07 19:10:13 +11:00
gcm_build_block_info(&if_stmt->then_list, state, loop, loop_depth,
if_depth + 1, ~0u);
gcm_build_block_info(&if_stmt->else_list, state, loop, loop_depth,
if_depth + 1, ~0u);
break;
}
case nir_cf_node_loop: {
nir_loop *loop = nir_cf_node_as_loop(node);
nir/gcm: fix pushing instructions into if blocks The previous logic would just set the block to the instructions original location if we couldn't evict it from a loop. For now we only push const loads to a later block inside ifs but we can add more heuristics later. This change helps a hand full of shaders but also stops a CTS regression caused by excess spilling after a series I'm working on to disable more of the GLSL IR optimisation passes. Shader-db results iris (BDW): total instructions in shared programs: 17529759 -> 17529749 (<.01%) instructions in affected programs: 15929 -> 15919 (-0.06%) helped: 5 HURT: 2 helped stats (abs) min: 1 max: 5 x̄: 2.40 x̃: 2 helped stats (rel) min: 0.06% max: 0.15% x̄: 0.11% x̃: 0.12% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.06% max: 0.06% x̄: 0.06% x̃: 0.06% 95% mean confidence interval for instructions value: -3.34 0.49 95% mean confidence interval for instructions %-change: -0.14% 0.02% Inconclusive result (value mean confidence interval includes 0). total cycles in shared programs: 861109994 -> 861099681 (<.01%) cycles in affected programs: 7027698 -> 7017385 (-0.15%) helped: 95 HURT: 72 helped stats (abs) min: 1 max: 7995 x̄: 138.54 x̃: 9 helped stats (rel) min: <.01% max: 15.96% x̄: 0.54% x̃: 0.11% HURT stats (abs) min: 1 max: 474 x̄: 39.56 x̃: 12 HURT stats (rel) min: <.01% max: 1.17% x̄: 0.20% x̃: 0.11% 95% mean confidence interval for cycles value: -159.05 35.54 95% mean confidence interval for cycles %-change: -0.45% 0.01% Inconclusive result (value mean confidence interval includes 0). total spills in shared programs: 17606 -> 17605 (<.01%) spills in affected programs: 323 -> 322 (-0.31%) helped: 1 HURT: 0 total fills in shared programs: 22599 -> 22598 (<.01%) fills in affected programs: 1348 -> 1347 (-0.07%) helped: 1 HURT: 0 Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14940>
2022-02-07 19:10:13 +11:00
gcm_build_block_info(&loop->body, state, loop, loop_depth + 1, if_depth,
nir: add heuristic for instructions in loops with GCM Moving instructions out of large loops tends to cause excessive spilling. This appears to be a good limit. In future it might make sense to make this a NIR options so other drivers can set their own limits. Tiger Lake total instructions in shared programs: 20930180 -> 20926952 (-0.02%) instructions in affected programs: 280768 -> 277540 (-1.15%) helped: 734 HURT: 192 helped stats (abs) min: 1 max: 61 x̄: 5.16 x̃: 4 helped stats (rel) min: 0.04% max: 10.64% x̄: 3.23% x̃: 3.14% HURT stats (abs) min: 1 max: 52 x̄: 2.90 x̃: 1 HURT stats (rel) min: 0.03% max: 9.76% x̄: 1.13% x̃: 0.61% 95% mean confidence interval for instructions value: -3.89 -3.08 95% mean confidence interval for instructions %-change: -2.49% -2.16% Instructions are helped. total cycles in shared programs: 841825217 -> 838817552 (-0.36%) cycles in affected programs: 122088078 -> 119080413 (-2.46%) helped: 941 HURT: 100 helped stats (abs) min: 1 max: 160080 x̄: 3274.31 x̃: 2660 helped stats (rel) min: <.01% max: 41.64% x̄: 5.50% x̃: 4.80% HURT stats (abs) min: 1 max: 41856 x̄: 734.62 x̃: 26 HURT stats (rel) min: <.01% max: 7.29% x̄: 0.44% x̃: 0.27% 95% mean confidence interval for cycles value: -3236.56 -2541.85 95% mean confidence interval for cycles %-change: -5.26% -4.60% Cycles are helped. total sends in shared programs: 977905 -> 977782 (-0.01%) sends in affected programs: 2279 -> 2156 (-5.40%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.93% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.42% -6.45% Sends are helped. LOST: 2 GAINED: 0 Ice Lake total instructions in shared programs: 19865361 -> 19861747 (-0.02%) instructions in affected programs: 185789 -> 182175 (-1.95%) helped: 593 HURT: 47 helped stats (abs) min: 1 max: 27 x̄: 6.17 x̃: 4 helped stats (rel) min: 0.19% max: 8.65% x̄: 4.53% x̃: 4.60% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.23% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -5.93 -5.37 95% mean confidence interval for instructions %-change: -4.32% -4.06% Instructions are helped. total loops in shared programs: 6120 -> 6117 (-0.05%) loops in affected programs: 6 -> 3 (-50.00%) helped: 3 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% total cycles in shared programs: 961777176 -> 959404350 (-0.25%) cycles in affected programs: 172224180 -> 169851354 (-1.38%) helped: 936 HURT: 80 helped stats (abs) min: 1 max: 9566 x̄: 2621.08 x̃: 2550 helped stats (rel) min: <.01% max: 41.77% x̄: 4.22% x̃: 3.84% HURT stats (abs) min: 1 max: 59146 x̄: 1006.34 x̃: 24 HURT stats (rel) min: <.01% max: 3.78% x̄: 0.44% x̃: 0.25% 95% mean confidence interval for cycles value: -2513.72 -2157.20 95% mean confidence interval for cycles %-change: -4.13% -3.57% Cycles are helped. total sends in shared programs: 1019995 -> 1019872 (-0.01%) sends in affected programs: 2283 -> 2160 (-5.39%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.39% -6.42% Sends are helped. LOST: 4 GAINED: 0 Skylake total instructions in shared programs: 17994337 -> 17993846 (<.01%) instructions in affected programs: 146294 -> 145803 (-0.34%) helped: 190 HURT: 47 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.14% max: 4.29% x̄: 1.08% x̃: 0.90% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.22% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -2.30 -1.84 95% mean confidence interval for instructions %-change: -0.95% -0.74% Instructions are helped. total loops in shared programs: 6029 -> 6023 (-0.10%) loops in affected programs: 12 -> 6 (-50.00%) helped: 6 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 939062940 -> 938023548 (-0.11%) cycles in affected programs: 169671482 -> 168632090 (-0.61%) helped: 980 HURT: 134 helped stats (abs) min: 1 max: 25000 x̄: 1075.57 x̃: 1052 helped stats (rel) min: <.01% max: 42.75% x̄: 2.51% x̃: 1.32% HURT stats (abs) min: 1 max: 837 x̄: 109.45 x̃: 20 HURT stats (rel) min: <.01% max: 5.71% x̄: 0.73% x̃: 0.21% 95% mean confidence interval for cycles value: -1005.89 -860.17 95% mean confidence interval for cycles %-change: -2.39% -1.84% Cycles are helped. total sends in shared programs: 1026848 -> 1026724 (-0.01%) sends in affected programs: 2302 -> 2178 (-5.39%) helped: 120 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.40% -6.43% Sends are helped. LOST: 1 GAINED: 1 Broadwell total instructions in shared programs: 17605621 -> 17605154 (<.01%) instructions in affected programs: 145691 -> 145224 (-0.32%) helped: 184 HURT: 48 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.13% max: 4.29% x̄: 1.09% x̃: 0.93% HURT stats (abs) min: 1 max: 7 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 0.48% x̄: 0.12% x̃: 0.04% 95% mean confidence interval for instructions value: -2.26 -1.77 95% mean confidence interval for instructions %-change: -0.95% -0.73% Instructions are helped. total loops in shared programs: 5968 -> 5963 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 1000679489 -> 998592756 (-0.21%) cycles in affected programs: 173421234 -> 171334501 (-1.20%) helped: 993 HURT: 153 helped stats (abs) min: 1 max: 766608 x̄: 2118.49 x̃: 1080 helped stats (rel) min: <.01% max: 54.61% x̄: 2.61% x̃: 1.73% HURT stats (abs) min: 1 max: 2200 x̄: 110.61 x̃: 11 HURT stats (rel) min: <.01% max: 5.68% x̄: 0.63% x̃: 0.06% 95% mean confidence interval for cycles value: -3191.23 -450.54 95% mean confidence interval for cycles %-change: -2.47% -1.89% Cycles are helped. total sends in shared programs: 996341 -> 996222 (-0.01%) sends in affected programs: 2151 -> 2032 (-5.53%) helped: 115 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 7.07% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.55% -6.58% Sends are helped. Haswell total instructions in shared programs: 16038375 -> 16038121 (<.01%) instructions in affected programs: 216797 -> 216543 (-0.12%) helped: 185 HURT: 217 helped stats (abs) min: 1 max: 12 x̄: 2.84 x̃: 3 helped stats (rel) min: 0.13% max: 4.23% x̄: 1.30% x̃: 1.20% HURT stats (abs) min: 1 max: 6 x̄: 1.25 x̃: 1 HURT stats (rel) min: 0.03% max: 5.66% x̄: 0.61% x̃: 0.40% 95% mean confidence interval for instructions value: -0.85 -0.41 95% mean confidence interval for instructions %-change: -0.40% -0.14% Instructions are helped. total loops in shared programs: 5947 -> 5942 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 967655093 -> 965746713 (-0.20%) cycles in affected programs: 197288924 -> 195380544 (-0.97%) helped: 950 HURT: 195 helped stats (abs) min: 1 max: 782820 x̄: 2274.79 x̃: 1260 helped stats (rel) min: <.01% max: 54.26% x̄: 3.02% x̃: 1.71% HURT stats (abs) min: 1 max: 15790 x̄: 1295.73 x̃: 21 HURT stats (rel) min: <.01% max: 119.85% x̄: 7.76% x̃: 0.11% 95% mean confidence interval for cycles value: -3014.22 -319.19 95% mean confidence interval for cycles %-change: -1.83% -0.55% Cycles are helped. total sends in shared programs: 934894 -> 934765 (-0.01%) sends in affected programs: 2192 -> 2063 (-5.89%) helped: 115 HURT: 2 helped stats (abs) min: 1 max: 4 x̄: 1.14 x̃: 1 helped stats (rel) min: 0.60% max: 28.57% x̄: 7.68% x̃: 6.67% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 16.67% max: 16.67% x̄: 16.67% x̃: 16.67% 95% mean confidence interval for sends value: -1.23 -0.98 95% mean confidence interval for sends %-change: -8.28% -6.24% Sends are helped. LOST: 1 GAINED: 18 Ivy Bridge total instructions in shared programs: 15269357 -> 15269398 (<.01%) instructions in affected programs: 190484 -> 190525 (0.02%) helped: 77 HURT: 206 helped stats (abs) min: 1 max: 6 x̄: 2.47 x̃: 3 helped stats (rel) min: 0.14% max: 5.31% x̄: 1.46% x̃: 1.65% HURT stats (abs) min: 1 max: 3 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 2.38% x̄: 0.42% x̃: 0.40% 95% mean confidence interval for instructions value: -0.06 0.35 95% mean confidence interval for instructions %-change: -0.21% 0.03% Inconclusive result (value mean confidence interval includes 0). total loops in shared programs: 4001 -> 3996 (-0.12%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 562045564 -> 561063543 (-0.17%) cycles in affected programs: 200924872 -> 199942851 (-0.49%) helped: 748 HURT: 160 helped stats (abs) min: 2 max: 14926 x̄: 1692.94 x̃: 1620 helped stats (rel) min: <.01% max: 53.29% x̄: 3.17% x̃: 1.87% HURT stats (abs) min: 2 max: 15726 x̄: 1776.86 x̃: 36 HURT stats (rel) min: <.01% max: 114.43% x̄: 10.66% x̃: 0.21% 95% mean confidence interval for cycles value: -1237.33 -925.71 95% mean confidence interval for cycles %-change: -1.54% 0.08% Inconclusive result (%-change mean confidence interval includes 0). total sends in shared programs: 893348 -> 893330 (<.01%) sends in affected programs: 187 -> 169 (-9.63%) helped: 14 HURT: 0 helped stats (abs) min: 1 max: 2 x̄: 1.29 x̃: 1 helped stats (rel) min: 4.08% max: 22.22% x̄: 11.70% x̃: 10.10% 95% mean confidence interval for sends value: -1.56 -1.02 95% mean confidence interval for sends %-change: -14.92% -8.48% Sends are helped. LOST: 1 GAINED: 19 Sandy Bridge total instructions in shared programs: 11785227 -> 11785774 (<.01%) instructions in affected programs: 78403 -> 78950 (0.70%) helped: 65 HURT: 505 helped stats (abs) min: 1 max: 4 x̄: 2.22 x̃: 3 helped stats (rel) min: 0.14% max: 4.17% x̄: 1.19% x̃: 1.38% HURT stats (abs) min: 1 max: 5 x̄: 1.37 x̃: 1 HURT stats (rel) min: 0.24% max: 3.33% x̄: 1.57% x̃: 1.72% 95% mean confidence interval for instructions value: 0.85 1.07 95% mean confidence interval for instructions %-change: 1.16% 1.36% Instructions are HURT. total loops in shared programs: 2441 -> 2437 (-0.16%) loops in affected programs: 8 -> 4 (-50.00%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 497178796 -> 496669298 (-0.10%) cycles in affected programs: 51483322 -> 50973824 (-0.99%) helped: 476 HURT: 137 helped stats (abs) min: 2 max: 7502 x̄: 1079.36 x̃: 1260 helped stats (rel) min: <.01% max: 42.50% x̄: 2.31% x̃: 0.86% HURT stats (abs) min: 2 max: 754 x̄: 31.23 x̃: 18 HURT stats (rel) min: <.01% max: 3.01% x̄: 0.09% x̃: 0.02% 95% mean confidence interval for cycles value: -901.99 -760.32 95% mean confidence interval for cycles %-change: -2.20% -1.36% Cycles are helped. total sends in shared programs: 642919 -> 642915 (<.01%) sends in affected programs: 32 -> 28 (-12.50%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 11.11% max: 14.29% x̄: 12.70% x̃: 12.70% 95% mean confidence interval for sends value: -1.00 -1.00 95% mean confidence interval for sends %-change: -15.61% -9.78% Sends are helped. Iron Lake total instructions in shared programs: 8180061 -> 8180248 (<.01%) instructions in affected programs: 65004 -> 65191 (0.29%) helped: 59 HURT: 253 helped stats (abs) min: 1 max: 4 x̄: 2.24 x̃: 3 helped stats (rel) min: 0.16% max: 2.23% x̄: 1.04% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.26 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.93% x̃: 0.60% 95% mean confidence interval for instructions value: 0.43 0.77 95% mean confidence interval for instructions %-change: 0.45% 0.68% Instructions are HURT. total loops in shared programs: 863 -> 861 (-0.23%) loops in affected programs: 4 -> 2 (-50.00%) helped: 2 HURT: 0 total cycles in shared programs: 239357490 -> 238907668 (-0.19%) cycles in affected programs: 17314006 -> 16864184 (-2.60%) helped: 176 HURT: 34 helped stats (abs) min: 4 max: 13400 x̄: 2558.05 x̃: 2920 helped stats (rel) min: 0.01% max: 35.58% x̄: 3.76% x̃: 2.69% HURT stats (abs) min: 2 max: 14 x̄: 11.59 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2440.68 -1843.34 95% mean confidence interval for cycles %-change: -3.78% -2.51% Cycles are helped. GM45 total instructions in shared programs: 4985293 -> 4985401 (<.01%) instructions in affected programs: 58807 -> 58915 (0.18%) helped: 57 HURT: 202 helped stats (abs) min: 1 max: 4 x̄: 2.26 x̃: 3 helped stats (rel) min: 0.15% max: 2.23% x̄: 1.06% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.17 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.76% x̃: 0.48% 95% mean confidence interval for instructions value: 0.22 0.61 95% mean confidence interval for instructions %-change: 0.24% 0.48% Instructions are HURT. total loops in shared programs: 639 -> 638 (-0.16%) loops in affected programs: 2 -> 1 (-50.00%) helped: 1 HURT: 0 total cycles in shared programs: 153794236 -> 153546274 (-0.16%) cycles in affected programs: 9947778 -> 9699816 (-2.49%) helped: 110 HURT: 31 helped stats (abs) min: 4 max: 13400 x̄: 2257.51 x̃: 1796 helped stats (rel) min: 0.01% max: 35.58% x̄: 4.33% x̃: 2.45% HURT stats (abs) min: 2 max: 14 x̄: 11.74 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2113.77 -1403.42 95% mean confidence interval for cycles %-change: -4.27% -2.47% Cycles are helped. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2899 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12064>
2021-07-26 23:25:58 +10:00
get_loop_instr_count(&loop->body));
break;
}
default:
unreachable("Invalid CF node type");
}
}
}
static bool
is_src_scalarizable(nir_src *src)
{
assert(src->is_ssa);
nir_instr *src_instr = src->ssa->parent_instr;
switch (src_instr->type) {
case nir_instr_type_alu: {
nir_alu_instr *src_alu = nir_instr_as_alu(src_instr);
/* ALU operations with output_size == 0 should be scalarized. We
* will also see a bunch of vecN operations from scalarizing ALU
* operations and, since they can easily be copy-propagated, they
* are ok too.
*/
return nir_op_infos[src_alu->op].output_size == 0 ||
src_alu->op == nir_op_vec2 ||
src_alu->op == nir_op_vec3 ||
src_alu->op == nir_op_vec4;
}
case nir_instr_type_load_const:
/* These are trivially scalarizable */
return true;
case nir_instr_type_ssa_undef:
return true;
case nir_instr_type_intrinsic: {
nir_intrinsic_instr *src_intrin = nir_instr_as_intrinsic(src_instr);
switch (src_intrin->intrinsic) {
case nir_intrinsic_load_deref: {
/* Don't scalarize if we see a load of a local variable because it
* might turn into one of the things we can't scalarize.
*/
nir_deref_instr *deref = nir_src_as_deref(src_intrin->src[0]);
return !nir_deref_mode_may_be(deref, (nir_var_function_temp |
nir_var_shader_temp));
}
case nir_intrinsic_interp_deref_at_centroid:
case nir_intrinsic_interp_deref_at_sample:
case nir_intrinsic_interp_deref_at_offset:
case nir_intrinsic_load_uniform:
case nir_intrinsic_load_ubo:
case nir_intrinsic_load_ssbo:
case nir_intrinsic_load_global:
case nir_intrinsic_load_global_constant:
case nir_intrinsic_load_input:
return true;
default:
break;
}
return false;
}
default:
/* We can't scalarize this type of instruction */
return false;
}
}
static bool
is_binding_uniform(nir_src src)
{
nir_binding binding = nir_chase_binding(src);
if (!binding.success)
return false;
for (unsigned i = 0; i < binding.num_indices; i++) {
if (!nir_src_is_always_uniform(binding.indices[i]))
return false;
}
return true;
}
static void
pin_intrinsic(nir_intrinsic_instr *intrin)
{
nir_instr *instr = &intrin->instr;
if (!nir_intrinsic_can_reorder(intrin)) {
instr->pass_flags = GCM_INSTR_PINNED;
return;
}
instr->pass_flags = 0;
/* If the intrinsic requires a uniform source, we can't safely move it across non-uniform
* control flow if it's not uniform at the point it's defined.
* Stores and atomics can never be re-ordered, so we don't have to consider them here.
*/
bool non_uniform = nir_intrinsic_has_access(intrin) &&
(nir_intrinsic_access(intrin) & ACCESS_NON_UNIFORM);
if (!non_uniform &&
(intrin->intrinsic == nir_intrinsic_load_ubo ||
intrin->intrinsic == nir_intrinsic_load_ssbo ||
intrin->intrinsic == nir_intrinsic_get_ubo_size ||
intrin->intrinsic == nir_intrinsic_get_ssbo_size ||
nir_intrinsic_has_image_dim(intrin) ||
((intrin->intrinsic == nir_intrinsic_load_deref ||
intrin->intrinsic == nir_intrinsic_deref_buffer_array_length) &&
nir_deref_mode_may_be(nir_src_as_deref(intrin->src[0]),
nir_var_mem_ubo | nir_var_mem_ssbo)))) {
if (!is_binding_uniform(intrin->src[0]))
instr->pass_flags = GCM_INSTR_PINNED;
} else if (intrin->intrinsic == nir_intrinsic_load_push_constant) {
if (!nir_src_is_always_uniform(intrin->src[0]))
instr->pass_flags = GCM_INSTR_PINNED;
} else if (intrin->intrinsic == nir_intrinsic_load_deref &&
nir_deref_mode_is(nir_src_as_deref(intrin->src[0]),
nir_var_mem_push_const)) {
nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
while (deref->deref_type != nir_deref_type_var) {
if ((deref->deref_type == nir_deref_type_array ||
deref->deref_type == nir_deref_type_ptr_as_array) &&
!nir_src_is_always_uniform(deref->arr.index)) {
instr->pass_flags = GCM_INSTR_PINNED;
return;
}
deref = nir_deref_instr_parent(deref);
if (!deref) {
instr->pass_flags = GCM_INSTR_PINNED;
return;
}
}
}
}
/* Walks the instruction list and marks immovable instructions as pinned or
* placed.
*
* This function also serves to initialize the instr->pass_flags field.
* After this is completed, all instructions' pass_flags fields will be set
* to either GCM_INSTR_PINNED, GCM_INSTR_PLACED or 0.
*/
static void
gcm_pin_instructions(nir_function_impl *impl, struct gcm_state *state)
{
state->num_instrs = 0;
nir_foreach_block(block, impl) {
nir_foreach_instr_safe(instr, block) {
/* Index the instructions for use in gcm_state::instrs */
instr->index = state->num_instrs++;
switch (instr->type) {
case nir_instr_type_alu:
switch (nir_instr_as_alu(instr)->op) {
case nir_op_fddx:
case nir_op_fddy:
case nir_op_fddx_fine:
case nir_op_fddy_fine:
case nir_op_fddx_coarse:
case nir_op_fddy_coarse:
/* These can only go in uniform control flow */
instr->pass_flags = GCM_INSTR_SCHEDULE_EARLIER_ONLY;
break;
case nir_op_mov:
if (!is_src_scalarizable(&(nir_instr_as_alu(instr)->src[0].src))) {
instr->pass_flags = GCM_INSTR_PINNED;
break;
}
FALLTHROUGH;
default:
instr->pass_flags = 0;
break;
}
break;
case nir_instr_type_tex: {
nir_tex_instr *tex = nir_instr_as_tex(instr);
if (nir_tex_instr_has_implicit_derivative(tex))
instr->pass_flags = GCM_INSTR_SCHEDULE_EARLIER_ONLY;
for (unsigned i = 0; i < tex->num_srcs; i++) {
nir_tex_src *src = &tex->src[i];
switch (src->src_type) {
case nir_tex_src_texture_deref:
if (!tex->texture_non_uniform && !is_binding_uniform(src->src))
instr->pass_flags = GCM_INSTR_PINNED;
break;
case nir_tex_src_sampler_deref:
if (!tex->sampler_non_uniform && !is_binding_uniform(src->src))
instr->pass_flags = GCM_INSTR_PINNED;
break;
case nir_tex_src_texture_offset:
case nir_tex_src_texture_handle:
if (!tex->texture_non_uniform && !nir_src_is_always_uniform(src->src))
instr->pass_flags = GCM_INSTR_PINNED;
break;
case nir_tex_src_sampler_offset:
case nir_tex_src_sampler_handle:
if (!tex->sampler_non_uniform && !nir_src_is_always_uniform(src->src))
instr->pass_flags = GCM_INSTR_PINNED;
break;
default:
break;
}
}
break;
}
case nir_instr_type_deref:
case nir_instr_type_load_const:
instr->pass_flags = 0;
break;
case nir_instr_type_intrinsic:
pin_intrinsic(nir_instr_as_intrinsic(instr));
break;
case nir_instr_type_jump:
case nir_instr_type_ssa_undef:
case nir_instr_type_phi:
instr->pass_flags = GCM_INSTR_PLACED;
break;
default:
unreachable("Invalid instruction type in GCM");
}
if (!(instr->pass_flags & GCM_INSTR_PLACED)) {
/* If this is an unplaced instruction, go ahead and pull it out of
* the program and put it on the instrs list. This has a couple
* of benifits. First, it makes the scheduling algorithm more
* efficient because we can avoid walking over basic blocks.
* Second, it keeps us from causing linked list confusion when
* we're trying to put everything in its proper place at the end
* of the pass.
*
* Note that we don't use nir_instr_remove here because that also
* cleans up uses and defs and we want to keep that information.
*/
exec_node_remove(&instr->node);
exec_list_push_tail(&state->instrs, &instr->node);
}
}
}
}
static void
gcm_schedule_early_instr(nir_instr *instr, struct gcm_state *state);
/** Update an instructions schedule for the given source
*
* This function is called iteratively as we walk the sources of an
* instruction. It ensures that the given source instruction has been
* scheduled and then update this instruction's block if the source
* instruction is lower down the tree.
*/
static bool
gcm_schedule_early_src(nir_src *src, void *void_state)
{
struct gcm_state *state = void_state;
nir_instr *instr = state->instr;
assert(src->is_ssa);
gcm_schedule_early_instr(src->ssa->parent_instr, void_state);
/* While the index isn't a proper dominance depth, it does have the
* property that if A dominates B then A->index <= B->index. Since we
* know that this instruction must have been dominated by all of its
* sources at some point (even if it's gone through value-numbering),
* all of the sources must lie on the same branch of the dominance tree.
* Therefore, we can just go ahead and just compare indices.
*/
struct gcm_instr_info *src_info =
&state->instr_infos[src->ssa->parent_instr->index];
struct gcm_instr_info *info = &state->instr_infos[instr->index];
if (info->early_block->index < src_info->early_block->index)
info->early_block = src_info->early_block;
/* We need to restore the state instruction because it may have been
* changed through the gcm_schedule_early_instr call above. Since we
* may still be iterating through sources and future calls to
* gcm_schedule_early_src for the same instruction will still need it.
*/
state->instr = instr;
return true;
}
/** Schedules an instruction early
*
* This function performs a recursive depth-first search starting at the
* given instruction and proceeding through the sources to schedule
* instructions as early as they can possibly go in the dominance tree.
* The instructions are "scheduled" by updating the early_block field of
* the corresponding gcm_instr_state entry.
*/
static void
gcm_schedule_early_instr(nir_instr *instr, struct gcm_state *state)
{
if (instr->pass_flags & GCM_INSTR_SCHEDULED_EARLY)
return;
instr->pass_flags |= GCM_INSTR_SCHEDULED_EARLY;
/* Pinned/placed instructions always get scheduled in their original block so
* we don't need to do anything. Also, bailing here keeps us from ever
* following the sources of phi nodes which can be back-edges.
*/
if (instr->pass_flags & GCM_INSTR_PINNED ||
instr->pass_flags & GCM_INSTR_PLACED) {
state->instr_infos[instr->index].early_block = instr->block;
return;
}
/* Start with the instruction at the top. As we iterate over the
* sources, it will get moved down as needed.
*/
state->instr_infos[instr->index].early_block = nir_start_block(state->impl);
state->instr = instr;
nir_foreach_src(instr, gcm_schedule_early_src, state);
}
nir: add heuristic for instructions in loops with GCM Moving instructions out of large loops tends to cause excessive spilling. This appears to be a good limit. In future it might make sense to make this a NIR options so other drivers can set their own limits. Tiger Lake total instructions in shared programs: 20930180 -> 20926952 (-0.02%) instructions in affected programs: 280768 -> 277540 (-1.15%) helped: 734 HURT: 192 helped stats (abs) min: 1 max: 61 x̄: 5.16 x̃: 4 helped stats (rel) min: 0.04% max: 10.64% x̄: 3.23% x̃: 3.14% HURT stats (abs) min: 1 max: 52 x̄: 2.90 x̃: 1 HURT stats (rel) min: 0.03% max: 9.76% x̄: 1.13% x̃: 0.61% 95% mean confidence interval for instructions value: -3.89 -3.08 95% mean confidence interval for instructions %-change: -2.49% -2.16% Instructions are helped. total cycles in shared programs: 841825217 -> 838817552 (-0.36%) cycles in affected programs: 122088078 -> 119080413 (-2.46%) helped: 941 HURT: 100 helped stats (abs) min: 1 max: 160080 x̄: 3274.31 x̃: 2660 helped stats (rel) min: <.01% max: 41.64% x̄: 5.50% x̃: 4.80% HURT stats (abs) min: 1 max: 41856 x̄: 734.62 x̃: 26 HURT stats (rel) min: <.01% max: 7.29% x̄: 0.44% x̃: 0.27% 95% mean confidence interval for cycles value: -3236.56 -2541.85 95% mean confidence interval for cycles %-change: -5.26% -4.60% Cycles are helped. total sends in shared programs: 977905 -> 977782 (-0.01%) sends in affected programs: 2279 -> 2156 (-5.40%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.93% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.42% -6.45% Sends are helped. LOST: 2 GAINED: 0 Ice Lake total instructions in shared programs: 19865361 -> 19861747 (-0.02%) instructions in affected programs: 185789 -> 182175 (-1.95%) helped: 593 HURT: 47 helped stats (abs) min: 1 max: 27 x̄: 6.17 x̃: 4 helped stats (rel) min: 0.19% max: 8.65% x̄: 4.53% x̃: 4.60% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.23% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -5.93 -5.37 95% mean confidence interval for instructions %-change: -4.32% -4.06% Instructions are helped. total loops in shared programs: 6120 -> 6117 (-0.05%) loops in affected programs: 6 -> 3 (-50.00%) helped: 3 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% total cycles in shared programs: 961777176 -> 959404350 (-0.25%) cycles in affected programs: 172224180 -> 169851354 (-1.38%) helped: 936 HURT: 80 helped stats (abs) min: 1 max: 9566 x̄: 2621.08 x̃: 2550 helped stats (rel) min: <.01% max: 41.77% x̄: 4.22% x̃: 3.84% HURT stats (abs) min: 1 max: 59146 x̄: 1006.34 x̃: 24 HURT stats (rel) min: <.01% max: 3.78% x̄: 0.44% x̃: 0.25% 95% mean confidence interval for cycles value: -2513.72 -2157.20 95% mean confidence interval for cycles %-change: -4.13% -3.57% Cycles are helped. total sends in shared programs: 1019995 -> 1019872 (-0.01%) sends in affected programs: 2283 -> 2160 (-5.39%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.39% -6.42% Sends are helped. LOST: 4 GAINED: 0 Skylake total instructions in shared programs: 17994337 -> 17993846 (<.01%) instructions in affected programs: 146294 -> 145803 (-0.34%) helped: 190 HURT: 47 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.14% max: 4.29% x̄: 1.08% x̃: 0.90% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.22% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -2.30 -1.84 95% mean confidence interval for instructions %-change: -0.95% -0.74% Instructions are helped. total loops in shared programs: 6029 -> 6023 (-0.10%) loops in affected programs: 12 -> 6 (-50.00%) helped: 6 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 939062940 -> 938023548 (-0.11%) cycles in affected programs: 169671482 -> 168632090 (-0.61%) helped: 980 HURT: 134 helped stats (abs) min: 1 max: 25000 x̄: 1075.57 x̃: 1052 helped stats (rel) min: <.01% max: 42.75% x̄: 2.51% x̃: 1.32% HURT stats (abs) min: 1 max: 837 x̄: 109.45 x̃: 20 HURT stats (rel) min: <.01% max: 5.71% x̄: 0.73% x̃: 0.21% 95% mean confidence interval for cycles value: -1005.89 -860.17 95% mean confidence interval for cycles %-change: -2.39% -1.84% Cycles are helped. total sends in shared programs: 1026848 -> 1026724 (-0.01%) sends in affected programs: 2302 -> 2178 (-5.39%) helped: 120 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.40% -6.43% Sends are helped. LOST: 1 GAINED: 1 Broadwell total instructions in shared programs: 17605621 -> 17605154 (<.01%) instructions in affected programs: 145691 -> 145224 (-0.32%) helped: 184 HURT: 48 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.13% max: 4.29% x̄: 1.09% x̃: 0.93% HURT stats (abs) min: 1 max: 7 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 0.48% x̄: 0.12% x̃: 0.04% 95% mean confidence interval for instructions value: -2.26 -1.77 95% mean confidence interval for instructions %-change: -0.95% -0.73% Instructions are helped. total loops in shared programs: 5968 -> 5963 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 1000679489 -> 998592756 (-0.21%) cycles in affected programs: 173421234 -> 171334501 (-1.20%) helped: 993 HURT: 153 helped stats (abs) min: 1 max: 766608 x̄: 2118.49 x̃: 1080 helped stats (rel) min: <.01% max: 54.61% x̄: 2.61% x̃: 1.73% HURT stats (abs) min: 1 max: 2200 x̄: 110.61 x̃: 11 HURT stats (rel) min: <.01% max: 5.68% x̄: 0.63% x̃: 0.06% 95% mean confidence interval for cycles value: -3191.23 -450.54 95% mean confidence interval for cycles %-change: -2.47% -1.89% Cycles are helped. total sends in shared programs: 996341 -> 996222 (-0.01%) sends in affected programs: 2151 -> 2032 (-5.53%) helped: 115 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 7.07% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.55% -6.58% Sends are helped. Haswell total instructions in shared programs: 16038375 -> 16038121 (<.01%) instructions in affected programs: 216797 -> 216543 (-0.12%) helped: 185 HURT: 217 helped stats (abs) min: 1 max: 12 x̄: 2.84 x̃: 3 helped stats (rel) min: 0.13% max: 4.23% x̄: 1.30% x̃: 1.20% HURT stats (abs) min: 1 max: 6 x̄: 1.25 x̃: 1 HURT stats (rel) min: 0.03% max: 5.66% x̄: 0.61% x̃: 0.40% 95% mean confidence interval for instructions value: -0.85 -0.41 95% mean confidence interval for instructions %-change: -0.40% -0.14% Instructions are helped. total loops in shared programs: 5947 -> 5942 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 967655093 -> 965746713 (-0.20%) cycles in affected programs: 197288924 -> 195380544 (-0.97%) helped: 950 HURT: 195 helped stats (abs) min: 1 max: 782820 x̄: 2274.79 x̃: 1260 helped stats (rel) min: <.01% max: 54.26% x̄: 3.02% x̃: 1.71% HURT stats (abs) min: 1 max: 15790 x̄: 1295.73 x̃: 21 HURT stats (rel) min: <.01% max: 119.85% x̄: 7.76% x̃: 0.11% 95% mean confidence interval for cycles value: -3014.22 -319.19 95% mean confidence interval for cycles %-change: -1.83% -0.55% Cycles are helped. total sends in shared programs: 934894 -> 934765 (-0.01%) sends in affected programs: 2192 -> 2063 (-5.89%) helped: 115 HURT: 2 helped stats (abs) min: 1 max: 4 x̄: 1.14 x̃: 1 helped stats (rel) min: 0.60% max: 28.57% x̄: 7.68% x̃: 6.67% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 16.67% max: 16.67% x̄: 16.67% x̃: 16.67% 95% mean confidence interval for sends value: -1.23 -0.98 95% mean confidence interval for sends %-change: -8.28% -6.24% Sends are helped. LOST: 1 GAINED: 18 Ivy Bridge total instructions in shared programs: 15269357 -> 15269398 (<.01%) instructions in affected programs: 190484 -> 190525 (0.02%) helped: 77 HURT: 206 helped stats (abs) min: 1 max: 6 x̄: 2.47 x̃: 3 helped stats (rel) min: 0.14% max: 5.31% x̄: 1.46% x̃: 1.65% HURT stats (abs) min: 1 max: 3 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 2.38% x̄: 0.42% x̃: 0.40% 95% mean confidence interval for instructions value: -0.06 0.35 95% mean confidence interval for instructions %-change: -0.21% 0.03% Inconclusive result (value mean confidence interval includes 0). total loops in shared programs: 4001 -> 3996 (-0.12%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 562045564 -> 561063543 (-0.17%) cycles in affected programs: 200924872 -> 199942851 (-0.49%) helped: 748 HURT: 160 helped stats (abs) min: 2 max: 14926 x̄: 1692.94 x̃: 1620 helped stats (rel) min: <.01% max: 53.29% x̄: 3.17% x̃: 1.87% HURT stats (abs) min: 2 max: 15726 x̄: 1776.86 x̃: 36 HURT stats (rel) min: <.01% max: 114.43% x̄: 10.66% x̃: 0.21% 95% mean confidence interval for cycles value: -1237.33 -925.71 95% mean confidence interval for cycles %-change: -1.54% 0.08% Inconclusive result (%-change mean confidence interval includes 0). total sends in shared programs: 893348 -> 893330 (<.01%) sends in affected programs: 187 -> 169 (-9.63%) helped: 14 HURT: 0 helped stats (abs) min: 1 max: 2 x̄: 1.29 x̃: 1 helped stats (rel) min: 4.08% max: 22.22% x̄: 11.70% x̃: 10.10% 95% mean confidence interval for sends value: -1.56 -1.02 95% mean confidence interval for sends %-change: -14.92% -8.48% Sends are helped. LOST: 1 GAINED: 19 Sandy Bridge total instructions in shared programs: 11785227 -> 11785774 (<.01%) instructions in affected programs: 78403 -> 78950 (0.70%) helped: 65 HURT: 505 helped stats (abs) min: 1 max: 4 x̄: 2.22 x̃: 3 helped stats (rel) min: 0.14% max: 4.17% x̄: 1.19% x̃: 1.38% HURT stats (abs) min: 1 max: 5 x̄: 1.37 x̃: 1 HURT stats (rel) min: 0.24% max: 3.33% x̄: 1.57% x̃: 1.72% 95% mean confidence interval for instructions value: 0.85 1.07 95% mean confidence interval for instructions %-change: 1.16% 1.36% Instructions are HURT. total loops in shared programs: 2441 -> 2437 (-0.16%) loops in affected programs: 8 -> 4 (-50.00%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 497178796 -> 496669298 (-0.10%) cycles in affected programs: 51483322 -> 50973824 (-0.99%) helped: 476 HURT: 137 helped stats (abs) min: 2 max: 7502 x̄: 1079.36 x̃: 1260 helped stats (rel) min: <.01% max: 42.50% x̄: 2.31% x̃: 0.86% HURT stats (abs) min: 2 max: 754 x̄: 31.23 x̃: 18 HURT stats (rel) min: <.01% max: 3.01% x̄: 0.09% x̃: 0.02% 95% mean confidence interval for cycles value: -901.99 -760.32 95% mean confidence interval for cycles %-change: -2.20% -1.36% Cycles are helped. total sends in shared programs: 642919 -> 642915 (<.01%) sends in affected programs: 32 -> 28 (-12.50%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 11.11% max: 14.29% x̄: 12.70% x̃: 12.70% 95% mean confidence interval for sends value: -1.00 -1.00 95% mean confidence interval for sends %-change: -15.61% -9.78% Sends are helped. Iron Lake total instructions in shared programs: 8180061 -> 8180248 (<.01%) instructions in affected programs: 65004 -> 65191 (0.29%) helped: 59 HURT: 253 helped stats (abs) min: 1 max: 4 x̄: 2.24 x̃: 3 helped stats (rel) min: 0.16% max: 2.23% x̄: 1.04% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.26 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.93% x̃: 0.60% 95% mean confidence interval for instructions value: 0.43 0.77 95% mean confidence interval for instructions %-change: 0.45% 0.68% Instructions are HURT. total loops in shared programs: 863 -> 861 (-0.23%) loops in affected programs: 4 -> 2 (-50.00%) helped: 2 HURT: 0 total cycles in shared programs: 239357490 -> 238907668 (-0.19%) cycles in affected programs: 17314006 -> 16864184 (-2.60%) helped: 176 HURT: 34 helped stats (abs) min: 4 max: 13400 x̄: 2558.05 x̃: 2920 helped stats (rel) min: 0.01% max: 35.58% x̄: 3.76% x̃: 2.69% HURT stats (abs) min: 2 max: 14 x̄: 11.59 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2440.68 -1843.34 95% mean confidence interval for cycles %-change: -3.78% -2.51% Cycles are helped. GM45 total instructions in shared programs: 4985293 -> 4985401 (<.01%) instructions in affected programs: 58807 -> 58915 (0.18%) helped: 57 HURT: 202 helped stats (abs) min: 1 max: 4 x̄: 2.26 x̃: 3 helped stats (rel) min: 0.15% max: 2.23% x̄: 1.06% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.17 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.76% x̃: 0.48% 95% mean confidence interval for instructions value: 0.22 0.61 95% mean confidence interval for instructions %-change: 0.24% 0.48% Instructions are HURT. total loops in shared programs: 639 -> 638 (-0.16%) loops in affected programs: 2 -> 1 (-50.00%) helped: 1 HURT: 0 total cycles in shared programs: 153794236 -> 153546274 (-0.16%) cycles in affected programs: 9947778 -> 9699816 (-2.49%) helped: 110 HURT: 31 helped stats (abs) min: 4 max: 13400 x̄: 2257.51 x̃: 1796 helped stats (rel) min: 0.01% max: 35.58% x̄: 4.33% x̃: 2.45% HURT stats (abs) min: 2 max: 14 x̄: 11.74 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2113.77 -1403.42 95% mean confidence interval for cycles %-change: -4.27% -2.47% Cycles are helped. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2899 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12064>
2021-07-26 23:25:58 +10:00
static bool
set_block_for_loop_instr(struct gcm_state *state, nir_instr *instr,
nir_block *block)
{
/* If the instruction wasn't in a loop to begin with we don't want to push
* it down into one.
*/
nir_loop *loop = state->blocks[instr->block->index].loop;
if (loop == NULL)
return true;
nir: add heuristic for instructions in loops with GCM Moving instructions out of large loops tends to cause excessive spilling. This appears to be a good limit. In future it might make sense to make this a NIR options so other drivers can set their own limits. Tiger Lake total instructions in shared programs: 20930180 -> 20926952 (-0.02%) instructions in affected programs: 280768 -> 277540 (-1.15%) helped: 734 HURT: 192 helped stats (abs) min: 1 max: 61 x̄: 5.16 x̃: 4 helped stats (rel) min: 0.04% max: 10.64% x̄: 3.23% x̃: 3.14% HURT stats (abs) min: 1 max: 52 x̄: 2.90 x̃: 1 HURT stats (rel) min: 0.03% max: 9.76% x̄: 1.13% x̃: 0.61% 95% mean confidence interval for instructions value: -3.89 -3.08 95% mean confidence interval for instructions %-change: -2.49% -2.16% Instructions are helped. total cycles in shared programs: 841825217 -> 838817552 (-0.36%) cycles in affected programs: 122088078 -> 119080413 (-2.46%) helped: 941 HURT: 100 helped stats (abs) min: 1 max: 160080 x̄: 3274.31 x̃: 2660 helped stats (rel) min: <.01% max: 41.64% x̄: 5.50% x̃: 4.80% HURT stats (abs) min: 1 max: 41856 x̄: 734.62 x̃: 26 HURT stats (rel) min: <.01% max: 7.29% x̄: 0.44% x̃: 0.27% 95% mean confidence interval for cycles value: -3236.56 -2541.85 95% mean confidence interval for cycles %-change: -5.26% -4.60% Cycles are helped. total sends in shared programs: 977905 -> 977782 (-0.01%) sends in affected programs: 2279 -> 2156 (-5.40%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.93% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.42% -6.45% Sends are helped. LOST: 2 GAINED: 0 Ice Lake total instructions in shared programs: 19865361 -> 19861747 (-0.02%) instructions in affected programs: 185789 -> 182175 (-1.95%) helped: 593 HURT: 47 helped stats (abs) min: 1 max: 27 x̄: 6.17 x̃: 4 helped stats (rel) min: 0.19% max: 8.65% x̄: 4.53% x̃: 4.60% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.23% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -5.93 -5.37 95% mean confidence interval for instructions %-change: -4.32% -4.06% Instructions are helped. total loops in shared programs: 6120 -> 6117 (-0.05%) loops in affected programs: 6 -> 3 (-50.00%) helped: 3 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% total cycles in shared programs: 961777176 -> 959404350 (-0.25%) cycles in affected programs: 172224180 -> 169851354 (-1.38%) helped: 936 HURT: 80 helped stats (abs) min: 1 max: 9566 x̄: 2621.08 x̃: 2550 helped stats (rel) min: <.01% max: 41.77% x̄: 4.22% x̃: 3.84% HURT stats (abs) min: 1 max: 59146 x̄: 1006.34 x̃: 24 HURT stats (rel) min: <.01% max: 3.78% x̄: 0.44% x̃: 0.25% 95% mean confidence interval for cycles value: -2513.72 -2157.20 95% mean confidence interval for cycles %-change: -4.13% -3.57% Cycles are helped. total sends in shared programs: 1019995 -> 1019872 (-0.01%) sends in affected programs: 2283 -> 2160 (-5.39%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.39% -6.42% Sends are helped. LOST: 4 GAINED: 0 Skylake total instructions in shared programs: 17994337 -> 17993846 (<.01%) instructions in affected programs: 146294 -> 145803 (-0.34%) helped: 190 HURT: 47 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.14% max: 4.29% x̄: 1.08% x̃: 0.90% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.22% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -2.30 -1.84 95% mean confidence interval for instructions %-change: -0.95% -0.74% Instructions are helped. total loops in shared programs: 6029 -> 6023 (-0.10%) loops in affected programs: 12 -> 6 (-50.00%) helped: 6 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 939062940 -> 938023548 (-0.11%) cycles in affected programs: 169671482 -> 168632090 (-0.61%) helped: 980 HURT: 134 helped stats (abs) min: 1 max: 25000 x̄: 1075.57 x̃: 1052 helped stats (rel) min: <.01% max: 42.75% x̄: 2.51% x̃: 1.32% HURT stats (abs) min: 1 max: 837 x̄: 109.45 x̃: 20 HURT stats (rel) min: <.01% max: 5.71% x̄: 0.73% x̃: 0.21% 95% mean confidence interval for cycles value: -1005.89 -860.17 95% mean confidence interval for cycles %-change: -2.39% -1.84% Cycles are helped. total sends in shared programs: 1026848 -> 1026724 (-0.01%) sends in affected programs: 2302 -> 2178 (-5.39%) helped: 120 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.40% -6.43% Sends are helped. LOST: 1 GAINED: 1 Broadwell total instructions in shared programs: 17605621 -> 17605154 (<.01%) instructions in affected programs: 145691 -> 145224 (-0.32%) helped: 184 HURT: 48 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.13% max: 4.29% x̄: 1.09% x̃: 0.93% HURT stats (abs) min: 1 max: 7 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 0.48% x̄: 0.12% x̃: 0.04% 95% mean confidence interval for instructions value: -2.26 -1.77 95% mean confidence interval for instructions %-change: -0.95% -0.73% Instructions are helped. total loops in shared programs: 5968 -> 5963 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 1000679489 -> 998592756 (-0.21%) cycles in affected programs: 173421234 -> 171334501 (-1.20%) helped: 993 HURT: 153 helped stats (abs) min: 1 max: 766608 x̄: 2118.49 x̃: 1080 helped stats (rel) min: <.01% max: 54.61% x̄: 2.61% x̃: 1.73% HURT stats (abs) min: 1 max: 2200 x̄: 110.61 x̃: 11 HURT stats (rel) min: <.01% max: 5.68% x̄: 0.63% x̃: 0.06% 95% mean confidence interval for cycles value: -3191.23 -450.54 95% mean confidence interval for cycles %-change: -2.47% -1.89% Cycles are helped. total sends in shared programs: 996341 -> 996222 (-0.01%) sends in affected programs: 2151 -> 2032 (-5.53%) helped: 115 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 7.07% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.55% -6.58% Sends are helped. Haswell total instructions in shared programs: 16038375 -> 16038121 (<.01%) instructions in affected programs: 216797 -> 216543 (-0.12%) helped: 185 HURT: 217 helped stats (abs) min: 1 max: 12 x̄: 2.84 x̃: 3 helped stats (rel) min: 0.13% max: 4.23% x̄: 1.30% x̃: 1.20% HURT stats (abs) min: 1 max: 6 x̄: 1.25 x̃: 1 HURT stats (rel) min: 0.03% max: 5.66% x̄: 0.61% x̃: 0.40% 95% mean confidence interval for instructions value: -0.85 -0.41 95% mean confidence interval for instructions %-change: -0.40% -0.14% Instructions are helped. total loops in shared programs: 5947 -> 5942 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 967655093 -> 965746713 (-0.20%) cycles in affected programs: 197288924 -> 195380544 (-0.97%) helped: 950 HURT: 195 helped stats (abs) min: 1 max: 782820 x̄: 2274.79 x̃: 1260 helped stats (rel) min: <.01% max: 54.26% x̄: 3.02% x̃: 1.71% HURT stats (abs) min: 1 max: 15790 x̄: 1295.73 x̃: 21 HURT stats (rel) min: <.01% max: 119.85% x̄: 7.76% x̃: 0.11% 95% mean confidence interval for cycles value: -3014.22 -319.19 95% mean confidence interval for cycles %-change: -1.83% -0.55% Cycles are helped. total sends in shared programs: 934894 -> 934765 (-0.01%) sends in affected programs: 2192 -> 2063 (-5.89%) helped: 115 HURT: 2 helped stats (abs) min: 1 max: 4 x̄: 1.14 x̃: 1 helped stats (rel) min: 0.60% max: 28.57% x̄: 7.68% x̃: 6.67% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 16.67% max: 16.67% x̄: 16.67% x̃: 16.67% 95% mean confidence interval for sends value: -1.23 -0.98 95% mean confidence interval for sends %-change: -8.28% -6.24% Sends are helped. LOST: 1 GAINED: 18 Ivy Bridge total instructions in shared programs: 15269357 -> 15269398 (<.01%) instructions in affected programs: 190484 -> 190525 (0.02%) helped: 77 HURT: 206 helped stats (abs) min: 1 max: 6 x̄: 2.47 x̃: 3 helped stats (rel) min: 0.14% max: 5.31% x̄: 1.46% x̃: 1.65% HURT stats (abs) min: 1 max: 3 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 2.38% x̄: 0.42% x̃: 0.40% 95% mean confidence interval for instructions value: -0.06 0.35 95% mean confidence interval for instructions %-change: -0.21% 0.03% Inconclusive result (value mean confidence interval includes 0). total loops in shared programs: 4001 -> 3996 (-0.12%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 562045564 -> 561063543 (-0.17%) cycles in affected programs: 200924872 -> 199942851 (-0.49%) helped: 748 HURT: 160 helped stats (abs) min: 2 max: 14926 x̄: 1692.94 x̃: 1620 helped stats (rel) min: <.01% max: 53.29% x̄: 3.17% x̃: 1.87% HURT stats (abs) min: 2 max: 15726 x̄: 1776.86 x̃: 36 HURT stats (rel) min: <.01% max: 114.43% x̄: 10.66% x̃: 0.21% 95% mean confidence interval for cycles value: -1237.33 -925.71 95% mean confidence interval for cycles %-change: -1.54% 0.08% Inconclusive result (%-change mean confidence interval includes 0). total sends in shared programs: 893348 -> 893330 (<.01%) sends in affected programs: 187 -> 169 (-9.63%) helped: 14 HURT: 0 helped stats (abs) min: 1 max: 2 x̄: 1.29 x̃: 1 helped stats (rel) min: 4.08% max: 22.22% x̄: 11.70% x̃: 10.10% 95% mean confidence interval for sends value: -1.56 -1.02 95% mean confidence interval for sends %-change: -14.92% -8.48% Sends are helped. LOST: 1 GAINED: 19 Sandy Bridge total instructions in shared programs: 11785227 -> 11785774 (<.01%) instructions in affected programs: 78403 -> 78950 (0.70%) helped: 65 HURT: 505 helped stats (abs) min: 1 max: 4 x̄: 2.22 x̃: 3 helped stats (rel) min: 0.14% max: 4.17% x̄: 1.19% x̃: 1.38% HURT stats (abs) min: 1 max: 5 x̄: 1.37 x̃: 1 HURT stats (rel) min: 0.24% max: 3.33% x̄: 1.57% x̃: 1.72% 95% mean confidence interval for instructions value: 0.85 1.07 95% mean confidence interval for instructions %-change: 1.16% 1.36% Instructions are HURT. total loops in shared programs: 2441 -> 2437 (-0.16%) loops in affected programs: 8 -> 4 (-50.00%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 497178796 -> 496669298 (-0.10%) cycles in affected programs: 51483322 -> 50973824 (-0.99%) helped: 476 HURT: 137 helped stats (abs) min: 2 max: 7502 x̄: 1079.36 x̃: 1260 helped stats (rel) min: <.01% max: 42.50% x̄: 2.31% x̃: 0.86% HURT stats (abs) min: 2 max: 754 x̄: 31.23 x̃: 18 HURT stats (rel) min: <.01% max: 3.01% x̄: 0.09% x̃: 0.02% 95% mean confidence interval for cycles value: -901.99 -760.32 95% mean confidence interval for cycles %-change: -2.20% -1.36% Cycles are helped. total sends in shared programs: 642919 -> 642915 (<.01%) sends in affected programs: 32 -> 28 (-12.50%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 11.11% max: 14.29% x̄: 12.70% x̃: 12.70% 95% mean confidence interval for sends value: -1.00 -1.00 95% mean confidence interval for sends %-change: -15.61% -9.78% Sends are helped. Iron Lake total instructions in shared programs: 8180061 -> 8180248 (<.01%) instructions in affected programs: 65004 -> 65191 (0.29%) helped: 59 HURT: 253 helped stats (abs) min: 1 max: 4 x̄: 2.24 x̃: 3 helped stats (rel) min: 0.16% max: 2.23% x̄: 1.04% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.26 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.93% x̃: 0.60% 95% mean confidence interval for instructions value: 0.43 0.77 95% mean confidence interval for instructions %-change: 0.45% 0.68% Instructions are HURT. total loops in shared programs: 863 -> 861 (-0.23%) loops in affected programs: 4 -> 2 (-50.00%) helped: 2 HURT: 0 total cycles in shared programs: 239357490 -> 238907668 (-0.19%) cycles in affected programs: 17314006 -> 16864184 (-2.60%) helped: 176 HURT: 34 helped stats (abs) min: 4 max: 13400 x̄: 2558.05 x̃: 2920 helped stats (rel) min: 0.01% max: 35.58% x̄: 3.76% x̃: 2.69% HURT stats (abs) min: 2 max: 14 x̄: 11.59 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2440.68 -1843.34 95% mean confidence interval for cycles %-change: -3.78% -2.51% Cycles are helped. GM45 total instructions in shared programs: 4985293 -> 4985401 (<.01%) instructions in affected programs: 58807 -> 58915 (0.18%) helped: 57 HURT: 202 helped stats (abs) min: 1 max: 4 x̄: 2.26 x̃: 3 helped stats (rel) min: 0.15% max: 2.23% x̄: 1.06% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.17 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.76% x̃: 0.48% 95% mean confidence interval for instructions value: 0.22 0.61 95% mean confidence interval for instructions %-change: 0.24% 0.48% Instructions are HURT. total loops in shared programs: 639 -> 638 (-0.16%) loops in affected programs: 2 -> 1 (-50.00%) helped: 1 HURT: 0 total cycles in shared programs: 153794236 -> 153546274 (-0.16%) cycles in affected programs: 9947778 -> 9699816 (-2.49%) helped: 110 HURT: 31 helped stats (abs) min: 4 max: 13400 x̄: 2257.51 x̃: 1796 helped stats (rel) min: 0.01% max: 35.58% x̄: 4.33% x̃: 2.45% HURT stats (abs) min: 2 max: 14 x̄: 11.74 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2113.77 -1403.42 95% mean confidence interval for cycles %-change: -4.27% -2.47% Cycles are helped. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2899 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12064>
2021-07-26 23:25:58 +10:00
if (nir_block_dominates(instr->block, block))
return true;
/* If the loop only executes a single time i.e its wrapped in a:
* do{ ... break; } while(true)
* Don't move the instruction as it will not help anything.
*/
if (loop->info->limiting_terminator == NULL && !loop->info->complex_loop &&
nir_block_ends_in_break(nir_loop_last_block(loop)))
return false;
/* Being too aggressive with how we pull instructions out of loops can
* result in extra register pressure and spilling. For example its fairly
* common for loops in compute shaders to calculate SSBO offsets using
* the workgroup id, subgroup id and subgroup invocation, pulling all
* these calculations outside the loop causes register pressure.
*
* To work around these issues for now we only allow constant and texture
* instructions to be moved outside their original loops, or instructions
* where the total loop instruction count is less than
* MAX_LOOP_INSTRUCTIONS.
*
* TODO: figure out some more heuristics to allow more to be moved out of
* loops.
*/
if (state->blocks[instr->block->index].loop_instr_count < MAX_LOOP_INSTRUCTIONS)
return true;
if (instr->type == nir_instr_type_load_const ||
instr->type == nir_instr_type_tex)
return true;
return false;
}
nir/gcm: fix pushing instructions into if blocks The previous logic would just set the block to the instructions original location if we couldn't evict it from a loop. For now we only push const loads to a later block inside ifs but we can add more heuristics later. This change helps a hand full of shaders but also stops a CTS regression caused by excess spilling after a series I'm working on to disable more of the GLSL IR optimisation passes. Shader-db results iris (BDW): total instructions in shared programs: 17529759 -> 17529749 (<.01%) instructions in affected programs: 15929 -> 15919 (-0.06%) helped: 5 HURT: 2 helped stats (abs) min: 1 max: 5 x̄: 2.40 x̃: 2 helped stats (rel) min: 0.06% max: 0.15% x̄: 0.11% x̃: 0.12% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.06% max: 0.06% x̄: 0.06% x̃: 0.06% 95% mean confidence interval for instructions value: -3.34 0.49 95% mean confidence interval for instructions %-change: -0.14% 0.02% Inconclusive result (value mean confidence interval includes 0). total cycles in shared programs: 861109994 -> 861099681 (<.01%) cycles in affected programs: 7027698 -> 7017385 (-0.15%) helped: 95 HURT: 72 helped stats (abs) min: 1 max: 7995 x̄: 138.54 x̃: 9 helped stats (rel) min: <.01% max: 15.96% x̄: 0.54% x̃: 0.11% HURT stats (abs) min: 1 max: 474 x̄: 39.56 x̃: 12 HURT stats (rel) min: <.01% max: 1.17% x̄: 0.20% x̃: 0.11% 95% mean confidence interval for cycles value: -159.05 35.54 95% mean confidence interval for cycles %-change: -0.45% 0.01% Inconclusive result (value mean confidence interval includes 0). total spills in shared programs: 17606 -> 17605 (<.01%) spills in affected programs: 323 -> 322 (-0.31%) helped: 1 HURT: 0 total fills in shared programs: 22599 -> 22598 (<.01%) fills in affected programs: 1348 -> 1347 (-0.07%) helped: 1 HURT: 0 Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14940>
2022-02-07 19:10:13 +11:00
static bool
set_block_to_if_block(struct gcm_state *state, nir_instr *instr,
nir_block *block)
{
if (instr->type == nir_instr_type_load_const)
return true;
/* TODO: Figure out some more heuristics to allow more to be moved into
* if-statements.
*/
return false;
}
static nir_block *
gcm_choose_block_for_instr(nir_instr *instr, nir_block *early_block,
nir_block *late_block, struct gcm_state *state)
{
assert(nir_block_dominates(early_block, late_block));
nir/gcm: fix pushing instructions into if blocks The previous logic would just set the block to the instructions original location if we couldn't evict it from a loop. For now we only push const loads to a later block inside ifs but we can add more heuristics later. This change helps a hand full of shaders but also stops a CTS regression caused by excess spilling after a series I'm working on to disable more of the GLSL IR optimisation passes. Shader-db results iris (BDW): total instructions in shared programs: 17529759 -> 17529749 (<.01%) instructions in affected programs: 15929 -> 15919 (-0.06%) helped: 5 HURT: 2 helped stats (abs) min: 1 max: 5 x̄: 2.40 x̃: 2 helped stats (rel) min: 0.06% max: 0.15% x̄: 0.11% x̃: 0.12% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.06% max: 0.06% x̄: 0.06% x̃: 0.06% 95% mean confidence interval for instructions value: -3.34 0.49 95% mean confidence interval for instructions %-change: -0.14% 0.02% Inconclusive result (value mean confidence interval includes 0). total cycles in shared programs: 861109994 -> 861099681 (<.01%) cycles in affected programs: 7027698 -> 7017385 (-0.15%) helped: 95 HURT: 72 helped stats (abs) min: 1 max: 7995 x̄: 138.54 x̃: 9 helped stats (rel) min: <.01% max: 15.96% x̄: 0.54% x̃: 0.11% HURT stats (abs) min: 1 max: 474 x̄: 39.56 x̃: 12 HURT stats (rel) min: <.01% max: 1.17% x̄: 0.20% x̃: 0.11% 95% mean confidence interval for cycles value: -159.05 35.54 95% mean confidence interval for cycles %-change: -0.45% 0.01% Inconclusive result (value mean confidence interval includes 0). total spills in shared programs: 17606 -> 17605 (<.01%) spills in affected programs: 323 -> 322 (-0.31%) helped: 1 HURT: 0 total fills in shared programs: 22599 -> 22598 (<.01%) fills in affected programs: 1348 -> 1347 (-0.07%) helped: 1 HURT: 0 Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14940>
2022-02-07 19:10:13 +11:00
bool block_set = false;
/* First see if we can push the instruction down into an if-statements block */
nir_block *best = late_block;
nir/gcm: fix pushing instructions into if blocks The previous logic would just set the block to the instructions original location if we couldn't evict it from a loop. For now we only push const loads to a later block inside ifs but we can add more heuristics later. This change helps a hand full of shaders but also stops a CTS regression caused by excess spilling after a series I'm working on to disable more of the GLSL IR optimisation passes. Shader-db results iris (BDW): total instructions in shared programs: 17529759 -> 17529749 (<.01%) instructions in affected programs: 15929 -> 15919 (-0.06%) helped: 5 HURT: 2 helped stats (abs) min: 1 max: 5 x̄: 2.40 x̃: 2 helped stats (rel) min: 0.06% max: 0.15% x̄: 0.11% x̃: 0.12% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.06% max: 0.06% x̄: 0.06% x̃: 0.06% 95% mean confidence interval for instructions value: -3.34 0.49 95% mean confidence interval for instructions %-change: -0.14% 0.02% Inconclusive result (value mean confidence interval includes 0). total cycles in shared programs: 861109994 -> 861099681 (<.01%) cycles in affected programs: 7027698 -> 7017385 (-0.15%) helped: 95 HURT: 72 helped stats (abs) min: 1 max: 7995 x̄: 138.54 x̃: 9 helped stats (rel) min: <.01% max: 15.96% x̄: 0.54% x̃: 0.11% HURT stats (abs) min: 1 max: 474 x̄: 39.56 x̃: 12 HURT stats (rel) min: <.01% max: 1.17% x̄: 0.20% x̃: 0.11% 95% mean confidence interval for cycles value: -159.05 35.54 95% mean confidence interval for cycles %-change: -0.45% 0.01% Inconclusive result (value mean confidence interval includes 0). total spills in shared programs: 17606 -> 17605 (<.01%) spills in affected programs: 323 -> 322 (-0.31%) helped: 1 HURT: 0 total fills in shared programs: 22599 -> 22598 (<.01%) fills in affected programs: 1348 -> 1347 (-0.07%) helped: 1 HURT: 0 Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14940>
2022-02-07 19:10:13 +11:00
for (nir_block *block = late_block; block != NULL; block = block->imm_dom) {
if (state->blocks[block->index].loop_depth >
state->blocks[instr->block->index].loop_depth)
continue;
if (state->blocks[block->index].if_depth >=
state->blocks[best->index].if_depth &&
set_block_to_if_block(state, instr, block)) {
/* If we are pushing the instruction into an if we want it to be
* in the earliest block not the latest to avoid creating register
* pressure issues. So we don't break unless we come across the
* block the instruction was originally in.
*/
best = block;
block_set = true;
if (block == instr->block)
break;
} else if (block == instr->block) {
/* If we couldn't push the instruction later just put is back where it
* was previously.
*/
if (!block_set)
best = block;
break;
}
if (block == early_block)
break;
}
/* Now see if we can evict the instruction from a loop */
for (nir_block *block = late_block; block != NULL; block = block->imm_dom) {
if (state->blocks[block->index].loop_depth <
nir/gcm: fix pushing instructions into if blocks The previous logic would just set the block to the instructions original location if we couldn't evict it from a loop. For now we only push const loads to a later block inside ifs but we can add more heuristics later. This change helps a hand full of shaders but also stops a CTS regression caused by excess spilling after a series I'm working on to disable more of the GLSL IR optimisation passes. Shader-db results iris (BDW): total instructions in shared programs: 17529759 -> 17529749 (<.01%) instructions in affected programs: 15929 -> 15919 (-0.06%) helped: 5 HURT: 2 helped stats (abs) min: 1 max: 5 x̄: 2.40 x̃: 2 helped stats (rel) min: 0.06% max: 0.15% x̄: 0.11% x̃: 0.12% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.06% max: 0.06% x̄: 0.06% x̃: 0.06% 95% mean confidence interval for instructions value: -3.34 0.49 95% mean confidence interval for instructions %-change: -0.14% 0.02% Inconclusive result (value mean confidence interval includes 0). total cycles in shared programs: 861109994 -> 861099681 (<.01%) cycles in affected programs: 7027698 -> 7017385 (-0.15%) helped: 95 HURT: 72 helped stats (abs) min: 1 max: 7995 x̄: 138.54 x̃: 9 helped stats (rel) min: <.01% max: 15.96% x̄: 0.54% x̃: 0.11% HURT stats (abs) min: 1 max: 474 x̄: 39.56 x̃: 12 HURT stats (rel) min: <.01% max: 1.17% x̄: 0.20% x̃: 0.11% 95% mean confidence interval for cycles value: -159.05 35.54 95% mean confidence interval for cycles %-change: -0.45% 0.01% Inconclusive result (value mean confidence interval includes 0). total spills in shared programs: 17606 -> 17605 (<.01%) spills in affected programs: 323 -> 322 (-0.31%) helped: 1 HURT: 0 total fills in shared programs: 22599 -> 22598 (<.01%) fills in affected programs: 1348 -> 1347 (-0.07%) helped: 1 HURT: 0 Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14940>
2022-02-07 19:10:13 +11:00
state->blocks[best->index].loop_depth) {
if (set_block_for_loop_instr(state, instr, block)) {
best = block;
} else if (block == instr->block) {
if (!block_set)
best = block;
break;
}
}
if (block == early_block)
break;
}
return best;
}
static void
gcm_schedule_late_instr(nir_instr *instr, struct gcm_state *state);
/** Schedules the instruction associated with the given SSA def late
*
* This function works by first walking all of the uses of the given SSA
* definition, ensuring that they are scheduled, and then computing the LCA
* (least common ancestor) of its uses. It then schedules this instruction
* as close to the LCA as possible while trying to stay out of loops.
*/
static bool
gcm_schedule_late_def(nir_ssa_def *def, void *void_state)
{
struct gcm_state *state = void_state;
nir_block *lca = NULL;
nir_foreach_use(use_src, def) {
nir/nir: Use a linked list instead of a hash set for use/def sets This commit switches us from the current setup of using hash sets for use/def sets to using linked lists. Doing so should save us quite a bit of memory because we aren't carrying around 3 hash sets per register and 2 per SSA value. It should also save us CPU time because adding/removing things from use/def sets is 4 pointer manipulations instead of a hash lookup. Running shader-db 50 times with USE_NIR=0, NIR, and NIR + use/def lists: GLSL IR Only: 586.4 +/- 1.653833 NIR with hash sets: 675.4 +/- 2.502108 NIR + use/def lists: 641.2 +/- 1.557043 I also ran a memory usage experiment with Ken's patch to delete GLSL IR and keep NIR. This patch cuts an aditional 42.9 MiB of ralloc'd memory over and above what we gained by deleting the GLSL IR on the same dota trace. On the code complexity side of things, some things are now much easier and others are a bit harder. One of the operations we perform constantly in optimization passes is to replace one source with another. Due to the fact that an instruction can use the same SSA value multiple times, we had to iterate through the sources of the instruction and determine if the use we were replacing was the only one before removing it from the set of uses. With this patch, uses are per-source not per-instruction so we can just remove it safely. On the other hand, trying to iterate over all of the instructions that use a given value is more difficult. Fortunately, the two places we do that are the ffma peephole where it doesn't matter and GCM where we already gracefully handle duplicates visits to an instruction. Another aspect here is that using linked lists in this way can be tricky to get right. With sets, things were quite forgiving and the worst that happened if you didn't properly remove a use was that it would get caught in the validator. With linked lists, it can lead to linked list corruption which can be harder to track. However, we do just as much validation of the linked lists as we did of the sets so the validator should still catch these problems. While working on this series, the vast majority of the bugs I had to fix were caught by assertions. I don't think the lists are going to be that much worse than the sets. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
2015-04-24 10:16:27 -07:00
nir_instr *use_instr = use_src->parent_instr;
gcm_schedule_late_instr(use_instr, state);
/* Phi instructions are a bit special. SSA definitions don't have to
* dominate the sources of the phi nodes that use them; instead, they
* have to dominate the predecessor block corresponding to the phi
* source. We handle this by looking through the sources, finding
* any that are usingg this SSA def, and using those blocks instead
* of the one the phi lives in.
*/
if (use_instr->type == nir_instr_type_phi) {
nir_phi_instr *phi = nir_instr_as_phi(use_instr);
nir_foreach_phi_src(phi_src, phi) {
if (phi_src->src.ssa == def)
lca = nir_dominance_lca(lca, phi_src->pred);
}
} else {
lca = nir_dominance_lca(lca, use_instr->block);
}
}
nir_foreach_if_use(use_src, def) {
nir/nir: Use a linked list instead of a hash set for use/def sets This commit switches us from the current setup of using hash sets for use/def sets to using linked lists. Doing so should save us quite a bit of memory because we aren't carrying around 3 hash sets per register and 2 per SSA value. It should also save us CPU time because adding/removing things from use/def sets is 4 pointer manipulations instead of a hash lookup. Running shader-db 50 times with USE_NIR=0, NIR, and NIR + use/def lists: GLSL IR Only: 586.4 +/- 1.653833 NIR with hash sets: 675.4 +/- 2.502108 NIR + use/def lists: 641.2 +/- 1.557043 I also ran a memory usage experiment with Ken's patch to delete GLSL IR and keep NIR. This patch cuts an aditional 42.9 MiB of ralloc'd memory over and above what we gained by deleting the GLSL IR on the same dota trace. On the code complexity side of things, some things are now much easier and others are a bit harder. One of the operations we perform constantly in optimization passes is to replace one source with another. Due to the fact that an instruction can use the same SSA value multiple times, we had to iterate through the sources of the instruction and determine if the use we were replacing was the only one before removing it from the set of uses. With this patch, uses are per-source not per-instruction so we can just remove it safely. On the other hand, trying to iterate over all of the instructions that use a given value is more difficult. Fortunately, the two places we do that are the ffma peephole where it doesn't matter and GCM where we already gracefully handle duplicates visits to an instruction. Another aspect here is that using linked lists in this way can be tricky to get right. With sets, things were quite forgiving and the worst that happened if you didn't properly remove a use was that it would get caught in the validator. With linked lists, it can lead to linked list corruption which can be harder to track. However, we do just as much validation of the linked lists as we did of the sets so the validator should still catch these problems. While working on this series, the vast majority of the bugs I had to fix were caught by assertions. I don't think the lists are going to be that much worse than the sets. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
2015-04-24 10:16:27 -07:00
nir_if *if_stmt = use_src->parent_if;
/* For if statements, we consider the block to be the one immediately
* preceding the if CF node.
*/
nir_block *pred_block =
nir_cf_node_as_block(nir_cf_node_prev(&if_stmt->cf_node));
lca = nir_dominance_lca(lca, pred_block);
}
nir_block *early_block =
state->instr_infos[def->parent_instr->index].early_block;
/* Some instructions may never be used. Flag them and the instruction
* placement code will get rid of them for us.
*/
if (lca == NULL) {
def->parent_instr->block = NULL;
return true;
}
if (def->parent_instr->pass_flags & GCM_INSTR_SCHEDULE_EARLIER_ONLY &&
lca != def->parent_instr->block &&
nir_block_dominates(def->parent_instr->block, lca)) {
lca = def->parent_instr->block;
}
/* We now have the LCA of all of the uses. If our invariants hold,
* this is dominated by the block that we chose when scheduling early.
* We now walk up the dominance tree and pick the lowest block that is
* as far outside loops as we can get.
*/
nir_block *best_block =
gcm_choose_block_for_instr(def->parent_instr, early_block, lca, state);
if (def->parent_instr->block != best_block)
state->progress = true;
def->parent_instr->block = best_block;
return true;
}
/** Schedules an instruction late
*
* This function performs a depth-first search starting at the given
* instruction and proceeding through its uses to schedule instructions as
* late as they can reasonably go in the dominance tree. The instructions
* are "scheduled" by updating their instr->block field.
*
* The name of this function is actually a bit of a misnomer as it doesn't
* schedule them "as late as possible" as the paper implies. Instead, it
* first finds the lates possible place it can schedule the instruction and
* then possibly schedules it earlier than that. The actual location is as
* far down the tree as we can go while trying to stay out of loops.
*/
static void
gcm_schedule_late_instr(nir_instr *instr, struct gcm_state *state)
{
if (instr->pass_flags & GCM_INSTR_SCHEDULED_LATE)
return;
instr->pass_flags |= GCM_INSTR_SCHEDULED_LATE;
/* Pinned/placed instructions are already scheduled so we don't need to do
* anything. Also, bailing here keeps us from ever following phi nodes
* which can be back-edges.
*/
if (instr->pass_flags & GCM_INSTR_PLACED ||
instr->pass_flags & GCM_INSTR_PINNED)
return;
nir_foreach_ssa_def(instr, gcm_schedule_late_def, state);
}
static bool
gcm_replace_def_with_undef(nir_ssa_def *def, void *void_state)
{
struct gcm_state *state = void_state;
if (nir_ssa_def_is_unused(def))
return true;
nir_ssa_undef_instr *undef =
nir_ssa_undef_instr_create(state->impl->function->shader,
def->num_components, def->bit_size);
nir_instr_insert(nir_before_cf_list(&state->impl->body), &undef->instr);
nir_ssa_def_rewrite_uses(def, &undef->def);
return true;
}
/** Places an instrution back into the program
*
* The earlier passes of GCM simply choose blocks for each instruction and
* otherwise leave them alone. This pass actually places the instructions
* into their chosen blocks.
*
* To do so, we simply insert instructions in the reverse order they were
* extracted. This will simply place instructions that were scheduled earlier
* onto the end of their new block and instructions that were scheduled later to
* the start of their new block.
*/
static void
gcm_place_instr(nir_instr *instr, struct gcm_state *state)
{
if (instr->pass_flags & GCM_INSTR_PLACED)
return;
instr->pass_flags |= GCM_INSTR_PLACED;
if (instr->block == NULL) {
nir_foreach_ssa_def(instr, gcm_replace_def_with_undef, state);
nir_instr_remove(instr);
return;
}
struct gcm_block_info *block_info = &state->blocks[instr->block->index];
exec_node_remove(&instr->node);
if (block_info->last_instr) {
exec_node_insert_node_before(&block_info->last_instr->node,
&instr->node);
} else {
/* Schedule it at the end of the block */
nir_instr *jump_instr = nir_block_last_instr(instr->block);
if (jump_instr && jump_instr->type == nir_instr_type_jump) {
exec_node_insert_node_before(&jump_instr->node, &instr->node);
} else {
exec_list_push_tail(&instr->block->instr_list, &instr->node);
}
}
block_info->last_instr = instr;
}
static bool
nir: add heuristic for instructions in loops with GCM Moving instructions out of large loops tends to cause excessive spilling. This appears to be a good limit. In future it might make sense to make this a NIR options so other drivers can set their own limits. Tiger Lake total instructions in shared programs: 20930180 -> 20926952 (-0.02%) instructions in affected programs: 280768 -> 277540 (-1.15%) helped: 734 HURT: 192 helped stats (abs) min: 1 max: 61 x̄: 5.16 x̃: 4 helped stats (rel) min: 0.04% max: 10.64% x̄: 3.23% x̃: 3.14% HURT stats (abs) min: 1 max: 52 x̄: 2.90 x̃: 1 HURT stats (rel) min: 0.03% max: 9.76% x̄: 1.13% x̃: 0.61% 95% mean confidence interval for instructions value: -3.89 -3.08 95% mean confidence interval for instructions %-change: -2.49% -2.16% Instructions are helped. total cycles in shared programs: 841825217 -> 838817552 (-0.36%) cycles in affected programs: 122088078 -> 119080413 (-2.46%) helped: 941 HURT: 100 helped stats (abs) min: 1 max: 160080 x̄: 3274.31 x̃: 2660 helped stats (rel) min: <.01% max: 41.64% x̄: 5.50% x̃: 4.80% HURT stats (abs) min: 1 max: 41856 x̄: 734.62 x̃: 26 HURT stats (rel) min: <.01% max: 7.29% x̄: 0.44% x̃: 0.27% 95% mean confidence interval for cycles value: -3236.56 -2541.85 95% mean confidence interval for cycles %-change: -5.26% -4.60% Cycles are helped. total sends in shared programs: 977905 -> 977782 (-0.01%) sends in affected programs: 2279 -> 2156 (-5.40%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.93% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.42% -6.45% Sends are helped. LOST: 2 GAINED: 0 Ice Lake total instructions in shared programs: 19865361 -> 19861747 (-0.02%) instructions in affected programs: 185789 -> 182175 (-1.95%) helped: 593 HURT: 47 helped stats (abs) min: 1 max: 27 x̄: 6.17 x̃: 4 helped stats (rel) min: 0.19% max: 8.65% x̄: 4.53% x̃: 4.60% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.23% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -5.93 -5.37 95% mean confidence interval for instructions %-change: -4.32% -4.06% Instructions are helped. total loops in shared programs: 6120 -> 6117 (-0.05%) loops in affected programs: 6 -> 3 (-50.00%) helped: 3 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% total cycles in shared programs: 961777176 -> 959404350 (-0.25%) cycles in affected programs: 172224180 -> 169851354 (-1.38%) helped: 936 HURT: 80 helped stats (abs) min: 1 max: 9566 x̄: 2621.08 x̃: 2550 helped stats (rel) min: <.01% max: 41.77% x̄: 4.22% x̃: 3.84% HURT stats (abs) min: 1 max: 59146 x̄: 1006.34 x̃: 24 HURT stats (rel) min: <.01% max: 3.78% x̄: 0.44% x̃: 0.25% 95% mean confidence interval for cycles value: -2513.72 -2157.20 95% mean confidence interval for cycles %-change: -4.13% -3.57% Cycles are helped. total sends in shared programs: 1019995 -> 1019872 (-0.01%) sends in affected programs: 2283 -> 2160 (-5.39%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.39% -6.42% Sends are helped. LOST: 4 GAINED: 0 Skylake total instructions in shared programs: 17994337 -> 17993846 (<.01%) instructions in affected programs: 146294 -> 145803 (-0.34%) helped: 190 HURT: 47 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.14% max: 4.29% x̄: 1.08% x̃: 0.90% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.22% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -2.30 -1.84 95% mean confidence interval for instructions %-change: -0.95% -0.74% Instructions are helped. total loops in shared programs: 6029 -> 6023 (-0.10%) loops in affected programs: 12 -> 6 (-50.00%) helped: 6 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 939062940 -> 938023548 (-0.11%) cycles in affected programs: 169671482 -> 168632090 (-0.61%) helped: 980 HURT: 134 helped stats (abs) min: 1 max: 25000 x̄: 1075.57 x̃: 1052 helped stats (rel) min: <.01% max: 42.75% x̄: 2.51% x̃: 1.32% HURT stats (abs) min: 1 max: 837 x̄: 109.45 x̃: 20 HURT stats (rel) min: <.01% max: 5.71% x̄: 0.73% x̃: 0.21% 95% mean confidence interval for cycles value: -1005.89 -860.17 95% mean confidence interval for cycles %-change: -2.39% -1.84% Cycles are helped. total sends in shared programs: 1026848 -> 1026724 (-0.01%) sends in affected programs: 2302 -> 2178 (-5.39%) helped: 120 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.40% -6.43% Sends are helped. LOST: 1 GAINED: 1 Broadwell total instructions in shared programs: 17605621 -> 17605154 (<.01%) instructions in affected programs: 145691 -> 145224 (-0.32%) helped: 184 HURT: 48 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.13% max: 4.29% x̄: 1.09% x̃: 0.93% HURT stats (abs) min: 1 max: 7 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 0.48% x̄: 0.12% x̃: 0.04% 95% mean confidence interval for instructions value: -2.26 -1.77 95% mean confidence interval for instructions %-change: -0.95% -0.73% Instructions are helped. total loops in shared programs: 5968 -> 5963 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 1000679489 -> 998592756 (-0.21%) cycles in affected programs: 173421234 -> 171334501 (-1.20%) helped: 993 HURT: 153 helped stats (abs) min: 1 max: 766608 x̄: 2118.49 x̃: 1080 helped stats (rel) min: <.01% max: 54.61% x̄: 2.61% x̃: 1.73% HURT stats (abs) min: 1 max: 2200 x̄: 110.61 x̃: 11 HURT stats (rel) min: <.01% max: 5.68% x̄: 0.63% x̃: 0.06% 95% mean confidence interval for cycles value: -3191.23 -450.54 95% mean confidence interval for cycles %-change: -2.47% -1.89% Cycles are helped. total sends in shared programs: 996341 -> 996222 (-0.01%) sends in affected programs: 2151 -> 2032 (-5.53%) helped: 115 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 7.07% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.55% -6.58% Sends are helped. Haswell total instructions in shared programs: 16038375 -> 16038121 (<.01%) instructions in affected programs: 216797 -> 216543 (-0.12%) helped: 185 HURT: 217 helped stats (abs) min: 1 max: 12 x̄: 2.84 x̃: 3 helped stats (rel) min: 0.13% max: 4.23% x̄: 1.30% x̃: 1.20% HURT stats (abs) min: 1 max: 6 x̄: 1.25 x̃: 1 HURT stats (rel) min: 0.03% max: 5.66% x̄: 0.61% x̃: 0.40% 95% mean confidence interval for instructions value: -0.85 -0.41 95% mean confidence interval for instructions %-change: -0.40% -0.14% Instructions are helped. total loops in shared programs: 5947 -> 5942 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 967655093 -> 965746713 (-0.20%) cycles in affected programs: 197288924 -> 195380544 (-0.97%) helped: 950 HURT: 195 helped stats (abs) min: 1 max: 782820 x̄: 2274.79 x̃: 1260 helped stats (rel) min: <.01% max: 54.26% x̄: 3.02% x̃: 1.71% HURT stats (abs) min: 1 max: 15790 x̄: 1295.73 x̃: 21 HURT stats (rel) min: <.01% max: 119.85% x̄: 7.76% x̃: 0.11% 95% mean confidence interval for cycles value: -3014.22 -319.19 95% mean confidence interval for cycles %-change: -1.83% -0.55% Cycles are helped. total sends in shared programs: 934894 -> 934765 (-0.01%) sends in affected programs: 2192 -> 2063 (-5.89%) helped: 115 HURT: 2 helped stats (abs) min: 1 max: 4 x̄: 1.14 x̃: 1 helped stats (rel) min: 0.60% max: 28.57% x̄: 7.68% x̃: 6.67% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 16.67% max: 16.67% x̄: 16.67% x̃: 16.67% 95% mean confidence interval for sends value: -1.23 -0.98 95% mean confidence interval for sends %-change: -8.28% -6.24% Sends are helped. LOST: 1 GAINED: 18 Ivy Bridge total instructions in shared programs: 15269357 -> 15269398 (<.01%) instructions in affected programs: 190484 -> 190525 (0.02%) helped: 77 HURT: 206 helped stats (abs) min: 1 max: 6 x̄: 2.47 x̃: 3 helped stats (rel) min: 0.14% max: 5.31% x̄: 1.46% x̃: 1.65% HURT stats (abs) min: 1 max: 3 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 2.38% x̄: 0.42% x̃: 0.40% 95% mean confidence interval for instructions value: -0.06 0.35 95% mean confidence interval for instructions %-change: -0.21% 0.03% Inconclusive result (value mean confidence interval includes 0). total loops in shared programs: 4001 -> 3996 (-0.12%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 562045564 -> 561063543 (-0.17%) cycles in affected programs: 200924872 -> 199942851 (-0.49%) helped: 748 HURT: 160 helped stats (abs) min: 2 max: 14926 x̄: 1692.94 x̃: 1620 helped stats (rel) min: <.01% max: 53.29% x̄: 3.17% x̃: 1.87% HURT stats (abs) min: 2 max: 15726 x̄: 1776.86 x̃: 36 HURT stats (rel) min: <.01% max: 114.43% x̄: 10.66% x̃: 0.21% 95% mean confidence interval for cycles value: -1237.33 -925.71 95% mean confidence interval for cycles %-change: -1.54% 0.08% Inconclusive result (%-change mean confidence interval includes 0). total sends in shared programs: 893348 -> 893330 (<.01%) sends in affected programs: 187 -> 169 (-9.63%) helped: 14 HURT: 0 helped stats (abs) min: 1 max: 2 x̄: 1.29 x̃: 1 helped stats (rel) min: 4.08% max: 22.22% x̄: 11.70% x̃: 10.10% 95% mean confidence interval for sends value: -1.56 -1.02 95% mean confidence interval for sends %-change: -14.92% -8.48% Sends are helped. LOST: 1 GAINED: 19 Sandy Bridge total instructions in shared programs: 11785227 -> 11785774 (<.01%) instructions in affected programs: 78403 -> 78950 (0.70%) helped: 65 HURT: 505 helped stats (abs) min: 1 max: 4 x̄: 2.22 x̃: 3 helped stats (rel) min: 0.14% max: 4.17% x̄: 1.19% x̃: 1.38% HURT stats (abs) min: 1 max: 5 x̄: 1.37 x̃: 1 HURT stats (rel) min: 0.24% max: 3.33% x̄: 1.57% x̃: 1.72% 95% mean confidence interval for instructions value: 0.85 1.07 95% mean confidence interval for instructions %-change: 1.16% 1.36% Instructions are HURT. total loops in shared programs: 2441 -> 2437 (-0.16%) loops in affected programs: 8 -> 4 (-50.00%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 497178796 -> 496669298 (-0.10%) cycles in affected programs: 51483322 -> 50973824 (-0.99%) helped: 476 HURT: 137 helped stats (abs) min: 2 max: 7502 x̄: 1079.36 x̃: 1260 helped stats (rel) min: <.01% max: 42.50% x̄: 2.31% x̃: 0.86% HURT stats (abs) min: 2 max: 754 x̄: 31.23 x̃: 18 HURT stats (rel) min: <.01% max: 3.01% x̄: 0.09% x̃: 0.02% 95% mean confidence interval for cycles value: -901.99 -760.32 95% mean confidence interval for cycles %-change: -2.20% -1.36% Cycles are helped. total sends in shared programs: 642919 -> 642915 (<.01%) sends in affected programs: 32 -> 28 (-12.50%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 11.11% max: 14.29% x̄: 12.70% x̃: 12.70% 95% mean confidence interval for sends value: -1.00 -1.00 95% mean confidence interval for sends %-change: -15.61% -9.78% Sends are helped. Iron Lake total instructions in shared programs: 8180061 -> 8180248 (<.01%) instructions in affected programs: 65004 -> 65191 (0.29%) helped: 59 HURT: 253 helped stats (abs) min: 1 max: 4 x̄: 2.24 x̃: 3 helped stats (rel) min: 0.16% max: 2.23% x̄: 1.04% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.26 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.93% x̃: 0.60% 95% mean confidence interval for instructions value: 0.43 0.77 95% mean confidence interval for instructions %-change: 0.45% 0.68% Instructions are HURT. total loops in shared programs: 863 -> 861 (-0.23%) loops in affected programs: 4 -> 2 (-50.00%) helped: 2 HURT: 0 total cycles in shared programs: 239357490 -> 238907668 (-0.19%) cycles in affected programs: 17314006 -> 16864184 (-2.60%) helped: 176 HURT: 34 helped stats (abs) min: 4 max: 13400 x̄: 2558.05 x̃: 2920 helped stats (rel) min: 0.01% max: 35.58% x̄: 3.76% x̃: 2.69% HURT stats (abs) min: 2 max: 14 x̄: 11.59 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2440.68 -1843.34 95% mean confidence interval for cycles %-change: -3.78% -2.51% Cycles are helped. GM45 total instructions in shared programs: 4985293 -> 4985401 (<.01%) instructions in affected programs: 58807 -> 58915 (0.18%) helped: 57 HURT: 202 helped stats (abs) min: 1 max: 4 x̄: 2.26 x̃: 3 helped stats (rel) min: 0.15% max: 2.23% x̄: 1.06% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.17 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.76% x̃: 0.48% 95% mean confidence interval for instructions value: 0.22 0.61 95% mean confidence interval for instructions %-change: 0.24% 0.48% Instructions are HURT. total loops in shared programs: 639 -> 638 (-0.16%) loops in affected programs: 2 -> 1 (-50.00%) helped: 1 HURT: 0 total cycles in shared programs: 153794236 -> 153546274 (-0.16%) cycles in affected programs: 9947778 -> 9699816 (-2.49%) helped: 110 HURT: 31 helped stats (abs) min: 4 max: 13400 x̄: 2257.51 x̃: 1796 helped stats (rel) min: 0.01% max: 35.58% x̄: 4.33% x̃: 2.45% HURT stats (abs) min: 2 max: 14 x̄: 11.74 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2113.77 -1403.42 95% mean confidence interval for cycles %-change: -4.27% -2.47% Cycles are helped. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2899 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12064>
2021-07-26 23:25:58 +10:00
opt_gcm_impl(nir_shader *shader, nir_function_impl *impl, bool value_number)
{
nir_metadata_require(impl, nir_metadata_block_index |
nir_metadata_dominance);
nir: add heuristic for instructions in loops with GCM Moving instructions out of large loops tends to cause excessive spilling. This appears to be a good limit. In future it might make sense to make this a NIR options so other drivers can set their own limits. Tiger Lake total instructions in shared programs: 20930180 -> 20926952 (-0.02%) instructions in affected programs: 280768 -> 277540 (-1.15%) helped: 734 HURT: 192 helped stats (abs) min: 1 max: 61 x̄: 5.16 x̃: 4 helped stats (rel) min: 0.04% max: 10.64% x̄: 3.23% x̃: 3.14% HURT stats (abs) min: 1 max: 52 x̄: 2.90 x̃: 1 HURT stats (rel) min: 0.03% max: 9.76% x̄: 1.13% x̃: 0.61% 95% mean confidence interval for instructions value: -3.89 -3.08 95% mean confidence interval for instructions %-change: -2.49% -2.16% Instructions are helped. total cycles in shared programs: 841825217 -> 838817552 (-0.36%) cycles in affected programs: 122088078 -> 119080413 (-2.46%) helped: 941 HURT: 100 helped stats (abs) min: 1 max: 160080 x̄: 3274.31 x̃: 2660 helped stats (rel) min: <.01% max: 41.64% x̄: 5.50% x̃: 4.80% HURT stats (abs) min: 1 max: 41856 x̄: 734.62 x̃: 26 HURT stats (rel) min: <.01% max: 7.29% x̄: 0.44% x̃: 0.27% 95% mean confidence interval for cycles value: -3236.56 -2541.85 95% mean confidence interval for cycles %-change: -5.26% -4.60% Cycles are helped. total sends in shared programs: 977905 -> 977782 (-0.01%) sends in affected programs: 2279 -> 2156 (-5.40%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.93% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.42% -6.45% Sends are helped. LOST: 2 GAINED: 0 Ice Lake total instructions in shared programs: 19865361 -> 19861747 (-0.02%) instructions in affected programs: 185789 -> 182175 (-1.95%) helped: 593 HURT: 47 helped stats (abs) min: 1 max: 27 x̄: 6.17 x̃: 4 helped stats (rel) min: 0.19% max: 8.65% x̄: 4.53% x̃: 4.60% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.23% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -5.93 -5.37 95% mean confidence interval for instructions %-change: -4.32% -4.06% Instructions are helped. total loops in shared programs: 6120 -> 6117 (-0.05%) loops in affected programs: 6 -> 3 (-50.00%) helped: 3 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% total cycles in shared programs: 961777176 -> 959404350 (-0.25%) cycles in affected programs: 172224180 -> 169851354 (-1.38%) helped: 936 HURT: 80 helped stats (abs) min: 1 max: 9566 x̄: 2621.08 x̃: 2550 helped stats (rel) min: <.01% max: 41.77% x̄: 4.22% x̃: 3.84% HURT stats (abs) min: 1 max: 59146 x̄: 1006.34 x̃: 24 HURT stats (rel) min: <.01% max: 3.78% x̄: 0.44% x̃: 0.25% 95% mean confidence interval for cycles value: -2513.72 -2157.20 95% mean confidence interval for cycles %-change: -4.13% -3.57% Cycles are helped. total sends in shared programs: 1019995 -> 1019872 (-0.01%) sends in affected programs: 2283 -> 2160 (-5.39%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.39% -6.42% Sends are helped. LOST: 4 GAINED: 0 Skylake total instructions in shared programs: 17994337 -> 17993846 (<.01%) instructions in affected programs: 146294 -> 145803 (-0.34%) helped: 190 HURT: 47 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.14% max: 4.29% x̄: 1.08% x̃: 0.90% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.22% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -2.30 -1.84 95% mean confidence interval for instructions %-change: -0.95% -0.74% Instructions are helped. total loops in shared programs: 6029 -> 6023 (-0.10%) loops in affected programs: 12 -> 6 (-50.00%) helped: 6 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 939062940 -> 938023548 (-0.11%) cycles in affected programs: 169671482 -> 168632090 (-0.61%) helped: 980 HURT: 134 helped stats (abs) min: 1 max: 25000 x̄: 1075.57 x̃: 1052 helped stats (rel) min: <.01% max: 42.75% x̄: 2.51% x̃: 1.32% HURT stats (abs) min: 1 max: 837 x̄: 109.45 x̃: 20 HURT stats (rel) min: <.01% max: 5.71% x̄: 0.73% x̃: 0.21% 95% mean confidence interval for cycles value: -1005.89 -860.17 95% mean confidence interval for cycles %-change: -2.39% -1.84% Cycles are helped. total sends in shared programs: 1026848 -> 1026724 (-0.01%) sends in affected programs: 2302 -> 2178 (-5.39%) helped: 120 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.40% -6.43% Sends are helped. LOST: 1 GAINED: 1 Broadwell total instructions in shared programs: 17605621 -> 17605154 (<.01%) instructions in affected programs: 145691 -> 145224 (-0.32%) helped: 184 HURT: 48 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.13% max: 4.29% x̄: 1.09% x̃: 0.93% HURT stats (abs) min: 1 max: 7 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 0.48% x̄: 0.12% x̃: 0.04% 95% mean confidence interval for instructions value: -2.26 -1.77 95% mean confidence interval for instructions %-change: -0.95% -0.73% Instructions are helped. total loops in shared programs: 5968 -> 5963 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 1000679489 -> 998592756 (-0.21%) cycles in affected programs: 173421234 -> 171334501 (-1.20%) helped: 993 HURT: 153 helped stats (abs) min: 1 max: 766608 x̄: 2118.49 x̃: 1080 helped stats (rel) min: <.01% max: 54.61% x̄: 2.61% x̃: 1.73% HURT stats (abs) min: 1 max: 2200 x̄: 110.61 x̃: 11 HURT stats (rel) min: <.01% max: 5.68% x̄: 0.63% x̃: 0.06% 95% mean confidence interval for cycles value: -3191.23 -450.54 95% mean confidence interval for cycles %-change: -2.47% -1.89% Cycles are helped. total sends in shared programs: 996341 -> 996222 (-0.01%) sends in affected programs: 2151 -> 2032 (-5.53%) helped: 115 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 7.07% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.55% -6.58% Sends are helped. Haswell total instructions in shared programs: 16038375 -> 16038121 (<.01%) instructions in affected programs: 216797 -> 216543 (-0.12%) helped: 185 HURT: 217 helped stats (abs) min: 1 max: 12 x̄: 2.84 x̃: 3 helped stats (rel) min: 0.13% max: 4.23% x̄: 1.30% x̃: 1.20% HURT stats (abs) min: 1 max: 6 x̄: 1.25 x̃: 1 HURT stats (rel) min: 0.03% max: 5.66% x̄: 0.61% x̃: 0.40% 95% mean confidence interval for instructions value: -0.85 -0.41 95% mean confidence interval for instructions %-change: -0.40% -0.14% Instructions are helped. total loops in shared programs: 5947 -> 5942 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 967655093 -> 965746713 (-0.20%) cycles in affected programs: 197288924 -> 195380544 (-0.97%) helped: 950 HURT: 195 helped stats (abs) min: 1 max: 782820 x̄: 2274.79 x̃: 1260 helped stats (rel) min: <.01% max: 54.26% x̄: 3.02% x̃: 1.71% HURT stats (abs) min: 1 max: 15790 x̄: 1295.73 x̃: 21 HURT stats (rel) min: <.01% max: 119.85% x̄: 7.76% x̃: 0.11% 95% mean confidence interval for cycles value: -3014.22 -319.19 95% mean confidence interval for cycles %-change: -1.83% -0.55% Cycles are helped. total sends in shared programs: 934894 -> 934765 (-0.01%) sends in affected programs: 2192 -> 2063 (-5.89%) helped: 115 HURT: 2 helped stats (abs) min: 1 max: 4 x̄: 1.14 x̃: 1 helped stats (rel) min: 0.60% max: 28.57% x̄: 7.68% x̃: 6.67% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 16.67% max: 16.67% x̄: 16.67% x̃: 16.67% 95% mean confidence interval for sends value: -1.23 -0.98 95% mean confidence interval for sends %-change: -8.28% -6.24% Sends are helped. LOST: 1 GAINED: 18 Ivy Bridge total instructions in shared programs: 15269357 -> 15269398 (<.01%) instructions in affected programs: 190484 -> 190525 (0.02%) helped: 77 HURT: 206 helped stats (abs) min: 1 max: 6 x̄: 2.47 x̃: 3 helped stats (rel) min: 0.14% max: 5.31% x̄: 1.46% x̃: 1.65% HURT stats (abs) min: 1 max: 3 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 2.38% x̄: 0.42% x̃: 0.40% 95% mean confidence interval for instructions value: -0.06 0.35 95% mean confidence interval for instructions %-change: -0.21% 0.03% Inconclusive result (value mean confidence interval includes 0). total loops in shared programs: 4001 -> 3996 (-0.12%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 562045564 -> 561063543 (-0.17%) cycles in affected programs: 200924872 -> 199942851 (-0.49%) helped: 748 HURT: 160 helped stats (abs) min: 2 max: 14926 x̄: 1692.94 x̃: 1620 helped stats (rel) min: <.01% max: 53.29% x̄: 3.17% x̃: 1.87% HURT stats (abs) min: 2 max: 15726 x̄: 1776.86 x̃: 36 HURT stats (rel) min: <.01% max: 114.43% x̄: 10.66% x̃: 0.21% 95% mean confidence interval for cycles value: -1237.33 -925.71 95% mean confidence interval for cycles %-change: -1.54% 0.08% Inconclusive result (%-change mean confidence interval includes 0). total sends in shared programs: 893348 -> 893330 (<.01%) sends in affected programs: 187 -> 169 (-9.63%) helped: 14 HURT: 0 helped stats (abs) min: 1 max: 2 x̄: 1.29 x̃: 1 helped stats (rel) min: 4.08% max: 22.22% x̄: 11.70% x̃: 10.10% 95% mean confidence interval for sends value: -1.56 -1.02 95% mean confidence interval for sends %-change: -14.92% -8.48% Sends are helped. LOST: 1 GAINED: 19 Sandy Bridge total instructions in shared programs: 11785227 -> 11785774 (<.01%) instructions in affected programs: 78403 -> 78950 (0.70%) helped: 65 HURT: 505 helped stats (abs) min: 1 max: 4 x̄: 2.22 x̃: 3 helped stats (rel) min: 0.14% max: 4.17% x̄: 1.19% x̃: 1.38% HURT stats (abs) min: 1 max: 5 x̄: 1.37 x̃: 1 HURT stats (rel) min: 0.24% max: 3.33% x̄: 1.57% x̃: 1.72% 95% mean confidence interval for instructions value: 0.85 1.07 95% mean confidence interval for instructions %-change: 1.16% 1.36% Instructions are HURT. total loops in shared programs: 2441 -> 2437 (-0.16%) loops in affected programs: 8 -> 4 (-50.00%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 497178796 -> 496669298 (-0.10%) cycles in affected programs: 51483322 -> 50973824 (-0.99%) helped: 476 HURT: 137 helped stats (abs) min: 2 max: 7502 x̄: 1079.36 x̃: 1260 helped stats (rel) min: <.01% max: 42.50% x̄: 2.31% x̃: 0.86% HURT stats (abs) min: 2 max: 754 x̄: 31.23 x̃: 18 HURT stats (rel) min: <.01% max: 3.01% x̄: 0.09% x̃: 0.02% 95% mean confidence interval for cycles value: -901.99 -760.32 95% mean confidence interval for cycles %-change: -2.20% -1.36% Cycles are helped. total sends in shared programs: 642919 -> 642915 (<.01%) sends in affected programs: 32 -> 28 (-12.50%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 11.11% max: 14.29% x̄: 12.70% x̃: 12.70% 95% mean confidence interval for sends value: -1.00 -1.00 95% mean confidence interval for sends %-change: -15.61% -9.78% Sends are helped. Iron Lake total instructions in shared programs: 8180061 -> 8180248 (<.01%) instructions in affected programs: 65004 -> 65191 (0.29%) helped: 59 HURT: 253 helped stats (abs) min: 1 max: 4 x̄: 2.24 x̃: 3 helped stats (rel) min: 0.16% max: 2.23% x̄: 1.04% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.26 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.93% x̃: 0.60% 95% mean confidence interval for instructions value: 0.43 0.77 95% mean confidence interval for instructions %-change: 0.45% 0.68% Instructions are HURT. total loops in shared programs: 863 -> 861 (-0.23%) loops in affected programs: 4 -> 2 (-50.00%) helped: 2 HURT: 0 total cycles in shared programs: 239357490 -> 238907668 (-0.19%) cycles in affected programs: 17314006 -> 16864184 (-2.60%) helped: 176 HURT: 34 helped stats (abs) min: 4 max: 13400 x̄: 2558.05 x̃: 2920 helped stats (rel) min: 0.01% max: 35.58% x̄: 3.76% x̃: 2.69% HURT stats (abs) min: 2 max: 14 x̄: 11.59 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2440.68 -1843.34 95% mean confidence interval for cycles %-change: -3.78% -2.51% Cycles are helped. GM45 total instructions in shared programs: 4985293 -> 4985401 (<.01%) instructions in affected programs: 58807 -> 58915 (0.18%) helped: 57 HURT: 202 helped stats (abs) min: 1 max: 4 x̄: 2.26 x̃: 3 helped stats (rel) min: 0.15% max: 2.23% x̄: 1.06% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.17 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.76% x̃: 0.48% 95% mean confidence interval for instructions value: 0.22 0.61 95% mean confidence interval for instructions %-change: 0.24% 0.48% Instructions are HURT. total loops in shared programs: 639 -> 638 (-0.16%) loops in affected programs: 2 -> 1 (-50.00%) helped: 1 HURT: 0 total cycles in shared programs: 153794236 -> 153546274 (-0.16%) cycles in affected programs: 9947778 -> 9699816 (-2.49%) helped: 110 HURT: 31 helped stats (abs) min: 4 max: 13400 x̄: 2257.51 x̃: 1796 helped stats (rel) min: 0.01% max: 35.58% x̄: 4.33% x̃: 2.45% HURT stats (abs) min: 2 max: 14 x̄: 11.74 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2113.77 -1403.42 95% mean confidence interval for cycles %-change: -4.27% -2.47% Cycles are helped. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2899 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12064>
2021-07-26 23:25:58 +10:00
nir_metadata_require(impl, nir_metadata_loop_analysis,
shader->options->force_indirect_unrolling,
shader->options->force_indirect_unrolling_sampler);
/* A previous pass may have left pass_flags dirty, so clear it all out. */
nir_foreach_block(block, impl)
nir_foreach_instr(instr, block)
instr->pass_flags = 0;
struct gcm_state state;
state.impl = impl;
state.instr = NULL;
state.progress = false;
exec_list_make_empty(&state.instrs);
state.blocks = rzalloc_array(NULL, struct gcm_block_info, impl->num_blocks);
nir/gcm: fix pushing instructions into if blocks The previous logic would just set the block to the instructions original location if we couldn't evict it from a loop. For now we only push const loads to a later block inside ifs but we can add more heuristics later. This change helps a hand full of shaders but also stops a CTS regression caused by excess spilling after a series I'm working on to disable more of the GLSL IR optimisation passes. Shader-db results iris (BDW): total instructions in shared programs: 17529759 -> 17529749 (<.01%) instructions in affected programs: 15929 -> 15919 (-0.06%) helped: 5 HURT: 2 helped stats (abs) min: 1 max: 5 x̄: 2.40 x̃: 2 helped stats (rel) min: 0.06% max: 0.15% x̄: 0.11% x̃: 0.12% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.06% max: 0.06% x̄: 0.06% x̃: 0.06% 95% mean confidence interval for instructions value: -3.34 0.49 95% mean confidence interval for instructions %-change: -0.14% 0.02% Inconclusive result (value mean confidence interval includes 0). total cycles in shared programs: 861109994 -> 861099681 (<.01%) cycles in affected programs: 7027698 -> 7017385 (-0.15%) helped: 95 HURT: 72 helped stats (abs) min: 1 max: 7995 x̄: 138.54 x̃: 9 helped stats (rel) min: <.01% max: 15.96% x̄: 0.54% x̃: 0.11% HURT stats (abs) min: 1 max: 474 x̄: 39.56 x̃: 12 HURT stats (rel) min: <.01% max: 1.17% x̄: 0.20% x̃: 0.11% 95% mean confidence interval for cycles value: -159.05 35.54 95% mean confidence interval for cycles %-change: -0.45% 0.01% Inconclusive result (value mean confidence interval includes 0). total spills in shared programs: 17606 -> 17605 (<.01%) spills in affected programs: 323 -> 322 (-0.31%) helped: 1 HURT: 0 total fills in shared programs: 22599 -> 22598 (<.01%) fills in affected programs: 1348 -> 1347 (-0.07%) helped: 1 HURT: 0 Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14940>
2022-02-07 19:10:13 +11:00
gcm_build_block_info(&impl->body, &state, NULL, 0, 0, ~0u);
gcm_pin_instructions(impl, &state);
state.instr_infos =
rzalloc_array(NULL, struct gcm_instr_info, state.num_instrs);
if (value_number) {
struct set *gvn_set = nir_instr_set_create(NULL);
foreach_list_typed_safe(nir_instr, instr, node, &state.instrs) {
if (instr->pass_flags & GCM_INSTR_PINNED)
continue;
if (nir_instr_set_add_or_rewrite(gvn_set, instr, NULL))
state.progress = true;
}
nir_instr_set_destroy(gvn_set);
}
foreach_list_typed(nir_instr, instr, node, &state.instrs)
gcm_schedule_early_instr(instr, &state);
foreach_list_typed(nir_instr, instr, node, &state.instrs)
gcm_schedule_late_instr(instr, &state);
while (!exec_list_is_empty(&state.instrs)) {
nir_instr *instr = exec_node_data(nir_instr,
state.instrs.tail_sentinel.prev, node);
gcm_place_instr(instr, &state);
}
ralloc_free(state.blocks);
ralloc_free(state.instr_infos);
nir_metadata_preserve(impl, nir_metadata_block_index |
nir: add heuristic for instructions in loops with GCM Moving instructions out of large loops tends to cause excessive spilling. This appears to be a good limit. In future it might make sense to make this a NIR options so other drivers can set their own limits. Tiger Lake total instructions in shared programs: 20930180 -> 20926952 (-0.02%) instructions in affected programs: 280768 -> 277540 (-1.15%) helped: 734 HURT: 192 helped stats (abs) min: 1 max: 61 x̄: 5.16 x̃: 4 helped stats (rel) min: 0.04% max: 10.64% x̄: 3.23% x̃: 3.14% HURT stats (abs) min: 1 max: 52 x̄: 2.90 x̃: 1 HURT stats (rel) min: 0.03% max: 9.76% x̄: 1.13% x̃: 0.61% 95% mean confidence interval for instructions value: -3.89 -3.08 95% mean confidence interval for instructions %-change: -2.49% -2.16% Instructions are helped. total cycles in shared programs: 841825217 -> 838817552 (-0.36%) cycles in affected programs: 122088078 -> 119080413 (-2.46%) helped: 941 HURT: 100 helped stats (abs) min: 1 max: 160080 x̄: 3274.31 x̃: 2660 helped stats (rel) min: <.01% max: 41.64% x̄: 5.50% x̃: 4.80% HURT stats (abs) min: 1 max: 41856 x̄: 734.62 x̃: 26 HURT stats (rel) min: <.01% max: 7.29% x̄: 0.44% x̃: 0.27% 95% mean confidence interval for cycles value: -3236.56 -2541.85 95% mean confidence interval for cycles %-change: -5.26% -4.60% Cycles are helped. total sends in shared programs: 977905 -> 977782 (-0.01%) sends in affected programs: 2279 -> 2156 (-5.40%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.93% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.42% -6.45% Sends are helped. LOST: 2 GAINED: 0 Ice Lake total instructions in shared programs: 19865361 -> 19861747 (-0.02%) instructions in affected programs: 185789 -> 182175 (-1.95%) helped: 593 HURT: 47 helped stats (abs) min: 1 max: 27 x̄: 6.17 x̃: 4 helped stats (rel) min: 0.19% max: 8.65% x̄: 4.53% x̃: 4.60% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.23% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -5.93 -5.37 95% mean confidence interval for instructions %-change: -4.32% -4.06% Instructions are helped. total loops in shared programs: 6120 -> 6117 (-0.05%) loops in affected programs: 6 -> 3 (-50.00%) helped: 3 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% total cycles in shared programs: 961777176 -> 959404350 (-0.25%) cycles in affected programs: 172224180 -> 169851354 (-1.38%) helped: 936 HURT: 80 helped stats (abs) min: 1 max: 9566 x̄: 2621.08 x̃: 2550 helped stats (rel) min: <.01% max: 41.77% x̄: 4.22% x̃: 3.84% HURT stats (abs) min: 1 max: 59146 x̄: 1006.34 x̃: 24 HURT stats (rel) min: <.01% max: 3.78% x̄: 0.44% x̃: 0.25% 95% mean confidence interval for cycles value: -2513.72 -2157.20 95% mean confidence interval for cycles %-change: -4.13% -3.57% Cycles are helped. total sends in shared programs: 1019995 -> 1019872 (-0.01%) sends in affected programs: 2283 -> 2160 (-5.39%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.39% -6.42% Sends are helped. LOST: 4 GAINED: 0 Skylake total instructions in shared programs: 17994337 -> 17993846 (<.01%) instructions in affected programs: 146294 -> 145803 (-0.34%) helped: 190 HURT: 47 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.14% max: 4.29% x̄: 1.08% x̃: 0.90% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.22% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -2.30 -1.84 95% mean confidence interval for instructions %-change: -0.95% -0.74% Instructions are helped. total loops in shared programs: 6029 -> 6023 (-0.10%) loops in affected programs: 12 -> 6 (-50.00%) helped: 6 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 939062940 -> 938023548 (-0.11%) cycles in affected programs: 169671482 -> 168632090 (-0.61%) helped: 980 HURT: 134 helped stats (abs) min: 1 max: 25000 x̄: 1075.57 x̃: 1052 helped stats (rel) min: <.01% max: 42.75% x̄: 2.51% x̃: 1.32% HURT stats (abs) min: 1 max: 837 x̄: 109.45 x̃: 20 HURT stats (rel) min: <.01% max: 5.71% x̄: 0.73% x̃: 0.21% 95% mean confidence interval for cycles value: -1005.89 -860.17 95% mean confidence interval for cycles %-change: -2.39% -1.84% Cycles are helped. total sends in shared programs: 1026848 -> 1026724 (-0.01%) sends in affected programs: 2302 -> 2178 (-5.39%) helped: 120 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.40% -6.43% Sends are helped. LOST: 1 GAINED: 1 Broadwell total instructions in shared programs: 17605621 -> 17605154 (<.01%) instructions in affected programs: 145691 -> 145224 (-0.32%) helped: 184 HURT: 48 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.13% max: 4.29% x̄: 1.09% x̃: 0.93% HURT stats (abs) min: 1 max: 7 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 0.48% x̄: 0.12% x̃: 0.04% 95% mean confidence interval for instructions value: -2.26 -1.77 95% mean confidence interval for instructions %-change: -0.95% -0.73% Instructions are helped. total loops in shared programs: 5968 -> 5963 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 1000679489 -> 998592756 (-0.21%) cycles in affected programs: 173421234 -> 171334501 (-1.20%) helped: 993 HURT: 153 helped stats (abs) min: 1 max: 766608 x̄: 2118.49 x̃: 1080 helped stats (rel) min: <.01% max: 54.61% x̄: 2.61% x̃: 1.73% HURT stats (abs) min: 1 max: 2200 x̄: 110.61 x̃: 11 HURT stats (rel) min: <.01% max: 5.68% x̄: 0.63% x̃: 0.06% 95% mean confidence interval for cycles value: -3191.23 -450.54 95% mean confidence interval for cycles %-change: -2.47% -1.89% Cycles are helped. total sends in shared programs: 996341 -> 996222 (-0.01%) sends in affected programs: 2151 -> 2032 (-5.53%) helped: 115 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 7.07% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.55% -6.58% Sends are helped. Haswell total instructions in shared programs: 16038375 -> 16038121 (<.01%) instructions in affected programs: 216797 -> 216543 (-0.12%) helped: 185 HURT: 217 helped stats (abs) min: 1 max: 12 x̄: 2.84 x̃: 3 helped stats (rel) min: 0.13% max: 4.23% x̄: 1.30% x̃: 1.20% HURT stats (abs) min: 1 max: 6 x̄: 1.25 x̃: 1 HURT stats (rel) min: 0.03% max: 5.66% x̄: 0.61% x̃: 0.40% 95% mean confidence interval for instructions value: -0.85 -0.41 95% mean confidence interval for instructions %-change: -0.40% -0.14% Instructions are helped. total loops in shared programs: 5947 -> 5942 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 967655093 -> 965746713 (-0.20%) cycles in affected programs: 197288924 -> 195380544 (-0.97%) helped: 950 HURT: 195 helped stats (abs) min: 1 max: 782820 x̄: 2274.79 x̃: 1260 helped stats (rel) min: <.01% max: 54.26% x̄: 3.02% x̃: 1.71% HURT stats (abs) min: 1 max: 15790 x̄: 1295.73 x̃: 21 HURT stats (rel) min: <.01% max: 119.85% x̄: 7.76% x̃: 0.11% 95% mean confidence interval for cycles value: -3014.22 -319.19 95% mean confidence interval for cycles %-change: -1.83% -0.55% Cycles are helped. total sends in shared programs: 934894 -> 934765 (-0.01%) sends in affected programs: 2192 -> 2063 (-5.89%) helped: 115 HURT: 2 helped stats (abs) min: 1 max: 4 x̄: 1.14 x̃: 1 helped stats (rel) min: 0.60% max: 28.57% x̄: 7.68% x̃: 6.67% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 16.67% max: 16.67% x̄: 16.67% x̃: 16.67% 95% mean confidence interval for sends value: -1.23 -0.98 95% mean confidence interval for sends %-change: -8.28% -6.24% Sends are helped. LOST: 1 GAINED: 18 Ivy Bridge total instructions in shared programs: 15269357 -> 15269398 (<.01%) instructions in affected programs: 190484 -> 190525 (0.02%) helped: 77 HURT: 206 helped stats (abs) min: 1 max: 6 x̄: 2.47 x̃: 3 helped stats (rel) min: 0.14% max: 5.31% x̄: 1.46% x̃: 1.65% HURT stats (abs) min: 1 max: 3 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 2.38% x̄: 0.42% x̃: 0.40% 95% mean confidence interval for instructions value: -0.06 0.35 95% mean confidence interval for instructions %-change: -0.21% 0.03% Inconclusive result (value mean confidence interval includes 0). total loops in shared programs: 4001 -> 3996 (-0.12%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 562045564 -> 561063543 (-0.17%) cycles in affected programs: 200924872 -> 199942851 (-0.49%) helped: 748 HURT: 160 helped stats (abs) min: 2 max: 14926 x̄: 1692.94 x̃: 1620 helped stats (rel) min: <.01% max: 53.29% x̄: 3.17% x̃: 1.87% HURT stats (abs) min: 2 max: 15726 x̄: 1776.86 x̃: 36 HURT stats (rel) min: <.01% max: 114.43% x̄: 10.66% x̃: 0.21% 95% mean confidence interval for cycles value: -1237.33 -925.71 95% mean confidence interval for cycles %-change: -1.54% 0.08% Inconclusive result (%-change mean confidence interval includes 0). total sends in shared programs: 893348 -> 893330 (<.01%) sends in affected programs: 187 -> 169 (-9.63%) helped: 14 HURT: 0 helped stats (abs) min: 1 max: 2 x̄: 1.29 x̃: 1 helped stats (rel) min: 4.08% max: 22.22% x̄: 11.70% x̃: 10.10% 95% mean confidence interval for sends value: -1.56 -1.02 95% mean confidence interval for sends %-change: -14.92% -8.48% Sends are helped. LOST: 1 GAINED: 19 Sandy Bridge total instructions in shared programs: 11785227 -> 11785774 (<.01%) instructions in affected programs: 78403 -> 78950 (0.70%) helped: 65 HURT: 505 helped stats (abs) min: 1 max: 4 x̄: 2.22 x̃: 3 helped stats (rel) min: 0.14% max: 4.17% x̄: 1.19% x̃: 1.38% HURT stats (abs) min: 1 max: 5 x̄: 1.37 x̃: 1 HURT stats (rel) min: 0.24% max: 3.33% x̄: 1.57% x̃: 1.72% 95% mean confidence interval for instructions value: 0.85 1.07 95% mean confidence interval for instructions %-change: 1.16% 1.36% Instructions are HURT. total loops in shared programs: 2441 -> 2437 (-0.16%) loops in affected programs: 8 -> 4 (-50.00%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 497178796 -> 496669298 (-0.10%) cycles in affected programs: 51483322 -> 50973824 (-0.99%) helped: 476 HURT: 137 helped stats (abs) min: 2 max: 7502 x̄: 1079.36 x̃: 1260 helped stats (rel) min: <.01% max: 42.50% x̄: 2.31% x̃: 0.86% HURT stats (abs) min: 2 max: 754 x̄: 31.23 x̃: 18 HURT stats (rel) min: <.01% max: 3.01% x̄: 0.09% x̃: 0.02% 95% mean confidence interval for cycles value: -901.99 -760.32 95% mean confidence interval for cycles %-change: -2.20% -1.36% Cycles are helped. total sends in shared programs: 642919 -> 642915 (<.01%) sends in affected programs: 32 -> 28 (-12.50%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 11.11% max: 14.29% x̄: 12.70% x̃: 12.70% 95% mean confidence interval for sends value: -1.00 -1.00 95% mean confidence interval for sends %-change: -15.61% -9.78% Sends are helped. Iron Lake total instructions in shared programs: 8180061 -> 8180248 (<.01%) instructions in affected programs: 65004 -> 65191 (0.29%) helped: 59 HURT: 253 helped stats (abs) min: 1 max: 4 x̄: 2.24 x̃: 3 helped stats (rel) min: 0.16% max: 2.23% x̄: 1.04% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.26 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.93% x̃: 0.60% 95% mean confidence interval for instructions value: 0.43 0.77 95% mean confidence interval for instructions %-change: 0.45% 0.68% Instructions are HURT. total loops in shared programs: 863 -> 861 (-0.23%) loops in affected programs: 4 -> 2 (-50.00%) helped: 2 HURT: 0 total cycles in shared programs: 239357490 -> 238907668 (-0.19%) cycles in affected programs: 17314006 -> 16864184 (-2.60%) helped: 176 HURT: 34 helped stats (abs) min: 4 max: 13400 x̄: 2558.05 x̃: 2920 helped stats (rel) min: 0.01% max: 35.58% x̄: 3.76% x̃: 2.69% HURT stats (abs) min: 2 max: 14 x̄: 11.59 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2440.68 -1843.34 95% mean confidence interval for cycles %-change: -3.78% -2.51% Cycles are helped. GM45 total instructions in shared programs: 4985293 -> 4985401 (<.01%) instructions in affected programs: 58807 -> 58915 (0.18%) helped: 57 HURT: 202 helped stats (abs) min: 1 max: 4 x̄: 2.26 x̃: 3 helped stats (rel) min: 0.15% max: 2.23% x̄: 1.06% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.17 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.76% x̃: 0.48% 95% mean confidence interval for instructions value: 0.22 0.61 95% mean confidence interval for instructions %-change: 0.24% 0.48% Instructions are HURT. total loops in shared programs: 639 -> 638 (-0.16%) loops in affected programs: 2 -> 1 (-50.00%) helped: 1 HURT: 0 total cycles in shared programs: 153794236 -> 153546274 (-0.16%) cycles in affected programs: 9947778 -> 9699816 (-2.49%) helped: 110 HURT: 31 helped stats (abs) min: 4 max: 13400 x̄: 2257.51 x̃: 1796 helped stats (rel) min: 0.01% max: 35.58% x̄: 4.33% x̃: 2.45% HURT stats (abs) min: 2 max: 14 x̄: 11.74 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2113.77 -1403.42 95% mean confidence interval for cycles %-change: -4.27% -2.47% Cycles are helped. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2899 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12064>
2021-07-26 23:25:58 +10:00
nir_metadata_dominance |
nir_metadata_loop_analysis);
return state.progress;
}
bool
nir_opt_gcm(nir_shader *shader, bool value_number)
{
bool progress = false;
nir_foreach_function(function, shader) {
if (function->impl)
nir: add heuristic for instructions in loops with GCM Moving instructions out of large loops tends to cause excessive spilling. This appears to be a good limit. In future it might make sense to make this a NIR options so other drivers can set their own limits. Tiger Lake total instructions in shared programs: 20930180 -> 20926952 (-0.02%) instructions in affected programs: 280768 -> 277540 (-1.15%) helped: 734 HURT: 192 helped stats (abs) min: 1 max: 61 x̄: 5.16 x̃: 4 helped stats (rel) min: 0.04% max: 10.64% x̄: 3.23% x̃: 3.14% HURT stats (abs) min: 1 max: 52 x̄: 2.90 x̃: 1 HURT stats (rel) min: 0.03% max: 9.76% x̄: 1.13% x̃: 0.61% 95% mean confidence interval for instructions value: -3.89 -3.08 95% mean confidence interval for instructions %-change: -2.49% -2.16% Instructions are helped. total cycles in shared programs: 841825217 -> 838817552 (-0.36%) cycles in affected programs: 122088078 -> 119080413 (-2.46%) helped: 941 HURT: 100 helped stats (abs) min: 1 max: 160080 x̄: 3274.31 x̃: 2660 helped stats (rel) min: <.01% max: 41.64% x̄: 5.50% x̃: 4.80% HURT stats (abs) min: 1 max: 41856 x̄: 734.62 x̃: 26 HURT stats (rel) min: <.01% max: 7.29% x̄: 0.44% x̃: 0.27% 95% mean confidence interval for cycles value: -3236.56 -2541.85 95% mean confidence interval for cycles %-change: -5.26% -4.60% Cycles are helped. total sends in shared programs: 977905 -> 977782 (-0.01%) sends in affected programs: 2279 -> 2156 (-5.40%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.93% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.42% -6.45% Sends are helped. LOST: 2 GAINED: 0 Ice Lake total instructions in shared programs: 19865361 -> 19861747 (-0.02%) instructions in affected programs: 185789 -> 182175 (-1.95%) helped: 593 HURT: 47 helped stats (abs) min: 1 max: 27 x̄: 6.17 x̃: 4 helped stats (rel) min: 0.19% max: 8.65% x̄: 4.53% x̃: 4.60% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.23% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -5.93 -5.37 95% mean confidence interval for instructions %-change: -4.32% -4.06% Instructions are helped. total loops in shared programs: 6120 -> 6117 (-0.05%) loops in affected programs: 6 -> 3 (-50.00%) helped: 3 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% total cycles in shared programs: 961777176 -> 959404350 (-0.25%) cycles in affected programs: 172224180 -> 169851354 (-1.38%) helped: 936 HURT: 80 helped stats (abs) min: 1 max: 9566 x̄: 2621.08 x̃: 2550 helped stats (rel) min: <.01% max: 41.77% x̄: 4.22% x̃: 3.84% HURT stats (abs) min: 1 max: 59146 x̄: 1006.34 x̃: 24 HURT stats (rel) min: <.01% max: 3.78% x̄: 0.44% x̃: 0.25% 95% mean confidence interval for cycles value: -2513.72 -2157.20 95% mean confidence interval for cycles %-change: -4.13% -3.57% Cycles are helped. total sends in shared programs: 1019995 -> 1019872 (-0.01%) sends in affected programs: 2283 -> 2160 (-5.39%) helped: 119 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.39% -6.42% Sends are helped. LOST: 4 GAINED: 0 Skylake total instructions in shared programs: 17994337 -> 17993846 (<.01%) instructions in affected programs: 146294 -> 145803 (-0.34%) helped: 190 HURT: 47 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.14% max: 4.29% x̄: 1.08% x̃: 0.90% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.03% max: 0.22% x̄: 0.11% x̃: 0.04% 95% mean confidence interval for instructions value: -2.30 -1.84 95% mean confidence interval for instructions %-change: -0.95% -0.74% Instructions are helped. total loops in shared programs: 6029 -> 6023 (-0.10%) loops in affected programs: 12 -> 6 (-50.00%) helped: 6 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 939062940 -> 938023548 (-0.11%) cycles in affected programs: 169671482 -> 168632090 (-0.61%) helped: 980 HURT: 134 helped stats (abs) min: 1 max: 25000 x̄: 1075.57 x̃: 1052 helped stats (rel) min: <.01% max: 42.75% x̄: 2.51% x̃: 1.32% HURT stats (abs) min: 1 max: 837 x̄: 109.45 x̃: 20 HURT stats (rel) min: <.01% max: 5.71% x̄: 0.73% x̃: 0.21% 95% mean confidence interval for cycles value: -1005.89 -860.17 95% mean confidence interval for cycles %-change: -2.39% -1.84% Cycles are helped. total sends in shared programs: 1026848 -> 1026724 (-0.01%) sends in affected programs: 2302 -> 2178 (-5.39%) helped: 120 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 6.91% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.40% -6.43% Sends are helped. LOST: 1 GAINED: 1 Broadwell total instructions in shared programs: 17605621 -> 17605154 (<.01%) instructions in affected programs: 145691 -> 145224 (-0.32%) helped: 184 HURT: 48 helped stats (abs) min: 1 max: 12 x̄: 2.83 x̃: 3 helped stats (rel) min: 0.13% max: 4.29% x̄: 1.09% x̃: 0.93% HURT stats (abs) min: 1 max: 7 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 0.48% x̄: 0.12% x̃: 0.04% 95% mean confidence interval for instructions value: -2.26 -1.77 95% mean confidence interval for instructions %-change: -0.95% -0.73% Instructions are helped. total loops in shared programs: 5968 -> 5963 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 1000679489 -> 998592756 (-0.21%) cycles in affected programs: 173421234 -> 171334501 (-1.20%) helped: 993 HURT: 153 helped stats (abs) min: 1 max: 766608 x̄: 2118.49 x̃: 1080 helped stats (rel) min: <.01% max: 54.61% x̄: 2.61% x̃: 1.73% HURT stats (abs) min: 1 max: 2200 x̄: 110.61 x̃: 11 HURT stats (rel) min: <.01% max: 5.68% x̄: 0.63% x̃: 0.06% 95% mean confidence interval for cycles value: -3191.23 -450.54 95% mean confidence interval for cycles %-change: -2.47% -1.89% Cycles are helped. total sends in shared programs: 996341 -> 996222 (-0.01%) sends in affected programs: 2151 -> 2032 (-5.53%) helped: 115 HURT: 0 helped stats (abs) min: 1 max: 4 x̄: 1.03 x̃: 1 helped stats (rel) min: 0.60% max: 14.29% x̄: 7.07% x̃: 6.67% 95% mean confidence interval for sends value: -1.09 -0.98 95% mean confidence interval for sends %-change: -7.55% -6.58% Sends are helped. Haswell total instructions in shared programs: 16038375 -> 16038121 (<.01%) instructions in affected programs: 216797 -> 216543 (-0.12%) helped: 185 HURT: 217 helped stats (abs) min: 1 max: 12 x̄: 2.84 x̃: 3 helped stats (rel) min: 0.13% max: 4.23% x̄: 1.30% x̃: 1.20% HURT stats (abs) min: 1 max: 6 x̄: 1.25 x̃: 1 HURT stats (rel) min: 0.03% max: 5.66% x̄: 0.61% x̃: 0.40% 95% mean confidence interval for instructions value: -0.85 -0.41 95% mean confidence interval for instructions %-change: -0.40% -0.14% Instructions are helped. total loops in shared programs: 5947 -> 5942 (-0.08%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 967655093 -> 965746713 (-0.20%) cycles in affected programs: 197288924 -> 195380544 (-0.97%) helped: 950 HURT: 195 helped stats (abs) min: 1 max: 782820 x̄: 2274.79 x̃: 1260 helped stats (rel) min: <.01% max: 54.26% x̄: 3.02% x̃: 1.71% HURT stats (abs) min: 1 max: 15790 x̄: 1295.73 x̃: 21 HURT stats (rel) min: <.01% max: 119.85% x̄: 7.76% x̃: 0.11% 95% mean confidence interval for cycles value: -3014.22 -319.19 95% mean confidence interval for cycles %-change: -1.83% -0.55% Cycles are helped. total sends in shared programs: 934894 -> 934765 (-0.01%) sends in affected programs: 2192 -> 2063 (-5.89%) helped: 115 HURT: 2 helped stats (abs) min: 1 max: 4 x̄: 1.14 x̃: 1 helped stats (rel) min: 0.60% max: 28.57% x̄: 7.68% x̃: 6.67% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 16.67% max: 16.67% x̄: 16.67% x̃: 16.67% 95% mean confidence interval for sends value: -1.23 -0.98 95% mean confidence interval for sends %-change: -8.28% -6.24% Sends are helped. LOST: 1 GAINED: 18 Ivy Bridge total instructions in shared programs: 15269357 -> 15269398 (<.01%) instructions in affected programs: 190484 -> 190525 (0.02%) helped: 77 HURT: 206 helped stats (abs) min: 1 max: 6 x̄: 2.47 x̃: 3 helped stats (rel) min: 0.14% max: 5.31% x̄: 1.46% x̃: 1.65% HURT stats (abs) min: 1 max: 3 x̄: 1.12 x̃: 1 HURT stats (rel) min: 0.03% max: 2.38% x̄: 0.42% x̃: 0.40% 95% mean confidence interval for instructions value: -0.06 0.35 95% mean confidence interval for instructions %-change: -0.21% 0.03% Inconclusive result (value mean confidence interval includes 0). total loops in shared programs: 4001 -> 3996 (-0.12%) loops in affected programs: 10 -> 5 (-50.00%) helped: 5 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 562045564 -> 561063543 (-0.17%) cycles in affected programs: 200924872 -> 199942851 (-0.49%) helped: 748 HURT: 160 helped stats (abs) min: 2 max: 14926 x̄: 1692.94 x̃: 1620 helped stats (rel) min: <.01% max: 53.29% x̄: 3.17% x̃: 1.87% HURT stats (abs) min: 2 max: 15726 x̄: 1776.86 x̃: 36 HURT stats (rel) min: <.01% max: 114.43% x̄: 10.66% x̃: 0.21% 95% mean confidence interval for cycles value: -1237.33 -925.71 95% mean confidence interval for cycles %-change: -1.54% 0.08% Inconclusive result (%-change mean confidence interval includes 0). total sends in shared programs: 893348 -> 893330 (<.01%) sends in affected programs: 187 -> 169 (-9.63%) helped: 14 HURT: 0 helped stats (abs) min: 1 max: 2 x̄: 1.29 x̃: 1 helped stats (rel) min: 4.08% max: 22.22% x̄: 11.70% x̃: 10.10% 95% mean confidence interval for sends value: -1.56 -1.02 95% mean confidence interval for sends %-change: -14.92% -8.48% Sends are helped. LOST: 1 GAINED: 19 Sandy Bridge total instructions in shared programs: 11785227 -> 11785774 (<.01%) instructions in affected programs: 78403 -> 78950 (0.70%) helped: 65 HURT: 505 helped stats (abs) min: 1 max: 4 x̄: 2.22 x̃: 3 helped stats (rel) min: 0.14% max: 4.17% x̄: 1.19% x̃: 1.38% HURT stats (abs) min: 1 max: 5 x̄: 1.37 x̃: 1 HURT stats (rel) min: 0.24% max: 3.33% x̄: 1.57% x̃: 1.72% 95% mean confidence interval for instructions value: 0.85 1.07 95% mean confidence interval for instructions %-change: 1.16% 1.36% Instructions are HURT. total loops in shared programs: 2441 -> 2437 (-0.16%) loops in affected programs: 8 -> 4 (-50.00%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 50.00% max: 50.00% x̄: 50.00% x̃: 50.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -50.00% -50.00% Loops are helped. total cycles in shared programs: 497178796 -> 496669298 (-0.10%) cycles in affected programs: 51483322 -> 50973824 (-0.99%) helped: 476 HURT: 137 helped stats (abs) min: 2 max: 7502 x̄: 1079.36 x̃: 1260 helped stats (rel) min: <.01% max: 42.50% x̄: 2.31% x̃: 0.86% HURT stats (abs) min: 2 max: 754 x̄: 31.23 x̃: 18 HURT stats (rel) min: <.01% max: 3.01% x̄: 0.09% x̃: 0.02% 95% mean confidence interval for cycles value: -901.99 -760.32 95% mean confidence interval for cycles %-change: -2.20% -1.36% Cycles are helped. total sends in shared programs: 642919 -> 642915 (<.01%) sends in affected programs: 32 -> 28 (-12.50%) helped: 4 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 11.11% max: 14.29% x̄: 12.70% x̃: 12.70% 95% mean confidence interval for sends value: -1.00 -1.00 95% mean confidence interval for sends %-change: -15.61% -9.78% Sends are helped. Iron Lake total instructions in shared programs: 8180061 -> 8180248 (<.01%) instructions in affected programs: 65004 -> 65191 (0.29%) helped: 59 HURT: 253 helped stats (abs) min: 1 max: 4 x̄: 2.24 x̃: 3 helped stats (rel) min: 0.16% max: 2.23% x̄: 1.04% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.26 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.93% x̃: 0.60% 95% mean confidence interval for instructions value: 0.43 0.77 95% mean confidence interval for instructions %-change: 0.45% 0.68% Instructions are HURT. total loops in shared programs: 863 -> 861 (-0.23%) loops in affected programs: 4 -> 2 (-50.00%) helped: 2 HURT: 0 total cycles in shared programs: 239357490 -> 238907668 (-0.19%) cycles in affected programs: 17314006 -> 16864184 (-2.60%) helped: 176 HURT: 34 helped stats (abs) min: 4 max: 13400 x̄: 2558.05 x̃: 2920 helped stats (rel) min: 0.01% max: 35.58% x̄: 3.76% x̃: 2.69% HURT stats (abs) min: 2 max: 14 x̄: 11.59 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2440.68 -1843.34 95% mean confidence interval for cycles %-change: -3.78% -2.51% Cycles are helped. GM45 total instructions in shared programs: 4985293 -> 4985401 (<.01%) instructions in affected programs: 58807 -> 58915 (0.18%) helped: 57 HURT: 202 helped stats (abs) min: 1 max: 4 x̄: 2.26 x̃: 3 helped stats (rel) min: 0.15% max: 2.23% x̄: 1.06% x̃: 1.29% HURT stats (abs) min: 1 max: 5 x̄: 1.17 x̃: 1 HURT stats (rel) min: 0.21% max: 3.85% x̄: 0.76% x̃: 0.48% 95% mean confidence interval for instructions value: 0.22 0.61 95% mean confidence interval for instructions %-change: 0.24% 0.48% Instructions are HURT. total loops in shared programs: 639 -> 638 (-0.16%) loops in affected programs: 2 -> 1 (-50.00%) helped: 1 HURT: 0 total cycles in shared programs: 153794236 -> 153546274 (-0.16%) cycles in affected programs: 9947778 -> 9699816 (-2.49%) helped: 110 HURT: 31 helped stats (abs) min: 4 max: 13400 x̄: 2257.51 x̃: 1796 helped stats (rel) min: 0.01% max: 35.58% x̄: 4.33% x̃: 2.45% HURT stats (abs) min: 2 max: 14 x̄: 11.74 x̃: 14 HURT stats (rel) min: <.01% max: 0.06% x̄: 0.03% x̃: 0.03% 95% mean confidence interval for cycles value: -2113.77 -1403.42 95% mean confidence interval for cycles %-change: -4.27% -2.47% Cycles are helped. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2899 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12064>
2021-07-26 23:25:58 +10:00
progress |= opt_gcm_impl(shader, function->impl, value_number);
}
return progress;
}