Module: Mesa
Branch: staging/21.0
Commit: 718287e9c1f701000d175cc0700428137faff1f6
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=718287e9c1f701000d175cc0700428137faff1f6

Author: Tony Wasserka <[email protected]>
Date:   Wed May  5 12:53:13 2021 +0200

aco/scheduler: Fix register demand computation for downwards moves

Previously, changes in total_demand_clause were not always propagated to
total_demand. For instance, clause moves do not change the local register
demand at the end of a clause, yet they may still affect the total maximum.

Reviewed-by: Daniel Schürmann <[email protected]>
Fixes: 8235bc64112 ("aco: try to group together VMEM loads of the same 
resource")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4533
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10644>
(cherry picked from commit c528af10761aa3ea902df269d71b54425c54e877)

---

 .pick_status.json                  |  2 +-
 src/amd/compiler/aco_scheduler.cpp | 18 +++++++++++++++---
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index fa7adf07c2c..cfede3d8e2d 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -2119,7 +2119,7 @@
         "description": "aco/scheduler: Fix register demand computation for 
downwards moves",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "8235bc64112c701ae763c76417ad8bb0644ad8cb"
     },
diff --git a/src/amd/compiler/aco_scheduler.cpp 
b/src/amd/compiler/aco_scheduler.cpp
index 1e0efb4df95..81b882c0a61 100644
--- a/src/amd/compiler/aco_scheduler.cpp
+++ b/src/amd/compiler/aco_scheduler.cpp
@@ -115,7 +115,6 @@ void move_element(T begin_it, size_t idx, size_t before) {
 void MoveState::downwards_advance_helper()
 {
    source_idx--;
-   total_demand.update(register_demand[source_idx]);
 }
 
 void MoveState::downwards_init(int current_idx, bool improved_rar_, bool 
may_form_clauses)
@@ -126,7 +125,8 @@ void MoveState::downwards_init(int current_idx, bool 
improved_rar_, bool may_for
    insert_idx = current_idx + 1;
    insert_idx_clause = current_idx;
 
-   total_demand = total_demand_clause = register_demand[current_idx];
+   total_demand = register_demand[current_idx];
+   total_demand_clause = {};
 
    std::fill(depends_on.begin(), depends_on.end(), false);
    if (improved_rar) {
@@ -194,11 +194,22 @@ MoveResult MoveState::downwards_move(bool clause)
    for (int i = source_idx; i < dest_insert_idx - 1; i++)
       register_demand[i] -= candidate_diff;
    register_demand[dest_insert_idx - 1] = new_demand;
-   total_demand_clause -= candidate_diff;
    insert_idx_clause--;
+   total_demand_clause -= candidate_diff;
+   if (source_idx == insert_idx_clause) {
+      total_demand_clause = RegisterDemand{};
+   }
    if (!clause) {
       total_demand -= candidate_diff;
       insert_idx--;
+   } else {
+      /* The local demand of clause instructions did not change. But if
+       * previously total_demand_clause was greater than or equal to
+       * total_demand, the global maximum may have changed still */
+      total_demand = total_demand_clause;
+      for (int i = insert_idx_clause; i < insert_idx; ++i) {
+         total_demand.update(register_demand[i]);
+      }
    }
 
    downwards_advance_helper();
@@ -219,6 +230,7 @@ void MoveState::downwards_skip()
       }
    }
    total_demand_clause.update(register_demand[source_idx]);
+   total_demand.update(register_demand[source_idx]);
 
    downwards_advance_helper();
 }

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to