This is an archive of the discontinued LLVM Phabricator instance.

[llvm-exegesis] getNonRedundantWriteProcRes - perform basic toplogical sorting (PR58500)
ClosedPublic

Authored by RKSimon on Oct 20 2022, 6:52 AM.

Details

Summary

getNonRedundantWriteProcRes was assuming that tblgen topologically sorted the cpu ModelProcResources[] arrays so that resource units were declared before the resource groups that used them, but unfortunately that doesn't appear to be true - in most cases it was just getting lucky based off the alphanumeric sorting that was being performed and the choice of the resource pipe names in most scheduler models (Intel models in particular).

This patch adds an explicit sort, based off llvm-mca's initializeUsedResources, that sorts by resource mask - I'm not sure whether this sorting is really enough, I don't think overlapping groups or Super resources are a problem, but somebody with more experience with this might be able to advise me....

I'd like to take this further in the future and start sharing more code between llvm-mca and llvm-exegesis - while triaging this bug I saw how similar both approaches are, but are just dissimilar enough that any refactor isn't going to be trivial :(

What is the best way to add test coverage here?

Diff Detail

Event Timeline

RKSimon created this revision.Oct 20 2022, 6:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 20 2022, 6:52 AM
Herald added a subscriber: mstojanovic. · View Herald Transcript
RKSimon requested review of this revision.Oct 20 2022, 6:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 20 2022, 6:52 AM
andreadb added a comment.EditedOct 20 2022, 7:06 AM

This patch looks like a good first step towards the goal of sharing more code between mca and exegesis (other than solving the issue with the sorting of resources).

@courbet @gchatelet what do you think?

ping - any more comments?

courbet accepted this revision.Oct 24 2022, 2:18 AM

Sorry I missed this.

I have not had that much time to work on this recently, but I agree with sharing more code :)

This revision is now accepted and ready to land.Oct 24 2022, 2:18 AM

In terms of tests right now we're using the actual model for x86 tests. I can work on adding an analysis unit test with a fake model.

In terms of tests right now we're using the actual model for x86 tests. I can work on adding an analysis unit test with a fake model.

Thank you - both the znver* and alderlake models show this in different ways