This is an archive of the discontinued LLVM Phabricator instance.

[llvm-mca] Add cycleBegin/cycleEnd callbacks to mca::Stage.
ClosedPublic

Authored by mattd on Jul 12 2018, 9:55 AM.

Details

Summary

This patch clears up some of the semantics within the Stage class. Now, preExecute
can be called multiple times per simulated cycle. Previously preExecute was
only called once per cycle, and postExecute could have been called multiple
times.

Now, cycleStart/cycleEnd are called only once per simulated cycle.
preExecute/postExecute can be called multiple times per cycle. This
occurs because multiple execution events can occur during a single cycle.

When stages are executed (Pipeline::runCycle), the postExecute hook will
be called only if all Stages return a success from their 'execute' callback.

Diff Detail

Event Timeline

mattd created this revision.Jul 12 2018, 9:55 AM
mattd updated this revision to Diff 155210.Jul 12 2018, 10:24 AM

Moved the Instructions container cleanup to cycleEnd.

mattd updated this revision to Diff 155269.Jul 12 2018, 2:07 PM
mattd updated this revision to Diff 155270.
mattd edited the summary of this revision. (Show Details)
mattd added a comment.Jul 12 2018, 2:12 PM

I just rebased this to fix a bad diff in the previous update.

andreadb accepted this revision.Jul 12 2018, 2:58 PM

LGTM if you address the comments below.

Thanks!

tools/llvm-mca/Stage.h
45

The stage behaviour should never be dependent on the Cycle ID.
In practice (as expected) param Cycle is never used by any stage, and it can be safely removed.

48

Same.

This revision is now accepted and ready to land.Jul 12 2018, 2:58 PM
mattd marked 2 inline comments as done.Jul 12 2018, 3:26 PM

Thanks for the review @andreadb! I'm totally fine with removing the Cycle formal. I added it because I thought that some user-defined Stage might find that data useful. Likewise, the pre/postExecute callbacks take InstRef references, but no existing function makes use of that either. I'd be happy to remove that InstRef formal as a NFC in another patch.

This revision was automatically updated to reflect the committed changes.