Split out the bench_engine so it can be run alone
This commit is contained in:
1 parent
bf3663f4eb
commit
402086ce7d
4 files changed
+91
-68
No files matched your search
@@ -3,3 +3,7 @@ Client/*
|
|||||||
!Client/cleanup.sh
|
!Client/cleanup.sh
|
||||||
OpenBench/migrations/*
|
OpenBench/migrations/*
|
||||||
credentials
|
credentials
|
||||||
|
|
||||||
|
Scripts/Binaries/*
|
||||||
|
Scripts/Networks/*
|
||||||
|
Scripts/Repositories/*
|
||||||
+2
-2
@@ -391,14 +391,14 @@ def server_configure_worker(arguments):
|
|||||||
|
|
||||||
# Compiler version was sufficient
|
# Compiler version was sufficient
|
||||||
if tuple(map(int, match.split('.'))) >= version:
|
if tuple(map(int, match.split('.'))) >= version:
|
||||||
print('%10s | %s (%s)' % (engine, compiler, match))
|
print('%14s | %s (%s)' % (engine, compiler, match))
|
||||||
COMPILERS[engine] = compiler
|
COMPILERS[engine] = compiler
|
||||||
break
|
break
|
||||||
|
|
||||||
# Report missing engines in case the User is not expecting it
|
# Report missing engines in case the User is not expecting it
|
||||||
for engine in filter(lambda x: x not in COMPILERS, data):
|
for engine in filter(lambda x: x not in COMPILERS, data):
|
||||||
compiler = data[engine]['compilers']
|
compiler = data[engine]['compilers']
|
||||||
print('%10s | Missing %s' % (engine, compiler))
|
print('%14s | Missing %s' % (engine, compiler))
|
||||||
|
|
||||||
print('\nScanning for CPU Flags...')
|
print('\nScanning for CPU Flags...')
|
||||||
|
|
||||||
|
|||||||
+8
-66
@@ -9,6 +9,7 @@ import sys
|
|||||||
|
|
||||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
|
||||||
|
|
||||||
|
from bench_engine import run_benchmark
|
||||||
from OpenBench.config import OPENBENCH_CONFIG
|
from OpenBench.config import OPENBENCH_CONFIG
|
||||||
|
|
||||||
USE_OLD_BINARIES = True
|
USE_OLD_BINARIES = True
|
||||||
@@ -20,7 +21,10 @@ BENCHMARK_SETS = None
|
|||||||
|
|
||||||
def download_network(engine, sha256):
|
def download_network(engine, sha256):
|
||||||
|
|
||||||
if not os.path.isfile(sha256):
|
if not os.path.isdir('Networks'):
|
||||||
|
os.mkdir('Networks')
|
||||||
|
|
||||||
|
if not os.path.isfile('Networks/%s' % (sha256)):
|
||||||
|
|
||||||
print ('Downloading %s for %s...' % (sha256, engine))
|
print ('Downloading %s for %s...' % (sha256, engine))
|
||||||
|
|
||||||
@@ -28,12 +32,12 @@ def download_network(engine, sha256):
|
|||||||
payload = { 'username' : OPENBENCH_USERNAME, 'password' : OPENBENCH_PASSWORD }
|
payload = { 'username' : OPENBENCH_USERNAME, 'password' : OPENBENCH_PASSWORD }
|
||||||
request = requests.post(data=payload, url=target)
|
request = requests.post(data=payload, url=target)
|
||||||
|
|
||||||
with open(sha256, 'wb') as fout:
|
with open('Networks/%s' % (sha256), 'wb') as fout:
|
||||||
for chunk in request.iter_content(chunk_size=1024):
|
for chunk in request.iter_content(chunk_size=1024):
|
||||||
if chunk: fout.write(chunk)
|
if chunk: fout.write(chunk)
|
||||||
fout.flush()
|
fout.flush()
|
||||||
|
|
||||||
with open(sha256, 'rb') as network:
|
with open('Networks/%s' % (sha256), 'rb') as network:
|
||||||
assert sha256 == hashlib.sha256(network.read()).hexdigest()[:8].upper()
|
assert sha256 == hashlib.sha256(network.read()).hexdigest()[:8].upper()
|
||||||
|
|
||||||
def download_default_networks():
|
def download_default_networks():
|
||||||
@@ -70,7 +74,7 @@ def build_engine(engine, config, defaults):
|
|||||||
|
|
||||||
command = 'make -j EXE=%s' % (engine)
|
command = 'make -j EXE=%s' % (engine)
|
||||||
if engine in defaults:
|
if engine in defaults:
|
||||||
command += ' EVALFILE=%s' % (os.path.join(base_path, defaults[engine]).replace('\\', '/'))
|
command += ' EVALFILE=%s' % (os.path.join(base_path, 'Networks', defaults[engine]).replace('\\', '/'))
|
||||||
|
|
||||||
print ('=' * 120)
|
print ('=' * 120)
|
||||||
print ('Attempting to build %s...' % (engine))
|
print ('Attempting to build %s...' % (engine))
|
||||||
@@ -102,68 +106,6 @@ def build_all_engines():
|
|||||||
|
|
||||||
build_engine(engine, config, defaults)
|
build_engine(engine, config, defaults)
|
||||||
|
|
||||||
def parse_stream_output(stream):
|
|
||||||
|
|
||||||
nps = bench = None # Search through output Stream
|
|
||||||
for line in stream.decode('ascii').strip().split('\n')[::-1]:
|
|
||||||
|
|
||||||
# Try to match a wide array of patterns
|
|
||||||
line = re.sub(r'[^a-zA-Z0-9 ]+', ' ', line)
|
|
||||||
nps_pattern = r'([0-9]+ NPS)|(NPS[ ]+[0-9]+)'
|
|
||||||
bench_pattern = r'([0-9]+ NODES)|(NODES[ ]+[0-9]+)'
|
|
||||||
re_nps = re.search(nps_pattern, line.upper())
|
|
||||||
re_bench = re.search(bench_pattern, line.upper())
|
|
||||||
|
|
||||||
# Replace only if not already found earlier
|
|
||||||
if not nps and re_nps: nps = re_nps.group()
|
|
||||||
if not bench and re_bench: bench = re_bench.group()
|
|
||||||
|
|
||||||
# Parse out the integer portion from our matches
|
|
||||||
nps = int(re.search(r'[0-9]+', nps).group()) if nps else None
|
|
||||||
bench = int(re.search(r'[0-9]+', bench).group()) if bench else None
|
|
||||||
return (bench, nps)
|
|
||||||
|
|
||||||
def single_core_bench(engine, outqueue):
|
|
||||||
|
|
||||||
# Launch the bench and wait for results
|
|
||||||
stdout, stderr = subprocess.Popen(
|
|
||||||
"./{0} bench".format(engine).split(),
|
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()
|
|
||||||
|
|
||||||
# Parse output streams for the benchmark data
|
|
||||||
bench, speed = parse_stream_output(stdout)
|
|
||||||
if bench is None or speed is None:
|
|
||||||
bench, speed = parse_stream_output(stderr)
|
|
||||||
outqueue.put((int(bench), int(speed)))
|
|
||||||
|
|
||||||
def multi_core_bench(engine, threads):
|
|
||||||
|
|
||||||
outqueue = multiprocessing.Queue()
|
|
||||||
|
|
||||||
processes = [
|
|
||||||
multiprocessing.Process(
|
|
||||||
target=single_core_bench,
|
|
||||||
args=(engine, outqueue)
|
|
||||||
) for ii in range(threads)
|
|
||||||
]
|
|
||||||
|
|
||||||
for process in processes: process.start()
|
|
||||||
|
|
||||||
return [outqueue.get() for ii in range(threads)]
|
|
||||||
|
|
||||||
def run_benchmark(engine, threads, sets):
|
|
||||||
|
|
||||||
benches, speeds = [], []
|
|
||||||
for ii in range(sets):
|
|
||||||
for bench, speed in multi_core_bench(engine, threads):
|
|
||||||
benches.append(bench); speeds.append(speed)
|
|
||||||
|
|
||||||
if len(set(benches)) != 1:
|
|
||||||
print("Error: Non-Deterministic Results!")
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
return int(sum(speeds) / len(speeds))
|
|
||||||
|
|
||||||
def bench_built_engines():
|
def bench_built_engines():
|
||||||
|
|
||||||
for engine in sorted(os.listdir('Binaries')):
|
for engine in sorted(os.listdir('Binaries')):
|
||||||
|
|||||||
Executable
+77
@@ -0,0 +1,77 @@
|
|||||||
|
import argparse
|
||||||
|
import multiprocessing
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def parse_stream_output(stream):
|
||||||
|
|
||||||
|
nps = bench = None # Search through output Stream
|
||||||
|
for line in stream.decode('ascii').strip().split('\n')[::-1]:
|
||||||
|
|
||||||
|
# Try to match a wide array of patterns
|
||||||
|
line = re.sub(r'[^a-zA-Z0-9 ]+', ' ', line)
|
||||||
|
nps_pattern = r'([0-9]+ NPS)|(NPS[ ]+[0-9]+)'
|
||||||
|
bench_pattern = r'([0-9]+ NODES)|(NODES[ ]+[0-9]+)'
|
||||||
|
re_nps = re.search(nps_pattern, line.upper())
|
||||||
|
re_bench = re.search(bench_pattern, line.upper())
|
||||||
|
|
||||||
|
# Replace only if not already found earlier
|
||||||
|
if not nps and re_nps: nps = re_nps.group()
|
||||||
|
if not bench and re_bench: bench = re_bench.group()
|
||||||
|
|
||||||
|
# Parse out the integer portion from our matches
|
||||||
|
nps = int(re.search(r'[0-9]+', nps).group()) if nps else None
|
||||||
|
bench = int(re.search(r'[0-9]+', bench).group()) if bench else None
|
||||||
|
return (bench, nps)
|
||||||
|
|
||||||
|
def single_core_bench(engine, outqueue):
|
||||||
|
|
||||||
|
# Launch the bench and wait for results
|
||||||
|
stdout, stderr = subprocess.Popen(
|
||||||
|
"./{0} bench".format(engine).split(),
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()
|
||||||
|
|
||||||
|
# Parse output streams for the benchmark data
|
||||||
|
bench, speed = parse_stream_output(stdout)
|
||||||
|
if bench is None or speed is None:
|
||||||
|
bench, speed = parse_stream_output(stderr)
|
||||||
|
outqueue.put((int(bench), int(speed)))
|
||||||
|
|
||||||
|
def multi_core_bench(engine, threads):
|
||||||
|
|
||||||
|
outqueue = multiprocessing.Queue()
|
||||||
|
|
||||||
|
processes = [
|
||||||
|
multiprocessing.Process(
|
||||||
|
target=single_core_bench,
|
||||||
|
args=(engine, outqueue)
|
||||||
|
) for ii in range(threads)
|
||||||
|
]
|
||||||
|
|
||||||
|
for process in processes: process.start()
|
||||||
|
|
||||||
|
return [outqueue.get() for ii in range(threads)]
|
||||||
|
|
||||||
|
def run_benchmark(engine, threads, sets):
|
||||||
|
|
||||||
|
benches, speeds = [], []
|
||||||
|
for ii in range(sets):
|
||||||
|
for bench, speed in multi_core_bench(engine, threads):
|
||||||
|
benches.append(bench); speeds.append(speed)
|
||||||
|
|
||||||
|
if len(set(benches)) != 1:
|
||||||
|
print("Error: Non-Deterministic Results!")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
return int(sum(speeds) / len(speeds))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
p = argparse.ArgumentParser()
|
||||||
|
p.add_argument('-E', '--engine' , help='Binary Name', required=True)
|
||||||
|
p.add_argument('-T', '--threads' , help='Concurrent Benchmarks', required=True)
|
||||||
|
p.add_argument('-S', '--sets' , help='Benchmark Sample Count', required=True)
|
||||||
|
args = p.parse_args()
|
||||||
|
|
||||||
|
print (run_benchmark(args.engine, int(args.threads), int(args.sets)))
|
||||||
Reference in new issue
Block a user