Set 'threads' in tests via parameter to compile

This is in preparation to #3454.
This commit is contained in:
Geza Lore 2022-07-05 10:57:16 +01:00
parent 42b711b862
commit 3aa8624658
33 changed files with 67 additions and 47 deletions

View File

@ -578,6 +578,7 @@ sub new {
make_pli => 0, # need to compile pli make_pli => 0, # need to compile pli
sc_time_resolution => "SC_PS", # Keep - PS is SystemC default sc_time_resolution => "SC_PS", # Keep - PS is SystemC default
sim_time => 1100, sim_time => 1100,
threads => -1, # --threads (negative means auto based on scenario)
benchmark => $opt_benchmark, benchmark => $opt_benchmark,
verbose => $opt_verbose, verbose => $opt_verbose,
run_env => '', run_env => '',
@ -902,6 +903,7 @@ sub compile_vlt_flags {
@{$param{verilator_flags}}, @{$param{verilator_flags}},
@{$param{verilator_flags2}}, @{$param{verilator_flags2}},
@{$param{verilator_flags3}}); @{$param{verilator_flags3}});
die "%Error: specify threads via 'threads =>' argument, not as a command line option" unless ($checkflags !~ /(^|\s)-?-threads\s/ && $checkflags !~ /(^|\s)-?-no-threads($|\s)/);
$self->{sc} = 1 if ($checkflags =~ /-sc\b/); $self->{sc} = 1 if ($checkflags =~ /-sc\b/);
$self->{trace} = ($opt_trace || $checkflags =~ /-trace\b/ $self->{trace} = ($opt_trace || $checkflags =~ /-trace\b/
|| $checkflags =~ /-trace-fst\b/); || $checkflags =~ /-trace-fst\b/);
@ -920,8 +922,7 @@ sub compile_vlt_flags {
unshift @verilator_flags, "--rr" if $opt_rr; unshift @verilator_flags, "--rr" if $opt_rr;
unshift @verilator_flags, "--x-assign unique"; # More likely to be buggy unshift @verilator_flags, "--x-assign unique"; # More likely to be buggy
unshift @verilator_flags, "--trace" if $opt_trace; unshift @verilator_flags, "--trace" if $opt_trace;
my $threads = ::calc_threads($Vltmt_threads); unshift @verilator_flags, "--threads $param{threads}" if $param{threads} >= 0;
unshift @verilator_flags, "--threads $threads" if $param{vltmt} && $checkflags !~ /-threads /;
unshift @verilator_flags, "--trace-threads 2" if $param{vltmt} && $checkflags =~ /-trace-fst /; unshift @verilator_flags, "--trace-threads 2" if $param{vltmt} && $checkflags =~ /-trace-fst /;
unshift @verilator_flags, "--debug-partition" if $param{vltmt}; unshift @verilator_flags, "--debug-partition" if $param{vltmt};
unshift @verilator_flags, "-CFLAGS -ggdb -LDFLAGS -ggdb" if $opt_gdbsim; unshift @verilator_flags, "-CFLAGS -ggdb -LDFLAGS -ggdb" if $opt_gdbsim;
@ -972,6 +973,9 @@ sub compile {
return 1 if $self->errors || $self->skips || $self->unsupporteds; return 1 if $self->errors || $self->skips || $self->unsupporteds;
$self->oprint("Compile\n") if $self->{verbose}; $self->oprint("Compile\n") if $self->{verbose};
die "%Error: 'threads =>' argument must be <= 1 for vlt scenario" if $param{vlt} && $param{threads} > 1;
$param{threads} = ::calc_threads($Vltmt_threads) if ($param{threads} < 0 && $param{vltmt});
compile_vlt_cmd(%param); compile_vlt_cmd(%param);
if (!$param{make_top_shell}) { if (!$param{make_top_shell}) {

View File

@ -11,7 +11,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(vltmt => 1); # Note issue shows up with --threads scenarios(vltmt => 1); # Note issue shows up with --threads
compile( compile(
verilator_flags2 => ['--compiler clang --threads 2 -Wno-UNOPTTHREADS'], verilator_flags2 => ['--compiler clang -Wno-UNOPTTHREADS'],
threads => 2
); );
ok(1); ok(1);

View File

@ -14,7 +14,8 @@ scenarios(vltmt => 1);
top_filename("t/t_gen_alw.v"); top_filename("t/t_gen_alw.v");
compile( compile(
v_flags2 => ["--debug --debugi 5 --threads 2"] v_flags2 => ["--debug --debugi 5"],
threads => 2
); );
foreach my $dotname ("linkcells", "task_call", "gate_simp", "gate_opt", foreach my $dotname ("linkcells", "task_call", "gate_simp", "gate_opt",

View File

@ -22,6 +22,7 @@ mkdir $child_dir;
(VM_PREFIX => "$Self->{VM_PREFIX}_child", (VM_PREFIX => "$Self->{VM_PREFIX}_child",
top_filename => "$Self->{name}_child.v", top_filename => "$Self->{name}_child.v",
verilator_flags => ["-cc", "-Mdir", "${child_dir}", "--debug-check"], verilator_flags => ["-cc", "-Mdir", "${child_dir}", "--debug-check"],
threads => $Self->{vltmt} ? $Self->get_default_vltmt_threads() : 0
); );
run(logfile => "${child_dir}/vlt_compile.log", run(logfile => "${child_dir}/vlt_compile.log",

View File

@ -18,8 +18,9 @@ scenarios(vlt_all => 1);
top_filename("t/t_gen_alw.v"); top_filename("t/t_gen_alw.v");
compile( compile(
v_flags2 => ["--prof-exec"],
# Checks below care about thread count, so use 2 (minimum reasonable) # Checks below care about thread count, so use 2 (minimum reasonable)
v_flags2 => ["--prof-exec", ($Self->{vltmt} ? "--threads 2" : "")] threads => $Self->{vltmt} ? 2 : 0
); );
execute( execute(

View File

@ -18,11 +18,12 @@ scenarios(vlt_all => 1);
compile( compile(
v_flags2 => ['t/t_hier_block.cpp'], v_flags2 => ['t/t_hier_block.cpp'],
verilator_flags2 => ['--stats', ($Self->{vltmt} ? ' --threads 6' : ''), verilator_flags2 => ['--stats',
'--hierarchical', '--hierarchical',
'--Wno-TIMESCALEMOD', '--Wno-TIMESCALEMOD',
'--CFLAGS', '"-pipe -DCPP_MACRO=cplusplus"' '--CFLAGS', '"-pipe -DCPP_MACRO=cplusplus"'
], ],
threads => $Self->{vltmt} ? 6 : 0
); );
execute( execute(

View File

@ -23,8 +23,8 @@ compile(
v_flags2 => ['t/t_hier_block.cpp'], v_flags2 => ['t/t_hier_block.cpp'],
verilator_flags2 => ['--stats', verilator_flags2 => ['--stats',
'+define+USE_VLT', 't/t_hier_block_vlt.vlt', '+define+USE_VLT', 't/t_hier_block_vlt.vlt',
'--CFLAGS', '"-pipe -DCPP_MACRO=cplusplus"', '--CFLAGS', '"-pipe -DCPP_MACRO=cplusplus"'],
($Self->{vltmt} ? ' --threads 6' : '')], threads => $Self->{vltmt} ? 6 : 0
); );
execute( execute(

View File

@ -22,9 +22,9 @@ compile(
verilator_flags2 => ['--sc', verilator_flags2 => ['--sc',
'--stats', '--stats',
'--hierarchical', '--hierarchical',
($Self->{vltmt} ? ' --threads 6' : ''),
'--CFLAGS', '"-pipe -DCPP_MACRO=cplusplus"' '--CFLAGS', '"-pipe -DCPP_MACRO=cplusplus"'
], ],
threads => $Self->{vltmt} ? 6 : 0
); );
execute( execute(

View File

@ -22,11 +22,11 @@ compile(
verilator_flags2 => ['--sc', verilator_flags2 => ['--sc',
'--stats', '--stats',
'--hierarchical', '--hierarchical',
($Self->{vltmt} ? ' --threads 6' : ''),
'--CFLAGS', '"-pipe -DCPP_MACRO=cplusplus"', '--CFLAGS', '"-pipe -DCPP_MACRO=cplusplus"',
"--CFLAGS", '"-O0 -ggdb"', "--CFLAGS", '"-O0 -ggdb"',
"--trace-fst" "--trace-fst"
], ],
threads => $Self->{vltmt} ? 6 : 0
); );
execute( execute(

View File

@ -22,11 +22,11 @@ compile(
verilator_flags2 => ['--sc', verilator_flags2 => ['--sc',
'--stats', '--stats',
'--hierarchical', '--hierarchical',
($Self->{vltmt} ? ' --threads 6' : ''),
'--CFLAGS', '"-pipe -DCPP_MACRO=cplusplus"', '--CFLAGS', '"-pipe -DCPP_MACRO=cplusplus"',
"--CFLAGS", '"-O0 -ggdb"', "--CFLAGS", '"-O0 -ggdb"',
"--trace" "--trace"
], ],
threads => $Self->{vltmt} ? 6 : 0
); );
execute( execute(

View File

@ -17,12 +17,12 @@ top_filename("t/t_hier_block.v");
compile( compile(
v_flags2 => ['t/t_hier_block.cpp'], v_flags2 => ['t/t_hier_block.cpp'],
verilator_flags2 => [($Self->{vltmt} ? ' --threads 6' : ''), verilator_flags2 => ['--hierarchical',
'--hierarchical',
'--Wno-TIMESCALEMOD', '--Wno-TIMESCALEMOD',
'--trace-fst', '--trace-fst',
'--no-trace-underscore', # To avoid handle mismatches '--no-trace-underscore', # To avoid handle mismatches
], ],
threads => $Self->{vltmt} ? 6 : 0
); );
execute( execute(

View File

@ -17,12 +17,12 @@ top_filename("t/t_hier_block.v");
compile( compile(
v_flags2 => ['t/t_hier_block.cpp'], v_flags2 => ['t/t_hier_block.cpp'],
verilator_flags2 => [($Self->{vltmt} ? ' --threads 6' : ''), verilator_flags2 => ['--hierarchical',
'--hierarchical',
'--Wno-TIMESCALEMOD', '--Wno-TIMESCALEMOD',
'--trace', '--trace',
'--no-trace-underscore', # To avoid handle mismatches '--no-trace-underscore', # To avoid handle mismatches
], ],
threads => $Self->{vltmt} ? 6 : 0
); );
execute( execute(

View File

@ -22,8 +22,8 @@ compile(
'--hierarchical', '--hierarchical',
'+define+SHOW_TIMESCALE', '+define+SHOW_TIMESCALE',
'+define+USE_VLT', 't/t_hier_block_vlt.vlt', '+define+USE_VLT', 't/t_hier_block_vlt.vlt',
'--CFLAGS', '"-pipe -DCPP_MACRO=cplusplus"', '--CFLAGS', '"-pipe -DCPP_MACRO=cplusplus"'],
($Self->{vltmt} ? ' --threads 6' : '')], threads => $Self->{vltmt} ? 6 : 0
); );
execute( execute(

View File

@ -14,9 +14,9 @@ top_filename("t/t_inst_tree.v");
my $default_vltmt_threads = $Self->get_default_vltmt_threads(); my $default_vltmt_threads = $Self->get_default_vltmt_threads();
compile( compile(
verilator_flags2 => ['--stats', "$Self->{t_dir}/$Self->{name}.vlt", verilator_flags2 => ['--stats', "$Self->{t_dir}/$Self->{name}.vlt"],
# Force 3 threads even if we have fewer cores # Force 3 threads even if we have fewer cores
$Self->{vltmt} ? "--threads $default_vltmt_threads" : ""] threads => $Self->{vltmt} ? $default_vltmt_threads : 0
); );
sub checkRelativeRefs { sub checkRelativeRefs {

View File

@ -56,10 +56,10 @@ while (1) {
compile( compile(
verilator_flags2 => ["$secret_dir/secret.sv", verilator_flags2 => ["$secret_dir/secret.sv",
($Self->{vltmt} ? ' --threads 1' : ''),
"-LDFLAGS", "-LDFLAGS",
"'-Wl,-rpath,$abs_secret_dir -L$abs_secret_dir -l$secret_prefix'"], "'-Wl,-rpath,$abs_secret_dir -L$abs_secret_dir -l$secret_prefix'"],
xsim_flags2 => ["$secret_dir/secret.sv"], xsim_flags2 => ["$secret_dir/secret.sv"],
threads => $Self->{vltmt} ? 1 : 0
); );
execute( execute(

View File

@ -11,7 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(vltmt => 1); scenarios(vltmt => 1);
compile( compile(
v_flags2 => ["--threads 2"], threads => 2,
fails => 1, fails => 1,
expect_filename => $Self->{golden_filename}, expect_filename => $Self->{golden_filename},
); );

View File

@ -14,7 +14,8 @@ scenarios(vltmt => 1);
top_filename("t/t_gen_alw.v"); top_filename("t/t_gen_alw.v");
compile( compile(
v_flags2 => ["--prof-pgo --threads 2"] v_flags2 => ["--prof-pgo"],
threads => 2
); );
execute( execute(
@ -30,8 +31,8 @@ file_grep("$Self->{obj_dir}/profile.vlt", qr/profile_data/i);
compile( compile(
# Intentinally no --prof-pgo here to make sure profile data can be read in # Intentinally no --prof-pgo here to make sure profile data can be read in
# without it (that is: --prof-pgo has no effect on profile_data hash names) # without it (that is: --prof-pgo has no effect on profile_data hash names)
v_flags2 => ["--threads 2", v_flags2 => [" $Self->{obj_dir}/profile.vlt"],
" $Self->{obj_dir}/profile.vlt"], threads => 2
); );
execute( execute(

View File

@ -14,8 +14,8 @@ scenarios(simulator => 1);
# %Warning-UNOPTTHREADS: Thread scheduler is unable to provide requested parallelism; consider asking for fewer threads. # %Warning-UNOPTTHREADS: Thread scheduler is unable to provide requested parallelism; consider asking for fewer threads.
# So use 6 threads here though it's not optimal in performace wise, but ok. # So use 6 threads here though it's not optimal in performace wise, but ok.
compile( compile(
verilator_flags2 => ['--stats' . ($Self->{vltmt} ? ' --threads 6' : ''), verilator_flags2 => ['--stats', "$Self->{t_dir}/t_split_var_0.vlt"],
"$Self->{t_dir}/t_split_var_0.vlt"], threads => $Self->{vltmt} ? 6 : 0
); );
execute( execute(

View File

@ -15,8 +15,8 @@ top_filename("t/t_split_var_0.v");
# %Warning-UNOPTTHREADS: Thread scheduler is unable to provide requested parallelism; consider asking for fewer threads. # %Warning-UNOPTTHREADS: Thread scheduler is unable to provide requested parallelism; consider asking for fewer threads.
# So use 6 threads here though it's not optimal in performace wise, but ok. # So use 6 threads here though it's not optimal in performace wise, but ok.
compile( compile(
verilator_flags2 => ['--cc --trace --stats' . ($Self->{vltmt} ? ' --threads 6' : ''), verilator_flags2 => ['--cc --trace --stats +define+TEST_ATTRIBUTES'],
'+define+TEST_ATTRIBUTES'], threads => $Self->{vltmt} ? 6 : 0
); );
execute( execute(

View File

@ -13,7 +13,8 @@ scenarios(simulator => 1);
top_filename("t/t_threads_counter.v"); top_filename("t/t_threads_counter.v");
compile( compile(
verilator_flags2 => ['--cc --no-threads'], verilator_flags2 => ['--cc'],
threads => 0,
); );
execute( execute(

View File

@ -13,7 +13,8 @@ scenarios(vltmt => 1);
top_filename("t/t_threads_counter.v"); top_filename("t/t_threads_counter.v");
compile( compile(
verilator_flags2 => ['--cc --threads 1'], verilator_flags2 => ['--cc'],
threads => 1
); );
execute( execute(

View File

@ -13,7 +13,8 @@ scenarios(vltmt => 1);
top_filename("t/t_threads_counter.v"); top_filename("t/t_threads_counter.v");
compile( compile(
verilator_flags2 => ['--cc --threads 2'], verilator_flags2 => ['--cc'],
threads => 2
); );
execute( execute(

View File

@ -13,7 +13,8 @@ scenarios(vltmt => 1);
top_filename("t/t_threads_counter.v"); top_filename("t/t_threads_counter.v");
compile( compile(
verilator_flags2 => ['--cc --threads 4'], verilator_flags2 => ['--cc'],
threads => 4
); );
execute( execute(

View File

@ -15,7 +15,8 @@ if ($Self->cfg_with_m32) {
} }
compile( compile(
verilator_flags2 => ['--cc --threads 1024'], verilator_flags2 => ['--cc'],
threads => 1024
); );
execute( execute(

View File

@ -13,7 +13,8 @@ scenarios(vltmt => 1);
top_filename("t/t_threads_counter.v"); top_filename("t/t_threads_counter.v");
compile( compile(
verilator_flags2 => ['--cc --threads 2 --debug-nondeterminism --no-skip-identical'], verilator_flags2 => ['--cc --debug-nondeterminism --no-skip-identical'],
threads => 2
); );
execute( execute(

View File

@ -14,8 +14,8 @@ scenarios(simulator => 1);
# %Warning-UNOPTTHREADS: Thread scheduler is unable to provide requested parallelism; consider asking for fewer threads. # %Warning-UNOPTTHREADS: Thread scheduler is unable to provide requested parallelism; consider asking for fewer threads.
# Strangely, asking for more threads makes it go away. # Strangely, asking for more threads makes it go away.
compile( compile(
verilator_flags2 => ['--cc --trace --trace-params -Wno-LITENDIAN', verilator_flags2 => ['--cc --trace --trace-params -Wno-LITENDIAN'],
($Self->{vltmt} ? '--threads 6' : '')], threads => $Self->{vltmt} ? 6 : 0
); );
execute( execute(

View File

@ -16,8 +16,8 @@ top_filename("t/t_trace_litendian.v");
# %Warning-UNOPTTHREADS: Thread scheduler is unable to provide requested parallelism; consider asking for fewer threads. # %Warning-UNOPTTHREADS: Thread scheduler is unable to provide requested parallelism; consider asking for fewer threads.
# Strangely, asking for more threads makes it go away. # Strangely, asking for more threads makes it go away.
compile( compile(
verilator_flags2 => ['--cc --trace-fst --trace-params -Wno-LITENDIAN', verilator_flags2 => ['--cc --trace-fst --trace-params -Wno-LITENDIAN'],
($Self->{vltmt} ? '--threads 6' : '')], threads => $Self->{vltmt} ? 6 : 0
); );
execute( execute(

View File

@ -20,8 +20,8 @@ else {
# %Warning-UNOPTTHREADS: Thread scheduler is unable to provide requested parallelism; consider asking for fewer threads. # %Warning-UNOPTTHREADS: Thread scheduler is unable to provide requested parallelism; consider asking for fewer threads.
# Strangely, asking for more threads makes it go away. # Strangely, asking for more threads makes it go away.
compile( compile(
verilator_flags2 => ['--sc --trace-fst --trace-params -Wno-LITENDIAN', verilator_flags2 => ['--sc --trace-fst --trace-params -Wno-LITENDIAN'],
($Self->{vltmt} ? '--threads 6' : '')], threads => $Self->{vltmt} ? 6 : 0
); );
execute( execute(

View File

@ -8,7 +8,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(vlt => 1); scenarios(vltmt => 1);
my $root = ".."; my $root = "..";
@ -17,10 +17,10 @@ compile(
verilator_flags2 => ["--cc", verilator_flags2 => ["--cc",
"--coverage-toggle --coverage-line --coverage-user", "--coverage-toggle --coverage-line --coverage-user",
"--trace --vpi ", "--trace --vpi ",
"--threads 2",
"--trace-threads 1", "--trace-threads 1",
"--prof-exec", "--prof-pgo", "--prof-exec", "--prof-pgo",
"$root/include/verilated_save.cpp"], "$root/include/verilated_save.cpp"],
threads => 2
); );
execute( execute(

View File

@ -16,7 +16,8 @@ my $root = "..";
compile( compile(
# Can't use --coverage and --savable together, so cheat and compile inline # Can't use --coverage and --savable together, so cheat and compile inline
verilator_flags2 => ["--cc --coverage-toggle --coverage-line --coverage-user --trace --threads 1 --vpi $root/include/verilated_save.cpp"], verilator_flags2 => ["--cc --coverage-toggle --coverage-line --coverage-user --trace --vpi $root/include/verilated_save.cpp"],
threads => 1
); );
execute( execute(

View File

@ -14,8 +14,9 @@ compile(
make_top_shell => 0, make_top_shell => 0,
make_main => 0, make_main => 0,
# link threads library, add custom .cpp code, add tracing & coverage support # link threads library, add custom .cpp code, add tracing & coverage support
verilator_flags2 => ["-threads 1 --exe $Self->{t_dir}/$Self->{name}.cpp", verilator_flags2 => ["--exe $Self->{t_dir}/$Self->{name}.cpp",
"--trace --coverage -cc"], "--trace --coverage -cc"],
threads => 1,
make_flags => 'CPPFLAGS_ADD=-DVL_NO_LEGACY', make_flags => 'CPPFLAGS_ADD=-DVL_NO_LEGACY',
); );

View File

@ -16,8 +16,9 @@ compile(
make_top_shell => 0, make_top_shell => 0,
make_main => 0, make_main => 0,
# link threads library, add custom .cpp code, add tracing & coverage support # link threads library, add custom .cpp code, add tracing & coverage support
verilator_flags2 => ["-threads 1 --exe $Self->{t_dir}/t_wrapper_context.cpp", verilator_flags2 => ["--exe $Self->{t_dir}/t_wrapper_context.cpp",
"--trace-fst --coverage -cc"], "--trace-fst --coverage -cc"],
threads => 1,
make_flags => 'CPPFLAGS_ADD=-DVL_NO_LEGACY', make_flags => 'CPPFLAGS_ADD=-DVL_NO_LEGACY',
); );

View File

@ -16,8 +16,9 @@ compile(
make_top_shell => 0, make_top_shell => 0,
make_main => 0, make_main => 0,
# link threads library, add custom .cpp code, add tracing & coverage support # link threads library, add custom .cpp code, add tracing & coverage support
verilator_flags2 => ["-threads 1 --exe $Self->{t_dir}/t_wrapper_context.cpp", verilator_flags2 => ["--exe $Self->{t_dir}/t_wrapper_context.cpp",
"--trace --coverage -cc"], "--trace --coverage -cc"],
threads => 1,
make_flags => 'CPPFLAGS_ADD=-DVL_NO_LEGACY', make_flags => 'CPPFLAGS_ADD=-DVL_NO_LEGACY',
); );