diff options
author | Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> | 2019-08-21 14:00:46 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> | 2019-08-22 12:50:14 -0700 |
commit | 58fc2603128a591e116d059b7d961eda02a03cb5 (patch) | |
tree | ea797844b3b78b25c4c5afe804dbb7a1175b2274 | |
parent | a8f86fcb512f1cb0a8cd834df0e1eba42edf9c05 (diff) |
pan/decode: Hoist shader-db stats to shared decode
We'll want all this information to validate the shader descriptor.
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
-rw-r--r-- | src/panfrost/midgard/disassemble.c | 41 | ||||
-rw-r--r-- | src/panfrost/midgard/disassemble.h | 23 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard_compile.c | 2 | ||||
-rw-r--r-- | src/panfrost/pandecode/decode.c | 42 |
4 files changed, 70 insertions, 38 deletions
diff --git a/src/panfrost/midgard/disassemble.c b/src/panfrost/midgard/disassemble.c index be26a9c36869..f42e0783b56f 100644 --- a/src/panfrost/midgard/disassemble.c +++ b/src/panfrost/midgard/disassemble.c @@ -44,7 +44,7 @@ static bool is_instruction_int = false; /* Stats */ -static unsigned nr_ins = 0; +static struct midgard_disasm_stats midg_stats; /* Prints a short form of the tag for branching, the minimum needed to be * legible and unambiguous */ @@ -554,7 +554,7 @@ print_vector_field(const char *name, uint16_t *words, uint16_t reg_word, reg_info->src2_reg, override, is_int); } - nr_ins++; + midg_stats.instruction_count++; printf("\n"); } @@ -635,7 +635,7 @@ print_scalar_field(const char *name, uint16_t *words, uint16_t reg_word, } else print_scalar_src(alu_field->src2, reg_info->src2_reg); - nr_ins++; + midg_stats.instruction_count++; printf("\n"); } @@ -744,7 +744,7 @@ print_compact_branch_writeout_field(uint16_t word) } } - nr_ins++; + midg_stats.instruction_count++; } static void @@ -782,7 +782,7 @@ print_extended_branch_writeout_field(uint8_t *words) print_tag_short(br.dest_tag); printf("\n"); - nr_ins++; + midg_stats.instruction_count++; } static unsigned @@ -1061,7 +1061,7 @@ print_load_store_instr(uint64_t data, print_load_store_arg(word->arg_2, 1); printf(" /* %X */\n", word->varying_parameters); - nr_ins++; + midg_stats.instruction_count++; } static void @@ -1349,11 +1349,11 @@ print_texture_word(uint32_t *word, unsigned tabs) printf("// unknown8 = 0x%x\n", texture->unknown8); } - nr_ins++; + midg_stats.instruction_count++; } -void -disassemble_midgard(uint8_t *code, size_t size, bool stats, unsigned nr_registers, const char *prefix) +struct midgard_disasm_stats +disassemble_midgard(uint8_t *code, size_t size) { uint32_t *words = (uint32_t *) code; unsigned num_words = size / 4; @@ -1366,9 +1366,7 @@ disassemble_midgard(uint8_t *code, size_t size, bool stats, unsigned nr_register unsigned i = 0; /* Stats for shader-db */ - unsigned nr_bundles = 0; - unsigned nr_quadwords = 0; - nr_ins = 0; + memset(&midg_stats, 0, sizeof(midg_stats)); while (i < num_words) { unsigned tag = words[i] & 0xF; @@ -1424,8 +1422,8 @@ disassemble_midgard(uint8_t *code, size_t size, bool stats, unsigned nr_register unsigned next = (words[i] & 0xF0) >> 4; /* We are parsing per bundle anyway */ - nr_bundles++; - nr_quadwords += num_quad_words; + midg_stats.bundle_count++; + midg_stats.quadword_count += num_quad_words; /* Break based on instruction prefetch flag */ @@ -1439,18 +1437,5 @@ disassemble_midgard(uint8_t *code, size_t size, bool stats, unsigned nr_register i += 4 * num_quad_words; } - if (stats) { - unsigned nr_threads = - (nr_registers <= 4) ? 4 : - (nr_registers <= 8) ? 2 : - 1; - - printf("%s" - "%u inst, %u bundles, %u quadwords, " - "%u registers, %u threads, 0 loops\n", - prefix, - nr_ins, nr_bundles, nr_quadwords, - nr_registers, nr_threads); - - } + return midg_stats; } diff --git a/src/panfrost/midgard/disassemble.h b/src/panfrost/midgard/disassemble.h index ca578b7d3aa2..dacc7a16d5dc 100644 --- a/src/panfrost/midgard/disassemble.h +++ b/src/panfrost/midgard/disassemble.h @@ -1,2 +1,23 @@ #include <stddef.h> -void disassemble_midgard(uint8_t *code, size_t size, bool stats, unsigned regs, const char *prefix); + +struct midgard_disasm_stats { + /* Counts gleaned from disassembly, or negative if the field cannot be + * inferred, for instance due to indirect access. If negative, the abs + * is the upper limit for the count. */ + + signed texture_count; + signed sampler_count; + signed attribute_count; + signed varying_count; + signed uniform_count; + signed uniform_buffer_count; + signed work_count; + + /* These are pseudometrics for shader-db */ + unsigned instruction_count; + unsigned bundle_count; + unsigned quadword_count; +}; + +struct midgard_disasm_stats +disassemble_midgard(uint8_t *code, size_t size); diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index 9d11ad25ea80..8000f72c9cf6 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -2810,7 +2810,7 @@ midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midga program->tls_size = ctx->tls_size; if (midgard_debug & MIDGARD_DBG_SHADERS) - disassemble_midgard(program->compiled.data, program->compiled.size, false, 0, ""); + disassemble_midgard(program->compiled.data, program->compiled.size); if (midgard_debug & MIDGARD_DBG_SHADERDB) { unsigned nr_bundles = 0, nr_ins = 0, nr_quadwords = 0; diff --git a/src/panfrost/pandecode/decode.c b/src/panfrost/pandecode/decode.c index de7365b39321..90d205de56ff 100644 --- a/src/panfrost/pandecode/decode.c +++ b/src/panfrost/pandecode/decode.c @@ -1720,7 +1720,7 @@ pandecode_scratchpad(uintptr_t pscratchpad, int job_no, char *suffix) static unsigned shader_id = 0; -static void +static struct midgard_disasm_stats pandecode_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type, bool is_bifrost, unsigned nr_regs) { @@ -1735,19 +1735,45 @@ pandecode_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type, printf("\n\n"); - char prefix[512]; - - snprintf(prefix, sizeof(prefix) - 1, "shader%d - %s shader: ", - shader_id++, - (type == JOB_TYPE_TILER) ? "FRAGMENT" : "VERTEX"); + struct midgard_disasm_stats stats; if (is_bifrost) { disassemble_bifrost(code, sz, false); + + /* TODO: Extend stats to Bifrost */ + stats.texture_count = -1; + stats.sampler_count = -1; + stats.attribute_count = -1; + stats.varying_count = -1; + stats.uniform_count = -1; + stats.uniform_buffer_count = -1; + stats.work_count = -1; + + stats.instruction_count = 0; + stats.bundle_count = 0; + stats.quadword_count = 0; } else { - disassemble_midgard(code, sz, true, nr_regs, prefix); + stats = disassemble_midgard(code, sz); + stats.work_count = nr_regs; } - printf("\n\n"); + /* Print shader-db stats */ + + unsigned nr_threads = + (stats.work_count <= 4) ? 4 : + (stats.work_count <= 8) ? 2 : + 1; + + printf("shader%d - %s shader: " + "%u inst, %u bundles, %u quadwords, " + "%u registers, %u threads, 0 loops\n\n\n", + shader_id++, + (type == JOB_TYPE_TILER) ? "FRAGMENT" : "VERTEX", + stats.instruction_count, stats.bundle_count, stats.quadword_count, + stats.work_count, nr_threads); + + + return stats; } static void |