Skip to content
Snippets Groups Projects
Commit 61876130 authored by Marc Gay-Balmaz's avatar Marc Gay-Balmaz
Browse files

Added multithreaded support

parent 5d67d983
No related branches found
No related tags found
No related merge requests found
import itertools
import subprocess
import sys
from threading import Thread
from typing import Optional, Callable, Iterable, Mapping, Any
import numpy
......@@ -12,6 +14,7 @@ param_increment = []
output_file_name = "result/OutputValues"
exec_cmd = "./enkiAdaptedMinimal "
count = 1
threadNB = 1
miss = False
logarithmical = False
......@@ -35,6 +38,10 @@ for i in range(1, len(sys.argv)):
miss = True
print("count arg detected!")
count = int(sys.argv[i+1])
elif sys.argv[i][2] == 'j':
miss = True
print("Multithread arg detected!")
threadNB = int(sys.argv[i+1])
elif sys.argv[i][2] == 'l':
print("log arg detected!")
logarithmical = True
......@@ -60,10 +67,36 @@ for i in range(len(param_min)):
combination = itertools.product(*param_combinations)
print("Tests begun")
# Test each value combination
for i in combination:
class SimulationRunner(Thread):
def __init__(self, array):
Thread.__init__(self)
self.array = array
def run(self) -> None:
for i in self.array:
for j in range(count):
subprocess.call(exec_cmd + " ".join(str(x) for x in i) + " > " + output_file_name + str(j) + "_" + "_".join(
str(x) for x in i) + ".dat", shell=True)
print("Creating tests")
# Test each value combination
threads = []
params = []
for p in combination:
params.append(p)
combinationNB = len(params)
for c in range(threadNB):
threads.append(SimulationRunner(params[int(c*combinationNB/threadNB):int((c+1)*combinationNB/threadNB)]))
print("Threads created")
for c in range(threadNB):
threads[c].start()
print("Threads started")
for c in range(threadNB):
threads[c].join()
print("Done")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment