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

Emit affine.for in pragma scop #23

Merged
merged 1 commit into from
Nov 3, 2020
Merged

Conversation

chelini
Copy link
Collaborator

@chelini chelini commented Nov 3, 2020

No description provided.

Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
@@ -180,43 +180,143 @@ ValueWithOffsets MLIRScanner::VisitVarDecl(clang::VarDecl *decl) {
return ValueWithOffsets(op, {zeroIndex});
}

bool MLIRScanner::getConstantLowerBound(clang::ForStmt *fors,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! just a quick comment: does this PR currently supports only constant upper/lower bounds?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Member

@kumasento kumasento left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

}

// CHECK: affine.for %arg0 = 0 to 1024 {
// CHECK-NEXT: %{{.*}} = index_cast %arg0 : index to i32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we need to cast index to i32 here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a cast because the induction variable in the affine.for is of Index type while for Clang is i32.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to run a cast cleanup but otherwise LGTM

}

// CHECK: affine.for %arg0 = 0 to 1024 {
// CHECK-NEXT: %{{.*}} = index_cast %arg0 : index to i32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to run a cast cleanup but otherwise LGTM

@chelini chelini merged commit 8299250 into manualcodegen Nov 3, 2020
@chelini
Copy link
Collaborator Author

chelini commented Nov 3, 2020

Hi @wsmoses and @kumasento,
As the next step after this PR, I was thinking to do the following:

  • Assume everything is affine within the scop and emit affine load and affine store.
  • Generalize affine for to cover at least Polybench.

Sounds good? Do you have any comments or thoughts?

@kumasento
Copy link
Member

Hi @wsmoses and @kumasento,
As the next step after this PR, I was thinking to do the following:

  • Assume everything is affine within the scop and emit affine load and affine store.
  • Generalize affine for to cover at least Polybench.

Sounds good? Do you have any comments or thoughts?

Hi @chelini

I think these steps sounds very good to me. One concern, which might be quite trivial, is how this scop-generated affine MLIR code interacts with the rest of the std code. Maybe in some cases, you might need to add an additional reg2mem pass to deal with live SSA values.

@wsmoses
Copy link
Member

wsmoses commented Nov 3, 2020

My next question is when this is going to be run (at frontend or post-processing). If done at the frontend you may need to be mindful of what loads are affine vs std (local variables may need std loads rather than affine, but affine may work -- need to think about).

In the interim I'm going to try getting printing working and doing an end-to-end test of the polybench suite.

wsmoses pushed a commit that referenced this pull request Nov 4, 2020
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
@chelini chelini deleted the affine-cleanup-for-pr branch November 5, 2020 13:59
wsmoses pushed a commit that referenced this pull request Nov 17, 2020
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
wsmoses pushed a commit that referenced this pull request Nov 20, 2020
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Nov 20, 2020
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
wsmoses pushed a commit that referenced this pull request Nov 21, 2020
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Nov 25, 2020
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
wsmoses pushed a commit that referenced this pull request Dec 2, 2020
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
wsmoses pushed a commit that referenced this pull request Dec 11, 2020
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Mar 19, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Mar 21, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Mar 21, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Mar 21, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Mar 22, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Mar 23, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Mar 23, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Mar 23, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Mar 24, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Mar 26, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Mar 28, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Apr 30, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request May 4, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request May 4, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request May 5, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Jun 11, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
chelini pushed a commit that referenced this pull request Jun 13, 2021
Add infrastructure to emit an affine.for in a code fragment delimited by pragma
scop and pragma endscop. Currently, we emit an affine.for for trivial loops:
for (int i = constant; i < other_constant; i++ or ++i).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants