The bulk of the implementation is common between 'release' mode (==AOT-ed
model) and 'development' mode (for training), the main difference is
that in development mode, we may also log features (for training logs),
inject scoring information and then produce the log file.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
I think we need to separate in a first patch the changes needed to reuse regallocscoring. For those, I think maybe a simple solution right now would be to have the base RegAllocEvictionAdvisorAnalysis and RegAllocPriorityAdvisorAnalysis (the base types) have a virtual void logRewardIfNeeded(float Reward) method. By default it does nothing. Just the Development variant does something. So that way you don't need the additional .h for the scoring, just moving it to a .cpp would be sufficient.
Overall fine, I think you should still split out the change that introduces the logRewardIfNeeded as a NFC.
For the main change (i.e. this after rebasing with the above NFC), you also need test.
llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp | ||
---|---|---|
424 | in the overridden case, drop the virtual. | |
llvm/lib/CodeGen/MLRegallocPriorityAdvisor.cpp | ||
121 | AU.setPreservesAll(), too. | |
181 | why is this virtual? | |
196 | AU.setPreservesAll() | |
300 | There's a loss here due to the ping-ponging between float and unsigned and then back to float for logging. I imagine we want to stay in float domain for training, though. One way to avoid unnecessary lossiness is to: factor getPriority in the ML case into a getPriorityImpl that returns a float, and then getPriority just casts. The oddity is that here you'd have to keep track of the "float" priorty as well as the unisgned one, so you'd have a float TrainingPrio and a unsigned Prio; or have Prio be a double and cast it to float when logging and to unsigned when returning, but you still need the getPriorityImpl. |
added Yundi for the test model generator, please wait for her feedback before submitting.
On my side, lgtm, left some comments about not trying to enable release mode at this point.
(self-note: there's some boilerplate we can further simplify, I think like ctoring of the dev mode could be more streamlined - I'll take a look into that)
llvm/lib/CodeGen/RegAllocPriorityAdvisor.cpp | ||
---|---|---|
39 | I'd remove this. We don't currently support constructing the release model - that also needs some stuff in CMakeLists.txt. All good, all we need is the development stuff anyway, and all the release stuff is common anyway. | |
88–90 | check LLVM_HAVE_TF_AOT_REGALLOCPRIORITYMODEL here (which nothing sets, which is good right now). We need to do something similar for evictadvisor now, too (not in this patch) |
in the overridden case, drop the virtual.