aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-10-18 13:58:46 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:06:11 -0800
commitaf0fe0f8dc7a8446d826364c3fc01791946497e5 (patch)
tree1428fd679fa06074648f8d7b77913b1addad9cc0 /host/lib
parent3b32e3b0de79898db5f7db5f47eeaf06a65d4a19 (diff)
downloaduhd-af0fe0f8dc7a8446d826364c3fc01791946497e5.tar.gz
uhd-af0fe0f8dc7a8446d826364c3fc01791946497e5.tar.bz2
uhd-af0fe0f8dc7a8446d826364c3fc01791946497e5.zip
mpmd: Optionally parallelize all calls to setup_rpc_blocks
Default is to not serialize inits.
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/mpmd/mpmd_impl.cpp48
-rw-r--r--host/lib/usrp/mpmd/mpmd_impl.hpp5
2 files changed, 39 insertions, 14 deletions
diff --git a/host/lib/usrp/mpmd/mpmd_impl.cpp b/host/lib/usrp/mpmd/mpmd_impl.cpp
index e8eb2ea6a..02b3e66c3 100644
--- a/host/lib/usrp/mpmd/mpmd_impl.cpp
+++ b/host/lib/usrp/mpmd/mpmd_impl.cpp
@@ -26,6 +26,8 @@
#include <random>
#include <string>
#include <vector>
+#include <future>
+#include <thread>
using namespace uhd;
using namespace uhd::mpmd;
@@ -356,7 +358,8 @@ mpmd_impl::mpmd_impl(const device_addr_t& device_args)
auto filtered_block_args = device_args; // TODO actually filter
// Blocks will finalize their own setup in this function. They have (and
// might need) full access to the prop tree, the timekeepers, etc.
- setup_rpc_blocks(filtered_block_args);
+ setup_rpc_blocks(filtered_block_args,
+ device_args.has_key("serialize_init"));
} else {
UHD_LOG_INFO("MPMD", "Claimed device without full initialization.");
}
@@ -474,23 +477,42 @@ void mpmd_impl::setup_rfnoc_blocks(
}
}
-void mpmd_impl::setup_rpc_blocks(const device_addr_t &block_args)
-{
- // This could definitely be parallelized. Blocks may do all sorts of stuff
- // inside set_rpc_client(), and it can take any amount of time (I mean,
- // like, seconds).
+void mpmd_impl::setup_rpc_blocks(
+ const device_addr_t &block_args,
+ const bool serialize_init
+) {
+ std::vector<std::future<void>> task_list;
+ // If we don't force async, most compilers, at least now, will default to
+ // deferred.
+ const auto launch_policy = serialize_init ?
+ std::launch::deferred :
+ std::launch::async;
+
+ // Preload all the tasks (they might start running on emplace_back)
for (const auto &block_ctrl: _rfnoc_block_ctrl) {
auto rpc_block_id = block_ctrl->get_block_id();
- if (has_block<uhd::rfnoc::rpc_block_ctrl>(block_ctrl->get_block_id())) {
+ if (has_block<uhd::rfnoc::rpc_block_ctrl>(rpc_block_id)) {
const size_t mboard_idx = rpc_block_id.get_device_no();
- UHD_LOGGER_DEBUG("MPMD")
- << "Adding RPC access to block: " << rpc_block_id
- << " Block args: " << block_args.to_string()
- ;
- get_block_ctrl<uhd::rfnoc::rpc_block_ctrl>(rpc_block_id)
- ->set_rpc_client(_mb[mboard_idx]->rpc, block_args);
+ auto rpc_block_ctrl =
+ get_block_ctrl<uhd::rfnoc::rpc_block_ctrl>(rpc_block_id);
+ auto rpc_sptr = _mb[mboard_idx]->rpc;
+ task_list.emplace_back(std::async(launch_policy,
+ [rpc_block_id, rpc_block_ctrl, &block_args, rpc_sptr](){
+ UHD_LOGGER_DEBUG("MPMD")
+ << "Adding RPC access to block: " << rpc_block_id
+ << " Block args: " << block_args.to_string()
+ ;
+ rpc_block_ctrl->set_rpc_client(rpc_sptr, block_args);
+ }
+ ));
}
}
+
+ // Execute all the calls to set_rpc_client(), either concurrently, or
+ // serially
+ for (auto &task : task_list) {
+ task.get();
+ }
}
size_t mpmd_impl::allocate_xbar_local_addr()
diff --git a/host/lib/usrp/mpmd/mpmd_impl.hpp b/host/lib/usrp/mpmd/mpmd_impl.hpp
index 50f533c99..14051c922 100644
--- a/host/lib/usrp/mpmd/mpmd_impl.hpp
+++ b/host/lib/usrp/mpmd/mpmd_impl.hpp
@@ -196,7 +196,10 @@ public:
);
//! Configure all blocks that require access to an RPC client
- void setup_rpc_blocks(const uhd::device_addr_t &block_args);
+ void setup_rpc_blocks(
+ const uhd::device_addr_t &block_args,
+ const bool serialize_init
+ );
/*! Returns a valid local address for a crossbar
*