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

dialects: (aie) Add aie dialect #1763

Merged
merged 62 commits into from
Feb 12, 2024
Merged

dialects: (aie) Add aie dialect #1763

merged 62 commits into from
Feb 12, 2024

Conversation

gabrielrodcanal
Copy link
Contributor

@gabrielrodcanal gabrielrodcanal commented Nov 8, 2023

Port of the AMD Xilinx AIE dialect for programming the AIEs on the AMD Xilinx Versal FPGA architecture. AIE is a hardened systolic array present in the Versal devices. The dialect describes netlists of AIE components and it can be lowered to the processor's assembly using the vendor's compiler. A description of the original dialect can be found here https://xilinx.github.io/mlir-aie/AIEDialect.html

Other than obvious improvements to the code the reviewers might spot, I would be interested in receiving feedback on the use of SymbolTable for DeviceOp and the reference to createObjectFifo from ObjectFifoAcquireOp. My main concern is that the user has to make sure the createObjectFifo operation is assigned to a DeviceOp before creating an ObjectFifoAcquireOp operation that refers to it. Do you see this as an acceptable restriction? If so, should we enforce this through the verifier? Find an example of what I am talking about in https://github.com/xdslproject/mlir-aie/blob/xdsl_tutorials/tutorials/tutorial-4/xdsl-tutorial-4.ipynb. In particular:

    object_fifo = aie.createObjectFifo(elem_number, tile14, tile34, i32, [256], "of")
    ...

    @Builder.region
    def region0(builder: Builder):
        ...
        builder.insert(object_fifo)
        ...
        
    device_val = IntegerAttr.from_int_and_width(0, i32)
    device = aie.DeviceOp(device_val, region0)

    acquire_fifo = aie.ObjectFifoAcquireOp(I32Attr(aie.PRODUCE_PORT), I32Attr(1), object_fifo.sym_name, device)

This forces the user to add new operations to the DeviceOp region after its creation instead of being able to insert all the operations with the builder. It looks a bit nasty to me. Example:

region0.block.add_op(core14)

I would like to request a review from @mesham, @superlopuh, @math-fehr, @AntonLydike and @PapyChacal.

BTW this doesn't pass Pyright yet, but I'd like to get some feedback before I work on fixing this.

@gabrielrodcanal gabrielrodcanal added the dialects Changes on the dialects label Nov 8, 2023
@gabrielrodcanal gabrielrodcanal self-assigned this Nov 8, 2023
Copy link

codecov bot commented Nov 8, 2023

Codecov Report

Attention: 393 lines in your changes are missing coverage. Please review.

Comparison is base (0edc396) 90.17% compared to head (ab87c87) 89.35%.

Files Patch % Lines
xdsl/dialects/experimental/aie.py 52.36% 393 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1763      +/-   ##
==========================================
- Coverage   90.17%   89.35%   -0.83%     
==========================================
  Files         305      306       +1     
  Lines       37041    37869     +828     
  Branches     5515     5591      +76     
==========================================
+ Hits        33402    33837     +435     
- Misses       2860     3253     +393     
  Partials      779      779              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gabrielrodcanal gabrielrodcanal marked this pull request as draft November 8, 2023 19:22
@compor compor changed the title [WIP] dialects: (aie) add aie dialect [WIP] dialects: (aie) Add aie dialect Nov 8, 2023
Copy link
Member

@superlopuh superlopuh left a comment

Choose a reason for hiding this comment

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

The symbol things look good to me. Is it the same as the aie dialect? Would it make sense to add some interop tests to check that this really is a reimplementation of their dialect exactly?

class FlowOp(IRDLOperation):
name = "AIE.flow"

sourceBundle: WireBundleAttr = attr_def(WireBundleAttr)
Copy link
Member

Choose a reason for hiding this comment

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

similarly here for attribute names and python vs C++ conventions, I'd recommend making python pretty and adding the translation hook thing. I'm not sure if everyone else will agree with this though, definitely a matter of personal preference

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would be your suggestion for the name of this attribute?

compor
compor previously requested changes Nov 9, 2023
Copy link
Collaborator

@compor compor left a comment

Choose a reason for hiding this comment

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

Big PR; I left some comments, which I think is a good start, but more iterations to come.

xdsl/dialects/experimental/aie.py Outdated Show resolved Hide resolved
xdsl/dialects/experimental/aie.py Outdated Show resolved Hide resolved
xdsl/dialects/experimental/aie.py Outdated Show resolved Hide resolved
xdsl/dialects/experimental/aie.py Outdated Show resolved Hide resolved
xdsl/dialects/experimental/aie.py Show resolved Hide resolved
xdsl/dialects/experimental/aie.py Show resolved Hide resolved
xdsl/dialects/experimental/aie.py Outdated Show resolved Hide resolved
xdsl/dialects/experimental/aie.py Outdated Show resolved Hide resolved
@compor compor self-requested a review November 9, 2023 00:35
Copy link
Member

@superlopuh superlopuh left a comment

Choose a reason for hiding this comment

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

Great! I think it might be worth having a go at replacing all the print without a corresponding parse with the assembly_format, but don't want to slow you down from now :)

@gabrielrodcanal
Copy link
Contributor Author

Great! I think it might be worth having a go at replacing all the print without a corresponding parse with the assembly_format, but don't want to slow you down from now :)

Yes! I'm working on it :)

Copy link
Collaborator

@compor compor left a comment

Choose a reason for hiding this comment

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

I understand that this goes to experimental but I think it might worth revisting how we do things in general regarding this.
What would constitute "graduating" from experimental?

Considering how long this took to "finalize", I am not sure writing tests would slow down development that much.

On the flip side, we are called to review a massive PR and regain context after weeks of giving an initial review.

Considering this, I don't feel confident approving this, but I don't want to block it.
So, please go ahead without my explicit approval.

@compor compor dismissed their stale review February 12, 2024 09:58

Experimental PR

@mesham mesham self-requested a review February 12, 2024 10:15
Copy link
Contributor

@mesham mesham left a comment

Choose a reason for hiding this comment

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

I think this looks good - it's adding the AMD AIE dialect into xDSL via experimental and as Gabriel has actioned the specific suggestions and comments on this I think it's good to get it checked in and usable more widely. There are some actions to write tests around this in the future, but many things in experimental lack tests (and indeed the point of experimental is to get less mature things in and available sooner) so it won't be unique in this regard. As experimental is explicitly "use at your own risk, this is less mature", then I think this is fine and nice to expand the available dialects.

Copy link
Contributor

@tobiasgrosser tobiasgrosser left a comment

Choose a reason for hiding this comment

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

I am fine adding this for now. Then we can go with smaller PRs that incrementally improve what we have.

"attribute, region, result, or successor"
"attribute, region, result, or successor",
at_position=start_pos,
end_position=end_pos,
)

def parse_type_directive(self) -> FormatDirective:
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest submitting this through a separate PR, as this is indeed not in the experimental folder or taking this out of this PR.

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 think this is a change from main, if I click on 'View file' it takes me to the merge @superlopuh did from main, so I guess there's no need for a new PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you merge latest main and make sure this diff disappears?

@tobiasgrosser
Copy link
Contributor

OK, that is good to go for me. I personally would add tests but that's up to you, I guess.

@gabrielrodcanal gabrielrodcanal merged commit 3bdaaef into main Feb 12, 2024
10 checks passed
@gabrielrodcanal gabrielrodcanal deleted the gabriel/aie branch February 12, 2024 20:09
@gabrielrodcanal
Copy link
Contributor Author

OK, that is good to go for me. I personally would add tests but that's up to you, I guess.

I will add tests in the near future, once I'm done with some deadlines!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialects Changes on the dialects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants