added no timeout option

This commit is contained in:
JanLJL
2021-04-19 10:57:51 +02:00
parent cfc061e5e3
commit 3f31235f8a
2 changed files with 22 additions and 18 deletions

View File

@@ -153,7 +153,8 @@ def create_parser(parser=None):
type=int,
default=10,
help="Set timeout in seconds for LCD analysis. After timeout, OSACA will continue"
" its analysis with the dependency paths found up to this point. Defaults to 10.",
" its analysis with the dependency paths found up to this point. Defaults to 10."
" Set to -1 for no timeout.",
)
parser.add_argument(
"--verbose", "-v", action="count", default=0, help="Increases verbosity level."

View File

@@ -2,12 +2,10 @@
import copy
import time
from collections import defaultdict
from itertools import accumulate, chain, product
from itertools import chain
from multiprocessing import Manager, Process, cpu_count
import networkx as nx
from osaca.parser import AttrDict
from osaca.semantics import INSTR_FLAGS, ArchSemantics, MachineModel
@@ -123,22 +121,27 @@ class KernelDG(nx.DiGraph):
]
for p in processes:
p.start()
start_time = time.time()
while time.time() - start_time <= timeout:
if any(p.is_alive() for p in processes):
time.sleep(0.2)
else:
# all procs done
for p in processes:
p.join()
break
else:
self.timed_out = True
# terminate running processes
if (timeout == -1):
# no timeout
for p in processes:
if p.is_alive():
p.kill()
p.join()
else:
start_time = time.time()
while time.time() - start_time <= timeout:
if any(p.is_alive() for p in processes):
time.sleep(0.2)
else:
# all procs done
for p in processes:
p.join()
break
else:
self.timed_out = True
# terminate running processes
for p in processes:
if p.is_alive():
p.kill()
p.join()
all_paths = list(all_paths)
else:
# sequential execution to avoid overhead when analyzing smaller kernels