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

[Calyx] Add Static Groups and Control #5354

Merged
merged 37 commits into from
Jun 30, 2023
Merged

Conversation

andrewb1999
Copy link
Contributor

Adds Calyx static groups and control as proposed here. Static groups and control provide a first-class way to ensure the native compiler has enough information to produce efficient, static FSMs.

The first use for these static ops within CIRCT will be improving the LoopScheduleToCalyx pass, as we can now rely on static behavior to generate efficient loop FSMs.

@andrewb1999 andrewb1999 added enhancement New feature or request Calyx The Calyx dialect labels Jun 9, 2023
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.

Overall LGTM.

From an engineering perspective, I "think" we could probably reduce code duplication by having interfaces IfOpInterface, SeqOpInterface, ParOpInterface. Then have StaticSeqOp and DynamicSeqOp (or whatever). WDYT? Maybe you already tried this?

Edit: also thanks for this work! Very cool :-)

lib/Dialect/Calyx/CalyxOps.cpp Outdated Show resolved Hide resolved
@@ -0,0 +1,188 @@
// RUN: circt-translate --export-calyx --split-input-file --verify-diagnostics %s | FileCheck %s --strict-whitespace
Copy link
Member

@cgyurgyik cgyurgyik Jun 9, 2023

Choose a reason for hiding this comment

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

Can you try round-tripping with the native compiler to confirm this works as expected?

https://docs.calyxir.org/fud/circt.html#native-representation-to-mlir

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think I can do this in the CIRCT CI currently. As far as I know the Calyx native compiler is not included as an optional dependency of CIRCT. I think there's a decent argument that it should be, but that's beyond the scope of this PR.

Copy link
Member

Choose a reason for hiding this comment

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

This can't be done because we don't live in the world of a monorepo.

So, unfortunately, we need to manually test this. I'm asking if you can ensure that your new changes round trip with the native compiler, i.e., does the native compiler emit correctly emit your new dialect additions. If it is not the case, then please open a bug in the native Calyx GitHub.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh ok, I understand what you mean now. I will test this manually.

Copy link
Member

Choose a reason for hiding this comment

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

Any follow up on this?

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 doesn't seem to work directly. I will open an issue on the native Calyx repo.

Copy link
Contributor

@mikeurbach mikeurbach left a comment

Choose a reason for hiding this comment

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

I took a quick look, and left some minor comments. Also agree with @cgyurgyik's suggestions.

Thanks for adding this, I'm excited to see these representations in CIRCT!

include/circt/Dialect/Calyx/CalyxControl.td Show resolved Hide resolved
include/circt/Dialect/Calyx/CalyxStructure.td Show resolved Hide resolved
}];
let arguments = (ins
I32Attr:$start,
OptionalAttr<I32Attr>:$end
Copy link
Contributor

Choose a reason for hiding this comment

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

For repeat and cycle, are 32 bits enough? I guess probably...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I made a guess here that 32 bits would be enough. I guess it's not a big deal to switch to 64 bits, but I'm not sure if it matters for any reasonable design.

lib/Dialect/Calyx/CalyxOps.cpp Outdated Show resolved Hide resolved
lib/Dialect/Calyx/Export/CalyxEmitter.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@mortbopet mortbopet left a comment

Choose a reason for hiding this comment

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

+1 for an interface or inheritance between these ops and their non-static counterparts, given that verifiers, arguments, builders, extraClassDeclarations,... seems highly identical.

@andrewb1999
Copy link
Contributor Author

Ok I added an interface for the If ops and addressed the other comments. I'm not sure that interfaces make sense for Seq and Par ops currently because most of the shared code is already handled by the ControlLike interface. I'm pretty sure that with the current Seq and Par ops adding an interface would introduce more code than it removes, but the interface could still make sense in the future if our uses of Seq and Par change a bit. Let me know what you think about those interfaces, but I think it's not really useful to have them now.

@mikeurbach
Copy link
Contributor

Sorry i haven't had a chance to take a second look, I will come back and review this.

@andrewb1999
Copy link
Contributor Author

Does anyone have a chance to review this further soon? I think I have addressed the issues and not having this merged is starting to block me.

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.

Just a question about round tripping. In general looks good.

lib/Dialect/Calyx/CalyxOps.cpp Show resolved Hide resolved
lib/Dialect/Calyx/CalyxOps.cpp Outdated Show resolved Hide resolved
@@ -0,0 +1,188 @@
// RUN: circt-translate --export-calyx --split-input-file --verify-diagnostics %s | FileCheck %s --strict-whitespace
Copy link
Member

Choose a reason for hiding this comment

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

Any follow up on this?

@andrewb1999
Copy link
Contributor Author

I'm going to go ahead and merge this now, but if anyone has any extra comments in the future I will be happy to address them in another PR.

@andrewb1999 andrewb1999 merged commit 9c73025 into llvm:main Jun 30, 2023
calebmkim added a commit to andrewb1999/circt that referenced this pull request Jul 12, 2023
Co-authored-by: Pai Li <pl582@cornell.edu>
Co-authored-by: Caleb <cmk265@cornell.edu>
@andrewb1999 andrewb1999 deleted the static-calyx branch February 28, 2024 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Calyx The Calyx dialect enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants