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

[LowerVTCMAlloc] Move LowerVtcmAlloc to after StorageRewrite #12364

Merged
merged 2 commits into from
Aug 12, 2022

Conversation

tkonolige
Copy link
Contributor

Vtcm allocations were being moved inside loops even if they were originally allocated outside of the loops. Normally PlanAndUpdateBufferAllocationLocation moves allocations as close to use as possible and then StorageRewrite moves them back out as far as possible. However, with Vtcm allocation, PlanAndUpdateBufferAllocationLocation would move the Vtcm allocation close to the compute, then LowerVtcm would convert the allocation to a LetStmt. StorageRewrite would not move this LetStmt as it only handles allocations. Moving LowerVtcmAlloc to after StorageRewrite ensures that the vtcm allocations are in their final spot before converting them to a LetStmt.

@csullivan @Lunderberg

Tristan Konolige added 2 commits August 10, 2022 13:14
Vtcm allocations were being moved inside loops even if they were
originally allocated outside of the loops. Normally
PlanAndUpdateBufferAllocationLocation moves allocations as close to use
as possible and then StorageRewrite moves them back out as far as
possible. However, with Vtcm allocation,
PlanAndUpdateBufferAllocationLocation would move the Vtcm allocation
close to the compute, then LowerVtcm would convert the allocation to a
LetStmt. StorageRewrite would not move this LetStmt as it only handles
allocations. Moving LowerVtcmAlloc to after StorageRewrite ensures that
the vtcm allocations are in their final spot before converting them to a
LetStmt.
Copy link
Contributor

@csullivan csullivan left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the discussions and effort on this @tkonolige and @Lunderberg.

@@ -583,8 +583,10 @@ class StoragePlanRewriter : public StmtExprMutator {
};

// Checks whether the storage_scope is especially tagged for a specific memory.
// Special memory is all combined into a single allocation.
Copy link
Contributor

Choose a reason for hiding this comment

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

I've verified that with the special tagged memory helper change we are getting correct behavior for aligned access in the cases that I mentioned to fail previously.

@csullivan csullivan merged commit 3eb6734 into apache:main Aug 12, 2022
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
…12364)

* [LowerVTCMAlloc] Move LowerVtcmAlloc to after StorageRewrite

Vtcm allocations were being moved inside loops even if they were
originally allocated outside of the loops. Normally
PlanAndUpdateBufferAllocationLocation moves allocations as close to use
as possible and then StorageRewrite moves them back out as far as
possible. However, with Vtcm allocation,
PlanAndUpdateBufferAllocationLocation would move the Vtcm allocation
close to the compute, then LowerVtcm would convert the allocation to a
LetStmt. StorageRewrite would not move this LetStmt as it only handles
allocations. Moving LowerVtcmAlloc to after StorageRewrite ensures that
the vtcm allocations are in their final spot before converting them to a
LetStmt.

* fix issues with tagging and storage rewrite
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