<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Apr 22, 2013, at 12:10 PM, Andrew Trick <<a href="mailto:atrick@apple.com">atrick@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><blockquote type="cite" style="font-family: Menlo; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; ">unsigned MachineTraceMetrics::Trace::<br>getResourceLength(ArrayRef<const MachineBasicBlock*> Extrablocks) const {<br>+  // Add up resources above and below the center block.<br>+  ArrayRef<unsigned> PRDepths = TE.getProcResourceDepths(getBlockNum());<br>+  ArrayRef<unsigned> PRHeights = TE.getProcResourceHeights(getBlockNum());<br>+  unsigned PRMax = 0;<br>+  for (unsigned K = 0; K != PRDepths.size(); ++K) {<br>+    unsigned PRCycles = PRDepths[K] + PRHeights[K];<br>+    for (unsigned I = 0; I != Extrablocks.size(); ++I)<br>+      PRCycles += TE.MTM.getProcResourceCycles(Extrablocks[I]->getNumber())[K];<br>+    PRMax = std::max(PRMax, PRCycles);<br>+  }<br>+  // Convert to cycle count.<br>+  PRMax = TE.MTM.getCycles(PRMax);<br>+<br>  unsigned Instrs = TBI.InstrDepth + TBI.InstrHeight;<br>  for (unsigned i = 0, e = Extrablocks.size(); i != e; ++i)<br>    Instrs += TE.MTM.getResources(Extrablocks[i])->InstrCount;<br>  if (unsigned IW = TE.MTM.SchedModel.getIssueWidth())<br>    Instrs /= IW;<br>  // Assume issue width 1 without a schedule model.<br>-  return Instrs;<br>+  return std::max(Instrs, PRMax);<br>}<br></div></blockquote></div><br><div>It's not clear to me when you account for the resources in the current block. Is this missing a call to getResourceCycles(getBlockNum())?</div></div></blockquote></div><br><div>The depth and height numbers both refer to the beginning of the block, so the instructions in the current block are part of the height number:</div><div><br></div><div><div>/// Get an array of processor resource heights for MBB. Indexed by processor</div><div>/// resource kind, this array contains the scaled processor resources consumed</div><div>/// by this block and all blocks following it in its trace.</div><div>///</div><div>/// Compare TraceBlockInfo::InstrHeight.</div><div>ArrayRef<unsigned></div><div>MachineTraceMetrics::Ensemble::</div><div>getProcResourceHeights(unsigned MBBNum) const {</div><div><br></div></div><div>This is similar to the instruction latency heights and depths where the latency of the current instruction is included in the height, but not in the depth.</div><div><br></div><div>Thanks,</div><div>/jakob</div><div><br></div></body></html>