Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Clean up 3-opt driver logic #112210

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

amanasifkhalid
Copy link
Member

Follow-up to #111989. Now that we only run one pass of 3-opt, we can remove some cruft needed to maintain state across 3-opt passes. This is a meek attempt to reduce the size of #112004 by separating out some of the no-diff changes.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 5, 2025
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

//
// Returns:
// True if we reordered anything, false otherwise
//
bool Compiler::ThreeOptLayout::RunThreeOptPass()
bool Compiler::ThreeOptLayout::RunThreeOpt()
Copy link
Member Author

@amanasifkhalid amanasifkhalid Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's what I want the hierarchy of 3-opt methods to look like:

  • ThreeOptLayout::Run: Set up some data structures, run 3-opt, and reorder the block list
  • ThreeOptLayout::RunThreeOpt: Run a 3-opt pass, and evaluate the new layout cost. TODO: If we want to try searching for a better local optimum, run another 3-opt pass with a different initial layout. I'd be surprised if this second pass makes a difference when we don't have loops, so a decent starting heuristic is to run another pass only when we have them. My current plan is to first run 3-opt without fgMoveHotJumps run on the initial layout, and then if we have loops, run fgMoveHotJumps on the initial layout, and try 3-opt again. We'll keep the better of the two.
  • ThreeOptLayout::RunGreedyThreeOptPass: Actually run 3-opt until convergence on whatever initial layout we're given.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll keep the better of the two.

As we saw with the fgMoveHotJumps data, layout score better doesn't reflect everything we care about... any thoughts on how we might also assess the compactness of a layout?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this computation would only happen twice per compilation, I think we can implement a more sophisticated cost model using one of the techniques you mentioned in #112016 just for comparing candidate layouts, without it being too expensive. If we can't do that, then assuming 3-opt converges to the same cost with and without fgMoveHotJumps, we could break ties by choosing the layout with fgMoveHotJumps under the assumption that it's more compact.

@amanasifkhalid
Copy link
Member Author

@dotnet/jit-contrib PTAL. No diffs. Thanks!

@amanasifkhalid amanasifkhalid merged commit 73efdf3 into dotnet:main Feb 6, 2025
113 checks passed
@amanasifkhalid amanasifkhalid deleted the 3-opt-cleanup branch February 6, 2025 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants