[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 04/22: volk: add feature for json results e
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 04/22: volk: add feature for json results export |
Date: |
Wed, 24 Sep 2014 22:07:38 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit bedc76d1de550b91907f57b02e50e3f2cf821b0b
Author: Nathan West <address@hidden>
Date: Fri Sep 19 14:34:21 2014 -0400
volk: add feature for json results export
---
volk/apps/volk_profile.cc | 61 ++++++++++++++++++++++++++++++++++++++++++++---
volk/lib/qa_utils.cc | 32 ++++++++++++++++++-------
volk/lib/qa_utils.h | 43 +++++++++++++++++++++++++++++++--
3 files changed, 123 insertions(+), 13 deletions(-)
diff --git a/volk/apps/volk_profile.cc b/volk/apps/volk_profile.cc
index 1dd0f9b..4168847 100644
--- a/volk/apps/volk_profile.cc
+++ b/volk/apps/volk_profile.cc
@@ -37,6 +37,49 @@
namespace fs = boost::filesystem;
+void write_json(std::ofstream &json_file, std::vector<volk_test_results_t>
results) {
+ json_file << "{" << std::endl;
+ json_file << " \"volk_tests\": [" << std::endl;
+ size_t len = results.size();
+ size_t i = 0;
+ BOOST_FOREACH(volk_test_results_t &result, results) {
+ json_file << " {" << std::endl;
+ json_file << " \"name\": \"" << result.name << "\"," << std::endl;
+ json_file << " \"vlen\": " << result.vlen << "," << std::endl;
+ json_file << " \"iter\": " << result.iter << "," << std::endl;
+ json_file << " \"best_arch_a\": \"" << result.best_arch_a
+ << "\"," << std::endl;
+ json_file << " \"best_arch_u\": \"" << result.best_arch_u
+ << "\"," << std::endl;
+ json_file << " \"results\": {" << std::endl;
+ size_t results_len = result.results.size();
+ size_t ri = 0;
+ typedef std::pair<std::string, volk_test_time_t> tpair;
+ BOOST_FOREACH(tpair pair, result.results) {
+ volk_test_time_t time = pair.second;
+ json_file << " \"" << time.name << "\": {" << std::endl;
+ json_file << " \"name\": \"" << time.name << "\"," <<
std::endl;
+ json_file << " \"time\": " << time.time << "," << std::endl;
+ json_file << " \"units\": \"" << time.units << "\"" <<
std::endl;
+ json_file << " }" ;
+ if(ri+1 != results_len) {
+ json_file << ",";
+ }
+ json_file << std::endl;
+ ri++;
+ }
+ json_file << " }" << std::endl;
+ json_file << " }";
+ if(i+1 != len) {
+ json_file << ",";
+ }
+ json_file << std::endl;
+ i++;
+ }
+ json_file << " ]" << std::endl;
+ json_file << "}" << std::endl;
+}
+
int main(int argc, char *argv[]) {
// Adding program options
boost::program_options::options_description desc("Options");
@@ -49,6 +92,9 @@ int main(int argc, char *argv[]) {
("tests-regex,R",
boost::program_options::value<std::string>(),
"Run tests matching regular expression.")
+ ("json,j",
+ boost::program_options::value<std::string>(),
+ "JSON output file")
;
// Handle the options that were given
@@ -56,6 +102,8 @@ int main(int argc, char *argv[]) {
bool benchmark_mode;
std::string kernel_regex;
bool store_results = true;
+ std::ofstream json_file;
+
try {
boost::program_options::store(boost::program_options::parse_command_line(argc,
argv, desc), vm);
boost::program_options::notify(vm);
@@ -83,9 +131,14 @@ int main(int argc, char *argv[]) {
return 0;
}
+ if ( vm.count("json") )
+ {
+ json_file.open( vm["json"].as<std::string>().c_str() );
+ }
+
// Run tests
- std::vector<std::string> results;
+ std::vector<volk_test_results_t> results;
//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);
@@ -205,8 +258,10 @@ int main(int argc, char *argv[]) {
#the function name is followed by the preferred architecture.\n\
";
- BOOST_FOREACH(std::string result, results) {
- config << result << std::endl;
+ BOOST_FOREACH(volk_test_results_t result, results) {
+ config << result.config_name << " "
+ << result.best_arch_a << " "
+ << result.best_arch_u << std::endl;
}
config.close();
}
diff --git a/volk/lib/qa_utils.cc b/volk/lib/qa_utils.cc
index f30f009..3ab4a99 100644
--- a/volk/lib/qa_utils.cc
+++ b/volk/lib/qa_utils.cc
@@ -5,7 +5,9 @@
#include <boost/tokenizer.hpp>
#include <boost/xpressive/xpressive.hpp>
#include <iostream>
+#include <fstream>
#include <vector>
+#include <map>
#include <list>
#include <ctime>
#include <cmath>
@@ -328,9 +330,9 @@ bool run_volk_tests(volk_func_desc_t desc,
lv_32fc_t scalar,
int vlen,
int iter,
- std::vector<std::string> *best_arch_vector = 0,
- std::string puppet_master_name = "NULL",
- bool benchmark_mode,
+ std::vector<volk_test_results_t> *results,
+ std::string puppet_master_name,
+ bool benchmark_mode,
std::string kernel_regex
) {
boost::xpressive::sregex kernel_expression =
boost::xpressive::sregex::compile(kernel_regex);
@@ -338,6 +340,12 @@ bool run_volk_tests(volk_func_desc_t desc,
// 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->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
@@ -453,6 +461,13 @@ bool run_volk_tests(volk_func_desc_t desc,
end = clock();
double arch_time = 1000.0 * (double)(end-start)/(double)CLOCKS_PER_SEC;
std::cout << arch_list[i] << " completed in " << arch_time << "ms" <<
std::endl;
+ if(results) {
+ volk_test_time_t result;
+ result.name = arch_list[i];
+ result.time = arch_time;
+ result.units = "ms";
+ results->back().results[result.name] = result;
+ }
profile_times.push_back(arch_time);
}
@@ -553,13 +568,14 @@ bool run_volk_tests(volk_func_desc_t desc,
std::cout << "Best aligned arch: " << best_arch_a << std::endl;
std::cout << "Best unaligned arch: " << best_arch_u << std::endl;
- if(best_arch_vector) {
+ if(results) {
if(puppet_master_name == "NULL") {
- best_arch_vector->push_back(name + " " + best_arch_a + " " +
best_arch_u);
- }
- else {
- best_arch_vector->push_back(puppet_master_name + " " + best_arch_a
+ " " + best_arch_u);
+ results->back().config_name = name;
+ } else {
+ results->back().config_name = puppet_master_name;
}
+ results->back().best_arch_a = best_arch_a;
+ results->back().best_arch_u = best_arch_u;
}
return fail_global;
diff --git a/volk/lib/qa_utils.h b/volk/lib/qa_utils.h
index fc1a023..7ca8b8d 100644
--- a/volk/lib/qa_utils.h
+++ b/volk/lib/qa_utils.h
@@ -3,7 +3,10 @@
#include <cstdlib>
#include <string>
+#include <iostream>
+#include <fstream>
#include <vector>
+#include <map>
#include <volk/volk.h>
#include <volk/volk_common.h>
@@ -21,10 +24,46 @@ volk_type_t volk_type_from_string(std::string);
float uniform(void);
void random_floats(float *buf, unsigned n);
-bool run_volk_tests(volk_func_desc_t, void(*)(), std::string, float,
lv_32fc_t, int, int, std::vector<std::string> *, std::string, bool
benchmark_mode=false, std::string kernel_regex="");
+class volk_test_time_t {
+ public:
+ std::string name;
+ double time;
+ std::string units;
+};
+
+class volk_test_results_t {
+ public:
+ std::string name;
+ std::string config_name;
+ int vlen;
+ int iter;
+ std::map<std::string, volk_test_time_t> results;
+ std::string best_arch_a;
+ std::string best_arch_u;
+};
+
+bool run_volk_tests(
+ volk_func_desc_t,
+ void(*)(),
+ std::string,
+ float,
+ lv_32fc_t,
+ int,
+ int,
+ std::vector<volk_test_results_t> *results = NULL,
+ std::string puppet_master_name = "NULL",
+ bool benchmark_mode=false,
+ std::string kernel_regex=""
+ );
-#define VOLK_RUN_TESTS(func, tol, scalar, len, iter)
BOOST_AUTO_TEST_CASE(func##_test) {
BOOST_CHECK_EQUAL(run_volk_tests(func##_get_func_desc(), (void
(*)())func##_manual, std::string(#func), tol, scalar, len, iter, 0, "NULL"),
0); }
+#define VOLK_RUN_TESTS(func, tol, scalar, len, iter) \
+ BOOST_AUTO_TEST_CASE(func##_test) { \
+ BOOST_CHECK_EQUAL(run_volk_tests( \
+ func##_get_func_desc(), (void (*)())func##_manual, \
+ std::string(#func), tol, scalar, len, iter, 0, "NULL"), \
+ 0); \
+ }
#define VOLK_PROFILE(func, tol, scalar, len, iter, results, bnmode,
kernel_regex) run_volk_tests(func##_get_func_desc(), (void (*)())func##_manual,
std::string(#func), tol, scalar, len, iter, results, "NULL", bnmode,
kernel_regex)
#define VOLK_PUPPET_PROFILE(func, puppet_master_func, tol, scalar, len, iter,
results, bnmode, kernel_regex) run_volk_tests(func##_get_func_desc(), (void
(*)())func##_manual, std::string(#func), tol, scalar, len, iter, results,
std::string(#puppet_master_func), bnmode, kernel_regex)
typedef void (*volk_fn_1arg)(void *, unsigned int, const char*); //one input,
operate in place
- [Commit-gnuradio] [gnuradio] branch master updated (6e12074 -> fd0955f), git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 04/22: volk: add feature for json results export,
git <=
- [Commit-gnuradio] [gnuradio] 03/22: Fix CMake abuse for assembly (.s) files, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 02/22: blocks: make tagged stream to pdu output optional, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 08/22: Fix prune_tags, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 01/22: Add vector support to abs block. Remove unused num_inputs from xml., git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 05/22: blocks: Added callback to vector source GRC bindings, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 07/22: Fix(?) prune_tags: needs verification, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 15/22: digital: clock recovery fix relative limit, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 21/22: Merge branch 'master' of git.gnuradio.org:gnuradio, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 13/22: fec: turning off some debug output., git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 10/22: Formatting fix-ups, git, 2014/09/24