ir3: Add preamble instr count metric

Turnip already had a pipeline stat to indicate whether we were using
early-preamble or not.  But no way to tell if there was a preamble at
all.  Adding a preamble instruction count tells us whether there is a
preamble, but also how big it is.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32977>
This commit is contained in:
Rob Clark 2025-01-10 08:43:01 -08:00 committed by Marge Bot
parent 894393470a
commit 114a47544f
5 changed files with 22 additions and 3 deletions

View file

@ -374,6 +374,9 @@ ir3_collect_info(struct ir3_shader_variant *v)
int n = MIN2(mem_delay, 1 + instr->repeat + instr->nop);
mem_delay -= n;
}
} else {
unsigned instrs_count = 1 + instr->repeat + instr->nop;
info->preamble_instrs_count += instrs_count;
}
if (instr->opc == OPC_SHPE)

View file

@ -38,6 +38,7 @@ struct ir3_info {
/* Size in dwords of the instructions. */
uint16_t sizedwords;
uint16_t instrs_count; /* expanded to account for rpt's */
uint16_t preamble_instrs_count;
uint16_t nops_count; /* # of nop instructions, including nopN */
uint16_t mov_count;
uint16_t cov_count;

View file

@ -930,7 +930,7 @@ ir3_shader_disasm(struct ir3_shader_variant *so, uint32_t *bin, FILE *out)
fprintf(
out,
"; %s prog %d/%d: %u cat0, %u cat1, %u cat2, %u cat3, %u cat4, %u cat5, %u cat6, %u cat7, \n",
"; %s prog %d/%d: %u cat0, %u cat1, %u cat2, %u cat3, %u cat4, %u cat5, %u cat6, %u cat7\n",
type, so->shader_id, so->id, so->info.instrs_per_cat[0],
so->info.instrs_per_cat[1], so->info.instrs_per_cat[2],
so->info.instrs_per_cat[3], so->info.instrs_per_cat[4],
@ -943,6 +943,12 @@ ir3_shader_disasm(struct ir3_shader_variant *so, uint32_t *bin, FILE *out)
type, so->shader_id, so->id, so->info.sstall, so->info.ss,
so->info.systall, so->info.sy, so->loops);
if (so->info.preamble_instrs_count) {
fprintf(
out, "; %u preamble instr, %s preamble\n",
so->info.preamble_instrs_count, so->info.early_preamble ? "early" : "late");
}
/* print shader type specific info: */
switch (so->type) {
case MESA_SHADER_VERTEX:

View file

@ -4816,6 +4816,14 @@ tu_GetPipelineExecutableStatisticsKHR(
stat->value.u64 = exe->stats.ldp_count;
}
vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) {
WRITE_STR(stat->name, "Preamble Instruction Count");
WRITE_STR(stat->description,
"Total number of IR3 instructions in the preamble.");
stat->format = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR;
stat->value.u64 = exe->stats.preamble_instrs_count;
}
vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) {
WRITE_STR(stat->name, "Early preamble");
WRITE_STR(stat->description,

View file

@ -68,7 +68,7 @@ dump_shader_info(struct ir3_shader_variant *v,
"%u dwords, %u last-baryf, %u last-helper, %u half, %u full, %u constlen, "
"%u cat0, %u cat1, %u cat2, %u cat3, %u cat4, %u cat5, %u cat6, %u cat7, "
"%u stp, %u ldp, %u sstall, %u (ss), %u systall, %u (sy), %d waves, "
"%d loops\n",
"%d loops, %u preamble inst, %s preamble\n",
ir3_shader_stage(v), v->info.instrs_count, v->info.nops_count,
v->info.instrs_count - v->info.nops_count, v->info.mov_count,
v->info.cov_count, v->info.sizedwords, v->info.last_baryf,
@ -79,7 +79,8 @@ dump_shader_info(struct ir3_shader_variant *v,
v->info.instrs_per_cat[4], v->info.instrs_per_cat[5],
v->info.instrs_per_cat[6], v->info.instrs_per_cat[7],
v->info.stp_count, v->info.ldp_count, v->info.sstall,
v->info.ss, v->info.systall, v->info.sy, v->info.max_waves, v->loops);
v->info.ss, v->info.systall, v->info.sy, v->info.max_waves, v->loops,
v->info.preamble_instrs_count, v->info.early_preamble ? "early" : "late");
}
static void