Mesa (master): pan/lcra: Use Chaitin's spilling heuristic
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Nov 14 02:58:51 UTC 2019
Module: Mesa
Branch: master
Commit: 39b5f2fa0bc904b8a8eff695bdcb8981c7b9a33e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=39b5f2fa0bc904b8a8eff695bdcb8981c7b9a33e
Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date: Wed Nov 13 15:57:18 2019 -0500
pan/lcra: Use Chaitin's spilling heuristic
Not much of a difference but slightly better and slightly less
arbitrary.
total instructions in shared programs: 3560 -> 3559 (-0.03%)
instructions in affected programs: 44 -> 43 (-2.27%)
helped: 1
HURT: 0
total bundles in shared programs: 1844 -> 1843 (-0.05%)
bundles in affected programs: 23 -> 22 (-4.35%)
helped: 1
HURT: 0
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
---
src/panfrost/midgard/lcra.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/panfrost/midgard/lcra.c b/src/panfrost/midgard/lcra.c
index d86c35ffe09..f5e2ff2d8fe 100644
--- a/src/panfrost/midgard/lcra.c
+++ b/src/panfrost/midgard/lcra.c
@@ -201,7 +201,7 @@ lcra_count_constraints(struct lcra_state *l, unsigned i)
signed
lcra_get_best_spill_node(struct lcra_state *l)
{
- signed best_benefit = INT_MIN;
+ float best_benefit = -1.0;
signed best_node = -1;
for (unsigned i = 0; i < l->node_count; ++i) {
@@ -209,14 +209,10 @@ lcra_get_best_spill_node(struct lcra_state *l)
if (l->class[i] != l->spill_class) continue;
if (l->spill_cost[i] < 0) continue;
- /* Compute the benefit of spilling a node as the number of
- * constraints on the node plus the number of slots it occupies
- * minus a multiple of the cost. TODO: Come up with a formula
- * whose use I can justify beyond "it makes my shaderdb look
- * happy" */
-
- signed benefit = lcra_count_constraints(l, i);
- benefit -= l->spill_cost[i] * 2;
+ /* Adapted from Chaitin's heuristic */
+ float constraints = lcra_count_constraints(l, i);
+ float cost = (l->spill_cost[i] + 1);
+ float benefit = constraints / cost;
if (benefit > best_benefit) {
best_benefit = benefit;
More information about the mesa-commit
mailing list