[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8969 - gnuradio/branches/developers/eb/vmx/gnuradio-c
From: |
eb |
Subject: |
[Commit-gnuradio] r8969 - gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter |
Date: |
Mon, 21 Jul 2008 21:48:28 -0600 (MDT) |
Author: eb
Date: 2008-07-21 21:48:26 -0600 (Mon, 21 Jul 2008)
New Revision: 8969
Added:
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.h
Removed:
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_vmx.cc
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_vmx.h
Modified:
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/Makefile.am
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.cc
Log:
renamed a few files
Modified:
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/Makefile.am
===================================================================
---
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/Makefile.am
2008-07-22 03:43:45 UTC (rev 8968)
+++
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/Makefile.am
2008-07-22 03:48:26 UTC (rev 8969)
@@ -170,7 +170,7 @@
sysconfig_powerpc.cc \
gr_fir_sysconfig_powerpc.cc \
gr_cpu_powerpc.cc \
- gr_fir_fff_vmx.cc \
+ gr_fir_fff_altivec.cc \
gr_altivec.c
powerpc_qa_CODE = \
@@ -299,6 +299,7 @@
gr_fir_ccf_x86.h \
gr_fir_ccc_simd.h \
gr_fir_ccc_x86.h \
+ gr_fir_fff_altivec.h \
gr_fir_fff_simd.h \
gr_fir_fff_x86.h \
gr_fir_fsf_simd.h \
Copied:
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc
(from rev 8968,
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_vmx.cc)
===================================================================
---
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc
(rev 0)
+++
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.cc
2008-07-22 03:48:26 UTC (rev 8969)
@@ -0,0 +1,212 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gr_fir_fff_altivec.h>
+#include <stdlib.h>
+#include <stdexcept>
+#include <assert.h>
+#include <gr_math.h>
+#include <gr_altivec.h>
+
+extern "C" {
+
+#if 0
+
+float
+dotprod_fff_vmx(const float *a, const float *b, size_t n)
+{
+ float sum = 0;
+ for (size_t i = 0; i < n; i++){
+ sum += a[i] * b[i];
+ }
+ return sum;
+}
+
+#else
+/*
+ * preconditions:
+ *
+ * n > 0 and a multiple of 4
+ * a 4-byte aligned
+ * b 16-byte aligned
+ */
+float
+dotprod_fff_vmx(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;
+
+ static const size_t UNROLL_CNT = 4;
+
+ n = gr_p2_round_down(n, 4);
+ size_t loop_cnt = n / (UNROLL_CNT * FLOATS_PER_VEC);
+ size_t nleft = n % (UNROLL_CNT * FLOATS_PER_VEC);
+
+ // 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};
+
+ // wind in
+
+ register int r0vs = 0 * VS;
+ register int r1vs = 1 * VS;
+ register int r2vs = 2 * VS;
+ register int r3vs = 3 * VS;
+
+ p0 = vec_ld(r0vs, a);
+ p1 = vec_ld(r1vs, a);
+ p2 = vec_ld(r2vs, a);
+ p3 = vec_ld(r3vs, a);
+ a += UNROLL_CNT;
+
+ a0 = vec_perm(p0, p1, lvsl_a);
+ b0 = vec_ld(r0vs, b);
+ p0 = vec_ld(r0vs, a);
+
+ for (size_t i = 0; i < loop_cnt; i++){
+
+ a1 = vec_perm(p1, p2, lvsl_a);
+ b1 = vec_ld(r1vs, b);
+ p1 = vec_ld(r1vs, a);
+ acc0 = vec_madd(a0, b0, acc0);
+
+ a2 = vec_perm(p2, p3, lvsl_a);
+ b2 = vec_ld(r2vs, b);
+ p2 = vec_ld(r2vs, a);
+ acc1 = vec_madd(a1, b1, acc1);
+
+ a3 = vec_perm(p3, p0, lvsl_a);
+ b3 = vec_ld(r3vs, b);
+ p3 = vec_ld(r3vs, a);
+ acc2 = vec_madd(a2, b2, acc2);
+
+ a += UNROLL_CNT;
+ b += UNROLL_CNT;
+
+ a0 = vec_perm(p0, p1, lvsl_a);
+ b0 = vec_ld(r0vs, b);
+ p0 = vec_ld(r0vs, a);
+ acc3 = vec_madd(a3, b3, acc3);
+ }
+
+ /*
+ * The compiler ought to be able to figure out that 0, 4, 8 and 12
+ * are the only possible values for nleft.
+ */
+ switch (nleft){
+ case 0:
+ break;
+
+ case 4:
+ acc0 = vec_madd(a0, b0, acc0);
+ break;
+
+ case 8:
+ a1 = vec_perm(p1, p2, lvsl_a);
+ b1 = vec_ld(r1vs, b);
+ acc0 = vec_madd(a0, b0, acc0);
+ acc1 = vec_madd(a1, b1, acc1);
+ break;
+
+ case 12:
+ a1 = vec_perm(p1, p2, lvsl_a);
+ b1 = vec_ld(r1vs, b);
+ acc0 = vec_madd(a0, b0, acc0);
+ a2 = vec_perm(p2, p3, lvsl_a);
+ b2 = vec_ld(r2vs, b);
+ acc1 = vec_madd(a1, b1, acc1);
+ acc2 = vec_madd(a2, b2, acc2);
+ break;
+ }
+
+ acc0 = acc0 + acc1;
+ acc2 = acc2 + acc3;
+ acc0 = acc0 + acc2;
+
+ return horizontal_add_f(acc0);
+}
+
+#endif
+}
+
+gr_fir_fff_vmx::gr_fir_fff_vmx()
+ : gr_fir_fff_generic(),
+ d_naligned_taps(0), d_aligned_taps(0)
+{
+}
+
+gr_fir_fff_vmx::gr_fir_fff_vmx (const std::vector<float> &new_taps)
+ : gr_fir_fff_generic(new_taps),
+ d_naligned_taps(0), d_aligned_taps(0)
+{
+ set_taps(new_taps);
+}
+
+gr_fir_fff_vmx::~gr_fir_fff_vmx()
+{
+ if (d_aligned_taps){
+ free(d_aligned_taps);
+ d_aligned_taps = 0;
+ }
+}
+
+void
+gr_fir_fff_vmx::set_taps(const std::vector<float> &inew_taps)
+{
+ gr_fir_fff_generic::set_taps(inew_taps); // call superclass
+ d_naligned_taps = gr_p2_round_up(ntaps(), FLOATS_PER_VEC);
+
+ if (d_aligned_taps){
+ free(d_aligned_taps);
+ d_aligned_taps = 0;
+ }
+ void *p;
+ int r = posix_memalign(&p, sizeof(vector float), d_naligned_taps *
sizeof(d_aligned_taps[0]));
+ if (r != 0){
+ throw std::bad_alloc();
+ }
+ d_aligned_taps = (float *) p;
+ memcpy(d_aligned_taps, &d_taps[0], ntaps() * sizeof(d_aligned_taps[0]));
+ for (size_t i = ntaps(); i < d_naligned_taps; i++)
+ d_aligned_taps[i] = 0.0;
+}
+
+
+float
+gr_fir_fff_vmx::filter (const float input[])
+{
+ if (d_naligned_taps == 0)
+ return 0.0;
+
+ return dotprod_fff_vmx(input, d_aligned_taps, d_naligned_taps);
+}
Copied:
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.h
(from rev 8961,
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_vmx.h)
===================================================================
---
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.h
(rev 0)
+++
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_altivec.h
2008-07-22 03:48:26 UTC (rev 8969)
@@ -0,0 +1,45 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GR_FIR_FFF_VMX_H
+#define INCLUDED_GR_FIR_FFF_VMX_H
+
+#include <gr_fir_fff_generic.h>
+
+/*!
+ * \brief VMX version of gr_fir_fff
+ */
+class gr_fir_fff_vmx : public gr_fir_fff_generic
+{
+protected:
+
+ size_t d_naligned_taps; // number of taps (multiple of 4)
+ float *d_aligned_taps; // 16-byte aligned, and zero padded to
multiple of 4
+
+public:
+ gr_fir_fff_vmx();
+ gr_fir_fff_vmx(const std::vector<float> &taps);
+ ~gr_fir_fff_vmx();
+
+ virtual void set_taps (const std::vector<float> &taps);
+ virtual float filter (const float input[]);
+};
+
+#endif /* INCLUDED_GR_FIR_FFF_VMX_H */
Deleted:
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_vmx.cc
Deleted:
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_vmx.h
Modified:
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.cc
===================================================================
---
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.cc
2008-07-22 03:43:45 UTC (rev 8968)
+++
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.cc
2008-07-22 03:48:26 UTC (rev 8969)
@@ -33,7 +33,7 @@
//#include <gr_fir_fcc_vmx.h>
#include <gr_fir_fff.h>
#include <gr_fir_fff_generic.h>
-#include <gr_fir_fff_vmx.h>
+#include <gr_fir_fff_altivec.h>
#include <gr_fir_fsf.h>
#include <gr_fir_fsf_generic.h>
//#include <gr_fir_fsf_powerpc.h>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8969 - gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter,
eb <=