diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index cdf9d9553..c5a737f43 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -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 ######################################################################## diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt index 417cb9efa..7a8409f46 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt @@ -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 diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc index 30a3c7953..a881d4572 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc @@ -67,6 +67,9 @@ int main(int argc, char *argv[]) { ("json,j", boost::program_options::value(), "JSON output file") + ("path,p", + boost::program_options::value(), + "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() + "/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 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 *results) { char path[1024]; volk_gnsssdr_get_config_path(path); + + read_results(results, std::string(path)); +} + +void read_results(std::vector *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 *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 *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())) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.h index 357b02f7a..4530c6be7 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.h @@ -30,5 +30,7 @@ void read_results(std::vector *results); +void read_results(std::vector *results, std::string path); void write_results(const std::vector *results, bool update_result); +void write_results(const std::vector *results, bool update_result, const std::string path); void write_json(std::ofstream &json_file, std::vector results); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_prefs.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_prefs.c index 02bce75f3..b77aed467 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_prefs.c +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_prefs.c @@ -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)