# HG changeset patch # User rlm # Date 1273634601 14400 # Node ID 0ede0715dbd66885d30aec271ec64ce8a61c0454 # Parent 6bd9397cd59101d3c0b0bd98ffc1e92bd6efd090 [svn r68] added sensible benchmarks diff -r 6bd9397cd591 -r 0ede0715dbd6 pygar-benchmarks/music/null/null0.wav Binary file pygar-benchmarks/music/null/null0.wav has changed diff -r 6bd9397cd591 -r 0ede0715dbd6 pygar-benchmarks/networks/net0 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pygar-benchmarks/networks/net0 Tue May 11 23:23:21 2010 -0400 @@ -0,0 +1,13 @@ +(0, "bit-shift.vmh") +(1, "volume-reduce.vmh") +(2, "identity.vmh") +(3, "delay.vmh") +(4, "bit-shift.vmh") +(5, "volume-reduce.vmh") +(6, "identity.vmh") +(7, "delay.vmh") +(8, "bit-shift.vmh") +(9, "volume-reduce.vmh") +(10,"identity.vmh") +(11,"delay.vmh") +(12,"bit-shift.vmh") \ No newline at end of file diff -r 6bd9397cd591 -r 0ede0715dbd6 pygar-benchmarks/programs/bit-shift.vmh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pygar-benchmarks/programs/bit-shift.vmh Tue May 11 23:23:21 2010 -0400 @@ -0,0 +1,90 @@ + +@400 // <__start> +3c1d0002 // 00001000 lui $sp,0x2 +0c00042d // 00001004 jal 10b4
+00000000 // 00001008 nop +00000000 // 0000100c nop + +@404 // +24020001 // 00001010 li $v0,1 +03e00008 // 00001014 jr $ra + +@406 // +4084a800 // 00001018 mtc0 $a0,$21 +08000407 // 0000101c j 101c +00000000 // 00001020 nop + +@409 // +40845000 // 00001024 mtc0 $a0,$10 +03e00008 // 00001028 jr $ra +00000000 // 0000102c nop + +@40c // +24020001 // 00001030 li $v0,1 +4082d000 // 00001034 mtc0 $v0,$26 +03e00008 // 00001038 jr $ra +00000000 // 0000103c nop + +@410 // +4003c800 // 00001040 mfc0 $v1,$25 +24020001 // 00001044 li $v0,1 +10620004 // 00001048 beq $v1,$v0,105c +4005e000 // 0000104c mfc0 $a1,$28 +00000000 // 00001050 nop +ac850000 // 00001054 sw $a1,0($a0) +03e00008 // 00001058 jr $ra +ac800000 // 0000105c sw $zero,0($a0) +00001021 // 00001060 move $v0,$zero +03e00008 // 00001064 jr $ra + +@41a // +4084d800 // 00001068 mtc0 $a0,$27 +03e00008 // 0000106c jr $ra +00000000 // 00001070 nop + +@41d // +27bdffa8 // 00001074 addiu $sp,$sp,-88 +afbf0050 // 00001078 sw $ra,80($sp) +0c000409 // 0000107c jal 1024 +27a40010 // 00001080 addiu $a0,$sp,16 +0c000410 // 00001084 jal 1040 +00021400 // 00001088 sll $v0,$v0,0x10 +10400003 // 0000108c beqz $v0,109c +8fa40010 // 00001090 lw $a0,16($sp) +0c00041a // 00001094 jal 1068 +08000420 // 00001098 j 1080 +0c00040c // 0000109c jal 1030 +00002021 // 000010a0 move $a0,$zero +0c000409 // 000010a4 jal 1024 +8fbf0050 // 000010a8 lw $ra,80($sp) +27bd0058 // 000010ac addiu $sp,$sp,88 +03e00008 // 000010b0 jr $ra + +@42d //
+27bdffe8 // 000010b4 addiu $sp,$sp,-24 +24040001 // 000010b8 li $a0,1 +afbf0010 // 000010bc sw $ra,16($sp) +0c00041d // 000010c0 jal 1074 +0c00040c // 000010c4 jal 1030 +8fbf0010 // 000010c8 lw $ra,16($sp) +27bd0018 // 000010cc addiu $sp,$sp,24 +03e00008 // 000010d0 jr $ra +00000000 // 000010d4 nop +00000000 // 000010d8 nop +00000000 // 000010dc nop + +@438 // <_heapend> +00000000 // 000010e0 nop + +@439 // +00000000 // 000010e4 nop +00000000 // 000010e8 nop +00000000 // 000010ec nop + +@43c // <.reginfo> +a000003c // 000010f0 sb $zero,60($zero) +00000000 // 000010f4 nop +00000000 // 000010f8 nop +00000000 // 000010fc nop +00000000 // 00001100 nop +000090d0 // 00001104 0x90d0 diff -r 6bd9397cd591 -r 0ede0715dbd6 pygar-benchmarks/programs/delay.vmh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pygar-benchmarks/programs/delay.vmh Tue May 11 23:23:21 2010 -0400 @@ -0,0 +1,90 @@ + +@400 // <__start> +3c1d0002 // 00001000 lui $sp,0x2 +0c00042d // 00001004 jal 10b4
+00000000 // 00001008 nop +00000000 // 0000100c nop + +@404 // +24020001 // 00001010 li $v0,1 +03e00008 // 00001014 jr $ra + +@406 // +4084a800 // 00001018 mtc0 $a0,$21 +08000407 // 0000101c j 101c +00000000 // 00001020 nop + +@409 // +40845000 // 00001024 mtc0 $a0,$10 +03e00008 // 00001028 jr $ra +00000000 // 0000102c nop + +@40c // +24020001 // 00001030 li $v0,1 +4082d000 // 00001034 mtc0 $v0,$26 +03e00008 // 00001038 jr $ra +00000000 // 0000103c nop + +@410 // +4003c800 // 00001040 mfc0 $v1,$25 +24020001 // 00001044 li $v0,1 +10620004 // 00001048 beq $v1,$v0,105c +4005e000 // 0000104c mfc0 $a1,$28 +00000000 // 00001050 nop +ac850000 // 00001054 sw $a1,0($a0) +03e00008 // 00001058 jr $ra +ac800000 // 0000105c sw $zero,0($a0) +00001021 // 00001060 move $v0,$zero +03e00008 // 00001064 jr $ra + +@41a // +4084d800 // 00001068 mtc0 $a0,$27 +03e00008 // 0000106c jr $ra +00000000 // 00001070 nop + +@41d // +27bdffa8 // 00001074 addiu $sp,$sp,-88 +afbf0050 // 00001078 sw $ra,80($sp) +0c000409 // 0000107c jal 1024 +27a40010 // 00001080 addiu $a0,$sp,16 +0c000410 // 00001084 jal 1040 +00021400 // 00001088 sll $v0,$v0,0x10 +10400003 // 0000108c beqz $v0,109c +8fa40010 // 00001090 lw $a0,16($sp) +0c00041a // 00001094 jal 1068 +08000420 // 00001098 j 1080 +0c00040c // 0000109c jal 1030 +00002021 // 000010a0 move $a0,$zero +0c000409 // 000010a4 jal 1024 +8fbf0050 // 000010a8 lw $ra,80($sp) +27bd0058 // 000010ac addiu $sp,$sp,88 +03e00008 // 000010b0 jr $ra + +@42d //
+27bdffe8 // 000010b4 addiu $sp,$sp,-24 +24040001 // 000010b8 li $a0,1 +afbf0010 // 000010bc sw $ra,16($sp) +0c00041d // 000010c0 jal 1074 +0c00040c // 000010c4 jal 1030 +8fbf0010 // 000010c8 lw $ra,16($sp) +27bd0018 // 000010cc addiu $sp,$sp,24 +03e00008 // 000010d0 jr $ra +00000000 // 000010d4 nop +00000000 // 000010d8 nop +00000000 // 000010dc nop + +@438 // <_heapend> +00000000 // 000010e0 nop + +@439 // +00000000 // 000010e4 nop +00000000 // 000010e8 nop +00000000 // 000010ec nop + +@43c // <.reginfo> +a000003c // 000010f0 sb $zero,60($zero) +00000000 // 000010f4 nop +00000000 // 000010f8 nop +00000000 // 000010fc nop +00000000 // 00001100 nop +000090d0 // 00001104 0x90d0 diff -r 6bd9397cd591 -r 0ede0715dbd6 pygar-benchmarks/programs/identity.vmh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pygar-benchmarks/programs/identity.vmh Tue May 11 23:23:21 2010 -0400 @@ -0,0 +1,90 @@ + +@400 // <__start> +3c1d0002 // 00001000 lui $sp,0x2 +0c00042d // 00001004 jal 10b4
+00000000 // 00001008 nop +00000000 // 0000100c nop + +@404 // +24020001 // 00001010 li $v0,1 +03e00008 // 00001014 jr $ra + +@406 // +4084a800 // 00001018 mtc0 $a0,$21 +08000407 // 0000101c j 101c +00000000 // 00001020 nop + +@409 // +40845000 // 00001024 mtc0 $a0,$10 +03e00008 // 00001028 jr $ra +00000000 // 0000102c nop + +@40c // +24020001 // 00001030 li $v0,1 +4082d000 // 00001034 mtc0 $v0,$26 +03e00008 // 00001038 jr $ra +00000000 // 0000103c nop + +@410 // +4003c800 // 00001040 mfc0 $v1,$25 +24020001 // 00001044 li $v0,1 +10620004 // 00001048 beq $v1,$v0,105c +4005e000 // 0000104c mfc0 $a1,$28 +00000000 // 00001050 nop +ac850000 // 00001054 sw $a1,0($a0) +03e00008 // 00001058 jr $ra +ac800000 // 0000105c sw $zero,0($a0) +00001021 // 00001060 move $v0,$zero +03e00008 // 00001064 jr $ra + +@41a // +4084d800 // 00001068 mtc0 $a0,$27 +03e00008 // 0000106c jr $ra +00000000 // 00001070 nop + +@41d // +27bdffa8 // 00001074 addiu $sp,$sp,-88 +afbf0050 // 00001078 sw $ra,80($sp) +0c000409 // 0000107c jal 1024 +27a40010 // 00001080 addiu $a0,$sp,16 +0c000410 // 00001084 jal 1040 +00021400 // 00001088 sll $v0,$v0,0x10 +10400003 // 0000108c beqz $v0,109c +8fa40010 // 00001090 lw $a0,16($sp) +0c00041a // 00001094 jal 1068 +08000420 // 00001098 j 1080 +0c00040c // 0000109c jal 1030 +00002021 // 000010a0 move $a0,$zero +0c000409 // 000010a4 jal 1024 +8fbf0050 // 000010a8 lw $ra,80($sp) +27bd0058 // 000010ac addiu $sp,$sp,88 +03e00008 // 000010b0 jr $ra + +@42d //
+27bdffe8 // 000010b4 addiu $sp,$sp,-24 +24040001 // 000010b8 li $a0,1 +afbf0010 // 000010bc sw $ra,16($sp) +0c00041d // 000010c0 jal 1074 +0c00040c // 000010c4 jal 1030 +8fbf0010 // 000010c8 lw $ra,16($sp) +27bd0018 // 000010cc addiu $sp,$sp,24 +03e00008 // 000010d0 jr $ra +00000000 // 000010d4 nop +00000000 // 000010d8 nop +00000000 // 000010dc nop + +@438 // <_heapend> +00000000 // 000010e0 nop + +@439 // +00000000 // 000010e4 nop +00000000 // 000010e8 nop +00000000 // 000010ec nop + +@43c // <.reginfo> +a000003c // 000010f0 sb $zero,60($zero) +00000000 // 000010f4 nop +00000000 // 000010f8 nop +00000000 // 000010fc nop +00000000 // 00001100 nop +000090d0 // 00001104 0x90d0 diff -r 6bd9397cd591 -r 0ede0715dbd6 pygar-benchmarks/programs/volume-reduce.vmh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pygar-benchmarks/programs/volume-reduce.vmh Tue May 11 23:23:21 2010 -0400 @@ -0,0 +1,90 @@ + +@400 // <__start> +3c1d0002 // 00001000 lui $sp,0x2 +0c00042d // 00001004 jal 10b4
+00000000 // 00001008 nop +00000000 // 0000100c nop + +@404 // +24020001 // 00001010 li $v0,1 +03e00008 // 00001014 jr $ra + +@406 // +4084a800 // 00001018 mtc0 $a0,$21 +08000407 // 0000101c j 101c +00000000 // 00001020 nop + +@409 // +40845000 // 00001024 mtc0 $a0,$10 +03e00008 // 00001028 jr $ra +00000000 // 0000102c nop + +@40c // +24020001 // 00001030 li $v0,1 +4082d000 // 00001034 mtc0 $v0,$26 +03e00008 // 00001038 jr $ra +00000000 // 0000103c nop + +@410 // +4003c800 // 00001040 mfc0 $v1,$25 +24020001 // 00001044 li $v0,1 +10620004 // 00001048 beq $v1,$v0,105c +4005e000 // 0000104c mfc0 $a1,$28 +00000000 // 00001050 nop +ac850000 // 00001054 sw $a1,0($a0) +03e00008 // 00001058 jr $ra +ac800000 // 0000105c sw $zero,0($a0) +00001021 // 00001060 move $v0,$zero +03e00008 // 00001064 jr $ra + +@41a // +4084d800 // 00001068 mtc0 $a0,$27 +03e00008 // 0000106c jr $ra +00000000 // 00001070 nop + +@41d // +27bdffa8 // 00001074 addiu $sp,$sp,-88 +afbf0050 // 00001078 sw $ra,80($sp) +0c000409 // 0000107c jal 1024 +27a40010 // 00001080 addiu $a0,$sp,16 +0c000410 // 00001084 jal 1040 +00021400 // 00001088 sll $v0,$v0,0x10 +10400003 // 0000108c beqz $v0,109c +8fa40010 // 00001090 lw $a0,16($sp) +0c00041a // 00001094 jal 1068 +08000420 // 00001098 j 1080 +0c00040c // 0000109c jal 1030 +00002021 // 000010a0 move $a0,$zero +0c000409 // 000010a4 jal 1024 +8fbf0050 // 000010a8 lw $ra,80($sp) +27bd0058 // 000010ac addiu $sp,$sp,88 +03e00008 // 000010b0 jr $ra + +@42d //
+27bdffe8 // 000010b4 addiu $sp,$sp,-24 +24040001 // 000010b8 li $a0,1 +afbf0010 // 000010bc sw $ra,16($sp) +0c00041d // 000010c0 jal 1074 +0c00040c // 000010c4 jal 1030 +8fbf0010 // 000010c8 lw $ra,16($sp) +27bd0018 // 000010cc addiu $sp,$sp,24 +03e00008 // 000010d0 jr $ra +00000000 // 000010d4 nop +00000000 // 000010d8 nop +00000000 // 000010dc nop + +@438 // <_heapend> +00000000 // 000010e0 nop + +@439 // +00000000 // 000010e4 nop +00000000 // 000010e8 nop +00000000 // 000010ec nop + +@43c // <.reginfo> +a000003c // 000010f0 sb $zero,60($zero) +00000000 // 000010f4 nop +00000000 // 000010f8 nop +00000000 // 000010fc nop +00000000 // 00001100 nop +000090d0 // 00001104 0x90d0 diff -r 6bd9397cd591 -r 0ede0715dbd6 pygar-benchmarks/setup/run-sim.bmark --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pygar-benchmarks/setup/run-sim.bmark Tue May 11 23:23:21 2010 -0400 @@ -0,0 +1,528 @@ +#!/usr/bin/env perl +# -*- perl -*- + +use strict; +use warnings; +use Getopt::Long qw(:config no_auto_abbrev no_ignore_case pass_through); +use IO::Pty; + +# +# Turn on warnings +# +$^W = 1; + +## +## Benchmark run script +## + +sub ExecModel($); +sub Exec($$); +sub CompareOutput(); +sub ReadConfig($$); + + +############################################################################# +############################################################################# +## +## Start by figuring out the model location and type. +## +############################################################################# +############################################################################# + +my %config; + +ReadConfig("config/env.sh", 1); +ReadConfig("$config{modelDir}/config/env.sh", 1); +ReadConfig("$config{modelDir}/config/signature.sh", 0); + +## +## Pseudo-enumeration of possible model types +## +my $MODEL_NONE = 0; +my $MODEL_FPGA = 1; # Model runs on FPGA hardware +my $MODEL_BLUESIM = 2; # Bluesim +my $MODEL_VSIM = 3; # Verilog simulator + +my $mType = $MODEL_NONE; + + +############################################################################# +############################################################################# +## +## Process command line arguments +## +############################################################################# +############################################################################# + +my $help = 0; +my $onlyCompare = 0; +my $noCompare = 0; +my $forceLoad = 0; +my $gdb = 0; +my $noProgram = 0; +my $noReserve = 0; +my $funcpPrefix = ""; +my $funcpSuffix = ""; +my $noshowfp = 0; +my $printCycle = undef; +my $showfp = undef; +my $bluesimCmd = undef; +my $vcdStart = undef; +my $vcdCycles = 20000; +my $m5run = 0; + +my $status = GetOptions("help!" => \$help, + "gdb!" => \$gdb, + "noprogram!" => \$noProgram, + "noreserve!" => \$noReserve, + "force-load!" => \$forceLoad, + "funcp-prefix=s" => \$funcpPrefix, + "funcp-suffix=s" => \$funcpSuffix, + "noshowfp!" => \$noshowfp, + "onlycompare!" => \$onlyCompare, + "nocompare!" => \$noCompare, + "pc=s" => \$printCycle, + "showfp:s" => \$showfp, + "bluesim=s" => \$bluesimCmd, + "vcdstart=i" => \$vcdStart, + "vcdcycles=i" => \$vcdCycles, + "m5!" => \$m5run, + ); + +# Put quotation marks back on arguments that have spaces since they will be +# passed through a shell once more. +foreach my $i ( 0 .. $#ARGV ) { + if (($ARGV[$i] =~ /\s/) && ! ($ARGV[$i] =~ /['"]$/)) { + $ARGV[$i] = '"' . $ARGV[$i] . '"'; + } +} + +if ($onlyCompare != 0) { + exit(CompareOutput()); +} + +if ($m5run != 0) { + $mType = $MODEL_NONE; +} +elsif (-f "$config{modelDir}/$config{model}_hw.errinfo") { + $mType = $MODEL_FPGA; +} +elsif (-f "$config{modelDir}/$config{model}_hw.exe") { + $mType = $MODEL_BLUESIM; +} +elsif (-f "$config{modelDir}/$config{model}_hw.vexe") { + $mType = $MODEL_VSIM; +} +else { + die("Can't determine model type"); +} + +if ($help || ! $status) { + print STDERR "\nArguments:\n"; + print STDERR " [--gdb] Invokes the software side in gdb\n"; + print STDERR " [--noprogram] Skips the FPGA load and reservation steps\n"; + print STDERR " [--noreserve] Skips the FPGA reservation steps\n"; + print STDERR " [--funcp-prefix=\"\"]\n"; + print STDERR " Prepend prefix to HAsim's --funcp argument\n"; + print STDERR " [--funcp-suffix=\"\"]\n"; + print STDERR " Append suffix to HAsim's --funcp argument\n"; + print STDERR " [--onlycompare] Only compare output files (without running)\n"; + print STDERR " [--nocompare] Skip comparison of output files\n"; + print STDERR " [--m5] Run workload in m5 without HAsim\n"; + + if ($mType == $MODEL_FPGA) { + print STDERR " [--force-load] Load a bitfile to the FPGA even if it has errors\n"; + } + + if ($mType == $MODEL_BLUESIM) { + print STDERR " [--vcdstart=] Generate VCD dump for wave viewer (e.g. gtkwave)\n"; + print STDERR " [--vcdcycles=] VCD dump length (default = 20000)\n"; + } + + if ($config{isHybridModel}) { + my $cmd = "$config{modelDir}/$config{model} --help-run-append"; + system($cmd); + } + + exit(1); +} + +############################################################################# +############################################################################# +## +## Adjust model arguments +## +############################################################################# +############################################################################# + +# Show front panel? +if ($noshowfp) { + $showfp = 'none'; +} +elsif (defined($showfp)) { + # Specified on the run command line + $showfp = 'gui' if ($showfp eq ''); +} +elsif ($config{feeder} eq 'none') { + # For null feeder default to showing LEDs on stdout + $showfp = 'stdout'; +} +else { + # Other models have heartbeats + $showfp = 'none'; +} + +my $feedFlags = "${funcpPrefix} $config{feedFlags} ${funcpSuffix}"; + +if ($config{feeder} eq 'm5') { + # Tell m5 to be quiet and not to enable the remote gdb port. Under netbatch + # it appears there are sometimes attempts to connect to the port, which + # stops simulation. + $feedFlags = "--quiet --remote-gdb-port=0 ${feedFlags}"; +} + +my $cmd; + +if ($m5run == 0) { + # Normal run + $cmd = "$config{modelDir}/$config{model} --modeldir=$config{modelDir} --workload=$config{workload} --showfp=${showfp} --funcp=\"${feedFlags}\" $config{genFlags}"; + foreach my $c (@ARGV) { + $cmd .= " $c"; + } + + if (defined($printCycle)) { + $cmd .= " --pc=${printCycle}"; + } +} +else { + if ($config{feeder} ne 'm5') { + die("This workload does not use m5"); + } + + # Running inside m5 without HAsim + my $m5cmd; + if (exists($ENV{M5BIN})) { + $m5cmd = $ENV{M5BIN}; + } + else { + my $m5bin = "platform/m5/build/ALPHA_SE/m5." . ($gdb ? "debug" : "opt"); + $m5cmd = `awb-resolver ${m5bin}`; + chomp($m5cmd); + die("Failed to find $m5bin") if ($m5cmd eq ''); + } + + $cmd = "${m5cmd} ${feedFlags}"; + + # Drop --hasim-sim + $cmd =~ s/--hasim-sim //; + # Drop escaping of quotes + $cmd =~ s/\\"/"/g; + + $noProgram = 1; +} + +# +# Bluesim arguments +# + +# Generate dump.vcd for wave viewer (e.g. gtkwave)? +if (defined($vcdStart)) { + my $vcdCmd = "sim vcd on; sim step $vcdCycles; sim stop"; + if ($vcdStart > 0) { + $vcdCmd = "sim step ${vcdStart}; ${vcdCmd}"; + } + + if (defined($bluesimCmd)) { + $bluesimCmd .= " "; + } + else { + $bluesimCmd = ""; + } + $bluesimCmd .= "-c \"$vcdCmd\""; +} + +if (defined($bluesimCmd)) { + $cmd .= " --bluesim=\'$bluesimCmd\'"; +} + +# Adjust the arguments for Bluesim if it is being invoked directly +if (! $config{isHybridModel} && ($mType == $MODEL_BLUESIM)) { + $cmd =~ s/\s--/ +--/g; + + # Bluesim may expect to load a program from a well known file + unlink('program.vmh'); + link("program/$config{workload}.$config{ISA}.vmh", 'program.vmh'); +} + + +############################################################################# +############################################################################# +## +## Load the FPGA and run the model +## +############################################################################# +############################################################################# + +# +# Move old stats file so we are sure statistics come from this run +# +if (-f "$config{workload}.stats") { + rename("$config{workload}.stats", "$config{workload}.stats.old"); +} + +if ($mType == $MODEL_FPGA) { + if (! defined($printCycle)) { + # User didn't specify a cycle printing interval. Pick one more reasonable + # for HW. + #$cmd .= " --pc=10000000"; + } + + # Load FPGA + $ENV{FPGA_BIT_FILE} = "$config{modelDir}/.xilinx/$config{model}_par.bit"; + + if (! $noProgram) { + if (! $forceLoad && -s "$config{modelDir}/$config{model}_hw.errinfo") { + print STDERR "FPGA bit file has errors:\n\n"; + system("cat $config{modelDir}/$config{model}_hw.errinfo > /dev/stderr"); + print STDERR "\nUse --force-load to ignore the error.\n"; + exit(1); + } + + if (! $noReserve) { + Exec("hasim-fpga-ctrl --reserve", "Failed to reserve FPGA"); + } + + # Does a download script exist to program the FPGA? + my $needProgram = (-f "$config{modelDir}/config/$config{model}.download"); + $needProgram = 1; + + # Is the FPGA already programmed with the correct bit file? + if (exists($config{signature})) { + my $curSignature = `hasim-fpga-ctrl --getsignature`; + chomp($curSignature); + if ($curSignature eq $config{signature}) { + print "FPGA is already programmed (signature match)...\n"; + #$needProgram = 0; + } + } + + if ($needProgram) { + Exec("hasim-fpga-ctrl --program", "Failed to enter FPGA programming mode"); + + my $dir = `pwd`; + chomp($dir); + Exec("(cd $config{modelDir}; ./config/$config{model}.download ${dir}/FPGA_programming.log)", "Failed to program FPGA"); + + if (exists($config{signature})) { + Exec("hasim-fpga-ctrl --setsignature=$config{signature}", "Failed to set FPGA bit image signature"); + } + } + + Exec("hasim-fpga-ctrl --activate", "Failed to activate FPGA or driver"); + } +} + +# Run the software side or a hardware simulator +my $run_status = 0; +if ($config{isHybridModel} || ($mType != $MODEL_FPGA)) { + $cmd = $cmd." 2> proc.trace\n"; + $run_status = ExecModel($cmd); +} + +# Create a stats file for null workloads to make regression.launcher happy (HACK) +if ( $config{workload} eq "null" ) { + system("touch null.stats"); +} + +if (-f "hasim_events.out") { + system("sort hasim_events.out -o hasim_events.out.$$; mv -f hasim_events.out.$$ hasim_events.out"); +} +if (-f "$config{workload}.stats") { + system("sort $config{workload}.stats -o $config{workload}.stats.$$; mv -f $config{workload}.stats.$$ $config{workload}.stats"); +} + +if (($mType == $MODEL_FPGA) && ! $noProgram && ! $noReserve) { + Exec("hasim-fpga-ctrl --drop-reservation", "Failed to drop FPGA reservation"); +} + +if ($run_status != 0) { + exit($run_status); +} +else { + exit(CompareOutput()); +} + + +sub ErrorExit($) { + my $msg = shift; + + print STDERR "${msg}\n"; + + if (($mType == $MODEL_FPGA) && ! $noProgram && ! $noReserve) { + system("hasim-fpga-ctrl --drop-reservation"); + } + + exit(1); +} + + +## +## ExecModel -- +## This is the routine that actually invokes the model. stdout and stderr +## are logged in a file. The return value is the exit status of the model. +## +sub ExecModel($) { + my $cmd = shift; + + if ($gdb) { + ## gdb needs stdin. Just use system() and don't do logging. + system("gdb -args " . $cmd); + return 0; + } + + ## + ## Invoke the model, but log its output both to stdout and to a file. + ## Use a pty so the invoked program will use line buffering instead + ## of fully buffered writes. (Libc sets up stdout line buffered when + ## it thinks it is writing to a terminal. It uses fully buffered + ## writing to a pipe.) + ## + + my $pty = new IO::Pty; + my $slave = $pty->slave(); + + my $pid = fork(); + die "Couldn't fork: $!" unless defined $pid; + + if (! $pid) { + # Child process is the monitoring process + $pty->make_slave_controlling_terminal(); + + my $output = "$config{workload}.$config{ISA}.out"; + if(exists($config{silent})) { + $output = "/dev/null"; + } + + if (! open(LOG, ">$output")) { + print STDERR "Error opening log file $output\n"; + } + + # Unbuffered I/O loop + while (1) { + my $buf; + my $n = sysread($slave, $buf, 4096); + + last if ($n == 0); + + syswrite(STDOUT, $buf); + syswrite(LOG, $buf); + } + + close(LOG); + exit(0); + } + + # Bind new PTY to STDOUT (but save old STDOUT) + $pty->close_slave(); + open(my $oldOut, ">&", STDOUT) or die $!; + open(STDOUT, ">&", $pty) or die $!; + + # Run model + my $result = system("${cmd} 2>&1"); + + # Send ^d to end child logging thread + print "\cD"; + + # Return to normal STDOUT + close(STDOUT); + open(STDOUT, ">&", $oldOut) or die $!; + close($oldOut); + + # Compute exit status of model + my $status = 0; + if ($result == -1) { + print STDERR "Model execution failed\n"; + $status = 1; + } + elsif ($result & 127) { + print STDERR "Child died with signal " . ($result & 127) . ", " . (($result & 128) ? 'with' : 'without') . " coredump\n"; + $status = 1; + } + elsif (($result >> 8) != 0) { + $status = $result >> 8; + print "Model exited with status $status\n"; + } + + return $status; +} + + +sub Exec($$) { + my $cmd = shift; + my $errmsg = shift; + + system($cmd); + if ($? == -1) { + ErrorExit("Failed to execute $cmd: $!"); + } + elsif ($? & 127) { + ErrorExit("Child died with signal " . ($? & 127) . ", " . (($? & 128) ? 'with' : 'without') . " coredump"); + } + elsif (($? >> 8) != 0) { + ErrorExit("${errmsg}"); + } +} + + +sub CompareOutput() { + return 0 if ($noCompare != 0); + return 0 if (! exists($config{compare}) || ($config{compare} eq '')); + + # run the checker + `cd ./checker/ && make clean && make`; + `./checker/checker input.wav out_gold.wav`; + print "about to call compare_wavs\n"; + my $out=`./checker/compare_wavs/compare_wavs 10 out_gold.wav out_hw.wav`; + + if ($out !~ /fail/) { + print "*** Output comparison passed ***\n"; + system("touch $config{workload}.stats"); + return 0; + } + else { + print "*** Output comparison failed ***\n"; + return 1; + } +} + + +# +# Read the configuration file +# +sub ReadConfig($$) { + my $conf = shift; + my $required = shift; + + my $status = open(CONFIG, "< $conf"); + if (! $status) { + return if (! $required); + die("Failed to open $conf"); + } + + while () { + chomp; + my $t = $_; + $t =~ s/#.*//; + if ($t =~ /^\s*([^\s]+)\s*=\s*"(.*)"\s*$/) { + my $c = $1; + my $v = $2; + $v =~ s/^["'](.*)["']$/$1/; # Drop quotation marks + $config{$c} = $v; + } + elsif ($t =~ /^\s*([^\s]+)\s*=\s*([^\s]+)\s*$/) { + my $c = $1; + my $v = $2; + $config{$c} = $v; + } + } +} diff -r 6bd9397cd591 -r 0ede0715dbd6 pygar-benchmarks/setup/sim-benchmark-setup.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pygar-benchmarks/setup/sim-benchmark-setup.pl Tue May 11 23:23:21 2010 -0400 @@ -0,0 +1,100 @@ +#!/usr/bin/env perl + + +use File::Basename; +use Getopt::Long; +use File::Copy; + +sub Usage(); + +my $music = undef; +my $network = undef; +my $from = undef; +my $to = undef; +my $command = undef; + + +# +# Parse the command line switches +# +if (! GetOptions('music=s' => \$music, + 'network=s' => \$network, + )) { + Usage(); +} + +print "\n\n*********************\n\nRLM:\n"; +print "music is: $music\nnetwork is: $network\n"; + + +my $bmark = $ARGV[0]; +my $destination = $ARGV[1]; +my $origin = "$bmark/.."; + + + +print "Origin: $origin\n"; +print "Destination: $destination\n"; + +print "\nCopying Files:\n"; + + + +$from = $bmark."/run-sim.bmark"; +$to = $destination."/run"; +print "Copying $from to $to\n"; +copy($from,$to) or die "Copy failed: $!"; +$command = "chmod 777 $to"; +`$command`; + + + +print "\nGenerating Placeholder Voices:\n"; + +for my $num(0..11) +{ + $command = "cp $origin/music/null/null0.wav $destination/input$num.wav\n"; + print $command; + `$command`; +} + +print "\nCopying Voices\n"; +$command = "cp $origin/music/$music/*.wav $destination"; +print "$command\n"; + + +print "\nGenerating Placeholder Programs:\n"; +$command = "mkdir $destination/programs\n"; +print $command; +`$command`; + +for my $num(0..11) +{ + $command = "cp $origin/programs/identity.vmh $destination/programs/program$num.vmh\n"; + print $command; + `$command`; +} + +print "\nCreating Network:\n\n"; +print "Open $origin/networks/$network :\n"; +open (NET, "<$origin/networks/$network") or die $!; + +for () +{ + @link = eval($_); + + print "Voice $link[0] will be run through $link[1]\n"; + + $command = "cp $origin/programs/$link[1] $destination/programs/program$link[0].vmh\n"; + print $command; + `$command`; + + +} + + + + +print "\n***********************\n"; + +