diff options
-rw-r--r-- | config/gr_set_md_cpu.m4 | 23 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | gnuradio-core/src/lib/filter/Makefile.am | 1 | ||||
-rw-r--r-- | gnuradio-core/src/lib/filter/dotprod_fff_altivec.c | 22 | ||||
-rw-r--r-- | gnuradio-core/src/lib/filter/gr_altivec.c | 4 | ||||
-rw-r--r-- | gnuradio-core/src/lib/filter/gr_altivec.h | 34 | ||||
-rw-r--r-- | gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/filter/gr_vec_types.h | 54 |
8 files changed, 117 insertions, 24 deletions
diff --git a/config/gr_set_md_cpu.m4 b/config/gr_set_md_cpu.m4 index b9c570ede..56fd83bac 100644 --- a/config/gr_set_md_cpu.m4 +++ b/config/gr_set_md_cpu.m4 @@ -19,20 +19,39 @@ dnl the Free Software Foundation, Inc., 51 Franklin Street, dnl Boston, MA 02110-1301, USA. dnl +AC_DEFUN([_TRY_ADD_ALTIVEC], +[ + LF_CHECK_CC_FLAG([-mabi=altivec -maltivec]) + LF_CHECK_CXX_FLAG([-mabi=altivec -maltivec]) +]) + AC_DEFUN([GR_SET_MD_CPU],[ AC_REQUIRE([AC_CANONICAL_HOST]) AC_ARG_WITH(md-cpu, - [ --with-md-cpu=ARCH set machine dependent speedups (auto)], + AC_HELP_STRING([--with-md-cpu=ARCH],[set machine dependent speedups (auto)]), [cf_with_md_cpu="$withval"], [cf_with_md_cpu="$host_cpu"]) - AC_MSG_CHECKING([for machine dependent speedups]) case "$cf_with_md_cpu" in x86 | i[[3-7]]86) MD_CPU=x86 MD_SUBCPU=x86 ;; x86_64) MD_CPU=x86 MD_SUBCPU=x86_64 ;; powerpc*) MD_CPU=powerpc ;; *) MD_CPU=generic ;; esac + + AC_ARG_ENABLE(altivec, + AC_HELP_STRING([--enable-altivec],[enable altivec on PowerPC (yes)]), + [ if test $MD_CPU = powerpc; then + case "$enableval" in + (no) MD_CPU=generic ;; + (yes) _TRY_ADD_ALTIVEC ;; + (*) AC_MSG_ERROR([Invalid argument ($enableval) to --enable-altivec]) ;; + esac + fi], + [ if test $MD_CPU = powerpc; then _TRY_ADD_ALTIVEC fi]) + + + AC_MSG_CHECKING([for machine dependent speedups]) AC_MSG_RESULT($MD_CPU) AC_SUBST(MD_CPU) AC_SUBST(MD_SUBCPU) diff --git a/configure.ac b/configure.ac index 14e982b34..342d57059 100644 --- a/configure.ac +++ b/configure.ac @@ -137,6 +137,7 @@ AC_CHECK_HEADERS(linux/ppdev.h dev/ppbus/ppi.h sys/mman.h sys/select.h sys/types AC_CHECK_HEADERS(sys/resource.h stdint.h sched.h signal.h sys/syscall.h) AC_CHECK_HEADERS(netinet/in.h) AC_CHECK_HEADERS(windows.h) +AC_CHECK_HEADERS(vec_types.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST diff --git a/gnuradio-core/src/lib/filter/Makefile.am b/gnuradio-core/src/lib/filter/Makefile.am index 14800cd94..20c7da3a2 100644 --- a/gnuradio-core/src/lib/filter/Makefile.am +++ b/gnuradio-core/src/lib/filter/Makefile.am @@ -283,6 +283,7 @@ grinclude_HEADERS = \ gr_single_pole_iir.h \ gr_single_pole_iir_filter_ff.h \ gr_single_pole_iir_filter_cc.h \ + gr_vec_types.h \ gri_goertzel.h \ gri_iir.h \ gri_mmse_fir_interpolator.h \ diff --git a/gnuradio-core/src/lib/filter/dotprod_fff_altivec.c b/gnuradio-core/src/lib/filter/dotprod_fff_altivec.c index ebddeb502..bebf7e401 100644 --- a/gnuradio-core/src/lib/filter/dotprod_fff_altivec.c +++ b/gnuradio-core/src/lib/filter/dotprod_fff_altivec.c @@ -61,8 +61,8 @@ dotprod_fff_altivec(const float *a, const float *b, size_t n) float dotprod_fff_altivec(const float *_a, const float *_b, size_t n) { - const vector float *a = (const vector float *) _a; - const vector float *b = (const vector float *) _b; + const vec_float4 *a = (const vec_float4 *) _a; + const vec_float4 *b = (const vec_float4 *) _b; static const size_t UNROLL_CNT = 4; @@ -73,15 +73,15 @@ dotprod_fff_altivec(const float *_a, const float *_b, size_t n) // printf("n = %zd, loop_cnt = %zd, nleft = %zd\n", n, loop_cnt, nleft); // Used with vperm to build a* from p* - vector unsigned char lvsl_a = vec_lvsl(0, _a); - - vector float p0, p1, p2, p3; - vector float a0, a1, a2, a3; - vector float b0, b1, b2, b3; - vector float acc0 = {0, 0, 0, 0}; - vector float acc1 = {0, 0, 0, 0}; - vector float acc2 = {0, 0, 0, 0}; - vector float acc3 = {0, 0, 0, 0}; + vec_uchar16 lvsl_a = vec_lvsl(0, _a); + + vec_float4 p0, p1, p2, p3; + vec_float4 a0, a1, a2, a3; + vec_float4 b0, b1, b2, b3; + vec_float4 acc0 = {0, 0, 0, 0}; + vec_float4 acc1 = {0, 0, 0, 0}; + vec_float4 acc2 = {0, 0, 0, 0}; + vec_float4 acc3 = {0, 0, 0, 0}; // wind in diff --git a/gnuradio-core/src/lib/filter/gr_altivec.c b/gnuradio-core/src/lib/filter/gr_altivec.c index 01ca95f0d..416132748 100644 --- a/gnuradio-core/src/lib/filter/gr_altivec.c +++ b/gnuradio-core/src/lib/filter/gr_altivec.c @@ -22,7 +22,7 @@ #include <gr_altivec.h> void -gr_print_vector_float(FILE *fp, vector float v) +gr_print_vector_float(FILE *fp, vec_float4 v) { union v_float_u u; u.v = v; @@ -30,7 +30,7 @@ gr_print_vector_float(FILE *fp, vector float v) } void -gr_pvf(FILE *fp, const char *label, vector float v) +gr_pvf(FILE *fp, const char *label, vec_float4 v) { fprintf(fp, "%s = ", label); gr_print_vector_float(fp, v); diff --git a/gnuradio-core/src/lib/filter/gr_altivec.h b/gnuradio-core/src/lib/filter/gr_altivec.h index 176579a6a..c0d7cfb34 100644 --- a/gnuradio-core/src/lib/filter/gr_altivec.h +++ b/gnuradio-core/src/lib/filter/gr_altivec.h @@ -21,7 +21,25 @@ #ifndef INCLUDED_GR_ALTIVEC_H #define INCLUDED_GR_ALTIVEC_H +/* + * N.B., always use "vec_float4" et al. instead of "vector float" to + * ensure portability across the various powerpc compilers. Some of + * them treat "vector" as a context specific keyword, some don't. + * Avoid the problem by always using the defines in vec_types.h + * (included below) + */ + #include <altivec.h> +#undef bool // repair namespace pollution +#undef vector // repair namespace pollution + +#ifdef HAVE_VEC_TYPES_H +#include <vec_types.h> // use system version if we've got it +#else +#include <gr_vec_types.h> // fall back to our local copy +#endif +#undef qword // repair namespace pollution + #include <stddef.h> #include <stdio.h> @@ -29,23 +47,23 @@ extern "C" { #endif -#define VS sizeof(vector float) -#define FLOATS_PER_VEC (sizeof(vector float)/sizeof(float)) +#define VS sizeof(vec_float4) +#define FLOATS_PER_VEC (sizeof(vec_float4)/sizeof(float)) union v_float_u { - vector float v; + vec_float4 v; float f[FLOATS_PER_VEC]; }; -void gr_print_vector_float(FILE *fp, vector float v); -void gr_pvf(FILE *fp, const char *label, vector float v); +void gr_print_vector_float(FILE *fp, vec_float4 v); +void gr_pvf(FILE *fp, const char *label, vec_float4 v); static inline float -horizontal_add_f(vector float v) +horizontal_add_f(vec_float4 v) { union v_float_u u; - vector float t0 = vec_add(v, vec_sld(v, v, 8)); - vector float t1 = vec_add(t0, vec_sld(t0, t0, 4)); + vec_float4 t0 = vec_add(v, vec_sld(v, v, 8)); + vec_float4 t1 = vec_add(t0, vec_sld(t0, t0, 4)); u.v = t1; return u.f[0]; } diff --git a/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc b/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc index 7583f5c1f..3d767f13e 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc +++ b/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc @@ -62,7 +62,7 @@ gr_fir_fff_altivec::set_taps(const std::vector<float> &inew_taps) d_aligned_taps = 0; } void *p; - int r = posix_memalign(&p, sizeof(vector float), d_naligned_taps * sizeof(d_aligned_taps[0])); + int r = posix_memalign(&p, sizeof(vec_float4), d_naligned_taps * sizeof(d_aligned_taps[0])); if (r != 0){ throw std::bad_alloc(); } diff --git a/gnuradio-core/src/lib/filter/gr_vec_types.h b/gnuradio-core/src/lib/filter/gr_vec_types.h new file mode 100644 index 000000000..eabe78b69 --- /dev/null +++ b/gnuradio-core/src/lib/filter/gr_vec_types.h @@ -0,0 +1,54 @@ +/* Cell single token vector types + Copyright (C) 2007 Free Software Foundation, Inc. + + This file 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 2 of the License, or (at your option) + any later version. + + This file 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 this file; see the file COPYING. If not, write to the Free + Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* As a special exception, if you include this header file into source files + compiled by GCC, this header file does not by itself cause the resulting + executable to be covered by the GNU General Public License. This exception + does not however invalidate any other reasons why the executable file might be + covered by the GNU General Public License. */ + +/* Single token vector data types for the PowerPC SIMD/Vector Multi-media + eXtension */ + +#ifndef _VEC_TYPES_H_ +#define _VEC_TYPES_H_ 1 + +#define qword __vector unsigned char + +#define vec_uchar16 __vector unsigned char +#define vec_char16 __vector signed char +#define vec_bchar16 __vector bool char + +#define vec_ushort8 __vector unsigned short +#define vec_short8 __vector signed short +#define vec_bshort8 __vector bool short + +#define vec_pixel8 __vector pixel + +#define vec_uint4 __vector unsigned int +#define vec_int4 __vector signed int +#define vec_bint4 __vector bool int + +#define vec_float4 __vector float + +#define vec_ullong2 __vector bool char +#define vec_llong2 __vector bool short + +#define vec_double2 __vector bool int + +#endif /* _VEC_TYPES_H_ */ |