<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 26, 2016, at 5:09 AM, Christof Douma via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">

<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" class="">

<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class="">Hi Phil.</div>
<div class=""><br class="">
</div>
<div class="">You more or less answered your own question, but let me give you some more info. Maybe it is of use.</div>
<div class=""><br class="">
</div>
<div class="">From what I understand the <span style="font-size: 13px;" class="">SchedMachineModel  </span>is the future, although it is not as powerful as itineraries at present. The mi-scheduler is mostly developed around out-of-orders cores, I believe (I love to hear arguments
 on the contrary). Some of the constraints that can be found in in-order micro architectures cannot be expressed in the per-operand scheduling model and the heuristics of the pre-RA scheduling pass is probably a bit too focussed on register pressure for in-order
 cores (I have no numbers, just hearsay). </div>
<div class=""><br class="">
</div>
<div class="">There is some documentation in comments at the start of include/llvm/Target/TargetSchedule.td that you might find useful. If you are going to look at an existing scheduling model, I suggest to look at an in-order core. A good example would be AArch64/AArch64SchedA53.td.
 If itineraries are present, they are used by the mi-scheduler next to the SchedMachineModel to detect hazards. I think that is the only place where the mi-scheduler uses itineraries.</div>
<div class=""><br class="">
</div>
<div class="">There are some magic numbers you need for in-order operation. Most notably MicroOpBufferSize should be set to 0 for full in-order behaviour. You also want to set CompleteModel to 0 as that prevents asserts due to instructions without scheduling information.
 There is a script that might help you to visualise if you have provided scheduling information in the <span style="font-size: 13px;" class="">SchedMachineModel </span>for all instructions (utils/schedcover.py). It is very simplistic and takes as input the debug output
 of tablegen. There are some usage comments at the beginning.</div></div></div></blockquote><div>Having itinerary data should be enough for an instruction to count as covered for the "CompleteModel" case. I'd highly recommend to aim for "CompleteModel 1" in your targets, because it is easy to forget new instructions. It should also not be complicated to add empty scheduling information to a node as a temporary measure for cases where you have a reason not to provide scheduling information.</div><div>schedcover.py is indeed a nice tool to get a feeling/overview of your scheduling information. If schedcover.py shows no empty cells then "CompleteModel 1" should work as well.</div><div><br class=""></div><div>- Matthias</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class=""><br class="">
</div>
<div class="">Regards,</div>
<div class="">Christof</div>
<div class=""><br class="">
</div>
<span id="OLK_SRC_BODY_SECTION" class="">
<div style="font-family: Calibri; font-size: 11pt; text-align: left; border-width: 1pt medium medium; border-style: solid none none; padding: 3pt 0in 0in; border-top-color: rgb(181, 196, 223);" class="">
<span style="font-weight:bold" class="">From: </span>llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" class="">llvm-dev-bounces@lists.llvm.org</a>> on behalf of Phil Tomson via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>><br class="">
<span style="font-weight:bold" class="">Reply-To: </span>Phil Tomson <<a href="mailto:phil.a.tomson@gmail.com" class="">phil.a.tomson@gmail.com</a>><br class="">
<span style="font-weight:bold" class="">Date: </span>Wednesday, 20 April 2016 23:06<br class="">
<span style="font-weight:bold" class="">To: </span>LLVM Developers Mailing List <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>><br class="">
<span style="font-weight:bold" class="">Subject: </span>Re: [llvm-dev] How to get started with instruction scheduling? Advice needed.<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div class="">I notice from looking at ARMScheduleA9.td that there seems to be a hybrid approach where they still have itineraries but also use SchedMachineModel:<br class="">
<br class="">
// ===---------------------------------------------------------------------===//<br class="">
// The following definitions describe the simpler per-operand machine model.<br class="">
// This works with MachineScheduler and will eventually replace itineraries.<br class="">
<br class="">
class A9WriteLMOpsListType<list<WriteSequence> writes> {<br class="">
  list <WriteSequence> Writes = writes;<br class="">
  SchedMachineModel SchedModel = ?;<br class="">
}<br class="">
<br class="">
// Cortex-A9 machine model for scheduling and other instruction cost heuristics.<br class="">
def CortexA9Model : SchedMachineModel {<br class="">
  let IssueWidth = 2; // 2 micro-ops are dispatched per cycle.<br class="">
  let MicroOpBufferSize = 56; // Based on available renamed registers.<br class="">
  let LoadLatency = 2; // Optimistic load latency assuming bypass.<br class="">
                       // This is overriden by OperandCycles if the<br class="">
                       // Itineraries are queried instead.<br class="">
  let MispredictPenalty = 8; // Based on estimate of pipeline depth.<br class="">
<br class="">
  let Itineraries = CortexA9Itineraries;<br class="">
<br class="">
  // FIXME: Many vector operations were never given an itinerary. We<br class="">
  // haven't mapped these to the new model either.<br class="">
  let CompleteModel = 0;<br class="">
}<br class="">
<br class="">
</div>
I'm guessing this is probably the way forward for my case since Itineraries seem to be already mostly defined.<br class="">
<br class="">
</div>
Phil<br class="">
</div>
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On Wed, Apr 20, 2016 at 1:27 PM, Phil Tomson <span dir="ltr" class="">
<<a href="mailto:phil.a.tomson@gmail.com" target="_blank" class="">phil.a.tomson@gmail.com</a>></span> wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" type="cite">
<div dir="ltr" class="">
<div class="">So if I use the <font size="2" class="">SchedMachineModel method, can I just skip itineraries?<span class="HOEnZb"><font color="#888888" class=""><br class="">
<br class="">
</font></span></font></div>
<span class="HOEnZb"><font color="#888888" class=""><font size="2" class="">Phil<br class="">
</font></font></span></div>
<div class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On Wed, Apr 20, 2016 at 12:29 PM, Sergei Larin <span dir="ltr" class="">
<<a href="mailto:slarin@codeaurora.org" target="_blank" class="">slarin@codeaurora.org</a>></span> wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" type="cite">
<div link="blue" vlink="purple" lang="EN-US" class="">
<div class=""><div class="MsoNormal"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">Target does make a difference. VLIW needs more hand-holding. For what you are describing it should be fairly simple.<u class=""></u><u class=""></u></span></div><div class="MsoNormal"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><u class=""></u> <u class=""></u></span></div><div class="MsoNormal"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">Best strategy – see what other targets do. ARM might be a good start for generic superscalar. Hexagon for VLIW style scheduling.<u class=""></u><u class=""></u></span></div><div class="MsoNormal"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><u class=""></u> <u class=""></u></span></div><div class="MsoNormal"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">Depending on what you decide, you might need different target hooks.<u class=""></u><u class=""></u></span></div><div class="MsoNormal"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><u class=""></u> <u class=""></u></span></div><div class="MsoNormal"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">Sergei<u class=""></u><u class=""></u></span></div><div class="MsoNormal"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><u class=""></u> <u class=""></u></span></div><div class="MsoNormal"><span style="font-size:10.5pt;font-family:Consolas;color:#1f497d" class="">---<u class=""></u><u class=""></u></span></div><div class="MsoNormal"><span style="font-size: 10.5pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation</span><span style="font-size:10.5pt;font-family:Consolas;color:#1f497d" class=""><u class=""></u><u class=""></u></span></div><div class="MsoNormal"><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><u class=""></u> <u class=""></u></span></div>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt" class="">
<div class="">
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in" class=""><div class="MsoNormal"><b class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class="">From:</span></b><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class=""> llvm-dev [mailto:<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank" class="">llvm-dev-bounces@lists.llvm.org</a>]
<b class="">On Behalf Of </b>Phil Tomson via llvm-dev<br class="">
<b class="">Sent:</b> Wednesday, April 20, 2016 12:51 PM<br class="">
<b class="">To:</b> LLVM Developers Mailing List <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>><br class="">
<b class="">Subject:</b> [llvm-dev] How to get started with instruction scheduling? Advice needed.<u class=""></u><u class=""></u></span></div>
</div>
</div>
<div class="">
<div class=""><div class="MsoNormal"><u class=""></u> <u class=""></u></div>
<div class="">
<div class="">
<div class=""><div class="MsoNormal">I need to add instruction scheduling for a new target which is a fairly simple in-order execution machine.<br class="">
<br class="">
I've been watching this presentation from a 2014 LLVM dev meeting as it seems relevant:<u class=""></u><u class=""></u></div>
</div><p class="MsoNormal" style="margin-bottom:12.0pt">"SchedMachineModel: Adding and Optimizing a Subtarget"
<a href="http://llvm.org/devmtg/2014-10/Slides/Estes-MISchedulerTutorial.pdf" target="_blank" class="">
http://llvm.org/devmtg/2014-10/Slides/Estes-MISchedulerTutorial.pdf</a><u class=""></u><u class=""></u></p>
</div><p class="MsoNormal" style="margin-bottom:12.0pt">In this presentation the author says that there have been several ways to approach scheduling in LLVM over the years:<u class=""></u><u class=""></u></p>
<ul type="disc" class="">
<li class="MsoNormal"><span style="font-size:10.0pt" class="">Pre 2008: SelectionDAGISel pass creates the ScheduleDAG from the SelectionDAG at the end of instruction selection</span><u class=""></u><u class=""></u></li><li class="MsoNormal"><span style="font-size:10.0pt" class="">ScheduleDAG works on SelectionDAG Nodes (SDNodes)</span><u class=""></u><u class=""></u></li><li class="MsoNormal"><span style="font-size:10.0pt" class="">Circa 2008: Post Register </span>
<u class=""></u><u class=""></u></li></ul>
<div class=""><p class="MsoNormal" style="margin-left:.5in"><span style="font-size: 10pt; font-family: Arial, sans-serif;" class="">Allocation pass added for
</span><span style="font-family: Arial, sans-serif;" class=""><u class=""></u><u class=""></u></span></p>
</div>
<div class=""><p class="MsoNormal" style="margin-left:.5in"><span style="font-size: 10pt; font-family: Arial, sans-serif;" class="">instruction selection ( SchedulePostRATDList
</span><span style="font-family: Arial, sans-serif;" class=""><u class=""></u><u class=""></u></span></p>
<div class=""><p class="MsoNormal" style="margin-left:.5in"><span style="font-size: 10pt; font-family: Arial, sans-serif;" class="">works on MachineInstrs)</span><span style="font-family: Arial, sans-serif;" class=""><u class=""></u><u class=""></u></span></p>
</div>
</div>
<ul type="disc" class="">
<li class="MsoNormal"><span style="font-size:10.0pt" class="">Circa 2012: MIScheduler </span>
<u class=""></u><u class=""></u></li></ul>
<div class=""><p class="MsoNormal" style="margin-left:.5in"><span style="font-size: 10pt; font-family: Arial, sans-serif;" class="">(ScheduleDAGMI) added as
</span><span style="font-family: Arial, sans-serif;" class=""><u class=""></u><u class=""></u></span></p>
</div>
<div class=""><p class="MsoNormal" style="margin-left:.5in"><span style="font-size: 10pt; font-family: Arial, sans-serif;" class="">separate pass for pre-RA
</span><span style="font-family: Arial, sans-serif;" class=""><u class=""></u><u class=""></u></span></p>
</div>
<div class=""><p class="MsoNormal" style="margin-left:.5in"><span style="font-size: 10pt; font-family: Arial, sans-serif;" class="">scheduling</span><span style="font-family: Arial, sans-serif;" class=""><u class=""></u><u class=""></u></span></p>
</div>
<ul type="disc" class="">
<li class="MsoNormal"><span style="font-size:10.0pt" class="">Circa 2014: MIScheduler </span>
<u class=""></u><u class=""></u></li></ul>
<div class=""><p class="MsoNormal" style="margin-left:.5in"><span style="font-size: 10pt; font-family: Arial, sans-serif;" class="">adapted to optionally replace
</span><span style="font-family: Arial, sans-serif;" class=""><u class=""></u><u class=""></u></span></p>
</div>
<div class=""><p class="MsoNormal" style="margin-left:.5in"><span style="font-size: 10pt; font-family: Arial, sans-serif;" class="">PostRA Scheduler</span><span style="font-family: Arial, sans-serif;" class=""><u class=""></u><u class=""></u></span></p>
</div><div class=""><span style="font-size:10.0pt" class="">In the presentation he goes with defining a subclass of SchedMachineModel</span> in the schedule .td file. And apparently with this approach there are no instruction itineraries.<u class=""></u><u class=""></u></div><div class="">So I'm wondering: what's the current recommended way to approach this and does it depend on the type or target? (in-order, superscalar, out of order, VLIW...)?<u class=""></u><u class=""></u></div><div class="">Someone earlier started to define instruction itineraries for our target. Should I continue down this road or move over to the SchedMachineModel approach? Are there other recommended presentations/documents that I should be looking at?<u class=""></u><u class=""></u></div><div class=""><u class=""></u> <u class=""></u></div><div class="">Thanks.<u class=""></u><u class=""></u></div><div class="">Phil<u class=""></u><u class=""></u></div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</span>IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for
 any purpose, or store or copy the information in any medium. Thank you.
</div>

_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></body></html>