JIT: Add TSPLIB dump capabilities to block layout #111005
Open
+143
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds functionality for dumping the flowgraph to files that can be consumed by TSPLIB-based optimizers. This enables us to compare the JIT's 3-opt implementation to state-of-the-art optimizers.
TSPLIB consumes a parameter file specifying various options for the solver to leverage, as well as a problem file describing the flowgraph. The JIT communicates the flowgraph to TSPLIB via a full matrix of "distances" between blocks, which is computed with
Compiler::ThreeOptLayout::GetCost()
. Unfortunately, TSPLIB only accepts integral values for distances, so the layout costs are truncated -- this imprecision sometimes leads the external optimizer to different optima that aren't truly better than the JIT's answer.TSPLIB gives each block a 1-indexed ordinal based on the order in which their distances are reported in the problem file. From the JIT side, I decided to use the lexical order of the optimized layout for this. This way, if we tell the optimizer to report its best traversal (via the
JitOutputTSPTourFile
switch), comparing it to the JIT's layout is simple: linearly-increasing traversals (1 2 3
etc) show agreement between the two.This functionality is best used with SPMI: Just set
JitDumpFlowGraphToTSPFile=1
when compiling a method, and then pass the resultant parameter file<spmi index>.par
to the external optimizer.I've used this functionality to analyze 3-opt's efficacy on
benchmarks.run_pgo
; I'll report my findings in a separate issue. I'll wait for #110922 to go in first before opening this up for review.