[PATCH] D115195: [mlgo][regalloc] Add score calculation for training

Mircea Trofin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 6 15:28:12 PST 2021


mtrofin created this revision.
mtrofin added reviewers: davidxl, yundiqian.
Herald added subscribers: hiraditya, mgorny, qcolombet, MatzeB.
mtrofin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Add the calculation of a score, which will be used during ML training. The
score qualifies the quality of a regalloc policy, and is independent of
what we train (currently, just eviction), or the regalloc algo itself.
We can then use scores to guide training (which happens offline), by
formulating a reward based on score variation - the goal being lowering
scores (currently, that reward is percentage reduction relative to
Greedy's heuristic)

Currently, we compute the score by factoring different instruction
counts (loads, stores, etc) with the machine basic block frequency,
regardless of the instructions' provenance - i.e. they could be due to
the regalloc policy or be introduced previously. This is different from
RAGreedy::reportStats, which accummulates the effects of the allocator
alone. We explored this alternative but found (at least currently) that
the more naive alternative introduced here produces better policies. We
do intend to consolidate the two, however, as we are actively
investigating improvements to our reward function, and will likely want
to re-explore scoring just the effects of the allocator.

In either case, we want to decouple score calculation from allocation
algorighm, as we currently evaluate it after a few more passes after
allocation (also, because score calculation should be reusable
regardless of allocation algorithm).

We intentionally accummulate counts independently because it facilitates
per-block reporting, which we found useful for debugging - for instance,
we can easily report the counts indepdently, and then cross-reference
with perf counter measurements.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115195

Files:
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/RegAllocScore.cpp
  llvm/lib/CodeGen/RegAllocScore.h
  llvm/unittests/CodeGen/CMakeLists.txt
  llvm/unittests/CodeGen/RegAllocScoreTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115195.392208.patch
Type: text/x-patch
Size: 17042 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211206/e0fad05c/attachment.bin>


More information about the llvm-commits mailing list