mirror of
https://github.com/RPCS3/llvm.git
synced 2025-05-14 17:36:29 +00:00

This patch introduces the following changes to the DispatchStatistics view: * DispatchStatistics now reports the number of dispatched opcodes instead of the number of dispatched instructions. * The "Dynamic Dispatch Stall Cycles" table now also reports the percentage of stall cycles against the total simulated cycles. This change allows users to easily compare dispatch group sizes with the processor DispatchWidth. Before this change, it was difficult to correlate the two numbers, since DispatchStatistics view reported numbers of instructions (instead of opcodes). DispatchWidth defines the maximum size of a dispatch group in terms of number of micro opcodes. The other change introduced by this patch is related to how DispatchStage generates "instruction dispatch" events. In particular: * There can be multiple dispatch events associated with a same instruction * Each dispatch event now encapsulates the number of dispatched micro opcodes. The number of micro opcodes declared by an instruction may exceed the processor DispatchWidth. Therefore, we cannot assume that instructions are always fully dispatched in a single cycle. DispatchStage knows already how to handle instructions declaring a number of opcodes bigger that DispatchWidth. However, DispatchStage always emitted a single instruction dispatch event (during the first simulated dispatch cycle) for instructions dispatched. With this patch, DispatchStage now correctly notifies multiple dispatch events for instructions that cannot be dispatched in a single cycle. A few views had to be modified. Views can no longer assume that there can only be one dispatch event per instruction. Tests (and docs) have been updated. Differential Revision: https://reviews.llvm.org/D51430 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341055 91177308-0d34-0410-b5e6-96231b3b80d8
87 lines
3.0 KiB
C++
87 lines
3.0 KiB
C++
//===--------------------- DispatchStatistics.cpp ---------------------*- C++
|
|
//-*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
/// \file
|
|
///
|
|
/// This file implements the DispatchStatistics interface.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "Views/DispatchStatistics.h"
|
|
#include "llvm/Support/Format.h"
|
|
|
|
using namespace llvm;
|
|
|
|
namespace mca {
|
|
|
|
void DispatchStatistics::onEvent(const HWStallEvent &Event) {
|
|
if (Event.Type < HWStallEvent::LastGenericEvent)
|
|
HWStalls[Event.Type]++;
|
|
}
|
|
|
|
void DispatchStatistics::onEvent(const HWInstructionEvent &Event) {
|
|
if (Event.Type != HWInstructionEvent::Dispatched)
|
|
return;
|
|
|
|
const auto &DE = static_cast<const HWInstructionDispatchedEvent &>(Event);
|
|
NumDispatched += DE.MicroOpcodes;
|
|
}
|
|
|
|
void DispatchStatistics::printDispatchHistogram(llvm::raw_ostream &OS) const {
|
|
std::string Buffer;
|
|
raw_string_ostream TempStream(Buffer);
|
|
TempStream << "\n\nDispatch Logic - "
|
|
<< "number of cycles where we saw N micro opcodes dispatched:\n";
|
|
TempStream << "[# dispatched], [# cycles]\n";
|
|
for (const std::pair<unsigned, unsigned> &Entry : DispatchGroupSizePerCycle) {
|
|
double Percentage = ((double)Entry.second / NumCycles) * 100.0;
|
|
TempStream << " " << Entry.first << ", " << Entry.second
|
|
<< " (" << format("%.1f", floor((Percentage * 10) + 0.5) / 10)
|
|
<< "%)\n";
|
|
}
|
|
|
|
TempStream.flush();
|
|
OS << Buffer;
|
|
}
|
|
|
|
static void printStalls(raw_ostream &OS, unsigned NumStalls,
|
|
unsigned NumCycles) {
|
|
if (!NumStalls) {
|
|
OS << NumStalls;
|
|
return;
|
|
}
|
|
|
|
double Percentage = ((double)NumStalls / NumCycles) * 100.0;
|
|
OS << NumStalls << " ("
|
|
<< format("%.1f", floor((Percentage * 10) + 0.5) / 10) << "%)";
|
|
}
|
|
|
|
void DispatchStatistics::printDispatchStalls(raw_ostream &OS) const {
|
|
std::string Buffer;
|
|
raw_string_ostream SS(Buffer);
|
|
SS << "\n\nDynamic Dispatch Stall Cycles:\n";
|
|
SS << "RAT - Register unavailable: ";
|
|
printStalls(SS, HWStalls[HWStallEvent::RegisterFileStall], NumCycles);
|
|
SS << "\nRCU - Retire tokens unavailable: ";
|
|
printStalls(SS, HWStalls[HWStallEvent::RetireControlUnitStall], NumCycles);
|
|
SS << "\nSCHEDQ - Scheduler full: ";
|
|
printStalls(SS, HWStalls[HWStallEvent::SchedulerQueueFull], NumCycles);
|
|
SS << "\nLQ - Load queue full: ";
|
|
printStalls(SS, HWStalls[HWStallEvent::LoadQueueFull], NumCycles);
|
|
SS << "\nSQ - Store queue full: ";
|
|
printStalls(SS, HWStalls[HWStallEvent::StoreQueueFull], NumCycles);
|
|
SS << "\nGROUP - Static restrictions on the dispatch group: ";
|
|
printStalls(SS, HWStalls[HWStallEvent::DispatchGroupStall], NumCycles);
|
|
SS << '\n';
|
|
SS.flush();
|
|
OS << Buffer;
|
|
}
|
|
|
|
} // namespace mca
|