[llvm] r340830 - [llvm-mca] Initialize each element in vector TimelineView::UsedBuffers to a default invalid buffer descriptor. NFCI
Andrea Di Biagio via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 28 08:07:11 PDT 2018
Author: adibiagio
Date: Tue Aug 28 08:07:11 2018
New Revision: 340830
URL: http://llvm.org/viewvc/llvm-project?rev=340830&view=rev
Log:
[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.
Modified:
llvm/trunk/tools/llvm-mca/Views/TimelineView.cpp
llvm/trunk/tools/llvm-mca/Views/TimelineView.h
Modified: llvm/trunk/tools/llvm-mca/Views/TimelineView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/Views/TimelineView.cpp?rev=340830&r1=340829&r2=340830&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/Views/TimelineView.cpp (original)
+++ llvm/trunk/tools/llvm-mca/Views/TimelineView.cpp Tue Aug 28 08:07:11 2018
@@ -32,6 +32,10 @@ TimelineView::TimelineView(const MCSubta
WaitTimeEntry NullWTEntry = {0, 0, 0};
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,
@@ -40,15 +44,12 @@ void TimelineView::onReservedBuffers(con
return;
const MCSchedModel &SM = STI.getSchedModel();
- std::pair<unsigned, unsigned> BufferInfo = {0, 0};
+ std::pair<unsigned, int> BufferInfo = {0, -1};
for (const unsigned Buffer : Buffers) {
const MCProcResourceDesc &MCDesc = *SM.getProcResource(Buffer);
- if (MCDesc.BufferSize <= 0)
- continue;
- unsigned OtherSize = static_cast<unsigned>(MCDesc.BufferSize);
- if (!BufferInfo.first || BufferInfo.second > OtherSize) {
+ if (!BufferInfo.first || BufferInfo.second > MCDesc.BufferSize) {
BufferInfo.first = Buffer;
- BufferInfo.second = OtherSize;
+ BufferInfo.second = MCDesc.BufferSize;
}
}
@@ -97,19 +98,19 @@ void TimelineView::onEvent(const HWInstr
}
static raw_ostream::Colors chooseColor(unsigned CumulativeCycles,
- unsigned Executions,
- unsigned BufferSize) {
- if (CumulativeCycles && BufferSize == 0)
+ unsigned Executions, int BufferSize) {
+ if (CumulativeCycles && BufferSize < 0)
return raw_ostream::MAGENTA;
- if (CumulativeCycles >= (BufferSize * Executions))
+ unsigned Size = static_cast<unsigned>(BufferSize);
+ if (CumulativeCycles >= Size * Executions)
return raw_ostream::RED;
- if ((CumulativeCycles * 2) >= (BufferSize * Executions))
+ if ((CumulativeCycles * 2) >= Size * Executions)
return raw_ostream::YELLOW;
return raw_ostream::SAVEDCOLOR;
}
static void tryChangeColor(raw_ostream &OS, unsigned Cycles,
- unsigned Executions, unsigned BufferSize) {
+ unsigned Executions, int BufferSize) {
if (!OS.has_colors())
return;
@@ -135,7 +136,7 @@ void TimelineView::printWaitTimeEntry(fo
OS << Executions;
OS.PadToColumn(13);
- unsigned BufferSize = UsedBuffer[SourceIndex].second;
+ int BufferSize = UsedBuffer[SourceIndex].second;
tryChangeColor(OS, Entry.CyclesSpentInSchedulerQueue, Executions, BufferSize);
OS << format("%.1f", floor((AverageTime1 * 10) + 0.5) / 10);
OS.PadToColumn(20);
Modified: llvm/trunk/tools/llvm-mca/Views/TimelineView.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/Views/TimelineView.h?rev=340830&r1=340829&r2=340830&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/Views/TimelineView.h (original)
+++ llvm/trunk/tools/llvm-mca/Views/TimelineView.h Tue Aug 28 08:07:11 2018
@@ -140,7 +140,10 @@ class TimelineView : public View {
unsigned CyclesSpentAfterWBAndBeforeRetire;
};
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,
const TimelineViewEntry &E, unsigned Iteration,
More information about the llvm-commits
mailing list