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 187

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

powered by: WebSVN 2.1.0

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