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] re-enable canonicalize pointers pass #5329

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

makslevental
Copy link
Contributor

@makslevental makslevental commented Dec 4, 2024

Disabled here #4966 (comment). Will explain soon.

@makslevental makslevental force-pushed the makslevental/re-enable-canonicalize-pointers branch from 9390a46 to bc6ba64 Compare December 4, 2024 07:22
Copy link
Contributor

@giuseros giuseros left a comment

Choose a reason for hiding this comment

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

It's looking nice! I left few comments in the code, and a general one is that I think we need to add few test cases.

Value tensorPtr = createTensorPointer(fatPtr, curLoc);
auto newForOp =
replaceForOpWithNewSignature(rewriter, forOp, {basePtr, offset});
size_t operandNum = curOperand->getOperandNumber();
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 have this into a function? Like rewriteForOpInPlace?

operandNum + 1 - forOp.getNumControlOperands();

SmallVector<Value> newInitArgs(
forOp.getInitArgs().take_front(numLeadingInitsIncludingCurOp));
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove the currentOp. It was there before exactly because we were pushing back the new operands. We can now get rid of it (and make the IR way simpler).


newForOp.getBody()->insertArgument(numLeadingInitsIncludingCurOp + 1,
offset.getType(), offset.getLoc());
newForOp.getBody()->insertArgument(numLeadingInitsIncludingCurOp + 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be numLeadingInitsIncludingCurOp + 2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No because you insert offset and then base behind it

rewriteOpMap[forOp] = newForOp;

newForOp->setOperand(operandNum, tensorPtr);
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Basically, if you remove the current operand from the the loop arguments, you won't need this anymore. This will be removed by canonicalization anyway, but it's here only because we have to pass "something" as the current operand.

Value tensorPtr = createTensorPointer(fatPtr, curLoc);
newForOp->setOperand(operandNum, tensorPtr);
}

OpOperand *forOperand = &newForOp->getOpOperand(operandNum);
// This is making sure we propagate the visit from the forOp result
Copy link
Contributor

Choose a reason for hiding this comment

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

Stale comment tbr

@makslevental makslevental force-pushed the makslevental/re-enable-canonicalize-pointers branch 2 times, most recently from cca951b to 2ca0a71 Compare December 14, 2024 01:15
@makslevental makslevental force-pushed the makslevental/re-enable-canonicalize-pointers branch from 2ca0a71 to ce211fd Compare December 16, 2024 06:19
@makslevental makslevental force-pushed the makslevental/re-enable-canonicalize-pointers branch from d1f4d6a to e4b27bd Compare December 16, 2024 20:00
@makslevental makslevental force-pushed the makslevental/re-enable-canonicalize-pointers branch from 1773949 to 5091eef Compare December 17, 2024 00:30
@makslevental makslevental force-pushed the makslevental/re-enable-canonicalize-pointers branch 2 times, most recently from 32d4271 to 9ed96db Compare December 17, 2024 01:01
@makslevental makslevental force-pushed the makslevental/re-enable-canonicalize-pointers branch 6 times, most recently from f308df9 to 1b44114 Compare December 17, 2024 22:42
@makslevental makslevental force-pushed the makslevental/re-enable-canonicalize-pointers branch 3 times, most recently from 1b6bd72 to 05c6fc1 Compare December 18, 2024 02:36
@makslevental makslevental force-pushed the makslevental/re-enable-canonicalize-pointers branch from 05c6fc1 to 55c3dd2 Compare December 18, 2024 03:32
Copy link
Contributor

Choose a reason for hiding this comment

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

As a warmup comment, could you add a test to check the issue we were having? Something on the line of:

for (%ptrA,%ptrB){
   yield %ptrB, %ptrA
}

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