freedreno/ir3: add simplified stall estimation
authorRob Clark <robdclark@chromium.org>
Wed, 4 Mar 2020 18:51:10 +0000 (10:51 -0800)
committerMarge Bot <eric+marge@anholt.net>
Tue, 10 Mar 2020 16:01:39 +0000 (16:01 +0000)
Doesn't take into account stalls that result from a register written in
a different block, etc.  But this should be more useful than just using
number of (ss)'s by trying to estimate how costly a given sync is.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4071>

src/freedreno/ir3/ir3.c
src/freedreno/ir3/ir3.h
src/gallium/drivers/freedreno/ir3/ir3_gallium.c

index 0dbe9bb..bf84270 100644 (file)
@@ -911,6 +911,8 @@ void * ir3_assemble(struct ir3 *shader, struct ir3_info *info,
        ptr = dwords = calloc(4, info->sizedwords);
 
        foreach_block (block, &shader->block_list) {
+               unsigned sfu_delay = 0;
+
                foreach_instr (instr, &block->instr_list) {
                        int ret = emit[opc_cat(instr->opc)](instr, dwords, info);
                        if (ret)
@@ -925,11 +927,19 @@ void * ir3_assemble(struct ir3 *shader, struct ir3_info *info,
                                info->nops_count += 1 + instr->repeat;
                        dwords += 2;
 
-                       if (instr->flags & IR3_INSTR_SS)
+                       if (instr->flags & IR3_INSTR_SS) {
                                info->ss++;
+                               info->sstall += sfu_delay;
+                       }
 
                        if (instr->flags & IR3_INSTR_SY)
                                info->sy++;
+
+                       if (is_sfu(instr)) {
+                               sfu_delay = 10;
+                       } else if (sfu_delay > 0) {
+                               sfu_delay--;
+                       }
                }
        }
 
index b66d8e2..1a3edbc 100644 (file)
@@ -59,6 +59,9 @@ struct ir3_info {
        /* number of sync bits: */
        uint16_t ss, sy;
 
+       /* estimate of number of cycles stalled on (ss) */
+       uint16_t sstall;
+
        uint16_t last_baryf;     /* instruction # of last varying fetch */
 };
 
index 5a47376..9ad67d2 100644 (file)
@@ -53,7 +53,7 @@ dump_shader_info(struct ir3_shader_variant *v, bool binning_pass,
        pipe_debug_message(debug, SHADER_INFO,
                        "%s shader: %u inst, %u nops, %u non-nops, %u dwords, "
                        "%u last-baryf, %u half, %u full, %u constlen, "
-                       "%u (ss), %u (sy), %d max_sun, %d loops\n",
+                       "%u sstall, %u (ss), %u (sy), %d max_sun, %d loops\n",
                        ir3_shader_stage(v),
                        v->info.instrs_count,
                        v->info.nops_count,
@@ -63,6 +63,7 @@ dump_shader_info(struct ir3_shader_variant *v, bool binning_pass,
                        v->info.max_half_reg + 1,
                        v->info.max_reg + 1,
                        v->constlen,
+                       v->info.sstall,
                        v->info.ss, v->info.sy,
                        v->max_sun, v->loops);
 }