Reversing the iteration dimensions #554
Labels
C: Prog Analysis
Related to formal analysis, SMT, etc.
C: Scheduling
The scheduling language and APIs
S: Needs Discussion
This needs discussion to decide if important to work
In some problems, you want to reverse the direction in which you iterate over a dimension.
For example, the natural starting algorithm of an algorithm that operate on the upper triangular part of a matrix is to iterate in the following way:
However, as you schedule you want the tail to be at the diagonal rather than at the right side of the matrix; I can provide more context why is that if necessary. So, you will want to reverse the direction of the iteration dimensions over the rows:
Supporting that will require a new primitive that performs the following transformation:
As a sanity check:
revese_loop(reverse_loop(proc, loop), loop)
would give ushi - ((hi - (i - lo) - 1) - lo) - 1 = hi - hi + i - lo + 1 + lo - 1 = i
There is a question of what analysis might be necessary to support this. A simple over-approximation would be to reuse the same analysis for parallelizing a loop then write a more specific analysis later on when the analysis gets revamped.
The text was updated successfully, but these errors were encountered: