Add VerilatedContext::useNumaAssign and set on threads() call (#6954)

This commit is contained in:
Yangyu Chen
2026-01-27 11:05:28 -05:00
committed by GitHub
parent 7c6c6a684b
commit 5b84635bde
6 changed files with 120 additions and 3 deletions
@@ -0,0 +1,53 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2026 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
//
//*************************************************************************
// Generated header
#include "Vt_gantt_numa_default_threads.h"
// General headers
#include "verilated.h"
#include "TestCheck.h"
int errors = 0;
std::unique_ptr<Vt_gantt_numa_default_threads> topp;
int main(int argc, char** argv) {
vluint64_t sim_time = 1100;
const std::unique_ptr<VerilatedContext> contextp{new VerilatedContext};
contextp->debug(0);
contextp->commandArgs(argc, argv);
srand48(5);
TEST_CHECK_EQ(contextp->useNumaAssign(), false);
contextp->threads(3);
TEST_CHECK_EQ(contextp->useNumaAssign(), true);
contextp->useNumaAssign(false);
TEST_CHECK_EQ(contextp->useNumaAssign(), false);
topp.reset(new VM_PREFIX{"top"});
topp->clk = 0;
topp->eval();
{ contextp->timeInc(10); }
while ((contextp->time() < sim_time) && !contextp->gotFinish()) {
topp->eval();
topp->clk = !topp->clk;
topp->eval();
contextp->timeInc(5);
}
if (!contextp->gotFinish()) {
vl_fatal(__FILE__, __LINE__, "main", "%Error: Timeout; never got a $finish");
}
topp->final();
topp.reset();
return (errors ? 10 : 0);
}
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2026 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import os
import sys
import vltest_bootstrap
test.scenarios('vltmt')
test.top_filename = "t/t_gantt.v"
test.pli_filename = "t/t_gantt_numa_default_threads.cpp"
# Require enough cores so default thread count stays >= model threads
# (we don't call contextp->threads in this test)
test.skip_if_too_few_cores()
test.compile(
make_main=False,
verilator_flags2=[
"--prof-exec",
"--exe",
test.pli_filename,
test.t_dir + "/t_gantt_c.cpp",
],
threads=test.get_default_vltmt_threads,
)
test.execute(all_run_flags=[
"+verilator+prof+exec+start+2",
" +verilator+prof+exec+window+2",
" +verilator+prof+exec+file+" + test.obj_dir + "/profile_exec.dat",
])
gantt_log = test.obj_dir + "/gantt_default_threads.log"
test.run(cmd=[
os.environ["VERILATOR_ROOT"] + "/bin/verilator_gantt",
"--no-vcd",
test.obj_dir + "/profile_exec.dat",
"| tee " + gantt_log,
])
if sys.platform != "darwin":
test.file_grep(gantt_log, r"NUMA status += NUMA assignment not requested")
test.passes()