[Mesa-dev] [PATCH 2/5] ra: Add q_values parameter to ra_set_finalize()
Tom Stellard
tom at stellard.net
Fri Sep 7 19:45:18 PDT 2012
From: Tom Stellard <thomas.stellard at amd.com>
This allows the user to pass precomputed q values to the allocator.
---
.../drivers/r300/compiler/radeon_pair_regalloc.c | 2 +-
src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp | 2 +-
.../drivers/dri/i965/brw_vec4_reg_allocate.cpp | 2 +-
src/mesa/program/register_allocate.c | 13 ++++++++++++-
src/mesa/program/register_allocate.h | 4 +++-
5 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c
index bb5b43f..85bb248 100644
--- a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c
+++ b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c
@@ -629,7 +629,7 @@ static void do_advanced_regalloc(struct regalloc_state * s)
get_reg_id(s->Input[i].Index, writemask));
}
- ra_set_finalize(regs);
+ ra_set_finalize(regs, NULL);
graph = ra_alloc_interference_graph(regs, node_count + s->NumInputs);
diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
index e7f11ae..b0d4124 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
@@ -142,7 +142,7 @@ brw_alloc_reg_set_for_classes(struct brw_context *brw,
class_count++;
}
- ra_set_finalize(brw->wm.regs);
+ ra_set_finalize(brw->wm.regs, NULL);
}
bool
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp
index 2d9d0c8..2cda678 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp
@@ -136,7 +136,7 @@ brw_alloc_reg_set_for_classes(struct brw_context *brw,
}
assert(reg == ra_reg_count);
- ra_set_finalize(brw->vs.regs);
+ ra_set_finalize(brw->vs.regs, NULL);
}
void
diff --git a/src/mesa/program/register_allocate.c b/src/mesa/program/register_allocate.c
index 07eb154..97d4e33 100644
--- a/src/mesa/program/register_allocate.c
+++ b/src/mesa/program/register_allocate.c
@@ -255,9 +255,11 @@ ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int r)
/**
* Must be called after all conflicts and register classes have been
* set up and before the register set is used for allocation.
+ * To avoid costly q value computation, use the q_values paramater
+ * to pass precomputed q values to this function.
*/
void
-ra_set_finalize(struct ra_regs *regs)
+ra_set_finalize(struct ra_regs *regs, unsigned int **q_values)
{
unsigned int b, c;
@@ -265,6 +267,15 @@ ra_set_finalize(struct ra_regs *regs)
regs->classes[b]->q = ralloc_array(regs, unsigned int, regs->class_count);
}
+ if (q_values) {
+ for (b = 0; b < regs->class_count; b++) {
+ for (c = 0; c < regs->class_count; c++) {
+ regs->classes[b]->q[c] = q_values[b][c];
+ }
+ }
+ return;
+ }
+
/* Compute, for each class B and C, how many regs of B an
* allocation to C could conflict with.
*/
diff --git a/src/mesa/program/register_allocate.h b/src/mesa/program/register_allocate.h
index 00b851e..2a9d611 100644
--- a/src/mesa/program/register_allocate.h
+++ b/src/mesa/program/register_allocate.h
@@ -43,7 +43,9 @@ void ra_add_reg_conflict(struct ra_regs *regs,
void ra_add_transitive_reg_conflict(struct ra_regs *regs,
unsigned int base_reg, unsigned int reg);
void ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int reg);
-void ra_set_finalize(struct ra_regs *regs);
+void ra_set_num_conflicts(struct ra_regs *regs, unsigned int class_a,
+ unsigned int class_b, unsigned int num_conflicts);
+void ra_set_finalize(struct ra_regs *regs, unsigned int **conflicts);
/** @} */
/** @{ Interference graph setup.
--
1.7.3.4
More information about the mesa-dev
mailing list