summaryrefslogtreecommitdiff
path: root/gr-gcell
diff options
context:
space:
mode:
authoreb2008-04-22 22:24:16 +0000
committereb2008-04-22 22:24:16 +0000
commitb9ba2711addfc9057c136b520afc9e121ec19be9 (patch)
tree059e93ef559bb837c9ca46549688c86d2e153f1c /gr-gcell
parent2ae538ed6a5d18615fb9eea280d861ed3a8600e5 (diff)
downloadgnuradio-b9ba2711addfc9057c136b520afc9e121ec19be9.tar.gz
gnuradio-b9ba2711addfc9057c136b520afc9e121ec19be9.tar.bz2
gnuradio-b9ba2711addfc9057c136b520afc9e121ec19be9.zip
Merged eb/gcell -r8215:8243 into trunk. This adds gr-gcell, the GNU
Radio interface to the Cell Broadband Engine. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@8244 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gr-gcell')
-rw-r--r--gr-gcell/Makefile.am24
-rw-r--r--gr-gcell/src/Makefile.am130
-rw-r--r--gr-gcell/src/examples/Makefile.am42
-rw-r--r--gr-gcell/src/gc_job_manager.i75
-rw-r--r--gr-gcell/src/gcell.i37
-rw-r--r--gr-gcell/src/gcell_fft_vcc.cc159
-rw-r--r--gr-gcell/src/gcell_fft_vcc.h63
-rw-r--r--gr-gcell/src/gcell_fft_vcc.i56
-rwxr-xr-xgr-gcell/src/qa_fft.py162
-rw-r--r--gr-gcell/src/run_tests.in10
10 files changed, 758 insertions, 0 deletions
diff --git a/gr-gcell/Makefile.am b/gr-gcell/Makefile.am
new file mode 100644
index 000000000..2386f80ae
--- /dev/null
+++ b/gr-gcell/Makefile.am
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+
+include $(top_srcdir)/Makefile.common
+
+SUBDIRS = src
+
diff --git a/gr-gcell/src/Makefile.am b/gr-gcell/src/Makefile.am
new file mode 100644
index 000000000..8b1e09ea1
--- /dev/null
+++ b/gr-gcell/src/Makefile.am
@@ -0,0 +1,130 @@
+#
+# 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.
+#
+
+include $(top_srcdir)/Makefile.common
+
+SUBDIRS = . examples
+
+EXTRA_DIST = run_tests.in
+TESTS = run_tests
+
+
+# Install the python portion so that it ends up as the gnuradio.gcell module
+# ${prefix}/lib/python${python_version}/site-packages/gnuradio
+
+ourpythondir = $(grpythondir)
+ourlibdir = $(grpyexecdir)
+
+AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(GCELL_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES)
+
+SWIGPYTHONARGS = $(SWIGPYTHONFLAGS) $(STD_DEFINES_AND_INCLUDES) $(GCELL_INCLUDES) \
+ $(WITH_SWIG_INCLUDES) $(WITH_INCLUDES)
+
+# ----------------------------------------------------------------
+# The C++ blocks
+# ----------------------------------------------------------------
+
+# the library for the C++ blocks
+lib_LTLIBRARIES = libgr_gcell.la
+
+libgr_gcell_la_SOURCES = \
+ gcell_fft_vcc.cc
+
+grinclude_HEADERS = \
+ gcell_fft_vcc.h
+
+libgr_gcell_la_LIBADD = \
+ $(GNURADIO_CORE_LA) \
+ $(GCELL_LA)
+
+libgr_gcell_la_LDFLAGS = $(NO_UNDEFINED)
+
+
+# ----------------------------------------------------------------
+# SWIG stuff
+# ----------------------------------------------------------------
+
+# the library for the swig interface
+ourlib_LTLIBRARIES = _gcell.la
+
+LOCAL_IFILES = \
+ $(top_srcdir)/gr-gcell/src/gcell.i
+
+NON_LOCAL_IFILES = \
+ $(GNURADIO_I)
+
+ALL_IFILES = \
+ $(LOCAL_IFILES) \
+ $(NON_LOCAL_IFILES)
+
+swig_built_sources = \
+ gcell.cc \
+ gcell.py
+
+ourpython_PYTHON = \
+ gcell.py
+
+_gcell_la_SOURCES = \
+ gcell.cc
+
+_gcell_la_LIBADD = \
+ $(PYTHON_LDFLAGS) \
+ libgr_gcell.la \
+ -lstdc++
+
+_gcell_la_LDFLAGS = $(NO_UNDEFINED) -module -avoid-version
+
+
+swiginclude_HEADERS = \
+ $(LOCAL_IFILES)
+
+#gcell.cc gcell.py: $(LOCAL_IFILES) $(NON_LOCAL_IFILES)
+# $(SWIG) $(SWIGPYTHONARGS) -module gcell -o gcell.cc $(LOCAL_IFILES)
+
+# KLUDGE: Force runtime include of gcell.d dependency file.
+# This is not guaranteed to be portable, but will probably work.
+# If it works, we have accurate dependencies for our swig stuff, which is good.
+@am__include@ @am__quote@./gcell.d@am__quote@
+
+gcell.py gcell.h: gcell.cc
+
+gcell.cc : gcell.i $(GNURADIO_I)
+ if $(SWIG) $(SWIGPYTHONARGS) -MMD -MF gcell.Td -module gcell -o gcell.cc $(srcdir)/gcell.i ;\
+ then if test $(host_os) = mingw32; \
+ then sed 's,\\\\,/,g' <gcell.Td >gcell.d; rm -f gcell.Td; \
+ else mv -f gcell.Td gcell.d; fi \
+ else rm -f gcell.Td; exit 1; fi
+
+
+noinst_PYTHON = \
+ qa_gcell.py
+
+# ----------------------------------------------------------------
+
+MOSTLYCLEANFILES = \
+ $(swig_built_sources) *~ *.pyc
+
+# Don't distribute output of swig
+dist-hook:
+ @for file in $(swig_built_sources); do echo $(RM) $(distdir)/$$file; done
+ @for file in $(swig_built_sources); do $(RM) $(distdir)/$$file; done
+
+DISTCLEANFILES = \
+ gcell.d
diff --git a/gr-gcell/src/examples/Makefile.am b/gr-gcell/src/examples/Makefile.am
new file mode 100644
index 000000000..d10c3dad6
--- /dev/null
+++ b/gr-gcell/src/examples/Makefile.am
@@ -0,0 +1,42 @@
+#
+# 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 GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+include $(top_srcdir)/Makefile.common
+
+#EXTRA_DIST = \
+# README \
+# fsm_utils.py
+
+
+ourdatadir = $(exampledir)/gcell
+ourdata_DATA = $(EXTRA_DIST)
+
+# Make example scripts with #! executable
+install-data-local: install-ourdataDATA
+ for i in `find $(ourdatadir) -type f ! -perm 755`; do \
+ if head -1 $$i | grep -q '^#!'; then \
+ chmod 755 $$i; \
+ echo "made executable: $$i"; \
+ fi; \
+ done
+
+MOSTLYCLEANFILES = *.pyc
+
diff --git a/gr-gcell/src/gc_job_manager.i b/gr-gcell/src/gc_job_manager.i
new file mode 100644
index 000000000..7bec48e19
--- /dev/null
+++ b/gr-gcell/src/gc_job_manager.i
@@ -0,0 +1,75 @@
+/* -*- 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.
+ */
+
+struct spe_program_handle_t;
+typedef boost::shared_ptr<spe_program_handle_t> spe_program_handle_sptr;
+%template(spe_program_handle_sptr) boost::shared_ptr<spe_program_handle_t>;
+
+class gc_job_manager;
+typedef boost::shared_ptr<gc_job_manager> gc_job_manager_sptr;
+%template(gc_job_manager_sptr) boost::shared_ptr<gc_job_manager>;
+
+
+%rename(program_handle_from_filename) gc_program_handle_from_filename;
+spe_program_handle_sptr
+gc_program_handle_from_filename(const std::string &filename);
+
+%rename(program_handle_from_address) gc_program_handle_from_address;
+spe_program_handle_sptr
+gc_program_handle_from_address(spe_program_handle_t *handle);
+
+
+%rename(jm_options) gc_jm_options;
+struct gc_jm_options {
+ unsigned int max_jobs; // max # of job descriptors in system
+ unsigned int max_client_threads; // max # of client threads of job manager
+ unsigned int nspes; // how many SPEs shall we use? 0 -> all of them
+ bool gang_schedule; // shall we gang schedule?
+ bool use_affinity; // shall we try for affinity (FIXME not implmented)
+ bool enable_logging; // shall we log SPE events?
+ uint32_t log2_nlog_entries; // log2 of number of log entries (default is 12 == 4k)
+ spe_program_handle_sptr program_handle; // program to load into SPEs
+
+ gc_jm_options(spe_program_handle_sptr program_handle_,
+ unsigned int nspes_ = 0) :
+ max_jobs(0), max_client_threads(0), nspes(nspes_),
+ gang_schedule(false), use_affinity(false),
+ enable_logging(false), log2_nlog_entries(12),
+ program_handle(program_handle_)
+ {
+ }
+};
+
+%rename(job_manager) gc_make_job_manager;
+gc_job_manager_sptr
+gc_make_job_manager(const gc_jm_options *options);
+
+%inline {
+ void set_singleton(gc_job_manager_sptr mgr)
+ {
+ gc_job_manager::set_singleton(mgr);
+ }
+
+ gc_job_manager_sptr singleton()
+ {
+ return gc_job_manager::singleton();
+ }
+}
diff --git a/gr-gcell/src/gcell.i b/gr-gcell/src/gcell.i
new file mode 100644
index 000000000..23f602895
--- /dev/null
+++ b/gr-gcell/src/gcell.i
@@ -0,0 +1,37 @@
+/* -*- 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.
+ */
+
+%feature("autodoc","1");
+
+//%include "exception.i"
+%import "gnuradio.i" // the common stuff
+
+%{
+#include "gnuradio_swig_bug_workaround.h" // mandatory bug fix
+//#include <stdexcept>
+
+#include <gc_job_manager.h>
+#include <gcell_fft_vcc.h>
+
+%}
+
+%include "gc_job_manager.i"
+%include "gcell_fft_vcc.i"
diff --git a/gr-gcell/src/gcell_fft_vcc.cc b/gr-gcell/src/gcell_fft_vcc.cc
new file mode 100644
index 000000000..4b781696d
--- /dev/null
+++ b/gr-gcell/src/gcell_fft_vcc.cc
@@ -0,0 +1,159 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2007,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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gcell_fft_vcc.h>
+#include <gr_io_signature.h>
+#include <gc_job_manager.h>
+#include <gc_aligned_alloc.h>
+#include <gcp_fft_1d_r2.h>
+#include <math.h>
+#include <assert.h>
+#include <stdexcept>
+
+
+#define MIN_FFT_SIZE 32
+#define MAX_FFT_SIZE 4096
+
+inline static bool
+is_power_of_2(int x)
+{
+ return x != 0 && (x & (x-1)) == 0;
+}
+
+static int
+log2(int x) // x is an exact power of 2
+{
+ for (int i = 0; i < 32; i++)
+ if (x == (1 << i))
+ return i;
+
+ assert(0);
+}
+
+#if 0
+gr_fft_vcc_sptr
+gcell_make_fft_vcc(int fft_size, bool forward, const std::vector<float> &window, bool shift)
+{
+ // If it doesn't meet our constraints, use standard implemenation
+ if (fft_size < MIN_FFT_SIZE || fft_size > MAX_FFT_SIZE
+ || !is_power_of_2(fft_size)
+ || (window.size() != 0 && fft_size > MAX_FFT_SIZE/2))
+ return gr_make_fft_vcc(fft_size, forward, window, shift);
+ else
+ return gr_fft_vcc_sptr (new gcell_fft_vcc(fft_size, forward, window, shift));
+}
+#else
+
+gcell_fft_vcc_sptr
+gcell_make_fft_vcc(int fft_size, bool forward, const std::vector<float> &window, bool shift)
+{
+ return gcell_fft_vcc_sptr (new gcell_fft_vcc(fft_size, forward, window, shift));
+}
+
+#endif
+
+gcell_fft_vcc::gcell_fft_vcc (int fft_size, bool forward,
+ const std::vector<float> &window, bool shift)
+ : gr_fft_vcc("gcell_fft_vcc", fft_size, forward, window, shift)
+{
+ if (fft_size < MIN_FFT_SIZE || fft_size > MAX_FFT_SIZE || !is_power_of_2(fft_size)){
+ throw std::invalid_argument("fft_size");
+ }
+
+ if (window.size() != 0 && fft_size > MAX_FFT_SIZE/2){
+ throw std::invalid_argument("fft_size too big to use window");
+ }
+
+ d_log2_fft_size = log2(fft_size);
+ d_mgr = gc_job_manager::singleton(); // grab the singleton job manager
+ d_twiddle_boost = gc_aligned_alloc_sptr(sizeof(std::complex<float>) * fft_size/4, 128);
+ d_twiddle = (std::complex<float>*) d_twiddle_boost.get();
+ gcp_fft_1d_r2_twiddle(d_log2_fft_size, d_twiddle);
+}
+
+gcell_fft_vcc::~gcell_fft_vcc ()
+{
+}
+
+int
+gcell_fft_vcc::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const gr_complex *in = (const gr_complex *) input_items[0];
+ gr_complex *out = (gr_complex *) output_items[0];
+
+ // unsigned int input_data_size = input_signature()->sizeof_stream_item(0);
+ // unsigned int output_data_size = output_signature()->sizeof_stream_item(0);
+
+ float window_buf[MAX_FFT_SIZE/2] __attribute__((aligned (16)));
+ float *window = 0;
+
+ // If we've got a window, ensure it's 16-byte aligned
+ // FIXME move this to set_window
+ if (d_window.size()){
+ if ((((intptr_t)&d_window[0]) & 0xf) == 0)
+ window = &d_window[0]; // OK as is
+ else {
+ window = window_buf; // copy to aligned buffer
+ memcpy(window, &d_window[0], sizeof(float) * d_window.size());
+ }
+ }
+
+ std::vector<gc_job_desc_sptr> jd_sptr(noutput_items);
+ gc_job_desc *jd[noutput_items];
+ bool done[noutput_items];
+
+ // submit noutput_items jobs in parallel
+
+ for (int i = 0; i < noutput_items; i++){
+ jd_sptr[i] = gcp_fft_1d_r2_submit(d_mgr, d_log2_fft_size,
+ d_forward, d_shift,
+ &out[i * d_fft_size],
+ &in[i * d_fft_size],
+ d_twiddle,
+ window);
+ jd[i] = jd_sptr[i].get();
+ }
+
+ int n = d_mgr->wait_jobs(noutput_items, jd, done, GC_WAIT_ALL);
+ if (n != noutput_items){
+ fprintf(stderr, "gcell_fft_vcc: wait_jobs returned %d, expected %d\n",
+ n, noutput_items);
+ return -1;
+ }
+
+ for (int i = 0; i < noutput_items; i++){
+ if (jd[i]->status != JS_OK){
+ fprintf(stderr, "gcell_fft_vcc jd[%d]->status = %s\n",
+ i, gc_job_status_string(jd[i]->status).c_str());
+ return -1;
+ }
+ }
+
+ return noutput_items;
+}
+
diff --git a/gr-gcell/src/gcell_fft_vcc.h b/gr-gcell/src/gcell_fft_vcc.h
new file mode 100644
index 000000000..2cf13b33d
--- /dev/null
+++ b/gr-gcell/src/gcell_fft_vcc.h
@@ -0,0 +1,63 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2007,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 GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GCELL_FFT_VCC_H
+#define INCLUDED_GCELL_FFT_VCC_H
+
+#include <gr_fft_vcc.h>
+
+class gc_job_manager;
+
+class gcell_fft_vcc;
+typedef boost::shared_ptr<gcell_fft_vcc> gcell_fft_vcc_sptr;
+
+gcell_fft_vcc_sptr
+gcell_make_fft_vcc(int fft_size, bool forward, const std::vector<float> &window, bool shift=false);
+
+/*!
+ * \brief Compute forward or reverse FFT. complex vector in / complex vector out.
+ * \ingroup dft
+ *
+ * Concrete class that uses gcell to offload FFT to SPEs.
+ */
+class gcell_fft_vcc : public gr_fft_vcc
+{
+ int d_log2_fft_size;
+ boost::shared_ptr<gc_job_manager> d_mgr;
+ std::complex<float> *d_twiddle; // twiddle values (16-byte aligned)
+ boost::shared_ptr<void> d_twiddle_boost; // automatic storage mgmt
+
+ friend gcell_fft_vcc_sptr
+ gcell_make_fft_vcc(int fft_size, bool forward, const std::vector<float> &window, bool shift);
+
+ gcell_fft_vcc(int fft_size, bool forward, const std::vector<float> &window, bool shift);
+
+ public:
+ ~gcell_fft_vcc();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif /* INCLUDED_GCELL_FFT_VCC_H */
diff --git a/gr-gcell/src/gcell_fft_vcc.i b/gr-gcell/src/gcell_fft_vcc.i
new file mode 100644
index 000000000..1d4a359f9
--- /dev/null
+++ b/gr-gcell/src/gcell_fft_vcc.i
@@ -0,0 +1,56 @@
+/* -*- 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.
+ */
+
+#if 1
+
+// This version works.
+
+GR_SWIG_BLOCK_MAGIC(gcell, fft_vcc)
+
+gcell_fft_vcc_sptr
+gcell_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift=false);
+
+class gcell_fft_vcc : public gr_sync_block
+{
+ protected:
+ gcell_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift);
+
+ public:
+ bool set_window(const std::vector<float> &window);
+};
+
+#else
+
+// This version gives swig heartburn. We end up with an object that's
+// not quite usable.
+
+GR_SWIG_BLOCK_MAGIC(gcell, fft_vcc);
+
+gcell_fft_vcc_sptr
+gcell_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window, bool shift=false);
+
+class gcell_fft_vcc : public gr_fft_vcc
+{
+ protected:
+ gr_fft_vcc(int fft_size, bool forward, const std::vector<float> &window, bool shift);
+};
+
+#endif
diff --git a/gr-gcell/src/qa_fft.py b/gr-gcell/src/qa_fft.py
new file mode 100755
index 000000000..d95b76c4c
--- /dev/null
+++ b/gr-gcell/src/qa_fft.py
@@ -0,0 +1,162 @@
+#!/usr/bin/env python
+#
+# 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.
+#
+
+from gnuradio import gr, gr_unittest
+import gcell
+import sys
+import random
+
+primes = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,
+ 59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,
+ 137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,
+ 227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311)
+
+
+class test_fft_filter(gr_unittest.TestCase):
+
+ def setUp(self):
+ ph = gcell.program_handle_from_filename("../../gcell/src/lib/spu/gcell_all")
+ opts = gcell.jm_options(ph, 1)
+ self.mgr = gcell.job_manager(opts)
+ gcell.set_singleton(self.mgr)
+
+ def tearDown(self):
+ pass
+
+ def assert_fft_ok2(self, expected_result, result_data):
+ expected_result = expected_result[:len(result_data)]
+ self.assertComplexTuplesAlmostEqual2 (expected_result, result_data,
+ abs_eps=1e-9, rel_eps=4e-4)
+
+ def assert_fft_float_ok2(self, expected_result, result_data, abs_eps=1e-9, rel_eps=4e-4):
+ expected_result = expected_result[:len(result_data)]
+ self.assertFloatTuplesAlmostEqual2 (expected_result, result_data,
+ abs_eps, rel_eps)
+
+ def test_001(self):
+ tb = gr.top_block()
+ fft_size = 32
+ src_data = tuple([complex(primes[2*i], primes[2*i+1]) for i in range(fft_size)])
+
+ expected_result = ((4377+4516j),
+ (-1706.1268310546875+1638.4256591796875j),
+ (-915.2083740234375+660.69427490234375j),
+ (-660.370361328125+381.59600830078125j),
+ (-499.96044921875+238.41630554199219j),
+ (-462.26748657226562+152.88948059082031j),
+ (-377.98440551757812+77.5928955078125j),
+ (-346.85821533203125+47.152004241943359j),
+ (-295+20j),
+ (-286.33609008789062-22.257017135620117j),
+ (-271.52999877929688-33.081821441650391j),
+ (-224.6358642578125-67.019538879394531j),
+ (-244.24473571777344-91.524826049804688j),
+ (-203.09068298339844-108.54627227783203j),
+ (-198.45195007324219-115.90768432617188j),
+ (-182.97744750976562-128.12318420410156j),
+ (-167-180j),
+ (-130.33688354492188-173.83778381347656j),
+ (-141.19784545898438-190.28807067871094j),
+ (-111.09677124023438-214.48896789550781j),
+ (-70.039543151855469-242.41630554199219j),
+ (-68.960540771484375-228.30015563964844j),
+ (-53.049201965332031-291.47097778320312j),
+ (-28.695289611816406-317.64553833007812j),
+ (57-300j),
+ (45.301143646240234-335.69509887695312j),
+ (91.936195373535156-373.32437133789062j),
+ (172.09465026855469-439.275146484375j),
+ (242.24473571777344-504.47515869140625j),
+ (387.81732177734375-666.6788330078125j),
+ (689.48553466796875-918.2142333984375j),
+ (1646.539306640625-1694.1956787109375j))
+
+ src = gr.vector_source_c(src_data)
+ s2v = gr.stream_to_vector(gr.sizeof_gr_complex, fft_size)
+ fft = gcell.fft_vcc(fft_size, True, [], False)
+ v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_size)
+ dst = gr.vector_sink_c()
+ tb.connect(src, s2v, fft, v2s, dst)
+ tb.run()
+ result_data = dst.data()
+ #print 'expected:', expected_result
+ #print 'results: ', result_data
+ #self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5)
+ self.assert_fft_ok2(expected_result, result_data)
+
+ def test_002(self):
+ tb = gr.top_block()
+ fft_size = 32
+
+ tmp_data = ((4377+4516j),
+ (-1706.1268310546875+1638.4256591796875j),
+ (-915.2083740234375+660.69427490234375j),
+ (-660.370361328125+381.59600830078125j),
+ (-499.96044921875+238.41630554199219j),
+ (-462.26748657226562+152.88948059082031j),
+ (-377.98440551757812+77.5928955078125j),
+ (-346.85821533203125+47.152004241943359j),
+ (-295+20j),
+ (-286.33609008789062-22.257017135620117j),
+ (-271.52999877929688-33.081821441650391j),
+ (-224.6358642578125-67.019538879394531j),
+ (-244.24473571777344-91.524826049804688j),
+ (-203.09068298339844-108.54627227783203j),
+ (-198.45195007324219-115.90768432617188j),
+ (-182.97744750976562-128.12318420410156j),
+ (-167-180j),
+ (-130.33688354492188-173.83778381347656j),
+ (-141.19784545898438-190.28807067871094j),
+ (-111.09677124023438-214.48896789550781j),
+ (-70.039543151855469-242.41630554199219j),
+ (-68.960540771484375-228.30015563964844j),
+ (-53.049201965332031-291.47097778320312j),
+ (-28.695289611816406-317.64553833007812j),
+ (57-300j),
+ (45.301143646240234-335.69509887695312j),
+ (91.936195373535156-373.32437133789062j),
+ (172.09465026855469-439.275146484375j),
+ (242.24473571777344-504.47515869140625j),
+ (387.81732177734375-666.6788330078125j),
+ (689.48553466796875-918.2142333984375j),
+ (1646.539306640625-1694.1956787109375j))
+
+ src_data = tuple([x/fft_size for x in tmp_data])
+
+ expected_result = tuple([complex(primes[2*i], primes[2*i+1]) for i in range(fft_size)])
+
+ src = gr.vector_source_c(src_data)
+ s2v = gr.stream_to_vector(gr.sizeof_gr_complex, fft_size)
+ fft = gcell.fft_vcc(fft_size, False, [], False)
+ v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_size)
+ dst = gr.vector_sink_c()
+ tb.connect(src, s2v, fft, v2s, dst)
+ tb.run()
+ result_data = dst.data()
+ #print 'expected:', expected_result
+ #print 'results: ', result_data
+ #self.assertComplexTuplesAlmostEqual (expected_result, result_data, 5)
+ self.assert_fft_ok2(expected_result, result_data)
+
+
+if __name__ == '__main__':
+ gr_unittest.main ()
+
diff --git a/gr-gcell/src/run_tests.in b/gr-gcell/src/run_tests.in
new file mode 100644
index 000000000..f7d51750d
--- /dev/null
+++ b/gr-gcell/src/run_tests.in
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# 1st parameter is absolute path to component source directory
+# 2nd parameter is absolute path to component build directory
+# 3rd parameter is path to Python QA directory
+
+@top_builddir@/run_tests.sh \
+ @abs_top_srcdir@/gr-gcell \
+ @abs_top_builddir@/gr-gcell \
+ @srcdir@