diff options
author | mattprost <matt.prost@ni.com> | 2019-12-13 10:37:20 -0600 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2019-12-20 16:32:22 -0800 |
commit | f69f069b18e6a075cd82b5bc44d28a30f554f71b (patch) | |
tree | ea8ddde6018222e47272c3f1f134eac649fcf6e4 /host/examples/benchmark_rate.cpp | |
parent | 0bf495f97002f65b73e7d2922e6f7fc5ea2a024d (diff) | |
download | uhd-f69f069b18e6a075cd82b5bc44d28a30f554f71b.tar.gz uhd-f69f069b18e6a075cd82b5bc44d28a30f554f71b.tar.bz2 uhd-f69f069b18e6a075cd82b5bc44d28a30f554f71b.zip |
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.
Diffstat (limited to 'host/examples/benchmark_rate.cpp')
-rw-r--r-- | host/examples/benchmark_rate.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
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<bool>& 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; |