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 <daniel@schuermann.dev>
Fixes: 8235bc6411 ("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>
This commit is contained in:
Tony Wasserka 2021-05-05 12:53:13 +02:00 committed by Marge Bot
parent c7d679f0f7
commit c528af1076
1 changed files with 15 additions and 3 deletions

View File

@ -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();
}