This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Check MI bundles for hazards
ClosedPublic

Authored by kerbowa on May 5 2019, 1:55 AM.

Details

Summary

GCNHazardRecognizer fails to identify hazards that are in and around bundles. This patch allows the hazard recognizer to consider bundled instructions in both scheduler and hazard recognizer mode. We ignore “bundledness” for the purpose of detecting hazards and examine the instructions individually.

Diff Detail

Event Timeline

kerbowa created this revision.May 5 2019, 1:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2019, 1:55 AM
kerbowa edited the summary of this revision. (Show Details)May 5 2019, 2:09 AM

Can you add a test for one of the hazards which do not expire and have no max waitstaits? Such as hazards from smem-war-hazard.mir for example.
Granted we do not do it today, but you can write a bundle with such instructions manually.

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
1172 ↗(On Diff #198170)

I do not like code duplication here. Can you call one from another?

kerbowa updated this revision to Diff 198199.May 5 2019, 1:08 PM

Add 'fixHazard' checks.

kerbowa marked 2 inline comments as done.May 5 2019, 1:12 PM
kerbowa added inline comments.
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
1172 ↗(On Diff #198170)

At first glance having the standard insertWaitStates call the instr_iterator version seems to break a bunch of tests. I can just add a function to insert noop's in bundles in GCNHazardRecognizer instead.

arsenm added a comment.May 6 2019, 1:37 AM

Can you add a separate test file for cases where a hazard was hidden by a bundle, and another for where the hazard is inside the bundle?

Can you add a separate test file for cases where a hazard was hidden by a bundle, and another for where the hazard is inside the bundle?

LGTM, but I am second to that.

kerbowa updated this revision to Diff 198399.May 6 2019, 11:58 PM
kerbowa marked an inline comment as done.

Add seperate test files.

There is no reason to split two test files.
For the test itself, could you please add one more. You have test where hazard instruction follows bundle. Can you add the same, where it is in bundle, and another one precedes it? Thanks!

arsenm added a comment.May 7 2019, 5:53 AM

The separate files helps me read which test is for which purpose

The separate files helps me read which test is for which purpose

Ok, let them be separate.

For the test itself, could you please add one more. You have test where hazard instruction follows bundle. Can you add the same, where it is in bundle, and another one precedes it? Thanks!

Sorry, I'm not sure I understand exactly what you mean. Do you want a hazard instruction in a bundle with another hazard instruction preceding it?

For the test itself, could you please add one more. You have test where hazard instruction follows bundle. Can you add the same, where it is in bundle, and another one precedes it? Thanks!

Sorry, I'm not sure I understand exactly what you mean. Do you want a hazard instruction in a bundle with another hazard instruction preceding it?

Right.

kerbowa updated this revision to Diff 198536.May 7 2019, 2:49 PM

Add new test.

rampitec accepted this revision.May 7 2019, 2:51 PM

LGTM

This revision is now accepted and ready to land.May 7 2019, 2:51 PM
This revision was automatically updated to reflect the committed changes.