[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r4980 - in gnuradio/branches/features/inband-usb: . mb
From: |
eb |
Subject: |
[Commit-gnuradio] r4980 - in gnuradio/branches/features/inband-usb: . mblock/src/lib |
Date: |
Fri, 13 Apr 2007 01:02:51 -0600 (MDT) |
Author: eb
Date: 2007-04-13 01:02:50 -0600 (Fri, 13 Apr 2007)
New Revision: 4980
Added:
gnuradio/branches/features/inband-usb/mblock/src/lib/benchmark_send.cc
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_gettid.cc
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_gettid.h
Modified:
gnuradio/branches/features/inband-usb/configure.ac
gnuradio/branches/features/inband-usb/mblock/src/lib/
gnuradio/branches/features/inband-usb/mblock/src/lib/Makefile.am
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_mblock.cc
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_mblock_impl.cc
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_mblock_impl.h
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_port.h
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_port_simple.cc
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_port_simple.h
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_runtime.h
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_runtime_nop.h
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_runtime_thread_per_block.cc
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_worker.cc
gnuradio/branches/features/inband-usb/mblock/src/lib/qa_bitset.cc
gnuradio/branches/features/inband-usb/mblock/src/lib/qa_mblock_prims.cc
Log:
Merged eb/ibu -r4968:4979 into features/inband-usb.
Now passing 400k messages/s.
Modified: gnuradio/branches/features/inband-usb/configure.ac
===================================================================
--- gnuradio/branches/features/inband-usb/configure.ac 2007-04-13 06:40:18 UTC
(rev 4979)
+++ gnuradio/branches/features/inband-usb/configure.ac 2007-04-13 07:02:50 UTC
(rev 4980)
@@ -114,7 +114,7 @@
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h limits.h strings.h time.h sys/ioctl.h sys/time.h
unistd.h)
AC_CHECK_HEADERS(linux/ppdev.h sys/mman.h sys/select.h sys/types.h)
-AC_CHECK_HEADERS(sys/resource.h stdint.h sched.h signal.h)
+AC_CHECK_HEADERS(sys/resource.h stdint.h sched.h signal.h sys/syscall.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
@@ -131,6 +131,7 @@
AC_CHECK_FUNCS([mmap select socket strcspn strerror strspn getpagesize
sysconf])
AC_CHECK_FUNCS([snprintf gettimeofday nanosleep sched_setscheduler])
AC_CHECK_FUNCS([modf sqrt sigaction sigprocmask])
+AC_CHECK_FUNCS([sched_setaffinity])
AC_CHECK_LIB(m, sincos, [AC_DEFINE([HAVE_SINCOS],[1],[Define to 1 if your
system has `sincos'.])])
AC_CHECK_LIB(m, sincosf,[AC_DEFINE([HAVE_SINCOSF],[1],[Define to 1 if your
system has `sincosf'.])])
Property changes on: gnuradio/branches/features/inband-usb/mblock/src/lib
___________________________________________________________________
Name: svn:ignore
- Makefile
Makefile.in
.la
.lo
.deps
.libs
*.la
*.lo
test_mblock
qa_bitset_mbh.cc
+ Makefile
Makefile.in
.la
.lo
.deps
.libs
*.la
*.lo
test_mblock
qa_bitset_mbh.cc
benchmark_send
Modified: gnuradio/branches/features/inband-usb/mblock/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/Makefile.am
2007-04-13 06:40:18 UTC (rev 4979)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/Makefile.am
2007-04-13 07:02:50 UTC (rev 4980)
@@ -43,6 +43,7 @@
mb_connection.cc \
mb_endpoint.cc \
mb_exception.cc \
+ mb_gettid.cc \
mb_mblock.cc \
mb_mblock_impl.cc \
mb_message.cc \
@@ -72,6 +73,7 @@
mb_class_registry.h \
mb_common.h \
mb_exception.h \
+ mb_gettid.h \
mb_mblock.h \
mb_message.h \
mb_msg_accepter.h \
@@ -119,9 +121,14 @@
-lstdc++
-noinst_PROGRAMS = test_mblock
+noinst_PROGRAMS = \
+ test_mblock \
+ benchmark_send
test_mblock_SOURCES = test_mblock.cc
test_mblock_LDADD = libmblock-qa.la
+benchmark_send_SOURCES = benchmark_send.cc
+benchmark_send_LDADD = libmblock-qa.la
+
CLEANFILES = $(BUILT_SOURCES) *.pyc
Copied: gnuradio/branches/features/inband-usb/mblock/src/lib/benchmark_send.cc
(from rev 4979,
gnuradio/branches/developers/eb/ibu/mblock/src/lib/benchmark_send.cc)
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/benchmark_send.cc
(rev 0)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/benchmark_send.cc
2007-04-13 07:02:50 UTC (rev 4980)
@@ -0,0 +1,45 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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 2, 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 <mb_runtime.h>
+#include <iostream>
+
+int
+main(int argc, char **argv)
+{
+ mb_runtime_sptr rt = mb_make_runtime();
+ pmt_t result = PMT_NIL;
+
+ long nmsgs = 1000000;
+ long batch_size = 100;
+
+ pmt_t arg = pmt_list2(pmt_from_long(nmsgs), // # of messages to send
through pipe
+ pmt_from_long(batch_size));
+
+ rt->run("top", "qa_bitset_top", arg, &result);
+
+ if (!pmt_equal(PMT_T, result)){
+ std::cerr << "benchmark_send: incorrect result";
+ return 1;
+ }
+
+ return 0;
+}
Copied: gnuradio/branches/features/inband-usb/mblock/src/lib/mb_gettid.cc (from
rev 4979, gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_gettid.cc)
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/mb_gettid.cc
(rev 0)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/mb_gettid.cc
2007-04-13 07:02:50 UTC (rev 4980)
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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 2, 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 <mb_gettid.h>
+
+#define NEED_STUB
+
+#if defined(HAVE_SYS_SYSCALL_H) && defined(HAVE_UNISTD_H)
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#if defined(SYS_gettid)
+#undef NEED_STUB
+
+int mb_gettid()
+{
+ return syscall(SYS_gettid);
+}
+
+#endif
+#endif
+
+#if defined(NEED_STUB)
+
+int
+mb_gettid()
+{
+ return 0;
+}
+
+#endif
Copied: gnuradio/branches/features/inband-usb/mblock/src/lib/mb_gettid.h (from
rev 4979, gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_gettid.h)
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/mb_gettid.h
(rev 0)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/mb_gettid.h
2007-04-13 07:02:50 UTC (rev 4980)
@@ -0,0 +1,26 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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 2, 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.
+ */
+
+/*!
+ * \brief Return Linux taskid, or 0 if not available
+ */
+int mb_gettid();
+
Modified: gnuradio/branches/features/inband-usb/mblock/src/lib/mb_mblock.cc
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/mb_mblock.cc
2007-04-13 06:40:18 UTC (rev 4979)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/mb_mblock.cc
2007-04-13 07:02:50 UTC (rev 4980)
@@ -48,9 +48,6 @@
mb_mblock::~mb_mblock()
{
- disconnect_all();
-
- // FIXME more?
}
Modified: gnuradio/branches/features/inband-usb/mblock/src/lib/mb_mblock_impl.cc
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/mb_mblock_impl.cc
2007-04-13 06:40:18 UTC (rev 4979)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/mb_mblock_impl.cc
2007-04-13 07:02:50 UTC (rev 4980)
@@ -30,8 +30,8 @@
#include <mb_exception.h>
#include <mb_util.h>
#include <mb_msg_accepter_smp.h>
-//#include <mb_runtime_placeholder.h>
#include <mbi_runtime_lock.h>
+#include <iostream>
static pmt_t s_self = pmt_intern("self");
@@ -139,6 +139,7 @@
mbi_runtime_lock l(this);
d_conn_table.disconnect(comp_name1, port_name1, comp_name2, port_name2);
+ invalidate_all_port_caches();
}
void
@@ -147,6 +148,7 @@
mbi_runtime_lock l(this);
d_conn_table.disconnect_component(component_name);
+ invalidate_all_port_caches();
}
void
@@ -155,6 +157,7 @@
mbi_runtime_lock l(this);
d_conn_table.disconnect_all();
+ invalidate_all_port_caches();
}
int
@@ -248,12 +251,11 @@
}
mb_msg_accepter_sptr
-mb_mblock_impl::make_accepter(const std::string port_name)
+mb_mblock_impl::make_accepter(pmt_t port_name)
{
// FIXME this should probably use some kind of configurable factory
mb_msg_accepter *ma =
- new mb_msg_accepter_smp(d_mb->shared_from_this(),
- pmt_intern(port_name));
+ new mb_msg_accepter_smp(d_mb->shared_from_this(), port_name);
return mb_msg_accepter_sptr(ma);
}
@@ -294,3 +296,42 @@
{
d_class_name = name;
}
+
+/*
+ * This is the "Big Hammer" port cache invalidator.
+ * It invalidates _all_ of the port caches in the entire mblock tree.
+ * It's overkill, but was simple to code.
+ */
+void
+mb_mblock_impl::invalidate_all_port_caches()
+{
+ class invalidator : public mb_visitor
+ {
+ public:
+ bool operator()(mb_mblock *mblock)
+ {
+ mb_mblock_impl_sptr impl = mblock->impl();
+ mb_port_map_t::iterator it = impl->d_port_map.begin();
+ mb_port_map_t::iterator end = impl->d_port_map.end();
+ for (; it != end; ++it)
+ it->second->invalidate_cache();
+ return true;
+ }
+ };
+
+ class nop : public mb_visitor
+ {
+ public:
+ bool operator()(mb_mblock *mblock)
+ {
+ return true;
+ }
+ };
+
+ invalidator visitor;
+ nop visitor2;
+
+ // Always true, except in early QA code
+ if (runtime()->top())
+ runtime()->top()->walk_tree(&visitor2);
+}
Modified: gnuradio/branches/features/inband-usb/mblock/src/lib/mb_mblock_impl.h
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/mb_mblock_impl.h
2007-04-13 06:40:18 UTC (rev 4979)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/mb_mblock_impl.h
2007-04-13 07:02:50 UTC (rev 4980)
@@ -146,7 +146,7 @@
walk_tree(mb_visitor *visitor);
mb_msg_accepter_sptr
- make_accepter(const std::string port_name);
+ make_accepter(pmt_t port_name);
mb_msg_queue &
msgq() { return d_msgq; }
@@ -212,6 +212,12 @@
endpoints_are_compatible(const mb_endpoint &ep0,
const mb_endpoint &ep1);
+ /*!
+ * \brief walk mblock tree and invalidate all port resolution caches.
+ * \implementation
+ */
+ void
+ invalidate_all_port_caches();
};
Modified: gnuradio/branches/features/inband-usb/mblock/src/lib/mb_port.h
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/mb_port.h
2007-04-13 06:40:18 UTC (rev 4979)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/mb_port.h
2007-04-13 07:02:50 UTC (rev 4980)
@@ -82,6 +82,12 @@
pmt_t data = PMT_NIL,
pmt_t metadata = PMT_NIL,
mb_pri_t priority = MB_PRI_DEFAULT) = 0;
+
+ /*
+ * \brief Invalidate any cached peer resolutions
+ * \implementation
+ */
+ virtual void invalidate_cache() = 0;
};
#endif /* INCLUDED_MB_PORT_H */
Modified: gnuradio/branches/features/inband-usb/mblock/src/lib/mb_port_simple.cc
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/mb_port_simple.cc
2007-04-13 06:40:18 UTC (rev 4979)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/mb_port_simple.cc
2007-04-13 07:02:50 UTC (rev 4980)
@@ -37,7 +37,8 @@
const std::string &protocol_class_name,
bool conjugated,
mb_port::port_type_t port_type)
- : mb_port(mblock, port_name, protocol_class_name, conjugated, port_type)
+ : mb_port(mblock, port_name, protocol_class_name, conjugated, port_type),
+ d_cache_valid(false)
{
}
@@ -67,6 +68,9 @@
mb_endpoint peer_ep;
mb_msg_accepter_sptr r;
+ if (start->d_cache_valid)
+ return start->d_cached_accepter;
+
mbi_runtime_lock l(p->mblock());
// Set up initial context.
@@ -99,7 +103,11 @@
case mb_port::INTERNAL: // Terminate here.
case mb_port::EXTERNAL:
r = pp->make_accepter();
- // FIXME cache the result
+
+ // cache the result
+
+ start->d_cached_accepter = r;
+ start->d_cache_valid = true;
return r;
case mb_port::RELAY: // Traverse to other side of relay port.
@@ -132,5 +140,12 @@
mb_msg_accepter_sptr
mb_port_simple::make_accepter()
{
- return d_mblock->impl()->make_accepter(port_name());
+ return d_mblock->impl()->make_accepter(port_symbol());
}
+
+void
+mb_port_simple::invalidate_cache()
+{
+ d_cache_valid = false;
+ d_cached_accepter.reset();
+}
Modified: gnuradio/branches/features/inband-usb/mblock/src/lib/mb_port_simple.h
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/mb_port_simple.h
2007-04-13 06:40:18 UTC (rev 4979)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/mb_port_simple.h
2007-04-13 07:02:50 UTC (rev 4980)
@@ -28,6 +28,9 @@
*/
class mb_port_simple : public mb_port
{
+ bool d_cache_valid;
+ mb_msg_accepter_sptr d_cached_accepter;
+
protected:
static mb_msg_accepter_sptr
find_accepter(mb_port_simple *start);
@@ -57,6 +60,13 @@
pmt_t data = PMT_NIL,
pmt_t metadata = PMT_NIL,
mb_pri_t priority = MB_PRI_DEFAULT);
+
+ /*
+ * \brief Invalidate any cached peer resolutions
+ * \implementation
+ */
+ void invalidate_cache();
+
};
#endif /* INCLUDED_MB_PORT_SIMPLE_H */
Modified: gnuradio/branches/features/inband-usb/mblock/src/lib/mb_runtime.h
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/mb_runtime.h
2007-04-13 06:40:18 UTC (rev 4979)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/mb_runtime.h
2007-04-13 07:02:50 UTC (rev 4980)
@@ -39,8 +39,12 @@
{
friend class mb_mblock_impl;
- omni_mutex d_brl; // big runtime lock (avoid using this if
possible...)
+ omni_mutex d_brl; // big runtime lock (avoid using this if
possible...)
+protected:
+ mb_mblock_sptr d_top;
+
+
public:
mb_runtime(){}
virtual ~mb_runtime();
@@ -81,6 +85,8 @@
virtual void request_shutdown(pmt_t result);
+ mb_mblock_sptr top() { return d_top; }
+
protected:
virtual mb_mblock_sptr
create_component(const std::string &instance_name,
Modified: gnuradio/branches/features/inband-usb/mblock/src/lib/mb_runtime_nop.h
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/mb_runtime_nop.h
2007-04-13 06:40:18 UTC (rev 4979)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/mb_runtime_nop.h
2007-04-13 07:02:50 UTC (rev 4980)
@@ -33,8 +33,6 @@
*/
class mb_runtime_nop : public mb_runtime
{
- mb_mblock_sptr d_top;
-
public:
mb_runtime_nop();
~mb_runtime_nop();
@@ -44,9 +42,6 @@
pmt_t user_arg,
pmt_t *result);
- // QA only
- mb_mblock_sptr top() { return d_top; }
-
protected:
mb_mblock_sptr
create_component(const std::string &instance_name,
Modified:
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_runtime_thread_per_block.cc
===================================================================
---
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_runtime_thread_per_block.cc
2007-04-13 06:40:18 UTC (rev 4979)
+++
gnuradio/branches/features/inband-usb/mblock/src/lib/mb_runtime_thread_per_block.cc
2007-04-13 07:02:50 UTC (rev 4980)
@@ -94,13 +94,20 @@
* Create the top-level component, and recursively all of its
* subcomponents.
*/
- mb_mblock_sptr top = create_component(instance_name, class_name, user_arg);
+ d_top = create_component(instance_name, class_name, user_arg);
- run_loop();
+ try {
+ run_loop();
+ }
+ catch (...){
+ d_top.reset();
+ throw;
+ }
if (result)
*result = d_shutdown_result;
+ d_top.reset();
return true;
}
Modified: gnuradio/branches/features/inband-usb/mblock/src/lib/mb_worker.cc
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/mb_worker.cc
2007-04-13 06:40:18 UTC (rev 4979)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/mb_worker.cc
2007-04-13 07:02:50 UTC (rev 4980)
@@ -26,26 +26,14 @@
#include <mb_runtime_thread_per_block.h>
#include <mb_exception.h>
#include <mb_mblock.h>
+#include <mb_gettid.h>
#include <iostream>
+#ifdef HAVE_SCHED_H
+#include <sched.h>
+#endif
#define VERBOSE 0 // define to 0 or 1
-#include <sys/syscall.h> // Move this somewhere else and autoconf
-#include <unistd.h>
-
-#ifdef SYS_gettid
-int mb_gettid()
-{
- return syscall(SYS_gettid);
-}
-#else
-int mb_gettid()
-{
- return -1;
-}
-#endif
-
-
mb_worker::mb_worker(mb_runtime_thread_per_block *runtime,
mb_mblock_maker_t maker,
const std::string &instance_name,
@@ -64,6 +52,32 @@
}
#endif
+#ifdef HAVE_SCHED_SETAFFINITY
+static void
+set_affinity(const std::string &instance_name, const std::string &class_name)
+{
+ static int counter = 0;
+ cpu_set_t mask;
+ CPU_ZERO(&mask);
+
+ if (0){
+
+ //CPU_SET(counter & 0x1, &mask);
+ //counter++;
+ CPU_SET(0, &mask);
+
+ int r = sched_setaffinity(mb_gettid(), sizeof(mask), &mask);
+ if (r == -1)
+ perror("sched_setaffinity");
+ }
+}
+#else
+static void
+set_affinity(const std::string &instance_name, const std::string &class_name)
+{
+}
+#endif
+
void
mb_worker::set_state(worker_state_t state)
{
@@ -80,6 +94,9 @@
{
// FIXME add pthread_sigmask stuff
+ //set_affinity(d_instance_name, d_class_name);
+ set_affinity(d_instance_name, "");
+
try {
worker_thread_top_level();
d_why_dead = RIP_EXIT;
Modified: gnuradio/branches/features/inband-usb/mblock/src/lib/qa_bitset.cc
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/qa_bitset.cc
2007-04-13 06:40:18 UTC (rev 4979)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/qa_bitset.cc
2007-04-13 07:02:50 UTC (rev 4980)
@@ -27,6 +27,7 @@
#include <mb_message.h>
#include <mb_class_registry.h>
#include <iostream>
+#include <sstream>
#include <bitset>
static pmt_t s_in = pmt_intern("in");
@@ -36,6 +37,14 @@
static pmt_t s_send_batch = pmt_intern("send-batch");
static pmt_t s_long0 = pmt_from_long(0);
+static std::string
+str(long x)
+{
+ std::ostringstream s;
+ s << x;
+ return s.str();
+}
+
class qa_bitset : public mb_mblock
{
mb_port_sptr d_in;
@@ -390,7 +399,9 @@
class qa_bitset_top : public mb_mblock
{
- mb_port_sptr d_cs0;
+ static const int NPIPES = 4;
+
+ std::vector<mb_port_sptr> d_cs;
long d_nmsgs; // # of messages to send
long d_batch_size; // # of messages to receive per batch
@@ -405,36 +416,48 @@
: mb_mblock(runtime, instance_name, user_arg)
{
d_nmsgs = pmt_to_long(pmt_nth(0, user_arg));
+ d_nmsgs = (d_nmsgs / NPIPES) * NPIPES;
d_batch_size = pmt_to_long(pmt_nth(1, user_arg));
- d_cs0 = define_port("cs0", "qa-bitset-cs", false, mb_port::INTERNAL);
+ /*
+ * We build NPIPES sources which feed NPIPES pipelines, each of which
+ * consists of 8-mblocks. All pipelines feed into a single sink
+ * which keeps track the results.
+ */
+ for (int i = 0; i < NPIPES; i++){
+ d_cs.push_back(define_port("cs"+str(i), "qa-bitset-cs", false,
mb_port::INTERNAL));
- // source of test messages
- define_component("src0", "qa_bitset_src",
- pmt_list3(pmt_from_long(0),
- pmt_from_long(d_nmsgs),
- pmt_from_long(d_batch_size)));
+ // sources of test messages
+ define_component("src"+str(i), "qa_bitset_src",
+ pmt_list3(pmt_from_long(i * d_nmsgs/NPIPES),
+ pmt_from_long(d_nmsgs/NPIPES),
+ pmt_from_long(d_batch_size)));
- // 32-mblock processing pipeline
- define_component("pipeline", "qa_bitset32", pmt_from_long(0));
+ // 8-mblock processing pipelines
+ define_component("pipeline"+str(i), "qa_bitset8", pmt_from_long(0));
+ }
- // sink for output of pipeline
+ // sink for output of pipelines
define_component("sink", "qa_bitset_sink",
pmt_list3(pmt_from_long(d_nmsgs),
- pmt_from_long(d_batch_size),
- pmt_from_long(0xffffffff)));
+ pmt_from_long(d_batch_size * NPIPES),
+ pmt_from_long(0x000000ff)));
- connect("self", "cs0", "src0", "cs_top");
- connect("src0", "out", "pipeline", "in");
- connect("src0", "cs", "sink", "cs0");
- connect("pipeline", "out", "sink", "in0");
+ for (int i = 0; i < NPIPES; i++){
+ connect("self", "cs"+str(i), "src"+str(i), "cs_top");
+ connect("src"+str(i), "out", "pipeline"+str(i), "in");
+ connect("src"+str(i), "cs", "sink", "cs"+str(i));
+ connect("pipeline"+str(i), "out", "sink", "in"+str(i));
+ }
}
void
qa_bitset_top::initial_transition()
{
- d_cs0->send(s_send_batch); // prime the pump
- d_cs0->send(s_send_batch);
+ for (int i = 0; i < NPIPES; i++){
+ d_cs[i]->send(s_send_batch); // prime the pump
+ d_cs[i]->send(s_send_batch);
+ }
}
REGISTER_MBLOCK_CLASS(qa_bitset_top);
Modified:
gnuradio/branches/features/inband-usb/mblock/src/lib/qa_mblock_prims.cc
===================================================================
--- gnuradio/branches/features/inband-usb/mblock/src/lib/qa_mblock_prims.cc
2007-04-13 06:40:18 UTC (rev 4979)
+++ gnuradio/branches/features/inband-usb/mblock/src/lib/qa_mblock_prims.cc
2007-04-13 07:02:50 UTC (rev 4980)
@@ -425,7 +425,7 @@
mb_mblock_sptr mb = mb_mblock_sptr(new dp_2(rt, "top", PMT_F));
// use "internal use only" method...
- mb_msg_accepter_sptr accepter = mb->impl()->make_accepter("cs");
+ mb_msg_accepter_sptr accepter = mb->impl()->make_accepter(pmt_intern("cs"));
// Now push a few messages into it...
// signal data metadata pri
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r4980 - in gnuradio/branches/features/inband-usb: . mblock/src/lib,
eb <=