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

[Transform] Create memory banks for memories used inside affine parallel loops #7804

Merged
merged 7 commits into from
Nov 14, 2024

Conversation

jiahanxie353
Copy link
Contributor

This patch partition memories used inside affine parallel loops into even banks and replace the old memrefs with new ones throughout the program.

@jiahanxie353 jiahanxie353 marked this pull request as ready for review November 12, 2024 21:23
Copy link
Member

@cgyurgyik cgyurgyik left a comment

Choose a reason for hiding this comment

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

I would like to see more tests for this code, e.g., error and corner cases.

include/circt/Transforms/Passes.td Show resolved Hide resolved
lib/Transforms/MemoryBanking.cpp Outdated Show resolved Hide resolved
lib/Transforms/MemoryBanking.cpp Outdated Show resolved Hide resolved
lib/Transforms/MemoryBanking.cpp Outdated Show resolved Hide resolved
lib/Transforms/MemoryBanking.cpp Outdated Show resolved Hide resolved
lib/Transforms/MemoryBanking.cpp Outdated Show resolved Hide resolved
lib/Transforms/MemoryBanking.cpp Show resolved Hide resolved
lib/Transforms/MemoryBanking.cpp Outdated Show resolved Hide resolved
lib/Transforms/MemoryBanking.cpp Outdated Show resolved Hide resolved
@jiahanxie353
Copy link
Contributor Author

Hey @cgyurgyik , thanks so much for the timely feedback! I have changed based on your review, including changing bankingFactor to std::optional altogether, adding the comments, some code style issues.

@jiahanxie353
Copy link
Contributor Author

Huhh.. I wonder why it has different behavior on CI and locally. I can pass ninja -C build/ check-circt no problem locally...

@cgyurgyik
Copy link
Member

Different machine?

@jiahanxie353
Copy link
Contributor Author

lol finally figure out the issue and passing the CI

ready for another round of review again!

@cgyurgyik
Copy link
Member

lol finally figure out the issue and passing the CI

ready for another round of review again!

Awesome. Can you resolve any outdated comments please?

@jiahanxie353
Copy link
Contributor Author

Awesome. Can you resolve any outdated comments please?

I believe I have resolved these based on your feedback, so I clicked "Resolve conversion" buttons. But please let me know if there's anything still need to be changed!

MemoryBankingPass(const MemoryBankingPass &other) = default;
explicit MemoryBankingPass(
std::optional<unsigned> bankingFactor = std::nullopt,
const std::function<unsigned(mlir::affine::AffineParallelOp)>
Copy link
Member

Choose a reason for hiding this comment

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

Why is this function necessary? I'm not actually seeing where this is used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not used indeed.
I referenced those affine loop transformation passes source code and saw them passing customized functions as arguments so that they can perform those customized transformation.
And I thought it could be useful in the future when the banking function is not as simple as taking the mod of the bankingFactor but some other complicated banking function (like TraceBank algorithm)
But I'm fine with removing it for now and introduce again in the future when it's actually used.

Please let me know what you think.

Copy link
Member

Choose a reason for hiding this comment

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

Yes I'd say let's remove it for now, and then re-add it when we have a definitive reason. LGTM after this is done.

@@ -0,0 +1,14 @@
// RUN: circt-opt %s -split-input-file -memory-banking="banking-factor=0" -verify-diagnostics
Copy link
Member

Choose a reason for hiding this comment

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

Nit: keep the naming consistent: memory_banking_invalid.mlir or cahnge the other to memory_bank.mlir

Copy link
Member

@cgyurgyik cgyurgyik left a comment

Choose a reason for hiding this comment

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

LGTM after the bankingFactor function parameter is removed.

@jiahanxie353
Copy link
Contributor Author

Thanks!

Merging it as the CI has passed

@jiahanxie353 jiahanxie353 merged commit ce5d670 into llvm:main Nov 14, 2024
4 checks passed
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.

2 participants