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 211

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 194 diegovalve
use Time::HiRes;
17 185 diegovalve
use Data::Dumper;
18
#use File::Copy::Recursive;
19
 
20
#Globals
21
my $SimulationCommand          = undef;
22
my @SimulationFiles            = undef;
23
my $SimulationBinary           = undef;
24
my $RegressionTargetDirectory  = undef;
25
my %TestList                   = undef;
26
 
27
 
28
my
29
$ScriptPath = getcwd();
30
print "Running from $ScriptPath\n";
31
#Read the configuration from this file
32
eval Slurp( "testlist.pl" );
33
die "-E- Errors in configuration file!\n".$@."\n" if($@);
34
 
35 194 diegovalve
my $Scale = 131072; # 2^17
36 185 diegovalve
CreateTargetTree( $RegressionTargetDirectory );
37 190 diegovalve
#----------------------------------------------------------------
38
sub hashValueAscendingNum {
39 191 diegovalve
   $TestList{$a}->{'run_index'} <=> $TestList{$b}->{'run_index'};
40 190 diegovalve
}
41 185 diegovalve
 
42
#----------------------------------------------------------------
43
sub CreateTargetTree
44
{
45
  my $DestinationPath = shift;
46
  my ($date, $time) = split(" ", HTTP::Date::time2iso());
47
  $time =~ s/:/_/g;
48
  my $RegDir = "$RegressionTargetDirectory/regression_${date}_${time}";
49
  mkdir $RegDir or die "Cannot create regression folder '$RegDir' $!\n";
50
 
51
  #Create the regression.log
52
  open LOG, ">$RegDir/regression.log" or die "Cannot create file regression log file '$RegDir/Regression.log' $!\n";
53
  print LOG "Regression Test-bench started at $date ,time $time\n";
54 194 diegovalve
  #Collect some information about the system
55
  my $system = `uname -a`;
56
  my $memory = `cat /proc/meminfo | grep -i memtotal`;
57
  my $cpu = `cat /proc/cpuinfo | grep -i model | grep name`;
58
  print LOG "System: $system\n";
59
  print LOG "RAM: $memory\n";
60
  print LOG "CPU:\n$cpu\n";
61 185 diegovalve
 
62
  #for my $i (0 .. $#TestList)
63
  #print Dumper(%TestList);
64 190 diegovalve
  for my $TestName (sort hashValueAscendingNum (keys %TestList))
65 185 diegovalve
  {
66 187 diegovalve
        chdir $ScriptPath;
67 185 diegovalve
        my $TestPath = $TestList{$TestName}->{'path'};
68
 
69
 
70
 
71
                print LOG "-----------------------------------------------------------------------------------\n";
72
                print LOG "Scene: '$TestName'\n";
73
        my $TestDir = "$RegDir/$TestName";
74 194 diegovalve
 
75 185 diegovalve
        mkdir $TestDir;
76
        #Copy compulsory files
77
        copy("$TestPath/Vertex.mem","$TestDir/") or die "-E- $TestPath/Vertex.mem $!\n";
78
        copy("$TestPath/Params.mem","$TestDir/") or die "-E- $TestPath/Params.mem $!\n";
79
        copy("$TestPath/Creg.mem","$TestDir/") or die "-E- $TestPath/Config.mem $!\n";
80
        copy("$TestPath/Reference.ppm","$TestDir/") or die "-E- $TestPath/Reference.ppm $!\n";
81
                copy("$TestPath/Textures.mem","$TestDir/") or die "-E- $TestPath/Textures.ppm $!\n";
82
                copy("$TestPath/Instructions.mem","$TestDir/") or die "-E- $TestPath/Instructions.ppm $!\n";
83 190 diegovalve
                copy("$TestPath/Instructions.mem","$TestDir/") or die "-E- $TestPath/Instructions.ppm $!\n";
84 194 diegovalve
                #Print some information about the scene
85 190 diegovalve
 
86 195 diegovalve
 
87
                my $Width = $TestList{$TestName}->{'width'};
88
                my $Height = $TestList{$TestName}->{'height'};
89
 
90 194 diegovalve
                print  LOG "Scene Resolution: $Width x $Height\n";
91 195 diegovalve
                my $Line = `grep -i  texture $TestDir/Params.mem`;
92
                my ($tWidth,$tHeight) = split(" ", $Line);
93
                $tWidth = (hex $tWidth)/$Scale;
94
                $tHeight = (hex $tHeight)/$Scale;
95
                print  LOG "Texture: $tWidth x $tHeight\n";
96 194 diegovalve
                my $TringleCount = `grep -A 1 -i child $TestDir/Vertex.mem | grep -v -i child`;
97
                print LOG "Triangle count: $TringleCount\n";
98
 
99 185 diegovalve
        #Copy the Source files just in case..
100
        mkdir "$RegDir/rtl";
101 190 diegovalve
                system("cp -vr ../rtl/*.v $RegDir/rtl");
102
        #copy("../rtl","$RegDir")  or die ("Cannot Copy '" . $_ . "' : $!\n");
103 185 diegovalve
 
104
 
105
#Compile the test code 
106
#print Dumper($TestList{$TestName});
107
my $CoreCount = $TestList{$TestName}->{core_count};
108
my $MemBankCount = $TestList{$TestName}->{mem_bank_count};
109
printf
110
  "
111
    Compiling Code
112
        Number of execution cores: $CoreCount
113
        Number of texture memory banks: $MemBankCount
114
  ";
115
 
116
  chdir "../simulation";
117 196 diegovalve
  if ( system("make compile GPUCORES=$CoreCount GPUMEMBANKS=$MemBankCount") != 0)
118 185 diegovalve
  {
119
        die "-E- Error compiling test code! ($!)\n";
120
  }
121
 #Now copy the binary over to our simulation directory
122
 
123
 
124
 copy("$SimulationBinary","$TestDir/") or die "-E- $SimulationBinary $!\n";
125
 
126
        printf
127
 "
128
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
129
 ** Theia Regression Started **
130
 
131
 
132
 Regression Target Directory:
133
 '$TestDir'
134
 
135
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136
 ";
137
 
138
 
139
        #Execute the Simulation
140
        chdir $TestDir;
141
        my ($StartDate,$StartTime) =   split(" ", HTTP::Date::time2iso());
142 194 diegovalve
 
143 185 diegovalve
                print LOG "Number of execution cores:         $CoreCount\n";
144
                print LOG "Number of memory banks:            $MemBankCount\n";
145 194 diegovalve
                print LOG "Simulation started at:             $StartDate $StartTime\n";
146
 
147 185 diegovalve
        #system "$SimulationCommand -tclbatch isim.tcl";
148 196 diegovalve
                if (system ("perl $ScriptPath/configure_params.pl $CoreCount $Width $Height") != 0)
149 185 diegovalve
                {
150
                        die "-E- Error configuing scene parameters! ($!)\n";
151
                }
152 194 diegovalve
                my $StartTime = [Time::HiRes::gettimeofday()];
153 185 diegovalve
                if (system("vvp -n $SimulationBinary -none") != 0)
154
                {
155
                  print LOG "-E- Error running simulation! ($!)\n";
156
                }
157
 
158 194 diegovalve
                my $diff = Time::HiRes::tv_interval($StartTime);
159
                my ($EndDate,$EndTime) =   split(" ", HTTP::Date::time2iso());
160 185 diegovalve
        print LOG "Simulation Completed at $EndDate $EndTime\n";
161 194 diegovalve
                print LOG "Simulation ran for " . $diff/3600 . " hours\n";
162
 
163
 
164 185 diegovalve
    ParseOutputPPM( $TestDir );
165
 
166
   # system("perl D:/\Proyecto/\RTL/\Scripts/calculate_stats.pl $TestDir/\CU.log $RegDir/\Regression.log $TestDir/\Simulation.log");
167
 
168
  }
169
close LOG;
170
 
171
 
172
 
173
}
174
 
175
#---------------------------------------------------------------- \
176
sub Slurp
177
{
178
    my $file = shift;
179
    open F, "< $file" or die "Error opening '$file' for read: $!";
180
    local $/ = undef;
181
    my $string = <F>;
182
    close F;
183
    return $string;
184
}
185 195 diegovalve
#-------------------------------------------------------------------------------
186
sub Round
187
{
188
  my $number = shift;
189
  my $rounded = sprintf("%.3f", $number);
190
  return $rounded;
191
}
192 185 diegovalve
#----------------------------------------------------------------
193
sub ParseOutputPPM()
194
{
195
  my $TestDir = shift;
196
  open FILE, "$TestDir/Output.ppm" or die "Can't open  $TestDir/Output.ppm !$\n";
197
  my $i = 1;
198
  my $CurrentRow;
199
 my $CurrentCol;
200
  while (<FILE>)
201
  {
202
 
203
   if (m/^#\s*(\d+)\,\s+(\d+)/)
204
   {
205
 $CurrentRow = $1;
206
 $CurrentCol = $2;
207
   }
208
 
209
   # m/\s*(\d)\s+(\d)\s+(\d).*/;
210
    if (m/x+/g)
211
    {
212
      print LOG "FATAL ERROR: 'Output.ppm' Found 'x' at row = $CurrentRow , col = $CurrentCol = $2, line $i\n" ;
213
      last;
214
      return;
215
    }
216
     $i++;
217
  }
218
  close FILE;
219 195 diegovalve
 
220
 my $TotalTime = 0;
221
open F, "$TestDir/Simulation.log" or die "$TestDir/Simulation.log' : $!\n";
222
 
223
 
224
local $/=undef;
225
my $Temp = <F>;
226
close F;
227
my($junk,$StartSimTime) = split /Simulation start time \:\s+/,$Temp;
228
my($junk,$EndSimTime) = split /Simulation end time \:\s+/,$Temp;
229
$StartSimTime =~ s/ns//;
230
$EndSimTime =~ s/ns//;
231
$TotalTime = ($EndSimTime-$StartSimTime)/1000000000;
232
print LOG "Simulated start time: $StartSimTime\n";
233
print LOG "Simulated end time: $EndSimTime\n";
234
print LOG "Total Time: $TotalTime seconds\n";
235
print LOG "Theorical FPS: ". Round( (1 /$TotalTime) )."\n";
236 185 diegovalve
}
237
 

powered by: WebSVN 2.1.0

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