1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 12:10:34 +00:00

Merge pull request #3 from anthony-arnold/arm

Compiling for ARM
This commit is contained in:
Carles Fernandez 2014-09-29 19:18:01 +02:00
commit 7fe5c119ac
8 changed files with 166 additions and 17 deletions

View File

@ -27,6 +27,8 @@ cmake_minimum_required(VERSION 2.8)
project(gnss-sdr CXX C) project(gnss-sdr CXX C)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
file(RELATIVE_PATH RELATIVE_CMAKE_CALL ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) file(RELATIVE_PATH RELATIVE_CMAKE_CALL ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
include(TestForARM)
include(TestForSSE)
######################################################################## ########################################################################
@ -545,6 +547,8 @@ if(OS_IS_LINUX)
/usr/lib/gcc/i686-linux-gnu/4.7 /usr/lib/gcc/i686-linux-gnu/4.7
/usr/lib/gcc/x86_64-linux-gnu/4.8 /usr/lib/gcc/x86_64-linux-gnu/4.8
/usr/lib/gcc/i686-linux-gnu/4.8 /usr/lib/gcc/i686-linux-gnu/4.8
/usr/lib/gcc/x86_64-linux-gnu/4.9
/usr/lib/gcc/i686-linux-gnu/4.9
/usr/lib/gcc/x86_64-redhat-linux/4.7.2 # Fedora 18 /usr/lib/gcc/x86_64-redhat-linux/4.7.2 # Fedora 18
/usr/lib/gcc/i686-redhat-linux/4.7.2 /usr/lib/gcc/i686-redhat-linux/4.7.2
/usr/lib/gcc/x86_64-redhat-linux/4.8.1 # Fedora 19 /usr/lib/gcc/x86_64-redhat-linux/4.8.1 # Fedora 19
@ -560,6 +564,7 @@ if(OS_IS_LINUX)
/usr/lib/gcc/i486-linux-gnu/4.6 /usr/lib/gcc/i486-linux-gnu/4.6
/usr/lib/gcc/i486-linux-gnu/4.7 /usr/lib/gcc/i486-linux-gnu/4.7
/usr/lib/gcc/i486-linux-gnu/4.8 /usr/lib/gcc/i486-linux-gnu/4.8
/usr/lib/gcc/i486-linux-gnu/4.9
) )
if(NOT GFORTRAN) if(NOT GFORTRAN)
message(" The gfortran library has not been found.") message(" The gfortran library has not been found.")
@ -859,18 +864,34 @@ endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Processor-architecture related flags # Processor-architecture related flags
# See http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options # See http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options
# Change to '-mtune=generic' when building for distribution # Change to '-mtune=generic' when building for distribution (except when compiling for arm)
if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) if (NOT ARCH_COMPILER_FLAGS)
if(OS_IS_MACOSX) if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -march=corei7 -mfpmath=sse") if(OS_IS_MACOSX)
else(OS_IS_MACOSX) set(ARCH_COMPILER_FLAGS "-march=corei7 -mfpmath=sse")
if(ENABLE_GENERIC_ARCH) else(OS_IS_MACOSX)
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -mtune=generic") if(ENABLE_GENERIC_ARCH)
else(ENABLE_GENERIC_ARCH) if (IS_ARM)
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -march=native -mfpmath=sse") set(ARCH_COMPILER_FLAGS "-mtune=generic-arm")
endif(ENABLE_GENERIC_ARCH) else (IS_ARM)
endif(OS_IS_MACOSX) set(ARCH_COMPILER_FLAGS "-mtune=generic")
endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) endif(IS_ARM)
else(ENABLE_GENERIC_ARCH)
if (IS_ARM) # ARM-specific options (https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html)
if (ARM_VERSION STREQUAL "arm")
# Unknown arm version - try our best to detect
set(ARCH_COMPILER_FLAGS "-mcpu=native")
else (ARM_VERSION STREQUAL "arm")
set(ARCH_COMPILER_FLAGS "-march=${ARM_VERSION}")
endif (ARM_VERSION STREQUAL "arm")
else (IS_ARM)
set(ARCH_COMPILER_FLAGS "-march=native -mfpmath=sse")
endif (IS_ARM)
endif(ENABLE_GENERIC_ARCH)
endif(OS_IS_MACOSX)
endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
endif (NOT ARCH_COMPILER_FLAGS)
set(MY_CXX_FLAGS "${MY_CXX_FLAGS} ${ARCH_COMPILER_FLAGS}")
if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
#http://gcc.gnu.org/wiki/Visibility #http://gcc.gnu.org/wiki/Visibility

View File

@ -1,5 +1,7 @@
![](./docs/doxygen/images/gnss-sdr_logo.png) ![](./docs/doxygen/images/gnss-sdr_logo.png)
[![DOI 10.5281/zenodo.11628](https://zenodo.org/badge/doi/10.5281/zenodo.11628.png)](http://dx.doi.org/10.5281/zenodo.11628)
**Welcome to GNSS-SDR!** **Welcome to GNSS-SDR!**
Visit [gnss-sdr.org](http://gnss-sdr.org "GNSS-SDR's Homepage") for more information about this open source GNSS software defined receiver. Visit [gnss-sdr.org](http://gnss-sdr.org "GNSS-SDR's Homepage") for more information about this open source GNSS software defined receiver.

View File

@ -0,0 +1,83 @@
##############################################################################
# check if the compiler defines the architecture as ARM and set the
# version, if found.
#
# - Anthony Arnold
##############################################################################
if (__TEST_FOR_ARM_INCLUDED)
return ()
endif()
set(__TEST_FOR_ARM_INCLUDED TRUE)
# Function checks if the input string defines ARM version and sets the
# output variable if found.
function(check_arm_version ppdef input_string version output_var)
string(REGEX MATCH "${ppdef}" _VERSION_MATCH "${input_string}")
if (NOT _VERSION_MATCH STREQUAL "")
set(${output_var} "${version}" PARENT_SCOPE)
endif(NOT _VERSION_MATCH STREQUAL "")
endfunction()
message(STATUS "Checking for ARM")
set (IS_ARM NO)
set (ARM_VERSION "")
if (CMAKE_COMPILER_IS_GNUCXX)
execute_process(COMMAND echo "int main(){}"
COMMAND ${CMAKE_CXX_COMPILER} -dM -E -
OUTPUT_VARIABLE TEST_FOR_ARM_RESULTS)
string(REGEX MATCH "__arm" ARM_FOUND "${TEST_FOR_ARM_RESULTS}")
if (NOT ARM_FOUND STREQUAL "")
set(IS_ARM YES)
message(STATUS "ARM system detected")
# detect the version
check_arm_version("__ARM_ARCH_2__" ${TEST_FOR_ARM_RESULTS} "armv2" ARM_VERSION)
check_arm_version("__ARM_ARCH_2A__" ${TEST_FOR_ARM_RESULTS} "armv2a" ARM_VERSION)
check_arm_version("__ARM_ARCH_3__" ${TEST_FOR_ARM_RESULTS} "armv3" ARM_VERSION)
check_arm_version("__ARM_ARCH_3M__" ${TEST_FOR_ARM_RESULTS} "armv3m" ARM_VERSION)
check_arm_version("__ARM_ARCH_4__" ${TEST_FOR_ARM_RESULTS} "armv4" ARM_VERSION)
check_arm_version("__ARM_ARCH_4T__" ${TEST_FOR_ARM_RESULTS} "armv4t" ARM_VERSION)
check_arm_version("__ARM_ARCH_5__" ${TEST_FOR_ARM_RESULTS} "armv5" ARM_VERSION)
check_arm_version("__ARM_ARCH_5T__" ${TEST_FOR_ARM_RESULTS} "armv5t" ARM_VERSION)
check_arm_version("__ARM_ARCH_5E__" ${TEST_FOR_ARM_RESULTS} "armv5e" ARM_VERSION)
check_arm_version("__ARM_ARCH_5TE__" ${TEST_FOR_ARM_RESULTS} "armv5te" ARM_VERSION)
check_arm_version("__ARM_ARCH_6__" ${TEST_FOR_ARM_RESULTS} "armv6" ARM_VERSION)
check_arm_version("__ARM_ARCH_6J__" ${TEST_FOR_ARM_RESULTS} "armv6j" ARM_VERSION)
check_arm_version("__ARM_ARCH_6K__" ${TEST_FOR_ARM_RESULTS} "armv6k" ARM_VERSION)
check_arm_version("__ARM_ARCH_6T2__" ${TEST_FOR_ARM_RESULTS} "armv6t2" ARM_VERSION)
check_arm_version("__ARM_ARCH_6Z__" ${TEST_FOR_ARM_RESULTS} "armv6z" ARM_VERSION)
check_arm_version("__ARM_ARCH_6ZK__" ${TEST_FOR_ARM_RESULTS} "armv6zk" ARM_VERSION)
check_arm_version("__ARM_ARCH_6M__" ${TEST_FOR_ARM_RESULTS} "armv6-m" ARM_VERSION)
check_arm_version("__ARM_ARCH_7__" ${TEST_FOR_ARM_RESULTS} "armv7" ARM_VERSION)
check_arm_version("__ARM_ARCH_7A__" ${TEST_FOR_ARM_RESULTS} "armv7-a" ARM_VERSION)
check_arm_version("__ARM_ARCH_7M__" ${TEST_FOR_ARM_RESULTS} "armv7-m" ARM_VERSION)
check_arm_version("__ARM_ARCH_7R__" ${TEST_FOR_ARM_RESULTS} "armv7-r" ARM_VERSION)
check_arm_version("__ARM_ARCH_7EM_" ${TEST_FOR_ARM_RESULTS} "armv7e-m" ARM_VERSION)
check_arm_version("__ARM_ARCH_7VE__" ${TEST_FOR_ARM_RESULTS} "armv7ve" ARM_VERSION)
check_arm_version("__ARM_ARCH_8A__" ${TEST_FOR_ARM_RESULTS} "armv8-a" ARM_VERSION)
# anything else just define as arm
if (ARM_VERSION STREQUAL "")
message(STATUS "Couldn't detect ARM version. Setting to 'arm'")
set(ARM_VERSION "arm")
else (ARM_VERSION STREQUAL "")
message(STATUS "ARM version ${ARM_VERSION} detected")
endif (ARM_VERSION STREQUAL "")
else (NOT ARM_FOUND STREQUAL "")
message(STATUS "System is not ARM")
endif(NOT ARM_FOUND STREQUAL "")
else (CMAKE_COMPILE_IS_GNUCXX)
# TODO: Other compilers
message(STATUS "Not detecting ARM on non-GNUCXX compiler. Defaulting to false")
message(STATUS "If you are compiling for ARM, set IS_ARM=ON manually")
endif(CMAKE_COMPILER_IS_GNUCXX)
set(IS_ARM ${IS_ARM} CACHE BOOL "Compiling for ARM")
set(ARM_VERSION ${ARM_VERSION} CACHE STRING "ARM version")

View File

@ -0,0 +1,36 @@
###############################################################################
# Test for availability of SSE
#
# - Anthony Arnold
###############################################################################
function (test_for_sse h_file result_var name)
if (NOT DEFINED ${result_var})
execute_process(COMMAND echo "#include <${h_file}>"
COMMAND ${CMAKE_CXX_COMPILER} -c -x c++ -
RESULT_VARIABLE COMPILE_RESULT
OUTPUT_QUIET ERROR_QUIET)
if (COMPILE_RESULT EQUAL 0)
message(STATUS "Detected ${name}")
endif(COMPILE_RESULT EQUAL 0)
set(${result_var} ${compile_result} CACHE INTERNAL "${name} Available")
endif (NOT DEFINED ${result_var})
endfunction(test_for_sse)
message(STATUS "Testing for SIMD extensions")
enable_language(C)
test_for_sse("ammintrin.h" SSE4A_AVAILABLE "SSE4A")
test_for_sse("nmmintrin.h" SSE4_2_AVAILABLE "SSE4.2")
test_for_sse("smmintrin.h" SSE4_1_AVAILABLE "SSE4.1")
test_for_sse("tmmintrin.h" SSSE3_AVAILABLE "SSSE3")
test_for_sse("pmmintrin.h" SSE3_AVAILABLE "SSE3")
test_for_sse("emmintrin.h" SSE2_AVAILABLE "SSE2")
test_for_sse("xmmintrin.h" SSE_AVAILABLE "SSE1")
test_for_sse("mmintrin.h" MMX_AVAILABLE "MMX")
test_for_sse("wmmintrin.h" AES_AVAILABLE "AES")
test_for_sse("immintrin.h" AVX_AVAILABLE "AVX")

View File

@ -365,7 +365,7 @@ int Gps_L1_Ca_Dll_Pll_Optim_Tracking_cc::general_work (int noutput_items, gr_vec
update_local_carrier(); update_local_carrier();
// perform Early, Prompt and Late correlation // perform Early, Prompt and Late correlation
#ifndef GENERIC_ARCH #if USING_VOLK_CW_EPL_CORR_CUSTOM
d_correlator.Carrier_wipeoff_and_EPL_volk_custom(d_current_prn_length_samples, d_correlator.Carrier_wipeoff_and_EPL_volk_custom(d_current_prn_length_samples,
in, in,
d_carr_sign, d_carr_sign,

View File

@ -40,6 +40,10 @@ if(ENABLE_GENERIC_ARCH)
add_definitions( -DGENERIC_ARCH=1 ) add_definitions( -DGENERIC_ARCH=1 )
endif(ENABLE_GENERIC_ARCH) endif(ENABLE_GENERIC_ARCH)
if (SSE3_AVAILABLE)
add_definitions( -DHAVE_SSE3=1 )
endif(SSE3_AVAILABLE)
file(GLOB TRACKING_LIB_HEADERS "*.h") file(GLOB TRACKING_LIB_HEADERS "*.h")
add_library(tracking_lib ${TRACKING_LIB_SOURCES} ${TRACKING_LIB_HEADERS}) add_library(tracking_lib ${TRACKING_LIB_SOURCES} ${TRACKING_LIB_HEADERS})
source_group(Headers FILES ${TRACKING_LIB_HEADERS}) source_group(Headers FILES ${TRACKING_LIB_HEADERS})

View File

@ -36,7 +36,7 @@
#include "correlator.h" #include "correlator.h"
#include <iostream> #include <iostream>
#ifndef GENERIC_ARCH #if USING_VOLK_CW_EPL_CORR_CUSTOM
#define LV_HAVE_SSE3 #define LV_HAVE_SSE3
#include "volk_cw_epl_corr.h" #include "volk_cw_epl_corr.h"
#endif #endif
@ -145,7 +145,7 @@ Correlator::~Correlator ()
{} {}
#ifndef GENERIC_ARCH #if USING_VOLK_CW_EPL_CORR_CUSTOM
void Correlator::Carrier_wipeoff_and_EPL_volk_custom(int signal_length_samples, const gr_complex* input, gr_complex* carrier,gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out) void Correlator::Carrier_wipeoff_and_EPL_volk_custom(int signal_length_samples, const gr_complex* input, gr_complex* carrier,gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out)
{ {
volk_cw_epl_corr_u(input, carrier, E_code, P_code, L_code, E_out, P_out, L_out, signal_length_samples); volk_cw_epl_corr_u(input, carrier, E_code, P_code, L_code, E_out, P_out, L_out, signal_length_samples);

View File

@ -41,6 +41,9 @@
#include <volk/volk.h> #include <volk/volk.h>
#include <gnuradio/gr_complex.h> #include <gnuradio/gr_complex.h>
#if !defined(GENERIC_ARCH) && HAVE_SSE3
#define USING_VOLK_CW_EPL_CORR_CUSTOM 1
#endif
/*! /*!
* \brief Class that implements carrier wipe-off and correlators. * \brief Class that implements carrier wipe-off and correlators.
@ -60,8 +63,8 @@ public:
void Carrier_wipeoff_and_EPL_volk_IQ(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* P_data_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, gr_complex* P_data_out); void Carrier_wipeoff_and_EPL_volk_IQ(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* P_data_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, gr_complex* P_data_out);
Correlator(); Correlator();
~Correlator(); ~Correlator();
#ifndef GENERIC_ARCH #if USING_VOLK_CW_EPL_CORR_CUSTOM
void Carrier_wipeoff_and_EPL_volk_custom(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out); void Carrier_wipeoff_and_EPL_volk_custom(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, bool input_vector_unaligned);
#endif #endif
private: private: