[PATCH] D138370: [MLGO][AsmPrinter] Call-graph reward calculation

Yueh-Ting (eop) Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 19 18:45:35 PST 2022


eopXD created this revision.
eopXD added reviewers: mtrofin, MaskRay, nikic.
Herald added subscribers: StephenFan, hiraditya.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a project: All.
eopXD requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Calculate 2 values characterizing a call graph, starting at an
externally-callable (non-local linkage) function.

One value is a latency estimator, the other is a icache pressure
estimator.

They both use basic block frequencies. When traversing the call graph,
the MBB frequencies of callees are weighed by the frequency of the
callsite, thus, ultimately, the frequencies used are relative to the
entrypoint (graph start).

The calculations are roughly similar, the difference is that for cache
pressure, we treat frequencies larger than 1 as 1 - i.e. probability of
execution (if a MBB is in a hot loop, its prob of execution is 1,
regardless of how hot the loop is).

The values are serialized in a section of the object file. This is
because the cache pressure uses actual MBB size in its calculation -
which is computed by the assembler. See
test/Transforms/Inline/ML/reward-o3.ll and the Inputs/parse_reward.py
accompanying it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138370

Files:
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/test/Transforms/Inline/ML/Inputs/parse_reward.py
  llvm/test/Transforms/Inline/ML/reward-o3.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138370.476715.patch
Type: text/x-patch
Size: 15996 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221120/965413b8/attachment.bin>


More information about the llvm-commits mailing list