Skip to content

Conversation

@Lunderberg
Copy link
Contributor

@Lunderberg Lunderberg commented Oct 28, 2021

This is intended to simplify transformations that impact BufferStore and BufferLoad nodes. As this impacts the TIR definitions, an RFC will be posted shortly.

This PR is divided into separate commits to help in review. The first commit is the main change adding an implementation of BufferPointer, and modifying BufferStore and BufferLoad. The majority of the commits that follow are responses to this change, fixing breakages caused by the main change. The final commit "Updated transforms..." contains the simplifications to existing transformations that are enabled by the new BufferPointer.

Edit: RFC posted here.

@Lunderberg
Copy link
Contributor Author

Rebase on main to resolve conflict.

Many lowering/optimization passes that interact with buffers have
duplicated logic for handling the indices of the load/store.  By
having a separate BufferPointer node that is used to represent a
pointer to a location inside a buffer, the common index handling can
be de-duplicated.

This is the primary change of this PR, with all subsequent commits
being either changes required for or enabled by this change.
With BufferPointer now shared by both BufferLoad and BufferStore,
updating the visitors so they follow the new graph.
In this commit, avoid any refactoring to make use of the new feature.
Previously, BufferStore could have value that was incomaptible with
the buffer in which it was stored, which wasn't checked until the
BufferStore node was lowered to Store nodes.  As a result, unit tests
that validate a single transformation could have incorrect types
stored.  Now, BufferStore checks that the value being stored matches
the expected value type during its constructor, and so those unit
tests require updates.
Previously, transforms that replace a buffer or modify the indices of
a buffer needed to perform very similar replacements for both
BufferLoad and BufferStore.  Now that both of these operate on a
BufferPointer, these passes can be simplified.
Copy link
Member

@jroesch jroesch left a comment

Choose a reason for hiding this comment

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

Conceptually makes sense to me.

@vinx13
Copy link
Member

vinx13 commented Nov 1, 2021

We should have more discussions on RFC before merging this

@tqchen tqchen added the status: need RFC need RFC discussion label Nov 2, 2021
Copy link
Member

@vinx13 vinx13 left a comment

Choose a reason for hiding this comment

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

Given it is common that only buffer + indices matters in rewriting, I'd suggest refactor into RewriteBufferAccess(pair<buffer, indices>) without modifying IR itself wherever possible. We can use a pair or auxiliary data structure BufferAccess (avoid potential confusion with concrete buffer pointer) to hold the input/output. We can discuss more in the RFC

@areusch
Copy link
Contributor

areusch commented Nov 10, 2021

@tqchen @jroesch @manupa-arm i think there were some concerns about escape analysis if pointer semantics are introduced to TIR. I think this has to do with USMP's inability to detect liveness by refcounting. i didn't take a deep look at the impl here, but could we resolve whether this is a problem before merging here?

@areusch
Copy link
Contributor

areusch commented Nov 10, 2021

on second look, it looks like we're not adding a new TIR datatype which is a pointer, so nevermind about my previous concern about liveness analysis.

@Lunderberg
Copy link
Contributor Author

Closing following discussion on RFC#0042.

@Lunderberg Lunderberg closed this Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: need RFC need RFC discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants