1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 12:40: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
Before submitting you code, please be sure to apply clang-format
(see http://gnss-sdr.org/coding-style/#use-tools-for-automated-code-formatting).
Before submitting you code, please be sure to [apply clang-format](http://gnss-sdr.org/coding-style/#use-tools-for-automated-code-formatting).
When the contribution is ready, you can [submit a pull
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)
return machine;
else
{
else {
unsigned int max_score = 0;
unsigned int i;
struct volk_gnsssdr_machine *max_machine = NULL;
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 > max_score)
{
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 > max_score) {
max_score = volk_gnsssdr_machines[i]->caps;
max_machine = volk_gnsssdr_machines[i];
}
@ -67,10 +63,8 @@ void volk_gnsssdr_list_machines(void)
extern unsigned int n_volk_gnsssdr_machines;
unsigned int i;
for (i = 0; i < n_volk_gnsssdr_machines; i++)
{
if (!(volk_gnsssdr_machines[i]->caps & (~volk_gnsssdr_get_lvarch())))
{
for(i=0; i<n_volk_gnsssdr_machines; i++) {
if(!(volk_gnsssdr_machines[i]->caps & (~volk_gnsssdr_get_lvarch()))) {
printf("%s;", volk_gnsssdr_machines[i]->name);
}
}
@ -85,17 +79,13 @@ const char *volk_gnsssdr_get_machine(void)
if(machine != NULL)
return machine->name;
else
{
else {
unsigned int max_score = 0;
unsigned int i;
struct volk_gnsssdr_machine *max_machine = NULL;
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 > max_score)
{
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 > max_score) {
max_score = volk_gnsssdr_machines[i]->caps;
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})
{
% if kern.has_dispatcher : ${kern.name} _dispatcher(${kern.arglist_names});
%if kern.has_dispatcher:
${kern.name}_dispatcher(${kern.arglist_names});
return;
%endif
@ -192,13 +183,14 @@ void ${kern.name} _manual(${kern.arglist_full}, const char *impl_name)
const int index = volk_gnsssdr_get_index(
get_machine()->${kern.name}_impl_names,
get_machine()->${kern.name}_n_impls,
impl_name);
impl_name
);
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 int *impl_deps = get_machine()->${kern.name}_impl_deps;
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_deps,
alignment,
n_impls};
n_impls
};
return desc;
}

View File

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

View File

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

View File

@ -20,11 +20,7 @@
<% arch_names = this_machine.arch_names %>
%for arch in this_machine.archs:
#define LV_HAVE_$ \
{ \
arch.name.upper() \
} \
1
#define LV_HAVE_${arch.name.upper()} 1
%endfor
#include <volk_gnsssdr/volk_gnsssdr_common.h>
@ -39,9 +35,7 @@
#include <volk_gnsssdr/${kern.name}.h>
%endfor
struct volk_gnsssdr_machine volk_gnsssdr_machine_$
{
this_machine.name} = {
struct volk_gnsssdr_machine volk_gnsssdr_machine_${this_machine.name} = {
<% 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.alignment},

View File

@ -27,8 +27,7 @@
__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 char *name;
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:
#ifdef LV_MACHINE_${machine.name.upper()}
extern struct volk_gnsssdr_machine volk_gnsssdr_machine_$
{
machine.name
};
extern struct volk_gnsssdr_machine volk_gnsssdr_machine_${machine.name};
#endif
%endfor