Convert gcell to use boost::threads instead of omnithread.
authorJohnathan Corgan <jcorgan@corganenterprises.com>
Mon, 19 Apr 2010 03:13:47 +0000 (20:13 -0700)
committerEric Blossom <eb@comsec.com>
Fri, 23 Apr 2010 05:04:21 +0000 (22:04 -0700)
Passes make check.

config/grc_gcell.m4
gcell/apps/benchmark_dma.cc
gcell/apps/benchmark_nop.cc
gcell/apps/benchmark_roundtrip.cc
gcell/lib/Makefile.am
gcell/lib/runtime/Makefile.am
gcell/lib/runtime/gc_client_thread_info.h
gcell/lib/runtime/gc_job_manager_impl.cc
gcell/lib/runtime/gc_job_manager_impl.h

index ff289d1aeccfc14b400cd2527824053e58846ae5..b94deb4db465ea1a10cf6388d5ae813360ea9b45 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright 2001,2002,2003,2004,2005,2006,2008 Free Software Foundation, Inc.
+dnl Copyright 2001,2002,2003,2004,2005,2006,2008,2010 Free Software Foundation, Inc.
 dnl 
 dnl This file is part of GNU Radio
 dnl 
@@ -21,9 +21,6 @@ AC_DEFUN([GRC_GCELL],[
     GRC_ENABLE(gcell)
     dnl GRC_WITH(gcell)
 
-    dnl Don't do gcell if omnithread skipped
-    GRC_CHECK_DEPENDENCY(gcell, omnithread)
-
     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
index a84defe3709c305f9dff93d4a785dc80f18750aa..bc3b3f3289f4914e9f8f2966e2033e99cbb5c505 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2010 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -23,7 +23,7 @@
 #include <config.h>
 #endif
 #include <gcell/gc_job_manager.h>
-#include <gnuradio/omni_time.h>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
 #include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -95,6 +95,8 @@ init_jd(gc_job_desc *jd, unsigned int usecs,
 static void
 run_test(unsigned int nspes, unsigned int usecs, unsigned int dma_size, int getput_mask)
 {
+  using namespace boost::posix_time;
+
   static const int64_t TOTAL_SIZE_DMA = 5LL << 30;
   static const int NJDS = 64;
   unsigned int njobs = (unsigned int)(TOTAL_SIZE_DMA / dma_size);
@@ -148,7 +150,7 @@ run_test(unsigned int nspes, unsigned int usecs, unsigned int dma_size, int getp
 
   for (int iter = 0; iter < 1; iter++){
 
-    omni_time t_start = omni_time::time();
+    ptime t_start(microsec_clock::universal_time());
 
     nsubmitted = 0;
     ncompleted = 0;
@@ -203,9 +205,9 @@ run_test(unsigned int nspes, unsigned int usecs, unsigned int dma_size, int getp
     }
 
     // stop timing
-    omni_time t_stop = omni_time::time();
+    ptime t_stop(microsec_clock::universal_time());
 
-    double delta = (t_stop - t_start).double_time();
+    double delta = (t_stop - t_start).total_microseconds() * 1e-6;
     printf("nspes: %2d  udelay: %4d  elapsed_time: %7.3f  dma_size: %5d  dma_throughput: %7.3e\n",
           mgr->nspes(), usecs, delta, dma_size,
           (double) njobs * dma_size / delta * (getput_mask == BENCHMARK_GET_PUT ? 2.0 : 1.0));
index dee46c84208e708e41b1aa4acdcd75871e2cedf7..a27373db406a4effd9f46dce0cdbdeacb38055b5 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2010 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -23,7 +23,7 @@
 #include <config.h>
 #endif
 #include <gcell/gc_job_manager.h>
-#include <gnuradio/omni_time.h>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
 #include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -47,6 +47,8 @@ init_jd(gc_job_desc *jd, unsigned int usecs)
 static void
 run_test(unsigned int nspes, unsigned int usecs, int njobs)
 {
+  using namespace boost::posix_time;
+
   static const int NJDS = 64;
   int nsubmitted = 0;
   int ncompleted = 0;
@@ -73,7 +75,7 @@ run_test(unsigned int nspes, unsigned int usecs, int njobs)
     init_jd(all_jds[i], usecs);
   }
 
-  omni_time t_start = omni_time::time();
+  ptime t_start(microsec_clock::universal_time());
 
   ci = 0;
   njds[0] = 0;
@@ -122,8 +124,8 @@ run_test(unsigned int nspes, unsigned int usecs, int njobs)
   }
 
   // stop timing
-  omni_time t_stop = omni_time::time();
-  double delta = (t_stop - t_start).double_time();
+  ptime t_stop(microsec_clock::universal_time());
+  double delta = (t_stop - t_start).total_microseconds() * 1e-6;
   printf("nspes: %2d  udelay: %4d  elapsed_time: %7.3f  njobs: %g  speedup: %6.3f\n",
         mgr->nspes(), usecs, delta, (double) njobs,
         njobs * usecs * 1e-6 / delta);
index 8ba37c968e168a8ea6014e94bc3a30593561658f..b994182a88ae086b8ffbf7f57d96b7de66ed5cb4 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008,2009 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -23,7 +23,7 @@
 #include <config.h>
 #endif
 #include <gcell/gc_job_manager.h>
-#include <gnuradio/omni_time.h>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
 #include <getopt.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -96,6 +96,8 @@ static void
 run_test(unsigned int nspes, unsigned int usecs, unsigned int dma_size,
         int getput_mask, int njobs_at_once)
 {
+  using namespace boost::posix_time;
+
   int NJDS = njobs_at_once;
   gc_job_desc *all_jds[NJDS];
   bool done[NJDS];
@@ -140,7 +142,7 @@ run_test(unsigned int nspes, unsigned int usecs, unsigned int dma_size,
   }
 
   int niter = 100000;
-  omni_time t_start = omni_time::time();
+  ptime t_start(microsec_clock::universal_time());
 
   for (int iter = 0; iter < niter; iter++){
 
@@ -164,8 +166,8 @@ run_test(unsigned int nspes, unsigned int usecs, unsigned int dma_size,
   }
 
   // stop timing
-  omni_time t_stop = omni_time::time();
-  double delta = (t_stop - t_start).double_time();
+  ptime t_stop(microsec_clock::universal_time());
+  double delta = (t_stop - t_start).total_microseconds() * 1e-6;
   printf("nspes: %2d  udelay: %4d  elapsed_time: %7.3f  dma_size: %5d  dma_throughput: %7.3e  round_trip: %gus\n",
         mgr->nspes(), usecs, delta, dma_size,
         (double) NJDS * niter * dma_size / delta * (getput_mask == BENCHMARK_GET_PUT ? 2.0 : 1.0),
index e7b349331d52b25864ff48576b04363ef273874d..fa9c4a0031de656aaffee1b049d10a7644f1946b 100644 (file)
@@ -36,7 +36,7 @@ libgcell_la_LIBADD = \
        runtime/libruntime.la \
        wrapper/libwrapper.la \
        -lspe2 \
-       $(OMNITHREAD_LA)
+       $(BOOST_LDFLAGS) $(BOOST_THREAD_LIB)
 
 libgcell_qa_la_LIBADD = \
        runtime/libruntime-qa.la \
index 2c653918e69cf24a0003f3ee5fa1d200ef9048ca..4d13790cd2df64b82df82ba709ec269cafbbf273 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright 2007,2008 Free Software Foundation, Inc.
+# Copyright 2007,2008,2010 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -23,7 +23,7 @@ include $(top_srcdir)/Makefile.common
 IBM_PPU_SYNC_INCLUDES = -I$(top_srcdir)/gcell/ibm/sync/ppu_source
 
 
-AM_CPPFLAGS = $(DEFINES) $(OMNITHREAD_INCLUDES) $(MBLOCK_INCLUDES) $(CPPUNIT_INCLUDES) \
+AM_CPPFLAGS = $(DEFINES) $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) \
        $(GCELL_INCLUDES) $(IBM_PPU_SYNC_INCLUDES) $(WITH_INCLUDES)
 
 
index 9f46ecca77f15a3adcf6948257f3ee42b40110fb..e49c070975ef64bb7f297a43a34ce15841ff85f3 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2010 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -21,7 +21,7 @@
 #ifndef INCLUDED_GC_CLIENT_THREAD_INFO_H
 #define INCLUDED_GC_CLIENT_THREAD_INFO_H
 
-#include <gnuradio/omnithread.h>
+#include <boost/thread.hpp>
 #include <boost/utility.hpp>
 
 enum gc_ct_state {
@@ -40,7 +40,7 @@ enum gc_ct_state {
 class gc_client_thread_info : boost::noncopyable {
 public:
   gc_client_thread_info() :
-    d_free(1), d_cond(&d_mutex), d_state(CT_NOT_WAITING),
+    d_free(1), d_cond(), d_state(CT_NOT_WAITING),
     d_jobs_done(0), d_njobs_waiting_for(0),
     d_jobs_waiting_for(0){ }
 
@@ -59,10 +59,10 @@ public:
   uint16_t       d_client_id;
 
   //! hold this mutex to manipulate anything below here
-  omni_mutex     d_mutex;
+  boost::mutex   d_mutex;
 
   //! signaled by event handler to wake client thread up
-  omni_condition  d_cond;
+  boost::condition_variable d_cond;
 
   //! Is this client waiting?
   gc_ct_state    d_state;
index cc49fd1f3a4bce97e921fef5f1bf11d075674454..58597cf2766c173506dd75e1b4572678889bf671 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008,2009 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -39,6 +39,7 @@
 #include <string.h>
 #include <sched.h>
 
+typedef boost::unique_lock<boost::mutex> scoped_lock;
 
 #define __nop() __asm__ volatile ("ori 0,0,0" : : : "memory")
 #define __cctpl() __asm__ volatile ("or 1,1,1" : : : "memory")
@@ -116,9 +117,9 @@ is_power_of_2(uint32_t x)
 
 gc_job_manager_impl::gc_job_manager_impl(const gc_jm_options *options)
   : d_debug(0), d_spu_args(0),
-    d_eh_cond(&d_eh_mutex), d_eh_thread(0), d_eh_state(EHS_INIT),
+    d_eh_cond(), d_eh_thread(0), d_eh_state(EHS_INIT),
     d_shutdown_requested(false),
-    d_jc_cond(&d_jc_mutex), d_jc_thread(0), d_jc_state(JCS_INIT), d_jc_njobs_active(0),
+    d_jc_cond(), d_jc_thread(0), d_jc_state(JCS_INIT), d_jc_njobs_active(0),
     d_ntell(0), d_tell_start(0),
     d_client_thread(0), d_ea_args_maxsize(0),
     d_proc_def(0), d_proc_def_ls_addr(0), d_nproc_defs(0)
@@ -368,12 +369,12 @@ gc_job_manager_impl::~gc_job_manager_impl()
 bool
 gc_job_manager_impl::shutdown()
 {
-  omni_mutex_lock      l(d_eh_mutex);
+  scoped_lock  l(d_eh_mutex);
 
   {
-    omni_mutex_lock    l2(d_jc_mutex);
+    scoped_lock        l2(d_jc_mutex);
     d_shutdown_requested = true;       // set flag for event handler thread
-    d_jc_cond.signal();                        // wake up job completer
+    d_jc_cond.notify_one();                    // wake up job completer
   }
 
   // should only happens during early QA code
@@ -381,7 +382,7 @@ gc_job_manager_impl::shutdown()
     return false;
 
   while (d_eh_state != EHS_DEAD)       // wait for it to finish
-    d_eh_cond.wait();
+    d_eh_cond.wait(l);
 
   return true;
 }
@@ -459,13 +460,13 @@ gc_job_manager_impl::free_job_desc(gc_job_desc *jd)
 inline bool
 gc_job_manager_impl::incr_njobs_active()
 {
-  omni_mutex_lock      l(d_jc_mutex);
+  scoped_lock  l(d_jc_mutex);
 
   if (d_shutdown_requested)
     return false;
 
   if (d_jc_njobs_active++ == 0)        // signal on 0 to 1 transition
-    d_jc_cond.signal();
+    d_jc_cond.notify_one();
 
   return true;
 }
@@ -473,7 +474,7 @@ gc_job_manager_impl::incr_njobs_active()
 inline void
 gc_job_manager_impl::decr_njobs_active(int n)
 {
-  omni_mutex_lock      l(d_jc_mutex);
+  scoped_lock  l(d_jc_mutex);
   d_jc_njobs_active -= n;
 }
 
@@ -614,7 +615,7 @@ gc_job_manager_impl::wait_jobs(unsigned int njobs,
   }
 
   {
-    omni_mutex_lock    l(cti->d_mutex);
+    scoped_lock        l(cti->d_mutex);
 
     // setup info for event handler
     cti->d_state = (mode == GC_WAIT_ANY) ? CT_WAIT_ANY : CT_WAIT_ALL;
@@ -646,7 +647,7 @@ gc_job_manager_impl::wait_jobs(unsigned int njobs,
 
       // FIXME what happens when somebody calls shutdown?
 
-      cti->d_cond.wait();      // wait for event handler to wake us up
+      cti->d_cond.wait(l);     // wait for event handler to wake us up
     }
 
     cti->d_state = CT_NOT_WAITING;  
@@ -835,17 +836,17 @@ gc_job_manager_impl::create_event_handler()
 void
 gc_job_manager_impl::set_eh_state(evt_handler_state s)
 {
-  omni_mutex_lock      l(d_eh_mutex);
+  scoped_lock  l(d_eh_mutex);
   d_eh_state = s;
-  d_eh_cond.broadcast();
+  d_eh_cond.notify_all();
 }
 
 void
 gc_job_manager_impl::set_ea_args_maxsize(int maxsize)
 {
-  omni_mutex_lock      l(d_eh_mutex);
+  scoped_lock  l(d_eh_mutex);
   d_ea_args_maxsize = maxsize;
-  d_eh_cond.broadcast();
+  d_eh_cond.notify_all();
 }
 
 void
@@ -956,7 +957,7 @@ gc_job_manager_impl::notify_clients_jobs_are_done(unsigned int spe_num,
       // FIXME we could distinguish between CT_WAIT_ALL & CT_WAIT_ANY
 
       if (last_cti->d_state == CT_WAIT_ANY || last_cti->d_state == CT_WAIT_ALL)
-       last_cti->d_cond.signal();      // wake client thread up
+       last_cti->d_cond.notify_one();  // wake client thread up
 
       last_cti->d_mutex.unlock();
       cti->d_mutex.lock();
@@ -970,7 +971,7 @@ gc_job_manager_impl::notify_clients_jobs_are_done(unsigned int spe_num,
   // "wind-out"
 
   if (last_cti->d_state == CT_WAIT_ANY || last_cti->d_state == CT_WAIT_ALL)
-    last_cti->d_cond.signal(); // wake client thread up
+    last_cti->d_cond.notify_one();     // wake client thread up
   last_cti->d_mutex.unlock();
 
   ci->in_use = 0;              // clear flag so SPE knows we're done with it
@@ -1189,13 +1190,13 @@ gc_job_manager_impl::job_completer_loop()
 
   while (1){
     {
-      omni_mutex_lock  l(d_jc_mutex);
+      scoped_lock l(d_jc_mutex);
       if (d_jc_njobs_active == 0){
        if (d_shutdown_requested){
          d_jc_state = JCS_DEAD;
          return;
        }
-       d_jc_cond.wait();
+       d_jc_cond.wait(l);
       }
     }
 
@@ -1280,10 +1281,10 @@ gc_job_manager_impl::free_cti(gc_client_thread_info *cti)
 int
 gc_job_manager_impl::ea_args_maxsize()
 {
-  omni_mutex_lock      l(d_eh_mutex);
+  scoped_lock  l(d_eh_mutex);
 
   while (d_ea_args_maxsize == 0)       // wait for it to be initialized
-    d_eh_cond.wait();
+    d_eh_cond.wait(l);
 
   return d_ea_args_maxsize;
 }
index a56117870b6df2f644bd30d67348ce9d77d71cdb..640fdfe793a5d585b1e9a9ecc4eb440d73ee3a1c 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007,2008,2009 Free Software Foundation, Inc.
+ * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -107,16 +107,16 @@ class gc_job_manager_impl : public gc_job_manager
   boost::shared_ptr<void> _d_comp_info_boost;  // hack for automatic storage mgmt
 
   // used to coordinate communication w/ the event handling thread
-  omni_mutex            d_eh_mutex;
-  omni_condition        d_eh_cond;
+  boost::mutex          d_eh_mutex;
+  boost::condition_variable d_eh_cond;
   pthread_t             d_eh_thread;           // the event handler thread
   volatile evt_handler_state   d_eh_state;
   volatile bool                        d_shutdown_requested;
   spe_event_handler     d_spe_event_handler;
   
   // used to coordinate communication w/ the job completer thread
-  omni_mutex            d_jc_mutex;
-  omni_condition        d_jc_cond;
+  boost::mutex          d_jc_mutex;
+  boost::condition_variable d_jc_cond;
   pthread_t             d_jc_thread;           // the job completion thread
   volatile job_completer_state d_jc_state;
   int                   d_jc_njobs_active;     // # of jobs submitted but not yet reaped