[Mesa-dev] [PATCH 15/33] intel: error-decode: implement a rolling window of programs

Scott D Phillips scott.d.phillips at intel.com
Tue Oct 31 20:07:54 UTC 2017


Lionel Landwerlin <lionel.g.landwerlin at intel.com> writes:

> If we have more programs than what we can store,
> aubinator_error_decode will assert. Instead let's have a rolling
> window of programs.
>
> v2: Fix overflowing issues (Eric Engestrom)
>
> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
> Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>

As an enhancement, you could change the loop where programs are
disassembled and printed to go through indexes like:

[idx_program ==> idx_program - 1] % MAX_NUM_PROGRAMS 

to maintain the oldest-to-newest order. Or if you don't feel like doing
that then maybe at least print the value of idx_program so the order
programs were found can be reversed.

Patches 1-15 are

Reviewed-by: Scott D Phillips <scott.d.phillips at intel.com>

> ---
>  src/intel/tools/aubinator_error_decode.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/src/intel/tools/aubinator_error_decode.c b/src/intel/tools/aubinator_error_decode.c
> index ed4d6f662ce..52c323e77ee 100644
> --- a/src/intel/tools/aubinator_error_decode.c
> +++ b/src/intel/tools/aubinator_error_decode.c
> @@ -47,6 +47,8 @@
>  #define GREEN_HEADER CSI "1;42m"
>  #define NORMAL       CSI "0m"
>  
> +#define MIN(a, b) ((a) < (b) ? (a) : (b))
> +
>  /* options */
>  
>  static bool option_full_decode = true;
> @@ -220,7 +222,15 @@ struct program {
>  
>  #define MAX_NUM_PROGRAMS 4096
>  static struct program programs[MAX_NUM_PROGRAMS];
> -static int num_programs = 0;
> +static int idx_program = 0, num_programs = 0;
> +
> +static int next_program(void)
> +{
> +   int ret = idx_program;
> +   idx_program = (idx_program + 1) % MAX_NUM_PROGRAMS;
> +   num_programs = MIN(num_programs + 1, MAX_NUM_PROGRAMS);
> +   return ret;
> +}
>  
>  static void decode(struct gen_spec *spec,
>                     const char *buffer_name,
> @@ -300,7 +310,7 @@ static void decode(struct gen_spec *spec,
>                                 enabled[1] ? "SIMD16 fragment shader" :
>                                 enabled[2] ? "SIMD32 fragment shader" : NULL;
>  
> -            programs[num_programs++] = (struct program) {
> +            programs[next_program()] = (struct program) {
>                 .type = type,
>                 .command = inst->name,
>                 .command_offset = offset,
> @@ -309,7 +319,7 @@ static void decode(struct gen_spec *spec,
>              };
>           } else {
>              if (enabled[0]) /* SIMD8 */ {
> -               programs[num_programs++] = (struct program) {
> +               programs[next_program()] = (struct program) {
>                    .type = "SIMD8 fragment shader",
>                    .command = inst->name,
>                    .command_offset = offset,
> @@ -318,7 +328,7 @@ static void decode(struct gen_spec *spec,
>                 };
>              }
>              if (enabled[1]) /* SIMD16 */ {
> -               programs[num_programs++] = (struct program) {
> +               programs[next_program()] = (struct program) {
>                    .type = "SIMD16 fragment shader",
>                    .command = inst->name,
>                    .command_offset = offset,
> @@ -327,7 +337,7 @@ static void decode(struct gen_spec *spec,
>                 };
>              }
>              if (enabled[2]) /* SIMD32 */ {
> -               programs[num_programs++] = (struct program) {
> +               programs[next_program()] = (struct program) {
>                    .type = "SIMD32 fragment shader",
>                    .command = inst->name,
>                    .command_offset = offset,
> @@ -374,7 +384,7 @@ static void decode(struct gen_spec *spec,
>              NULL;
>  
>           if (is_enabled) {
> -            programs[num_programs++] = (struct program) {
> +            programs[next_program()] = (struct program) {
>                 .type = type,
>                 .command = inst->name,
>                 .command_offset = offset,
> @@ -383,8 +393,6 @@ static void decode(struct gen_spec *spec,
>              };
>           }
>        }
> -
> -      assert(num_programs < MAX_NUM_PROGRAMS);
>     }
>  }
>  
> -- 
> 2.15.0.rc2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list