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 sequential memories #5471

Merged
merged 11 commits into from
Jun 26, 2023
Merged

Conversation

andrewb1999
Copy link
Contributor

Adds new calyx.seq_mem op which, in contrast to calyx.memory, has sequential reads. Sequential reads on memories is much more realistic than combinational reads for most use cases. Native Calyx is planning to deprecate std_mem soon as many users are accidentally using that instead of seq_mem, which can significantly hurt the QOR.

We will still need to change the LoopScheduleToCalyx pass to use calyx.seq_mem instead of calyx.memory before deprecating std_mem, which is something I am working on while adding loop schedule support for sequential loops.

Copy link
Contributor

@rachitnigam rachitnigam left a comment

Choose a reason for hiding this comment

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

Broken documentation link but otherwise looks good

include/circt/Dialect/Calyx/CalyxPrimitives.td Outdated Show resolved Hide resolved
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.

Thanks!

dimension in `$sizes`. The `$width` attribute dictates the width of a single
element.

See https://capra.cs.cornell.edu/docs/calyx/libraries/core.html#memories for
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be fixed here as well

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.

I know this PR has already received approvals, and I'm not going to block it if you really want to merge. But i think it's somewhat smelly code that the return values of this op isn't implemented in what i'd consider the canonical way to do this.

);

let results = (outs
Variadic<AnySignlessInteger>:$results
Copy link
Contributor

@mortbopet mortbopet Jun 26, 2023

Choose a reason for hiding this comment

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

Really not a big fan of the long results type list (: i1, i32, i1, i1, i32, i1) when most (all?) of those are known based on the memory type (size attributes).
Could change the results to

let results = (outs Variadic<AnySignlessInteger>:$addrs, AnySignlessInteger:$writeData, I1:$wrEn, I1:$wrDone, I1:$clk, AnySignlessInteger:$rdData, I1:$rdEn, I1:$rdDone)>

and using the InferTypeOpInterface. This would also be much more canonical, in that all of the custom getters that you've implemented will be autogenerated.

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 agree, but I am just following the method used on existing Calyx ops for now. This op functions very similarly to the existing calyx.memory op. Maybe I can merge this PR and then work on another PR at a later date to bring all of the Calyx ops inline with the suggestions you make?

Copy link
Contributor

Choose a reason for hiding this comment

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

Works for me - a general cleanup in this aspect would be nice!

lib/Dialect/Calyx/CalyxOps.cpp Outdated Show resolved Hide resolved
@andrewb1999
Copy link
Contributor Author

I'm going to go ahead and merge this and then work on a PR that infers the types for all Calyx primitives, because I agree that the long list of types is pretty annoying.

@andrewb1999 andrewb1999 merged commit 2706aec into llvm:main Jun 26, 2023
5 checks passed
@cgyurgyik cgyurgyik mentioned this pull request Jul 19, 2023
1 task
@andrewb1999 andrewb1999 deleted the add-seq-memories 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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants