added cli support for serialized instructions

This commit is contained in:
Julian Hammer
2018-07-05 14:25:15 +02:00
parent a4fee9bc06
commit 3dac7d6795
3 changed files with 15 additions and 12 deletions

View File

@@ -9,9 +9,11 @@ def main():
# parser.add_argument('mode', metavar='MODE', type=str, choices=['latency', 'throughput'])
parser.add_argument('instructions', metavar='INSTR', type=op.Instruction.from_string, nargs='+',
help='instruction declaration, e.g., "add {src:i32:r} {srcdst:i32:r}"')
parser.add_argument('--serialize', action='store_true',
help='Serialize instructions.')
parser.add_argument('--latency-serial', '-l', type=int, default=8,
help='length of serial chain for each instruction in latency benchmark')
parser.add_argument('--parallel', '-p',type=int, default=4,
parser.add_argument('--parallel', '-p',type=int, default=10,
help='number of parallel instances of serial chains in throughput '
'benchmark')
parser.add_argument('--throughput-serial', '-t', type=int, default=8,
@@ -25,6 +27,7 @@ def main():
serial_factor=args.latency_serial,
parallel_factor=args.parallel,
throughput_serial_factor=args.throughput_serial,
serialize=args.serialize,
verbosity=args.verbose)
print("Latency: {:.2f} cycle\nThroughput: {:.2f} cycle\n".format(lat, tp))

View File

@@ -238,15 +238,18 @@ class IntegerLoopBenchmark(LoopBenchmark):
def bench_instructions(instructions, serial_factor=8, parallel_factor=4, throughput_serial_factor=8,
verbosity=0):
serialize=False, verbosity=0):
not_serializable = False
try:
# Latency Benchmark
if verbosity > 0:
print('## Latency Benchmark')
p_instrs = []
for i in instructions:
p_instrs.append(op.Serialized([i] * serial_factor))
if not serialize:
for i in instructions:
p_instrs.append(op.Serialized([i] * serial_factor))
else:
p_instrs = [op.Serialized(instructions * serial_factor)]
p = op.Parallelized(p_instrs)
b = IntegerLoopBenchmark(p)
if verbosity >= 3:
@@ -274,8 +277,11 @@ def bench_instructions(instructions, serial_factor=8, parallel_factor=4, through
if verbosity > 0:
print('## Throughput Benchmark')
p_instrs = []
for i in instructions:
p_instrs.append(op.Serialized([i] * throughput_serial_factor))
if not serialize:
for i in instructions:
p_instrs.append(op.Serialized([i] * throughput_serial_factor))
else:
p_instrs = [op.Serialized(instructions * throughput_serial_factor)]
p = op.Parallelized(p_instrs * parallel_factor)
b = IntegerLoopBenchmark(p)
if verbosity >= 3:

View File

@@ -195,12 +195,6 @@ class Synthable:
class Operation(Synthable):
"""Base class for operations."""
def __repr__(self):
return '{}({})'.format(
self.__class__.__name__,
', '.join(['{}={!r}'.format(k, v) for k, v in self.__dict__.items()
if not k.startswith('_')]))
class Instruction(Operation):
def __init__(self, instruction, destination_operand, source_operands):