From a701ab4bd10017235b0d1ad91c0874590d641b01 Mon Sep 17 00:00:00 2001 From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de> Date: Fri, 5 Oct 2018 10:21:09 +0200 Subject: [PATCH] Change call to benchmark programs and donkey wrapper --- bin/donkey_benchmark_wrapper.py | 19 +++++++++++++++++++ bin/donkey_benchmark_wrapper.sh | 6 ------ python/dune/perftool/sumfact/autotune.py | 7 ++++--- 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 bin/donkey_benchmark_wrapper.py delete mode 100755 bin/donkey_benchmark_wrapper.sh diff --git a/bin/donkey_benchmark_wrapper.py b/bin/donkey_benchmark_wrapper.py new file mode 100644 index 00000000..8e5740c8 --- /dev/null +++ b/bin/donkey_benchmark_wrapper.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +import time +import sys +import os + +# Run the actual command +command = "srun -p haswell10c -n 20 -c 2 --cpu_bin=verbose,core".split() +command.append(sys.argv[1]) +ret = subprocess.call(command) + +# If that failed - fail! +if ret != 0: + sys.exit(ret) + +# If that was succesful, wait for the output file to be available on the filesystem +# This step is necessary because the NFS synchronization is too slow for our workflow. +while not os.path.isfile(sys.argv[2]): + time.sleep(0.1) diff --git a/bin/donkey_benchmark_wrapper.sh b/bin/donkey_benchmark_wrapper.sh deleted file mode 100755 index 4c4a93ca..00000000 --- a/bin/donkey_benchmark_wrapper.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -srun -p haswell10c -n 20 -c 2 --cpu_bin=verbose,core $1 - -# Give the file system some time to get our results file handled -sleep 0.1s diff --git a/python/dune/perftool/sumfact/autotune.py b/python/dune/perftool/sumfact/autotune.py index ffe64336..41a8ff14 100644 --- a/python/dune/perftool/sumfact/autotune.py +++ b/python/dune/perftool/sumfact/autotune.py @@ -63,7 +63,7 @@ def compiler_invocation(name, filename): return compile_flags -def generate_standalone_code(sf, filename, logname): +def generate_standalone_code(sf, filename): delete_cache_items("kernel_default") with open(filename, "w") as f: @@ -174,7 +174,7 @@ def generate_standalone_code(sf, filename, logname): # Stop the TSC timer and write the result to a file f.writelines([" auto stop = Dune::PDELab::TSC::stop();\n", " std::ofstream file;\n", - " file.open(\"{}\");\n".format(logname), + " file.open(argv[1]);\n", " file << Dune::PDELab::TSC::elapsed(start, stop) << std::endl;\n", " file.close();\n", " accum += output[dis(rng)];\n", @@ -200,7 +200,7 @@ def autotune_realization(sf): with cache_restoring(): with filelock.FileLock(lock): if not os.path.isfile(logname): - generate_standalone_code(sf, filename, logname) + generate_standalone_code(sf, filename) ret = subprocess.call(compiler_invocation(name, filename)) assert ret == 0 @@ -213,6 +213,7 @@ def autotune_realization(sf): # Run the benchmark program call.append(name) + call.append(logname) devnull = open(os.devnull, 'w') ret = subprocess.call(call, stdout=devnull, stderr=subprocess.STDOUT) assert ret == 0 -- GitLab