From 0ddea14c57130e18bdb7d41e24bd3be7f354ac5a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 2 Jul 2016 13:34:00 +0200 Subject: [PATCH 1/4] Add automatic profiling after make --- .../volk_gnsssdr/CMakeLists.txt | 27 +++++++++++++++++ .../volk_gnsssdr/apps/CMakeLists.txt | 19 ++++++++++-- .../volk_gnsssdr/apps/volk_gnsssdr_profile.cc | 30 ++++++++++++++++++- .../volk_gnsssdr/apps/volk_gnsssdr_profile.h | 2 ++ .../volk_gnsssdr/lib/volk_gnsssdr_prefs.c | 10 +++++++ 5 files changed, 84 insertions(+), 4 deletions(-) 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) From d92b3598d74d19ae4beaaa7ff0d1294feab43106 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 2 Jul 2016 18:54:39 +0200 Subject: [PATCH 2/4] Add option to launch volk_gnssssdr_profile after build --- CMakeLists.txt | 2 ++ .../libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt | 5 +++-- .../volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt | 7 +++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d284ee848..01aa8fcda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ option(ENABLE_GPERFTOOLS "Enable linking to Gperftools libraries (tcmalloc and p option(ENABLE_GPROF "Enable the use of the GNU profiler tool 'gprof'" OFF) # Acceleration +option(ENABLE_PROFILING "Enable execution of volk_gnsssdr_profile at the end of the building" OFF) option(ENABLE_OPENCL "Enable building of processing blocks implemented with OpenCL (experimental)" OFF) option(ENABLE_CUDA "Enable building of processing blocks implemented with CUDA (experimental, requires CUDA SDK)" OFF) @@ -427,6 +428,7 @@ if(NOT VOLK_GNSSSDR_FOUND) -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/volk_gnsssdr_module/install -DENABLE_STATIC_LIBS=ON + -DENABLE_PROFILING=${ENABLE_PROFILING} -DCMAKE_CXX_FLAGS=${CXX_FLAGS} -DCMAKE_C_FLAGS=${C_FLAGS} ${STRIP_VOLK_GNSSSDR_PROFILE} 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 c5a737f43..7897ac81b 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -265,8 +265,9 @@ 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) +if(ENABLE_STATIC_LIBS) + set(ENABLE_STATIC_LIBS ON) + 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}") 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 7a8409f46..1b5200818 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 @@ -81,23 +81,22 @@ if(ENABLE_PROFILING) 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( + +# install( # TARGETS volk_gnsssdr-config-info # DESTINATION bin # COMPONENT "volk_gnsssdr" -#) +# ) From 8cdcbb17d1dc99ba6bcc65d931903a87081210fb Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 2 Jul 2016 19:14:05 +0200 Subject: [PATCH 3/4] Fix typo --- .../libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7897ac81b..f78e3b26d 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -265,7 +265,7 @@ 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_STATIC_LIBS) +if(ENABLE_PROFILING) set(ENABLE_STATIC_LIBS ON) if(DEFINED VOLK_CONFIGPATH) get_filename_component(VOLK_CONFIGPATH ${VOLK_CONFIGPATH} ABSOLUTE) From 512e2992e90d8fb85133158527840a9052520e4a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 2 Jul 2016 19:24:48 +0200 Subject: [PATCH 4/4] Document ENABLE_PROFILING option --- .../libs/volk_gnsssdr_module/volk_gnsssdr/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/README.md b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/README.md index c7b520fc9..5471f26a8 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/README.md +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/README.md @@ -40,11 +40,21 @@ $ volk_gnsssdr_profile From now on, GNSS-SDR (and any other program of your own that makes use of VOLK_GNSSSDR) will benefit from the acceleration provided by SIMD instructions available in your processor. +The execution of ```volk_gnsssdr_profile``` can be set automatically after building, leaving your system ready to use: + +~~~~~~ +$ cmake -DENABLE_PROFILING=ON ../ +$ make +$ sudo make install +~~~~~~ + + This figure shows the role of some VOLK_GNSSSDR kernels in the context of a GNSS baseband processor: ![Example of VOLK_GNSSSDR usage.](./docs/images/VOLK_GNSSSDR_Usage_Example.png) + If you use VOLK_GNSSSDR in your research and/or software, please cite the following paper: * C. Fernández-Prades, J. Arribas, P. Closas, *Accelerating GNSS Software Receivers*, in Proc. of the ION GNSS+ 2016 Conference, Portland, Oregon, Sept. 12-16, 2016.