Commit 54f7d33b authored by Konstantinos Chatzilygeroudis's avatar Konstantinos Chatzilygeroudis
Browse files

Local parallel + serial experiments

parent f910b6f1
......@@ -2,6 +2,7 @@ import os
import stat
import subprocess
import time
import threading
from waflib.Tools import waf_unit_test
json_ok = True
......@@ -123,7 +124,6 @@ def _sub_script_local(conf_file):
# parse conf
list_exps = simplejson.load(open(conf_file))
fnames = []
arguments = []
for conf in list_exps:
exps = conf['exps']
nb_runs = conf['nb_runs']
......@@ -163,19 +163,30 @@ def _sub_script_local(conf_file):
subprocess.call('cp ' + bin_dir + '/' + e + ' ' + '"' + directory + '"', shell=True)
fname = e
fnames += [(fname, directory)]
arguments.append(args)
return fnames,arguments
return fnames,args
def run_local(conf_file):
fnames,args = _sub_script_local(conf_file)
i = 0
def run_local_one(directory, s):
std_out = open(directory+"/stdout.txt", "w")
std_err = open(directory+"/stderr.txt", "w")
retcode = subprocess.call(s, shell=True, env=None, stdout=std_out, stderr=std_err)
def run_local(conf_file, serial = True):
fnames,arguments = _sub_script_local(conf_file)
threads = []
for (fname, directory) in fnames:
s = "cd " + '"' + directory + '"' + " && " + "./" + fname + ' ' + args[i] # + " &"
s = "cd " + '"' + directory + '"' + " && " + "./" + fname + ' ' + arguments
print "Executing " + s
retcode = subprocess.call(s, shell=True, env=None)
time.sleep(1)
i = i + 1
if not serial:
t = threading.Thread(target=run_local_one, args=(directory,s,))
threads.append(t)
else:
run_local_one(directory,s)
if not serial:
for i in range(len(threads)):
threads[i].start()
for i in range(len(threads)):
threads[i].join()
def qsub(conf_file):
tpl = """#!/bin/sh
......
......@@ -34,6 +34,7 @@ def options(opt):
opt.add_option('--qsub', type='string', help='config file (json) to submit to torque', dest='qsub')
opt.add_option('--oar', type='string', help='config file (json) to submit to oar', dest='oar')
opt.add_option('--local', type='string', help='config file (json) to run local', dest='local')
opt.add_option('--local_serial', type='string', help='config file (json) to run local', dest='local_serial')
opt.add_option('--experimental', action='store_true', help='specify to compile the experimental examples', dest='experimental')
# tests
opt.add_option('--tests', action='store_true', help='compile tests or not', dest='tests')
......@@ -125,7 +126,9 @@ def shutdown(ctx):
if ctx.options.oar:
limbo.oar(ctx.options.oar)
if ctx.options.local:
limbo.run_local(ctx.options.local)
limbo.run_local(ctx.options.local, False)
if ctx.options.local_serial:
limbo.run_local(ctx.options.local_serial)
class BuildExtensiveTestsContext(BuildContext):
......
Supports Markdown
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