mirror of
https://github.com/YosysHQ/sby.git
synced 2025-04-27 23:45:50 +00:00
Make jobserver integration
Only implements the POSIX jobserver and will break on windows. Unbreaking it on windows will be done as a follow up. Not used for autotune, that needs some more changes.
This commit is contained in:
parent
de939e279a
commit
b0786aea43
5 changed files with 359 additions and 7 deletions
|
@ -20,8 +20,11 @@
|
|||
import argparse, json, os, sys, shutil, tempfile, re
|
||||
##yosys-sys-path##
|
||||
from sby_core import SbyConfig, SbyTask, SbyAbort, SbyTaskloop, process_filename
|
||||
from sby_jobserver import SbyJobClient, process_jobserver_environment
|
||||
import time, platform
|
||||
|
||||
process_jobserver_environment() # needs to be called early
|
||||
|
||||
class DictAction(argparse.Action):
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
assert isinstance(getattr(namespace, self.dest), dict), f"Use ArgumentParser.set_defaults() to initialize {self.dest} to dict()"
|
||||
|
@ -46,6 +49,11 @@ parser.add_argument("-T", metavar="<taskname>", action="append", dest="tasknames
|
|||
help="add taskname (useful when sby file is read from stdin)")
|
||||
parser.add_argument("-E", action="store_true", dest="throw_err",
|
||||
help="throw an exception (incl stack trace) for most errors")
|
||||
parser.add_argument("-j", metavar="<N>", type=int, dest="jobcount",
|
||||
help="maximum number of processes to run in parallel")
|
||||
parser.add_argument("--sequential", action="store_true", dest="sequential",
|
||||
help="run tasks in sequence, not in parallel")
|
||||
|
||||
parser.add_argument("--autotune", action="store_true", dest="autotune",
|
||||
help="automatically find a well performing engine and engine configuration for each task")
|
||||
parser.add_argument("--autotune-config", dest="autotune_config",
|
||||
|
@ -114,6 +122,8 @@ reusedir = False
|
|||
setupmode = args.setupmode
|
||||
autotune = args.autotune
|
||||
autotune_config = args.autotune_config
|
||||
sequential = args.sequential
|
||||
jobcount = args.jobcount
|
||||
init_config_file = args.init_config_file
|
||||
|
||||
if sbyfile is not None:
|
||||
|
@ -501,12 +511,22 @@ def start_task(taskloop, taskname):
|
|||
failed = []
|
||||
retcode = 0
|
||||
|
||||
if jobcount is not None and jobcount < 1:
|
||||
print("ERROR: The -j option requires a positive number as argument")
|
||||
sys.exit(1)
|
||||
|
||||
# Autotune is already parallel, parallelizing it across tasks needs some more work
|
||||
sequential = autotune # TODO selection between parallel/sequential
|
||||
if autotune:
|
||||
sequential = True
|
||||
|
||||
if sequential:
|
||||
if autotune:
|
||||
jobclient = None # TODO make autotune use a jobclient
|
||||
else:
|
||||
jobclient = SbyJobClient(jobcount)
|
||||
|
||||
for taskname in tasknames:
|
||||
taskloop = SbyTaskloop()
|
||||
taskloop = SbyTaskloop(jobclient)
|
||||
try:
|
||||
task = start_task(taskloop, taskname)
|
||||
except SbyAbort:
|
||||
|
@ -525,7 +545,8 @@ if sequential:
|
|||
if task.retcode:
|
||||
failed.append(taskname)
|
||||
else:
|
||||
taskloop = SbyTaskloop()
|
||||
jobclient = SbyJobClient(jobcount)
|
||||
taskloop = SbyTaskloop(jobclient)
|
||||
|
||||
tasks = {}
|
||||
for taskname in tasknames:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue