utils: parallelize all roi parts generation

Signed-off-by: Alessandro Comodi <acomodi@antmicro.com>
This commit is contained in:
Alessandro Comodi 2022-03-04 11:05:55 +01:00
parent f63752fe3e
commit 6c4188a520
1 changed files with 23 additions and 5 deletions

View File

@ -9,13 +9,26 @@
# #
# SPDX-License-Identifier: ISC # SPDX-License-Identifier: ISC
import argparse import argparse
import yaml import multiprocessing as mp
import subprocess
import os import os
import re import re
import subprocess
import yaml
from prjxray import util from prjxray import util
def worker(arglist):
part, cwd = arglist
cmd = "make roi_only"
env = os.environ.copy()
env['XRAY_PART'] = part
print("running subprocess")
subprocess.run(cmd.split(' '), check=True, env=env, cwd=cwd)
def main(): def main():
"""Rois all parts for a family by calling "make roi_only" over all parts """Rois all parts for a family by calling "make roi_only" over all parts
with the same device as XRAY_PART. with the same device as XRAY_PART.
@ -36,12 +49,17 @@ def main():
if device['fabric'] == information['device']: if device['fabric'] == information['device']:
valid_devices.append(name) valid_devices.append(name)
tasks = []
for part, data in util.get_parts(db_root).items(): for part, data in util.get_parts(db_root).items():
if data['device'] in valid_devices: if data['device'] in valid_devices:
command = "make roi_only"
env['XRAY_PART'] = part
cwd = os.getenv('XRAY_FUZZERS_DIR') cwd = os.getenv('XRAY_FUZZERS_DIR')
subprocess.run(command.split(' '), check=True, env=env, cwd=cwd)
tasks.append((part, cwd))
with mp.Pool() as pool:
for _ in pool.imap_unordered(worker, tasks):
pass
if __name__ == '__main__': if __name__ == '__main__':