1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 12:40:35 +00:00

Add option for volk_gnsssdr_profile execution after build

This commit is contained in:
Carles Fernandez 2016-07-02 19:27:56 +02:00
commit 2ec5479d6e
7 changed files with 97 additions and 5 deletions

View File

@ -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}

View File

@ -260,6 +260,34 @@ 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)
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}")
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

@ -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.

View File

@ -75,16 +75,28 @@ 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()
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})
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"
#)
# )

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)