changeset 67:0ede0715dbd6 pygar svn.68

[svn r68] added sensible benchmarks
author rlm
date Tue, 11 May 2010 23:23:21 -0400
parents 6bd9397cd591
children 44cc00df1168
files pygar-benchmarks/music/null/null0.wav pygar-benchmarks/networks/net0 pygar-benchmarks/networks/net1 pygar-benchmarks/programs/bit-shift.vmh pygar-benchmarks/programs/delay.vmh pygar-benchmarks/programs/identity.vmh pygar-benchmarks/programs/volume-reduce.vmh pygar-benchmarks/setup/run-sim.bmark pygar-benchmarks/setup/sim-benchmark-setup.pl
diffstat 8 files changed, 1001 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
     1.1 Binary file pygar-benchmarks/music/null/null0.wav has changed
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/pygar-benchmarks/networks/net0	Tue May 11 23:23:21 2010 -0400
     2.3 @@ -0,0 +1,13 @@
     2.4 +(0, "bit-shift.vmh")
     2.5 +(1, "volume-reduce.vmh")
     2.6 +(2, "identity.vmh")
     2.7 +(3, "delay.vmh")
     2.8 +(4, "bit-shift.vmh")
     2.9 +(5, "volume-reduce.vmh")
    2.10 +(6, "identity.vmh")
    2.11 +(7, "delay.vmh")
    2.12 +(8, "bit-shift.vmh")
    2.13 +(9, "volume-reduce.vmh")
    2.14 +(10,"identity.vmh")
    2.15 +(11,"delay.vmh")
    2.16 +(12,"bit-shift.vmh")
    2.17 \ No newline at end of file
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/pygar-benchmarks/programs/bit-shift.vmh	Tue May 11 23:23:21 2010 -0400
     3.3 @@ -0,0 +1,90 @@
     3.4 +
     3.5 +@400      // <__start>
     3.6 +3c1d0002  // 00001000 lui $sp,0x2
     3.7 +0c00042d  // 00001004 jal 10b4 <main>
     3.8 +00000000  // 00001008 nop
     3.9 +00000000  // 0000100c nop
    3.10 +
    3.11 +@404      // <verify>
    3.12 +24020001  // 00001010 li $v0,1
    3.13 +03e00008  // 00001014 jr $ra
    3.14 +
    3.15 +@406      // <finishTest>
    3.16 +4084a800  // 00001018 mtc0 $a0,$21
    3.17 +08000407  // 0000101c j 101c <finishTest+4>
    3.18 +00000000  // 00001020 nop
    3.19 +
    3.20 +@409      // <setStats>
    3.21 +40845000  // 00001024 mtc0 $a0,$10
    3.22 +03e00008  // 00001028 jr $ra
    3.23 +00000000  // 0000102c nop
    3.24 +
    3.25 +@40c      // <setComp>
    3.26 +24020001  // 00001030 li $v0,1
    3.27 +4082d000  // 00001034 mtc0 $v0,$26
    3.28 +03e00008  // 00001038 jr $ra
    3.29 +00000000  // 0000103c nop
    3.30 +
    3.31 +@410      // <getSample>
    3.32 +4003c800  // 00001040 mfc0 $v1,$25
    3.33 +24020001  // 00001044 li $v0,1
    3.34 +10620004  // 00001048 beq $v1,$v0,105c <getSample+1c>
    3.35 +4005e000  // 0000104c mfc0 $a1,$28
    3.36 +00000000  // 00001050 nop
    3.37 +ac850000  // 00001054 sw $a1,0($a0)
    3.38 +03e00008  // 00001058 jr $ra
    3.39 +ac800000  // 0000105c sw $zero,0($a0)
    3.40 +00001021  // 00001060 move $v0,$zero
    3.41 +03e00008  // 00001064 jr $ra
    3.42 +
    3.43 +@41a      // <putSample>
    3.44 +4084d800  // 00001068 mtc0 $a0,$27
    3.45 +03e00008  // 0000106c jr $ra
    3.46 +00000000  // 00001070 nop
    3.47 +
    3.48 +@41d      // <runWithStats>
    3.49 +27bdffa8  // 00001074 addiu $sp,$sp,-88
    3.50 +afbf0050  // 00001078 sw $ra,80($sp)
    3.51 +0c000409  // 0000107c jal 1024 <setStats>
    3.52 +27a40010  // 00001080 addiu $a0,$sp,16
    3.53 +0c000410  // 00001084 jal 1040 <getSample>
    3.54 +00021400  // 00001088 sll $v0,$v0,0x10
    3.55 +10400003  // 0000108c beqz $v0,109c <runWithStats+28>
    3.56 +8fa40010  // 00001090 lw $a0,16($sp)
    3.57 +0c00041a  // 00001094 jal 1068 <putSample>
    3.58 +08000420  // 00001098 j 1080 <runWithStats+c>
    3.59 +0c00040c  // 0000109c jal 1030 <setComp>
    3.60 +00002021  // 000010a0 move $a0,$zero
    3.61 +0c000409  // 000010a4 jal 1024 <setStats>
    3.62 +8fbf0050  // 000010a8 lw $ra,80($sp)
    3.63 +27bd0058  // 000010ac addiu $sp,$sp,88
    3.64 +03e00008  // 000010b0 jr $ra
    3.65 +
    3.66 +@42d      // <main>
    3.67 +27bdffe8  // 000010b4 addiu $sp,$sp,-24
    3.68 +24040001  // 000010b8 li $a0,1
    3.69 +afbf0010  // 000010bc sw $ra,16($sp)
    3.70 +0c00041d  // 000010c0 jal 1074 <runWithStats>
    3.71 +0c00040c  // 000010c4 jal 1030 <setComp>
    3.72 +8fbf0010  // 000010c8 lw $ra,16($sp)
    3.73 +27bd0018  // 000010cc addiu $sp,$sp,24
    3.74 +03e00008  // 000010d0 jr $ra
    3.75 +00000000  // 000010d4 nop
    3.76 +00000000  // 000010d8 nop
    3.77 +00000000  // 000010dc nop
    3.78 +
    3.79 +@438      // <_heapend>
    3.80 +00000000  // 000010e0 nop
    3.81 +
    3.82 +@439      // <environ>
    3.83 +00000000  // 000010e4 nop
    3.84 +00000000  // 000010e8 nop
    3.85 +00000000  // 000010ec nop
    3.86 +
    3.87 +@43c      // <.reginfo>
    3.88 +a000003c  // 000010f0 sb $zero,60($zero)
    3.89 +00000000  // 000010f4 nop
    3.90 +00000000  // 000010f8 nop
    3.91 +00000000  // 000010fc nop
    3.92 +00000000  // 00001100 nop
    3.93 +000090d0  // 00001104 0x90d0
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/pygar-benchmarks/programs/delay.vmh	Tue May 11 23:23:21 2010 -0400
     4.3 @@ -0,0 +1,90 @@
     4.4 +
     4.5 +@400      // <__start>
     4.6 +3c1d0002  // 00001000 lui $sp,0x2
     4.7 +0c00042d  // 00001004 jal 10b4 <main>
     4.8 +00000000  // 00001008 nop
     4.9 +00000000  // 0000100c nop
    4.10 +
    4.11 +@404      // <verify>
    4.12 +24020001  // 00001010 li $v0,1
    4.13 +03e00008  // 00001014 jr $ra
    4.14 +
    4.15 +@406      // <finishTest>
    4.16 +4084a800  // 00001018 mtc0 $a0,$21
    4.17 +08000407  // 0000101c j 101c <finishTest+4>
    4.18 +00000000  // 00001020 nop
    4.19 +
    4.20 +@409      // <setStats>
    4.21 +40845000  // 00001024 mtc0 $a0,$10
    4.22 +03e00008  // 00001028 jr $ra
    4.23 +00000000  // 0000102c nop
    4.24 +
    4.25 +@40c      // <setComp>
    4.26 +24020001  // 00001030 li $v0,1
    4.27 +4082d000  // 00001034 mtc0 $v0,$26
    4.28 +03e00008  // 00001038 jr $ra
    4.29 +00000000  // 0000103c nop
    4.30 +
    4.31 +@410      // <getSample>
    4.32 +4003c800  // 00001040 mfc0 $v1,$25
    4.33 +24020001  // 00001044 li $v0,1
    4.34 +10620004  // 00001048 beq $v1,$v0,105c <getSample+1c>
    4.35 +4005e000  // 0000104c mfc0 $a1,$28
    4.36 +00000000  // 00001050 nop
    4.37 +ac850000  // 00001054 sw $a1,0($a0)
    4.38 +03e00008  // 00001058 jr $ra
    4.39 +ac800000  // 0000105c sw $zero,0($a0)
    4.40 +00001021  // 00001060 move $v0,$zero
    4.41 +03e00008  // 00001064 jr $ra
    4.42 +
    4.43 +@41a      // <putSample>
    4.44 +4084d800  // 00001068 mtc0 $a0,$27
    4.45 +03e00008  // 0000106c jr $ra
    4.46 +00000000  // 00001070 nop
    4.47 +
    4.48 +@41d      // <runWithStats>
    4.49 +27bdffa8  // 00001074 addiu $sp,$sp,-88
    4.50 +afbf0050  // 00001078 sw $ra,80($sp)
    4.51 +0c000409  // 0000107c jal 1024 <setStats>
    4.52 +27a40010  // 00001080 addiu $a0,$sp,16
    4.53 +0c000410  // 00001084 jal 1040 <getSample>
    4.54 +00021400  // 00001088 sll $v0,$v0,0x10
    4.55 +10400003  // 0000108c beqz $v0,109c <runWithStats+28>
    4.56 +8fa40010  // 00001090 lw $a0,16($sp)
    4.57 +0c00041a  // 00001094 jal 1068 <putSample>
    4.58 +08000420  // 00001098 j 1080 <runWithStats+c>
    4.59 +0c00040c  // 0000109c jal 1030 <setComp>
    4.60 +00002021  // 000010a0 move $a0,$zero
    4.61 +0c000409  // 000010a4 jal 1024 <setStats>
    4.62 +8fbf0050  // 000010a8 lw $ra,80($sp)
    4.63 +27bd0058  // 000010ac addiu $sp,$sp,88
    4.64 +03e00008  // 000010b0 jr $ra
    4.65 +
    4.66 +@42d      // <main>
    4.67 +27bdffe8  // 000010b4 addiu $sp,$sp,-24
    4.68 +24040001  // 000010b8 li $a0,1
    4.69 +afbf0010  // 000010bc sw $ra,16($sp)
    4.70 +0c00041d  // 000010c0 jal 1074 <runWithStats>
    4.71 +0c00040c  // 000010c4 jal 1030 <setComp>
    4.72 +8fbf0010  // 000010c8 lw $ra,16($sp)
    4.73 +27bd0018  // 000010cc addiu $sp,$sp,24
    4.74 +03e00008  // 000010d0 jr $ra
    4.75 +00000000  // 000010d4 nop
    4.76 +00000000  // 000010d8 nop
    4.77 +00000000  // 000010dc nop
    4.78 +
    4.79 +@438      // <_heapend>
    4.80 +00000000  // 000010e0 nop
    4.81 +
    4.82 +@439      // <environ>
    4.83 +00000000  // 000010e4 nop
    4.84 +00000000  // 000010e8 nop
    4.85 +00000000  // 000010ec nop
    4.86 +
    4.87 +@43c      // <.reginfo>
    4.88 +a000003c  // 000010f0 sb $zero,60($zero)
    4.89 +00000000  // 000010f4 nop
    4.90 +00000000  // 000010f8 nop
    4.91 +00000000  // 000010fc nop
    4.92 +00000000  // 00001100 nop
    4.93 +000090d0  // 00001104 0x90d0
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/pygar-benchmarks/programs/identity.vmh	Tue May 11 23:23:21 2010 -0400
     5.3 @@ -0,0 +1,90 @@
     5.4 +
     5.5 +@400      // <__start>
     5.6 +3c1d0002  // 00001000 lui $sp,0x2
     5.7 +0c00042d  // 00001004 jal 10b4 <main>
     5.8 +00000000  // 00001008 nop
     5.9 +00000000  // 0000100c nop
    5.10 +
    5.11 +@404      // <verify>
    5.12 +24020001  // 00001010 li $v0,1
    5.13 +03e00008  // 00001014 jr $ra
    5.14 +
    5.15 +@406      // <finishTest>
    5.16 +4084a800  // 00001018 mtc0 $a0,$21
    5.17 +08000407  // 0000101c j 101c <finishTest+4>
    5.18 +00000000  // 00001020 nop
    5.19 +
    5.20 +@409      // <setStats>
    5.21 +40845000  // 00001024 mtc0 $a0,$10
    5.22 +03e00008  // 00001028 jr $ra
    5.23 +00000000  // 0000102c nop
    5.24 +
    5.25 +@40c      // <setComp>
    5.26 +24020001  // 00001030 li $v0,1
    5.27 +4082d000  // 00001034 mtc0 $v0,$26
    5.28 +03e00008  // 00001038 jr $ra
    5.29 +00000000  // 0000103c nop
    5.30 +
    5.31 +@410      // <getSample>
    5.32 +4003c800  // 00001040 mfc0 $v1,$25
    5.33 +24020001  // 00001044 li $v0,1
    5.34 +10620004  // 00001048 beq $v1,$v0,105c <getSample+1c>
    5.35 +4005e000  // 0000104c mfc0 $a1,$28
    5.36 +00000000  // 00001050 nop
    5.37 +ac850000  // 00001054 sw $a1,0($a0)
    5.38 +03e00008  // 00001058 jr $ra
    5.39 +ac800000  // 0000105c sw $zero,0($a0)
    5.40 +00001021  // 00001060 move $v0,$zero
    5.41 +03e00008  // 00001064 jr $ra
    5.42 +
    5.43 +@41a      // <putSample>
    5.44 +4084d800  // 00001068 mtc0 $a0,$27
    5.45 +03e00008  // 0000106c jr $ra
    5.46 +00000000  // 00001070 nop
    5.47 +
    5.48 +@41d      // <runWithStats>
    5.49 +27bdffa8  // 00001074 addiu $sp,$sp,-88
    5.50 +afbf0050  // 00001078 sw $ra,80($sp)
    5.51 +0c000409  // 0000107c jal 1024 <setStats>
    5.52 +27a40010  // 00001080 addiu $a0,$sp,16
    5.53 +0c000410  // 00001084 jal 1040 <getSample>
    5.54 +00021400  // 00001088 sll $v0,$v0,0x10
    5.55 +10400003  // 0000108c beqz $v0,109c <runWithStats+28>
    5.56 +8fa40010  // 00001090 lw $a0,16($sp)
    5.57 +0c00041a  // 00001094 jal 1068 <putSample>
    5.58 +08000420  // 00001098 j 1080 <runWithStats+c>
    5.59 +0c00040c  // 0000109c jal 1030 <setComp>
    5.60 +00002021  // 000010a0 move $a0,$zero
    5.61 +0c000409  // 000010a4 jal 1024 <setStats>
    5.62 +8fbf0050  // 000010a8 lw $ra,80($sp)
    5.63 +27bd0058  // 000010ac addiu $sp,$sp,88
    5.64 +03e00008  // 000010b0 jr $ra
    5.65 +
    5.66 +@42d      // <main>
    5.67 +27bdffe8  // 000010b4 addiu $sp,$sp,-24
    5.68 +24040001  // 000010b8 li $a0,1
    5.69 +afbf0010  // 000010bc sw $ra,16($sp)
    5.70 +0c00041d  // 000010c0 jal 1074 <runWithStats>
    5.71 +0c00040c  // 000010c4 jal 1030 <setComp>
    5.72 +8fbf0010  // 000010c8 lw $ra,16($sp)
    5.73 +27bd0018  // 000010cc addiu $sp,$sp,24
    5.74 +03e00008  // 000010d0 jr $ra
    5.75 +00000000  // 000010d4 nop
    5.76 +00000000  // 000010d8 nop
    5.77 +00000000  // 000010dc nop
    5.78 +
    5.79 +@438      // <_heapend>
    5.80 +00000000  // 000010e0 nop
    5.81 +
    5.82 +@439      // <environ>
    5.83 +00000000  // 000010e4 nop
    5.84 +00000000  // 000010e8 nop
    5.85 +00000000  // 000010ec nop
    5.86 +
    5.87 +@43c      // <.reginfo>
    5.88 +a000003c  // 000010f0 sb $zero,60($zero)
    5.89 +00000000  // 000010f4 nop
    5.90 +00000000  // 000010f8 nop
    5.91 +00000000  // 000010fc nop
    5.92 +00000000  // 00001100 nop
    5.93 +000090d0  // 00001104 0x90d0
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/pygar-benchmarks/programs/volume-reduce.vmh	Tue May 11 23:23:21 2010 -0400
     6.3 @@ -0,0 +1,90 @@
     6.4 +
     6.5 +@400      // <__start>
     6.6 +3c1d0002  // 00001000 lui $sp,0x2
     6.7 +0c00042d  // 00001004 jal 10b4 <main>
     6.8 +00000000  // 00001008 nop
     6.9 +00000000  // 0000100c nop
    6.10 +
    6.11 +@404      // <verify>
    6.12 +24020001  // 00001010 li $v0,1
    6.13 +03e00008  // 00001014 jr $ra
    6.14 +
    6.15 +@406      // <finishTest>
    6.16 +4084a800  // 00001018 mtc0 $a0,$21
    6.17 +08000407  // 0000101c j 101c <finishTest+4>
    6.18 +00000000  // 00001020 nop
    6.19 +
    6.20 +@409      // <setStats>
    6.21 +40845000  // 00001024 mtc0 $a0,$10
    6.22 +03e00008  // 00001028 jr $ra
    6.23 +00000000  // 0000102c nop
    6.24 +
    6.25 +@40c      // <setComp>
    6.26 +24020001  // 00001030 li $v0,1
    6.27 +4082d000  // 00001034 mtc0 $v0,$26
    6.28 +03e00008  // 00001038 jr $ra
    6.29 +00000000  // 0000103c nop
    6.30 +
    6.31 +@410      // <getSample>
    6.32 +4003c800  // 00001040 mfc0 $v1,$25
    6.33 +24020001  // 00001044 li $v0,1
    6.34 +10620004  // 00001048 beq $v1,$v0,105c <getSample+1c>
    6.35 +4005e000  // 0000104c mfc0 $a1,$28
    6.36 +00000000  // 00001050 nop
    6.37 +ac850000  // 00001054 sw $a1,0($a0)
    6.38 +03e00008  // 00001058 jr $ra
    6.39 +ac800000  // 0000105c sw $zero,0($a0)
    6.40 +00001021  // 00001060 move $v0,$zero
    6.41 +03e00008  // 00001064 jr $ra
    6.42 +
    6.43 +@41a      // <putSample>
    6.44 +4084d800  // 00001068 mtc0 $a0,$27
    6.45 +03e00008  // 0000106c jr $ra
    6.46 +00000000  // 00001070 nop
    6.47 +
    6.48 +@41d      // <runWithStats>
    6.49 +27bdffa8  // 00001074 addiu $sp,$sp,-88
    6.50 +afbf0050  // 00001078 sw $ra,80($sp)
    6.51 +0c000409  // 0000107c jal 1024 <setStats>
    6.52 +27a40010  // 00001080 addiu $a0,$sp,16
    6.53 +0c000410  // 00001084 jal 1040 <getSample>
    6.54 +00021400  // 00001088 sll $v0,$v0,0x10
    6.55 +10400003  // 0000108c beqz $v0,109c <runWithStats+28>
    6.56 +8fa40010  // 00001090 lw $a0,16($sp)
    6.57 +0c00041a  // 00001094 jal 1068 <putSample>
    6.58 +08000420  // 00001098 j 1080 <runWithStats+c>
    6.59 +0c00040c  // 0000109c jal 1030 <setComp>
    6.60 +00002021  // 000010a0 move $a0,$zero
    6.61 +0c000409  // 000010a4 jal 1024 <setStats>
    6.62 +8fbf0050  // 000010a8 lw $ra,80($sp)
    6.63 +27bd0058  // 000010ac addiu $sp,$sp,88
    6.64 +03e00008  // 000010b0 jr $ra
    6.65 +
    6.66 +@42d      // <main>
    6.67 +27bdffe8  // 000010b4 addiu $sp,$sp,-24
    6.68 +24040001  // 000010b8 li $a0,1
    6.69 +afbf0010  // 000010bc sw $ra,16($sp)
    6.70 +0c00041d  // 000010c0 jal 1074 <runWithStats>
    6.71 +0c00040c  // 000010c4 jal 1030 <setComp>
    6.72 +8fbf0010  // 000010c8 lw $ra,16($sp)
    6.73 +27bd0018  // 000010cc addiu $sp,$sp,24
    6.74 +03e00008  // 000010d0 jr $ra
    6.75 +00000000  // 000010d4 nop
    6.76 +00000000  // 000010d8 nop
    6.77 +00000000  // 000010dc nop
    6.78 +
    6.79 +@438      // <_heapend>
    6.80 +00000000  // 000010e0 nop
    6.81 +
    6.82 +@439      // <environ>
    6.83 +00000000  // 000010e4 nop
    6.84 +00000000  // 000010e8 nop
    6.85 +00000000  // 000010ec nop
    6.86 +
    6.87 +@43c      // <.reginfo>
    6.88 +a000003c  // 000010f0 sb $zero,60($zero)
    6.89 +00000000  // 000010f4 nop
    6.90 +00000000  // 000010f8 nop
    6.91 +00000000  // 000010fc nop
    6.92 +00000000  // 00001100 nop
    6.93 +000090d0  // 00001104 0x90d0
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/pygar-benchmarks/setup/run-sim.bmark	Tue May 11 23:23:21 2010 -0400
     7.3 @@ -0,0 +1,528 @@
     7.4 +#!/usr/bin/env perl
     7.5 +# -*- perl -*-
     7.6 +
     7.7 +use strict;
     7.8 +use warnings;
     7.9 +use Getopt::Long qw(:config no_auto_abbrev no_ignore_case pass_through);
    7.10 +use IO::Pty;
    7.11 +
    7.12 +#
    7.13 +# Turn on warnings
    7.14 +#
    7.15 +$^W = 1;
    7.16 +
    7.17 +##
    7.18 +## Benchmark run script
    7.19 +##
    7.20 +
    7.21 +sub ExecModel($);
    7.22 +sub Exec($$);
    7.23 +sub CompareOutput();
    7.24 +sub ReadConfig($$);
    7.25 +
    7.26 +
    7.27 +#############################################################################
    7.28 +#############################################################################
    7.29 +##
    7.30 +## Start by figuring out the model location and type.
    7.31 +##
    7.32 +#############################################################################
    7.33 +#############################################################################
    7.34 +
    7.35 +my %config;
    7.36 +
    7.37 +ReadConfig("config/env.sh", 1);
    7.38 +ReadConfig("$config{modelDir}/config/env.sh", 1);
    7.39 +ReadConfig("$config{modelDir}/config/signature.sh", 0);
    7.40 +
    7.41 +##
    7.42 +## Pseudo-enumeration of possible model types
    7.43 +##
    7.44 +my $MODEL_NONE = 0;
    7.45 +my $MODEL_FPGA = 1;                     # Model runs on FPGA hardware
    7.46 +my $MODEL_BLUESIM = 2;                  # Bluesim
    7.47 +my $MODEL_VSIM = 3;                     # Verilog simulator
    7.48 +
    7.49 +my $mType = $MODEL_NONE;
    7.50 +
    7.51 +
    7.52 +#############################################################################
    7.53 +#############################################################################
    7.54 +##
    7.55 +## Process command line arguments
    7.56 +##
    7.57 +#############################################################################
    7.58 +#############################################################################
    7.59 +
    7.60 +my $help = 0;
    7.61 +my $onlyCompare = 0;
    7.62 +my $noCompare = 0;
    7.63 +my $forceLoad = 0;
    7.64 +my $gdb = 0;
    7.65 +my $noProgram = 0;
    7.66 +my $noReserve = 0;
    7.67 +my $funcpPrefix = "";
    7.68 +my $funcpSuffix = "";
    7.69 +my $noshowfp = 0;
    7.70 +my $printCycle = undef;
    7.71 +my $showfp = undef;
    7.72 +my $bluesimCmd = undef;
    7.73 +my $vcdStart = undef;
    7.74 +my $vcdCycles = 20000;
    7.75 +my $m5run = 0;
    7.76 +
    7.77 +my $status = GetOptions("help!" => \$help,
    7.78 +                        "gdb!" => \$gdb,
    7.79 +                        "noprogram!" => \$noProgram,
    7.80 +                        "noreserve!" => \$noReserve,
    7.81 +                        "force-load!" => \$forceLoad,
    7.82 +                        "funcp-prefix=s" => \$funcpPrefix,
    7.83 +                        "funcp-suffix=s" => \$funcpSuffix,
    7.84 +                        "noshowfp!" => \$noshowfp,
    7.85 +                        "onlycompare!" => \$onlyCompare,
    7.86 +                        "nocompare!" => \$noCompare,
    7.87 +                        "pc=s" => \$printCycle,
    7.88 +                        "showfp:s" => \$showfp,
    7.89 +                        "bluesim=s" => \$bluesimCmd,
    7.90 +                        "vcdstart=i" => \$vcdStart,
    7.91 +                        "vcdcycles=i" => \$vcdCycles,
    7.92 +                        "m5!" => \$m5run,
    7.93 +                       );
    7.94 +
    7.95 +# Put quotation marks back on arguments that have spaces since they will be
    7.96 +# passed through a shell once more.
    7.97 +foreach my $i ( 0 .. $#ARGV ) {
    7.98 +    if (($ARGV[$i] =~ /\s/) && ! ($ARGV[$i] =~ /['"]$/)) {
    7.99 +        $ARGV[$i] = '"' . $ARGV[$i] . '"';
   7.100 +    }
   7.101 +}
   7.102 +
   7.103 +if ($onlyCompare != 0) {
   7.104 +    exit(CompareOutput());
   7.105 +}
   7.106 +
   7.107 +if ($m5run != 0) {
   7.108 +    $mType = $MODEL_NONE;
   7.109 +}
   7.110 +elsif (-f "$config{modelDir}/$config{model}_hw.errinfo") {
   7.111 +    $mType = $MODEL_FPGA;
   7.112 +}
   7.113 +elsif (-f "$config{modelDir}/$config{model}_hw.exe") {
   7.114 +    $mType = $MODEL_BLUESIM;
   7.115 +}
   7.116 +elsif (-f "$config{modelDir}/$config{model}_hw.vexe") {
   7.117 +    $mType = $MODEL_VSIM;
   7.118 +}
   7.119 +else {
   7.120 +    die("Can't determine model type");
   7.121 +}
   7.122 +
   7.123 +if ($help || ! $status) {
   7.124 +    print STDERR "\nArguments:\n";
   7.125 +    print STDERR "   [--gdb]                 Invokes the software side in gdb\n";
   7.126 +    print STDERR "   [--noprogram]           Skips the FPGA load and reservation steps\n";
   7.127 +    print STDERR "   [--noreserve]           Skips the FPGA reservation steps\n";
   7.128 +    print STDERR "   [--funcp-prefix=\"<prefix>\"]\n";
   7.129 +    print STDERR "                           Prepend prefix to HAsim's --funcp argument\n";
   7.130 +    print STDERR "   [--funcp-suffix=\"<suffix>\"]\n";
   7.131 +    print STDERR "                           Append suffix to HAsim's --funcp argument\n";
   7.132 +    print STDERR "   [--onlycompare]         Only compare output files (without running)\n";
   7.133 +    print STDERR "   [--nocompare]           Skip comparison of output files\n";
   7.134 +    print STDERR "   [--m5]                  Run workload in m5 without HAsim\n";
   7.135 +
   7.136 +    if ($mType == $MODEL_FPGA) {
   7.137 +        print STDERR "   [--force-load]          Load a bitfile to the FPGA even if it has errors\n";
   7.138 +    }
   7.139 +
   7.140 +    if ($mType == $MODEL_BLUESIM) {
   7.141 +        print STDERR "   [--vcdstart=<cycle>]    Generate VCD dump for wave viewer (e.g. gtkwave)\n";
   7.142 +        print STDERR "   [--vcdcycles=<cycles>]  VCD dump length (default = 20000)\n";
   7.143 +    }
   7.144 +
   7.145 +    if ($config{isHybridModel}) {
   7.146 +        my $cmd = "$config{modelDir}/$config{model} --help-run-append";
   7.147 +        system($cmd);
   7.148 +    }
   7.149 +
   7.150 +    exit(1);
   7.151 +}
   7.152 +
   7.153 +#############################################################################
   7.154 +#############################################################################
   7.155 +##
   7.156 +## Adjust model arguments
   7.157 +##
   7.158 +#############################################################################
   7.159 +#############################################################################
   7.160 +
   7.161 +# Show front panel?
   7.162 +if ($noshowfp) {
   7.163 +    $showfp = 'none';
   7.164 +}
   7.165 +elsif (defined($showfp)) {
   7.166 +    # Specified on the run command line
   7.167 +    $showfp = 'gui' if ($showfp eq '');
   7.168 +}
   7.169 +elsif ($config{feeder} eq 'none') {
   7.170 +    # For null feeder default to showing LEDs on stdout
   7.171 +    $showfp = 'stdout';
   7.172 +}
   7.173 +else {
   7.174 +    # Other models have heartbeats
   7.175 +    $showfp = 'none';
   7.176 +}
   7.177 +
   7.178 +my $feedFlags = "${funcpPrefix} $config{feedFlags} ${funcpSuffix}";
   7.179 +
   7.180 +if ($config{feeder} eq 'm5') {
   7.181 +    # Tell m5 to be quiet and not to enable the remote gdb port.  Under netbatch
   7.182 +    # it appears there are sometimes attempts to connect to the port, which
   7.183 +    # stops simulation.
   7.184 +    $feedFlags = "--quiet --remote-gdb-port=0 ${feedFlags}";
   7.185 +}
   7.186 +
   7.187 +my $cmd;
   7.188 +
   7.189 +if ($m5run == 0) {
   7.190 +    # Normal run
   7.191 +    $cmd = "$config{modelDir}/$config{model} --modeldir=$config{modelDir} --workload=$config{workload} --showfp=${showfp} --funcp=\"${feedFlags}\" $config{genFlags}";
   7.192 +    foreach my $c (@ARGV) {
   7.193 +        $cmd .= " $c";
   7.194 +    }
   7.195 +
   7.196 +    if (defined($printCycle)) {
   7.197 +        $cmd .= " --pc=${printCycle}";
   7.198 +    }
   7.199 +}
   7.200 +else {
   7.201 +    if ($config{feeder} ne 'm5') {
   7.202 +        die("This workload does not use m5");
   7.203 +    }
   7.204 +
   7.205 +    # Running inside m5 without HAsim
   7.206 +    my $m5cmd;
   7.207 +    if (exists($ENV{M5BIN})) {
   7.208 +        $m5cmd = $ENV{M5BIN};
   7.209 +    }
   7.210 +    else {
   7.211 +        my $m5bin = "platform/m5/build/ALPHA_SE/m5." . ($gdb ? "debug" : "opt");
   7.212 +        $m5cmd = `awb-resolver ${m5bin}`;
   7.213 +        chomp($m5cmd);
   7.214 +        die("Failed to find $m5bin") if ($m5cmd eq '');
   7.215 +    }
   7.216 +
   7.217 +    $cmd = "${m5cmd} ${feedFlags}";
   7.218 +
   7.219 +    # Drop --hasim-sim
   7.220 +    $cmd =~ s/--hasim-sim //;
   7.221 +    # Drop escaping of quotes
   7.222 +    $cmd =~ s/\\"/"/g;
   7.223 +
   7.224 +    $noProgram = 1;
   7.225 +}
   7.226 +
   7.227 +#
   7.228 +# Bluesim arguments
   7.229 +#
   7.230 +
   7.231 +# Generate dump.vcd for wave viewer (e.g. gtkwave)?
   7.232 +if (defined($vcdStart)) {
   7.233 +    my $vcdCmd = "sim vcd on; sim step $vcdCycles; sim stop";
   7.234 +    if ($vcdStart > 0) {
   7.235 +        $vcdCmd = "sim step ${vcdStart}; ${vcdCmd}";
   7.236 +    }
   7.237 +
   7.238 +    if (defined($bluesimCmd)) {
   7.239 +        $bluesimCmd .= " ";
   7.240 +    }
   7.241 +    else {
   7.242 +        $bluesimCmd = "";
   7.243 +    }
   7.244 +    $bluesimCmd .= "-c \"$vcdCmd\"";
   7.245 +}
   7.246 +
   7.247 +if (defined($bluesimCmd)) {
   7.248 +    $cmd .= " --bluesim=\'$bluesimCmd\'";
   7.249 +}
   7.250 +
   7.251 +# Adjust the arguments for Bluesim if it is being invoked directly
   7.252 +if (! $config{isHybridModel} && ($mType == $MODEL_BLUESIM)) {
   7.253 +    $cmd =~ s/\s--/ +--/g;
   7.254 +
   7.255 +    # Bluesim may expect to load a program from a well known file
   7.256 +    unlink('program.vmh');
   7.257 +    link("program/$config{workload}.$config{ISA}.vmh", 'program.vmh');
   7.258 +}
   7.259 +
   7.260 +
   7.261 +#############################################################################
   7.262 +#############################################################################
   7.263 +##
   7.264 +## Load the FPGA and run the model
   7.265 +##
   7.266 +#############################################################################
   7.267 +#############################################################################
   7.268 +
   7.269 +#
   7.270 +# Move old stats file so we are sure statistics come from this run
   7.271 +#
   7.272 +if (-f "$config{workload}.stats") {
   7.273 +    rename("$config{workload}.stats", "$config{workload}.stats.old");
   7.274 +}
   7.275 +
   7.276 +if ($mType == $MODEL_FPGA) {
   7.277 +    if (! defined($printCycle)) {
   7.278 +        # User didn't specify a cycle printing interval.  Pick one more reasonable
   7.279 +        # for HW.
   7.280 +        #$cmd .= " --pc=10000000";
   7.281 +    }
   7.282 +
   7.283 +    # Load FPGA
   7.284 +    $ENV{FPGA_BIT_FILE} = "$config{modelDir}/.xilinx/$config{model}_par.bit";
   7.285 +
   7.286 +    if (! $noProgram) {
   7.287 +        if (! $forceLoad && -s "$config{modelDir}/$config{model}_hw.errinfo") {
   7.288 +            print STDERR "FPGA bit file has errors:\n\n";
   7.289 +            system("cat $config{modelDir}/$config{model}_hw.errinfo > /dev/stderr");
   7.290 +            print STDERR "\nUse --force-load to ignore the error.\n";
   7.291 +            exit(1);
   7.292 +        }
   7.293 +
   7.294 +        if (! $noReserve) {
   7.295 +            Exec("hasim-fpga-ctrl --reserve", "Failed to reserve FPGA");
   7.296 +        }
   7.297 +
   7.298 +        # Does a download script exist to program the FPGA?
   7.299 +        my $needProgram = (-f "$config{modelDir}/config/$config{model}.download");
   7.300 +        $needProgram = 1;
   7.301 +
   7.302 +        # Is the FPGA already programmed with the correct bit file?
   7.303 +        if (exists($config{signature})) {
   7.304 +            my $curSignature = `hasim-fpga-ctrl --getsignature`;
   7.305 +            chomp($curSignature);
   7.306 +            if ($curSignature eq $config{signature}) {
   7.307 +                print "FPGA is already programmed (signature match)...\n";
   7.308 +                #$needProgram = 0;
   7.309 +            }
   7.310 +        }
   7.311 +
   7.312 +        if ($needProgram) {
   7.313 +            Exec("hasim-fpga-ctrl --program", "Failed to enter FPGA programming mode");
   7.314 +
   7.315 +            my $dir = `pwd`;
   7.316 +            chomp($dir);
   7.317 +            Exec("(cd $config{modelDir}; ./config/$config{model}.download ${dir}/FPGA_programming.log)", "Failed to program FPGA");
   7.318 +
   7.319 +            if (exists($config{signature})) {
   7.320 +                Exec("hasim-fpga-ctrl --setsignature=$config{signature}", "Failed to set FPGA bit image signature");
   7.321 +            }
   7.322 +        }
   7.323 +
   7.324 +        Exec("hasim-fpga-ctrl --activate", "Failed to activate FPGA or driver");
   7.325 +    }
   7.326 +}
   7.327 +
   7.328 +# Run the software side or a hardware simulator
   7.329 +my $run_status = 0;
   7.330 +if ($config{isHybridModel} || ($mType != $MODEL_FPGA)) {
   7.331 +    $cmd = $cmd." 2> proc.trace\n";
   7.332 +    $run_status = ExecModel($cmd);
   7.333 +}
   7.334 +
   7.335 +# Create a stats file for null workloads to make regression.launcher happy (HACK)
   7.336 +if ( $config{workload} eq "null" ) {
   7.337 +  system("touch null.stats");
   7.338 +}
   7.339 +
   7.340 +if (-f "hasim_events.out") {
   7.341 +    system("sort hasim_events.out -o hasim_events.out.$$; mv -f hasim_events.out.$$ hasim_events.out");
   7.342 +}
   7.343 +if (-f "$config{workload}.stats") {
   7.344 +    system("sort $config{workload}.stats -o $config{workload}.stats.$$; mv -f $config{workload}.stats.$$ $config{workload}.stats");
   7.345 +}
   7.346 +
   7.347 +if (($mType == $MODEL_FPGA) && ! $noProgram && ! $noReserve) {
   7.348 +    Exec("hasim-fpga-ctrl --drop-reservation", "Failed to drop FPGA reservation");
   7.349 +}
   7.350 +
   7.351 +if ($run_status != 0) {
   7.352 +    exit($run_status);
   7.353 +}
   7.354 +else {
   7.355 +    exit(CompareOutput());
   7.356 +}
   7.357 +
   7.358 +
   7.359 +sub ErrorExit($) {
   7.360 +    my $msg = shift;
   7.361 +
   7.362 +    print STDERR "${msg}\n";
   7.363 +
   7.364 +    if (($mType == $MODEL_FPGA) && ! $noProgram && ! $noReserve) {
   7.365 +        system("hasim-fpga-ctrl --drop-reservation");
   7.366 +    }
   7.367 +
   7.368 +    exit(1);
   7.369 +}
   7.370 +
   7.371 +
   7.372 +##
   7.373 +## ExecModel --
   7.374 +##   This is the routine that actually invokes the model.  stdout and stderr
   7.375 +##   are logged in a file.  The return value is the exit status of the model.
   7.376 +##
   7.377 +sub ExecModel($) {
   7.378 +    my $cmd = shift;
   7.379 +
   7.380 +    if ($gdb) {
   7.381 +        ## gdb needs stdin.  Just use system() and don't do logging.
   7.382 +        system("gdb -args " . $cmd);
   7.383 +        return 0;
   7.384 +    }
   7.385 +
   7.386 +    ##
   7.387 +    ## Invoke the model, but log its output both to stdout and to a file.
   7.388 +    ## Use a pty so the invoked program will use line buffering instead
   7.389 +    ## of fully buffered writes.  (Libc sets up stdout line buffered when
   7.390 +    ## it thinks it is writing to a terminal.  It uses fully buffered
   7.391 +    ## writing to a pipe.)
   7.392 +    ##
   7.393 +
   7.394 +    my $pty = new IO::Pty;
   7.395 +    my $slave = $pty->slave();
   7.396 +
   7.397 +    my $pid = fork();
   7.398 +    die "Couldn't fork: $!" unless defined $pid;
   7.399 +
   7.400 +    if (! $pid) {
   7.401 +        # Child process is the monitoring process
   7.402 +        $pty->make_slave_controlling_terminal();
   7.403 +
   7.404 +        my $output = "$config{workload}.$config{ISA}.out";  
   7.405 +        if(exists($config{silent})) {
   7.406 +	    $output = "/dev/null";
   7.407 +	}
   7.408 +
   7.409 +        if (! open(LOG, ">$output")) {
   7.410 +            print STDERR "Error opening log file $output\n";
   7.411 +        }
   7.412 +
   7.413 +        # Unbuffered I/O loop
   7.414 +        while (1) {
   7.415 +            my $buf;
   7.416 +            my $n = sysread($slave, $buf, 4096);
   7.417 +
   7.418 +            last if ($n == 0);
   7.419 +
   7.420 +            syswrite(STDOUT, $buf);
   7.421 +            syswrite(LOG, $buf);
   7.422 +        }
   7.423 +
   7.424 +        close(LOG);
   7.425 +        exit(0);
   7.426 +    }
   7.427 +
   7.428 +    # Bind new PTY to STDOUT (but save old STDOUT)
   7.429 +    $pty->close_slave();
   7.430 +    open(my $oldOut, ">&", STDOUT) or die $!;
   7.431 +    open(STDOUT, ">&", $pty) or die $!;
   7.432 +
   7.433 +    # Run model
   7.434 +    my $result = system("${cmd} 2>&1");
   7.435 +
   7.436 +    # Send ^d to end child logging thread
   7.437 +    print "\cD";
   7.438 +
   7.439 +    # Return to normal STDOUT
   7.440 +    close(STDOUT);
   7.441 +    open(STDOUT, ">&", $oldOut) or die $!;
   7.442 +    close($oldOut);
   7.443 +
   7.444 +    # Compute exit status of model
   7.445 +    my $status = 0;
   7.446 +    if ($result == -1) {
   7.447 +        print STDERR "Model execution failed\n";
   7.448 +        $status = 1;
   7.449 +    }
   7.450 +    elsif ($result & 127) {
   7.451 +        print STDERR "Child died with signal " . ($result & 127) . ", " . (($result & 128) ? 'with' : 'without') . " coredump\n";
   7.452 +        $status = 1;
   7.453 +    }
   7.454 +    elsif (($result >> 8) != 0) {
   7.455 +        $status = $result >> 8;
   7.456 +        print "Model exited with status $status\n";
   7.457 +    }
   7.458 +
   7.459 +    return $status;
   7.460 +}
   7.461 +
   7.462 +
   7.463 +sub Exec($$) {
   7.464 +    my $cmd = shift;
   7.465 +    my $errmsg = shift;
   7.466 +
   7.467 +    system($cmd);
   7.468 +    if ($? == -1) {
   7.469 +        ErrorExit("Failed to execute $cmd: $!");
   7.470 +    }
   7.471 +    elsif ($? & 127) {
   7.472 +        ErrorExit("Child died with signal " . ($? & 127) . ", " . (($? & 128) ? 'with' : 'without') . " coredump");
   7.473 +    }
   7.474 +    elsif (($? >> 8) != 0) {
   7.475 +        ErrorExit("${errmsg}");
   7.476 +    }
   7.477 +}
   7.478 +
   7.479 +
   7.480 +sub CompareOutput() {
   7.481 +    return 0 if ($noCompare != 0);
   7.482 +    return 0 if (! exists($config{compare}) || ($config{compare} eq ''));
   7.483 +
   7.484 +    # run the checker 
   7.485 +    `cd ./checker/ && make clean && make`;
   7.486 +    `./checker/checker input.wav out_gold.wav`;
   7.487 +    print "about to call compare_wavs\n";
   7.488 +    my $out=`./checker/compare_wavs/compare_wavs 10 out_gold.wav out_hw.wav`;
   7.489 +   
   7.490 +    if ($out !~ /fail/) {
   7.491 +        print "*** Output comparison passed ***\n";
   7.492 +        system("touch $config{workload}.stats");
   7.493 +        return 0;
   7.494 +    }
   7.495 +    else {
   7.496 +        print "*** Output comparison failed ***\n";
   7.497 +        return 1;
   7.498 +    }
   7.499 +}
   7.500 +
   7.501 +
   7.502 +#
   7.503 +# Read the configuration file
   7.504 +#
   7.505 +sub ReadConfig($$) {
   7.506 +    my $conf = shift;
   7.507 +    my $required = shift;
   7.508 +
   7.509 +    my $status = open(CONFIG, "< $conf");
   7.510 +    if (! $status) {
   7.511 +        return if (! $required);
   7.512 +        die("Failed to open $conf");
   7.513 +    }
   7.514 +
   7.515 +    while (<CONFIG>) {
   7.516 +        chomp;
   7.517 +        my $t = $_;
   7.518 +        $t =~ s/#.*//;
   7.519 +        if ($t =~ /^\s*([^\s]+)\s*=\s*"(.*)"\s*$/) {
   7.520 +            my $c = $1;
   7.521 +            my $v = $2;
   7.522 +            $v =~ s/^["'](.*)["']$/$1/;         # Drop quotation marks
   7.523 +            $config{$c} = $v;
   7.524 +        }
   7.525 +        elsif ($t =~ /^\s*([^\s]+)\s*=\s*([^\s]+)\s*$/) {
   7.526 +            my $c = $1;
   7.527 +            my $v = $2;
   7.528 +            $config{$c} = $v;
   7.529 +        }
   7.530 +    }
   7.531 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/pygar-benchmarks/setup/sim-benchmark-setup.pl	Tue May 11 23:23:21 2010 -0400
     8.3 @@ -0,0 +1,100 @@
     8.4 +#!/usr/bin/env perl
     8.5 +
     8.6 +
     8.7 +use File::Basename;
     8.8 +use Getopt::Long;
     8.9 +use File::Copy;
    8.10 +
    8.11 +sub Usage();
    8.12 +
    8.13 +my $music = undef;
    8.14 +my $network = undef;
    8.15 +my $from = undef;
    8.16 +my $to = undef;
    8.17 +my $command = undef;
    8.18 +
    8.19 + 
    8.20 +#
    8.21 +# Parse the command line switches
    8.22 +#
    8.23 +if (! GetOptions('music=s' => \$music,
    8.24 +                 'network=s' => \$network,
    8.25 +    )) {
    8.26 +    Usage();
    8.27 +}
    8.28 +
    8.29 +print "\n\n*********************\n\nRLM:\n";
    8.30 +print "music is: $music\nnetwork is: $network\n";
    8.31 +
    8.32 +
    8.33 +my $bmark = $ARGV[0];
    8.34 +my $destination = $ARGV[1];
    8.35 +my $origin = "$bmark/..";
    8.36 +
    8.37 +
    8.38 +
    8.39 +print "Origin: $origin\n";
    8.40 +print "Destination: $destination\n";
    8.41 +
    8.42 +print "\nCopying Files:\n";
    8.43 +
    8.44 +
    8.45 +
    8.46 +$from = $bmark."/run-sim.bmark";
    8.47 +$to = $destination."/run";
    8.48 +print "Copying $from to $to\n";
    8.49 +copy($from,$to) or die "Copy failed: $!";
    8.50 +$command = "chmod 777 $to";
    8.51 +`$command`;
    8.52 +
    8.53 +
    8.54 +
    8.55 +print "\nGenerating Placeholder Voices:\n";
    8.56 +
    8.57 +for my $num(0..11)
    8.58 +{
    8.59 +    $command = "cp $origin/music/null/null0.wav  $destination/input$num.wav\n";
    8.60 +    print $command;
    8.61 +    `$command`;
    8.62 +}
    8.63 +
    8.64 +print "\nCopying Voices\n";
    8.65 +$command = "cp $origin/music/$music/*.wav  $destination";
    8.66 +print "$command\n";
    8.67 +
    8.68 +
    8.69 +print "\nGenerating Placeholder Programs:\n";
    8.70 +$command = "mkdir  $destination/programs\n";
    8.71 +print $command;
    8.72 +`$command`;
    8.73 +
    8.74 +for my $num(0..11)
    8.75 +{
    8.76 +    $command = "cp $origin/programs/identity.vmh  $destination/programs/program$num.vmh\n";
    8.77 +    print $command;
    8.78 +    `$command`;
    8.79 +}
    8.80 +
    8.81 +print "\nCreating Network:\n\n";
    8.82 +print "Open $origin/networks/$network :\n";
    8.83 +open (NET, "<$origin/networks/$network") or die $!;
    8.84 +
    8.85 +for (<NET>)
    8.86 +{
    8.87 +    @link  = eval($_);
    8.88 +        
    8.89 +    print "Voice $link[0] will be run through $link[1]\n";
    8.90 +
    8.91 +    $command = "cp $origin/programs/$link[1]  $destination/programs/program$link[0].vmh\n";
    8.92 +    print $command;
    8.93 +    `$command`;
    8.94 +    
    8.95 +
    8.96 +}
    8.97 +
    8.98 +
    8.99 +
   8.100 +
   8.101 +print "\n***********************\n";
   8.102 +
   8.103 +