Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "perf: use DPI-C instead of boring utils for perf counters" #151

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 0 additions & 153 deletions src/test/csrc/common/perfhelper.cpp

This file was deleted.

44 changes: 0 additions & 44 deletions src/test/csrc/common/perfhelper.h

This file was deleted.

7 changes: 2 additions & 5 deletions src/test/csrc/vcs/vcs_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
#include "ram.h"
#include "flash.h"
#include "refproxy.h"
#include "perfhelper.h"

static bool has_reset = false;
static char bin_file[256] = "ram.bin";
static char *flash_bin_file = NULL;
static bool enable_difftest = true;
static int max_cycles = 0;
static int cycles = 0;

extern "C" void set_bin_file(char *s) {
printf("ram image:%s\n",s);
Expand Down Expand Up @@ -60,14 +58,12 @@ extern "C" void set_max_cycles(long mc) {
max_cycles = mc;
}

extern "C" void simv_init(uint64_t log_begin, uint64_t log_end) {
extern "C" void simv_init() {
common_init("simv");

init_ram(bin_file);
init_flash(flash_bin_file);

perf_init(log_begin, log_end, &cycles);

difftest_init();
init_device();
if (enable_difftest) {
Expand All @@ -81,6 +77,7 @@ extern "C" int simv_step() {
return 1;
}

static int cycles = 0;
if (max_cycles != 0) { // 0 for no limit
if (cycles >= max_cycles) {
eprintf(ANSI_COLOR_YELLOW "EXCEEDED MAX CYCLE:%d\n" ANSI_COLOR_RESET, max_cycles);
Expand Down
17 changes: 2 additions & 15 deletions src/test/csrc/verilator/emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
#include "compress.h"
#include "lightsss.h"
#include "remote_bitbang.h"
#include "perfhelper.h"
#include <algorithm>

extern remote_bitbang_t * jtag;

Expand Down Expand Up @@ -319,9 +317,6 @@ Emulator::Emulator(int argc, const char *argv[]):
// init flash
init_flash(args.flash_bin);

// set log time range and log level
perf_init(args.log_begin, args.log_end, &cycles);

// init core
reset_ncycles(10);

Expand Down Expand Up @@ -566,8 +561,8 @@ inline void Emulator::single_cycle() {
#ifndef CONFIG_NO_DIFFTEST
auto trap = difftest[0]->get_trap_event();
uint64_t cycle = trap->cycleCnt;
uint64_t begin = std::max(dut_ptr->io_logCtrl_log_begin, perf_get_begin());
uint64_t end = std::max(dut_ptr->io_logCtrl_log_end, perf_get_end());
uint64_t begin = dut_ptr->io_logCtrl_log_begin;
uint64_t end = dut_ptr->io_logCtrl_log_end;
bool in_range = (begin <= cycle) && (cycle <= end);
#else
bool in_range = true;
Expand Down Expand Up @@ -689,15 +684,11 @@ int Emulator::tick() {
auto trap = difftest[i]->get_trap_event();
if (trap->instrCnt >= args.warmup_instr) {
Info("Warmup finished. The performance counters will be dumped and then reset.\n");
perf_set_clean();
perf_set_dump();
dut_ptr->io_perfInfo_clean = 1;
dut_ptr->io_perfInfo_dump = 1;
args.warmup_instr = -1;
}
if (trap->cycleCnt % args.stat_cycles == args.stat_cycles - 1) {
perf_set_clean();
perf_set_dump();
dut_ptr->io_perfInfo_clean = 1;
dut_ptr->io_perfInfo_dump = 1;
}
Expand Down Expand Up @@ -733,8 +724,6 @@ int Emulator::tick() {
#ifdef CONFIG_NO_DIFFTEST
args.max_cycles --;
#endif // CONFIG_NO_DIFFTEST
perf_unset_clean();
perf_unset_dump();
dut_ptr->io_perfInfo_clean = 0;
dut_ptr->io_perfInfo_dump = 0;

Expand Down Expand Up @@ -898,10 +887,8 @@ inline void Emulator::save_coverage(time_t t) {
#endif

void Emulator::trigger_stat_dump() {
perf_set_dump();
dut_ptr->io_perfInfo_dump = 1;
if(get_args().force_dump_result) {
perf_set_end(UINT64_MAX);
dut_ptr->io_logCtrl_log_end = -1;
}
single_cycle();
Expand Down
26 changes: 12 additions & 14 deletions src/test/vsrc/vcs/top.v
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ import "DPI-C" function void set_flash_bin(string bin);
import "DPI-C" function void set_diff_ref_so(string diff_so);
import "DPI-C" function void set_no_diff();
import "DPI-C" function void set_max_cycles(int mc);
import "DPI-C" function void simv_init(longint log_begin, longint log_end);
import "DPI-C" function void simv_init();
import "DPI-C" function int simv_step();
import "DPI-C" function void perf_set_begin(longint perf_begin);
import "DPI-C" function void perf_set_end(longint perf_end);
import "DPI-C" function void perf_alloc_cycles();

module tb_top();

Expand All @@ -44,12 +41,10 @@ string flash_bin_file;
string wave_type;
string diff_ref_so;
reg [31:0] max_cycles;
reg [63:0] arg_log_begin;
reg [63:0] arg_log_end;

initial begin
reset = 1;
clock = 0;
reset = 1;
// enable waveform
if ($test$plusargs("dump-wave")) begin
$value$plusargs("dump-wave=%s", wave_type);
Expand All @@ -70,20 +65,16 @@ initial begin
end
// log begin
if ($test$plusargs("b")) begin
$value$plusargs("b=%lu", arg_log_begin);
$value$plusargs("b=%d", io_logCtrl_log_begin);
end
else begin
arg_log_begin = 0;
io_logCtrl_log_begin = 0;
end
// log end
if ($test$plusargs("e")) begin
$value$plusargs("e=%lu", arg_log_end);
$value$plusargs("e=%d", io_logCtrl_log_end);
end
else begin
arg_log_end = 0;
io_logCtrl_log_end = 0;
end
// workload: bin file
Expand Down Expand Up @@ -114,8 +105,6 @@ initial begin
max_cycles = 0;
end

simv_init(arg_log_begin, arg_log_end);

// Note: reset delay #100 should be larger than RANDOMIZE_DELAY
#100 reset = 0;
end
Expand Down Expand Up @@ -147,9 +136,18 @@ always @(posedge clock) begin
end
end

reg has_init;
always @(posedge clock) begin
if (reset) begin
has_init <= 1'b0;
end
else if (!has_init) begin
simv_init();
has_init <= 1'b1;
end

// check errors
if (!reset) begin
if (!reset && has_init) begin
if (simv_step()) begin
$finish();
end
Expand Down