[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8961 - gnuradio/branches/developers/eb/vmx/gnuradio-c
From: |
eb |
Subject: |
[Commit-gnuradio] r8961 - gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter |
Date: |
Mon, 21 Jul 2008 09:49:51 -0600 (MDT) |
Author: eb
Date: 2008-07-21 09:49:50 -0600 (Mon, 21 Jul 2008)
New Revision: 8961
Added:
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
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/qa_dotprod_powerpc.cc
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
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/qa_filter.cc
Log:
work-in-progress on altivec
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-21 06:20:24 UTC (rev 8960)
+++
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/Makefile.am
2008-07-21 15:49:50 UTC (rev 8961)
@@ -169,9 +169,11 @@
powerpc_CODE = \
sysconfig_powerpc.cc \
gr_fir_sysconfig_powerpc.cc \
- gr_cpu_powerpc.cc
+ gr_cpu_powerpc.cc \
+ gr_fir_fff_vmx.cc
-powerpc_qa_CODE =
+powerpc_qa_CODE = \
+ qa_dotprod_powerpc.cc
#
Added:
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.cc
(rev 0)
+++
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_vmx.cc
2008-07-21 15:49:50 UTC (rev 8961)
@@ -0,0 +1,208 @@
+/* -*- 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_vmx.h>
+#include <altivec.h>
+#include <stdlib.h>
+#include <stdexcept>
+
+
+static const unsigned FLOATS_PER_VEC = 4;
+
+union v_float_u {
+ vector float v;
+ float f[FLOATS_PER_VEC];
+};
+
+void
+print_vector_float(FILE *fp, vector float v)
+{
+ v_float_u u;
+ u.v = v;
+ fprintf(fp, "{ %f, %f, %f, %f }", u.f[0], u.f[1], u.f[2], u.f[3]);
+}
+
+void
+print_vector_float_nl(FILE *fp, vector float v)
+{
+ print_vector_float(fp, v);
+ putc('\n', fp);
+}
+
+void
+pvf(FILE *fp, const char *name, vector float v)
+{
+ fprintf(fp, "%s = ", name);
+ print_vector_float_nl(fp, v);
+}
+
+static float
+horizontal_add_f(vector float v)
+{
+ 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));
+ u.v = t1;
+ return u.f[0];
+}
+
+static inline size_t
+gr_round_down(size_t x, size_t pow2)
+{
+ return x & -pow2;
+}
+
+static inline size_t
+gr_round_up(size_t x, size_t pow2)
+{
+ return gr_round_down(x + pow2 - 1, pow2);
+}
+
+static inline size_t
+gr_modulo(size_t x, size_t pow2)
+{
+ return x & (pow2 - 1);
+}
+
+static inline size_t
+gr_modulo_neg(size_t x, size_t pow2)
+{
+ return pow2 - gr_modulo(x, pow2);
+}
+
+#if 0
+
+float
+dotprod_fff_vmx(const float *a, const float *b, unsigned n)
+{
+ float sum = 0;
+ for (unsigned int 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 4-byte aligned
+ */
+float
+dotprod_fff_vmx(const float *a, const float *b, unsigned n)
+{
+ static const unsigned FLOATS_PER_LOOP = 1 * FLOATS_PER_VEC;
+
+ unsigned loop_cnt = n / FLOATS_PER_LOOP;
+ vector float acc0 = {0, 0, 0, 0};
+
+ vector unsigned char lvsl_a;
+ vector float msq_a0; // most significant quadword
+ vector float lsq_a0; // least significant quadword
+
+ vector unsigned char lvsl_b;
+ vector float msq_b0; // most significant quadword
+ vector float lsq_b0; // least significant quadword
+
+ lvsl_a = vec_lvsl(0, a);
+ msq_a0 = vec_ld(0, a);
+ a += FLOATS_PER_VEC;
+
+ lvsl_b = vec_lvsl(0, b);
+ msq_b0 = vec_ld(0, b);
+ b += FLOATS_PER_VEC;
+
+ for (unsigned i = 0; i < loop_cnt; i++){
+ lsq_a0 = vec_ld(0, a);
+ lsq_b0 = vec_ld(0, b);
+ a += FLOATS_PER_VEC;
+ b += FLOATS_PER_VEC;
+
+ vector float va = vec_perm(msq_a0, lsq_a0, lvsl_a);
+ msq_a0 = lsq_a0;
+
+ vector float vb = vec_perm(msq_b0, lsq_b0, lvsl_b);
+ msq_b0 = lsq_b0;
+
+ acc0 = vec_madd(va, vb, acc0);
+ }
+
+ 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_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);
+}
Property changes on:
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_vmx.cc
___________________________________________________________________
Name: svn:eol-style
+ native
Added:
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_vmx.h
(rev 0)
+++
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_vmx.h
2008-07-21 15:49:50 UTC (rev 8961)
@@ -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 */
Property changes on:
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_fff_vmx.h
___________________________________________________________________
Name: svn:eol-style
+ native
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-21 06:20:24 UTC (rev 8960)
+++
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/gr_fir_sysconfig_powerpc.cc
2008-07-21 15:49:50 UTC (rev 8961)
@@ -27,22 +27,22 @@
#include <gr_fir_ccf.h>
#include <gr_fir_ccf_generic.h>
-//#include <gr_fir_ccf_powerpc.h>
+//#include <gr_fir_ccf_vmx.h>
#include <gr_fir_fcc.h>
#include <gr_fir_fcc_generic.h>
-//#include <gr_fir_fcc_powerpc.h>
+//#include <gr_fir_fcc_vmx.h>
#include <gr_fir_fff.h>
#include <gr_fir_fff_generic.h>
-//#include <gr_fir_fff_powerpc.h>
+#include <gr_fir_fff_vmx.h>
#include <gr_fir_fsf.h>
#include <gr_fir_fsf_generic.h>
//#include <gr_fir_fsf_powerpc.h>
#include <gr_fir_ccc.h>
#include <gr_fir_ccc_generic.h>
-//#include <gr_fir_ccc_powerpc.h>
+//#include <gr_fir_ccc_vmx.h>
#include <gr_fir_scc.h>
#include <gr_fir_scc_generic.h>
-//#include <gr_fir_scc_powerpc.h>
+//#include <gr_fir_scc_vmx.h>
#include <iostream>
using std::cerr;
@@ -71,6 +71,7 @@
{
return new gr_fir_ccc_vmx (taps);
}
+#endif
static gr_fir_fff *
make_gr_fir_fff_vmx (const std::vector<float> &taps)
@@ -78,6 +79,7 @@
return new gr_fir_fff_vmx (taps);
}
+#if 0
static gr_fir_fsf *
make_gr_fir_fsf_vmx (const std::vector<float> &taps)
{
@@ -171,7 +173,6 @@
{
static bool first = true;
-#if 0
if (gr_cpu::has_vmx ()){
if (first){
cerr << ">>> gr_fir_fff: using VMX\n";
@@ -179,7 +180,6 @@
}
return make_gr_fir_fff_vmx (taps);
}
-#endif
if (first){
cerr << ">>> gr_fir_fff: handing off to parent class\n";
@@ -242,13 +242,12 @@
void
gr_fir_sysconfig_powerpc::get_gr_fir_ccf_info (std::vector<gr_fir_ccf_info>
*info)
{
- gr_fir_ccf_info t;
-
// invoke parent..
gr_fir_sysconfig_generic::get_gr_fir_ccf_info (info);
- // add our stuff...
#if 0
+ // add our stuff...
+ gr_fir_ccf_info t;
if (gr_cpu::has_vmx ()){
t.name = "VMX";
t.create = make_gr_fir_ccf_vmx;
@@ -260,13 +259,12 @@
void
gr_fir_sysconfig_powerpc::get_gr_fir_fcc_info (std::vector<gr_fir_fcc_info>
*info)
{
- gr_fir_fcc_info t;
-
// invoke parent..
gr_fir_sysconfig_generic::get_gr_fir_fcc_info (info);
- // add our stuff...
#if 0
+ // add our stuff...
+ gr_fir_fcc_info t;
if (gr_cpu::has_vmx ()){
t.name = "VMX";
t.create = make_gr_fir_fcc_vmx;
@@ -278,13 +276,12 @@
void
gr_fir_sysconfig_powerpc::get_gr_fir_ccc_info (std::vector<gr_fir_ccc_info>
*info)
{
- gr_fir_ccc_info t;
-
// invoke parent..
gr_fir_sysconfig_generic::get_gr_fir_ccc_info (info);
- // add our stuff...
#if 0
+ // add our stuff...
+ gr_fir_ccc_info t;
if (gr_cpu::has_vmx ()){
t.name = "VMX";
t.create = make_gr_fir_ccc_vmx;
@@ -296,31 +293,27 @@
void
gr_fir_sysconfig_powerpc::get_gr_fir_fff_info (std::vector<gr_fir_fff_info>
*info)
{
- gr_fir_fff_info t;
-
// invoke parent..
gr_fir_sysconfig_generic::get_gr_fir_fff_info (info);
// add our stuff...
-#if 0
+ gr_fir_fff_info t;
if (gr_cpu::has_vmx ()){
t.name = "VMX";
t.create = make_gr_fir_fff_vmx;
(*info).push_back (t);
}
-#endif
}
void
gr_fir_sysconfig_powerpc::get_gr_fir_fsf_info (std::vector<gr_fir_fsf_info>
*info)
{
- gr_fir_fsf_info t;
-
// invoke parent..
gr_fir_sysconfig_generic::get_gr_fir_fsf_info (info);
- // add our stuff...
#if 0
+ // add our stuff...
+ gr_fir_fsf_info t;
if (gr_cpu::has_vmx ()){
t.name = "VMX";
t.create = make_gr_fir_fsf_vmx;
@@ -332,13 +325,12 @@
void
gr_fir_sysconfig_powerpc::get_gr_fir_scc_info (std::vector<gr_fir_scc_info>
*info)
{
- gr_fir_scc_info t;
-
// invoke parent..
gr_fir_sysconfig_generic::get_gr_fir_scc_info (info);
- // add our stuff...
#if 0
+ // add our stuff...
+ gr_fir_scc_info t;
if (gr_cpu::has_vmx ()){
t.name = "VMX";
t.create = make_gr_fir_scc_vmx;
Copied:
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/qa_dotprod_powerpc.cc
(from rev 8953,
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/qa_dotprod_generic.cc)
===================================================================
---
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/qa_dotprod_powerpc.cc
(rev 0)
+++
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/qa_dotprod_powerpc.cc
2008-07-21 15:49:50 UTC (rev 8961)
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2003 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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+#include "qa_dotprod.h"
+
+CppUnit::TestSuite *
+qa_dotprod_suite ()
+{
+ CppUnit::TestSuite *s = new CppUnit::TestSuite ("dotprod");
+
+ // empty test suite
+
+ return s;
+}
Modified:
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/qa_filter.cc
===================================================================
---
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/qa_filter.cc
2008-07-21 06:20:24 UTC (rev 8960)
+++
gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter/qa_filter.cc
2008-07-21 15:49:50 UTC (rev 8961)
@@ -42,13 +42,13 @@
CppUnit::TestSuite *s = new CppUnit::TestSuite ("filter");
s->addTest (qa_dotprod_suite ());
- s->addTest (qa_gri_mmse_fir_interpolator::suite ());
- s->addTest (qa_gri_mmse_fir_interpolator_cc::suite ());
s->addTest (qa_gr_fir_fff::suite ());
s->addTest (qa_gr_fir_ccc::suite ());
s->addTest (qa_gr_fir_fcc::suite ());
s->addTest (qa_gr_fir_scc::suite ());
s->addTest (qa_gr_fir_ccf::suite ());
+ s->addTest (qa_gri_mmse_fir_interpolator::suite ());
+ s->addTest (qa_gri_mmse_fir_interpolator_cc::suite ());
return s;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8961 - gnuradio/branches/developers/eb/vmx/gnuradio-core/src/lib/filter,
eb <=