GNU Radio 3.6.5 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2008 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License along 00018 * with this program; if not, write to the Free Software Foundation, Inc., 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00020 */ 00021 #ifndef INCLUDED_GR_ALTIVEC_H 00022 #define INCLUDED_GR_ALTIVEC_H 00023 00024 /* 00025 * N.B., always use "vec_float4" et al. instead of "vector float" to 00026 * ensure portability across the various powerpc compilers. Some of 00027 * them treat "vector" as a context specific keyword, some don't. 00028 * Avoid the problem by always using the defines in vec_types.h 00029 * (included below) 00030 */ 00031 00032 #include <gr_core_api.h> 00033 #include <altivec.h> 00034 #undef bool // repair namespace pollution 00035 #undef vector // repair namespace pollution 00036 00037 #ifdef HAVE_VEC_TYPES_H 00038 #include <vec_types.h> // use system version if we've got it 00039 #else 00040 #include <gr_vec_types.h> // fall back to our local copy 00041 #endif 00042 #undef qword // repair namespace pollution 00043 00044 #include <stddef.h> 00045 #include <stdio.h> 00046 00047 #ifdef __cplusplus 00048 extern "C" { 00049 #endif 00050 00051 #define VS sizeof(vec_float4) 00052 #define FLOATS_PER_VEC (sizeof(vec_float4)/sizeof(float)) 00053 00054 union v_float_u { 00055 vec_float4 v; 00056 float f[FLOATS_PER_VEC]; 00057 }; 00058 00059 GR_CORE_API void gr_print_vector_float(FILE *fp, vec_float4 v); 00060 GR_CORE_API void gr_pvf(FILE *fp, const char *label, vec_float4 v); 00061 00062 static inline float 00063 horizontal_add_f(vec_float4 v) 00064 { 00065 union v_float_u u; 00066 vec_float4 t0 = vec_add(v, vec_sld(v, v, 8)); 00067 vec_float4 t1 = vec_add(t0, vec_sld(t0, t0, 4)); 00068 u.v = t1; 00069 return u.f[0]; 00070 } 00071 00072 #ifdef __cplusplus 00073 } 00074 #endif 00075 00076 #endif /* INCLUDED_GR_ALTIVEC_H */