OpenCores
URL https://opencores.org/ocsvn/theia_gpu/theia_gpu/trunk

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [icarus_version/] [scripts/] [run_regressions.pl] - Blame information for rev 190

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 185 diegovalve
#!/usr/bin/perl
2
 
3
# This is the main simulation environment laucnher script.
4
# It will create a regression area under a folder with a
5
# unique name.
6
#
7
#
8
#
9
#
10
 
11
use strict;
12
use Cwd;
13
use File::Copy;
14
use File::Find;
15
use HTTP::Date;
16
use Data::Dumper;
17
#use File::Copy::Recursive;
18
 
19
#Globals
20
my $SimulationCommand          = undef;
21
my @SimulationFiles            = undef;
22
my $SimulationBinary           = undef;
23
my $RegressionTargetDirectory  = undef;
24
my %TestList                   = undef;
25
 
26
 
27
my
28
$ScriptPath = getcwd();
29
print "Running from $ScriptPath\n";
30
#Read the configuration from this file
31
eval Slurp( "testlist.pl" );
32
die "-E- Errors in configuration file!\n".$@."\n" if($@);
33
 
34
 
35
CreateTargetTree( $RegressionTargetDirectory );
36 190 diegovalve
#----------------------------------------------------------------
37
sub hashValueAscendingNum {
38
   $TestList{$a}->{'index'} <=> $TestList{$b}->{'index'};
39
}
40 185 diegovalve
 
41
#----------------------------------------------------------------
42
sub CreateTargetTree
43
{
44
  my $DestinationPath = shift;
45
  my ($date, $time) = split(" ", HTTP::Date::time2iso());
46
  $time =~ s/:/_/g;
47
  my $RegDir = "$RegressionTargetDirectory/regression_${date}_${time}";
48
  mkdir $RegDir or die "Cannot create regression folder '$RegDir' $!\n";
49
 
50
  #Create the regression.log
51
  open LOG, ">$RegDir/regression.log" or die "Cannot create file regression log file '$RegDir/Regression.log' $!\n";
52
  print LOG "Regression Test-bench started at $date ,time $time\n";
53
 
54
 
55
  #for my $i (0 .. $#TestList)
56
  #print Dumper(%TestList);
57 190 diegovalve
  for my $TestName (sort hashValueAscendingNum (keys %TestList))
58 185 diegovalve
  {
59 187 diegovalve
        chdir $ScriptPath;
60 185 diegovalve
        my $TestPath = $TestList{$TestName}->{'path'};
61
 
62
 
63
 
64
                print LOG "-----------------------------------------------------------------------------------\n";
65
                print LOG "Scene: '$TestName'\n";
66
        my $TestDir = "$RegDir/$TestName";
67
        mkdir $TestDir;
68
        #Copy compulsory files
69
        copy("$TestPath/Vertex.mem","$TestDir/") or die "-E- $TestPath/Vertex.mem $!\n";
70
        copy("$TestPath/Params.mem","$TestDir/") or die "-E- $TestPath/Params.mem $!\n";
71
        copy("$TestPath/Creg.mem","$TestDir/") or die "-E- $TestPath/Config.mem $!\n";
72
        copy("$TestPath/Reference.ppm","$TestDir/") or die "-E- $TestPath/Reference.ppm $!\n";
73
                copy("$TestPath/Textures.mem","$TestDir/") or die "-E- $TestPath/Textures.ppm $!\n";
74
                copy("$TestPath/Instructions.mem","$TestDir/") or die "-E- $TestPath/Instructions.ppm $!\n";
75 190 diegovalve
                copy("$TestPath/Instructions.mem","$TestDir/") or die "-E- $TestPath/Instructions.ppm $!\n";
76
 
77 185 diegovalve
        #Copy the Source files just in case..
78
        mkdir "$RegDir/rtl";
79 190 diegovalve
                system("cp -vr ../rtl/*.v $RegDir/rtl");
80
        #copy("../rtl","$RegDir")  or die ("Cannot Copy '" . $_ . "' : $!\n");
81 185 diegovalve
 
82
 
83
#Compile the test code 
84
#print Dumper($TestList{$TestName});
85
my $CoreCount = $TestList{$TestName}->{core_count};
86
my $MemBankCount = $TestList{$TestName}->{mem_bank_count};
87
printf
88
  "
89
    Compiling Code
90
        Number of execution cores: $CoreCount
91
        Number of texture memory banks: $MemBankCount
92
  ";
93
 
94
  chdir "../simulation";
95
  if ( system("make compile GPUCORES=$CoreCount GPUMEMBANKS=$MemBankCount") != 0)
96
  {
97
        die "-E- Error compiling test code! ($!)\n";
98
  }
99
 #Now copy the binary over to our simulation directory
100
 
101
 
102
 copy("$SimulationBinary","$TestDir/") or die "-E- $SimulationBinary $!\n";
103
 
104
        printf
105
 "
106
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107
 ** Theia Regression Started **
108
 
109
 
110
 Regression Target Directory:
111
 '$TestDir'
112
 
113
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114
 ";
115
 
116
 
117
        #Execute the Simulation
118
        chdir $TestDir;
119
        my ($StartDate,$StartTime) =   split(" ", HTTP::Date::time2iso());
120
        print LOG "Simulation started at:             $StartDate $StartTime\n";
121
                print LOG "Number of execution cores:         $CoreCount\n";
122
                print LOG "Number of memory banks:            $MemBankCount\n";
123
        #system "$SimulationCommand -tclbatch isim.tcl";
124
                if (system ("perl $ScriptPath/configure_params.pl $CoreCount") != 0)
125
                {
126
                        die "-E- Error configuing scene parameters! ($!)\n";
127
                }
128
 
129
                if (system("vvp -n $SimulationBinary -none") != 0)
130
                {
131
                  print LOG "-E- Error running simulation! ($!)\n";
132
                }
133
 
134
        my ($EndDate,$EndTime) =   split(" ", HTTP::Date::time2iso());
135
        print LOG "Simulation Completed at $EndDate $EndTime\n";
136
        if (  $StartDate eq $EndDate)
137
        {
138
          my ($StartHour,$StartMinute) = split ":",$StartTime;
139
          my ($EndHour,$EndMinute) = split ":",$EndTime;
140
          print LOG "Elapsed time "
141
           . ($EndHour - $StartHour) . " : " . ($EndMinute - $StartMinute) . "\n";
142
        } else {
143
          print LOG "Simulation ran for more than 1 day\n";
144
        }
145
    ParseOutputPPM( $TestDir );
146
 
147
   # system("perl D:/\Proyecto/\RTL/\Scripts/calculate_stats.pl $TestDir/\CU.log $RegDir/\Regression.log $TestDir/\Simulation.log");
148
 
149
  }
150
close LOG;
151
 
152
 
153
 
154
}
155
 
156
#---------------------------------------------------------------- \
157
sub Slurp
158
{
159
    my $file = shift;
160
    open F, "< $file" or die "Error opening '$file' for read: $!";
161
    local $/ = undef;
162
    my $string = <F>;
163
    close F;
164
    return $string;
165
}
166
#----------------------------------------------------------------
167
sub ParseOutputPPM()
168
{
169
  my $TestDir = shift;
170
  open FILE, "$TestDir/Output.ppm" or die "Can't open  $TestDir/Output.ppm !$\n";
171
  my $i = 1;
172
  my $CurrentRow;
173
 my $CurrentCol;
174
  while (<FILE>)
175
  {
176
 
177
   if (m/^#\s*(\d+)\,\s+(\d+)/)
178
   {
179
 $CurrentRow = $1;
180
 $CurrentCol = $2;
181
   }
182
 
183
   # m/\s*(\d)\s+(\d)\s+(\d).*/;
184
    if (m/x+/g)
185
    {
186
      print LOG "FATAL ERROR: 'Output.ppm' Found 'x' at row = $CurrentRow , col = $CurrentCol = $2, line $i\n" ;
187
      last;
188
      return;
189
    }
190
     $i++;
191
  }
192
  close FILE;
193
}
194
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.