diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-09-22 08:50:22 -0400 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-09-30 08:40:13 -0400 |
commit | b5396369d2f4cc4bbff3bd2bf0639257ffb6fde5 (patch) | |
tree | e868cfb35644f97ea55c029ad2ab020ea93237b8 /src/panfrost/midgard | |
parent | 826fd7308bba1fcd4fd4c94c798f4f45a741e657 (diff) |
pan/midgard: Add mir_update_worklist helper
After we've chosen an instruction, popped it off, and processed it, it's
time to update the worklist, removing that instruction from the
dependency graph to allow its dependents to be put onto the worklist.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/panfrost/midgard')
-rw-r--r-- | src/panfrost/midgard/midgard_schedule.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c index 046480ba2ac..8f324805cdb 100644 --- a/src/panfrost/midgard/midgard_schedule.c +++ b/src/panfrost/midgard/midgard_schedule.c @@ -767,6 +767,45 @@ mir_initialize_worklist(BITSET_WORD *worklist, midgard_instruction **instruction } } +/* Update the worklist after an instruction terminates. Remove its edges from + * the graph and if that causes any node to have no dependencies, add it to the + * worklist */ + +static void +mir_update_worklist( + BITSET_WORD *worklist, unsigned count, + midgard_instruction **instructions, midgard_instruction *done) +{ + /* Sanity check: if no instruction terminated, there is nothing to do. + * If the instruction that terminated had dependencies, that makes no + * sense and means we messed up the worklist. Finally, as the purpose + * of this routine is to update dependents, we abort early if there are + * no dependents defined. */ + + if (!done) + return; + + assert(done->nr_dependencies == 0); + + if (!done->dependents) + return; + + /* We have an instruction with dependents. Iterate each dependent to + * remove one dependency (`done`), adding dependents to the worklist + * where possible. */ + + unsigned i; + BITSET_WORD tmp; + BITSET_FOREACH_SET(i, tmp, done->dependents, count) { + assert(instructions[i]->nr_dependencies); + + if (!(--instructions[i]->nr_dependencies)) + BITSET_SET(worklist, i); + } + + free(done->dependents); +} + /* While scheduling, we need to choose instructions satisfying certain * criteria. As we schedule backwards, we choose the *last* instruction in the * worklist to simulate in-order scheduling. Chosen instructions must satisfy a |