[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8307 - in gnuradio/branches/developers/eb/gcell-wip/g
From: |
eb |
Subject: |
[Commit-gnuradio] r8307 - in gnuradio/branches/developers/eb/gcell-wip/gcell/src: apps/spu include lib/general/spu lib/runtime/spu lib/spu lib/wrapper |
Date: |
Sun, 4 May 2008 00:18:54 -0600 (MDT) |
Author: eb
Date: 2008-05-04 00:18:54 -0600 (Sun, 04 May 2008)
New Revision: 8307
Added:
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/general/spu/qa_memset.c
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/qa_gcell_general.cc
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/qa_gcell_general.h
Modified:
gnuradio/branches/developers/eb/gcell-wip/gcell/src/apps/spu/benchmark_procs.c
gnuradio/branches/developers/eb/gcell-wip/gcell/src/include/compiler.h
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/general/spu/memset.S
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/spu/gcell_runtime_qa.c
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/spu/Makefile.am
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/Makefile.am
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/qa_gcell_wrapper.cc
Log:
44GB/s memset for SPE. Within 3% of ideal. Created easy to use QA
framework to handle SPE utility code that's usually not called from
the PPE. See qa_gcell_general.{h,cc} and qa_memset.c for example usage.
Modified:
gnuradio/branches/developers/eb/gcell-wip/gcell/src/apps/spu/benchmark_procs.c
===================================================================
---
gnuradio/branches/developers/eb/gcell-wip/gcell/src/apps/spu/benchmark_procs.c
2008-05-03 19:25:32 UTC (rev 8306)
+++
gnuradio/branches/developers/eb/gcell-wip/gcell/src/apps/spu/benchmark_procs.c
2008-05-04 06:18:54 UTC (rev 8307)
@@ -23,9 +23,6 @@
#include <gc_declare_proc.h>
#include <string.h>
-#define _UNUSED __attribute__((unused))
-
-
static void
benchmark_udelay(const gc_job_direct_args_t *input,
gc_job_direct_args_t *output _UNUSED,
Modified: gnuradio/branches/developers/eb/gcell-wip/gcell/src/include/compiler.h
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/gcell/src/include/compiler.h
2008-05-03 19:25:32 UTC (rev 8306)
+++ gnuradio/branches/developers/eb/gcell-wip/gcell/src/include/compiler.h
2008-05-04 06:18:54 UTC (rev 8307)
@@ -30,6 +30,8 @@
#define _AL16 __attribute__((aligned (16)))
#define _AL128 __attribute__((aligned (128)))
+#define _UNUSED __attribute__((unused))
+
#ifndef likely
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
Modified:
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/general/spu/memset.S
===================================================================
---
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/general/spu/memset.S
2008-05-03 19:25:32 UTC (rev 8306)
+++
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/general/spu/memset.S
2008-05-04 06:18:54 UTC (rev 8307)
@@ -54,9 +54,9 @@
#define m r22
#define r r23
- PROC_ENTRY(memset_spe2)
+ PROC_ENTRY(memset)
- // Hint the return from do_head, in case we head that way.
+ // Hint the return from do_head, in case we go that way.
// There's pretty much nothing to can do to hint the branch to it.
hbrr do_head_br, head_complete
Added:
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/general/spu/qa_memset.c
===================================================================
---
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/general/spu/qa_memset.c
(rev 0)
+++
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/general/spu/qa_memset.c
2008-05-04 06:18:54 UTC (rev 8307)
@@ -0,0 +1,201 @@
+/* -*- 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.
+ */
+
+#include <gc_declare_proc.h>
+#include <string.h>
+#include <stdio.h>
+#include <spu_intrinsics.h>
+#include <spu_mfcio.h>
+
+
+#define MAX_QA_BYTES 1024
+#define MAX_OFFSET 32
+#define ALIGNMENT 16
+#define K 0xA5
+
+// FIXME should be passed at gcell init time
+//static const int TIMEBASE = 79800000; // ps3
+static const int TIMEBASE = 26666666; // qs21
+
+typedef void* (*memset_fptr)(void *s, int val, size_t n);
+
+void *
+memset_ref(void *sv, int c, size_t n)
+{
+ unsigned char *s = (unsigned char *) sv;
+ size_t i;
+ for (i = 0; i < n; i++)
+ s[i] = c;
+
+ return sv;
+}
+
+static bool
+check_before(unsigned char *buf, size_t len, size_t offset)
+{
+ unsigned char *p = buf + sizeof(vector unsigned char) + offset;
+ bool ok = true;
+ int i;
+
+ for (i = -16; i < 0; i++){
+ unsigned char expected = (&p[i] - buf) & 0xff;
+ if (p[i] != expected){
+ printf("b:memset(%p, 0x%x, %zu) <offset %2zd> [%3d] expected %02x, got
%02x\n",
+ p, K, len, offset, i, K, p[i]);
+ ok = false;
+ }
+ }
+ return ok;
+}
+
+static bool
+check_middle(unsigned char *buf, size_t len, size_t offset)
+{
+ unsigned char *p = buf + sizeof(vector unsigned char) + offset;
+ bool ok = true;
+ size_t i;
+
+ for (i = 0; i < len; i++){
+ unsigned char expected = K;
+ if (p[i] != expected){
+ printf("m:memset(%p, 0x%x, %zu) <offset %2zd> [%3zd] expected %02x, got
%02x\n",
+ p, K, len, offset, i, expected, p[i]);
+ ok = false;
+ }
+ }
+ return ok;
+}
+
+static bool
+check_after(unsigned char *buf, size_t len, size_t offset)
+{
+ unsigned char *p = buf + sizeof(vector unsigned char) + offset;
+ bool ok = true;
+ size_t i;
+
+ for (i = len; i < len + 16; i++){
+ unsigned char expected = (&p[i] - buf) & 0xff;
+ if (p[i] != expected){
+ printf("a:memset(%p, 0x%x, %zu) <offset %2zd> [%3zd] expected %02x, got
%02x\n",
+ p, K, len, offset, i, expected, p[i]);
+ ok = false;
+ }
+ }
+ return ok;
+}
+
+
+static bool
+test_memset_aux(memset_fptr f,
+ unsigned char *buf, size_t buflen, size_t len, size_t offset)
+{
+ size_t i;
+
+ // init buffer to non-zero known state
+ for (i = 0; i < buflen; i++)
+ buf[i] = i;
+
+ // Our working buffer. Starts 16 bytes + offset into buf.
+ // We offset by 16 so that we can see if data before is getting damaged.
+ unsigned char *p = buf + sizeof(vector unsigned char) + offset;
+
+ (*f)(p, K, len);
+
+ bool ok = true;
+ ok &= check_before(buf, len, offset);
+ ok &= check_middle(buf, len, offset);
+ ok &= check_after(buf, len, offset);
+
+ return ok;
+}
+
+bool
+test_memset(memset_fptr f)
+{
+ size_t BUFLEN = MAX_QA_BYTES + 2*sizeof(vector unsigned char) + MAX_OFFSET;
+ unsigned char unaligned_buf[BUFLEN + ALIGNMENT -1];
+ unsigned char *aligned_buf =
+ (unsigned char *)((((intptr_t) unaligned_buf) + ALIGNMENT - 1) &
-ALIGNMENT);
+
+ // printf("unaligned = %p\n", unaligned_buf);
+ // printf("aligned = %p\n", aligned_buf);
+
+ size_t len;
+ size_t offset;
+ bool ok = true;
+
+ for (len = 0; len < MAX_QA_BYTES; len++){
+ for (offset = 0; offset <= MAX_OFFSET; offset++){
+ ok &= test_memset_aux(f, aligned_buf, BUFLEN, len, offset);
+ }
+ }
+
+ return ok;
+}
+
+// returns bytes/s
+float
+benchmark_memset(memset_fptr f, bool aligned)
+{
+ static const int SIZE = 32768;
+ unsigned char buf[SIZE];
+ uint32_t t0, t1;
+ int nbytes;
+
+ spu_write_decrementer(0xffffffff);
+
+ if (aligned){
+ nbytes = SIZE;
+ t0 = spu_read_decrementer();
+ (*f)(buf, 0x55, nbytes);
+ (*f)(buf, 0x55, nbytes);
+ (*f)(buf, 0x55, nbytes);
+ (*f)(buf, 0x55, nbytes);
+ t1 = spu_read_decrementer();
+ }
+ else {
+ nbytes = SIZE - 2;
+ t0 = spu_read_decrementer();
+ (*f)(buf + 1, 0x55, nbytes);
+ (*f)(buf + 1, 0x55, nbytes);
+ (*f)(buf + 1, 0x55, nbytes);
+ (*f)(buf + 1, 0x55, nbytes);
+ t1 = spu_read_decrementer();
+ }
+
+ //printf("delta ticks: %d\n", t0 - t1);
+ return (float) nbytes * 4 / ((t0 - t1) * 1.0/TIMEBASE);
+}
+
+/*
+ * Implement the standard QA stub.
+ * No input arguments, 1 bool output.
+ */
+static void
+gcs_qa_memset(const gc_job_direct_args_t *input _UNUSED,
+ gc_job_direct_args_t *output,
+ const gc_job_ea_args_t *eaa _UNUSED)
+{
+ bool ok = test_memset(memset);
+ output->arg[0].u32 = ok;
+}
+
+GC_DECLARE_PROC(gcs_qa_memset, "qa_memset");
Property changes on:
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/general/spu/qa_memset.c
___________________________________________________________________
Name: svn:eol-style
+ native
Modified:
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/spu/gcell_runtime_qa.c
===================================================================
---
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/spu/gcell_runtime_qa.c
2008-05-03 19:25:32 UTC (rev 8306)
+++
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/runtime/spu/gcell_runtime_qa.c
2008-05-04 06:18:54 UTC (rev 8307)
@@ -24,10 +24,6 @@
#include <string.h>
-#define _UNUSED __attribute__((unused))
-
-// FIXME move these out of here; only for QA usage
-
static void
qa_nop(const gc_job_direct_args_t *input _UNUSED,
gc_job_direct_args_t *output _UNUSED,
Modified:
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/spu/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/spu/Makefile.am
2008-05-03 19:25:32 UTC (rev 8306)
+++ gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/spu/Makefile.am
2008-05-04 06:18:54 UTC (rev 8307)
@@ -66,8 +66,11 @@
general_spu_noinst_headers = \
$(general_srcdir)/fft_1d.h \
- $(general_srcdir)/fft_1d_r2.h
+ $(general_srcdir)/fft_1d_r2.h
+# The QA code for (usually) non-PPE visible support routines in lib/general/spu
+general_spu_qa_sources = \
+ $(general_srcdir)/qa_memset.c
# ----------------------------------------------------------------
# files in the lib/wrapper/spu directory
@@ -100,16 +103,27 @@
$(wrapper_spu_noinst_headers)
# ----------------------------------------------------------------
-# SPU executables
+# build some SPU executables
noinst_PROGRAMS = \
gcell_all \
- gcell_runtime_qa
+ gcell_runtime_qa \
+ gcell_general_qa
-# all known gcell procs (at least until they get too big)
+#
+# All known non-QA gcell procs (at least until they get too big).
+#
gcell_all_SOURCES = $(wrapper_spu_sources)
gcell_all_LDADD = libgcell_spu.a
-# just the QA code required for testing the runtime
+#
+# The QA code required for testing the runtime.
+#
gcell_runtime_qa_SOURCES = $(runtime_srcdir)/gcell_runtime_qa.c
gcell_runtime_qa_LDADD = libgcell_spu.a
+
+#
+# The QA code required for testing the SPE support routines in lib/general/spu
+#
+gcell_general_qa_SOURCES = $(general_spu_qa_sources)
+gcell_general_qa_LDADD = libgcell_spu.a
Modified:
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/Makefile.am
2008-05-03 19:25:32 UTC (rev 8306)
+++ gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/Makefile.am
2008-05-04 06:18:54 UTC (rev 8307)
@@ -24,27 +24,46 @@
noinst_LTLIBRARIES = libwrapper.la libwrapper-qa.la
-# generate a libtool.lo that contains an embeded SPU executable
+#
+# generate libtool.lo's that contain embedded SPU executables
+#
gcell_all.lo: ../spu/gcell_all
$(GCELL_EMBEDSPU_LIBTOOL) $@ $<
+gcell_general_qa.lo: ../spu/gcell_general_qa
+ $(GCELL_EMBEDSPU_LIBTOOL) $@ $<
+
+
+
+# The primary library
+
libwrapper_la_SOURCES = \
gcp_fft_1d_r2.cc
libwrapper_la_LIBADD = \
gcell_all.lo
+
+# The QA library
+
libwrapper_qa_la_SOURCES = \
+ qa_gcell_general.cc \
qa_gcell_wrapper.cc \
qa_gcp_fft_1d_r2.cc
libwrapper_qa_la_LIBADD = \
+ gcell_general_qa.lo \
-lfftw3f
+# Headers
+
gcellinclude_HEADERS = \
gcp_fft_1d_r2.h
noinst_HEADERS = \
+ qa_gcell_general.h \
qa_gcell_wrapper.h
-CLEANFILES = gcell_all.lo
+
+CLEANFILES = gcell_all.lo gcell_general_qa.lo
+
Added:
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/qa_gcell_general.cc
===================================================================
---
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/qa_gcell_general.cc
(rev 0)
+++
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/qa_gcell_general.cc
2008-05-04 06:18:54 UTC (rev 8307)
@@ -0,0 +1,83 @@
+/* -*- 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.
+ */
+
+#include "qa_gcell_general.h"
+#include <cppunit/TestAssert.h>
+
+#include <stdio.h>
+#include <stdlib.h> // random, posix_memalign
+#include <algorithm>
+#include <string.h>
+#include <gc_job_manager.h>
+
+
+// handle to embedded SPU executable
+extern spe_program_handle_t gcell_general_qa;
+
+gc_job_desc_sptr
+gcp_qa_general_submit(gc_job_manager_sptr mgr, const std::string &proc_name)
+{
+ gc_proc_id_t proc_id = mgr->lookup_proc(proc_name);
+ gc_job_desc_sptr jd = gc_job_manager::alloc_job_desc(mgr);
+
+ jd->proc_id = proc_id;
+ jd->input.nargs = 0;
+ jd->output.nargs = 1;
+ jd->eaa.nargs = 0;
+
+ if (!mgr->submit_job(jd.get())){
+ gc_job_status_t s = jd->status;
+ throw gc_bad_submit(proc_name, s);
+ }
+ return jd;
+}
+
+
+bool
+qa_gcell_general::generic_test_body(const std::string &proc_name)
+{
+ gc_jm_options opts;
+ opts.program_handle = gc_program_handle_from_address(&gcell_general_qa);
+ opts.nspes = 1;
+ gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
+
+ gc_job_desc_sptr jd = gcp_qa_general_submit(mgr, proc_name);
+ if (!mgr->wait_job(jd.get())){
+ fprintf(stderr, "wait_job for %s failed: %s\n",
+ proc_name.c_str(),
+ gc_job_status_string(jd->status).c_str());
+ CPPUNIT_ASSERT(0);
+ }
+
+ return jd->output.arg[0].u32; // bool result from SPE code
+}
+
+/*
+ * ------------------------------------------------------------------------
+ * Add more calls to SPE QA code here...
+ * ------------------------------------------------------------------------
+ */
+void
+qa_gcell_general::test_memset()
+{
+ CPPUNIT_ASSERT(generic_test_body("qa_memset"));
+}
+
Property changes on:
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/qa_gcell_general.cc
___________________________________________________________________
Name: svn:eol-style
+ native
Added:
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/qa_gcell_general.h
===================================================================
---
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/qa_gcell_general.h
(rev 0)
+++
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/qa_gcell_general.h
2008-05-04 06:18:54 UTC (rev 8307)
@@ -0,0 +1,40 @@
+/* -*- 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_QA_GCELL_GENERAL_H
+#define INCLUDED_QA_GCELL_GENERAL_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_gcell_general : public CppUnit::TestCase {
+
+ CPPUNIT_TEST_SUITE(qa_gcell_general);
+ CPPUNIT_TEST(test_memset);
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+ void test_memset();
+
+ bool generic_test_body(const std::string &proc_name);
+};
+
+#endif /* INCLUDED_QA_GCELL_GENERAL_H */
Property changes on:
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/qa_gcell_general.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified:
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/qa_gcell_wrapper.cc
===================================================================
---
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/qa_gcell_wrapper.cc
2008-05-03 19:25:32 UTC (rev 8306)
+++
gnuradio/branches/developers/eb/gcell-wip/gcell/src/lib/wrapper/qa_gcell_wrapper.cc
2008-05-04 06:18:54 UTC (rev 8307)
@@ -20,12 +20,13 @@
*/
/*
- * This class gathers together all the test cases for the lib
+ * This class gathers together all the test cases for the lib/wrapper
* directory into a single test suite. As you create new test cases,
* add them here.
*/
#include <qa_gcell_wrapper.h>
+#include <qa_gcell_general.h>
#include <qa_gcp_fft_1d_r2.h>
CppUnit::TestSuite *
@@ -33,6 +34,7 @@
{
CppUnit::TestSuite *s = new CppUnit::TestSuite("wrapper");
+ s->addTest(qa_gcell_general::suite());
s->addTest(qa_gcp_fft_1d_r2::suite());
return s;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8307 - in gnuradio/branches/developers/eb/gcell-wip/gcell/src: apps/spu include lib/general/spu lib/runtime/spu lib/spu lib/wrapper,
eb <=