Add automatic profiling after make

This commit is contained in:
Carles Fernandez 2016-07-02 13:34:00 +02:00
parent a0bc6d7472
commit 0ddea14c57
5 changed files with 84 additions and 4 deletions

View File

@ -260,6 +260,33 @@ else()
endif()
message(STATUS " Modify using: -DENABLE_TESTING=ON/OFF")
########################################################################
# Option to enable post-build profiling using volk_profile, off by default
########################################################################
OPTION(ENABLE_PROFILING "Launch system profiler after build" OFF)
if(ENABLE_PROFILING)
if(DEFINED VOLK_CONFIGPATH)
get_filename_component(VOLK_CONFIGPATH ${VOLK_CONFIGPATH} ABSOLUTE)
set(VOLK_CONFIGPATH "${VOLK_CONFIGPATH}/volk_gnsssdr")
message(STATUS "System profiling is enabled, using path: ${VOLK_CONFIGPATH}")
elseif(DEFINED ENV{VOLK_CONFIGPATH})
set(VOLK_CONFIGPATH "$ENV{VOLK_CONFIGPATH}/volk_gnsssdr")
message(STATUS "System profiling is enabled, using env path: $ENV{VOLK_CONFIGPATH}")
else()
message(STATUS "System profiling is enabled with default paths.")
if(DEFINED ENV{HOME})
set(VOLK_CONFIGPATH "$ENV{HOME}/.volk_gnsssdr")
elseif(DEFINED ENV{APPDATA})
set(VOLK_CONFIGPATH "$ENV{APPDATA}/.volk_gnsssdr")
endif()
endif()
else()
message(STATUS "System profiling is disabled.")
endif()
message(STATUS " Modify using: -DENABLE_PROFILING=ON/OFF")
########################################################################
########################################################################
# Setup the library
########################################################################

View File

@ -75,13 +75,26 @@ install(
COMPONENT "volk_gnsssdr"
)
# Launch volk_gnsssdr_profile if requested to do so
if(ENABLE_PROFILING)
if(DEFINED VOLK_CONFIGPATH)
set( VOLK_CONFIG_ARG "-p${VOLK_CONFIGPATH}" )
set( VOLK_CONFIG "${VOLK_CONFIGPATH}/volk_gnsssdr_config" )
endif()
message("++++++++++++++ ${VOLK_CONFIG}")
add_custom_command(OUTPUT ${VOLK_CONFIG}
COMMAND volk_gnsssdr_profile "${VOLK_CONFIG_ARG}"
DEPENDS volk_gnsssdr_profile
COMMENT "Launching profiler, this may take a few minutes..."
)
add_custom_target(volk-gnsssdr-profile-run ALL DEPENDS ${VOLK_CONFIG})
# target_link_libraries(volk-gnsssdr-profile-run volk_gnsssdr ${Boost_LIBRARIES} ${Clang_required_link} ${orc_lib})
endif()
# MAKE volk_gnsssdr-config-info
add_executable(volk_gnsssdr-config-info volk_gnsssdr-config-info.cc)
target_link_libraries(volk_gnsssdr-config-info volk_gnsssdr ${Boost_LIBRARIES} ${Clang_required_link} ${orc_lib})
add_dependencies(volk_gnsssdr-config-info volk_gnsssdr)
#install(
# TARGETS volk_gnsssdr-config-info
# DESTINATION bin

View File

@ -67,6 +67,9 @@ int main(int argc, char *argv[]) {
("json,j",
boost::program_options::value<std::string>(),
"JSON output file")
("path,p",
boost::program_options::value<std::string>(),
"Specify volk_config path.")
;
// Handle the options that were given
@ -82,6 +85,7 @@ int main(int argc, char *argv[]) {
std::string def_kernel_regex;
bool update_mode = false;
bool dry_run = false;
std::string config_file;
// Handle the provided options
try {
@ -129,6 +133,16 @@ int main(int argc, char *argv[]) {
json_file.open( filename.c_str() );
}
if ( vm.count("path") ) {
try {
config_file = vm["path"].as<std::string>() + "/volk_config";
}
catch (boost::bad_any_cast& error) {
std::cerr << error.what() << std::endl;
return 1;
}
}
volk_gnsssdr_test_params_t test_params(def_tol, def_scalar, def_vlen, def_iter,
def_benchmark_mode, def_kernel_regex);
@ -136,6 +150,8 @@ int main(int argc, char *argv[]) {
std::vector<volk_gnsssdr_test_results_t> results;
if(update_mode) {
read_results(&results);
if( vm.count("path") ) read_results(&results, config_file);
else read_results(&results);
}
@ -198,6 +214,8 @@ int main(int argc, char *argv[]) {
if(!dry_run) {
write_results(&results, false);
if(vm.count("path")) write_results(&results, false, config_file);
else write_results(&results, false);
}
else {
std::cout << "Warning: this was a dry-run. Config not generated" << std::endl;
@ -208,6 +226,12 @@ void read_results(std::vector<volk_gnsssdr_test_results_t> *results)
{
char path[1024];
volk_gnsssdr_get_config_path(path);
read_results(results, std::string(path));
}
void read_results(std::vector<volk_gnsssdr_test_results_t> *results, std::string path)
{
const fs::path config_path(path);
if(fs::exists(config_path)) {
@ -260,8 +284,12 @@ void write_results(const std::vector<volk_gnsssdr_test_results_t> *results, bool
char path[1024];
volk_gnsssdr_get_config_path(path);
const fs::path config_path(path);
write_results( results, update_result, std::string(path));
}
void write_results(const std::vector<volk_gnsssdr_test_results_t> *results, bool update_result, const std::string path)
{
const fs::path config_path(path);
// Until we can update the config on a kernel by kernel basis
// do not overwrite volk_gnsssdr_config when using a regex.
if (not fs::exists(config_path.branch_path()))

View File

@ -30,5 +30,7 @@
void read_results(std::vector<volk_gnsssdr_test_results_t> *results);
void read_results(std::vector<volk_gnsssdr_test_results_t> *results, std::string path);
void write_results(const std::vector<volk_gnsssdr_test_results_t> *results, bool update_result);
void write_results(const std::vector<volk_gnsssdr_test_results_t> *results, bool update_result, const std::string path);
void write_json(std::ofstream &json_file, std::vector<volk_gnsssdr_test_results_t> results);

View File

@ -26,7 +26,17 @@ void volk_gnsssdr_get_config_path(char *path)
{
if (!path) return;
const char *suffix = "/.volk_gnsssdr/volk_gnsssdr_config";
const char *suffix2 = "/volk_gnsssdr/volk_gnsssdr_config"; //non-hidden
char *home = NULL;
//allows config redirection via env variable
home = getenv("VOLK_CONFIGPATH");
if(home!=NULL){
strncpy(path,home,512);
strcat(path,suffix2);
return;
}
if (home == NULL) home = getenv("HOME");
if (home == NULL) home = getenv("APPDATA");
if (home == NULL)