From 7a588a5a8e6052e7d3e0270c6511fa9618ccf212 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Apr 2025 16:04:26 -0700 Subject: [PATCH] brw: Use live->max_vgrf_size in pre-RA scheduling Post-RA scheduling doesn't use liveness analysis, so we continue using MAX_VGRF_SIZE(devinfo). But for pre-RA scheduling, we now use live->max_vgrf_size. This helps get us to a place where we can emit arbitrarily large VGRFs early on in compilation, but which will be split and cleaned up prior to register allocation. It may also allocate smaller arrays in practice since MAX_VGRF_SIZE(devinfo) assumes the worst case scenario for things we actually could need to allocate. Cc: mesa-stable Reviewed-by: Matt Turner Part-of: (cherry picked from commit a45583f07812015fdcd83257645cb17b2285a456) --- .pick_status.json | 2 +- .../compiler/brw_schedule_instructions.cpp | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 96a28fdec66..b48e3356489 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1384,7 +1384,7 @@ "description": "brw: Use live->max_vgrf_size in pre-RA scheduling", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/intel/compiler/brw_schedule_instructions.cpp b/src/intel/compiler/brw_schedule_instructions.cpp index 41b0dd77e3c..9f8d5d87917 100644 --- a/src/intel/compiler/brw_schedule_instructions.cpp +++ b/src/intel/compiler/brw_schedule_instructions.cpp @@ -643,6 +643,7 @@ public: bool post_reg_alloc; int grf_count; + unsigned max_vgrf_size; const fs_visitor *s; /** @@ -708,9 +709,6 @@ brw_instruction_scheduler::brw_instruction_scheduler(void *mem_ctx, const fs_vis this->grf_count = grf_count; this->post_reg_alloc = post_reg_alloc; - const unsigned grf_write_scale = MAX_VGRF_SIZE(s->devinfo); - this->last_grf_write = linear_zalloc_array(lin_ctx, schedule_node *, grf_count * grf_write_scale); - this->nodes_len = s->cfg->last_block()->end_ip + 1; this->nodes = linear_zalloc_array(lin_ctx, schedule_node, this->nodes_len); @@ -774,8 +772,11 @@ brw_instruction_scheduler::brw_instruction_scheduler(void *mem_ctx, const fs_vis this->written = NULL; this->reads_remaining = NULL; this->hw_reads_remaining = NULL; + this->max_vgrf_size = MAX_VGRF_SIZE(s->devinfo); } + this->last_grf_write = linear_zalloc_array(lin_ctx, schedule_node *, grf_count * this->max_vgrf_size); + foreach_block(block, s->cfg) { set_current_block(block); @@ -876,6 +877,8 @@ brw_instruction_scheduler::setup_liveness(cfg_t *cfg) } } + this->max_vgrf_size = live.max_vgrf_size; + ralloc_free(payload_last_use_ip); } @@ -1212,13 +1215,13 @@ brw_instruction_scheduler::clear_last_grf_write() if (inst->dst.file == VGRF) { /* Don't bother being careful with regs_written(), quicker to just clear 2 cachelines. */ - memset(&last_grf_write[inst->dst.nr * MAX_VGRF_SIZE(s->devinfo)], 0, - sizeof(*last_grf_write) * MAX_VGRF_SIZE(s->devinfo)); + memset(&last_grf_write[inst->dst.nr * max_vgrf_size], 0, + sizeof(*last_grf_write) * max_vgrf_size); } } } else { memset(last_grf_write, 0, - sizeof(*last_grf_write) * grf_count * MAX_VGRF_SIZE(s->devinfo)); + sizeof(*last_grf_write) * grf_count * max_vgrf_size); } } @@ -1227,7 +1230,7 @@ brw_instruction_scheduler::grf_index(const brw_reg ®) { if (post_reg_alloc) return reg.nr; - return reg.nr * MAX_VGRF_SIZE(s->devinfo) + reg.offset / REG_SIZE; + return reg.nr * max_vgrf_size + reg.offset / REG_SIZE; } void