Support for ICache stat counters.

This commit is contained in:
jon
2020-12-15 14:49:16 +00:00
parent 73d25bf8f5
commit b6a397df52
5 changed files with 44 additions and 10 deletions

View File

@@ -1119,7 +1119,7 @@ module mkCore#(CoreId coreId)(Core);
Vector #(31, Bit #(Report_Width)) mem_core_evts_vec = to_large_vector (coreFix.memExeIfc.events);
Vector #(31, Bit #(Report_Width)) other_core_evts_vec = to_large_vector (hpm_core_events_reg);
Vector #(31, Bit #(Report_Width)) core_evts_vec = unpack(pack(mem_core_evts_vec) | pack(other_core_evts_vec));
Vector #(16, Bit #(Report_Width)) imem_evts_vec = replicate (0);//to_large_vector (near_mem.imem.events);
Vector #(16, Bit #(Report_Width)) imem_evts_vec = to_large_vector (iMem.events);
Vector #(16, Bit #(Report_Width)) dmem_evts_vec = to_large_vector (dMem.events);
Vector #(32, Bit #(Report_Width)) external_evts_vec = replicate (0);//to_large_vector (w_external_evts);

View File

@@ -57,6 +57,10 @@ import CacheUtils::*;
import Performance::*;
import LatencyTimer::*;
import RandomReplace::*;
`ifdef PERFORMANCE_MONITORING
import PerformanceMonitor::*;
import SpecialWires::*;
`endif
export ICRqStuck(..);
export IPRqStuck(..);
@@ -97,6 +101,9 @@ interface IBank#(
// performance
method Action setPerfStatus(Bool stats);
method Data getPerfData(L1IPerfType t);
`ifdef PERFORMANCE_MONITORING
method EventsCache events;
`endif
endinterface
module mkIBank#(
@@ -178,32 +185,54 @@ module mkIBank#(
Bool flushDone = True;
`endif
LatencyTimer#(cRqNum, 10) latTimer <- mkLatencyTimer;
`ifdef PERF_COUNT
Reg#(Bool) doStats <- mkConfigReg(False);
Count#(Data) ldCnt <- mkCount(0);
Count#(Data) ldMissCnt <- mkCount(0);
Count#(Data) ldMissLat <- mkCount(0);
LatencyTimer#(cRqNum, 10) latTimer <- mkLatencyTimer;
`endif
`ifdef PERFORMANCE_MONITORING
Array #(Wire #(EventsCache)) perf_events <- mkDWireOR (2, unpack (0));
Reg #(EventsCache) perf_events_reg <- mkConfigReg(unpack(0));
rule update_events_reg;
perf_events_reg <= perf_events[0];
endrule
`endif
function Action incrReqCnt;
action
`ifdef PERF_COUNT
if(doStats) begin
ldCnt.incr(1);
end
`endif
`ifdef PERFORMANCE_MONITORING
EventsCache events = unpack (0);
events.evt_LD = 1;
perf_events[0] <= events;
`endif
noAction;
endaction
endfunction
function Action incrMissCnt(cRqIdxT idx);
action
let lat <- latTimer.done(idx);
`ifdef PERF_COUNT
if(doStats) begin
ldMissLat.incr(zeroExtend(lat));
ldMissCnt.incr(1);
end
`endif
`ifdef PERFORMANCE_MONITORING
EventsCache events = unpack (0);
events.evt_LD_MISS_LAT = saturating_truncate(lat);
events.evt_LD_MISS = 1;
perf_events[1] <= events;
`endif
noAction;
endaction
endfunction
`endif
function tagT getTag(Addr a) = truncateLSB(a);
@@ -377,10 +406,8 @@ module mkIBank#(
fshow(slot), " ; ",
fshow(cRqToP)
);
`ifdef PERF_COUNT
// performance counter: start miss timer
latTimer.start(n);
`endif
endrule
// last stage of pipeline: process req
@@ -818,6 +845,9 @@ module mkIBank#(
default: 0;
endcase);
endmethod
`ifdef PERFORMANCE_MONITORING
method EventsCache events = perf_events_reg;
`endif
endmodule

View File

@@ -478,10 +478,8 @@ endfunction
fshow(slot), " ; ",
fshow(cRqToP)
);
`ifdef PERF_COUNT
// performance counter: start miss timer
latTimer.start(n);
`endif
endrule
// last stage of pipeline: process req

View File

@@ -372,6 +372,9 @@ interface ICoCache;
method Action flush;
method Bool flush_done;
interface Perf#(L1IPerfType) perf;
`ifdef PERFORMANCE_MONITORING
method EventsCache events;
`endif
interface ChildCacheToParent#(L1Way, void) to_parent;
@@ -442,6 +445,9 @@ module mkICoCache(ICoCache);
`endif
endmethod
endinterface
`ifdef PERFORMANCE_MONITORING
method EventsCache events = cache.events;
`endif
interface to_parent = cache.to_parent;