diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-11-21 11:58:11 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:05:06 -0800 |
commit | afe889af2b7dd13904cd2ce9f401a0221b047b3d (patch) | |
tree | e710f2d56ba3ca91328a7106198b4f4999f6e649 | |
parent | 077f29d982822ca9cca3f159f517aa581dbc1601 (diff) | |
download | uhd-afe889af2b7dd13904cd2ce9f401a0221b047b3d.tar.gz uhd-afe889af2b7dd13904cd2ce9f401a0221b047b3d.tar.bz2 uhd-afe889af2b7dd13904cd2ce9f401a0221b047b3d.zip |
mpm: mg: Optionally parallelize init calls to dboard
Default is to run in parallel. serialize_init=1 will run them serially.
Reviewed-By: Brent Stapleton <brent.stapleton@ettus.com>
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/base.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index f5b3f39e8..3cfcc0ce8 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -20,6 +20,7 @@ Mboard implementation base class from __future__ import print_function import os +from concurrent import futures from hashlib import md5 from builtins import str from builtins import range @@ -323,7 +324,8 @@ class PeriphManagerBase(object): all RFNoC blocks must be reachable via CHDR interfaces (i.e., clocks need to be on). - Return False on failure, True on success. + Return False on failure, True on success. If daughterboard inits return + False (any of them), this will also return False. args -- A dictionary of args for initialization. Similar to device args in UHD. @@ -336,8 +338,22 @@ class PeriphManagerBase(object): "Cannot run init(), device was never fully initialized!") return False self._init_args = args - self.log.debug("Initializing dboards...") - return all((dboard.init(args) for dboard in self.dboards)) + if len(self.dboards) == 0: + return True + if args.get("serialize_init", False): + self.log.debug("Initializing dboards serially...") + return all((dboard.init(args) for dboard in self.dboards)) + self.log.debug("Initializing dboards in parallel...") + num_workers = len(self.dboards) + with futures.ThreadPoolExecutor(max_workers=num_workers) as executor: + init_futures = [ + executor.submit(dboard.init, args) + for dboard in self.dboards + ] + return all([ + x.result() + for x in futures.as_completed(init_futures) + ]) def deinit(self): """ |