#!/usr/bin/perl
|
#!/usr/bin/perl
|
|
|
# This is the main simulation environment laucnher script.
|
# This is the main simulation environment laucnher script.
|
# It will create a regression area under a folder with a
|
# It will create a regression area under a folder with a
|
# unique name.
|
# unique name.
|
#
|
#
|
#
|
#
|
#
|
#
|
#
|
#
|
|
|
use strict;
|
use strict;
|
use Cwd;
|
use Cwd;
|
use File::Copy;
|
use File::Copy;
|
use File::Find;
|
use File::Find;
|
use HTTP::Date;
|
use HTTP::Date;
|
use Data::Dumper;
|
use Data::Dumper;
|
#use File::Copy::Recursive;
|
#use File::Copy::Recursive;
|
|
|
#Globals
|
#Globals
|
my $SimulationCommand = undef;
|
my $SimulationCommand = undef;
|
my @SimulationFiles = undef;
|
my @SimulationFiles = undef;
|
my $SimulationBinary = undef;
|
my $SimulationBinary = undef;
|
my $RegressionTargetDirectory = undef;
|
my $RegressionTargetDirectory = undef;
|
my %TestList = undef;
|
my %TestList = undef;
|
|
|
|
|
my
|
my
|
$ScriptPath = getcwd();
|
$ScriptPath = getcwd();
|
print "Running from $ScriptPath\n";
|
print "Running from $ScriptPath\n";
|
#Read the configuration from this file
|
#Read the configuration from this file
|
eval Slurp( "testlist.pl" );
|
eval Slurp( "testlist.pl" );
|
die "-E- Errors in configuration file!\n".$@."\n" if($@);
|
die "-E- Errors in configuration file!\n".$@."\n" if($@);
|
|
|
|
|
CreateTargetTree( $RegressionTargetDirectory );
|
CreateTargetTree( $RegressionTargetDirectory );
|
|
#----------------------------------------------------------------
|
|
sub hashValueAscendingNum {
|
|
$TestList{$a}->{'index'} <=> $TestList{$b}->{'index'};
|
|
}
|
|
|
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
sub CreateTargetTree
|
sub CreateTargetTree
|
{
|
{
|
my $DestinationPath = shift;
|
my $DestinationPath = shift;
|
my ($date, $time) = split(" ", HTTP::Date::time2iso());
|
my ($date, $time) = split(" ", HTTP::Date::time2iso());
|
$time =~ s/:/_/g;
|
$time =~ s/:/_/g;
|
my $RegDir = "$RegressionTargetDirectory/regression_${date}_${time}";
|
my $RegDir = "$RegressionTargetDirectory/regression_${date}_${time}";
|
mkdir $RegDir or die "Cannot create regression folder '$RegDir' $!\n";
|
mkdir $RegDir or die "Cannot create regression folder '$RegDir' $!\n";
|
|
|
#Create the regression.log
|
#Create the regression.log
|
open LOG, ">$RegDir/regression.log" or die "Cannot create file regression log file '$RegDir/Regression.log' $!\n";
|
open LOG, ">$RegDir/regression.log" or die "Cannot create file regression log file '$RegDir/Regression.log' $!\n";
|
print LOG "Regression Test-bench started at $date ,time $time\n";
|
print LOG "Regression Test-bench started at $date ,time $time\n";
|
|
|
|
|
#for my $i (0 .. $#TestList)
|
#for my $i (0 .. $#TestList)
|
#print Dumper(%TestList);
|
#print Dumper(%TestList);
|
for my $TestName (keys %TestList)
|
for my $TestName (sort hashValueAscendingNum (keys %TestList))
|
{
|
{
|
chdir $ScriptPath;
|
chdir $ScriptPath;
|
my $TestPath = $TestList{$TestName}->{'path'};
|
my $TestPath = $TestList{$TestName}->{'path'};
|
|
|
|
|
|
|
print LOG "-----------------------------------------------------------------------------------\n";
|
print LOG "-----------------------------------------------------------------------------------\n";
|
print LOG "Scene: '$TestName'\n";
|
print LOG "Scene: '$TestName'\n";
|
my $TestDir = "$RegDir/$TestName";
|
my $TestDir = "$RegDir/$TestName";
|
mkdir $TestDir;
|
mkdir $TestDir;
|
#Copy compulsory files
|
#Copy compulsory files
|
copy("$TestPath/Vertex.mem","$TestDir/") or die "-E- $TestPath/Vertex.mem $!\n";
|
copy("$TestPath/Vertex.mem","$TestDir/") or die "-E- $TestPath/Vertex.mem $!\n";
|
copy("$TestPath/Params.mem","$TestDir/") or die "-E- $TestPath/Params.mem $!\n";
|
copy("$TestPath/Params.mem","$TestDir/") or die "-E- $TestPath/Params.mem $!\n";
|
copy("$TestPath/Creg.mem","$TestDir/") or die "-E- $TestPath/Config.mem $!\n";
|
copy("$TestPath/Creg.mem","$TestDir/") or die "-E- $TestPath/Config.mem $!\n";
|
copy("$TestPath/Reference.ppm","$TestDir/") or die "-E- $TestPath/Reference.ppm $!\n";
|
copy("$TestPath/Reference.ppm","$TestDir/") or die "-E- $TestPath/Reference.ppm $!\n";
|
copy("$TestPath/Textures.mem","$TestDir/") or die "-E- $TestPath/Textures.ppm $!\n";
|
copy("$TestPath/Textures.mem","$TestDir/") or die "-E- $TestPath/Textures.ppm $!\n";
|
copy("$TestPath/Instructions.mem","$TestDir/") or die "-E- $TestPath/Instructions.ppm $!\n";
|
copy("$TestPath/Instructions.mem","$TestDir/") or die "-E- $TestPath/Instructions.ppm $!\n";
|
|
copy("$TestPath/Instructions.mem","$TestDir/") or die "-E- $TestPath/Instructions.ppm $!\n";
|
|
|
#Copy the Source files just in case..
|
#Copy the Source files just in case..
|
mkdir "$RegDir/rtl";
|
mkdir "$RegDir/rtl";
|
|
system("cp -vr ../rtl/*.v $RegDir/rtl");
|
|
#copy("../rtl","$RegDir") or die ("Cannot Copy '" . $_ . "' : $!\n");
|
|
|
find
|
|
(
|
|
sub{ next if !m/.*\.v/; copy( $File::Find::name,"$RegDir/rtl") or die ("Cannot Copy '" . $_ . "' : $!\n") },
|
|
("../rtl/")
|
|
);
|
|
|
|
#Compile the test code
|
#Compile the test code
|
#print Dumper($TestList{$TestName});
|
#print Dumper($TestList{$TestName});
|
my $CoreCount = $TestList{$TestName}->{core_count};
|
my $CoreCount = $TestList{$TestName}->{core_count};
|
my $MemBankCount = $TestList{$TestName}->{mem_bank_count};
|
my $MemBankCount = $TestList{$TestName}->{mem_bank_count};
|
printf
|
printf
|
"
|
"
|
Compiling Code
|
Compiling Code
|
Number of execution cores: $CoreCount
|
Number of execution cores: $CoreCount
|
Number of texture memory banks: $MemBankCount
|
Number of texture memory banks: $MemBankCount
|
";
|
";
|
|
|
chdir "../simulation";
|
chdir "../simulation";
|
if ( system("make compile GPUCORES=$CoreCount GPUMEMBANKS=$MemBankCount") != 0)
|
if ( system("make compile GPUCORES=$CoreCount GPUMEMBANKS=$MemBankCount") != 0)
|
{
|
{
|
die "-E- Error compiling test code! ($!)\n";
|
die "-E- Error compiling test code! ($!)\n";
|
}
|
}
|
#Now copy the binary over to our simulation directory
|
#Now copy the binary over to our simulation directory
|
|
|
|
|
copy("$SimulationBinary","$TestDir/") or die "-E- $SimulationBinary $!\n";
|
copy("$SimulationBinary","$TestDir/") or die "-E- $SimulationBinary $!\n";
|
|
|
printf
|
printf
|
"
|
"
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
** Theia Regression Started **
|
** Theia Regression Started **
|
|
|
|
|
Regression Target Directory:
|
Regression Target Directory:
|
'$TestDir'
|
'$TestDir'
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
";
|
";
|
|
|
|
|
#Execute the Simulation
|
#Execute the Simulation
|
chdir $TestDir;
|
chdir $TestDir;
|
my ($StartDate,$StartTime) = split(" ", HTTP::Date::time2iso());
|
my ($StartDate,$StartTime) = split(" ", HTTP::Date::time2iso());
|
print LOG "Simulation started at: $StartDate $StartTime\n";
|
print LOG "Simulation started at: $StartDate $StartTime\n";
|
print LOG "Number of execution cores: $CoreCount\n";
|
print LOG "Number of execution cores: $CoreCount\n";
|
print LOG "Number of memory banks: $MemBankCount\n";
|
print LOG "Number of memory banks: $MemBankCount\n";
|
#system "$SimulationCommand -tclbatch isim.tcl";
|
#system "$SimulationCommand -tclbatch isim.tcl";
|
if (system ("perl $ScriptPath/configure_params.pl $CoreCount") != 0)
|
if (system ("perl $ScriptPath/configure_params.pl $CoreCount") != 0)
|
{
|
{
|
die "-E- Error configuing scene parameters! ($!)\n";
|
die "-E- Error configuing scene parameters! ($!)\n";
|
}
|
}
|
|
|
if (system("vvp -n $SimulationBinary -none") != 0)
|
if (system("vvp -n $SimulationBinary -none") != 0)
|
{
|
{
|
print LOG "-E- Error running simulation! ($!)\n";
|
print LOG "-E- Error running simulation! ($!)\n";
|
}
|
}
|
|
|
my ($EndDate,$EndTime) = split(" ", HTTP::Date::time2iso());
|
my ($EndDate,$EndTime) = split(" ", HTTP::Date::time2iso());
|
print LOG "Simulation Completed at $EndDate $EndTime\n";
|
print LOG "Simulation Completed at $EndDate $EndTime\n";
|
if ( $StartDate eq $EndDate)
|
if ( $StartDate eq $EndDate)
|
{
|
{
|
my ($StartHour,$StartMinute) = split ":",$StartTime;
|
my ($StartHour,$StartMinute) = split ":",$StartTime;
|
my ($EndHour,$EndMinute) = split ":",$EndTime;
|
my ($EndHour,$EndMinute) = split ":",$EndTime;
|
print LOG "Elapsed time "
|
print LOG "Elapsed time "
|
. ($EndHour - $StartHour) . " : " . ($EndMinute - $StartMinute) . "\n";
|
. ($EndHour - $StartHour) . " : " . ($EndMinute - $StartMinute) . "\n";
|
} else {
|
} else {
|
print LOG "Simulation ran for more than 1 day\n";
|
print LOG "Simulation ran for more than 1 day\n";
|
}
|
}
|
ParseOutputPPM( $TestDir );
|
ParseOutputPPM( $TestDir );
|
|
|
# system("perl D:/\Proyecto/\RTL/\Scripts/calculate_stats.pl $TestDir/\CU.log $RegDir/\Regression.log $TestDir/\Simulation.log");
|
# system("perl D:/\Proyecto/\RTL/\Scripts/calculate_stats.pl $TestDir/\CU.log $RegDir/\Regression.log $TestDir/\Simulation.log");
|
|
|
}
|
}
|
close LOG;
|
close LOG;
|
|
|
|
|
|
|
}
|
}
|
|
|
#---------------------------------------------------------------- \
|
#---------------------------------------------------------------- \
|
sub Slurp
|
sub Slurp
|
{
|
{
|
my $file = shift;
|
my $file = shift;
|
open F, "< $file" or die "Error opening '$file' for read: $!";
|
open F, "< $file" or die "Error opening '$file' for read: $!";
|
local $/ = undef;
|
local $/ = undef;
|
my $string = <F>;
|
my $string = <F>;
|
close F;
|
close F;
|
return $string;
|
return $string;
|
}
|
}
|
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
sub ParseOutputPPM()
|
sub ParseOutputPPM()
|
{
|
{
|
my $TestDir = shift;
|
my $TestDir = shift;
|
open FILE, "$TestDir/Output.ppm" or die "Can't open $TestDir/Output.ppm !$\n";
|
open FILE, "$TestDir/Output.ppm" or die "Can't open $TestDir/Output.ppm !$\n";
|
my $i = 1;
|
my $i = 1;
|
my $CurrentRow;
|
my $CurrentRow;
|
my $CurrentCol;
|
my $CurrentCol;
|
while (<FILE>)
|
while (<FILE>)
|
{
|
{
|
|
|
if (m/^#\s*(\d+)\,\s+(\d+)/)
|
if (m/^#\s*(\d+)\,\s+(\d+)/)
|
{
|
{
|
$CurrentRow = $1;
|
$CurrentRow = $1;
|
$CurrentCol = $2;
|
$CurrentCol = $2;
|
}
|
}
|
|
|
# m/\s*(\d)\s+(\d)\s+(\d).*/;
|
# m/\s*(\d)\s+(\d)\s+(\d).*/;
|
if (m/x+/g)
|
if (m/x+/g)
|
{
|
{
|
print LOG "FATAL ERROR: 'Output.ppm' Found 'x' at row = $CurrentRow , col = $CurrentCol = $2, line $i\n" ;
|
print LOG "FATAL ERROR: 'Output.ppm' Found 'x' at row = $CurrentRow , col = $CurrentCol = $2, line $i\n" ;
|
last;
|
last;
|
return;
|
return;
|
}
|
}
|
$i++;
|
$i++;
|
}
|
}
|
close FILE;
|
close FILE;
|
}
|
}
|
|
|
|
|