agx: Implement some shader-db stats

Instructions, bytes, and registers -- this should hold us over until we
can reverse the underlying uarch and get proper cycle estimations.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
This commit is contained in:
Alyssa Rosenzweig 2022-04-12 18:05:59 -04:00
parent 31b3f56813
commit 81477f3809
3 changed files with 24 additions and 6 deletions

View File

@ -1152,13 +1152,29 @@ agx_set_st_vary_final(agx_context *ctx)
static void
agx_print_stats(agx_context *ctx, unsigned size, FILE *fp)
{
unsigned nr_ins = 0, nr_bytes = 0, nr_threads = 1;
unsigned nr_ins = 0, max_reg = 0;
/* TODO */
fprintf(stderr, "%s shader: %u inst, %u bytes, %u threads, %u loops,"
"%u:%u spills:fills\n",
agx_foreach_instr_global(ctx, I) {
/* Count instructions */
nr_ins++;
/* Count registers */
agx_foreach_dest(I, d) {
if (I->dest[d].type == AGX_INDEX_REGISTER) {
max_reg = MAX2(max_reg,
I->dest[d].value + agx_write_registers(I, d) - 1);
}
}
}
/* TODO: Pipe through occupancy */
unsigned nr_threads = 1;
fprintf(stderr, "%s - %s shader: %u inst, %u bytes, %u halfregs, %u threads, "
"%u loops, %u:%u spills:fills\n",
ctx->nir->info.label ?: "",
nr_ins, nr_bytes, nr_threads, ctx->loop_count,
gl_shader_stage_name(ctx->stage),
nr_ins, size, max_reg, nr_threads, ctx->loop_count,
ctx->spills, ctx->fills);
}

View File

@ -661,6 +661,8 @@ void agx_dce(agx_context *ctx);
void agx_ra(agx_context *ctx);
void agx_pack_binary(agx_context *ctx, struct util_dynarray *emission);
unsigned agx_write_registers(agx_instr *I, unsigned d);
void agx_compute_liveness(agx_context *ctx);
void agx_liveness_ins_update(BITSET_WORD *live, agx_instr *I);

View File

@ -31,7 +31,7 @@
*/
/** Returns number of registers written by an instruction */
static unsigned
unsigned
agx_write_registers(agx_instr *I, unsigned d)
{
unsigned size = I->dest[d].size == AGX_SIZE_32 ? 2 : 1;