Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reversing the iteration dimensions #554

Open
SamirDroubi opened this issue Jan 20, 2024 · 2 comments
Open

Reversing the iteration dimensions #554

SamirDroubi opened this issue Jan 20, 2024 · 2 comments
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

Comments

@SamirDroubi
Copy link
Collaborator

SamirDroubi commented Jan 20, 2024

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:

@sched_op([ForCursorA])
def reverse_loop(proc, loop):
     """
     for i in seq(lo, hi):
          s
          ->
          s [i -> hi - (i - lo) - 1]
     """

As a sanity check:
revese_loop(reverse_loop(proc, loop), loop) would give us hi - ((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.

@SamirDroubi SamirDroubi added C: Scheduling The scheduling language and APIs C: Prog Analysis Related to formal analysis, SMT, etc. S: Needs Discussion This needs discussion to decide if important to work labels Jan 20, 2024
@yamaguchi1024
Copy link
Member

Loop carry dependency analysis will be necessary to support this, this is a good motivating example for the value sensitive analysis

@gilbo
Copy link
Contributor

gilbo commented Jan 20, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants