2020-12-30 12:35:06 +00:00
|
|
|
/*
|
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2014-11-07 19:51:01 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
2014-09-07 23:56:09 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2020-12-30 12:35:06 +00:00
|
|
|
*
|
2014-09-07 23:56:09 +00:00
|
|
|
*/
|
|
|
|
|
2019-10-11 09:57:33 +00:00
|
|
|
// clang-format off
|
2014-09-07 23:56:09 +00:00
|
|
|
#include <volk_gnsssdr/volk_gnsssdr_cpu.h>
|
|
|
|
#include <volk_gnsssdr/volk_gnsssdr_config_fixed.h>
|
|
|
|
#include <stdlib.h>
|
2016-01-12 19:15:16 +00:00
|
|
|
#include <string.h>
|
2019-10-11 09:57:33 +00:00
|
|
|
// clang-format on
|
2014-09-07 23:56:09 +00:00
|
|
|
|
2022-04-03 21:24:31 +00:00
|
|
|
#if defined(VOLK_CPU_FEATURES)
|
2020-08-21 12:43:04 +00:00
|
|
|
#include "cpu_features_macros.h"
|
|
|
|
#if defined(CPU_FEATURES_ARCH_X86)
|
|
|
|
#include "cpuinfo_x86.h"
|
|
|
|
#elif defined(CPU_FEATURES_ARCH_ARM)
|
|
|
|
#include "cpuinfo_arm.h"
|
|
|
|
#elif defined(CPU_FEATURES_ARCH_AARCH64)
|
|
|
|
#include "cpuinfo_aarch64.h"
|
|
|
|
#elif defined(CPU_FEATURES_ARCH_MIPS)
|
|
|
|
#include "cpuinfo_mips.h"
|
|
|
|
#elif defined(CPU_FEATURES_ARCH_PPC)
|
|
|
|
#include "cpuinfo_ppc.h"
|
|
|
|
#endif
|
|
|
|
|
2020-08-22 10:34:03 +00:00
|
|
|
// This is required for MSVC
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
using namespace cpu_features;
|
|
|
|
#endif
|
2022-04-03 21:24:31 +00:00
|
|
|
#endif
|
2020-08-22 10:34:03 +00:00
|
|
|
|
2020-08-21 12:43:04 +00:00
|
|
|
struct VOLK_CPU volk_gnsssdr_cpu;
|
2018-04-28 23:19:48 +00:00
|
|
|
|
2018-03-04 01:04:27 +00:00
|
|
|
// clang-format off
|
2014-09-07 23:56:09 +00:00
|
|
|
|
2016-07-15 02:34:49 +00:00
|
|
|
%for arch in archs:
|
2018-03-03 11:48:54 +00:00
|
|
|
static int i_can_has_${arch.name} (void) {
|
2016-07-15 02:34:49 +00:00
|
|
|
%for check, params in arch.checks:
|
2020-08-21 12:43:04 +00:00
|
|
|
%if "neon" in arch.name:
|
|
|
|
#if defined(CPU_FEATURES_ARCH_ARM)
|
|
|
|
if (GetArmInfo().features.${check} == 0){ return 0; }
|
|
|
|
#endif
|
|
|
|
%else:
|
|
|
|
#if defined(CPU_FEATURES_ARCH_X86)
|
|
|
|
if (GetX86Info().features.${check} == 0){ return 0; }
|
|
|
|
#endif
|
|
|
|
%endif
|
2018-03-03 11:48:54 +00:00
|
|
|
%endfor
|
|
|
|
return 1;
|
2014-09-07 23:56:09 +00:00
|
|
|
}
|
2018-03-03 11:48:54 +00:00
|
|
|
%endfor
|
2014-09-07 23:56:09 +00:00
|
|
|
|
|
|
|
#if defined(HAVE_FENV_H)
|
2018-03-03 11:48:54 +00:00
|
|
|
#if defined(FE_TONEAREST)
|
|
|
|
#include <fenv.h>
|
|
|
|
static inline void set_float_rounding(void){
|
|
|
|
fesetround(FE_TONEAREST);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline void set_float_rounding(void){
|
|
|
|
//do nothing
|
|
|
|
}
|
|
|
|
#endif
|
2014-09-07 23:56:09 +00:00
|
|
|
#elif defined(_MSC_VER)
|
2018-03-03 11:48:54 +00:00
|
|
|
#include <float.h>
|
|
|
|
static inline void set_float_rounding(void){
|
|
|
|
unsigned int cwrd;
|
|
|
|
_controlfp_s(&cwrd, 0, 0);
|
|
|
|
_controlfp_s(&cwrd, _RC_NEAR, _MCW_RC);
|
|
|
|
}
|
2014-09-07 23:56:09 +00:00
|
|
|
#else
|
2018-03-03 11:48:54 +00:00
|
|
|
static inline void set_float_rounding(void){
|
|
|
|
//do nothing
|
|
|
|
}
|
2014-09-07 23:56:09 +00:00
|
|
|
#endif
|
|
|
|
|
2018-03-03 11:48:54 +00:00
|
|
|
void volk_gnsssdr_cpu_init() {
|
2016-07-15 02:34:49 +00:00
|
|
|
%for arch in archs:
|
|
|
|
volk_gnsssdr_cpu.has_${arch.name} = &i_can_has_${arch.name};
|
2018-03-03 11:48:54 +00:00
|
|
|
%endfor
|
|
|
|
set_float_rounding();
|
2014-09-07 23:56:09 +00:00
|
|
|
}
|
|
|
|
|
2018-03-03 11:48:54 +00:00
|
|
|
unsigned int volk_gnsssdr_get_lvarch() {
|
2014-09-07 23:56:09 +00:00
|
|
|
unsigned int retval = 0;
|
|
|
|
volk_gnsssdr_cpu_init();
|
2016-07-15 02:34:49 +00:00
|
|
|
%for arch in archs:
|
|
|
|
retval += volk_gnsssdr_cpu.has_${arch.name}() << LV_${arch.name.upper()};
|
2018-03-03 11:48:54 +00:00
|
|
|
%endfor
|
|
|
|
return retval;
|
2014-09-07 23:56:09 +00:00
|
|
|
}
|
2018-03-04 01:04:27 +00:00
|
|
|
// clang-format on
|