diff options
author | Brent Stapleton <brent.stapleton@ettus.com> | 2018-12-21 10:54:05 -0800 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-03 09:20:18 -0800 |
commit | aa1ec635379192bc9694ceddfb7c417992b94db4 (patch) | |
tree | 733f7a5b60da5bb273c4fe3330592ba6e905843f /host | |
parent | 7d34f4d2c8e3ae63f7f217be7700d20e5c8823a7 (diff) | |
download | uhd-aa1ec635379192bc9694ceddfb7c417992b94db4.tar.gz uhd-aa1ec635379192bc9694ceddfb7c417992b94db4.tar.bz2 uhd-aa1ec635379192bc9694ceddfb7c417992b94db4.zip |
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).
Diffstat (limited to 'host')
-rw-r--r-- | host/examples/tx_waveforms.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
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<std::complex<float> > buff(spb); std::vector<std::complex<float> *> 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; } |