commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r5021 - in gnuradio/branches/developers/eb/ibu: mblock


From: eb
Subject: [Commit-gnuradio] r5021 - in gnuradio/branches/developers/eb/ibu: mblock/src/lib pmt/src/lib
Date: Mon, 16 Apr 2007 15:00:44 -0600 (MDT)

Author: eb
Date: 2007-04-16 15:00:44 -0600 (Mon, 16 Apr 2007)
New Revision: 5021

Modified:
   gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_message.cc
   gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_message.h
   gnuradio/branches/developers/eb/ibu/pmt/src/lib/pmt.cc
   gnuradio/branches/developers/eb/ibu/pmt/src/lib/pmt_int.h
Log:
Added code to use class specific new and delete for mb_message and
pmt_base.  The implementation currently uses boost::singleton_pool
which is suboptimal, since we can't get cache line aligned allocations
out of it.


Modified: gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_message.cc
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_message.cc    
2007-04-16 20:51:58 UTC (rev 5020)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_message.cc    
2007-04-16 21:00:44 UTC (rev 5021)
@@ -23,7 +23,20 @@
 #include <config.h>
 #endif
 #include <mb_message.h>
+#include <boost/pool/pool.hpp>
+#include <boost/pool/singleton_pool.hpp>
+#include <stdio.h>
 
+static const int CACHE_LINE_SIZE = 64;         // good guess
+
+#define ROUNDUP(x, stride) ((((x) + (stride) - 1)/(stride)) * (stride))
+
+struct msg_pool_tag {};
+
+typedef boost::singleton_pool<msg_pool_tag,
+                             ROUNDUP(sizeof(mb_message), CACHE_LINE_SIZE)> 
msg_pool;
+
+
 mb_message_sptr
 mb_make_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority)
 {
@@ -53,3 +66,23 @@
   
   return os;
 }
+
+
+#if 1
+void *
+mb_message::operator new(size_t size)
+{
+  void *p = msg_pool::malloc();
+
+  // FIXME fix alignment.
+  // fprintf(stderr, "mb_message::new p = %p\n", p);
+  // assert((reinterpret_cast<intptr_t>(p) & (CACHE_LINE_SIZE - 1)) == 0);
+  return p;
+}
+
+void
+mb_message::operator delete(void *p, size_t size)
+{
+  msg_pool::free(p);
+}
+#endif

Modified: gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_message.h
===================================================================
--- gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_message.h     
2007-04-16 20:51:58 UTC (rev 5020)
+++ gnuradio/branches/developers/eb/ibu/mblock/src/lib/mb_message.h     
2007-04-16 21:00:44 UTC (rev 5021)
@@ -67,6 +67,10 @@
   pmt_t port_id() const { return d_port_id; }
 
   void set_port_id(pmt_t port_id){ d_port_id = port_id; }
+
+  void *operator new(size_t);
+  void operator delete(void *, size_t);
+
 };
 
 std::ostream& operator<<(std::ostream& os, const mb_message &msg);

Modified: gnuradio/branches/developers/eb/ibu/pmt/src/lib/pmt.cc
===================================================================
--- gnuradio/branches/developers/eb/ibu/pmt/src/lib/pmt.cc      2007-04-16 
20:51:58 UTC (rev 5020)
+++ gnuradio/branches/developers/eb/ibu/pmt/src/lib/pmt.cc      2007-04-16 
21:00:44 UTC (rev 5021)
@@ -26,7 +26,41 @@
 #include <vector>
 #include <pmt.h>
 #include "pmt_int.h"
+#include <boost/pool/pool.hpp>
+#include <boost/pool/singleton_pool.hpp>
+#include <stdio.h>
 
+
+static const int CACHE_LINE_SIZE = 64;         // good guess
+
+#define ROUNDUP(x, stride) ((((x) + (stride) - 1)/(stride)) * (stride))
+
+struct pmt_pool_tag {};
+
+typedef boost::singleton_pool<pmt_pool_tag,
+                             ROUNDUP(sizeof(pmt_pair), CACHE_LINE_SIZE)> 
msg_pool;
+
+
+#if 1
+void *
+pmt_base::operator new(size_t size)
+{
+  void *p = msg_pool::malloc();
+
+  // FIXME fix alignment.
+  // fprintf(stderr, "pmt_base::new p = %p\n", p);
+  // assert((reinterpret_cast<intptr_t>(p) & (CACHE_LINE_SIZE - 1)) == 0);
+  return p;
+}
+
+void
+pmt_base::operator delete(void *p, size_t size)
+{
+  msg_pool::free(p);
+}
+#endif
+
+
 pmt_base::~pmt_base()
 {
   // nop -- out of line virtual destructor

Modified: gnuradio/branches/developers/eb/ibu/pmt/src/lib/pmt_int.h
===================================================================
--- gnuradio/branches/developers/eb/ibu/pmt/src/lib/pmt_int.h   2007-04-16 
20:51:58 UTC (rev 5020)
+++ gnuradio/branches/developers/eb/ibu/pmt/src/lib/pmt_int.h   2007-04-16 
21:00:44 UTC (rev 5021)
@@ -62,6 +62,8 @@
   virtual bool is_c32vector() const { return false; }
   virtual bool is_c64vector() const { return false; }
 
+  void *operator new(size_t);
+  void operator delete(void *, size_t);
 };
 
 class pmt_bool : public pmt_base





reply via email to

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