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

[GPU] Ignore deallocations in shared memory reuse pass #20149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

qedawkins
Copy link
Contributor

Deallocations don't affect the liveness range and can be ignored. Additionally adds the pass to LLVMGPU pipelines as this should be free to run everywhere.

Deallocations don't affect the liveness range and can be ignored.
Additionally adds the pass to LLVMGPU pipelines as this should be free
to run everywhere.
@@ -45,6 +45,10 @@ static LivenessRange getLivenessRange(memref::AllocOp alloc,
workList.push_back(user);
continue;
}
// Skip deallocations as they don't affect the liveness range.
if (isa<memref::DeallocOp>(user)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just use alloca for shared memory and not have deallocs at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, but that's a decent amount of churn for not much benefit that I see. The deallocs are dropped at a later point though, I could just move that pattern up earlier.

Copy link
Contributor

Choose a reason for hiding this comment

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

dropping a dealloc is basically saying the alloc is really an alloca. I understand the churn is an issue, but this is precisely the difference between alloca and alloc. We are really abusing alloc here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that is true... ok I can look into changing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So most of the LLVMGPU side looks to work fine with alloca, but SPIR-V only supports memref.alloc with workgroup scope. I'll see if I can keep support for both for the time being then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR makes the switch for the two main pipelines we're developing: #20167

Some of the CUDA stuff is relying on functions that only support alloc upstream that I don't feel like going and changing.

@qedawkins
Copy link
Contributor Author

It looks like there are regressions from enabling this pass. Will have to investigate more before landing.

@krzysz00
Copy link
Contributor

krzysz00 commented Mar 5, 2025

So, the thing is "dealloc doesn't affect the liveness range" isn't true. Dealloc terminates a liveness range and causes that alloc()d memory to be reusable

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.

3 participants