[llvm] r178553 - Count processor resources individually in MachineTraceMetrics.

Jakob Stoklund Olesen stoklund at 2pi.dk
Mon Apr 22 13:07:46 PDT 2013


On Apr 22, 2013, at 12:10 PM, Andrew Trick <atrick at apple.com> wrote:

>> unsigned MachineTraceMetrics::Trace::
>> getResourceLength(ArrayRef<const MachineBasicBlock*> Extrablocks) const {
>> +  // Add up resources above and below the center block.
>> +  ArrayRef<unsigned> PRDepths = TE.getProcResourceDepths(getBlockNum());
>> +  ArrayRef<unsigned> PRHeights = TE.getProcResourceHeights(getBlockNum());
>> +  unsigned PRMax = 0;
>> +  for (unsigned K = 0; K != PRDepths.size(); ++K) {
>> +    unsigned PRCycles = PRDepths[K] + PRHeights[K];
>> +    for (unsigned I = 0; I != Extrablocks.size(); ++I)
>> +      PRCycles += TE.MTM.getProcResourceCycles(Extrablocks[I]->getNumber())[K];
>> +    PRMax = std::max(PRMax, PRCycles);
>> +  }
>> +  // Convert to cycle count.
>> +  PRMax = TE.MTM.getCycles(PRMax);
>> +
>>   unsigned Instrs = TBI.InstrDepth + TBI.InstrHeight;
>>   for (unsigned i = 0, e = Extrablocks.size(); i != e; ++i)
>>     Instrs += TE.MTM.getResources(Extrablocks[i])->InstrCount;
>>   if (unsigned IW = TE.MTM.SchedModel.getIssueWidth())
>>     Instrs /= IW;
>>   // Assume issue width 1 without a schedule model.
>> -  return Instrs;
>> +  return std::max(Instrs, PRMax);
>> }
> 
> It's not clear to me when you account for the resources in the current block. Is this missing a call to getResourceCycles(getBlockNum())?

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:

/// Get an array of processor resource heights for MBB. Indexed by processor
/// resource kind, this array contains the scaled processor resources consumed
/// by this block and all blocks following it in its trace.
///
/// Compare TraceBlockInfo::InstrHeight.
ArrayRef<unsigned>
MachineTraceMetrics::Ensemble::
getProcResourceHeights(unsigned MBBNum) const {

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.

Thanks,
/jakob

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130422/1d9cfff0/attachment.html>


More information about the llvm-commits mailing list