[hamradio-commits] [gnss-sdr] 03/16: Add automatic profiling after make

Carles Fernandez carles_fernandez-guest at moszumanska.debian.org
Mon Jul 4 17:33:13 UTC 2016


This is an automated email from the git hooks/post-receive script.

carles_fernandez-guest pushed a commit to branch master
in repository gnss-sdr.

commit 0ddea14c57130e18bdb7d41e24bd3be7f354ac5a
Author: Carles Fernandez <carles.fernandez at gmail.com>
Date:   Sat Jul 2 13:34:00 2016 +0200

    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 cdf9d95..c5a737f 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 417cb9e..7a8409f 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 30a3c79..a881d45 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<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()))
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 357b02f..4530c6b 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<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);
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 02bce75..b77aed4 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)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/gnss-sdr.git



More information about the pkg-hamradio-commits mailing list