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 194

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
                my $Line = `grep -i  width $TestDir/Params.mem`;
86
                my ($Width,$Height) = split(" ", $Line);
87
                $Width = (hex $Width)/$Scale;
88
                $Height = (hex $Height)/$Scale;
89 190 diegovalve
 
90 194 diegovalve
                print  LOG "Scene Resolution: $Width x $Height\n";
91
                $Line = `grep -i  texture $TestDir/Params.mem`;
92
                my ($Width,$Height) = split(" ", $Line);
93
                $Width = (hex $Width)/$Scale;
94
                $Height = (hex $Height)/$Scale;
95
                print  LOG "Texture: $Width x $Height\n";
96
                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
  if ( system("make compile GPUCORES=$CoreCount GPUMEMBANKS=$MemBankCount") != 0)
118
  {
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
                if (system ("perl $ScriptPath/configure_params.pl $CoreCount") != 0)
149
                {
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
#----------------------------------------------------------------
186
sub ParseOutputPPM()
187
{
188
  my $TestDir = shift;
189
  open FILE, "$TestDir/Output.ppm" or die "Can't open  $TestDir/Output.ppm !$\n";
190
  my $i = 1;
191
  my $CurrentRow;
192
 my $CurrentCol;
193
  while (<FILE>)
194
  {
195
 
196
   if (m/^#\s*(\d+)\,\s+(\d+)/)
197
   {
198
 $CurrentRow = $1;
199
 $CurrentCol = $2;
200
   }
201
 
202
   # m/\s*(\d)\s+(\d)\s+(\d).*/;
203
    if (m/x+/g)
204
    {
205
      print LOG "FATAL ERROR: 'Output.ppm' Found 'x' at row = $CurrentRow , col = $CurrentCol = $2, line $i\n" ;
206
      last;
207
      return;
208
    }
209
     $i++;
210
  }
211
  close FILE;
212
}
213
 

powered by: WebSVN 2.1.0

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