1 //===--------------------- SchedulerStatistics.h ----------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 /// This file defines class SchedulerStatistics. Class SchedulerStatistics is a
11 /// View that listens to instruction issue events in order to print general
12 /// statistics related to the hardware schedulers.
17 /// Schedulers - number of cycles where we saw N instructions issued:
18 /// [# issued], [# cycles]
23 /// Scheduler's queue usage:
24 /// [1] Resource name.
25 /// [2] Average number of used buffer entries.
26 /// [3] Maximum number of used buffer entries.
27 /// [4] Total number of buffer entries.
34 //===----------------------------------------------------------------------===//
36 #ifndef LLVM_TOOLS_LLVM_MCA_SCHEDULERSTATISTICS_H
37 #define LLVM_TOOLS_LLVM_MCA_SCHEDULERSTATISTICS_H
39 #include "Views/View.h"
40 #include "llvm/ADT/SmallVector.h"
41 #include "llvm/MC/MCSubtargetInfo.h"
47 class SchedulerStatistics final
: public View
{
48 const llvm::MCSchedModel
&SM
;
49 unsigned LQResourceID
;
50 unsigned SQResourceID
;
55 unsigned MostRecentLoadDispatched
;
56 unsigned MostRecentStoreDispatched
;
58 // Tracks the usage of a scheduler's queue.
61 unsigned MaxUsedSlots
;
62 uint64_t CumulativeNumUsedSlots
;
65 std::vector
<unsigned> IssuedPerCycle
;
66 std::vector
<BufferUsage
> Usage
;
68 void updateHistograms();
69 void printSchedulerStats(llvm::raw_ostream
&OS
) const;
70 void printSchedulerUsage(llvm::raw_ostream
&OS
) const;
73 SchedulerStatistics(const llvm::MCSubtargetInfo
&STI
);
74 void onEvent(const HWInstructionEvent
&Event
) override
;
75 void onCycleBegin() override
{ NumCycles
++; }
76 void onCycleEnd() override
{ updateHistograms(); }
78 // Increases the number of used scheduler queue slots of every buffered
79 // resource in the Buffers set.
80 void onReservedBuffers(const InstRef
&IR
,
81 llvm::ArrayRef
<unsigned> Buffers
) override
;
83 // Decreases by one the number of used scheduler queue slots of every
84 // buffered resource in the Buffers set.
85 void onReleasedBuffers(const InstRef
&IR
,
86 llvm::ArrayRef
<unsigned> Buffers
) override
;
88 void printView(llvm::raw_ostream
&OS
) const override
;