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

[LLVMGPUVectorDistribute] Add support for inter-subgroup multi_reduction #19596

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

Conversation

manupak
Copy link
Contributor

@manupak manupak commented Jan 3, 2025

This commit adds support for distribute multi_reductions where the reduction dimension(s) is/are distributed across subgroups.

We perform the existing reduction distribution, however, we are left with partial reductions accross subgroups.

Thereafter, we insert tranfer_write / transfer_read to shared memory to achieve a layout change where
we re-distribute reduction subgroup tiles into element tile. Finally, we do another multi_reduction to complete the reduction.

closes: #19578

@manupak manupak marked this pull request as draft January 3, 2025 17:38
@manupak
Copy link
Contributor Author

manupak commented Jan 3, 2025

Im putting this to draft as I have not yet numerically verified these changes.

This PR basically implements approach 3 of https://hackmd.io/bXwT715pQU-8rrS78LKCbw

@manupak manupak requested a review from Groverkss January 3, 2025 17:40
@@ -235,11 +235,11 @@ static void applyVectorDistribution(Operation *root,
applicator.applyDefaultCostModel();

// Collect all the operations to be distributed.
std::deque<Operation *> worklist;
llvm::SmallDenseSet<Operation *> worklist;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think vector distribution insensitive to work ordering. Am I wrong here?

Why this here now ?
I had to do this because re-distribution listener will keep adding ops to work list even if we do a operand change. Then we end up with same operation in the worklist multiple times. If folks have a better solution, Im all ears :)

@manupak manupak force-pushed the inter-sg-reduce branch 2 times, most recently from 151cc55 to 2029ed7 Compare January 3, 2025 18:19
This commit adds support for distribute multi_reductions
where the reduction dimension(s) is/are distributed across
subgroups.

We perform the existing reduction distribution, however,
we are left with partial reductions accross subgroups.

Thereafter, we insert tranfer_write / transfer_read
to shared memory to achieve a layout change where
we re-distribute reduction subgroup tiles into element
tile. Finally, we do another multi_reduction to complete
the reduction.

Signed-off-by: Manupa Karunaratne <[email protected]>
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.

[LLVMGPUVectorDistribute] Add inter-subgroup reduction support for MultiReduction
1 participant