[llvm-mca] Pass an instruction reference when notifying event listeners about reserved/released buffer resources. NFC

llvm-svn: 340821
This commit is contained in:
Andrea Di Biagio 2018-08-28 13:14:42 +00:00
parent 4d652c4ce7
commit 29c5d5aa36
5 changed files with 30 additions and 32 deletions

View File

@ -25,7 +25,8 @@ void SchedulerStatistics::onEvent(const HWInstructionEvent &Event) {
++NumIssued;
}
void SchedulerStatistics::onReservedBuffers(ArrayRef<unsigned> Buffers) {
void SchedulerStatistics::onReservedBuffers(const InstRef & /* unused */,
ArrayRef<unsigned> Buffers) {
for (const unsigned Buffer : Buffers) {
BufferUsage &BU = Usage[Buffer];
BU.SlotsInUse++;
@ -33,7 +34,8 @@ void SchedulerStatistics::onReservedBuffers(ArrayRef<unsigned> Buffers) {
}
}
void SchedulerStatistics::onReleasedBuffers(ArrayRef<unsigned> Buffers) {
void SchedulerStatistics::onReleasedBuffers(const InstRef & /* unused */,
ArrayRef<unsigned> Buffers) {
for (const unsigned Buffer : Buffers)
Usage[Buffer].SlotsInUse--;
}

View File

@ -77,11 +77,13 @@ public:
// Increases the number of used scheduler queue slots of every buffered
// resource in the Buffers set.
void onReservedBuffers(llvm::ArrayRef<unsigned> Buffers) override;
void onReservedBuffers(const InstRef &IR,
llvm::ArrayRef<unsigned> Buffers) override;
// Decreases by one the number of used scheduler queue slots of every
// buffered resource in the Buffers set.
void onReleasedBuffers(llvm::ArrayRef<unsigned> Buffers) override;
void onReleasedBuffers(const InstRef &IR,
llvm::ArrayRef<unsigned> Buffers) override;
void printView(llvm::raw_ostream &OS) const override;
};

View File

@ -127,9 +127,11 @@ public:
virtual void onResourceAvailable(const ResourceRef &RRef) {}
// Events generated by the Scheduler when buffered resources are
// consumed/freed.
virtual void onReservedBuffers(llvm::ArrayRef<unsigned> Buffers) {}
virtual void onReleasedBuffers(llvm::ArrayRef<unsigned> Buffers) {}
// consumed/freed for an instruction.
virtual void onReservedBuffers(const InstRef &Inst,
llvm::ArrayRef<unsigned> Buffers) {}
virtual void onReleasedBuffers(const InstRef &Inst,
llvm::ArrayRef<unsigned> Buffers) {}
virtual ~HWEventListener() {}

View File

@ -66,11 +66,8 @@ public:
void notifyInstructionReady(const InstRef &IR);
void notifyResourceAvailable(const ResourceRef &RR);
// Notify listeners that buffered resources were consumed.
void notifyReservedBuffers(llvm::ArrayRef<uint64_t> Buffers);
// Notify listeners that buffered resources were freed.
void notifyReleasedBuffers(llvm::ArrayRef<uint64_t> Buffers);
// Notify listeners that buffered resources have been consumed or freed.
void notifyReservedOrReleasedBuffers(const InstRef &IR, bool Reserved);
};
} // namespace mca

View File

@ -57,12 +57,11 @@ Error ExecuteStage::issueInstruction(InstRef &IR) {
SmallVector<InstRef, 4> Ready;
HWS.issueInstruction(IR, Used, Ready);
const InstrDesc &Desc = IR.getInstruction()->getDesc();
notifyReleasedBuffers(Desc.Buffers);
notifyReservedOrReleasedBuffers(IR, /* Reserved */false);
notifyInstructionIssued(IR, Used);
if (IR.getInstruction()->isExecuted()) {
notifyInstructionExecuted(IR);
//FIXME: add a buffer of executed instructions.
// FIXME: add a buffer of executed instructions.
if (Error S = moveToTheNextStage(IR))
return S;
}
@ -97,7 +96,7 @@ Error ExecuteStage::cycleStart() {
for (InstRef &IR : Executed) {
notifyInstructionExecuted(IR);
//FIXME: add a buffer of executed instructions.
// FIXME: add a buffer of executed instructions.
if (Error S = moveToTheNextStage(IR))
return S;
}
@ -120,9 +119,8 @@ Error ExecuteStage::execute(InstRef &IR) {
// BufferSize=0 as reserved. Resources with a buffer size of zero will only
// be released after MCIS is issued, and all the ResourceCycles for those
// units have been consumed.
const InstrDesc &Desc = IR.getInstruction()->getDesc();
HWS.dispatch(IR);
notifyReservedBuffers(Desc.Buffers);
notifyReservedOrReleasedBuffers(IR, /* Reserved */true);
if (!HWS.isReady(IR))
return ErrorSuccess();
@ -170,26 +168,23 @@ void ExecuteStage::notifyInstructionIssued(
notifyEvent<HWInstructionEvent>(HWInstructionIssuedEvent(IR, Used));
}
void ExecuteStage::notifyReservedBuffers(ArrayRef<uint64_t> Buffers) {
if (Buffers.empty())
void ExecuteStage::notifyReservedOrReleasedBuffers(const InstRef &IR,
bool Reserved) {
const InstrDesc &Desc = IR.getInstruction()->getDesc();
if (Desc.Buffers.empty())
return;
SmallVector<unsigned, 4> BufferIDs(Buffers.begin(), Buffers.end());
std::transform(Buffers.begin(), Buffers.end(), BufferIDs.begin(),
SmallVector<unsigned, 4> BufferIDs(Desc.Buffers.begin(), Desc.Buffers.end());
std::transform(Desc.Buffers.begin(), Desc.Buffers.end(), BufferIDs.begin(),
[&](uint64_t Op) { return HWS.getResourceID(Op); });
for (HWEventListener *Listener : getListeners())
Listener->onReservedBuffers(BufferIDs);
}
void ExecuteStage::notifyReleasedBuffers(ArrayRef<uint64_t> Buffers) {
if (Buffers.empty())
if (Reserved) {
for (HWEventListener *Listener : getListeners())
Listener->onReservedBuffers(IR, BufferIDs);
return;
}
SmallVector<unsigned, 4> BufferIDs(Buffers.begin(), Buffers.end());
std::transform(Buffers.begin(), Buffers.end(), BufferIDs.begin(),
[&](uint64_t Op) { return HWS.getResourceID(Op); });
for (HWEventListener *Listener : getListeners())
Listener->onReleasedBuffers(BufferIDs);
Listener->onReleasedBuffers(IR, BufferIDs);
}
} // namespace mca