agx: add stats for preamble inst

we don't need detail but this is a good way to make sure we don't make things
blow up.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35949>
This commit is contained in:
Alyssa Rosenzweig
2025-06-25 14:43:10 -04:00
parent 78f4c7c6a4
commit 7f23f37e82
2 changed files with 16 additions and 8 deletions
+15 -8
View File
@@ -2769,6 +2769,7 @@ static void
agx_calc_stats(agx_context *ctx, unsigned size, struct agx2_stats *stats)
{
struct agx_cycle_estimate cycles = agx_estimate_cycles(ctx);
uint32_t old_preamble_inst = stats->preamble_inst;
*stats = (struct agx2_stats){
.alu = cycles.alu,
@@ -2780,6 +2781,7 @@ agx_calc_stats(agx_context *ctx, unsigned size, struct agx2_stats *stats)
.scratch = ctx->scratch_size_B,
.threads = agx_occupancy_for_register_count(ctx->max_reg).max_threads,
.loops = ctx->loop_count,
.preamble_inst = old_preamble_inst,
};
/* Count instructions */
@@ -3653,15 +3655,15 @@ agx_compile_function_nir(nir_shader *nir, nir_function_impl *impl,
else
out->nr_gprs = nr_gprs;
/* Don't dump statistics for preambles, since they're not worth optimizing */
if (!impl->function->is_preamble) {
agx_calc_stats(ctx, binary->size, &ctx->out->stats);
if (agx_should_dump(nir, AGX_DBG_SHADERDB)) {
agx2_stats_fprintf(stderr,
_mesa_shader_stage_to_abbrev(nir->info.stage),
&ctx->out->stats);
if (impl->function->is_preamble) {
uint32_t instrs = 0;
agx_foreach_instr_global(ctx, I) {
instrs++;
}
ctx->out->stats.preamble_inst = instrs;
} else {
agx_calc_stats(ctx, binary->size, &ctx->out->stats);
}
/*
@@ -3914,6 +3916,11 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
}
}
if (agx_should_dump(nir, AGX_DBG_SHADERDB)) {
agx2_stats_fprintf(stderr, _mesa_shader_stage_to_abbrev(nir->info.stage),
&out->info.stats);
}
info->stage = nir->info.stage;
/* Check these outside the stage check since nir->info.stage is the hardware
+1
View File
@@ -34,6 +34,7 @@
<stat name="Loops">Number of hardware loops</stat>
<stat name="Spills">Number of spill (stack store) instructions</stat>
<stat name="Fills">Number of fill (stack load) instructions</stat>
<stat name="Preamble instructions" display="Preamble inst">Preamble instruction count</stat>
</isa>
<family name="Pan">