brw: Use debug archive file with INTEL_DEBUG=mda

Instead of dumping multiple files with the optimizer passes, write a single
archive file with all the contents.  The actual file is created
by the drivers, so later commits will actually enable the feature in
anv and iris.

This removes the use of INTEL_DEBUG=optimizer (and the corresponding
enum value) in brw.  That environment variable is still used by ELK --
which currently doesn't support mda.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29146>
This commit is contained in:
Caio Oliveira 2024-05-10 13:44:44 -07:00
parent bccc0fa984
commit f82d85a685
15 changed files with 33 additions and 24 deletions

View file

@ -565,6 +565,9 @@ Intel driver environment variables
print instruction hex dump with the disassembly
``l3``
emit messages about the new L3 state during transitions
``mda``
generate mda.tar files containing shader at each optimization
pass and iteration that make progress (Gfx >= 9)
``mesh``
dump shader assembly for mesh shaders
``no8``
@ -588,7 +591,7 @@ Intel driver environment variables
disable lossless color compression
``optimizer``
dump shader assembly to files at each optimization pass and
iteration that make progress
iteration that make progress (Gfx < 9)
``pc``
emit messages about PIPE_CONTROL instruction usage
``perf``

View file

@ -97,6 +97,7 @@ compile_single_bs(const struct brw_compiler *compiler,
.needs_register_pressure = stats != NULL,
.log_data = params->base.log_data,
.debug_enabled = debug_enabled,
.archiver = params->base.archiver,
};
brw_shader s(&shader_params);

View file

@ -221,6 +221,7 @@ brw_compile_cs(const struct brw_compiler *compiler,
.needs_register_pressure = params->base.stats != NULL,
.log_data = params->base.log_data,
.debug_enabled = debug_enabled,
.archiver = params->base.archiver,
};
v[simd] = std::make_unique<brw_shader>(&shader_params);
brw_adjust_uniforms(*v[simd]);

View file

@ -1595,6 +1595,7 @@ brw_compile_fs(const struct brw_compiler *compiler,
.needs_register_pressure = params->base.stats != NULL,
.log_data = params->base.log_data,
.debug_enabled = debug_enabled,
.archiver = params->base.archiver,
};
if (devinfo->ver < 20) {

View file

@ -370,6 +370,7 @@ brw_compile_gs(const struct brw_compiler *compiler,
.needs_register_pressure = params->base.stats != NULL,
.log_data = params->base.log_data,
.debug_enabled = debug_enabled,
.archiver = params->base.archiver,
};
brw_shader v(&shader_params);
v.gs.control_data_bits_per_vertex = control_data_bits_per_vertex;

View file

@ -416,6 +416,7 @@ brw_compile_task(const struct brw_compiler *compiler,
.needs_register_pressure = params->base.stats != NULL,
.log_data = params->base.log_data,
.debug_enabled = debug_enabled,
.archiver = params->base.archiver,
};
v[simd] = std::make_unique<brw_shader>(&shader_params);
@ -1270,6 +1271,7 @@ brw_compile_mesh(const struct brw_compiler *compiler,
.needs_register_pressure = params->base.stats != NULL,
.log_data = params->base.log_data,
.debug_enabled = debug_enabled,
.archiver = params->base.archiver,
};
v[simd] = std::make_unique<brw_shader>(&shader_params);

View file

@ -281,6 +281,7 @@ brw_compile_tcs(const struct brw_compiler *compiler,
.needs_register_pressure = params->base.stats != NULL,
.log_data = params->base.log_data,
.debug_enabled = debug_enabled,
.archiver = params->base.archiver,
};
brw_shader v(&shader_params);
if (!run_tcs(v)) {

View file

@ -183,6 +183,7 @@ brw_compile_tes(const struct brw_compiler *compiler,
.needs_register_pressure = params->base.stats != NULL,
.log_data = params->base.log_data,
.debug_enabled = debug_enabled,
.archiver = params->base.archiver,
};
brw_shader v(&shader_params);
if (!run_tes(v)) {

View file

@ -363,6 +363,7 @@ brw_compile_vs(const struct brw_compiler *compiler,
.needs_register_pressure = params->base.stats != NULL,
.log_data = params->base.log_data,
.debug_enabled = debug_enabled,
.archiver = params->base.archiver,
};
brw_shader v(&shader_params);
if (!run_vs(v)) {

View file

@ -27,6 +27,7 @@
#include "c11/threads.h"
#include "dev/intel_device_info.h"
#include "isl/isl.h"
#include "mda/debug_archiver.h"
#include "util/macros.h"
#include "util/mesa-sha1.h"
#include "util/enum_operators.h"
@ -1478,6 +1479,8 @@ struct brw_compile_params {
uint64_t debug_flag;
uint32_t source_hash;
debug_archiver *archiver;
};
/**

View file

@ -408,7 +408,8 @@ brw_shader::brw_shader(const brw_shader_params *params)
needs_register_pressure(params->needs_register_pressure),
dispatch_width(params->dispatch_width),
max_polygons(params->num_polygons),
api_subgroup_size(brw_nir_api_subgroup_size(params->nir, dispatch_width))
api_subgroup_size(brw_nir_api_subgroup_size(params->nir, dispatch_width)),
archiver(params->archiver)
{
assert(api_subgroup_size == 0 ||
api_subgroup_size == 8 ||
@ -1009,31 +1010,18 @@ brw_shader::debug_optimizer(const nir_shader *nir,
const char *pass_name,
int iteration, int pass_num) const
{
/* source_hash is not readily accessible in this context */
if (!brw_should_print_shader(nir, DEBUG_OPTIMIZER, 0))
if (!archiver)
return;
char *filename;
int ret = asprintf(&filename, "%s/%s%d-%s-%02d-%02d-%s",
debug_get_option("INTEL_SHADER_OPTIMIZER_PATH", "./"),
_mesa_shader_stage_to_abbrev(stage), dispatch_width, nir->info.name,
/* TODO: Add replacement for INTEL_SHADER_OPTIMIZER_PATH. */
const char *filename =
ralloc_asprintf(mem_ctx, "BRW%d/%02d-%02d-%s",
dispatch_width,
iteration, pass_num, pass_name);
if (ret == -1)
return;
FILE *file = stderr;
if (__normal_user()) {
file = fopen(filename, "w");
if (!file)
file = stderr;
}
brw_print_instructions(*this, file);
if (file != stderr)
fclose(file);
free(filename);
FILE *f = debug_archiver_start_file(archiver, filename);
brw_print_instructions(*this, f);
debug_archiver_finish_file(archiver);
}
static uint32_t

View file

@ -77,6 +77,8 @@ struct brw_shader_params
bool needs_register_pressure;
void *log_data;
bool debug_enabled;
debug_archiver *archiver;
};
struct brw_shader
@ -223,6 +225,8 @@ public:
struct brw_shader_stats shader_stats;
debug_archiver *archiver;
void debug_optimizer(const nir_shader *nir,
const char *pass_name,
int iteration, int pass_num) const;

View file

@ -159,7 +159,7 @@ libintel_compiler_brw = static_library(
c_args : [no_override_init_args],
cpp_args : ['-Werror=vla'],
gnu_symbol_visibility : 'hidden',
dependencies : [idep_nir_headers, idep_mesautil, idep_intel_dev, idep_vtn],
dependencies : [idep_nir_headers, idep_mesautil, idep_intel_dev, idep_vtn, idep_mda],
build_by_default : false,
)

View file

@ -71,6 +71,7 @@ static const struct debug_control_bitset debug_control[] = {
OPT1("blorp", DEBUG_BLORP),
OPT1("nodualobj", DEBUG_NO_DUAL_OBJECT_GS),
OPT1("optimizer", DEBUG_OPTIMIZER),
OPT1("mda", DEBUG_MDA),
OPT1("ann", DEBUG_ANNOTATION),
OPT1("no8", DEBUG_NO8),
OPT1("no-oaconfig", DEBUG_NO_OACONFIG),

View file

@ -57,6 +57,7 @@ enum intel_debug_flag {
DEBUG_BLORP,
DEBUG_NO_DUAL_OBJECT_GS,
DEBUG_OPTIMIZER,
DEBUG_MDA,
DEBUG_ANNOTATION,
DEBUG_NO_OACONFIG,
DEBUG_SPILL_FS,