Mesa (master): aco: allow to schedule SALU/SMEM through exec changes

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 22 14:47:50 UTC 2020


Module: Mesa
Branch: master
Commit: 3f14140f484b4af5c25ef9b23b7f23def4a32ed7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f14140f484b4af5c25ef9b23b7f23def4a32ed7

Author: Daniel Schürmann <daniel at schuermann.dev>
Date:   Wed Aug 12 16:16:46 2020 +0200

aco: allow to schedule SALU/SMEM through exec changes

Totals from 16794 (12.05% of 139391) affected shaders (NAVI10):
SGPRs: 757760 -> 762048 (+0.57%); split: -0.39%, +0.95%
VGPRs: 402844 -> 402744 (-0.02%); split: -0.04%, +0.02%
CodeSize: 22290900 -> 22285068 (-0.03%); split: -0.06%, +0.04%
MaxWaves: 294163 -> 294222 (+0.02%); split: +0.03%, -0.01%
Instrs: 4190074 -> 4188513 (-0.04%); split: -0.08%, +0.04%
Cycles: 40685028 -> 40678640 (-0.02%); split: -0.03%, +0.02%
VMEM: 7711867 -> 7704315 (-0.10%); split: +0.28%, -0.38%
SMEM: 942472 -> 1007052 (+6.85%); split: +7.15%, -0.30%
VClause: 92990 -> 92974 (-0.02%); split: -0.03%, +0.01%
SClause: 263700 -> 263810 (+0.04%); split: -0.38%, +0.42%
Copies: 277467 -> 276988 (-0.17%); split: -0.37%, +0.20%
Branches: 45899 -> 45896 (-0.01%)

Reviewed-by: Rhys Perry <pendingchaos02 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7903>

---

 src/amd/compiler/aco_scheduler.cpp | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/amd/compiler/aco_scheduler.cpp b/src/amd/compiler/aco_scheduler.cpp
index 1c6060a48f4..d7e7f1edabd 100644
--- a/src/amd/compiler/aco_scheduler.cpp
+++ b/src/amd/compiler/aco_scheduler.cpp
@@ -363,6 +363,7 @@ struct memory_event_set {
 struct hazard_query {
    bool contains_spill;
    bool contains_sendmsg;
+   bool uses_exec;
    memory_event_set mem_events;
    unsigned aliasing_storage; /* storage classes which are accessed (non-SMEM) */
    unsigned aliasing_storage_smem; /* storage classes which are accessed (SMEM) */
@@ -371,6 +372,7 @@ struct hazard_query {
 void init_hazard_query(hazard_query *query) {
    query->contains_spill = false;
    query->contains_sendmsg = false;
+   query->uses_exec = false;
    memset(&query->mem_events, 0, sizeof(query->mem_events));
    query->aliasing_storage = 0;
    query->aliasing_storage_smem = 0;
@@ -411,6 +413,7 @@ void add_to_hazard_query(hazard_query *query, Instruction *instr)
    if (instr->opcode == aco_opcode::p_spill || instr->opcode == aco_opcode::p_reload)
       query->contains_spill = true;
    query->contains_sendmsg |= instr->opcode == aco_opcode::s_sendmsg;
+   query->uses_exec |= needs_exec_mask(instr);
 
    memory_sync_info sync = get_sync_info_with_hack(instr);
 
@@ -444,11 +447,15 @@ enum HazardResult {
 
 HazardResult perform_hazard_query(hazard_query *query, Instruction *instr, bool upwards)
 {
-   if (instr->opcode == aco_opcode::p_exit_early_if)
-      return hazard_fail_exec;
-   for (const Definition& def : instr->definitions) {
-      if (def.isFixed() && def.physReg() == exec)
-         return hazard_fail_exec;
+   /* don't schedule discards downwards */
+   if (!upwards && instr->opcode == aco_opcode::p_exit_early_if)
+      return hazard_fail_unreorderable;
+
+   if (query->uses_exec) {
+      for (const Definition& def : instr->definitions) {
+         if (def.isFixed() && def.physReg() == exec)
+            return hazard_fail_exec;
+      }
    }
 
    /* don't move exports so that they stay closer together */



More information about the mesa-commit mailing list