Skip to content

Commit

Permalink
fix trip counts for large benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
sgpthomas committed Aug 16, 2020
1 parent 91e0b3f commit bf19894
Show file tree
Hide file tree
Showing 21 changed files with 234 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
define(N, 64)
define(N_bw, ubit<7>)
define(SQRT_HEADER, "math.h") // "fxp_sqrt.h"
define(WHILE0, min=0 max=63 avg=32)
define(WHILE0_1, min=0 max=62 avg=21)
define(WHILE1, min=0 max=63 avg=32)

// END macro definitions
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@

define(N, 64)
define(N_bw, ubit<7>)
define(WHILE0, min=1 max=63 avg=32)
define(WHILE1, min=1 max=63 avg=32)
define(WHILE2, min=1 max=63 avg=32)

// END macro definitions
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ define(N, 80)
define(M_bw, ubit<7>)
define(N_bw, ubit<7>)
define(SQRT_HEADER, "math.h") // "fxp_sqrt.h"
define(WHILE0, min=0 max=79 avg=40)

// END macro definitions
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@

define(N, 64)
define(N_bw, ubit<7>)
define(WHILE0, min=0 max=63 avg=32)
define(WHILE0_1, min=0 max=62 avg=21)
define(WHILE1, min=1 max=64 avg=32)
define(WHILE1_1, min=0 max=63 avg=21)

// END macro definition
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ define(M, 60)
define(N, 80)
define(M_bw, ubit<7>)
define(N_bw, ubit<7>)
define(WHILE0, min=0 max=59 avg=30)

// END macro definition
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ define(M, 60)
define(N, 80)
define(M_bw, ubit<6>)
define(N_bw, ubit<7>)
define(WHILE0, min=1 max=80 avg=40)
define(WHILE1, min=1 max=80 avg=40)

// END macro definition
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ define(M, 60)
define(N, 80)
define(M_bw, ubit<6>)
define(N_bw, ubit<7>)
define(WHILE0, min=1 max=80 avg=40)
define(WHILE1, min=1 max=80 avg=40)

// END macro definitions
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

define(N, 64)
define(N_bw, ubit<7>)
define(WHILE0, min=0 max=63 avg=32)

// END macro definitions
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ define(M, 60)
define(N, 80)
define(M_bw, ubit<6>)
define(N_bw, ubit<7>)
define(WHILE0, min=0 max=59 avg=30)
define(WHILE1, min=0 max=59 avg=30)
define(WHILE2, min=0 max=59 avg=30)

// END macro definition
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
define(N, 8)
define(N_bw, ubit<4>)
define(SQRT_HEADER, "math.h") // "fxp_sqrt.h"
define(WHILE0, min=0 max=7 avg=4)
define(WHILE0_1, min=0 max=6 avg=2)
define(WHILE1, min=0 max=7 avg=4)

// END macro definitions
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@

define(N, 8)
define(N_bw, ubit<4>)
define(WHILE0, min=1 max=7 avg=4)
define(WHILE1, min=1 max=7 avg=4)
define(WHILE2, min=1 max=7 avg=4)

// END macro definitions
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ define(N, 12)
define(M_bw, ubit<4>)
define(N_bw, ubit<4>)
define(SQRT_HEADER, "math.h") // "fxp_sqrt.h"
define(WHILE0, min=0 max=11 avg=6)

// END macro definitions
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@

define(N, 8)
define(N_bw, ubit<4>)
define(WHILE0, min=0 max=7 avg=4)
define(WHILE0_1, min=0 max=6 avg=2)
define(WHILE1, min=1 max=8 avg=4)
define(WHILE1_1, min=0 max=7 avg=2)

// END macro definition
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ define(M, 8)
define(N, 12)
define(M_bw, ubit<4>)
define(N_bw, ubit<4>)
define(WHILE0, min=0 max=7 avg=4)

// END macro definition
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ define(M, 8)
define(N, 12)
define(M_bw, ubit<4>)
define(N_bw, ubit<4>)
define(WHILE0, min=1 max=12 avg=6)
define(WHILE1, min=1 max=12 avg=6)

// END macro definition
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ define(M, 8)
define(N, 12)
define(M_bw, ubit<4>)
define(N_bw, ubit<4>)
define(WHILE0, min=1 max=8 avg=4)
define(WHILE1, min=1 max=8 avg=4)

// END macro definitions
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

define(N, 8)
define(N_bw, ubit<4>)
define(WHILE0, min=0 max=7 avg=4)

// END macro definitions
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ define(M, 8)
define(N, 12)
define(M_bw, ubit<4>)
define(N_bw, ubit<4>)
define(WHILE0, min=0 max=7 avg=4)

// END macro definition
192 changes: 192 additions & 0 deletions benchmarks/templates/tripcount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
#!/usr/bin/env python3
import sys
import json
from pathlib import Path

class TripCount():
def __init__(self, name):
self.name = name
self.current = 0
self.account = []

def incr(self):
self.current += 1

def reset(self):
self.account.append(self.current)
self.current = 0

def output(self):
mx = max(self.account)
mn = min(self.account)
avg = round(sum(self.account) / len(self.account))
print(f'{self.name}:')
print(f'\tdecor "#pragma HLS loop_tripcount min={mn} max={mx} avg={avg}"')
# print(f'\t{self.account}')


if __name__ == "__main__":
benchmark = sys.argv[1]
size = sys.argv[2]

# read json file
template = json.load(Path(f"{size}_polybench/linear-algebra-{benchmark}.template").open())
t = template['key']

if benchmark == "gramschmidt":
while1 = TripCount('while1')
for k in range(t['N']):
for i in range(t['M']):
pass
for i in range(t['M']):
pass
j = k + 1
while (j < t['N']):
while1.incr()
for i in range(t['M']):
pass
for i in range(t['M']):
pass
j += 1
while1.reset()
while1.output()

elif benchmark == "cholesky":
while1 = TripCount('while1')
while2 = TripCount('while2')
while3 = TripCount('while3')
for i in range(t['N']):
j = 0
while (j < i):
while1.incr()
k = 0
while (k < j):
while2.incr()
k += 1
while2.reset()
j += 1
while1.reset()
k = 0
while (k < i):
while3.incr()
k += 1
while3.reset()
while1.output()
while2.output()
while3.output()

elif benchmark == "durbin":
while1 = TripCount('while')
for k in range(1, t['N']):
i = 0
while (i < k):
while1.incr()
i += 1
while1.reset()
while1.output()

elif benchmark == "trisolv":
while1 = TripCount('while1')
for i in range(t['N']):
j = 0
while (j < i):
while1.incr()
j += 1
while1.reset()
while1.output()

elif benchmark == "syrk":
while1 = TripCount('while1')
while2 = TripCount('while2')
for i in range(t['N']):
j = 0
while (j <= i):
while1.incr()
j += 1
while1.reset()
j2 = 0
while (j2 <= i):
while2.incr()
for k in range(t['M']):
pass
j2 += 1
while2.reset()
while1.output()
while2.output()

elif benchmark == "syr2k":
while1 = TripCount('while1')
while2 = TripCount('while2')
for i in range(t['N']):
j = 0
while (j <= i):
while1.incr()
j += 1
while1.reset()
j2 = 0
while (j2 <= i):
while2.incr()
for k in range(t['M']):
pass
j2 += 1
while2.reset()
while1.output()
while2.output()

elif benchmark == "trmm":
while1 = TripCount('while')
for i in range(t['M']):
for j in range(t['N']):
k = i + 1
while (k < t['M']):
while1.incr()
k += 1
while1.reset()
while1.output()

elif benchmark == "symm":
while1 = TripCount('while')
for i in range(t['M']):
for j in range(t['N']):
for k in range(i):
while1.incr()
while1.reset()
while1.output()

elif benchmark == "lu":
for1 = TripCount('for1')
while1 = TripCount('while1')
while1_1 = TripCount('while1_1')
while2 = TripCount('while2')
while2_1 = TripCount('while2_1')
for i in range(t['N']):
for1.incr()
j = 0
while (j < i):
while1.incr()
k = 0
while (k < j):
while1_1.incr()
k += 1
while1_1.reset()
j += 1
while1.reset()

j = i
while (j < t['N']):
while2.incr()
k = 0
while (k < i):
while2_1.incr()
k += 1
while2_1.reset()
j += 1
while2.reset()
for1.reset()
for1.output()
while1.output()
while1_1.output()
while2.output()
while2_1.output()
else:
print(f"{benchmark} has no tripcount registered.")
6 changes: 3 additions & 3 deletions bin/get-benchmarks-csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

set -eu

benchmarks=./benchmarks/verilog/*.expect
benchmarks=./benchmarks/small_polybench/*.fuse

echo "benchmark,latency"
for bench in $benchmarks; do
base="$(basename -s .expect $bench)"
./bin/run-benchmark $bench benchmarks/data/"$base".data | head -n 1
./bin/run-benchmark $bench "$bench".data | head -n 1
done
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ fn construct_pass_manager() -> Result<PassManager> {
Papercut,
CompileEmpty,
CompileControl,
CollapseControl,
StaticTiming,
CompileControl,
GoInsertion,
Expand Down

0 comments on commit bf19894

Please sign in to comment.