From e1d20b69c4fc152ebd8ac4bded7b879db7e8d7d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 11 Jan 2024 10:38:40 +0100 Subject: [PATCH] aco: give spiller more room to assign spilled SGPRs to VGPRs On chordal graphs, a greedy coloring can be done in a way that never uses more colors than are required for the largest clique. However, since we have vector values and force phi resources into the same spill slots, the interference graphs are not chordal, and thus, this assumption doesn't hold. Use twice as many spill slots as upper bound. Totals from 10 (0.01% of 79242) affected shaders: (GFX11) MaxWaves: 52 -> 54 (+3.85%) Instrs: 271386 -> 271779 (+0.14%) CodeSize: 1362544 -> 1365432 (+0.21%) VGPRs: 2536 -> 2532 (-0.16%) SpillVGPRs: 778 -> 818 (+5.14%) Scratch: 73472 -> 76800 (+4.53%) Latency: 3331718 -> 3328798 (-0.09%); split: -0.14%, +0.05% InvThroughput: 1665860 -> 1643350 (-1.35%); split: -1.40%, +0.05% VClause: 3292 -> 3329 (+1.12%); split: -0.06%, +1.18% Copies: 46082 -> 46257 (+0.38%) Cc: mesa-stable Part-of: (cherry picked from commit e3098bb23284b598ec6d5030ceaa1c3d5bd9d428) --- .pick_status.json | 2 +- src/amd/compiler/aco_spill.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index c5b9dba8260..964610bd4fc 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -714,7 +714,7 @@ "description": "aco: give spiller more room to assign spilled SGPRs to VGPRs", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp index 67fb00a8d8e..8da3d49202b 100644 --- a/src/amd/compiler/aco_spill.cpp +++ b/src/amd/compiler/aco_spill.cpp @@ -1938,7 +1938,7 @@ spill(Program* program, live& live_vars) /* calculate extra VGPRs required for spilling SGPRs */ if (demand.sgpr > sgpr_limit) { unsigned sgpr_spills = demand.sgpr - sgpr_limit; - extra_vgprs = DIV_ROUND_UP(sgpr_spills, program->wave_size) + 1; + extra_vgprs = DIV_ROUND_UP(sgpr_spills * 2, program->wave_size) + 1; } /* add extra SGPRs required for spilling VGPRs */ if (demand.vgpr + extra_vgprs > vgpr_limit) { @@ -1949,7 +1949,7 @@ spill(Program* program, live& live_vars) if (demand.sgpr + extra_sgprs > sgpr_limit) { /* re-calculate in case something has changed */ unsigned sgpr_spills = demand.sgpr + extra_sgprs - sgpr_limit; - extra_vgprs = DIV_ROUND_UP(sgpr_spills, program->wave_size) + 1; + extra_vgprs = DIV_ROUND_UP(sgpr_spills * 2, program->wave_size) + 1; } } /* the spiller has to target the following register demand */