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 0dbe9bba4604128a1496b7a871f2c79971b0304e..bf84270186809421f2e883b77f77f863b75eced8 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 b66d8e2d6fd14897e2d05f9d0a352b49740e51ac..1a3edbc45309363e45531c52c1351484b93515a4 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 5a47376c14eb054b18ccad1a4c30ec50dee959c2..9ad67d2ec9b07b01eae943ef03f611613b04534a 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);
 }