# mischeduler

**URL:** <https://discourse.llvm.org/t/mischeduler/42950>\
**Category:** LLVM Dev List Archives\
**Created:** [October 28, 2016, 10:04am UTC](https://discourse.llvm.org/t/mischeduler/42950 "2016-10-28T10:04:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JonPsson](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/jonpsson/32/2112_2.png) [@JonPsson](https://discourse.llvm.org/u/JonPsson)\
**Post date:** [October 28, 2016, 10:04am UTC](https://discourse.llvm.org/t/mischeduler/42950/1 "2016-10-28T10:04:18Z")

</div>

Hi,

Regarding the mischeduler, I wonder

// For loops that are acyclic path limited, aggressively schedule for  
// latency. This can result in very long dependence chains scheduled in  
// sequence, so once every cycle (when CurrMOps == 0), switch to normal  
// heuristics.  
if (Rem.IsAcyclicLatencyLimited && !Zone-\>getCurrMOps() &&  
&nbsp;&nbsp;&nbsp;&nbsp;tryLatency(TryCand, Cand, \*Zone))  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;

Is this an error in comment or code? The CurrMOps is 0 once per cycle, which means  
this is actually done once per cycle, in contrast to what the comment suggests.

...

&nbsp;&nbsp;&nbsp;// Schedule aggressively for latency in PostRA mode. We don't check for  
&nbsp;&nbsp;&nbsp;// acyclic latency during PostRA, and highly out-of-order processors will  
&nbsp;&nbsp;&nbsp;// skip PostRA scheduling.  
&nbsp;&nbsp;&nbsp;if (!OtherResLimited) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (IsPostRA || (RemLatency + CurrZone.getCurrCycle() \> Rem.CriticalPath)) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Policy.ReduceLatency |= true;

Why !OtherResLimited? tryCandidate() has already checked for resource balancing just  
before this. To not do the latency check then only means falling back to original  
order.

/Jonas

---

<div class="post-metadata">

**Author:** ![atrick](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/atrick/32/2243_2.png) [@atrick](https://discourse.llvm.org/u/atrick)\
**Post date:** [November 3, 2016, 5:41am UTC](https://discourse.llvm.org/t/mischeduler/42950/2 "2016-11-03T05:41:06Z")

</div>

> Hi,
> 
> Regarding the mischeduler, I wonder
> 
> // For loops that are acyclic path limited, aggressively schedule for  
> // latency. This can result in very long dependence chains scheduled in  
> // sequence, so once every cycle (when CurrMOps == 0), switch to normal  
> // heuristics.  
> if (Rem.IsAcyclicLatencyLimited && !Zone-\>getCurrMOps() &&  
> &nbsp;&nbsp;tryLatency(TryCand, Cand, \*Zone))  
> &nbsp;&nbsp;&nbsp;&nbsp;return;
> 
> Is this an error in comment or code? The CurrMOps is 0 once per cycle, which means  
> this is actually done once per cycle, in contrast to what the comment suggests.

Intuitively, I think the code is sensible and the comment misleading. It should probably say something like:

For loops that are acyclic path limited, aggressively schedule for latency. Within an single cycle, whenever CurrMOps \> 0, allow normal heuristics to take precedence.

> ...
> 
> // Schedule aggressively for latency in PostRA mode. We don't check for  
> // acyclic latency during PostRA, and highly out-of-order processors will  
> // skip PostRA scheduling.  
> if (!OtherResLimited) {  
> &nbsp;&nbsp;&nbsp;if (IsPostRA || (RemLatency + CurrZone.getCurrCycle() \> Rem.CriticalPath)) {  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Policy.ReduceLatency |= true;
> 
> Why !OtherResLimited? tryCandidate() has already checked for resource balancing just  
> before this. To not do the latency check then only means falling back to original  
> order.

The concept here is to aggressively prioritize scheduling for latency in PostRA mode—unless the unscheduled instructions are clearly resource limited. I agree with your comment. Not sure what your question is 😉

-Andy

---

<div class="post-metadata">

**Author:** ![JonPsson](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/jonpsson/32/2112_2.png) [@JonPsson](https://discourse.llvm.org/u/JonPsson)\
**Post date:** [November 3, 2016, 8:13am UTC](https://discourse.llvm.org/t/mischeduler/42950/3 "2016-11-03T08:13:26Z")

</div>

Hi Andy,

> Intuitively, I think the code is sensible and the comment misleading. It should probably say something like:
> 
> &nbsp;&nbsp;For loops that are acyclic path limited, aggressively schedule for latency. Within an single cycle, whenever CurrMOps \> 0, allow normal heuristics to take precedence.

I changed the comment -- see attached patch.

> The concept here is to aggressively prioritize scheduling for latency in PostRA mode—unless the unscheduled instructions are clearly resource limited. I agree with your comment. Not sure what your question is 😉

That's actually making sense to me now - sorry. I was confusing "policy" and "candidate evaluation".

/Jonas

[MISched\_comment\_acycliclat.patch](https://discourse.llvm.org/uploads/short-url/zRPfZXdpXSe7JEdjtE00pj2tP8Y.patch) (820 Bytes)

---

<div class="post-metadata">

**Author:** ![atrick](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/atrick/32/2243_2.png) [@atrick](https://discourse.llvm.org/u/atrick)\
**Post date:** [November 4, 2016, 3:19am UTC](https://discourse.llvm.org/t/mischeduler/42950/4 "2016-11-04T03:19:39Z")

</div>

> Hi Andy,
> 
> > Intuitively, I think the code is sensible and the comment misleading. It should probably say something like:
> > 
> > For loops that are acyclic path limited, aggressively schedule for latency. Within an single cycle, whenever CurrMOps \> 0, allow normal heuristics to take precedence.
> 
> I changed the comment -- see attached patch.

LGTM!  
-Andy
