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

Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into next

This commit is contained in:
Carles Fernandez 2018-03-03 12:50:03 +01:00
commit f6b7e1812b
10 changed files with 197 additions and 236 deletions

View File

@ -128,8 +128,7 @@ $ git pull --rebase upstream next
### How to submit a pull request ### How to submit a pull request
Before submitting you code, please be sure to apply clang-format Before submitting you code, please be sure to [apply clang-format](http://gnss-sdr.org/coding-style/#use-tools-for-automated-code-formatting).
(see http://gnss-sdr.org/coding-style/#use-tools-for-automated-code-formatting).
When the contribution is ready, you can [submit a pull When the contribution is ready, you can [submit a pull
request](https://github.com/gnss-sdr/gnss-sdr/compare/). Head to your request](https://github.com/gnss-sdr/gnss-sdr/compare/). Head to your

View File

@ -37,17 +37,13 @@ struct volk_gnsssdr_machine *get_machine(void)
if(machine != NULL) if(machine != NULL)
return machine; return machine;
else else {
{
unsigned int max_score = 0; unsigned int max_score = 0;
unsigned int i; unsigned int i;
struct volk_gnsssdr_machine *max_machine = NULL; struct volk_gnsssdr_machine *max_machine = NULL;
for (i = 0; i < n_volk_gnsssdr_machines; i++) for(i=0; i<n_volk_gnsssdr_machines; i++) {
{ if(!(volk_gnsssdr_machines[i]->caps & (~volk_gnsssdr_get_lvarch()))) {
if (!(volk_gnsssdr_machines[i]->caps & (~volk_gnsssdr_get_lvarch()))) if(volk_gnsssdr_machines[i]->caps > max_score) {
{
if (volk_gnsssdr_machines[i]->caps > max_score)
{
max_score = volk_gnsssdr_machines[i]->caps; max_score = volk_gnsssdr_machines[i]->caps;
max_machine = volk_gnsssdr_machines[i]; max_machine = volk_gnsssdr_machines[i];
} }
@ -67,10 +63,8 @@ void volk_gnsssdr_list_machines(void)
extern unsigned int n_volk_gnsssdr_machines; extern unsigned int n_volk_gnsssdr_machines;
unsigned int i; unsigned int i;
for (i = 0; i < n_volk_gnsssdr_machines; i++) for(i=0; i<n_volk_gnsssdr_machines; i++) {
{ if(!(volk_gnsssdr_machines[i]->caps & (~volk_gnsssdr_get_lvarch()))) {
if (!(volk_gnsssdr_machines[i]->caps & (~volk_gnsssdr_get_lvarch())))
{
printf("%s;", volk_gnsssdr_machines[i]->name); printf("%s;", volk_gnsssdr_machines[i]->name);
} }
} }
@ -85,17 +79,13 @@ const char *volk_gnsssdr_get_machine(void)
if(machine != NULL) if(machine != NULL)
return machine->name; return machine->name;
else else {
{
unsigned int max_score = 0; unsigned int max_score = 0;
unsigned int i; unsigned int i;
struct volk_gnsssdr_machine *max_machine = NULL; struct volk_gnsssdr_machine *max_machine = NULL;
for (i = 0; i < n_volk_gnsssdr_machines; i++) for(i=0; i<n_volk_gnsssdr_machines; i++) {
{ if(!(volk_gnsssdr_machines[i]->caps & (~volk_gnsssdr_get_lvarch()))) {
if (!(volk_gnsssdr_machines[i]->caps & (~volk_gnsssdr_get_lvarch()))) if(volk_gnsssdr_machines[i]->caps > max_score) {
{
if (volk_gnsssdr_machines[i]->caps > max_score)
{
max_score = volk_gnsssdr_machines[i]->caps; max_score = volk_gnsssdr_machines[i]->caps;
max_machine = volk_gnsssdr_machines[i]; max_machine = volk_gnsssdr_machines[i];
} }
@ -128,7 +118,8 @@ bool volk_gnsssdr_is_aligned(const void *ptr)
static inline void __${kern.name}_d(${kern.arglist_full}) static inline void __${kern.name}_d(${kern.arglist_full})
{ {
% if kern.has_dispatcher : ${kern.name} _dispatcher(${kern.arglist_names}); %if kern.has_dispatcher:
${kern.name}_dispatcher(${kern.arglist_names});
return; return;
%endif %endif
@ -192,13 +183,14 @@ void ${kern.name} _manual(${kern.arglist_full}, const char *impl_name)
const int index = volk_gnsssdr_get_index( const int index = volk_gnsssdr_get_index(
get_machine()->${kern.name}_impl_names, get_machine()->${kern.name}_impl_names,
get_machine()->${kern.name}_n_impls, get_machine()->${kern.name}_n_impls,
impl_name); impl_name
);
get_machine()->${kern.name}_impls[index]( get_machine()->${kern.name}_impls[index](
${kern.arglist_names}); ${kern.arglist_names}
);
} }
volk_gnsssdr_func_desc_t ${kern.name} _get_func_desc(void) volk_gnsssdr_func_desc_t ${kern.name}_get_func_desc(void) {
{
const char **impl_names = get_machine()->${kern.name}_impl_names; const char **impl_names = get_machine()->${kern.name}_impl_names;
const int *impl_deps = get_machine()->${kern.name}_impl_deps; const int *impl_deps = get_machine()->${kern.name}_impl_deps;
const bool *alignment = get_machine()->${kern.name}_impl_alignment; const bool *alignment = get_machine()->${kern.name}_impl_alignment;
@ -207,7 +199,8 @@ volk_gnsssdr_func_desc_t ${kern.name} _get_func_desc(void)
impl_names, impl_names,
impl_deps, impl_deps,
alignment, alignment,
n_impls}; n_impls
};
return desc; return desc;
} }

View File

@ -21,8 +21,7 @@
%for i, arch in enumerate(archs): %for i, arch in enumerate(archs):
//#ifndef LV_${arch.name.upper()} //#ifndef LV_${arch.name.upper()}
#define LV_$ \ #define LV_${arch.name.upper()} ${i}
{arch.name.upper()} $ { i }
//#endif //#endif
%endfor %endfor

View File

@ -40,12 +40,9 @@ struct VOLK_CPU volk_gnsssdr_cpu;
* check for AVX capability before executing. * check for AVX capability before executing.
*/ */
#if ((__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 2) || (__clang_major__ >= 3)) && defined(HAVE_XGETBV) #if ((__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 2) || (__clang_major__ >= 3)) && defined(HAVE_XGETBV)
static inline unsigned long long _xgetbv(unsigned int index) static inline unsigned long long _xgetbv(unsigned int index){
{
unsigned int eax, edx; unsigned int eax, edx;
__VOLK_ASM __VOLK_VOLATILE("xgetbv" __VOLK_ASM __VOLK_VOLATILE ("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index));
: "=a"(eax), "=d"(edx)
: "c"(index));
return ((unsigned long long)edx << 32) | eax; return ((unsigned long long)edx << 32) | eax;
} }
#define __xgetbv() _xgetbv(0) #define __xgetbv() _xgetbv(0)
@ -70,8 +67,7 @@ static inline unsigned long long _xgetbv(unsigned int index)
#endif //defined(VOLK_CPU_x86) #endif //defined(VOLK_CPU_x86)
static inline unsigned int cpuid_count_x86_bit(unsigned int level, unsigned int count, unsigned int reg, unsigned int bit) static inline unsigned int cpuid_count_x86_bit(unsigned int level, unsigned int count, unsigned int reg, unsigned int bit) {
{
#if defined(VOLK_CPU_x86) #if defined(VOLK_CPU_x86)
unsigned int regs[4] = {0}; unsigned int regs[4] = {0};
cpuid_x86_count(level, count, regs); cpuid_x86_count(level, count, regs);
@ -81,8 +77,7 @@ static inline unsigned int cpuid_count_x86_bit(unsigned int level, unsigned int
#endif #endif
} }
static inline unsigned int cpuid_x86_bit(unsigned int reg, unsigned int op, unsigned int bit) static inline unsigned int cpuid_x86_bit(unsigned int reg, unsigned int op, unsigned int bit) {
{
#if defined(VOLK_CPU_x86) #if defined(VOLK_CPU_x86)
unsigned int regs[4]; unsigned int regs[4];
memset(regs, 0, sizeof(unsigned int)*4); memset(regs, 0, sizeof(unsigned int)*4);
@ -93,8 +88,7 @@ static inline unsigned int cpuid_x86_bit(unsigned int reg, unsigned int op, unsi
#endif #endif
} }
static inline unsigned int check_extended_cpuid(unsigned int val) static inline unsigned int check_extended_cpuid(unsigned int val) {
{
#if defined(VOLK_CPU_x86) #if defined(VOLK_CPU_x86)
unsigned int regs[4]; unsigned int regs[4];
memset(regs, 0, sizeof(unsigned int)*4); memset(regs, 0, sizeof(unsigned int)*4);
@ -105,8 +99,7 @@ static inline unsigned int check_extended_cpuid(unsigned int val)
#endif #endif
} }
static inline unsigned int get_avx_enabled(void) static inline unsigned int get_avx_enabled(void) {
{
#if defined(VOLK_CPU_x86) #if defined(VOLK_CPU_x86)
return __xgetbv() & 0x6; return __xgetbv() & 0x6;
#else #else
@ -114,8 +107,7 @@ static inline unsigned int get_avx_enabled(void)
#endif #endif
} }
static inline unsigned int get_avx2_enabled(void) static inline unsigned int get_avx2_enabled(void) {
{
#if defined(VOLK_CPU_x86) #if defined(VOLK_CPU_x86)
return __xgetbv() & 0x6; return __xgetbv() & 0x6;
#else #else
@ -131,8 +123,7 @@ static inline unsigned int get_avx2_enabled(void)
#define VOLK_CPU_ARM #define VOLK_CPU_ARM
#endif #endif
static int has_neon(void) static int has_neon(void){
{
#if defined(VOLK_CPU_ARM) #if defined(VOLK_CPU_ARM)
FILE *auxvec_f; FILE *auxvec_f;
unsigned long auxvec[2]; unsigned long auxvec[2];
@ -143,8 +134,7 @@ static int has_neon(void)
size_t r = 1; size_t r = 1;
//so auxv is basically 32b of ID and 32b of value //so auxv is basically 32b of ID and 32b of value
//so it goes like this //so it goes like this
while (!found_neon && r) while(!found_neon && r) {
{
r = fread(auxvec, sizeof(unsigned long), 2, auxvec_f); r = fread(auxvec, sizeof(unsigned long), 2, auxvec_f);
if((auxvec[0] == AT_HWCAP) && (auxvec[1] & HWCAP_NEON)) if((auxvec[0] == AT_HWCAP) && (auxvec[1] & HWCAP_NEON))
found_neon = 1; found_neon = 1;
@ -158,59 +148,50 @@ static int has_neon(void)
} }
%for arch in archs: %for arch in archs:
static int i_can_has_${arch.name} (void) static int i_can_has_${arch.name} (void) {
{
%for check, params in arch.checks: %for check, params in arch.checks:
if (${check}(<% joined_params = ', '.join(params)%>${joined_params}) == 0) return 0; if (${check}(<% joined_params = ', '.join(params)%>${joined_params}) == 0) return 0;
% endfor return 1; %endfor
return 1;
} }
%endfor %endfor
#if defined(HAVE_FENV_H) #if defined(HAVE_FENV_H)
#if defined(FE_TONEAREST) #if defined(FE_TONEAREST)
#include <fenv.h> #include <fenv.h>
static inline void static inline void set_float_rounding(void){
set_float_rounding(void)
{
fesetround(FE_TONEAREST); fesetround(FE_TONEAREST);
} }
#else #else
static inline void static inline void set_float_rounding(void){
set_float_rounding(void)
{
//do nothing //do nothing
} }
#endif #endif
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#include <float.h> #include <float.h>
static inline void static inline void set_float_rounding(void){
set_float_rounding(void)
{
unsigned int cwrd; unsigned int cwrd;
_controlfp_s(&cwrd, 0, 0); _controlfp_s(&cwrd, 0, 0);
_controlfp_s(&cwrd, _RC_NEAR, _MCW_RC); _controlfp_s(&cwrd, _RC_NEAR, _MCW_RC);
} }
#else #else
static inline void static inline void set_float_rounding(void){
set_float_rounding(void)
{
//do nothing //do nothing
} }
#endif #endif
void volk_gnsssdr_cpu_init() void volk_gnsssdr_cpu_init() {
{
%for arch in archs: %for arch in archs:
volk_gnsssdr_cpu.has_${arch.name} = &i_can_has_${arch.name}; volk_gnsssdr_cpu.has_${arch.name} = &i_can_has_${arch.name};
%endfor %endfor
set_float_rounding(); set_float_rounding();
} }
unsigned int volk_gnsssdr_get_lvarch() unsigned int volk_gnsssdr_get_lvarch() {
{
unsigned int retval = 0; unsigned int retval = 0;
volk_gnsssdr_cpu_init(); volk_gnsssdr_cpu_init();
%for arch in archs: %for arch in archs:
retval += volk_gnsssdr_cpu.has_${arch.name}() << LV_${arch.name.upper()}; retval += volk_gnsssdr_cpu.has_${arch.name}() << LV_${arch.name.upper()};
% endfor return retval; %endfor
return retval;
} }

View File

@ -23,8 +23,7 @@
__VOLK_DECL_BEGIN __VOLK_DECL_BEGIN
struct VOLK_CPU struct VOLK_CPU {
{
%for arch in archs: %for arch in archs:
int (*has_${arch.name}) (); int (*has_${arch.name}) ();
%endfor %endfor

View File

@ -20,11 +20,7 @@
<% arch_names = this_machine.arch_names %> <% arch_names = this_machine.arch_names %>
%for arch in this_machine.archs: %for arch in this_machine.archs:
#define LV_HAVE_$ \ #define LV_HAVE_${arch.name.upper()} 1
{ \
arch.name.upper() \
} \
1
%endfor %endfor
#include <volk_gnsssdr/volk_gnsssdr_common.h> #include <volk_gnsssdr/volk_gnsssdr_common.h>
@ -39,9 +35,7 @@
#include <volk_gnsssdr/${kern.name}.h> #include <volk_gnsssdr/${kern.name}.h>
%endfor %endfor
struct volk_gnsssdr_machine volk_gnsssdr_machine_$ struct volk_gnsssdr_machine volk_gnsssdr_machine_${this_machine.name} = {
{
this_machine.name} = {
<% make_arch_have_list = (' | '.join(['(1 << LV_%s)'%a.name.upper() for a in this_machine.archs])) %> ${make_arch_have_list}, <% make_arch_have_list = (' | '.join(['(1 << LV_%s)'%a.name.upper() for a in this_machine.archs])) %> ${make_arch_have_list},
<% this_machine_name = "\""+this_machine.name+"\"" %> ${this_machine_name}, <% this_machine_name = "\""+this_machine.name+"\"" %> ${this_machine_name},
${this_machine.alignment}, ${this_machine.alignment},

View File

@ -27,8 +27,7 @@
__VOLK_DECL_BEGIN __VOLK_DECL_BEGIN
struct volk_gnsssdr_machine struct volk_gnsssdr_machine {
{
const unsigned int caps; //capabilities (i.e., archs compiled into this machine, in the volk_gnsssdr_get_lvarch format) const unsigned int caps; //capabilities (i.e., archs compiled into this machine, in the volk_gnsssdr_get_lvarch format)
const char *name; const char *name;
const size_t alignment; //the maximum byte alignment required for functions in this library const size_t alignment; //the maximum byte alignment required for functions in this library
@ -44,10 +43,7 @@ struct volk_gnsssdr_machine
%for machine in machines: %for machine in machines:
#ifdef LV_MACHINE_${machine.name.upper()} #ifdef LV_MACHINE_${machine.name.upper()}
extern struct volk_gnsssdr_machine volk_gnsssdr_machine_$ extern struct volk_gnsssdr_machine volk_gnsssdr_machine_${machine.name};
{
machine.name
};
#endif #endif
%endfor %endfor