<p dir="ltr"><br>
On Nov 26, 2015 6:02 AM, "Juan A. Suarez Romero" <<a href="mailto:jasuarez@igalia.com">jasuarez@igalia.com</a>> wrote:<br>
><br>
> When using INTEL_DEBUG=optimizer, each optimizing step is dump to disk,<br>
> in a separate file.<br>
><br>
> But as fs_visitor::optimize() and vec4_visitor::run() are called more<br>
> than once, it ends up overwriting the files already on disk, loosing<br>
> then previous optimizer steps.<br>
><br>
> To avoid this, add a new static variable that tracks the global<br>
> iteration across the entire life of the program running.<br>
><br>
> v2: use atomic_inc() for the static variable (Jason).<br>
><br>
> Signed-off-by: Juan A. Suarez Romero <<a href="mailto:jasuarez@igalia.com">jasuarez@igalia.com</a>><br>
> ---<br>
> src/mesa/drivers/dri/i965/brw_fs.cpp | 15 +++++++++++----<br>
> src/mesa/drivers/dri/i965/brw_vec4.cpp | 13 +++++++++----<br>
> 2 files changed, 20 insertions(+), 8 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
> index 7904f4d..72ee5cc 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
> @@ -39,6 +39,7 @@<br>
> #include "brw_program.h"<br>
> #include "brw_dead_control_flow.h"<br>
> #include "glsl/nir/glsl_types.h"<br>
> +#include "util/u_atomic.h"<br>
><br>
> using namespace brw;<br>
><br>
> @@ -4948,6 +4949,9 @@ fs_visitor::calculate_register_pressure()<br>
> void<br>
> fs_visitor::optimize()<br>
> {<br>
> + static int global_iteration_atomic = 0;<br>
> + int global_iteration;</p>
<p dir="ltr">Of you did the increment here, you could make this const.</p>
<p dir="ltr">> +<br>
> /* Start by validating the shader we currently have. */<br>
> validate();<br>
><br>
> @@ -4978,8 +4982,9 @@ fs_visitor::optimize()<br>
> \<br>
> if (unlikely(INTEL_DEBUG & DEBUG_OPTIMIZER) && this_progress) { \<br>
> char filename[64]; \<br>
> - snprintf(filename, 64, "%s%d-%s-%02d-%02d-" #pass, \<br>
> - stage_abbrev, dispatch_width, nir-><a href="http://info.name">info.name</a>, iteration, pass_num); \<br>
> + snprintf(filename, 64, "%s%d-%s-%02d-%02d-%02d-" #pass, \<br>
> + stage_abbrev, dispatch_width, nir-><a href="http://info.name">info.name</a>, \<br>
> + global_iteration, iteration, pass_num); \<br>
> \<br>
> backend_shader::dump_instructions(filename); \<br>
> } \<br>
> @@ -4990,10 +4995,12 @@ fs_visitor::optimize()<br>
> this_progress; \<br>
> })<br>
><br>
> + global_iteration = p_atomic_inc_return(&global_iteration_atomic);</p>
<p dir="ltr">It would make things more clear of you out this above the macro definition. The macro isn't used until after this, but that would be more clear if the increment were higher up.</p>
<p dir="ltr">> +<br>
> if (unlikely(INTEL_DEBUG & DEBUG_OPTIMIZER)) {<br>
> char filename[64];<br>
> - snprintf(filename, 64, "%s%d-%s-00-start",<br>
> - stage_abbrev, dispatch_width, nir-><a href="http://info.name">info.name</a>);<br>
> + snprintf(filename, 64, "%s%d-%s-%02d-00-00-start",<br>
> + stage_abbrev, dispatch_width, nir-><a href="http://info.name">info.name</a>, global_iteration);<br>
><br>
> backend_shader::dump_instructions(filename);<br>
> }<br>
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp<br>
> index 9a79d67..dd44b32 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp<br>
> @@ -29,6 +29,7 @@<br>
> #include "brw_vec4_live_variables.h"<br>
> #include "brw_dead_control_flow.h"<br>
> #include "program/prog_parameter.h"<br>
> +#include "util/u_atomic.h"<br>
><br>
> #define MAX_INSTRUCTION (1 << 30)<br>
><br>
> @@ -1779,6 +1780,9 @@ vec4_visitor::convert_to_hw_regs()<br>
> bool<br>
> vec4_visitor::run()<br>
> {<br>
> + static int global_iteration_atomic = 0;<br>
> + int global_iteration;<br>
> +<br>
> if (shader_time_index >= 0)<br>
> emit_shader_time_begin();<br>
><br>
> @@ -1812,8 +1816,8 @@ vec4_visitor::run()<br>
> \<br>
> if (unlikely(INTEL_DEBUG & DEBUG_OPTIMIZER) && this_progress) { \<br>
> char filename[64]; \<br>
> - snprintf(filename, 64, "%s-%s-%02d-%02d-" #pass, \<br>
> - stage_abbrev, nir-><a href="http://info.name">info.name</a>, iteration, pass_num); \<br>
> + snprintf(filename, 64, "%s-%s-%02d-%02d-%02d-" #pass, \<br>
> + stage_abbrev, nir-><a href="http://info.name">info.name</a>, global_iteration, iteration, pass_num); \<br>
> \<br>
> backend_shader::dump_instructions(filename); \<br>
> } \<br>
> @@ -1822,11 +1826,12 @@ vec4_visitor::run()<br>
> this_progress; \<br>
> })<br>
><br>
> + global_iteration = p_atomic_inc_return(&global_iteration_atomic);</p>
<p dir="ltr">Same comment.</p>
<p dir="ltr">> if (unlikely(INTEL_DEBUG & DEBUG_OPTIMIZER)) {<br>
> char filename[64];<br>
> - snprintf(filename, 64, "%s-%s-00-start",<br>
> - stage_abbrev, nir-><a href="http://info.name">info.name</a>);<br>
> + snprintf(filename, 64, "%s-%s-%02d-00-00-start",<br>
> + stage_abbrev, nir-><a href="http://info.name">info.name</a>, global_iteration);<br>
><br>
> backend_shader::dump_instructions(filename);<br>
> }<br>
> --<br>
> 2.5.0<br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>