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

vcs, palldium: support warmup, set difftest_perfCtrl_clean by DPI-C #506

Merged
merged 6 commits into from
Nov 25, 2024

Conversation

xiaokamikami
Copy link
Contributor

No description provided.

@xiaokamikami xiaokamikami marked this pull request as ready for review November 18, 2024 02:01
@klin02
Copy link
Member

klin02 commented Nov 19, 2024

wait until passing perfclean to helper. And we will add ci test for this feature

@klin02
Copy link
Member

klin02 commented Nov 20, 2024

Previous we use tapAndRead to hidden IO ports for read-only probe like some Difftest Bundle.

However, chisel does not support hierarchical wiring for writable probe, so we must addSource first, which requires us to createTopIO before generating DUT. By the way, addSink/addSource will also be deprecated later, and latest bore API require us to addSource before addSink.

Also, chisel's probe seems can only accessed top-to-bottom. For example, we can use SimTop.xx.yy.zz in SimTop, but can not use SimTop.aa in Module SimTop.xx.yy. That means even we addSource first and use tapAndRead, explicit IO port will be generated to pass timer and so on.

In next step, seems we should still try isVisible to reduce number of LogPerfHelper

@klin02
Copy link
Member

klin02 commented Nov 21, 2024

Seems we can use Builder.currentModule and tap to get LogPerfelper instantiate in same parent Module. I'm trying but some helper instantiated in when scope can not accessed from even same module.

@@ -44,6 +42,8 @@ static bool enable_difftest = true;
static uint64_t max_instrs = 0;
static char *workload_list = NULL;
static uint32_t overwrite_nbytes = 0xe00;
static uint64_t warmup_instrs = 0;
static svScope wamupScope;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warmup instead of wamup

@@ -57,6 +57,8 @@ enum {
SIMV_FAIL,
} simv_state;

extern "C" void claer_perfcnt();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clear instead of claer

@@ -84,6 +86,17 @@ extern "C" void set_overwrite_autoset() {
fclose(fp);
}

// The workload warms up and clears the instruction counter
extern "C" void set_warmup_insts(uint64_t warmup_inst, uint64_t cmn_inst) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why cmn_inst here? We only need to pass warmup from vcs_top, and set difftest_clean/dump by dpic

assign difftest_uart_in_ch = 8'hff;

export "DPI-C" task claer_perfcnt;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MissSpelling here too.

dpi_perfCtrl_clean <= 1'b1;
endtask

reg clear_perf_cnt;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can simplify logic here. Use RegNext(just example) as mask to ensure clean raise only 1 cycle.

// The workload warms up and clears the instruction counter
extern "C" void set_warmup_insts(uint64_t warmup_inst, uint64_t cmn_inst) {
warmup_instrs = warmup_inst + cmn_inst;
wamupScope = svGetScope();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warmup here.

printf("Error: Could not retrieve wamup scope, set first\n");
assert(wamupScope);
}
printf("set warmp insts %ld, cmn insts %ld\n", warmup_inst, cmn_inst);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warmup here.

@@ -57,6 +57,8 @@ enum {
SIMV_FAIL,
} simv_state;

extern "C" void clear_perfcnt();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also use set_[signalName] for consistent API style.

auto trap = difftest[i]->get_trap_event();
if (warmup_instrs != 0 && trap->instrCnt > warmup_instrs) {
svSetScope(wamupScope);
clear_perfcnt();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap setScope and setSignal to same function. Don't expose Scope to avoid abuse.

@@ -50,6 +50,7 @@ import "DPI-C" function void set_max_instrs(longint mc);
import "DPI-C" function longint get_stuck_limit();
import "DPI-C" function void set_overwrite_nbytes(longint len);
import "DPI-C" function void set_overwrite_autoset();
import "DPI-C" context function void set_warmup_insts(longint workload_inst, longint cmn_inst);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems no need to add context ?

if ($test$plusargs("warmup-inst")) begin
$value$plusargs("warmup-inst=%d", warmup_instrs);
end
if ($test$plusargs("cmn-instrs")) begin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's no need to pass cmn-instrs here.
Difftest should only process basic workload, no need to care CMN. Total warmup-insts should be calculated before passing to Difftest

@@ -170,12 +185,29 @@ initial begin
end
end

reg dpi_perfCtrl_clean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use simply difftest_perfCtrl_clean_r for same coding style.

end else begin
if (dpi_perfCtrl_clean) begin
dpi_perfCtrl_clean <= 1'b0;
$display("claer perfCnt");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe no need to add display. Code here is just to set a singal, the effect has already printed by Software

@@ -84,6 +86,17 @@ extern "C" void set_overwrite_autoset() {
fclose(fp);
}

// The workload warms up and clears the instruction counter
extern "C" void set_warmup_insts(uint64_t warmup_inst, uint64_t cmn_inst) {
warmup_instrs = warmup_inst + cmn_inst;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to add CMN here? Difftest is a common verification framework cross mutli-platform, no need to add specific param here if we can add in another way, such as platform-specific scripts.

dpic_perfCtrl_clean = 1'b1;
endtask

always @(posedge clock) begin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use difftest_perfCtrl_clean_r for same nameing style.

// The workload warms up and clears the instruction counter
extern "C" void set_warmup_insts(uint64_t warmup_inst) {
warmup_instrs = warmup_inst;
wamupScope = svGetScope();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MissSpelling here. warmup instead of wamup

extern "C" void set_warmup_insts(uint64_t warmup_inst) {
warmup_instrs = warmup_inst;
wamupScope = svGetScope();
if (wamupScope == NULL) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to check here, but need to check svSetSope.

for (int i = 0; i < NUM_CORES; i++) {
auto trap = difftest[i]->get_trap_event();
if (warmup_instrs != 0 && trap->instrCnt > warmup_instrs) {
svSetScope(wamupScope);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap setScope and setSignal to same function. Don't expose Scope to avoid abuse.
Modified as review before. Like below

extern "C" void set_squash_enable(int enable);
void difftest_squash_enable(int enable) {
  if (squashScope == NULL) {
    printf("Error: Could not retrieve squash scope, set first\n");
    assert(squashScope);
  }
  svSetScope(squashScope);
  set_squash_enable(enable);
}

@@ -44,6 +42,8 @@ static bool enable_difftest = true;
static uint64_t max_instrs = 0;
static char *workload_list = NULL;
static uint32_t overwrite_nbytes = 0xe00;
static uint64_t warmup_instrs = 0;
static svScope wamupScope;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should seperate scope to warmup. We can add a context function set_difftest_endpoint_scope and rm context from passing warmup_instrs. Later we may also use the scope to change top ports of Difftest like dump clean and so on.

@klin02
Copy link
Member

klin02 commented Nov 25, 2024

Previous commit is made by @xiaokamikami. Author is append because of rebasing.

@klin02 klin02 changed the title diff: The hardware performance counter is cleared at the necessary wamup Difftest: support workload warmup for vcs/palladium Nov 25, 2024
@klin02 klin02 changed the title Difftest: support workload warmup for vcs/palladium vcs, palldium: support workload warmup, enable signal modified by DPI-C Nov 25, 2024
@klin02 klin02 changed the title vcs, palldium: support workload warmup, enable signal modified by DPI-C vcs, palldium: support warmup, set difftest_perfCtrl_clean by DPI-C Nov 25, 2024
@klin02 klin02 merged commit 9f43eee into master Nov 25, 2024
5 checks passed
@klin02 klin02 deleted the wamup_vcs branch November 25, 2024 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants