3 * Copyright 2008 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include <gr_fir_fff_altivec.h>
29 #include <gr_altivec.h>
30 #include <dotprod_fff_altivec.h>
32 #include "posix_memalign.h"
34 gr_fir_fff_altivec::gr_fir_fff_altivec()
35 : gr_fir_fff_generic(),
36 d_naligned_taps(0), d_aligned_taps(0)
40 gr_fir_fff_altivec::gr_fir_fff_altivec (const std::vector<float> &new_taps)
41 : gr_fir_fff_generic(new_taps),
42 d_naligned_taps(0), d_aligned_taps(0)
47 gr_fir_fff_altivec::~gr_fir_fff_altivec()
56 gr_fir_fff_altivec::set_taps(const std::vector<float> &inew_taps)
58 gr_fir_fff_generic::set_taps(inew_taps); // call superclass
59 d_naligned_taps = gr_p2_round_up(ntaps(), FLOATS_PER_VEC);
66 int r = posix_memalign(&p, sizeof(vec_float4), d_naligned_taps * sizeof(d_aligned_taps[0]));
68 throw std::bad_alloc();
70 d_aligned_taps = (float *) p;
71 memcpy(d_aligned_taps, &d_taps[0], ntaps() * sizeof(d_aligned_taps[0]));
72 for (size_t i = ntaps(); i < d_naligned_taps; i++)
73 d_aligned_taps[i] = 0.0;
78 gr_fir_fff_altivec::filter (const float input[])
80 if (d_naligned_taps == 0)
83 return dotprod_fff_altivec(input, d_aligned_taps, d_naligned_taps);