Mesa (main): pan/bi: Shrink live array to 8-bits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Jul 18 02:03:17 UTC 2021
Module: Mesa
Branch: main
Commit: 7de5293b897080a2a954d54e076b2c1e55f08c53
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7de5293b897080a2a954d54e076b2c1e55f08c53
Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date: Fri Jul 16 19:17:53 2021 -0400
pan/bi: Shrink live array to 8-bits
We only actually use 4-bits, so we could shrink again. But this by
itself means 1/2 the memory usage for liveness analysis and 1/2 the
copying/alloc/free.
Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11936>
---
src/panfrost/bifrost/bi_liveness.c | 12 ++++++------
src/panfrost/bifrost/bi_opt_dce.c | 2 +-
src/panfrost/bifrost/bi_ra.c | 4 ++--
src/panfrost/bifrost/compiler.h | 10 ++++------
4 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/src/panfrost/bifrost/bi_liveness.c b/src/panfrost/bifrost/bi_liveness.c
index 49297081543..6c7a7b5c100 100644
--- a/src/panfrost/bifrost/bi_liveness.c
+++ b/src/panfrost/bifrost/bi_liveness.c
@@ -32,7 +32,7 @@
* returns whether progress was made. */
void
-bi_liveness_ins_update(uint16_t *live, bi_instr *ins, unsigned max)
+bi_liveness_ins_update(uint8_t *live, bi_instr *ins, unsigned max)
{
/* live_in[s] = GEN[s] + (live_out[s] - KILL[s]) */
@@ -46,7 +46,7 @@ bi_liveness_ins_update(uint16_t *live, bi_instr *ins, unsigned max)
bi_foreach_src(ins, src) {
unsigned count = bi_count_read_registers(ins, src);
unsigned rmask = BITFIELD_MASK(count);
- uint16_t mask = (rmask << ins->src[src].offset);
+ uint8_t mask = (rmask << ins->src[src].offset);
unsigned node = bi_get_node(ins->src[src]);
if (node < max)
@@ -65,8 +65,8 @@ liveness_block_update(bi_block *blk, unsigned temp_count)
blk->live_out[i] |= succ->live_in[i];
}
- uint16_t *live = ralloc_array(blk, uint16_t, temp_count);
- memcpy(live, blk->live_out, temp_count * sizeof(uint16_t));
+ uint8_t *live = ralloc_array(blk, uint8_t, temp_count);
+ memcpy(live, blk->live_out, temp_count);
bi_foreach_instr_in_block_rev(blk, ins)
bi_liveness_ins_update(live, (bi_instr *) ins, temp_count);
@@ -112,8 +112,8 @@ bi_compute_liveness(bi_context *ctx)
if (block->live_out)
ralloc_free(block->live_out);
- block->live_in = rzalloc_array(block, uint16_t, temp_count);
- block->live_out = rzalloc_array(block, uint16_t, temp_count);
+ block->live_in = rzalloc_array(block, uint8_t, temp_count);
+ block->live_out = rzalloc_array(block, uint8_t, temp_count);
}
/* Initialize the work list with the exit block */
diff --git a/src/panfrost/bifrost/bi_opt_dce.c b/src/panfrost/bifrost/bi_opt_dce.c
index 254cd681c45..141591dc532 100644
--- a/src/panfrost/bifrost/bi_opt_dce.c
+++ b/src/panfrost/bifrost/bi_opt_dce.c
@@ -36,7 +36,7 @@ bi_opt_dead_code_eliminate(bi_context *ctx)
bi_compute_liveness(ctx);
bi_foreach_block_rev(ctx, block) {
- uint16_t *live = rzalloc_array(block, uint16_t, temp_count);
+ uint8_t *live = rzalloc_array(block, uint8_t, temp_count);
bi_foreach_successor(block, succ) {
for (unsigned i = 0; i < temp_count; ++i)
diff --git a/src/panfrost/bifrost/bi_ra.c b/src/panfrost/bifrost/bi_ra.c
index f62a6509ecb..135727f112a 100644
--- a/src/panfrost/bifrost/bi_ra.c
+++ b/src/panfrost/bifrost/bi_ra.c
@@ -207,7 +207,7 @@ bi_make_affinity(uint64_t clobber, unsigned count, bool split_file)
}
static void
-bi_mark_interference(bi_block *block, struct lcra_state *l, uint16_t *live, uint64_t preload_live, unsigned node_count, bool is_blend, bool split_file)
+bi_mark_interference(bi_block *block, struct lcra_state *l, uint8_t *live, uint64_t preload_live, unsigned node_count, bool is_blend, bool split_file)
{
bi_foreach_instr_in_block_rev(block, ins) {
/* Mark all registers live after the instruction as
@@ -265,7 +265,7 @@ bi_compute_interference(bi_context *ctx, struct lcra_state *l, bool full_regs)
bi_postra_liveness(ctx);
bi_foreach_block_rev(ctx, blk) {
- uint16_t *live = mem_dup(blk->live_out, node_count * sizeof(uint16_t));
+ uint8_t *live = mem_dup(blk->live_out, node_count);
bi_mark_interference(blk, l, live, blk->reg_live_out,
node_count, ctx->inputs->is_blend, !full_regs);
diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h
index 3e1e7e3afb0..85925e6a60c 100644
--- a/src/panfrost/bifrost/compiler.h
+++ b/src/panfrost/bifrost/compiler.h
@@ -537,11 +537,9 @@ typedef struct bi_block {
struct set *predecessors;
bool unconditional_jumps;
- /* In liveness analysis, these are live masks (per-component) for
- * indices for the block. Scalar compilers have the luxury of using
- * simple bit fields, but for us, liveness is a vector idea. */
- uint16_t *live_in;
- uint16_t *live_out;
+ /* Per 32-bit word live masks for the block indexed by node */
+ uint8_t *live_in;
+ uint8_t *live_out;
/* If true, uses clauses; if false, uses instructions */
bool scheduled;
@@ -842,7 +840,7 @@ int bi_test_packing_formats(void);
/* Liveness */
void bi_compute_liveness(bi_context *ctx);
-void bi_liveness_ins_update(uint16_t *live, bi_instr *ins, unsigned max);
+void bi_liveness_ins_update(uint8_t *live, bi_instr *ins, unsigned max);
void bi_invalidate_liveness(bi_context *ctx);
void bi_postra_liveness(bi_context *ctx);
More information about the mesa-commit
mailing list