diff options
Diffstat (limited to 'host/utils/converter_benchmark.cpp')
-rw-r--r-- | host/utils/converter_benchmark.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/host/utils/converter_benchmark.cpp b/host/utils/converter_benchmark.cpp index f6d7e9650..ba521441f 100644 --- a/host/utils/converter_benchmark.cpp +++ b/host/utils/converter_benchmark.cpp @@ -22,6 +22,7 @@ #include <boost/program_options.hpp> #include <boost/format.hpp> #include <boost/timer.hpp> +#include <boost/lexical_cast.hpp> #include <boost/algorithm/string.hpp> #include <iostream> #include <iomanip> @@ -97,6 +98,28 @@ void init_random_vector_complex_int(std::vector<char> &buf_ptr, const size_t n_i } } +struct item32_sc12_3x +{ + uint32_t line0; + uint32_t line1; + uint32_t line2; +}; + +template <typename T> +void init_random_vector_complex_sc12(std::vector<char> &buf_ptr, const size_t n_items) +{ + item32_sc12_3x *const buf = reinterpret_cast<item32_sc12_3x * const>(&buf_ptr[0]); + if (n_items % 4) throw std::invalid_argument(""); + + for (size_t i = 0; i < n_items / 4; i++) { + int16_t iq[8]; + for (auto &k : iq) k = rand() & 0xfff; + buf[i].line0 = iq[0] << 20 | iq[1] << 8 | iq[2] >> 4; + buf[i].line1 = iq[2] << 28 | iq[3] << 16 | iq[4] << 4 | iq[5] >> 8; + buf[i].line2 = iq[5] << 24 | iq[6] << 12 | iq[7] << 0; + } +} + template <typename T> void init_random_vector_real_int(std::vector<char> &buf_ptr, size_t n_items) { @@ -163,6 +186,8 @@ void init_buffers( for (size_t i = 0; i < buf.size(); i++) { if (type == "sc8") { init_random_vector_complex_int<int8_t>(buf[i], n_items); + } else if (type == "sc12") { + init_random_vector_complex_sc12<int16_t>(buf[i], n_items); } else if (type == "sc16") { init_random_vector_complex_int<int16_t>(buf[i], n_items); } else if (type == "sc32") { @@ -354,7 +379,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]) boost::is_any_of(","), // Split at , boost::token_compress_on // Avoid empty results ); - BOOST_FOREACH(const std::string &this_prio, prios_in_list) { + for(const std::string &this_prio: prios_in_list) { size_t prio_index = boost::lexical_cast<size_t>(this_prio); converter::sptr conv_for_prio = get_converter(converter_id, prio_index)(); // Can throw a uhd::key_error conv_list[prio_index] = conv_for_prio; @@ -384,7 +409,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]) /// Final configurations to the converter: std::cout << "Configuring converters:" << std::endl; - BOOST_FOREACH(priority_type prio_i, conv_list.keys()) { + for(priority_type prio_i: conv_list.keys()) { std::cout << "* [" << prio_i << "]: "; configure_conv(conv_list[prio_i], in_type, out_type); } @@ -393,7 +418,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]) std::cout << "{{{" << std::endl; if (not debug_mode) { std::cout << "prio,duration_ms,avg_duration_ms,n_samples,iterations" << std::endl; - BOOST_FOREACH(priority_type prio_i, conv_list.keys()) { + for(priority_type prio_i: conv_list.keys()) { double duration = run_benchmark( conv_list[prio_i], input_buf_refs, |