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

[AMD] Fix uniform offset computation #4678

Merged
merged 3 commits into from
Sep 9, 2024

Conversation

giuseros
Copy link
Contributor

@giuseros giuseros commented Sep 9, 2024

There was a bug in how we were splitting the uniform/non-uniform offset contribution for addptr.

Consider this IR (where U is a uniform value, e.g., , coming from a splat and NU is non-uniform, coming e.g., from a make_range).

%a = %U+%NU
%b = %a + %NU
%c = addptr %ptr, %b

It would have been rewritten to

%b = %NU+%NU
%basePtr = addptr %basePtrOld, %U
%c = addi %offset, %b

The main issue here is that %b's operand #0 has changed, i.e., the scalar contribution has been removed. This is fine if addptr is the only operation that uses %b. If any other operation uses %b, they need the "old" %b.

The solution is to accumulate both the uniform and non-uniform contributions in a separate IR and leave the original %b untouched. Possible duplications will be removed by the canonicalizer .

Doing things in this way, I also could generalize the pass to all expressions of the form (U+NU)*(U+NU).

I tried enabling this pass and running all the suite and it is working fine

Copy link
Collaborator

@antiagainst antiagainst left a comment

Choose a reason for hiding this comment

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

Nice. This is much better than mutating directly; thanks! I just have a few small nits.

@antiagainst antiagainst changed the title Fix uniform offset computation [AMD] Fix uniform offset computation Sep 9, 2024
Copy link
Collaborator

@antiagainst antiagainst left a comment

Choose a reason for hiding this comment

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

I addressed the small nits given I need to retrigger the CI after some network issues anyway.

@antiagainst antiagainst merged commit 25324a7 into triton-lang:main Sep 9, 2024
7 checks 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