Skip to content

Commit

Permalink
qa: refactor volk_profile and testqa for flexibility and ease
Browse files Browse the repository at this point in the history
This is a refactor to add several test options on command line,
remove boost UTF, and make a single list of kernels for profile
and test purposes
  • Loading branch information
hamgravy authored and n-west committed Feb 2, 2015
1 parent 7d8583a commit 9a5e290
Show file tree
Hide file tree
Showing 7 changed files with 482 additions and 326 deletions.
364 changes: 187 additions & 177 deletions apps/volk_profile.cc

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions apps/volk_profile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


void read_results(std::vector<volk_test_results_t> *results);
void write_results(const std::vector<volk_test_results_t> *results);
void write_json(std::ofstream &json_file, std::vector<volk_test_results_t> results);
1 change: 0 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@ else()
message(STATUS "Did not find liborc and orcc, disabling orc support...")
endif()


########################################################################
# Handle the generated constants
########################################################################
Expand Down
135 changes: 135 additions & 0 deletions lib/kernel_tests.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#include "qa_utils.h"

#include <volk/volk.h>

#include <boost/assign/list_of.hpp>
#include <vector>

// macros for initializing volk_test_case_t. Maccros are needed to generate
// function names of the pattern kernel_name_*

// for puppets we need to get all the func_variants for the puppet and just
// keep track of the actual function name to write to results
#define VOLK_INIT_PUPP(func, puppet_master_func, test_params)\
volk_test_case_t(func##_get_func_desc(), (void(*)())func##_manual, std::string(#func),\
std::string(#puppet_master_func), test_params)

#define VOLK_INIT_TEST(func, test_params)\
volk_test_case_t(func##_get_func_desc(), (void(*)())func##_manual, std::string(#func),\
test_params)

std::vector<volk_test_case_t> init_test_list(volk_test_params_t test_params)
{

// Some kernels need a lower tolerance
volk_test_params_t test_params_inacc = volk_test_params_t(1e-3, test_params.scalar(),
test_params.vlen(), test_params.iter(), test_params.benchmark_mode(), test_params.kernel_regex());

std::vector<volk_test_case_t> test_cases = boost::assign::list_of
(VOLK_INIT_PUPP(volk_64u_popcntpuppet_64u, volk_64u_popcnt, test_params))

(VOLK_INIT_PUPP(volk_16u_byteswappuppet_16u, volk_16u_byteswap, test_params))
(VOLK_INIT_PUPP(volk_32u_byteswappuppet_32u, volk_32u_byteswap, test_params))
(VOLK_INIT_PUPP(volk_32u_popcntpuppet_32u, volk32u_popcnt_32u, test_params))
(VOLK_INIT_PUPP(volk_64u_byteswappuppet_64u, volk_64u_byteswap, test_params))
(VOLK_INIT_PUPP(volk_32fc_s32fc_rotatorpuppet_32fc, volk_32fc_s32fc_x2_rotator_32fc, test_params))
(VOLK_INIT_PUPP(volk_8u_conv_k7_r2puppet_8u, volk_8u_x4_conv_k7_r2_8u, volk_test_params_t(0, test_params.scalar(), test_params.vlen(), test_params.iter()/10, test_params.benchmark_mode(), test_params.kernel_regex())))
(VOLK_INIT_TEST(volk_32f_s32f_32f_fm_detect_32f, test_params))
(VOLK_INIT_TEST(volk_16ic_s32f_deinterleave_real_32f, test_params))
(VOLK_INIT_TEST(volk_16ic_deinterleave_real_8i, test_params))
(VOLK_INIT_TEST(volk_16ic_deinterleave_16i_x2, test_params))
(VOLK_INIT_TEST(volk_16ic_s32f_deinterleave_32f_x2, test_params))
(VOLK_INIT_TEST(volk_16ic_deinterleave_real_16i, test_params))
(VOLK_INIT_TEST(volk_16ic_magnitude_16i, test_params))
(VOLK_INIT_TEST(volk_16ic_s32f_magnitude_32f, test_params))
(VOLK_INIT_TEST(volk_16i_s32f_convert_32f, test_params))
(VOLK_INIT_TEST(volk_16i_convert_8i, test_params))
(VOLK_INIT_TEST(volk_16i_32fc_dot_prod_32fc, test_params_inacc))
(VOLK_INIT_TEST(volk_32f_accumulator_s32f, test_params_inacc))
(VOLK_INIT_TEST(volk_32f_x2_add_32f, test_params))
(VOLK_INIT_TEST(volk_32fc_32f_multiply_32fc, test_params))
(VOLK_INIT_TEST(volk_32f_log2_32f, volk_test_params_t(3, test_params.scalar(), test_params.vlen(), test_params.iter(), test_params.benchmark_mode(), test_params.kernel_regex())))
(VOLK_INIT_TEST(volk_32f_expfast_32f, volk_test_params_t(1e-1, test_params.scalar(), test_params.vlen(), test_params.iter(), test_params.benchmark_mode(), test_params.kernel_regex())))
(VOLK_INIT_TEST(volk_32f_x2_pow_32f, volk_test_params_t(1e-2, test_params.scalar(), test_params.vlen(), test_params.iter(), test_params.benchmark_mode(), test_params.kernel_regex())))
(VOLK_INIT_TEST(volk_32f_sin_32f, test_params))
(VOLK_INIT_TEST(volk_32f_cos_32f, test_params))
(VOLK_INIT_TEST(volk_32f_tan_32f, test_params))
(VOLK_INIT_TEST(volk_32f_atan_32f, test_params_inacc))
(VOLK_INIT_TEST(volk_32f_asin_32f, test_params_inacc))
(VOLK_INIT_TEST(volk_32f_acos_32f, test_params_inacc))
(VOLK_INIT_TEST(volk_32fc_s32f_power_32fc, test_params))
(VOLK_INIT_TEST(volk_32f_s32f_calc_spectral_noise_floor_32f, test_params_inacc))
(VOLK_INIT_TEST(volk_32fc_s32f_atan2_32f, test_params))
(VOLK_INIT_TEST(volk_32fc_x2_conjugate_dot_prod_32fc, test_params_inacc))
(VOLK_INIT_TEST(volk_32fc_deinterleave_32f_x2, test_params))
(VOLK_INIT_TEST(volk_32fc_deinterleave_64f_x2, test_params))
(VOLK_INIT_TEST(volk_32fc_s32f_deinterleave_real_16i, test_params))
(VOLK_INIT_TEST(volk_32fc_deinterleave_imag_32f, test_params))
(VOLK_INIT_TEST(volk_32fc_deinterleave_real_32f, test_params))
(VOLK_INIT_TEST(volk_32fc_deinterleave_real_64f, test_params))
(VOLK_INIT_TEST(volk_32fc_x2_dot_prod_32fc, test_params_inacc))
(VOLK_INIT_TEST(volk_32fc_32f_dot_prod_32fc, test_params_inacc))
(VOLK_INIT_TEST(volk_32fc_index_max_16u, volk_test_params_t(3, test_params.scalar(), test_params.vlen(), test_params.iter(), test_params.benchmark_mode(), test_params.kernel_regex())))
(VOLK_INIT_TEST(volk_32fc_s32f_magnitude_16i, test_params))
(VOLK_INIT_TEST(volk_32fc_magnitude_32f, test_params))
(VOLK_INIT_TEST(volk_32fc_magnitude_squared_32f, test_params))
(VOLK_INIT_TEST(volk_32fc_x2_multiply_32fc, test_params))
(VOLK_INIT_TEST(volk_32fc_x2_multiply_conjugate_32fc, test_params))
(VOLK_INIT_TEST(volk_32fc_conjugate_32fc, test_params))
(VOLK_INIT_TEST(volk_32f_s32f_convert_16i, test_params))
(VOLK_INIT_TEST(volk_32f_s32f_convert_32i, volk_test_params_t(1, test_params.scalar(), test_params.vlen(), test_params.iter(), test_params.benchmark_mode(), test_params.kernel_regex())))
(VOLK_INIT_TEST(volk_32f_convert_64f, test_params))
(VOLK_INIT_TEST(volk_32f_s32f_convert_8i, volk_test_params_t(1, test_params.scalar(), test_params.vlen(), test_params.iter(), test_params.benchmark_mode(), test_params.kernel_regex())))
(VOLK_INIT_TEST(volk_32fc_s32f_power_spectrum_32f, test_params))
(VOLK_INIT_TEST(volk_32fc_x2_square_dist_32f, test_params))
(VOLK_INIT_TEST(volk_32fc_x2_s32f_square_dist_scalar_mult_32f, test_params))
(VOLK_INIT_TEST(volk_32f_x2_divide_32f, test_params))
(VOLK_INIT_TEST(volk_32f_x2_dot_prod_32f, test_params_inacc))
(VOLK_INIT_TEST(volk_32f_x2_s32f_interleave_16ic, volk_test_params_t(1, test_params.scalar(), test_params.vlen(), test_params.iter(), test_params.benchmark_mode(), test_params.kernel_regex())))
(VOLK_INIT_TEST(volk_32f_x2_interleave_32fc, test_params))
(VOLK_INIT_TEST(volk_32f_x2_max_32f, test_params))
(VOLK_INIT_TEST(volk_32f_x2_min_32f, test_params))
(VOLK_INIT_TEST(volk_32f_x2_multiply_32f, test_params))
(VOLK_INIT_TEST(volk_32f_s32f_normalize, test_params))
(VOLK_INIT_TEST(volk_32f_s32f_power_32f, test_params))
(VOLK_INIT_TEST(volk_32f_sqrt_32f, test_params))
(VOLK_INIT_TEST(volk_32f_s32f_stddev_32f, test_params_inacc))
(VOLK_INIT_TEST(volk_32f_stddev_and_mean_32f_x2, test_params_inacc))
(VOLK_INIT_TEST(volk_32f_x2_subtract_32f, test_params))
(VOLK_INIT_TEST(volk_32f_x3_sum_of_poly_32f, test_params_inacc))
(VOLK_INIT_TEST(volk_32i_x2_and_32i, test_params))
(VOLK_INIT_TEST(volk_32i_s32f_convert_32f, test_params))
(VOLK_INIT_TEST(volk_32i_x2_or_32i, test_params))
(VOLK_INIT_TEST(volk_32f_x2_dot_prod_16i, test_params))
(VOLK_INIT_TEST(volk_64f_convert_32f, test_params))
(VOLK_INIT_TEST(volk_64f_x2_max_64f, test_params))
(VOLK_INIT_TEST(volk_64f_x2_min_64f, test_params))
(VOLK_INIT_TEST(volk_8ic_deinterleave_16i_x2, test_params))
(VOLK_INIT_TEST(volk_8ic_s32f_deinterleave_32f_x2, test_params))
(VOLK_INIT_TEST(volk_8ic_deinterleave_real_16i, test_params))
(VOLK_INIT_TEST(volk_8ic_s32f_deinterleave_real_32f, test_params))
(VOLK_INIT_TEST(volk_8ic_deinterleave_real_8i, test_params))
(VOLK_INIT_TEST(volk_8ic_x2_multiply_conjugate_16ic, test_params))
(VOLK_INIT_TEST(volk_8ic_x2_s32f_multiply_conjugate_32fc, test_params))
(VOLK_INIT_TEST(volk_8i_convert_16i, test_params))
(VOLK_INIT_TEST(volk_8i_s32f_convert_32f, test_params))
(VOLK_INIT_TEST(volk_32fc_s32fc_multiply_32fc, test_params))
(VOLK_INIT_TEST(volk_32f_s32f_multiply_32f, test_params))
(VOLK_INIT_TEST(volk_32f_binary_slicer_32i, test_params))
(VOLK_INIT_TEST(volk_32f_binary_slicer_8i, test_params))
(VOLK_INIT_TEST(volk_32f_tanh_32f, test_params))
// no one uses these, so don't test them
//VOLK_PROFILE(volk_16i_x5_add_quad_16i_x4, 1e-4, 2046, 10000, &results, benchmark_mode, kernel_regex);
//VOLK_PROFILE(volk_16i_branch_4_state_8, 1e-4, 2046, 10000, &results, benchmark_mode, kernel_regex);
//VOLK_PROFILE(volk_16i_max_star_16i, 0, 0, 204602, 10000, &results, benchmark_mode, kernel_regex);
//VOLK_PROFILE(volk_16i_max_star_horizontal_16i, 0, 0, 204602, 10000, &results, benchmark_mode, kernel_regex);
//VOLK_PROFILE(volk_16i_permute_and_scalar_add, 1e-4, 0, 2046, 10000, &results, benchmark_mode, kernel_regex);
//VOLK_PROFILE(volk_16i_x4_quad_max_star_16i, 1e-4, 0, 2046, 10000, &results, benchmark_mode, kernel_regex);
// we need a puppet for this one
//(VOLK_INIT_TEST(volk_32fc_s32f_x2_power_spectral_density_32f, test_params))

;


return test_cases;
}
49 changes: 19 additions & 30 deletions lib/qa_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <boost/foreach.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/tokenizer.hpp>
#include <boost/xpressive/xpressive.hpp>
#include <iostream>
#include <fstream>
#include <vector>
Expand Down Expand Up @@ -217,19 +216,6 @@ inline void run_cast_test3_s32fc(volk_fn_3arg_s32fc func, std::vector<void *> &b
while(iter--) func(buffs[0], buffs[1], buffs[2], scalar, vlen, arch.c_str());
}

// This function is a nop that helps resolve GNU Radio bugs 582 and 583.
// Without this the cast in run_volk_tests for tol_i = static_cast<int>(float tol)
// won't happen on armhf (reported on cortex A9 and A15).
void lv_force_cast_hf( int tol_i, float tol_f)
{
int diff_i = 1;
float diff_f = 1;
if( diff_i > tol_i )
std::cout << "" ;
if( diff_f > tol_f )
std::cout << "" ;
}

template <class t>
bool fcompare(t *in1, t *in2, unsigned int vlen, float tol) {
bool fail = false;
Expand Down Expand Up @@ -323,6 +309,19 @@ class volk_qa_aligned_mem_pool{
private: std::vector<void * > _mems;
};

bool run_volk_tests(volk_func_desc_t desc,
void (*manual_func)(),
std::string name,
volk_test_params_t test_params,
std::vector<volk_test_results_t> *results,
std::string puppet_master_name
)
{
return run_volk_tests(desc, manual_func, name, test_params.tol(), test_params.scalar(),
test_params.vlen(), test_params.iter(), results, puppet_master_name,
test_params.benchmark_mode(), test_params.kernel_regex());
}

bool run_volk_tests(volk_func_desc_t desc,
void (*manual_func)(),
std::string name,
Expand All @@ -332,31 +331,19 @@ bool run_volk_tests(volk_func_desc_t desc,
int iter,
std::vector<volk_test_results_t> *results,
std::string puppet_master_name,
bool benchmark_mode,
bool benchmark_mode,
std::string kernel_regex
) {
boost::xpressive::sregex kernel_expression = boost::xpressive::sregex::compile(kernel_regex);
if( !boost::xpressive::regex_search(name, kernel_expression) ) {
// in this case we have a regex and are only looking to test one kernel
return false;
}
if(results) {
results->push_back(volk_test_results_t());
results->push_back(volk_test_results_t());
results->back().name = name;
results->back().vlen = vlen;
results->back().iter = iter;
}
std::cout << "RUN_VOLK_TESTS: " << name << "(" << vlen << "," << iter << ")" << std::endl;

// The multiply and lv_force_cast_hf are work arounds for GNU Radio bugs 582 and 583
// The bug is the casting/assignment below do not happen, which results in false
// positives when testing for errors in fcompare and icompare.
// Since this only happens on armhf (reported for Cortex A9 and A15) combined with
// the following fixes it is suspected to be a compiler bug.
// Bug 1272024 on launchpad has been filed with Linaro GCC.
const float tol_f = tol*1.0000001;
const float tol_f = tol;
const unsigned int tol_i = static_cast<const unsigned int>(tol);
lv_force_cast_hf( tol_i, tol_f );

//first let's get a list of available architectures for the test
std::vector<std::string> arch_list = get_arch_list(desc);
Expand Down Expand Up @@ -401,7 +388,9 @@ bool run_volk_tests(volk_func_desc_t desc,
arch_buffs.push_back(mem_pool.get_new(vlen*outputsig[j].size*(outputsig[j].is_complex ? 2 : 1)));
}
for(size_t j=0; j<inputsig.size(); j++) {
arch_buffs.push_back(inbuffs[j]);
void *arch_inbuff = mem_pool.get_new(vlen*inputsig[j].size*(inputsig[j].is_complex ? 2 : 1));
memcpy(arch_inbuff, inbuffs[j], vlen * inputsig[j].size * (inputsig[j].is_complex ? 2 : 1));
arch_buffs.push_back(arch_inbuff);
}
test_data.push_back(arch_buffs);
}
Expand Down
Loading

0 comments on commit 9a5e290

Please sign in to comment.