From f69f069b18e6a075cd82b5bc44d28a30f554f71b Mon Sep 17 00:00:00 2001 From: mattprost Date: Fri, 13 Dec 2019 10:37:20 -0600 Subject: examples: benchmark_rate dpdk recv/send thread priority elevation Improves dpdk streaming performance for benchmark_rate by elevating thread priority of the send and recv threads. It does this conditionally, if use_dpdk=1 was passed in through the command line args. Admittedly, this is not a perfect solution, as it does not account for the case when a dpdk user is utilizing a config file to pass in that information. The scope of this fix does seem appropriate for an example. --- host/examples/benchmark_rate.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'host/examples/benchmark_rate.cpp') diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp index b28482b9a..eee17bab8 100644 --- a/host/examples/benchmark_rate.cpp +++ b/host/examples/benchmark_rate.cpp @@ -64,6 +64,7 @@ inline std::string time_delta_str(const start_time_type& ref_time) } #define NOW() (time_delta_str(start_time)) +volatile bool set_realtime_priority = false; /*********************************************************************** * Benchmark RX Rate @@ -75,6 +76,10 @@ void benchmark_rx_rate(uhd::usrp::multi_usrp::sptr usrp, const start_time_type& start_time, std::atomic& burst_timer_elapsed) { + if (set_realtime_priority) { + uhd::set_thread_priority_safe(); + } + // print pre-test summary std::cout << boost::format("[%s] Testing receive rate %f Msps on %u channels") % NOW() % (usrp->get_rx_rate() / 1e6) % rx_stream->get_num_channels() @@ -199,6 +204,10 @@ void benchmark_tx_rate(uhd::usrp::multi_usrp::sptr usrp, const size_t spp, bool random_nsamps = false) { + if (set_realtime_priority) { + uhd::set_thread_priority_safe(); + } + // print pre-test summary std::cout << boost::format("[%s] Testing transmit rate %f Msps on %u channels") % NOW() % (usrp->get_tx_rate() / 1e6) % tx_stream->get_num_channels() @@ -381,6 +390,10 @@ int UHD_SAFE_MAIN(int argc, char* argv[]) "features.\n" << std::endl; } + // "use_dpdk" must be specified in the device args for proper performance during streaming with dpdk + if (args.find("use_dpdk") != std::string::npos) { + set_realtime_priority = true; + } start_time_type start_time(std::chrono::steady_clock::now()); std::cout << boost::format("[%s] Creating the usrp device with: %s...") % NOW() % args << std::endl; -- cgit v1.2.3