[Mesa-dev] [PATCH 4/4] radeonsi: add radeonsi_debug_disassembly option
Marek Olšák
maraeo at gmail.com
Mon May 13 23:17:47 UTC 2019
For the series:
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Marek
On Mon, May 13, 2019 at 5:15 PM Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> This dumps disassembly to the pipe_debug_callback together with shader
> stats.
>
> Can be used together with shader-db to get full disassembly of all shaders
> in the database.
> ---
> src/gallium/drivers/radeonsi/si_debug_options.h | 1 +
> src/gallium/drivers/radeonsi/si_shader.c | 15 +++++++++------
> 2 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_debug_options.h
> b/src/gallium/drivers/radeonsi/si_debug_options.h
> index db642366ca6..ef8435804fb 100644
> --- a/src/gallium/drivers/radeonsi/si_debug_options.h
> +++ b/src/gallium/drivers/radeonsi/si_debug_options.h
> @@ -1,8 +1,9 @@
> OPT_BOOL(clear_db_cache_before_clear, false, "Clear DB cache before fast
> depth clear")
> OPT_BOOL(enable_nir, false, "Enable NIR")
> OPT_BOOL(aux_debug, false, "Generate ddebug_dumps for the auxiliary
> context")
> OPT_BOOL(sync_compile, false, "Always compile synchronously (will cause
> stalls)")
> OPT_BOOL(dump_shader_binary, false, "Dump shader binary as part of
> ddebug_dumps")
> +OPT_BOOL(debug_disassembly, false, "Report shader disassembly as part of
> driver debug messages (for shader db)")
> OPT_BOOL(vs_fetch_always_opencode, false, "Always open code vertex
> fetches (less efficient, purely for testing)")
>
> #undef OPT_BOOL
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c
> b/src/gallium/drivers/radeonsi/si_shader.c
> index 2186938fec9..4c321dc60dc 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -5154,27 +5154,22 @@ static void si_shader_dump_disassembly(struct
> si_screen *screen,
> .elf_ptrs = &binary->elf_buffer,
> .elf_sizes = &binary->elf_size }))
> return;
>
> const char *disasm;
> uint64_t nbytes;
>
> if (!ac_rtld_get_section_by_name(&rtld_binary, ".AMDGPU.disasm",
> &disasm, &nbytes))
> goto out;
>
> - fprintf(file, "Shader %s disassembly:\n", name);
> - if (nbytes > INT_MAX) {
> - fprintf(file, "too long\n");
> + if (nbytes > INT_MAX)
> goto out;
> - }
> -
> - fprintf(file, "%*s", (int)nbytes, disasm);
>
> if (debug && debug->debug_message) {
> /* Very long debug messages are cut off, so send the
> * disassembly one line at a time. This causes more
> * overhead, but on the plus side it simplifies
> * parsing of resulting logs.
> */
> pipe_debug_message(debug, SHADER_INFO,
> "Shader Disassembly Begin");
>
> @@ -5190,20 +5185,25 @@ static void si_shader_dump_disassembly(struct
> si_screen *screen,
> "%.*s", count, disasm +
> line);
> }
>
> line += count + 1;
> }
>
> pipe_debug_message(debug, SHADER_INFO,
> "Shader Disassembly End");
> }
>
> + if (file) {
> + fprintf(file, "Shader %s disassembly:\n", name);
> + fprintf(file, "%*s", (int)nbytes, disasm);
> + }
> +
> out:
> ac_rtld_close(&rtld_binary);
> }
>
> static void si_calculate_max_simd_waves(struct si_shader *shader)
> {
> struct si_screen *sscreen = shader->selector->screen;
> struct ac_shader_config *conf = &shader->config;
> unsigned num_inputs = shader->selector->info.num_inputs;
> unsigned lds_increment = sscreen->info.chip_class >= CIK ? 512 :
> 256;
> @@ -5255,20 +5255,23 @@ static void si_calculate_max_simd_waves(struct
> si_shader *shader)
>
> shader->max_simd_waves = max_simd_waves;
> }
>
> void si_shader_dump_stats_for_shader_db(struct si_screen *screen,
> struct si_shader *shader,
> struct pipe_debug_callback *debug)
> {
> const struct ac_shader_config *conf = &shader->config;
>
> + if (screen->options.debug_disassembly)
> + si_shader_dump_disassembly(screen, &shader->binary, debug,
> "main", NULL);
> +
> pipe_debug_message(debug, SHADER_INFO,
> "Shader Stats: SGPRS: %d VGPRS: %d Code Size:
> %d "
> "LDS: %d Scratch: %d Max Waves: %d Spilled
> SGPRs: %d "
> "Spilled VGPRs: %d PrivMem VGPRs: %d",
> conf->num_sgprs, conf->num_vgprs,
> si_get_shader_binary_size(screen, shader),
> conf->lds_size, conf->scratch_bytes_per_wave,
> shader->max_simd_waves, conf->spilled_sgprs,
> conf->spilled_vgprs, shader->private_mem_vgprs);
> }
> --
> 2.20.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20190513/4a6c406e/attachment.html>
More information about the mesa-dev
mailing list