From 34a8d07982d35a59fb7043405ec764c94e6b2c83 Mon Sep 17 00:00:00 2001 From: Hendrik Borras <hendrikborras@web.de> Date: Fri, 31 Jul 2020 11:01:28 +0200 Subject: [PATCH] Fixes Xilinx/finn#205 --- src/finn/util/vcd.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/finn/util/vcd.py b/src/finn/util/vcd.py index d9e244422..e1fe2df03 100644 --- a/src/finn/util/vcd.py +++ b/src/finn/util/vcd.py @@ -162,16 +162,23 @@ def _get_stats(x): return (x[0], get_stream_if_stats(x[1], x[0])) -def get_all_stream_if_stats(vcd_file, stream_ifs=None, sort_by="{'V': 1, 'R': 0}"): +def get_all_stream_if_stats(vcd_file, stream_ifs=None, sort_by="{'V': 1, 'R': 0}", num_workers=None): """Return a list of streaming interface stats, sorted by the percentage - for the given sort_by key. If stream_ifs is None, all streamin interface + for the given sort_by key. If stream_ifs is None, all streaming interface stats will be returned, otherwise treated as a list of interface names to - return the stats for.""" + return the stats for. + By default the number of parallel workers from the environment variable + NUM_DEFAULT_WORKERS will be used. This behavior can be changed on a per + call basis by supplying the optional parameter: num_workers + """ if stream_ifs is None: stream_ifs = list_stream_if(vcd_file) - with mp.Pool(get_num_default_workers()) as p: + if num_workers == None: + num_workers = get_num_default_workers() + + with mp.Pool(num_workers) as p: stream_ifs = map(lambda x: (x, vcd_file), stream_ifs) all_stats = p.map(_get_stats, stream_ifs) -- GitLab