Commit 46b32b7d authored by Andrew McNab's avatar Andrew McNab
Browse files

diracBenchmark.py -> DIRACbenchmark.py

parent 9d390c0a
#!/usr/bin/python
########################################################################
# File : diracBenchmark.py
# File : DIRACbenchmark.py
# Author : Andrew McNab
########################################################################
""" DIRAC Benchmark 2012 by Ricardo Graciani, and wrapper functions to
run multiple instances in parallel by Andrew McNab.
This file (diracBenchmark.py) is intended to be the ultimate upstream
This file (DIRACbenchmark.py) is intended to be the ultimate upstream
shared by different users of the DIRAC Benchmark 2012 (DB12). The
canonical version can be found at https://github.com/?????
"""
......@@ -21,7 +21,7 @@ import multiprocessing
version = '0.1 DB12'
def singleDiracBenchmark( iterations = 1, resultObject = None ):
def singleDiracBenchmark( iterations = 1 ):
""" Get Normalized Power of one CPU in DIRAC Benchmark 2012 units (DB12)
"""
......@@ -53,13 +53,21 @@ def singleDiracBenchmark( iterations = 1, resultObject = None ):
if not cput:
return None
else:
if resultObject is not None:
# This makes it easy to use with multiprocessing.Process
resultObject.value = calib * iterations / cput
# Return DIRAC-compatible values
return { 'CPU' : cput, 'WALL' : wall, 'NORM' : calib * iterations / cput, 'UNIT' : 'DB12' }
# Return DIRAC-compatible values too
return { 'CPU' : cput, 'WALL' : wall, 'NORM' : calib * iterations / cput, 'UNIT' : 'DB12' }
def singleDiracBenchmarkProcess( resultObject, iterations = 1 ):
""" Run singleDiracBenchmark() in a multiprocessing friendly way
"""
benchmarkResult = singleDiracBenchmark( iterations )
if not benchmarkResult or 'NORM' not in benchmarkResult:
return None
# This makes it easy to use with multiprocessing.Process
resultObject.value = benchmarkResult['NORM']
def multipleDiracBenchmark( instances = 1, iterations = 1 ):
......@@ -72,7 +80,7 @@ def multipleDiracBenchmark( instances = 1, iterations = 1 ):
# Set up all the subprocesses
for i in range( instances ):
results.append( multiprocessing.Value('d', 0.0) )
processes.append( multiprocessing.Process( target = singleDiracBenchmark, args = ( iterations, results[i] ) ) )
processes.append( multiprocessing.Process( target = singleDiracBenchmarkProcess, args = ( results[i], iterations ) ) )
# Start them all off at the same time
for p in processes:
......@@ -132,7 +140,7 @@ def jobslotDiracBenchmark( instances = None, iterations = 1 ):
if __name__ == "__main__":
if len(sys.argv) == 1 or sys.argv[1] == 'single':
print singleDiracBenchmark()['sum']
print singleDiracBenchmark()['NORM']
sys.exit(0)
if sys.argv[1] == 'version':
......
......@@ -36,7 +36,7 @@ INSTALL_FILES=VERSION mjf.init \
mjf.sh.torque mjf.csh.torque mjf-get-total-cpu.torque \
mjf.sh.htcondor mjf.csh.htcondor mjf-get-total-cpu.htcondor \
mjf-job-wrapper make-jobfeatures.htcondor \
diracBenchmark.py db12.init
DIRACbenchmark.py db12.init
TGZ_FILES=$(INSTALL_FILES) Makefile mjf-torque.spec mjf-htcondor.spec mjf-db12.spec README
......
......@@ -26,7 +26,7 @@ start() {
echo -n $"Run DB12 fast benchmark: "
db12_sum=`/usr/sbin/diracBenchmark.py $total_cpu | cut -f2 -d' '`
db12_sum=`/usr/sbin/DIRACbenchmark.py $total_cpu | cut -f2 -d' '`
if [ "$db12_sum" != "" ] ; then
echo "$db12_sum" > /etc/db12/db12
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment