[PATCH] D86684: [NFC][Refactor] Add the SchedHeuristic for Scheduler to allow platform customizing the heuristics

Qing Shan Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 23:53:51 PDT 2020


steven.zhang created this revision.
steven.zhang added reviewers: fhahn, evandro, arsenm, rampitec, foad, kbarton, jsji.
Herald added subscribers: kerbowa, javed.absar, hiraditya, nhaehnle, jvesely, nemanjai, MatzeB.
Herald added a project: LLVM.
steven.zhang requested review of this revision.
Herald added a subscriber: wdng.

Hi, all, I want to add a new SchedHeuristic to track all the heuristic Scheduler used basing on the follow facts.

1. It is hard for target to add new heuristic now, as the Reason and tryCandidate() are maintained by base class.
2. It is hard for target to change the priority of each heuristic(i.e. prefer cluster over stall) as it is hard code by tryCandidate.
3. We assume the value of the Reason matches the priority in the tryCandidate which is easy to be out of sync. And it is out of sync now in fact. (see Stall and TopDepthReduce, we don't know their priority as it is changed according to input)
4. The duplicated heuristic between pre-ra and post-ra scheduler. (There are many duplicate code between these two tryCandidate)

As PowerPC target want to add more and more heuristic, and we are struggling to deal with this, so, this is the motivation of this refactor and welcome for comments.

What I did now:

- Each heuristic is an instance of the SchedHeuristic
- Predefine all the heuristic we have now.
- All the active heuristics are put into a vector and its position in the vector means its priority.
- To add a new heuristic, just need to define a new instance of SchedHeuristic with Name and heuristic call back, then, call registerHeuristic() into any position of the vector.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86684

Files:
  llvm/include/llvm/CodeGen/MachineScheduler.h
  llvm/lib/CodeGen/MachineScheduler.cpp
  llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp
  llvm/lib/Target/PowerPC/PPCMachineScheduler.cpp
  llvm/lib/Target/PowerPC/PPCMachineScheduler.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86684.288201.patch
Type: text/x-patch
Size: 55263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200827/fdd1a8cc/attachment-0001.bin>


More information about the llvm-commits mailing list