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

Change aie.device op from NoTerminator to SingleBlockImplicitTerminator #1936

Merged
merged 8 commits into from
Nov 23, 2024

Conversation

fifield
Copy link
Collaborator

@fifield fifield commented Nov 20, 2024

There is a block merging pattern used by the greedy pattern rewriter which queries a values's parent block's terminator. If the value is an aie.buffer in an aie.device, the getTerminator() call will assert because aie.device has no terminator. This is the root cause of the bug in #1755. Another fix would be to modify the upstream code to first check that the block is expected to have a terminator

Copy link
Collaborator

@andrej andrej left a comment

Choose a reason for hiding this comment

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

Very nice, thank you for investigating the root cause and fixing this. I double-checked with #1772 and this changeset allows that to compile.

@@ -290,7 +290,7 @@ def __init__(
)

def get_name(self):
return self.result.get_name()
return self.sym_name.value if self.sym_name else ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good change. Before this, I had to have some_buf.get_name()[1:] somewhere in my code, I think because it contained the @ in front of the name. Good to be aware of this though in case it breaks other code anywhere (hopefully nobody did what I did).

# CHECK: (1, 0) <Channel: buffer=MemRef(%buffer_3_2, memref<10x10xi32>) producer_lock=Scalar(%buffer_3_2_producer_lock = aie.lock(%tile_3_2) {sym_name = "buffer_3_2_producer_lock"}) consumer_lock=Scalar(%buffer_3_2_consumer_lock = aie.lock(%tile_3_2) {sym_name = "buffer_3_2_consumer_lock"})>
# CHECK: (1, 1) <Channel: buffer=MemRef(%buffer_3_3, memref<10x10xi32>) producer_lock=Scalar(%buffer_3_3_producer_lock = aie.lock(%tile_3_3) {sym_name = "buffer_3_3_producer_lock"}) consumer_lock=Scalar(%buffer_3_3_consumer_lock = aie.lock(%tile_3_3) {sym_name = "buffer_3_3_consumer_lock"})>
# CHECK: (0, 0) <Channel: buffer=MemRef(%33, memref<10x10xi32>) producer_lock=Scalar(%34 = "aie.lock"(%14) <{sym_name = "_producer_lock"}> : (index) -> index) consumer_lock=Scalar(%35 = "aie.lock"(%14) <{sym_name = "_consumer_lock"}> : (index) -> index)>
# CHECK: (0, 1) <Channel: buffer=MemRef(%36, memref<10x10xi32>) producer_lock=Scalar(%37 = "aie.lock"(%15) <{sym_name = "_producer_lock"}> : (index) -> index) consumer_lock=Scalar(%38 = "aie.lock"(%15) <{sym_name = "_consumer_lock"}> : (index) -> index)>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just out of curiosity, what is happening here? Why is it fine for all these locks to have the same symbol name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, good catch, I'll investigate. There's a difference in how the ir is getting printed, likely because it isn't considered "valid" yet without a terminator when the print()s happen. But there seems to be some difference in how names/symbols are resolved too which I don't fully understand.

@keryell
Copy link
Member

keryell commented Nov 22, 2024

There is a block merging pattern used by the greedy pattern rewriter which queries a values's parent block's terminator. [...] Another fix would be to modify the upstream code to first check that the block is expected to have a terminator

Yes, go for it to upstream!
We need more people caring about the commons.

There is a block merging pattern used by the greedy pattern rewriter
which queries a values's parent block's terminator. If the value
is an aie.buffer in an aie.device, the getTerminator() call will
assert because aie.device has no terminator. Another fix is to add
a check in the upstream code.
@fifield fifield added this pull request to the merge queue Nov 23, 2024
Merged via the queue into Xilinx:main with commit c21dee7 Nov 23, 2024
52 checks passed
@fifield fifield deleted the aie_device_end branch November 23, 2024 01:33
keryell added a commit to keryell/mlir-aie that referenced this pull request Nov 23, 2024
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.

4 participants