From aa1ec635379192bc9694ceddfb7c417992b94db4 Mon Sep 17 00:00:00 2001 From: Brent Stapleton Date: Fri, 21 Dec 2018 10:54:05 -0800 Subject: examples: optimize tx_waveforms memory allocations Move filling the TX buffer outside the critical path. Now, we pre-fill the TX buffer before entering the send loop (and before setting the TX stream time), and fill the TX buffer after calling send() (for the next iteration). --- host/examples/tx_waveforms.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'host/examples/tx_waveforms.cpp') diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index d5e4cb6f5..b432741fa 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -173,6 +173,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::vector > buff(spb); std::vector *> buffs(channel_nums.size(), &buff.front()); + //pre-fill the buffer with the waveform + for (size_t n = 0; n < buff.size(); n++){ + buff[n] = wave_table(index += step); + } + std::cout << boost::format("Setting device timestamp to 0...") << std::endl; if (channel_nums.size() > 1) { @@ -250,16 +255,16 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ break; } - //fill the buffer with the waveform - for (size_t n = 0; n < buff.size(); n++){ - buff[n] = wave_table(index += step); - } - //send the entire contents of the buffer num_acc_samps += tx_stream->send( buffs, buff.size(), md ); + //fill the buffer with the waveform + for (size_t n = 0; n < buff.size(); n++){ + buff[n] = wave_table(index += step); + } + md.start_of_burst = false; md.has_time_spec = false; } -- cgit v1.2.3