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

[AMDGPU][SIInsertWaitcnts] Do not add s_waitcnt when the counters are known to be 0 already #65735

Closed
wants to merge 3 commits into from

Conversation

jmmartinez
Copy link

Currently a WIP, I've only updated a single test to depict the change (there are ~50 tests that need update).

Differential Revision: https://reviews.llvm.org/D156679

@@ -477,7 +483,7 @@ class SIInsertWaitcnts : public MachineFunctionPass {
bool generateWaitcnt(AMDGPU::Waitcnt Wait,
MachineBasicBlock::instr_iterator It,
MachineBasicBlock &Block, WaitcntBrackets &ScoreBrackets,
MachineInstr *OldWaitcntInstr);
MachineInstr *OldWaitcntInstr) const;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like an unrelated clean up? Please commit it separately.

@@ -45,6 +45,7 @@ define void @back_off_barrier_no_fence(ptr %in, ptr %out) #0 {
; GFX11-BACKOFF-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX11-BACKOFF-NEXT: flat_load_b32 v0, v[0:1]
; GFX11-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
; GFX11-BACKOFF-NEXT: s_waitcnt_vscnt null, 0x0
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why your patch would ever cause an extra waitcnt like this.

@@ -364,7 +371,6 @@ class SIInsertWaitcnts : public MachineFunctionPass {
const MachineRegisterInfo *MRI = nullptr;
AMDGPU::IsaVersion IV;

DenseSet<MachineInstr *> TrackedWaitcntSet;
Copy link
Contributor

@jayfoad jayfoad Sep 19, 2023

Choose a reason for hiding this comment

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

Is my understanding correct? Previously we used TrackedWaitcntSet to distinguish pre-existing waitcnts from waitcnts inserted by this pass. Now we don't need that, all we need is to know the difference between hard and soft waitcnts?

Comment on lines +1288 to +1470
let mayLoad = 1;
let mayStore = 1;
let has_sdst = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these needed? The definition of S_WAITCNT above does not have them.

@jayfoad
Copy link
Contributor

jayfoad commented Sep 20, 2023

1st, 2nd and 4th commits seem like obvious cleanups. LGTM, please commit them separately.

Juan Manuel MARTINEZ CAAMAÑO added 3 commits October 25, 2023 14:36
@jmmartinez jmmartinez changed the title [WIP][AMDGPU][SIInsertWaitcnts] Do not add s_waitcnt when the counters are known to be 0 already [AMDGPU][SIInsertWaitcnts] Do not add s_waitcnt when the counters are known to be 0 already Oct 30, 2023
@kzhuravl
Copy link
Contributor

kzhuravl commented Nov 2, 2023

Hi Juan, the CQE cycle came back green, so this PR can be merged. Thanks!

@@ -34,6 +34,11 @@ static cl::opt<bool> AmdgcnSkipCacheInvalidations(
"amdgcn-skip-cache-invalidations", cl::init(false), cl::Hidden,
cl::desc("Use this to skip inserting cache invalidating instructions."));

static cl::opt<bool> AmdgcnDisableSoftWaitcnt(
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of this I suggest you change memory-legalizer-atomic-fence.ll to use -stop-after=si-memory-legalizer (and generate the checks in it with utils/update_mir_test_checks.py).

@jmmartinez
Copy link
Author

@kzhuravl that's awesome! Thanks for the update.

However, I am not able to rebase and address Jay's review since I don't have a PC available (for the next 6 months).

If somebody else could move the PR forward it would be great. Otherwise I'll finish it when I'm back.

@kzhuravl
Copy link
Contributor

kzhuravl commented Nov 7, 2023

Hi @jwanggit86, can you please take over this PR? This needs to be rebased, and review comments addressed, thanks!

@jwanggit86
Copy link
Contributor

@kzhuravl Sure. I'll take over.

@kzhuravl kzhuravl assigned Pierre-vh and unassigned jmmartinez and jwanggit86 Nov 18, 2023
@kzhuravl
Copy link
Contributor

@Pierre-vh got some cycles to look into this now, so re-assigning to him.

@Pierre-vh
Copy link
Contributor

#72830

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants