This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Add GCNMaxILPSchedStrategy
ClosedPublic

Authored by kerbowa on Jul 31 2022, 11:26 PM.

Details

Summary

Creates a new scheduling strategy that attempts to maximize ILP for a single
wave.

Diff Detail

Event Timeline

kerbowa created this revision.Jul 31 2022, 11:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2022, 11:26 PM
kerbowa requested review of this revision.Jul 31 2022, 11:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2022, 11:26 PM
foad added inline comments.Aug 1 2022, 7:03 AM
llvm/test/CodeGen/AMDGPU/schedule-regpressure-limit.ll
2

Why has this changed?

kerbowa added inline comments.Aug 1 2022, 8:18 AM
llvm/test/CodeGen/AMDGPU/schedule-regpressure-limit.ll
2

I renamed the iterative scheduler cl flags to have this "iterative" prefix. Mostly for clarity and to avoid confusion with this scheduling strategy that is being added in this patch.

foad added a comment.Aug 1 2022, 9:24 AM

Is scheduling for maximum ILP the same thing as scheduling for minimum latency?

Does this patch have anything in common with lib/Target/AMDGPU/GCNILPSched.cpp? (Is that even maintained?)

llvm/test/CodeGen/AMDGPU/schedule-regpressure-limit.ll
2

Oh I see. I somehow missed that change in AMDGPUTargetMachine.cpp.

Is scheduling for maximum ILP the same thing as scheduling for minimum latency?

Yes, it's the same.

Does this patch have anything in common with lib/Target/AMDGPU/GCNILPSched.cpp? (Is that even maintained?)

That is part of the iterative scheduler. I don't know if it is maintained. I did see it was crashing on some lit tests if I changed waves-per-eu.

Does this patch have anything in common with lib/Target/AMDGPU/GCNILPSched.cpp? (Is that even maintained?)

That is part of the iterative scheduler. I don't know if it is maintained. I did see it was crashing on some lit tests if I changed waves-per-eu.

It was probably made obsolete by the recent changes to the default scheduler. @vpykhtin do you think we still have there something useful?

rampitec added inline comments.Aug 1 2022, 11:12 AM
llvm/lib/Target/AMDGPU/GCNSchedStrategy.h
32

AFAIR PreRARematerialize shall be a last stage, it was leaving some variables in an inconsistent state. Before the last refactoring there was even static_assert about that.

I see that you are building stages pipeline within SchedStages, but probably it makes sense to reorder the enum and redefine operator++ to walk SchedStages instead of static casting integers now.

kerbowa added inline comments.Aug 1 2022, 11:55 AM
llvm/lib/Target/AMDGPU/GCNSchedStrategy.h
32

The idea is that different SchedStrategies may have different stages or permutations of stages.

I already defined operator++ in a previous patch. I'm not sure what casting of integers you are referring to.

In this patch, each SchedStrategy has the order of its stages defined in the SchedStages vector. I should make the max occupancy strategy assert that PreRARemat is the last stage in that vector and make all the checks relative to that vector.

rampitec added inline comments.Aug 1 2022, 12:17 PM
llvm/lib/Target/AMDGPU/GCNSchedStrategy.h
32

I mean the cast at line 42. It might be clearer to use a next stage from SchedStages vector rather than just incrementing GCNSchedStageID numerically. Ten years from now nobody will remember why PreRARematerialize shall be a last one, and code can easily avoid using that operator alltogether, like it does using a range based loop for SchedStages in the runSchedStages. Then imagine you would like to add it to the ILP pipeline too, it will just break operator++ logic.

foad added a comment.Aug 2 2022, 4:08 AM

+1 for the general idea of having a max ilp strategy that we can opt into.

kerbowa updated this revision to Diff 449393.Aug 2 2022, 12:42 PM

Address comments.

rampitec accepted this revision.Aug 2 2022, 12:48 PM

LGTM, thanks!

This revision is now accepted and ready to land.Aug 2 2022, 12:48 PM
This revision was landed with ongoing or failed builds.Aug 2 2022, 1:21 PM
This revision was automatically updated to reflect the committed changes.