commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r8681 - in gnuradio/branches/developers/eb/tbb-sched:


From: eb
Subject: [Commit-gnuradio] r8681 - in gnuradio/branches/developers/eb/tbb-sched: config gnuradio-core/src/lib gnuradio-core/src/lib/runtime
Date: Mon, 23 Jun 2008 15:20:38 -0600 (MDT)

Author: eb
Date: 2008-06-23 15:20:36 -0600 (Mon, 23 Jun 2008)
New Revision: 8681

Added:
   
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_block_task.cc
   
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_block_task.h
   
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_top_task.cc
   
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_top_task.h
   
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_top_block_impl_tbb.cc
   
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_top_block_impl_tbb.h
Modified:
   gnuradio/branches/developers/eb/tbb-sched/config/grc_gnuradio_core.m4
   gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/Makefile.am
   
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/Makefile.am
Log:
Merged tbb specific stuff from eb/mp-sched r8447:8660.



Modified: gnuradio/branches/developers/eb/tbb-sched/config/grc_gnuradio_core.m4
===================================================================
--- gnuradio/branches/developers/eb/tbb-sched/config/grc_gnuradio_core.m4       
2008-06-23 21:00:49 UTC (rev 8680)
+++ gnuradio/branches/developers/eb/tbb-sched/config/grc_gnuradio_core.m4       
2008-06-23 21:20:36 UTC (rev 8681)
@@ -31,6 +31,11 @@
     dnl Don't do gnuradio-core if omnithread skipped
     GRC_CHECK_DEPENDENCY(gnuradio-core, omnithread)
 
+    dnl check for intel threading building blocks
+    PKG_CHECK_MODULES(TBB, tbb_debug >= 2.0,
+       [AC_DEFINE(HAVE_TBB,[1],[Define if you have threading building 
blocks])],
+       [passed=no; AC_MSG_RESULT([gnuradio-core requires threading building 
blocks. See http://www.threadingbuildingblocks.org])])
+
     dnl If execution gets to here, $passed will be:
     dnl   with : if the --with code didn't error out
     dnl   yes  : if the --enable code passed muster and all dependencies are 
met
@@ -51,7 +56,7 @@
 -I\${abs_top_srcdir}/gnuradio-core/src/lib/g72x \
 -I\${abs_top_srcdir}/gnuradio-core/src/lib/swig \
 -I\${abs_top_builddir}/gnuradio-core/src/lib/swig \
-\$(FFTW3F_CFLAGS)"
+\$(FFTW3F_CFLAGS) \$(TBB_CFLAGS)"
         
gnuradio_core_LA="\${abs_top_builddir}/gnuradio-core/src/lib/libgnuradio-core.la"
        
gnuradio_core_I="\${abs_top_srcdir}/gnuradio-core/src/lib/swig/gnuradio.i"
        
gnuradio_core_LIBDIRPATH="\${abs_top_builddir}/gnuradio-core/src/lib:\${abs_top_builddir}/gnuradio-core/src/lib/.libs"

Modified: 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/Makefile.am 
2008-06-23 21:00:49 UTC (rev 8680)
+++ gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/Makefile.am 
2008-06-23 21:20:36 UTC (rev 8681)
@@ -47,7 +47,8 @@
        reed-solomon/librs.la           \
        runtime/libruntime.la           \
        $(OMNITHREAD_LA)                \
-       $(FFTW3F_LIBS)
+       $(FFTW3F_LIBS)                  \
+       $(TBB_LIBS)
 
 libgnuradio_core_qa_la_LIBADD  =       \
        filter/libfilter-qa.la          \

Modified: 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/Makefile.am
 2008-06-23 21:00:49 UTC (rev 8680)
+++ 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/Makefile.am
 2008-06-23 21:20:36 UTC (rev 8681)
@@ -29,6 +29,19 @@
        $(SHM_OPEN_LIBS)
 
 
+# FIXME conditionalize these
+
+tbb_sources = \
+       gr_tbb_top_task.cc \
+       gr_top_block_impl_tbb.cc \
+       gr_tbb_block_task.cc
+
+tbb_headers = \
+       gr_tbb_block_task.h \
+       gr_tbb_top_task.h \
+       gr_top_block_impl_tbb.h
+
+
 libruntime_la_SOURCES =                        \
        gr_basic_block.cc                       \
        gr_flowgraph.cc                         \
@@ -62,7 +75,8 @@
        gr_vmcircbuf_mmap_tmpfile.cc            \
        gr_vmcircbuf_createfilemapping.cc       \
        gr_vmcircbuf_sysv_shm.cc                \
-       gr_select_handler.cc                    
+       gr_select_handler.cc                    \
+       $(tbb_sources)
 
 libruntime_qa_la_SOURCES =                     \
        qa_gr_block.cc                          \
@@ -107,7 +121,8 @@
        gr_timer.h                              \
        gr_tmp_path.h                           \
        gr_types.h                              \
-       gr_vmcircbuf.h                          
+       gr_vmcircbuf.h                          \
+       $(tbb_headers)
 
 noinst_HEADERS =                               \
        gr_vmcircbuf_mmap_shm_open.h            \

Copied: 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_block_task.cc
 (from rev 8660, 
gnuradio/branches/developers/eb/mp-sched/gnuradio-core/src/lib/runtime/gr_tbb_block_task.cc)
===================================================================
--- 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_block_task.cc
                                (rev 0)
+++ 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_block_task.cc
        2008-06-23 21:20:36 UTC (rev 8681)
@@ -0,0 +1,41 @@
+/* -*- 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_tbb_block_task.h>
+#include <gr_top_block_impl_tbb.h>
+
+
+gr_tbb_block_task::~gr_tbb_block_task()
+{
+}
+
+tbb::task *
+gr_tbb_block_task::execute()
+{
+  if (d_tb_impl->d_shutting_down)
+    return NULL;
+
+  return NULL;   // FIXME do some real work
+}

Copied: 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_block_task.h
 (from rev 8660, 
gnuradio/branches/developers/eb/mp-sched/gnuradio-core/src/lib/runtime/gr_tbb_block_task.h)
===================================================================
--- 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_block_task.h
                         (rev 0)
+++ 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_block_task.h
 2008-06-23 21:20:36 UTC (rev 8681)
@@ -0,0 +1,43 @@
+/* -*- 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_TBB_BLOCK_TASK_H
+#define INCLUDED_GR_TBB_BLOCK_TASK_H
+
+#include <tbb/task.h>
+
+class gr_top_block_impl_tbb;
+class gr_block;
+
+class gr_tbb_block_task : public tbb::task
+{
+  gr_top_block_impl_tbb        *d_tb_impl;
+  gr_block             *d_block;
+
+public:
+  gr_tbb_block_task(gr_top_block_impl_tbb *tb_impl, gr_block *block)
+    : d_tb_impl(tb_impl), d_block(block) { }
+  ~gr_tbb_block_task();
+
+  tbb::task *execute();
+};
+
+
+#endif /* INCLUDED_GR_TBB_BLOCK_TASK_H */

Copied: 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_top_task.cc
 (from rev 8660, 
gnuradio/branches/developers/eb/mp-sched/gnuradio-core/src/lib/runtime/gr_tbb_top_task.cc)
===================================================================
--- 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_top_task.cc
                          (rev 0)
+++ 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_top_task.cc
  2008-06-23 21:20:36 UTC (rev 8681)
@@ -0,0 +1,58 @@
+/* -*- 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_tbb_top_task.h>
+#include <gr_tbb_block_task.h>
+#include <gr_top_block_impl_tbb.h>
+
+gr_tbb_top_task::~gr_tbb_top_task()
+{
+}
+
+/*
+ * If we're not done, we recycle ourselves as our continuation and
+ * spawn a gr_tbb_block_task for each source.
+ */
+tbb::task *
+gr_tbb_top_task::execute()
+{
+  if (d_tb_impl->d_shutting_down || d_tb_impl->d_nalive == 0)
+    return NULL;
+
+  recycle_as_safe_continuation();
+
+  // create a child for each source
+  tbb::task_list       tl;
+
+  for (size_t i = 0; i < d_tb_impl->d_source.size(); i++){
+    gr_tbb_block_task &t =
+      *new(allocate_child()) gr_tbb_block_task(d_tb_impl, 
d_tb_impl->d_source[i].get());
+    tl.push_back(t);
+  }
+
+  set_ref_count(d_tb_impl->d_source.size() + 1);       // + 1 for 
"safe_continuation"
+
+  spawn(tl);
+  return NULL;
+}

Copied: 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_top_task.h
 (from rev 8660, 
gnuradio/branches/developers/eb/mp-sched/gnuradio-core/src/lib/runtime/gr_tbb_top_task.h)
===================================================================
--- 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_top_task.h
                           (rev 0)
+++ 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_tbb_top_task.h
   2008-06-23 21:20:36 UTC (rev 8681)
@@ -0,0 +1,41 @@
+/* -*- 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_TBB_TOP_TASK_H
+#define INCLUDED_GR_TBB_TOP_TASK_H
+
+#include <tbb/task.h>
+
+class gr_top_block_impl_tbb;
+
+class gr_tbb_top_task : public tbb::task
+{
+  gr_top_block_impl_tbb        *d_tb_impl;
+
+public:
+  gr_tbb_top_task(gr_top_block_impl_tbb *tb_impl) : d_tb_impl(tb_impl) { }
+  ~gr_tbb_top_task();
+
+  tbb::task *execute();
+};
+
+
+
+#endif /* INCLUDED_GR_TBB_TOP_TASK_H */

Copied: 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_top_block_impl_tbb.cc
 (from rev 8660, 
gnuradio/branches/developers/eb/mp-sched/gnuradio-core/src/lib/runtime/gr_top_block_impl_tbb.cc)
===================================================================
--- 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_top_block_impl_tbb.cc
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_top_block_impl_tbb.cc
    2008-06-23 21:20:36 UTC (rev 8681)
@@ -0,0 +1,115 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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 <gr_top_block.h>
+#include <gr_top_block_impl_tbb.h>
+#include <gr_flat_flowgraph.h>
+#include <gr_scheduler_thread.h>
+#include <gr_local_sighandler.h>
+
+#include <stdexcept>
+#include <iostream>
+#include <string.h>
+#include <unistd.h>
+
+#define GR_TOP_BLOCK_IMPL_TBB_DEBUG 0
+
+
+// ----------------------------------------------------------------
+
+gr_top_block_impl_tbb::gr_top_block_impl_tbb(gr_top_block *owner) 
+  : gr_top_block_impl(owner)
+{
+}
+
+gr_top_block_impl_tbb::~gr_top_block_impl_tbb()
+{
+}
+
+void
+gr_top_block_impl_tbb::start_threads()
+{
+  if (GR_TOP_BLOCK_IMPL_TBB_DEBUG)
+    std::cout << "start_threads: entered" << std::endl;
+
+#if 0
+  d_graphs = d_ffg->partition();
+  for (std::vector<gr_basic_block_vector_t>::iterator p = d_graphs.begin();
+       p != d_graphs.end(); p++) {
+    gr_scheduler_thread *thread = new 
gr_scheduler_thread(make_gr_block_vector(*p));
+    d_threads.push_back(thread);
+    if (GR_TOP_BLOCK_IMPL_TBB_DEBUG)
+      std::cout << "start_threads: starting " << thread << std::endl;
+    thread->start();
+  }
+#endif
+
+  d_running = true;
+}
+
+/*
+ * N.B. as currently implemented, it is possible that this may be
+ * invoked by the SIGINT handler which is fragile as hell...
+ */
+void
+gr_top_block_impl_tbb::stop()
+{
+  if (GR_TOP_BLOCK_IMPL_TBB_DEBUG){
+    char *msg = "stop: entered\n";
+    ::write(1, msg, strlen(msg));
+  }
+
+#if 0
+  for (gr_scheduler_thread_viter_t p = d_threads.begin(); p != 
d_threads.end(); p++) {
+    if (*p)
+      (*p)->stop();
+  }
+#endif
+}
+
+void
+gr_top_block_impl_tbb::wait()
+{
+  if (GR_TOP_BLOCK_IMPL_TBB_DEBUG)
+    std::cout << "wait: entered" << std::endl;
+
+#if 0
+  void *dummy_status; // don't ever dereference this
+  gr_local_sighandler sigint(SIGINT, runtime_sigint_handler);
+
+  for (gr_scheduler_thread_viter_t p = d_threads.begin(); p != 
d_threads.end(); p++) {
+    if (GR_TOP_BLOCK_IMPL_TBB_DEBUG)
+      std::cout << "wait: joining thread " << (*p) << std::endl;
+    (*p)->join(&dummy_status); // omnithreads will self-delete, so pointer is 
now dead
+    (*p) = 0; // FIXME: switch to stl::list and actually remove from container
+    if (GR_TOP_BLOCK_IMPL_TBB_DEBUG)
+      std::cout << "wait: join returned" << std::endl;
+  }
+
+  d_threads.clear();
+#endif
+  d_running = false;
+}

Copied: 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_top_block_impl_tbb.h
 (from rev 8660, 
gnuradio/branches/developers/eb/mp-sched/gnuradio-core/src/lib/runtime/gr_top_block_impl_tbb.h)
===================================================================
--- 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_top_block_impl_tbb.h
                             (rev 0)
+++ 
gnuradio/branches/developers/eb/tbb-sched/gnuradio-core/src/lib/runtime/gr_top_block_impl_tbb.h
     2008-06-23 21:20:36 UTC (rev 8681)
@@ -0,0 +1,57 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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_GR_TOP_BLOCK_IMPL_TBB_H
+#define INCLUDED_GR_TOP_BLOCK_IMPL_TBB_H
+
+#include <gr_top_block_impl.h>
+#include <tbb/atomic.h>
+
+/*!
+ *\brief Implementation details of gr_top_block
+ * \ingroup internal
+ *
+ * Concrete implementation of gr_top_block using threading building blocks.
+ */
+class gr_top_block_impl_tbb : public gr_top_block_impl
+{
+public:
+  gr_top_block_impl_tbb(gr_top_block *owner);
+  ~gr_top_block_impl_tbb();
+
+  // Signal scheduler threads to stop
+  void stop();
+
+  // Wait for scheduler threads to exit
+  void wait();
+
+public:
+    
+  std::vector<gr_block_sptr>   d_source;
+  bool                         d_shutting_down;
+  tbb::atomic<int>             d_nalive;
+
+
+  void start_threads();
+};
+
+#endif /* INCLUDED_GR_TOP_BLOCK_IMPL_TBB_H */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]