forked from OSchip/llvm-project
[llvm-mca] Initialize each element in vector TimelineView::UsedBuffers to a default invalid buffer descriptor. NFCI
Also change the default buffer size for UsedBuffer entries to -1 (i.e. "unknown size"). No functional change intended. llvm-svn: 340830
This commit is contained in:
parent
8212eae996
commit
4269d64b20
|
@ -32,6 +32,10 @@ TimelineView::TimelineView(const MCSubtargetInfo &sti, MCInstPrinter &Printer,
|
||||||
|
|
||||||
WaitTimeEntry NullWTEntry = {0, 0, 0};
|
WaitTimeEntry NullWTEntry = {0, 0, 0};
|
||||||
std::fill(WaitTime.begin(), WaitTime.end(), NullWTEntry);
|
std::fill(WaitTime.begin(), WaitTime.end(), NullWTEntry);
|
||||||
|
|
||||||
|
std::pair<unsigned, int> NullUsedBufferEntry = {/* Invalid resource ID*/ 0,
|
||||||
|
/* unknown buffer size */ -1};
|
||||||
|
std::fill(UsedBuffer.begin(), UsedBuffer.end(), NullUsedBufferEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineView::onReservedBuffers(const InstRef &IR,
|
void TimelineView::onReservedBuffers(const InstRef &IR,
|
||||||
|
@ -40,15 +44,12 @@ void TimelineView::onReservedBuffers(const InstRef &IR,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const MCSchedModel &SM = STI.getSchedModel();
|
const MCSchedModel &SM = STI.getSchedModel();
|
||||||
std::pair<unsigned, unsigned> BufferInfo = {0, 0};
|
std::pair<unsigned, int> BufferInfo = {0, -1};
|
||||||
for (const unsigned Buffer : Buffers) {
|
for (const unsigned Buffer : Buffers) {
|
||||||
const MCProcResourceDesc &MCDesc = *SM.getProcResource(Buffer);
|
const MCProcResourceDesc &MCDesc = *SM.getProcResource(Buffer);
|
||||||
if (MCDesc.BufferSize <= 0)
|
if (!BufferInfo.first || BufferInfo.second > MCDesc.BufferSize) {
|
||||||
continue;
|
|
||||||
unsigned OtherSize = static_cast<unsigned>(MCDesc.BufferSize);
|
|
||||||
if (!BufferInfo.first || BufferInfo.second > OtherSize) {
|
|
||||||
BufferInfo.first = Buffer;
|
BufferInfo.first = Buffer;
|
||||||
BufferInfo.second = OtherSize;
|
BufferInfo.second = MCDesc.BufferSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,19 +98,19 @@ void TimelineView::onEvent(const HWInstructionEvent &Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static raw_ostream::Colors chooseColor(unsigned CumulativeCycles,
|
static raw_ostream::Colors chooseColor(unsigned CumulativeCycles,
|
||||||
unsigned Executions,
|
unsigned Executions, int BufferSize) {
|
||||||
unsigned BufferSize) {
|
if (CumulativeCycles && BufferSize < 0)
|
||||||
if (CumulativeCycles && BufferSize == 0)
|
|
||||||
return raw_ostream::MAGENTA;
|
return raw_ostream::MAGENTA;
|
||||||
if (CumulativeCycles >= (BufferSize * Executions))
|
unsigned Size = static_cast<unsigned>(BufferSize);
|
||||||
|
if (CumulativeCycles >= Size * Executions)
|
||||||
return raw_ostream::RED;
|
return raw_ostream::RED;
|
||||||
if ((CumulativeCycles * 2) >= (BufferSize * Executions))
|
if ((CumulativeCycles * 2) >= Size * Executions)
|
||||||
return raw_ostream::YELLOW;
|
return raw_ostream::YELLOW;
|
||||||
return raw_ostream::SAVEDCOLOR;
|
return raw_ostream::SAVEDCOLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tryChangeColor(raw_ostream &OS, unsigned Cycles,
|
static void tryChangeColor(raw_ostream &OS, unsigned Cycles,
|
||||||
unsigned Executions, unsigned BufferSize) {
|
unsigned Executions, int BufferSize) {
|
||||||
if (!OS.has_colors())
|
if (!OS.has_colors())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -135,7 +136,7 @@ void TimelineView::printWaitTimeEntry(formatted_raw_ostream &OS,
|
||||||
|
|
||||||
OS << Executions;
|
OS << Executions;
|
||||||
OS.PadToColumn(13);
|
OS.PadToColumn(13);
|
||||||
unsigned BufferSize = UsedBuffer[SourceIndex].second;
|
int BufferSize = UsedBuffer[SourceIndex].second;
|
||||||
tryChangeColor(OS, Entry.CyclesSpentInSchedulerQueue, Executions, BufferSize);
|
tryChangeColor(OS, Entry.CyclesSpentInSchedulerQueue, Executions, BufferSize);
|
||||||
OS << format("%.1f", floor((AverageTime1 * 10) + 0.5) / 10);
|
OS << format("%.1f", floor((AverageTime1 * 10) + 0.5) / 10);
|
||||||
OS.PadToColumn(20);
|
OS.PadToColumn(20);
|
||||||
|
|
|
@ -140,7 +140,10 @@ class TimelineView : public View {
|
||||||
unsigned CyclesSpentAfterWBAndBeforeRetire;
|
unsigned CyclesSpentAfterWBAndBeforeRetire;
|
||||||
};
|
};
|
||||||
std::vector<WaitTimeEntry> WaitTime;
|
std::vector<WaitTimeEntry> WaitTime;
|
||||||
std::vector<std::pair<unsigned, unsigned>> UsedBuffer;
|
|
||||||
|
// This field is used to map instructions to buffered resources.
|
||||||
|
// Elements of this vector are <resourceID, BufferSizer> pairs.
|
||||||
|
std::vector<std::pair<unsigned, int>> UsedBuffer;
|
||||||
|
|
||||||
void printTimelineViewEntry(llvm::formatted_raw_ostream &OS,
|
void printTimelineViewEntry(llvm::formatted_raw_ostream &OS,
|
||||||
const TimelineViewEntry &E, unsigned Iteration,
|
const TimelineViewEntry &E, unsigned Iteration,
|
||||||
|
|
Loading…
Reference in New Issue