commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 19/28: core: make in-place buffering enable


From: git
Subject: [Commit-gnuradio] [gnuradio] 19/28: core: make in-place buffering enabled per port
Date: Mon, 15 Aug 2016 00:47:07 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

nwest pushed a commit to annotated tag gr_basic_work
in repository gnuradio.

commit 2969f4cad63a0239e4253d90072b2bbe05af1d25
Author: Josh Blum <address@hidden>
Date:   Sun Nov 13 16:41:02 2011 -0800

    core: make in-place buffering enabled per port
---
 gnuradio-core/src/lib/runtime/gr_block.cc          | 11 ++++++++++-
 gnuradio-core/src/lib/runtime/gr_block.h           | 21 +++++++++++++++------
 gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc |  8 ++------
 3 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/gnuradio-core/src/lib/runtime/gr_block.cc 
b/gnuradio-core/src/lib/runtime/gr_block.cc
index daefb55..498c928 100644
--- a/gnuradio-core/src/lib/runtime/gr_block.cc
+++ b/gnuradio-core/src/lib/runtime/gr_block.cc
@@ -35,7 +35,6 @@ gr_block::gr_block (const std::string &name,
   : gr_basic_block(name, input_signature, output_signature),
     d_output_multiple (1),
     d_relative_rate (1.0),
-    d_inplace(false),
     d_history(1),
     d_fixed_rate(false),
     d_tag_propagation_policy(TPP_ALL_TO_ALL)
@@ -46,6 +45,16 @@ gr_block::~gr_block ()
 {
 }
 
+bool gr_block::can_inplace(const size_t port) const{
+    if (d_inplace.size() <= port) return false;
+    return d_inplace.at(port) && this->fixed_rate();
+}
+
+void gr_block::set_inplace(const bool enb, const size_t port){
+    d_inplace.resize(std::max<size_t>(port+1, d_inplace.size()));
+    d_inplace.at(port) = enb;
+}
+
 // stub implementation:  1:1
 
 void
diff --git a/gnuradio-core/src/lib/runtime/gr_block.h 
b/gnuradio-core/src/lib/runtime/gr_block.h
index 91a0c62..d0b3e8d 100644
--- a/gnuradio-core/src/lib/runtime/gr_block.h
+++ b/gnuradio-core/src/lib/runtime/gr_block.h
@@ -73,13 +73,22 @@ class GR_CORE_API gr_block : public gr_basic_block {
 
   virtual ~gr_block ();
 
+  //! Can this input port have in-place buffering?
+  bool can_inplace(const size_t port) const;
+
   /*!
-   * Enable/disable inplace processing on this block.
-   * This does not guarantee that input memory is output memory.
-   * That is an important decision for the scheduler to make.
+   * Enable/disable in-place buffering on this input port.
+   * When enabled, this port's input buffer can be shared
+   * with an output buffer when certain conditions are met:
+   *
+   * - The upstream buffer only writes to this port
+   * - This block is a fixed, 1:1 rate sync block
+   * - An output port exists that matches in IO size
+   *
+   * \param enb true to enable in-place buffering
+   * \param port the index of an input port
    */
-  bool inplace () const { return d_inplace; }
-  void  set_inplace (bool inplace) { d_inplace = inplace; }
+  void set_inplace(const bool enb, const size_t port = 0);
 
   /*!
    * Assume block computes y_i = f(x_i, x_i-1, x_i-2, x_i-3...)
@@ -241,7 +250,7 @@ class GR_CORE_API gr_block : public gr_basic_block {
   int                   d_output_multiple;
   double                d_relative_rate;       // approx output_rate / 
input_rate
   gr_block_detail_sptr d_detail;               // implementation details
-  bool                  d_inplace;
+  std::vector<bool>     d_inplace;
   unsigned              d_history;
   bool                  d_fixed_rate;
   tag_propagation_policy_t d_tag_propagation_policy; // policy for moving tags 
downstream
diff --git a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc 
b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
index 377b3b1..1c9df4c 100644
--- a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
+++ b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
@@ -157,18 +157,14 @@ 
gr_flat_flowgraph::connect_block_inputs(gr_basic_block_sptr block)
   }
 }
 
-static bool is_inplace(gr_basic_block_sptr block){
-    return cast_to_block_sptr(block)->inplace() and 
cast_to_block_sptr(block)->fixed_rate();
-}
-
 void gr_flat_flowgraph::simplify_inplace(gr_basic_block_sptr block){
 
-    if (not is_inplace(block)) return;
     typedef std::multimap<int, gr_endpoint> mastermap_type;
     mastermap_type upstream_masters;
 
     //get a map of io sizes to upstream masters
     for (size_t i = 0; i < calc_used_ports(block, true).size(); i++){
+        if (!cast_to_block_sptr(block)->can_inplace(i)) continue;
         const int in_size = block->input_signature()->sizeof_stream_item(i);
         const gr_endpoint master_ep = 
get_inplace_master(calc_upstream_edge(block, i).src());
         if (master_ep.block().get() != NULL) 
upstream_masters.insert(std::make_pair(in_size, master_ep));
@@ -202,7 +198,7 @@ gr_endpoint 
gr_flat_flowgraph::get_inplace_master(gr_endpoint src){
     if (calc_downstream_blocks(src.block(), src.port()).size() != 1) return 
gr_endpoint();
 
     //if this block is not in-place, end here, otherwise search upstream
-    if (!is_inplace(src.block())) return src;
+    if (!cast_to_block_sptr(src.block())->can_inplace(src.port())) return src;
 
     const size_t out_size = 
src.block()->output_signature()->sizeof_stream_item(src.port());
     for (size_t i = 0; i < calc_used_ports(src.block(), true).size(); i++){



reply via email to

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