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 IR generation to minimize the depth of the allocation nesting #543

Merged
merged 55 commits into from
Jan 16, 2025

Conversation

vksnk
Copy link
Collaborator

@vksnk vksnk commented Jan 9, 2025

This attempts to lay out allocation nodes such that the nesting is minimized. The general idea is to iteratively build up a tree of allocations starting from the allocations with the allocations with the shortest life time as the lowest level of the tree. This is not always possible in general to do and there are corner cases where nesting of allocations will have depth N regardless of the approach, but in most practical situations this will produce a structure close to the tree (for example, for the linear pipeline it should build a perfect tree of depth ~log(N)).

There are a couple of tests in the copy_pipeline which don't alias anymore, so the checks there are commented out until simplifier is able to use buffer bounds better.

Copy link
Owner

@dsharlet dsharlet 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 first pass, I need to try reading the algorithm again to better understand it.

builder/optimizations.cc Outdated Show resolved Hide resolved
builder/pipeline.cc Outdated Show resolved Hide resolved
builder/pipeline.cc Outdated Show resolved Hide resolved
builder/pipeline.cc Outdated Show resolved Hide resolved
builder/test/copy_pipeline.cc Outdated Show resolved Hide resolved
builder/pipeline.cc Show resolved Hide resolved
builder/pipeline.cc Show resolved Hide resolved
builder/pipeline.cc Outdated Show resolved Hide resolved
builder/pipeline.cc Show resolved Hide resolved
builder/pipeline.cc Outdated Show resolved Hide resolved
builder/pipeline.cc Outdated Show resolved Hide resolved
builder/pipeline.cc Outdated Show resolved Hide resolved
builder/pipeline.cc Outdated Show resolved Hide resolved
builder/pipeline.cc Outdated Show resolved Hide resolved
builder/pipeline.cc Outdated Show resolved Hide resolved
vksnk pushed a commit that referenced this pull request Jan 13, 2025
This changes `alias_buffers` to only alias copies, rather than copies
and in-place calls. Doing in-place calls correctly is tricky, and
doesn't really need all the complexity of `alias_buffers`. I think it
will be better done as a separate pass. We also don't have much that
actually relies on this functionality, and in fact a few tests were
accidentally relying on it (fixed in this PR), and this should unblock
#543.
builder/pipeline.cc Show resolved Hide resolved
builder/pipeline.cc Show resolved Hide resolved
@vksnk vksnk merged commit 57e0090 into main Jan 16, 2025
1 check passed
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