Skip to content

Commit

Permalink
emu: move IPC stats to difftest.display_stats()
Browse files Browse the repository at this point in the history
  • Loading branch information
poemonsense committed Feb 2, 2024
1 parent 5b798bc commit 14302bc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
9 changes: 9 additions & 0 deletions src/test/csrc/difftest/difftest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,15 @@ void CommitTrace::display(bool use_spike) {
}
}

void Difftest::display_stats() {
auto trap = get_trap_event();
uint64_t instrCnt = trap->instrCnt;
uint64_t cycleCnt = trap->cycleCnt;
double ipc = (double)instrCnt / cycleCnt;
eprintf(ANSI_COLOR_MAGENTA "instrCnt = %'" PRIu64 ", cycleCnt = %'" PRIu64 ", IPC = %lf\n" ANSI_COLOR_RESET,
instrCnt, cycleCnt, ipc);
}

void DiffState::display_commit_count(int i) {
auto retire_pointer = (retire_group_pointer + DEBUG_GROUP_TRACE_SIZE - 1) % DEBUG_GROUP_TRACE_SIZE;
printf("commit group [%02d]: pc %010lx cmtcnt %d%s\n",
Expand Down
3 changes: 3 additions & 0 deletions src/test/csrc/difftest/difftest.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ class Difftest {
inline int get_trap_code() {
return dut->trap.code;
}

void display();
void display_stats();

void set_trace(const char *name, bool is_read) {
difftrace = new DiffTrace(name, is_read);
}
Expand Down
13 changes: 4 additions & 9 deletions src/test/csrc/verilator/emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ Emulator::~Emulator() {

Info(ANSI_COLOR_BLUE "Seed=%d Guest cycle spent: %'" PRIu64
" (this will be different from cycleCnt if emu loads a snapshot)\n" ANSI_COLOR_RESET, args.seed, cycles);
printf(ANSI_COLOR_BLUE "Host time spent: %'dms\n" ANSI_COLOR_RESET, elapsed_time);
Info(ANSI_COLOR_BLUE "Host time spent: %'dms\n" ANSI_COLOR_RESET, elapsed_time);

if (args.enable_jtag) {
delete jtag;
Expand Down Expand Up @@ -957,11 +957,7 @@ void Emulator::display_trapinfo() {
#ifndef CONFIG_NO_DIFFTEST
for (int i = 0; i < NUM_CORES; i++) {
printf("Core %d: ", i);
auto trap = difftest[i]->get_trap_event();
uint64_t pc = trap->pc;
uint64_t instrCnt = trap->instrCnt;
uint64_t cycleCnt = trap->cycleCnt;

uint64_t pc = difftest[i]->get_trap_event()->pc;
switch (trapCode) {
case STATE_GOODTRAP:
eprintf(ANSI_COLOR_GREEN "HIT GOOD TRAP at pc = 0x%" PRIx64 "\n" ANSI_COLOR_RESET, pc);
Expand All @@ -985,9 +981,8 @@ void Emulator::display_trapinfo() {
eprintf(ANSI_COLOR_RED "Unknown trap code: %d\n", trapCode);
}

double ipc = (double)instrCnt / cycleCnt;
eprintf(ANSI_COLOR_MAGENTA "instrCnt = %'" PRIu64 ", cycleCnt = %'" PRIu64 ", IPC = %lf\n" ANSI_COLOR_RESET,
instrCnt, cycleCnt, ipc);
difftest[i]->display_stats();

#ifdef TRACE_INFLIGHT_MEM_INST
runahead[i]->memdep_watcher->print_pred_matrix();
#endif
Expand Down

0 comments on commit 14302bc

Please sign in to comment.