mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-30 23:03:05 +00:00 
			
		
		
		
	Merge branch 'next' into fix_bug
This commit is contained in:
		| @@ -479,7 +479,7 @@ set(Boost_ADDITIONAL_VERSIONS | ||||
| ) | ||||
| set(Boost_USE_MULTITHREAD ON) | ||||
| set(Boost_USE_STATIC_LIBS OFF) | ||||
| find_package(Boost COMPONENTS date_time system filesystem thread serialization chrono unit_test_framework program_options REQUIRED) | ||||
| find_package(Boost COMPONENTS date_time system filesystem thread serialization chrono REQUIRED) | ||||
| if(NOT Boost_FOUND) | ||||
|      message(FATAL_ERROR "Fatal error: Boost (version >=${GNSSSDR_BOOST_MIN_VERSION}) required.") | ||||
| endif(NOT Boost_FOUND) | ||||
| @@ -1227,9 +1227,9 @@ else(DOXYGEN_FOUND) | ||||
|      message(STATUS " Get it from http://www.stack.nl/~dimitri/doxygen/index.html") | ||||
|      if(OS_IS_LINUX) | ||||
|          if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") | ||||
|              message(" or simply by doing 'sudo yum install doxygen-latex'.") | ||||
|              message(STATUS " or simply by doing 'sudo yum install doxygen-latex'.") | ||||
|          else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") | ||||
|              message(" or simply by doing 'sudo apt-get install doxygen-latex'.") | ||||
|              message(STATUS " or simply by doing 'sudo apt-get install doxygen-latex'.") | ||||
|          endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") | ||||
|      endif(OS_IS_LINUX) | ||||
|      if(OS_IS_MACOSX) | ||||
|   | ||||
| @@ -58,10 +58,9 @@ If you want to start building and running GNSS-SDR as quick and easy as possible | ||||
| ~~~~~~ | ||||
| $ sudo apt-get install build-essential cmake git libboost-dev libboost-date-time-dev \ | ||||
|        libboost-system-dev libboost-filesystem-dev libboost-thread-dev libboost-chrono-dev \ | ||||
|        libboost-serialization-dev libboost-program-options-dev libboost-test-dev \ | ||||
|        liblog4cpp5-dev libuhd-dev gnuradio-dev gr-osmosdr libblas-dev liblapack-dev \ | ||||
|        libarmadillo-dev libgflags-dev libgoogle-glog-dev libgnutls-openssl-dev \ | ||||
|        python-mako python-six libmatio-dev googletest | ||||
|        libboost-serialization-dev liblog4cpp5-dev libuhd-dev gnuradio-dev gr-osmosdr \ | ||||
|        libblas-dev liblapack-dev libarmadillo-dev libgflags-dev libgoogle-glog-dev \ | ||||
|        libgnutls-openssl-dev python-mako python-six libmatio-dev googletest | ||||
| ~~~~~~ | ||||
|  | ||||
| Please note that `googletest` was named `libgtest-dev` in distributions older than Debian 9 Stretch and Ubuntu 17.04 Zesty. | ||||
|   | ||||
| @@ -136,6 +136,10 @@ pcps_acquisition::pcps_acquisition( | ||||
|         { | ||||
|             d_data_buffer_sc = static_cast<lv_16sc_t*>(volk_gnsssdr_malloc(d_fft_size * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment())); | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|             d_data_buffer_sc = nullptr; | ||||
|         } | ||||
|     grid_ = arma::fmat(); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1117,7 +1117,7 @@ HTML_STYLESHEET        = | ||||
| # defined cascading style sheet that is included after the standard style sheets | ||||
| # created by doxygen. Using this option one can overrule certain style aspects. | ||||
| # This is preferred over using HTML_STYLESHEET since it does not replace the | ||||
| # standard style sheet and is therefor more robust against future updates. | ||||
| # standard style sheet and is therefore more robust against future updates. | ||||
| # Doxygen will copy the style sheet file to the output directory. For an example | ||||
| # see the documentation. | ||||
| # This tag requires that the tag GENERATE_HTML is set to YES. | ||||
| @@ -2008,7 +2008,7 @@ PREDEFINED             = LV_HAVE_GENERIC \ | ||||
| EXPAND_AS_DEFINED      = | ||||
|  | ||||
| # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will | ||||
| # remove all refrences to function-like macros that are alone on a line, have an | ||||
| # remove all references to function-like macros that are alone on a line, have an | ||||
| # all uppercase name, and do not end with a semicolon. Such function macros are | ||||
| # typically used for boiler-plate code, and will confuse the parser if not | ||||
| # removed. | ||||
|   | ||||
| @@ -46,7 +46,7 @@ machine: | ||||
|  | ||||
| ~~~~~~  | ||||
| $ sudo apt-get install cmake python-mako python-six libboost-dev \ | ||||
|   libboost-filesystem-dev libboost-system-dev libboost-program-options-dev | ||||
|   libboost-filesystem-dev libboost-system-dev | ||||
| ~~~~~~  | ||||
|  | ||||
| In order to build and install the library, go to the base folder of the | ||||
|   | ||||
| @@ -63,6 +63,7 @@ endif(UNIX) | ||||
| add_executable(volk_gnsssdr_profile | ||||
|     ${CMAKE_CURRENT_SOURCE_DIR}/volk_gnsssdr_profile.cc | ||||
|     ${PROJECT_SOURCE_DIR}/lib/qa_utils.cc | ||||
|     ${CMAKE_CURRENT_SOURCE_DIR}/volk_gnsssdr_option_helpers.cc | ||||
| ) | ||||
|  | ||||
| if(ENABLE_STATIC_LIBS) | ||||
| @@ -87,26 +88,13 @@ 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) | ||||
| add_executable(volk_gnsssdr-config-info volk_gnsssdr-config-info.cc ${CMAKE_CURRENT_SOURCE_DIR}/volk_gnsssdr_option_helpers.cc) | ||||
| if(ENABLE_STATIC_LIBS) | ||||
|    target_link_libraries(volk_gnsssdr-config-info volk_gnsssdr_static ${Boost_LIBRARIES} ${Clang_required_link} ${orc_lib}) | ||||
|    target_link_libraries(volk_gnsssdr-config-info volk_gnsssdr_static ${Clang_required_link} ${orc_lib}) | ||||
| else(ENABLE_STATIC_LIBS) | ||||
|    target_link_libraries(volk_gnsssdr-config-info volk_gnsssdr ${Boost_LIBRARIES} ${Clang_required_link} ${orc_lib}) | ||||
|    target_link_libraries(volk_gnsssdr-config-info volk_gnsssdr ${Clang_required_link} ${orc_lib}) | ||||
|    add_dependencies(volk_gnsssdr-config-info volk_gnsssdr) | ||||
| endif(ENABLE_STATIC_LIBS) | ||||
|  | ||||
| @@ -123,3 +111,20 @@ 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() | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| /* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) | ||||
| /* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) | ||||
|  * | ||||
|  * This file is part of GNSS-SDR. | ||||
|  * | ||||
| @@ -22,86 +22,53 @@ | ||||
|  | ||||
| #include <volk_gnsssdr/constants.h> | ||||
| #include "volk_gnsssdr/volk_gnsssdr.h" | ||||
| #include <boost/program_options.hpp> | ||||
| #include <iostream> | ||||
| #include "volk_gnsssdr_option_helpers.h" | ||||
|  | ||||
| namespace po = boost::program_options; | ||||
|  | ||||
| int | ||||
| main(int argc, char **argv) | ||||
| void print_alignment() | ||||
| { | ||||
|   po::options_description desc("Program options: volk_gnsssdr-config-info [options]"); | ||||
|   po::variables_map vm; | ||||
|  | ||||
|   desc.add_options() | ||||
|     ("help,h", "print help message") | ||||
|     ("prefix", "print VOLK_GNSSSDR installation prefix") | ||||
|     ("cc", "print VOLK_GNSSSDR C compiler version") | ||||
|     ("cflags", "print VOLK_GNSSSDR CFLAGS") | ||||
|     ("all-machines", "print VOLK_GNSSSDR machines built into library") | ||||
|     ("avail-machines", "print VOLK_GNSSSDR machines the current platform can use") | ||||
|     ("machine", "print the VOLK_GNSSSDR machine that will be used") | ||||
|     ("alignment", "print the alignment that will be used") | ||||
|     ("malloc", "print malloc implementation that will be used") | ||||
|     ("version,v", "print VOLK_GNSSSDR version") | ||||
|     ; | ||||
|  | ||||
|   try { | ||||
|     po::store(po::parse_command_line(argc, argv, desc), vm); | ||||
|     po::notify(vm); | ||||
|   } | ||||
|   catch (po::error& error){ | ||||
|     std::cerr << "Error: " << error.what() << std::endl << std::endl; | ||||
|     std::cerr << desc << std::endl; | ||||
|     return 1; | ||||
|   } | ||||
|  | ||||
|   if(vm.size() == 0 || vm.count("help")) { | ||||
|     std::cout << desc << std::endl; | ||||
|     return 1; | ||||
|   } | ||||
|  | ||||
|   if(vm.count("prefix")) | ||||
|     std::cout << volk_gnsssdr_prefix() << std::endl; | ||||
|  | ||||
|   if(vm.count("version")) | ||||
|     std::cout << volk_gnsssdr_version() << std::endl; | ||||
|  | ||||
|   if(vm.count("cc")) | ||||
|     std::cout << volk_gnsssdr_c_compiler() << std::endl; | ||||
|  | ||||
|   if(vm.count("cflags")) | ||||
|     std::cout << volk_gnsssdr_compiler_flags() << std::endl; | ||||
|  | ||||
|   // stick an extra ';' to make output of this and avail-machines the | ||||
|   // same structure for easier parsing | ||||
|   if(vm.count("all-machines")) | ||||
|     std::cout << volk_gnsssdr_available_machines() << ";" << std::endl; | ||||
|  | ||||
|   if(vm.count("avail-machines")) { | ||||
|     volk_gnsssdr_list_machines(); | ||||
|   } | ||||
|  | ||||
|   if(vm.count("machine")) { | ||||
|     std::cout << volk_gnsssdr_get_machine() << std::endl; | ||||
|   } | ||||
|  | ||||
|   if(vm.count("alignment")) { | ||||
|       std::cout << "Alignment in bytes: " << volk_gnsssdr_get_alignment() << std::endl; | ||||
|    } | ||||
|  | ||||
|    // You don't want to change the volk_malloc code, so just copy the if/else | ||||
|    // structure from there and give an explanation for the implementations | ||||
|    if(vm.count("malloc")) { | ||||
|      std::cout << "Used malloc implementation: "; | ||||
|  #if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || HAVE_POSIX_MEMALIGN | ||||
|      std::cout << "posix_memalign" << std::endl; | ||||
|  #elif _MSC_VER >= 1400 | ||||
|      std::cout << "aligned_malloc" << std::endl; | ||||
|  #else | ||||
|      std::cout << "No standard handler available, using own implementation." << std::endl; | ||||
|  #endif | ||||
|    } | ||||
|  | ||||
|   return 0; | ||||
|   std::cout << "Alignment in bytes: " << volk_gnsssdr_get_alignment() << std::endl; | ||||
| } | ||||
|  | ||||
|  | ||||
| void print_malloc() | ||||
| { | ||||
|   // You don't want to change the volk_malloc code, so just copy the if/else | ||||
|   // structure from there and give an explanation for the implementations | ||||
|   std::cout << "Used malloc implementation: "; | ||||
|   #if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || HAVE_POSIX_MEMALIGN | ||||
|   std::cout << "posix_memalign" << std::endl; | ||||
|   #elif _MSC_VER >= 1400 | ||||
|   std::cout << "aligned_malloc" << std::endl; | ||||
|   #else | ||||
|       std::cout << "No standard handler available, using own implementation." << std::endl; | ||||
|   #endif | ||||
| } | ||||
|  | ||||
|  | ||||
| int main(int argc, char **argv) | ||||
| { | ||||
|     option_list our_options("volk_gnsssdr-config-info"); | ||||
|     our_options.add(option_t("prefix", "", "print the VOLK_GNSSSDR installation prefix", volk_gnsssdr_prefix())); | ||||
|     our_options.add(option_t("cc", "", "print the VOLK_GNSSDR C compiler version", volk_gnsssdr_c_compiler())); | ||||
|     our_options.add(option_t("cflags", "", "print the VOLK_GNSSSDR CFLAGS", volk_gnsssdr_compiler_flags())); | ||||
|     our_options.add(option_t("all-machines", "", "print VOLK_GNSSSDR machines built", volk_gnsssdr_available_machines())); | ||||
|     our_options.add(option_t("avail-machines", "", "print VOLK_GNSSSDR machines on the current " | ||||
|             "platform", volk_gnsssdr_list_machines)); | ||||
|     our_options.add(option_t("machine", "", "print the current VOLK_GNSSSDR machine that will be used", | ||||
|             volk_gnsssdr_get_machine())); | ||||
|     our_options.add(option_t("alignment", "", "print the memory alignment", print_alignment)); | ||||
|     our_options.add(option_t("malloc", "", "print the malloc implementation used in volk_gnsssdr_malloc", | ||||
|             print_malloc)); | ||||
|     our_options.add(option_t("version", "v", "print the VOLK_GNSSSDR version", volk_gnsssdr_version())); | ||||
|  | ||||
|     try | ||||
|     { | ||||
|             our_options.parse(argc, argv); | ||||
|     } | ||||
|     catch(...) | ||||
|     { | ||||
|             return 1; | ||||
|     } | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,167 @@ | ||||
| /* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) | ||||
|  * | ||||
|  * This file is part of GNSS-SDR. | ||||
|  * | ||||
|  * GNSS-SDR is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * GNSS-SDR is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU General Public License | ||||
|  * along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #include "volk_gnsssdr_option_helpers.h" | ||||
|  | ||||
| #include <iostream> | ||||
|  | ||||
| /* | ||||
|  * Option type | ||||
|  */ | ||||
| option_t::option_t(std::string longform, std::string shortform, std::string msg, void (*callback)()) | ||||
|         : longform("--" + longform), | ||||
|           shortform("-" + shortform), | ||||
|           msg(msg), | ||||
|           callback(callback) { option_type = VOID_CALLBACK; } | ||||
|  | ||||
| option_t::option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(int)) | ||||
|         : longform("--" + longform), | ||||
|           shortform("-" + shortform), | ||||
|           msg(msg), | ||||
|           callback((void (*)()) callback) { option_type = INT_CALLBACK; } | ||||
|  | ||||
| option_t::option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(float)) | ||||
|         : longform("--" + longform), | ||||
|           shortform("-" + shortform), | ||||
|           msg(msg), | ||||
|           callback((void (*)()) callback) { option_type = FLOAT_CALLBACK; } | ||||
|  | ||||
| option_t::option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(bool)) | ||||
|         : longform("--" + longform), | ||||
|           shortform("-" + shortform), | ||||
|           msg(msg), | ||||
|           callback((void (*)()) callback) { option_type = BOOL_CALLBACK; } | ||||
|  | ||||
| option_t::option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(std::string)) | ||||
|         : longform("--" + longform), | ||||
|           shortform("-" + shortform), | ||||
|           msg(msg), | ||||
|           callback((void (*)()) callback) { option_type = STRING_CALLBACK; } | ||||
|  | ||||
| option_t::option_t(std::string longform, std::string shortform, std::string msg, std::string printval) | ||||
|         : longform("--" + longform), | ||||
|           shortform("-" + shortform), | ||||
|           msg(msg), | ||||
|           printval(printval) { option_type = STRING; } | ||||
|  | ||||
|  | ||||
| /* | ||||
|  * Option List | ||||
|  */ | ||||
|  | ||||
| option_list::option_list(std::string program_name) : | ||||
|         program_name(program_name) { | ||||
|     { internal_list = std::vector<option_t>(); } | ||||
| } | ||||
|  | ||||
| void option_list::add(const option_t & opt) { internal_list.push_back(opt); } | ||||
|  | ||||
| void option_list::parse(int argc, char **argv) { | ||||
|     for (int arg_number = 0; arg_number < argc; ++arg_number) { | ||||
|         for (std::vector<option_t>::iterator this_option = internal_list.begin(); | ||||
|              this_option != internal_list.end(); | ||||
|              this_option++) { | ||||
|             if (this_option->longform == std::string(argv[arg_number]) || | ||||
|                 this_option->shortform == std::string(argv[arg_number])) { | ||||
|                 switch (this_option->option_type) { | ||||
|                     case VOID_CALLBACK: | ||||
|                         this_option->callback(); | ||||
|                         break; | ||||
|                     case INT_CALLBACK: | ||||
|                         try { | ||||
|                             int int_val = std::stoi(argv[++arg_number]); | ||||
|                             ((void (*)(int)) this_option->callback)(int_val); | ||||
|                         } catch (std::exception &exc) { | ||||
|                             std::cout << "An int option can only receive a number" << std::endl; | ||||
|                             throw std::exception(); | ||||
|                         }; | ||||
|                         break; | ||||
|                     case FLOAT_CALLBACK: | ||||
|                         try { | ||||
|                             int int_val = std::stof(argv[++arg_number]); | ||||
|                             ((void (*)(float)) this_option->callback)(int_val); | ||||
|                         } catch (std::exception &exc) { | ||||
|                             std::cout << "A float option can only receive a number" << std::endl; | ||||
|                             throw std::exception(); | ||||
|                         }; | ||||
|                         break; | ||||
|                     case BOOL_CALLBACK: | ||||
|                         try { | ||||
|                             bool int_val = (bool) std::stoi(argv[++arg_number]); | ||||
|                             ((void (*)(bool)) this_option->callback)(int_val); | ||||
|                         } catch (std::exception &exc) { | ||||
|                             std::cout << "A bool option can only receive 0 or 1" << std::endl; | ||||
|                             throw std::exception(); | ||||
|                         }; | ||||
|                         break; | ||||
|                     case STRING_CALLBACK: | ||||
|                         try { | ||||
|                             ((void (*)(std::string)) this_option->callback)(argv[++arg_number]); | ||||
|                         } catch (std::exception &exc) { | ||||
|                             throw std::exception(); | ||||
|                         }; | ||||
|                         break; | ||||
|                     case STRING: | ||||
|                         std::cout << this_option->printval << std::endl; | ||||
|                         break; | ||||
|                     default: | ||||
|                         this_option->callback(); | ||||
|                         break; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         if (std::string("--help") == std::string(argv[arg_number]) || | ||||
|             std::string("-h") == std::string(argv[arg_number])) { | ||||
|             help(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| void option_list::help() { | ||||
|     std::cout << program_name << std::endl; | ||||
|     std::cout << "  -h [ --help ] \t\tDisplay this help message" << std::endl; | ||||
|     for (std::vector<option_t>::iterator this_option = internal_list.begin(); | ||||
|          this_option != internal_list.end(); | ||||
|          this_option++) { | ||||
|         std::string help_line("  "); | ||||
|         if (this_option->shortform == "-") { | ||||
|             help_line += this_option->longform + " "; | ||||
|         } else { | ||||
|             help_line += this_option->shortform + " [ " + this_option->longform + " ]"; | ||||
|         } | ||||
|  | ||||
|         switch (help_line.size() / 8) { | ||||
|             case 0: | ||||
|                 help_line += "\t\t\t\t"; | ||||
|                 break; | ||||
|             case 1: | ||||
|                 help_line += "\t\t\t"; | ||||
|                 break; | ||||
|             case 2: | ||||
|                 help_line += "\t\t"; | ||||
|                 break; | ||||
|             case 3: | ||||
|                 help_line += "\t"; | ||||
|                 break; | ||||
|             default: | ||||
|                 break; | ||||
|         } | ||||
|         help_line += this_option->msg; | ||||
|         std::cout << help_line << std::endl; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,69 @@ | ||||
| /* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) | ||||
|  * | ||||
|  * This file is part of GNSS-SDR. | ||||
|  * | ||||
|  * GNSS-SDR is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * GNSS-SDR is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU General Public License | ||||
|  * along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #ifndef VOLK_VOLK_OPTION_HELPERS_H | ||||
| #define VOLK_VOLK_OPTION_HELPERS_H | ||||
|  | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| typedef enum | ||||
| { | ||||
|     VOID_CALLBACK, | ||||
|     INT_CALLBACK, | ||||
|     BOOL_CALLBACK, | ||||
|     STRING_CALLBACK, | ||||
|     FLOAT_CALLBACK, | ||||
|     STRING, | ||||
| } VOLK_OPTYPE; | ||||
|  | ||||
| class option_t { | ||||
| public: | ||||
|     option_t(std::string longform, std::string shortform, std::string msg, void (*callback)()); | ||||
|     option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(int)); | ||||
|     option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(float)); | ||||
|     option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(bool)); | ||||
|     option_t(std::string longform, std::string shortform, std::string msg, void (*callback)(std::string)); | ||||
|     option_t(std::string longform, std::string shortform, std::string msg, std::string printval); | ||||
|  | ||||
|     std::string longform; | ||||
|     std::string shortform; | ||||
|     std::string msg; | ||||
|     VOLK_OPTYPE option_type; | ||||
|     std::string printval; | ||||
|     void (*callback)(); | ||||
|  | ||||
| }; | ||||
|  | ||||
| class option_list | ||||
| { | ||||
| public: | ||||
|     option_list(std::string program_name); | ||||
|  | ||||
|     void add(const option_t & opt); | ||||
|  | ||||
|     void parse(int argc, char **argv); | ||||
|  | ||||
|     void help(); | ||||
| private: | ||||
|     std::string program_name; | ||||
|     std::vector<option_t> internal_list; | ||||
| }; | ||||
|  | ||||
|  | ||||
| #endif //VOLK_VOLK_OPTION_HELPERS_H | ||||
| @@ -18,215 +18,139 @@ | ||||
|  | ||||
| #include "qa_utils.h" | ||||
| #include "kernel_tests.h" | ||||
| #include "volk_gnsssdr_option_helpers.h" | ||||
| #include "volk_gnsssdr_profile.h" | ||||
|  | ||||
| #include <volk_gnsssdr/volk_gnsssdr.h> | ||||
| #include <volk_gnsssdr/volk_gnsssdr_prefs.h> | ||||
|  | ||||
| #include <vector> | ||||
| #include <boost/exception/diagnostic_information.hpp> | ||||
| #include <boost/filesystem.hpp> | ||||
| #include <boost/program_options.hpp> | ||||
| #include <boost/xpressive/xpressive.hpp> | ||||
| #include <iostream> | ||||
| #include <fstream> | ||||
| #include <sys/stat.h> | ||||
|  | ||||
| namespace fs = boost::filesystem; | ||||
|  | ||||
| int main(int argc, char *argv[]) { | ||||
|     // Adding program options | ||||
| volk_gnsssdr_test_params_t test_params(1e-6f, 327.f, 8111, 1987, false, ""); | ||||
|  | ||||
| void set_benchmark(bool val) { test_params.set_benchmark(val); } | ||||
| void set_tolerance(float val) { test_params.set_tol(val); } | ||||
| void set_vlen(int val) { test_params.set_vlen((unsigned int)val); } | ||||
| void set_iter(int val) { test_params.set_iter((unsigned int)val); } | ||||
| void set_substr(std::string val) { test_params.set_regex(val); } | ||||
| bool update_mode = false; | ||||
| void set_update(bool val) { update_mode = val; } | ||||
| bool dry_run = false; | ||||
| void set_dryrun(bool val) { dry_run = val; } | ||||
| std::string json_filename(""); | ||||
| void set_json(std::string val) { json_filename = val; } | ||||
| std::string volk_config_path(""); | ||||
| void set_volk_config(std::string val) { volk_config_path = val; } | ||||
|  | ||||
| int main(int argc, char *argv[]) | ||||
| { | ||||
|     option_list profile_options("volk_gnsssdr_profile"); | ||||
|     profile_options.add(option_t("benchmark", "b", "Run all kernels (benchmark mode)", set_benchmark)); | ||||
|     profile_options.add(option_t("tol", "t", "Set the default tolerance for all tests", set_tolerance)); | ||||
|     profile_options.add(option_t("vlen", "v", "Set the default vector length for tests", set_vlen)); | ||||
|     profile_options.add((option_t("iter", "i", "Set the default number of test iterations per kernel", set_iter))); | ||||
|     profile_options.add((option_t("tests-substr", "R", "Run tests matching substring", set_substr))); | ||||
|     profile_options.add((option_t("update", "u", "Run only kernels missing from config", set_update))); | ||||
|     profile_options.add((option_t("dry-run", "n", "Dry run. Respect other options, but don't write to file", set_dryrun))); | ||||
|     profile_options.add((option_t("json", "j", "Write results to JSON file named as argument value", set_json))); | ||||
|     profile_options.add((option_t("path", "p", "Specify the volk_config path", set_volk_config))); | ||||
|  | ||||
|     try | ||||
|     { | ||||
|             boost::program_options::options_description desc("Options"); | ||||
|             desc.add_options() | ||||
|               ("help,h", "Print help messages") | ||||
|               ("benchmark,b", | ||||
|                  boost::program_options::value<bool>()->default_value( false ) | ||||
|                                                       ->implicit_value( true ), | ||||
|                  "Run all kernels (benchmark mode)") | ||||
|               ("tol,t", | ||||
|                  boost::program_options::value<float>()->default_value( 1e-6 ), | ||||
|                  "Set the default error tolerance for tests") | ||||
|               ("vlen,v", | ||||
|                  boost::program_options::value<int>()->default_value( 8111 ), //it is also prime | ||||
|                  "Set the default vector length for tests") // default is a mersenne prime | ||||
|               ("iter,i", | ||||
|                  boost::program_options::value<int>()->default_value( 1987 ), | ||||
|                  "Set the default number of test iterations per kernel") | ||||
|               ("tests-regex,R", | ||||
|                   boost::program_options::value<std::string>(), | ||||
|                   "Run tests matching regular expression.") | ||||
|               ("update,u", | ||||
|                   boost::program_options::value<bool>()->default_value( false ) | ||||
|                                                        ->implicit_value( true ), | ||||
|                   "Run only kernels missing from config; use -R to further restrict the candidates") | ||||
|               ("dry-run,n", | ||||
|                   boost::program_options::value<bool>()->default_value( false ) | ||||
|                                                         ->implicit_value( true ), | ||||
|                   "Dry run. Respect other options, but don't write to file") | ||||
|               ("json,j", | ||||
|                   boost::program_options::value<std::string>(), | ||||
|                   "JSON output file") | ||||
|               ("path,p", | ||||
|                   boost::program_options::value<std::string>(), | ||||
|                   "Specify volk_config path.") | ||||
|               ; | ||||
|             profile_options.parse(argc, argv); | ||||
|     } | ||||
|     catch(...) | ||||
|     { | ||||
|            return 1; | ||||
|     } | ||||
|  | ||||
|             // Handle the options that were given | ||||
|             boost::program_options::variables_map vm; | ||||
|             bool benchmark_mode; | ||||
|             std::string kernel_regex; | ||||
|             std::ofstream json_file; | ||||
|             float def_tol; | ||||
|             lv_32fc_t def_scalar; | ||||
|             int def_iter; | ||||
|             int def_vlen; | ||||
|             bool def_benchmark_mode; | ||||
|             std::string def_kernel_regex; | ||||
|             bool update_mode = false; | ||||
|             bool dry_run = false; | ||||
|             std::string config_file; | ||||
|  | ||||
|             // Handle the provided options | ||||
|             try { | ||||
|                     boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); | ||||
|                     boost::program_options::notify(vm); | ||||
|                     benchmark_mode = vm.count("benchmark")?vm["benchmark"].as<bool>():false; | ||||
|                     if ( vm.count("tests-regex" ) ) { | ||||
|                             kernel_regex = vm["tests-regex"].as<std::string>(); | ||||
|                     } | ||||
|                     else { | ||||
|                             kernel_regex = ".*"; | ||||
|                     } | ||||
|  | ||||
|                     def_tol = vm["tol"].as<float>(); | ||||
|                     def_scalar = 327.0; | ||||
|                     def_vlen = vm["vlen"].as<int>(); | ||||
|                     def_iter = vm["iter"].as<int>(); | ||||
|                     def_benchmark_mode = benchmark_mode; | ||||
|                     def_kernel_regex = kernel_regex; | ||||
|                     update_mode = vm["update"].as<bool>(); | ||||
|                     dry_run = vm["dry-run"].as<bool>(); | ||||
|             } | ||||
|             catch (const boost::program_options::error & error) { | ||||
|                     std::cerr << "Error: " << error.what() << std::endl << std::endl; | ||||
|                     std::cerr << desc << std::endl; | ||||
|                     return 1; | ||||
|             } | ||||
|  | ||||
|             /** --help option */ | ||||
|             if ( vm.count("help") ) { | ||||
|                     std::cout << "The VOLK_GNSSSDR profiler." << std::endl | ||||
|                             << desc << std::endl; | ||||
|     for (int arg_number = 0; arg_number < argc; ++arg_number) { | ||||
|             if (std::string("--help") == std::string(argv[arg_number]) || | ||||
|                     std::string("-h") == std::string(argv[arg_number])) { | ||||
|                     return 0; | ||||
|             } | ||||
|  | ||||
|             if ( vm.count("json") ) { | ||||
|                     std::string filename; | ||||
|                     try { | ||||
|                             filename = vm["json"].as<std::string>(); | ||||
|                     } | ||||
|                     catch (const boost::bad_any_cast& error) { | ||||
|                             std::cerr << error.what() << std::endl; | ||||
|                             return 1; | ||||
|                     } | ||||
|                     json_file.open( filename.c_str() ); | ||||
|             } | ||||
|  | ||||
|             if ( vm.count("path") ) { | ||||
|                     try { | ||||
|                             config_file = vm["path"].as<std::string>() + "/volk_config"; | ||||
|                     } | ||||
|                     catch (const 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); | ||||
|  | ||||
|             // Run tests | ||||
|             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); | ||||
|             } | ||||
|  | ||||
|  | ||||
|             // Initialize the list of tests | ||||
|             // the default test parameters come from options | ||||
|             std::vector<volk_gnsssdr_test_case_t> test_cases = init_test_list(test_params); | ||||
|             boost::xpressive::sregex kernel_expression; | ||||
|             try { | ||||
|                     kernel_expression = boost::xpressive::sregex::compile(kernel_regex); | ||||
|             } | ||||
|             catch (const boost::xpressive::regex_error& error) { | ||||
|                     std::cerr << "Error occurred while compiling regex" << std::endl << std::endl; | ||||
|                     return 1; | ||||
|             } | ||||
|  | ||||
|             // Iteratate through list of tests running each one | ||||
|             for(unsigned int ii = 0; ii < test_cases.size(); ++ii) { | ||||
|                     bool regex_match = true; | ||||
|  | ||||
|                     volk_gnsssdr_test_case_t test_case = test_cases[ii]; | ||||
|                     // if the kernel name matches regex then do the test | ||||
|                     if(boost::xpressive::regex_search(test_case.name(), kernel_expression)) { | ||||
|                             regex_match = true; | ||||
|                     } | ||||
|                     else { | ||||
|                             regex_match = false; | ||||
|                     } | ||||
|  | ||||
|                     // if we are in update mode check if we've already got results | ||||
|                     // if we have any, then no need to test that kernel | ||||
|                     bool update = true; | ||||
|                     if(update_mode) { | ||||
|                             for(unsigned int jj=0; jj < results.size(); ++jj) { | ||||
|                                     if(results[jj].name == test_case.name() || | ||||
|                                             results[jj].name == test_case.puppet_master_name()) { | ||||
|                                             update = false; | ||||
|                                             break; | ||||
|                                     } | ||||
|                             } | ||||
|                     } | ||||
|  | ||||
|                     if( regex_match && update ) { | ||||
|                             try { | ||||
|                                     run_volk_gnsssdr_tests(test_case.desc(), test_case.kernel_ptr(), test_case.name(), | ||||
|                                             test_case.test_parameters(), &results, test_case.puppet_master_name()); | ||||
|                             } | ||||
|                             catch (const std::string & error) { | ||||
|                                     std::cerr << "Caught Exception in 'run_volk_gnsssdr_tests': " << error << std::endl; | ||||
|                             } | ||||
|  | ||||
|                     } | ||||
|             } | ||||
|  | ||||
|  | ||||
|             // Output results according to provided options | ||||
|             if(vm.count("json")) { | ||||
|                     write_json(json_file, results); | ||||
|                     json_file.close(); | ||||
|             } | ||||
|  | ||||
|             if(!dry_run) { | ||||
|                     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; | ||||
|             } | ||||
|     } | ||||
|     catch(const boost::exception & e) | ||||
|     { | ||||
|             std::cerr << boost::diagnostic_information(e) << std::endl; | ||||
|             return 1; | ||||
|     // Adding program options | ||||
|     std::ofstream json_file; | ||||
|     std::string config_file; | ||||
|  | ||||
|     if ( json_filename != "" ) { | ||||
|         json_file.open( json_filename.c_str() ); | ||||
|     } | ||||
|  | ||||
|     if ( volk_config_path != "" ) { | ||||
|         config_file = volk_config_path + "/volk_config"; | ||||
|     } | ||||
|  | ||||
|     // Run tests | ||||
|     std::vector<volk_gnsssdr_test_results_t> results; | ||||
|     if(update_mode) { | ||||
|         if( config_file != "" ) read_results(&results, config_file); | ||||
|         else read_results(&results); | ||||
|     } | ||||
|  | ||||
|     // Initialize the list of tests | ||||
|     std::vector<volk_gnsssdr_test_case_t> test_cases = init_test_list(test_params); | ||||
|  | ||||
|     // Iterate through list of tests running each one | ||||
|     std::string substr_to_match(test_params.kernel_regex()); | ||||
|     for(unsigned int ii = 0; ii < test_cases.size(); ++ii) { | ||||
|         bool regex_match = true; | ||||
|  | ||||
|         volk_gnsssdr_test_case_t test_case = test_cases[ii]; | ||||
|         // if the kernel name matches regex then do the test | ||||
|         std::string test_case_name = test_case.name(); | ||||
|         if(test_case_name.find(substr_to_match) == std::string::npos) { | ||||
|             regex_match = false; | ||||
|         } | ||||
|  | ||||
|         // if we are in update mode check if we've already got results | ||||
|         // if we have any, then no need to test that kernel | ||||
|         bool update = true; | ||||
|         if(update_mode) { | ||||
|             for(unsigned int jj=0; jj < results.size(); ++jj) { | ||||
|                 if(results[jj].name == test_case.name() || | ||||
|                     results[jj].name == test_case.puppet_master_name()) { | ||||
|                     update = false; | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if( regex_match && update ) { | ||||
|             try { | ||||
|             run_volk_gnsssdr_tests(test_case.desc(), test_case.kernel_ptr(), test_case.name(), | ||||
|                 test_case.test_parameters(), &results, test_case.puppet_master_name()); | ||||
|             } | ||||
|             catch (std::string &error) { | ||||
|                 std::cerr << "Caught Exception in 'run_volk_gnssdr_tests': " << error << std::endl; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  | ||||
|     // Output results according to provided options | ||||
|     if(json_filename != "") { | ||||
|         write_json(json_file, results); | ||||
|         json_file.close(); | ||||
|     } | ||||
|  | ||||
|     if(!dry_run) { | ||||
|         if(config_file != "") 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; | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| void read_results(std::vector<volk_gnsssdr_test_results_t> *results) | ||||
| { | ||||
|     char path[1024]; | ||||
| @@ -237,11 +161,12 @@ 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) | ||||
| { | ||||
|     const fs::path config_path(path); | ||||
|     struct stat buffer; | ||||
|     bool config_status = (stat (path.c_str(), &buffer) == 0); | ||||
|  | ||||
|     if(fs::exists(config_path)) { | ||||
|     if( config_status ) { | ||||
|         // a config exists and we are reading results from it | ||||
|         std::ifstream config(config_path.string().c_str()); | ||||
|         std::ifstream config(path.c_str()); | ||||
|         char config_line[256]; | ||||
|         while(config.getline(config_line, 255)) { | ||||
|             // tokenize the input line by kernel_name unaligned aligned | ||||
| @@ -252,23 +177,23 @@ void read_results(std::vector<volk_gnsssdr_test_results_t> *results, std::string | ||||
|             std::size_t str_size = config_str.size(); | ||||
|             std::size_t found = 1; | ||||
|  | ||||
|             found = config_str.find(" "); | ||||
|             found = config_str.find(' '); | ||||
|             // Split line by spaces | ||||
|             while(found && found < str_size) { | ||||
|                 found = config_str.find(" "); | ||||
|                 // kernel names MUST be less than 128 chars, which is | ||||
|                 // a length restricted by volk_gnsssdr/volk_gnsssdr_prefs.c | ||||
|                 // on the last token in the parsed string we won't find a space | ||||
|                 // so make sure we copy at most 128 chars. | ||||
|                 if(found > 127) { | ||||
|                     found = 127; | ||||
|                 } | ||||
|                 str_size = config_str.size(); | ||||
|                 char buffer[128]  = {'\0'}; | ||||
|                 config_str.copy(buffer, found + 1, 0); | ||||
|                 buffer[found] = '\0'; | ||||
|                 single_kernel_result.push_back(std::string(buffer)); | ||||
|                 config_str.erase(0, found+1); | ||||
|                     found = config_str.find(' '); | ||||
|                     // kernel names MUST be less than 128 chars, which is | ||||
|                     // a length restricted by volk/volk_prefs.c | ||||
|                     // on the last token in the parsed string we won't find a space | ||||
|                     // so make sure we copy at most 128 chars. | ||||
|                     if(found > 127) { | ||||
|                             found = 127; | ||||
|                     } | ||||
|                     str_size = config_str.size(); | ||||
|                     char buffer[128] = {'\0'}; | ||||
|                     config_str.copy(buffer, found + 1, 0); | ||||
|                     buffer[found] = '\0'; | ||||
|                     single_kernel_result.push_back(std::string(buffer)); | ||||
|                     config_str.erase(0, found+1); | ||||
|             } | ||||
|  | ||||
|             if(single_kernel_result.size() == 3) { | ||||
| @@ -299,23 +224,23 @@ void write_results(const std::vector<volk_gnsssdr_test_results_t> *results, bool | ||||
|     // do not overwrite volk_gnsssdr_config when using a regex. | ||||
|     if (not fs::exists(config_path.branch_path())) | ||||
|     { | ||||
|         std::cout << "Creating " << config_path.branch_path() << "..." << std::endl; | ||||
|         std::cout << "Creating " << config_path.branch_path() << " ..." << std::endl; | ||||
|         fs::create_directories(config_path.branch_path()); | ||||
|     } | ||||
|  | ||||
|     std::ofstream config; | ||||
|     if(update_result) { | ||||
|         std::cout << "Updating " << config_path << "..." << std::endl; | ||||
|         config.open(config_path.string().c_str(), std::ofstream::app); | ||||
|         std::cout << "Updating " << path << " ..." << std::endl; | ||||
|         config.open(path.c_str(), std::ofstream::app); | ||||
|         if (!config.is_open()) { //either we don't have write access or we don't have the dir yet | ||||
|             std::cout << "Error opening file " << config_path << std::endl; | ||||
|             std::cout << "Error opening file " << path << std::endl; | ||||
|         } | ||||
|     } | ||||
|     else { | ||||
|         std::cout << "Writing " << config_path << "..." << std::endl; | ||||
|         config.open(config_path.string().c_str()); | ||||
|         std::cout << "Writing " << path << " ..." << std::endl; | ||||
|         config.open(path.c_str()); | ||||
|         if (!config.is_open()) { //either we don't have write access or we don't have the dir yet | ||||
|             std::cout << "Error opening file " << config_path << std::endl; | ||||
|             std::cout << "Error opening file " << path << std::endl; | ||||
|         } | ||||
|  | ||||
|         config << "\ | ||||
|   | ||||
| @@ -58,7 +58,7 @@ | ||||
| # the new option. | ||||
| # E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in | ||||
| # MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would | ||||
| # be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. | ||||
| # be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefore. | ||||
|  | ||||
| #============================================================================= | ||||
| # Copyright 2010 Alexander Neundorf <neundorf@kde.org> | ||||
|   | ||||
| @@ -29,8 +29,6 @@ set(__INCLUDED_VOLK_BOOST_CMAKE TRUE) | ||||
| set(BOOST_REQUIRED_COMPONENTS | ||||
|     filesystem | ||||
|     system | ||||
|     unit_test_framework | ||||
|     program_options | ||||
| ) | ||||
|  | ||||
| if(UNIX AND NOT BOOST_ROOT AND EXISTS "/usr/lib64") | ||||
|   | ||||
| @@ -29,7 +29,7 @@ set(__INCLUDED_VOLK_BUILD_TYPES_CMAKE TRUE) | ||||
| #  - RelWithDebInfo: -O3 -g | ||||
| #  - MinSizeRel: -Os | ||||
|  | ||||
| # Addtional Build Types, defined below: | ||||
| # Additional Build Types, defined below: | ||||
| #  - NoOptWithASM: -O0 -g -save-temps | ||||
| #  - O2WithASM: -O2 -g -save-temps | ||||
| #  - O3WithASM: -O3 -g -save-temps | ||||
|   | ||||
| @@ -138,7 +138,7 @@ class impl_class: | ||||
|                 arg_type, arg_name = m.groups() | ||||
|                 self.args.append((arg_type, arg_name)) | ||||
|         except Exception as ex: | ||||
|             raise Exception('I cant parse the function prototype from: %s in %s\n%s'%(kern_name, body, ex)) | ||||
|             raise Exception('I can\'t parse the function prototype from: %s in %s\n%s'%(kern_name, body, ex)) | ||||
|  | ||||
|         assert self.name | ||||
|         self.is_aligned = self.name.startswith('a_') | ||||
|   | ||||
| @@ -73,6 +73,11 @@ template <typename T> inline T lv_conj(const T &x){ | ||||
|  | ||||
| #else /* __cplusplus */ | ||||
|  | ||||
| #if __STDC_VERSION__ >= 199901L /* C99 check */ | ||||
| /* this allows us to conj in lv_conj without the double detour for single-precision floats */ | ||||
| #include <tgmath.h> | ||||
| #endif /* C99 check */ | ||||
|  | ||||
| #include <complex.h> | ||||
|  | ||||
| typedef char complex         lv_8sc_t; | ||||
| @@ -96,7 +101,9 @@ typedef double complex       lv_64fc_t; | ||||
| #define lv_conj(x) (~(x)) | ||||
|  | ||||
| // When not available, use the c99 complex function family, | ||||
| // which always returns double regardless of the input type. | ||||
| // which always returns double regardless of the input type, | ||||
| // unless we have C99 and thus tgmath.h overriding functions | ||||
| // with type-generic versions. | ||||
| #else /* __GNUC__ */ | ||||
|  | ||||
| #define lv_creal(x) (creal(x)) | ||||
|   | ||||
| @@ -38,7 +38,7 @@ __VOLK_DECL_BEGIN | ||||
|  * memory that are guaranteed to be on an alignment, VOLK handles this | ||||
|  * itself. The volk_gnsssdr_malloc function behaves like malloc in that it | ||||
|  * returns a pointer to the allocated memory. However, it also takes | ||||
|  * in an alignment specfication, which is usually something like 16 or | ||||
|  * in an alignment specification, which is usually something like 16 or | ||||
|  * 32 to ensure that the aligned memory is located on a particular | ||||
|  * byte boundary for use with SIMD. | ||||
|  * | ||||
|   | ||||
| @@ -148,7 +148,7 @@ static inline void volk_gnsssdr_32f_sincos_32fc_u_sse4_1(lv_32fc_t* out, const f | ||||
|     for(;number < num_points; number++) | ||||
|         { | ||||
|             float _in = *aPtr++; | ||||
|             *bPtr++ = lv_cmake(cos(_in), sin(_in)); | ||||
|             *bPtr++ = lv_cmake(cosf(_in), sinf(_in)); | ||||
|         } | ||||
| } | ||||
|  | ||||
| @@ -242,7 +242,7 @@ static inline void volk_gnsssdr_32f_sincos_32fc_a_sse4_1(lv_32fc_t* out, const f | ||||
|     for(;number < num_points; number++) | ||||
|         { | ||||
|             float _in = *aPtr++; | ||||
|             *bPtr++ = lv_cmake(cos(_in), sin(_in)); | ||||
|             *bPtr++ = lv_cmake(cosf(_in), sinf(_in)); | ||||
|         } | ||||
| } | ||||
|  | ||||
| @@ -395,7 +395,7 @@ static inline void volk_gnsssdr_32f_sincos_32fc_a_sse2(lv_32fc_t* out, const flo | ||||
|     for(number = sse_iters * 4; number < num_points; number++) | ||||
|         { | ||||
|             _in = *aPtr++; | ||||
|             *bPtr++ = lv_cmake((float)cos(_in), (float)sin(_in) ); | ||||
|             *bPtr++ = lv_cmake((float)cosf(_in), (float)sinf(_in) ); | ||||
|         } | ||||
|  | ||||
| } | ||||
| @@ -548,7 +548,7 @@ static inline void volk_gnsssdr_32f_sincos_32fc_u_sse2(lv_32fc_t* out, const flo | ||||
|     for(number = sse_iters * 4; number < num_points; number++) | ||||
|         { | ||||
|             _in = *aPtr++; | ||||
|             *bPtr++ = lv_cmake((float)cos(_in), (float)sin(_in) ); | ||||
|             *bPtr++ = lv_cmake((float)cosf(_in), (float)sinf(_in) ); | ||||
|         } | ||||
|  | ||||
| } | ||||
| @@ -564,7 +564,7 @@ static inline void volk_gnsssdr_32f_sincos_32fc_generic(lv_32fc_t* out, const fl | ||||
|     for(i = 0; i < num_points; i++) | ||||
|         { | ||||
|             _in = *in++; | ||||
|             *out++ = lv_cmake((float)cos(_in), (float)sin(_in) ); | ||||
|             *out++ = lv_cmake((float)cosf(_in), (float)sinf(_in) ); | ||||
|         } | ||||
| } | ||||
|  | ||||
| @@ -709,7 +709,7 @@ static inline void volk_gnsssdr_32f_sincos_32fc_neon(lv_32fc_t* out, const float | ||||
|     for(number = neon_iters * 4; number < num_points; number++) | ||||
|         { | ||||
|             _in = *aPtr++; | ||||
|             *bPtr++ = lv_cmake((float)cos(_in), (float)sin(_in) ); | ||||
|             *bPtr++ = lv_cmake((float)cosf(_in), (float)sinf(_in) ); | ||||
|         } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -214,7 +214,7 @@ static inline void volk_gnsssdr_s32f_sincos_32fc_a_sse2(lv_32fc_t* out, const fl | ||||
|     _phase = _phase + phase_inc * (sse_iters * 4); | ||||
|     for(number = sse_iters * 4; number < num_points; number++) | ||||
|         { | ||||
|             *bPtr++ = lv_cmake((float)cos((_phase)), (float)sin((_phase)) ); | ||||
|             *bPtr++ = lv_cmake((float)cosf((_phase)), (float)sinf((_phase)) ); | ||||
|             _phase += phase_inc; | ||||
|         } | ||||
|     (*phase) = _phase; | ||||
| @@ -371,7 +371,7 @@ static inline void volk_gnsssdr_s32f_sincos_32fc_u_sse2(lv_32fc_t* out, const fl | ||||
|     _phase = _phase + phase_inc * (sse_iters * 4); | ||||
|     for(number = sse_iters * 4; number < num_points; number++) | ||||
|         { | ||||
|             *bPtr++ = lv_cmake((float)cos(_phase), (float)sin(_phase) ); | ||||
|             *bPtr++ = lv_cmake((float)cosf(_phase), (float)sinf(_phase) ); | ||||
|             _phase += phase_inc; | ||||
|         } | ||||
|     (*phase) = _phase; | ||||
| @@ -388,7 +388,7 @@ static inline void volk_gnsssdr_s32f_sincos_32fc_generic(lv_32fc_t* out, const f | ||||
|     unsigned int i; | ||||
|     for(i = 0; i < num_points; i++) | ||||
|         { | ||||
|             *out++ = lv_cmake((float)cos(_phase), (float)sin(_phase) ); | ||||
|             *out++ = lv_cmake((float)cosf(_phase), (float)sinf(_phase) ); | ||||
|             _phase += phase_inc; | ||||
|         } | ||||
|     (*phase) = _phase; | ||||
| @@ -596,7 +596,7 @@ static inline void volk_gnsssdr_s32f_sincos_32fc_a_avx2(lv_32fc_t* out, const fl | ||||
|     _phase = _phase + phase_inc * (avx_iters * 8); | ||||
|     for(number = avx_iters * 8; number < num_points; number++) | ||||
|         { | ||||
|             out[number] = lv_cmake((float)cos(_phase), (float)sin(_phase) ); | ||||
|             out[number] = lv_cmake((float)cosf(_phase), (float)sinf(_phase) ); | ||||
|             _phase += phase_inc; | ||||
|         } | ||||
|     (*phase) = _phase; | ||||
| @@ -764,7 +764,7 @@ static inline void volk_gnsssdr_s32f_sincos_32fc_u_avx2(lv_32fc_t* out, const fl | ||||
|     _phase = _phase + phase_inc * (avx_iters * 8); | ||||
|     for(number = avx_iters * 8; number < num_points; number++) | ||||
|         { | ||||
|             out[number] = lv_cmake((float)cos(_phase), (float)sin(_phase) ); | ||||
|             out[number] = lv_cmake((float)cosf(_phase), (float)sinf(_phase) ); | ||||
|             _phase += phase_inc; | ||||
|         } | ||||
|     (*phase) = _phase; | ||||
| @@ -880,7 +880,7 @@ static inline void volk_gnsssdr_s32f_sincos_32fc_neon(lv_32fc_t* out, const floa | ||||
|     _phase = _phase + phase_inc * (neon_iters * 4); | ||||
|     for(number = neon_iters * 4; number < num_points; number++) | ||||
|         { | ||||
|             *bPtr++ = lv_cmake((float)cos(_phase), (float)sin(_phase) ); | ||||
|             *bPtr++ = lv_cmake((float)cosf(_phase), (float)sinf(_phase) ); | ||||
|             _phase += phase_inc; | ||||
|         } | ||||
|     (*phase) = _phase; | ||||
|   | ||||
| @@ -30,7 +30,6 @@ | ||||
|  | ||||
| #include "qa_utils.h" | ||||
| #include <vector> | ||||
| #include <boost/assign/list_of.hpp> | ||||
| #include <volk_gnsssdr/volk_gnsssdr.h> | ||||
|  | ||||
|  | ||||
| @@ -47,6 +46,8 @@ | ||||
|     volk_gnsssdr_test_case_t(func##_get_func_desc(), (void(*)())func##_manual, std::string(#func),\ | ||||
|     test_params) | ||||
|  | ||||
| #define QA(test) test_cases.push_back(test); | ||||
|  | ||||
| std::vector<volk_gnsssdr_test_case_t> init_test_list(volk_gnsssdr_test_params_t test_params) | ||||
| { | ||||
|  | ||||
| @@ -64,41 +65,41 @@ std::vector<volk_gnsssdr_test_case_t> init_test_list(volk_gnsssdr_test_params_t | ||||
|     volk_gnsssdr_test_params_t test_params_inacc2 = volk_gnsssdr_test_params_t(2e-1, test_params.scalar(), | ||||
|                 test_params.vlen(), test_params.iter(), test_params.benchmark_mode(), test_params.kernel_regex()); | ||||
|  | ||||
|     std::vector<volk_gnsssdr_test_case_t> test_cases = boost::assign::list_of | ||||
|     std::vector<volk_gnsssdr_test_case_t> test_cases; | ||||
|  | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_8i_accumulator_s8i, test_params_more_iters)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_8i_index_max_16u, test_params_more_iters)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_8i_max_s8i, test_params_more_iters)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_8i_x2_add_8i, test_params_more_iters)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_8ic_conjugate_8ic, test_params_more_iters)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_8ic_magnitude_squared_8i, test_params_more_iters)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_8ic_x2_dot_prod_8ic, test_params)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_8ic_x2_multiply_8ic, test_params)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_8ic_s8ic_multiply_8ic, test_params)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_8u_x2_multiply_8u, test_params_more_iters)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_64f_accumulator_64f, test_params)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_32f_sincos_32fc, test_params_inacc)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_32f_index_max_32u, test_params)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_32fc_convert_8ic, test_params)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_32fc_convert_16ic, test_params_more_iters)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_16ic_x2_dot_prod_16ic, test_params)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_16ic_x2_multiply_16ic, test_params_more_iters)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_16ic_convert_32fc, test_params_more_iters)) | ||||
|         (VOLK_INIT_TEST(volk_gnsssdr_16ic_conjugate_16ic, test_params_more_iters)) | ||||
|         (VOLK_INIT_PUPP(volk_gnsssdr_s32f_sincospuppet_32fc, volk_gnsssdr_s32f_sincos_32fc, test_params_inacc2)) | ||||
|         (VOLK_INIT_PUPP(volk_gnsssdr_16ic_rotatorpuppet_16ic, volk_gnsssdr_16ic_s32fc_x2_rotator_16ic, test_params_int1)) | ||||
|         (VOLK_INIT_PUPP(volk_gnsssdr_16ic_resamplerfastpuppet_16ic, volk_gnsssdr_16ic_resampler_fast_16ic, test_params)) | ||||
|         (VOLK_INIT_PUPP(volk_gnsssdr_16ic_resamplerfastxnpuppet_16ic, volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn, test_params)) | ||||
|         (VOLK_INIT_PUPP(volk_gnsssdr_16ic_resamplerxnpuppet_16ic, volk_gnsssdr_16ic_xn_resampler_16ic_xn, test_params)) | ||||
|         (VOLK_INIT_PUPP(volk_gnsssdr_16i_resamplerxnpuppet_16i, volk_gnsssdr_16i_xn_resampler_16i_xn, test_params)) | ||||
|         (VOLK_INIT_PUPP(volk_gnsssdr_32fc_resamplerxnpuppet_32fc, volk_gnsssdr_32fc_xn_resampler_32fc_xn, test_params)) | ||||
|         (VOLK_INIT_PUPP(volk_gnsssdr_32f_resamplerxnpuppet_32f, volk_gnsssdr_32f_xn_resampler_32f_xn, test_params)) | ||||
|         (VOLK_INIT_PUPP(volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic, volk_gnsssdr_16ic_x2_dot_prod_16ic_xn, test_params)) | ||||
|         (VOLK_INIT_PUPP(volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic, volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn, test_params_int16)) | ||||
|         (VOLK_INIT_PUPP(volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic, volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn, test_params_int16)) | ||||
|         (VOLK_INIT_PUPP(volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc, volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn, test_params_int1)) | ||||
|         (VOLK_INIT_PUPP(volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc, volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn, test_params_int1)) | ||||
|         ; | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_8i_accumulator_s8i, test_params_more_iters)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_8i_index_max_16u, test_params_more_iters)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_8i_max_s8i, test_params_more_iters)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_8i_x2_add_8i, test_params_more_iters)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_8ic_conjugate_8ic, test_params_more_iters)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_8ic_magnitude_squared_8i, test_params_more_iters)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_8ic_x2_dot_prod_8ic, test_params)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_8ic_x2_multiply_8ic, test_params)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_8ic_s8ic_multiply_8ic, test_params)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_8u_x2_multiply_8u, test_params_more_iters)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_64f_accumulator_64f, test_params)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_32f_sincos_32fc, test_params_inacc)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_32f_index_max_32u, test_params)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_32fc_convert_8ic, test_params)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_32fc_convert_16ic, test_params_more_iters)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_16ic_x2_dot_prod_16ic, test_params)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_16ic_x2_multiply_16ic, test_params_more_iters)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_16ic_convert_32fc, test_params_more_iters)) | ||||
|     QA(VOLK_INIT_TEST(volk_gnsssdr_16ic_conjugate_16ic, test_params_more_iters)) | ||||
|     QA(VOLK_INIT_PUPP(volk_gnsssdr_s32f_sincospuppet_32fc, volk_gnsssdr_s32f_sincos_32fc, test_params_inacc2)) | ||||
|     QA(VOLK_INIT_PUPP(volk_gnsssdr_16ic_rotatorpuppet_16ic, volk_gnsssdr_16ic_s32fc_x2_rotator_16ic, test_params_int1)) | ||||
|     QA(VOLK_INIT_PUPP(volk_gnsssdr_16ic_resamplerfastpuppet_16ic, volk_gnsssdr_16ic_resampler_fast_16ic, test_params)) | ||||
|     QA(VOLK_INIT_PUPP(volk_gnsssdr_16ic_resamplerfastxnpuppet_16ic, volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn, test_params)) | ||||
|     QA(VOLK_INIT_PUPP(volk_gnsssdr_16ic_resamplerxnpuppet_16ic, volk_gnsssdr_16ic_xn_resampler_16ic_xn, test_params)) | ||||
|     QA(VOLK_INIT_PUPP(volk_gnsssdr_16i_resamplerxnpuppet_16i, volk_gnsssdr_16i_xn_resampler_16i_xn, test_params)) | ||||
|     QA(VOLK_INIT_PUPP(volk_gnsssdr_32fc_resamplerxnpuppet_32fc, volk_gnsssdr_32fc_xn_resampler_32fc_xn, test_params)) | ||||
|     QA(VOLK_INIT_PUPP(volk_gnsssdr_32f_resamplerxnpuppet_32f, volk_gnsssdr_32f_xn_resampler_32f_xn, test_params)) | ||||
|     QA(VOLK_INIT_PUPP(volk_gnsssdr_16ic_x2_dotprodxnpuppet_16ic, volk_gnsssdr_16ic_x2_dot_prod_16ic_xn, test_params)) | ||||
|     QA(VOLK_INIT_PUPP(volk_gnsssdr_16ic_x2_rotator_dotprodxnpuppet_16ic, volk_gnsssdr_16ic_x2_rotator_dot_prod_16ic_xn, test_params_int16)) | ||||
|     QA(VOLK_INIT_PUPP(volk_gnsssdr_16ic_16i_rotator_dotprodxnpuppet_16ic, volk_gnsssdr_16ic_16i_rotator_dot_prod_16ic_xn, test_params_int16)) | ||||
|     QA(VOLK_INIT_PUPP(volk_gnsssdr_32fc_x2_rotator_dotprodxnpuppet_32fc, volk_gnsssdr_32fc_x2_rotator_dot_prod_32fc_xn, test_params_int1)) | ||||
|     QA(VOLK_INIT_PUPP(volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc, volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn, test_params_int1)) | ||||
|     ; | ||||
|  | ||||
|     return test_cases; | ||||
| } | ||||
|   | ||||
| @@ -76,6 +76,13 @@ class volk_gnsssdr_test_params_t { | ||||
|                            bool benchmark_mode, std::string kernel_regex) : | ||||
|             _tol(tol), _scalar(scalar), _vlen(vlen), _iter(iter), | ||||
|             _benchmark_mode(benchmark_mode), _kernel_regex(kernel_regex) {}; | ||||
|         // setters | ||||
|         void set_tol(float tol) {_tol=tol;}; | ||||
|         void set_scalar(lv_32fc_t scalar) {_scalar=scalar;}; | ||||
|         void set_vlen(unsigned int vlen) {_vlen=vlen;}; | ||||
|         void set_iter(unsigned int iter) {_iter=iter;}; | ||||
|         void set_benchmark(bool benchmark) {_benchmark_mode=benchmark;}; | ||||
|         void set_regex(std::string regex) {_kernel_regex=regex;}; | ||||
|         // getters | ||||
|         float tol() {return _tol;}; | ||||
|         lv_32fc_t scalar() {return _scalar;}; | ||||
|   | ||||
| @@ -50,7 +50,7 @@ void *volk_gnsssdr_malloc(size_t size, size_t alignment) | ||||
|     else | ||||
|         { | ||||
|             fprintf(stderr, | ||||
|                     "VOLK: Error allocating memory " | ||||
|                     "VOLK_GNSSSDR: Error allocating memory " | ||||
|                     "(posix_memalign: error %d: %s)\n", err, strerror(err)); | ||||
|             return NULL; | ||||
|         } | ||||
| @@ -70,7 +70,7 @@ void *volk_gnsssdr_malloc(size_t size, size_t alignment) | ||||
|     void *ptr = _aligned_malloc(size, alignment); | ||||
|     if(ptr == NULL) | ||||
|         { | ||||
|             fprintf(stderr, "VOLK: Error allocating memory (_aligned_malloc)\n"); | ||||
|             fprintf(stderr, "VOLK_GNSSSDR: Error allocating memory (_aligned_malloc)\n"); | ||||
|         } | ||||
|     return ptr; | ||||
| } | ||||
|   | ||||
| @@ -82,7 +82,7 @@ extern VOLK_API ${kern.pname} ${kern.name}_u; | ||||
| //! Call into a specific implementation given by name | ||||
| extern VOLK_API void ${kern.name}_manual(${kern.arglist_full}, const char* impl_name); | ||||
|  | ||||
| //! Get description paramaters for this kernel | ||||
| //! Get description parameters for this kernel | ||||
| extern VOLK_API volk_gnsssdr_func_desc_t ${kern.name}_get_func_desc(void); | ||||
| %endfor | ||||
|  | ||||
|   | ||||
| @@ -42,7 +42,7 @@ | ||||
| #include "GPS_L1_CA.h" | ||||
|  | ||||
|  | ||||
| DEFINE_int32(cpu_multicorrelator_real_codes_iterations_test, 1000, "Number of averaged iterations in CPU multicorrelator test timing test"); | ||||
| DEFINE_int32(cpu_multicorrelator_real_codes_iterations_test, 100, "Number of averaged iterations in CPU multicorrelator test timing test"); | ||||
| DEFINE_int32(cpu_multicorrelator_real_codes_max_threads_test, 12, "Number of maximum concurrent correlators in CPU multicorrelator test timing test"); | ||||
|  | ||||
| void run_correlator_cpu_real_codes(cpu_multicorrelator_real_codes* correlator, | ||||
|   | ||||
| @@ -42,7 +42,7 @@ | ||||
| #include "GPS_L1_CA.h" | ||||
|  | ||||
|  | ||||
| DEFINE_int32(cpu_multicorrelator_iterations_test, 1000, "Number of averaged iterations in CPU multicorrelator test timing test"); | ||||
| DEFINE_int32(cpu_multicorrelator_iterations_test, 100, "Number of averaged iterations in CPU multicorrelator test timing test"); | ||||
| DEFINE_int32(cpu_multicorrelator_max_threads_test, 12, "Number of maximum concurrent correlators in CPU multicorrelator test timing test"); | ||||
|  | ||||
| void run_correlator_cpu(cpu_multicorrelator* correlator, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Antonio Ramos
					Antonio Ramos