This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Handle LDS DMA and LDS_DIRECT hazards
ClosedPublic

Authored by rampitec on Apr 27 2022, 12:52 PM.

Details

Summary

There shall be 1 wait state between M0 write and LDS DMA/LDS_DIRECT use.

Diff Detail

Event Timeline

rampitec created this revision.Apr 27 2022, 12:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2022, 12:52 PM
rampitec requested review of this revision.Apr 27 2022, 12:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2022, 12:52 PM
Herald added a subscriber: wdng. · View Herald Transcript
foad added inline comments.Apr 28 2022, 1:35 AM
llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
358–366

The coding style is strange here because it looks like it could call checkReadM0Hazards four times. But I guess in practice at most one of the conditionals will be true?

rampitec added inline comments.Apr 28 2022, 1:56 AM
llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
358–366

It tests for different types of instructions, so the actual function will be called once at most. Moreover, these are not common instructions. In fact scanning for operands to see if it uses LDS_DIRECT is more expensive.

rampitec updated this revision to Diff 426772.May 3 2022, 10:46 AM
rampitec marked an inline comment as done.

Collapsed all conditions around checkReadM0Hazards(). To me it is less readable but since there is a concern we may call checkReadM0Hazards() more than needed, combined.

arsenm added inline comments.May 3 2022, 10:55 AM
llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
358–359

Don't see why you merged in these cases that early returned before

rampitec added inline comments.May 3 2022, 10:57 AM
llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
358–366

I am generally concerned by these early returns. We may skip checking other hazards which require more waitstates. I think we may need to remove all early returns here completely with the complexity of the hazard recognizer growing.

rampitec updated this revision to Diff 426799.May 3 2022, 12:13 PM
rampitec marked an inline comment as done.

Returned early return, at least for this patch. I have convinced myself that hazards checked later cannot interfere with these instructions.

arsenm accepted this revision.May 4 2022, 1:58 PM
This revision is now accepted and ready to land.May 4 2022, 1:58 PM
This revision was landed with ongoing or failed builds.May 4 2022, 2:45 PM
This revision was automatically updated to reflect the committed changes.