Add initial Travis CI config

This commit is contained in:
Todd Strader 2019-06-27 11:26:25 -04:00
parent 6903c52ef7
commit 009f053d6e
15 changed files with 103 additions and 11 deletions

37
.travis.yml Normal file
View File

@ -0,0 +1,37 @@
# DESCRIPTION: Travis-CI config
#
# Copyright 2003-2019 by Todd Strader. Verilator 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.
language: cpp
compiler: gcc
cache: ccache
# Some tests require gdb
addons:
apt:
packages:
- gdb
# Run three test slices in parallel
env:
- TEST=--dist
- TEST=--vlt
- TEST=--vltmt
before_install:
# Perl modules needed for testing
- yes yes | sudo cpan -fi Unix::Processors Parallel::Forker Bit::Vector
before_script:
- export VLT_JOBS=$((`nproc` + 1))
- export OBJCACHE=ccache
- export VERILATOR_ROOT=`pwd`
- autoconf
script:
- >
./configure --enable-maintainer-mode --enable-longtests &&
make -j $VLT_JOBS &&
make test SCENARIOS=$TEST
after_script:
- ccache -s

View File

@ -14,6 +14,7 @@
.*\.key
.*\.vcd
.*\.1
\.travis\.yml
/obj_dir/
/obj_dbg/
/obj_nc/

View File

@ -42,9 +42,11 @@ endif
######################################################################
SCENARIOS ?= "--vlt --vltmt --dist"
.PHONY: test
test:
$(PERL) driver.pl $(DRIVER_FLAGS) --vlt --vltmt --dist
$(PERL) driver.pl $(DRIVER_FLAGS) $(SCENARIOS)
######################################################################

View File

@ -48,6 +48,7 @@ autoflush STDERR 1;
our @Orig_ARGV = @ARGV;
our @Orig_ARGV_Sw; foreach (@Orig_ARGV) { push @Orig_ARGV_Sw, $_ if /^-/ && !/^-j/; }
our $Start = time();
our $Vltmt_threads = 3;
$Debug = 0;
my $opt_benchmark;
@ -246,11 +247,23 @@ sub parameter {
}
}
sub calc_jobs {
sub max_procs {
my $ok = eval "
use Unix::Processors;
return Unix::Processors->new->max_online;
";
return $ok;
}
sub calc_threads {
my $default = shift;
my $ok = max_procs();
$ok && !$@ or return $default;
return ($ok < $default) ? $ok : $default;
}
sub calc_jobs {
my $ok = max_procs();
$ok && !$@ or die "%Error: Can't use -j: $@\n";
print "driver.pl: Found $ok cores, using -j ",$ok+1,"\n";
return $ok + 1;
@ -603,7 +616,8 @@ sub compile_vlt_flags {
unshift @verilator_flags, "--gdbbt" if $opt_gdbbt;
unshift @verilator_flags, "--x-assign unique"; # More likely to be buggy
unshift @verilator_flags, "--trace" if $opt_trace;
unshift @verilator_flags, "--threads 3" if $param{vltmt};
my $threads = ::calc_threads($Vltmt_threads);
unshift @verilator_flags, "--threads $threads" if $param{vltmt};
unshift @verilator_flags, "--trace-fst-thread" if $param{vltmt} && $checkflags =~ /-trace-fst/;
unshift @verilator_flags, "--debug-partition" if $param{vltmt};
if (defined $opt_optimize) {
@ -1046,6 +1060,30 @@ sub trace_filename {
return "$self->{obj_dir}/simx.vcd";
}
sub get_default_vltmt_threads {
return $Vltmt_threads;
}
sub too_few_cores {
my $threads = ::calc_threads($Vltmt_threads);
return $threads < $Vltmt_threads;
}
sub skip_if_too_few_cores {
my $self = (ref $_[0]? shift : $Self);
if (too_few_cores()) {
$self->skip("Skipping due to too few cores\n");
}
}
sub wno_unopthreads_for_few_cores {
if (too_few_cores()) {
warn "Too few cores, using -Wno-UNOPTTHREADS\n";
return "-Wno-UNOPTTHREADS";
}
return "";
}
#----------------------------------------------------------------------
sub run {

View File

@ -10,7 +10,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(simulator => 1);
compile(
verilator_flags2 => ["--stats"],
verilator_flags2 => ["--stats",
$Self->wno_unopthreads_for_few_cores()]
);
if ($Self->{vlt_all}) {

View File

@ -10,7 +10,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(simulator => 1);
compile(
v_flags2 => ["--stats"],
v_flags2 => ["--stats",
$Self->wno_unopthreads_for_few_cores()]
);
execute(

View File

@ -7,12 +7,13 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
scenarios(vltmt => 1);
scenarios(simulator => 1);
top_filename("t/t_bench_mux4k.v");
compile(
v_flags2 => ["--stats"],
v_flags2 => ["--stats",
$Self->wno_unopthreads_for_few_cores()]
);
if (`numactl --show` !~ /cpu/) {

View File

@ -10,7 +10,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(simulator => 1);
compile(
verilator_flags2 => ["--stats"],
verilator_flags2 => ["--stats",
$Self->wno_unopthreads_for_few_cores()]
);
execute(

View File

@ -7,6 +7,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->skip_if_too_few_cores();
scenarios(vltmt => 1);
top_filename("t/t_dpi_threads.v");

View File

@ -10,6 +10,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(simulator => 1);
compile(
verilator_flags2 => [$Self->wno_unopthreads_for_few_cores()]
);
execute(

View File

@ -11,8 +11,11 @@ scenarios(simulator => 1);
top_filename("t/t_inst_tree.v");
my $default_vltmt_threads = $Self->get_default_vltmt_threads();
compile(
verilator_flags2 => ['+define+NOUSE_INLINE', '+define+USE_PUBLIC', '--stats'],
verilator_flags2 => ['+define+NOUSE_INLINE', '+define+USE_PUBLIC', '--stats',
# Force 3 threads even if we have fewer cores
$Self->{vltmt} ? "--threads $default_vltmt_threads" : ""]
);
sub checkRelativeRefs {

View File

@ -12,7 +12,8 @@ scenarios(simulator => 1);
top_filename("t/t_inst_tree.v");
compile(
verilator_flags2 => ['+define+NOUSE_INLINE', '+define+USE_PUBLIC', '--stats', '--norelative-cfuncs'],
verilator_flags2 => ['+define+NOUSE_INLINE', '+define+USE_PUBLIC', '--stats', '--norelative-cfuncs',
$Self->wno_unopthreads_for_few_cores()]
);
if ($Self->{vlt_all}) {

View File

@ -12,7 +12,8 @@ scenarios(simulator => 1);
top_filename("t/t_inst_tree.v");
compile(
v_flags2 => ['+define+USE_INLINE', '+define+USE_PUBLIC'],
v_flags2 => ['+define+USE_INLINE', '+define+USE_PUBLIC',
$Self->wno_unopthreads_for_few_cores()]
);
execute(

View File

@ -10,6 +10,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(simulator => 1);
compile(
verilator_flags2 => [$Self->wno_unopthreads_for_few_cores()]
);
execute(

View File

@ -11,6 +11,7 @@ scenarios(simulator => 1);
compile(
verilator_flags2 => ["-unroll-count 1024",
$Self->wno_unopthreads_for_few_cores(),
"--stats"],
);