[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 14/43: gnuradio-runtime: modified buffer le
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 14/43: gnuradio-runtime: modified buffer length types to size_t, moved buffer length vectors into detail |
Date: |
Thu, 2 Apr 2015 19:15:50 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit f1657258ccaa1b62d9ef8bd4d8e9b3cebf865b9c
Author: Bill Clark <address@hidden>
Date: Wed Apr 1 16:29:52 2015 -0400
gnuradio-runtime: modified buffer length types to size_t, moved buffer
length vectors into detail
---
gnuradio-runtime/include/gnuradio/hier_block2.h | 23 ++++-----
gnuradio-runtime/lib/hier_block2.cc | 66 ++++++++++++-------------
gnuradio-runtime/lib/hier_block2_detail.cc | 58 +++++++++++++++++-----
gnuradio-runtime/lib/hier_block2_detail.h | 5 +-
gnuradio-runtime/swig/hier_block2.i | 12 ++---
5 files changed, 100 insertions(+), 64 deletions(-)
diff --git a/gnuradio-runtime/include/gnuradio/hier_block2.h
b/gnuradio-runtime/include/gnuradio/hier_block2.h
index 9a3f113..18739d3 100644
--- a/gnuradio-runtime/include/gnuradio/hier_block2.h
+++ b/gnuradio-runtime/include/gnuradio/hier_block2.h
@@ -57,9 +57,6 @@ namespace gr {
*/
hier_block2_detail *d_detail;
- // Track output buffer min/max settings
- std::vector<long> d_max_output_buffer;
- std::vector<long> d_min_output_buffer;
protected:
hier_block2(void) {} // allows pure virtual interface sub-classes
@@ -177,32 +174,32 @@ namespace gr {
/*!
* \brief Returns max buffer size on output port \p i.
*/
- long max_output_buffer(size_t i=0);
+ size_t max_output_buffer(size_t i=0);
/*!
* \brief Sets max buffer size on all output ports.
*/
- void set_max_output_buffer(long max_output_buffer);
+ void set_max_output_buffer(size_t max_output_buffer);
/*!
* \brief Sets max buffer size on output port \p port.
*/
- void set_max_output_buffer(int port, long max_output_buffer);
+ void set_max_output_buffer(int port, size_t max_output_buffer);
/*!
* \brief Returns min buffer size on output port \p i.
*/
- long min_output_buffer(size_t i=0);
+ size_t min_output_buffer(size_t i=0);
/*!
* \brief Sets min buffer size on all output ports.
*/
- void set_min_output_buffer(long min_output_buffer);
+ void set_min_output_buffer(size_t min_output_buffer);
/*!
* \brief Sets min buffer size on output port \p port.
*/
- void set_min_output_buffer(int port, long min_output_buffer);
+ void set_min_output_buffer(int port, size_t min_output_buffer);
// This is a public method for ease of code organization, but should be
@@ -270,20 +267,20 @@ namespace gr {
std::vector<int> processor_affinity();
/*!
- * \brief Get if all block buffers should be set.
+ * \brief Get if all block min buffers should be set.
*
* \details this returns whether all the block min output buffers
* should be set or just the block ports connected to the hier ports.
*/
- bool set_all_min_output_buffer(void);
+ bool all_min_output_buffer_p(void);
/*!
- * \brief Get if all block buffers should be set.
+ * \brief Get if all block max buffers should be set.
*
* \details this returns whether all the block max output buffers
* should be set or just the block ports connected to the hier ports.
*/
- bool set_all_max_output_buffer(void);
+ bool all_max_output_buffer_p(void);
};
/*!
diff --git a/gnuradio-runtime/lib/hier_block2.cc
b/gnuradio-runtime/lib/hier_block2.cc
index 809b0d0..81d310a 100644
--- a/gnuradio-runtime/lib/hier_block2.cc
+++ b/gnuradio-runtime/lib/hier_block2.cc
@@ -29,6 +29,7 @@
#include <gnuradio/flowgraph.h>
#include "hier_block2_detail.h"
#include <iostream>
+#include <stdio.h>
namespace gr {
@@ -49,9 +50,7 @@ namespace gr {
: basic_block(name, input_signature, output_signature),
d_detail(new hier_block2_detail(this)),
hier_message_ports_in(pmt::PMT_NIL),
- hier_message_ports_out(pmt::PMT_NIL),
- d_max_output_buffer(std::max(output_signature->max_streams(),1), -1),
- d_min_output_buffer(std::max(output_signature->max_streams(),1), -1)
+ hier_message_ports_out(pmt::PMT_NIL)
{
// This bit of magic ensures that self() works in the constructors of
derived classes.
gnuradio::detail::sptr_magic::create_and_stash_initial_sptr(this);
@@ -184,75 +183,76 @@ namespace gr {
return dot_graph_fg(hierblock2->flatten());
}
- long
- hier_block2::max_output_buffer(size_t i=0)
+ size_t
+ hier_block2::max_output_buffer(size_t i)
{
- if(d_max_output_buffer.size() <= i)
+ if(i >= d_detail->d_max_output_buffer.size())
throw std::invalid_argument("hier_block2::max_output_buffer: port out of
range.");
- return d_max_output_buffer[i];
+ return d_detail->d_max_output_buffer[i];
}
void
- hier_block2::set_max_output_buffer(long max_output_buffer)
+ hier_block2::set_max_output_buffer(size_t max_output_buffer)
{
+
if(output_signature()->max_streams()>0)
{
- if(d_max_output_buffer.size() == 0)
+ if(d_detail->d_max_output_buffer.size() == 0)
throw std::length_error("hier_block2::max_output_buffer: out_sig
greater than zero, buff_vect isn't");
- for(int idx = 0; idx < output_signature()->max_streams(); idx++){
- d_max_output_buffer[idx] = max_output_buffer;
+ for(size_t idx = 0; idx < output_signature()->max_streams(); idx++){
+ d_detail->d_max_output_buffer[idx] = max_output_buffer;
}
}
}
void
- hier_block2::set_max_output_buffer(int port, long max_output_buffer)
+ hier_block2::set_max_output_buffer(int port, size_t max_output_buffer)
{
- if((size_t)port >= d_max_output_buffer.size())
+ if((size_t)port >= d_detail->d_max_output_buffer.size())
throw std::invalid_argument("hier_block2::max_output_buffer: port out of
range.");
else{
- d_max_output_buffer[port] = max_output_buffer;
+ d_detail->d_max_output_buffer[port] = max_output_buffer;
}
}
- long
- hier_block2::min_output_buffer(size_t i=0)
+ size_t
+ hier_block2::min_output_buffer(size_t i)
{
- if(d_min_output_buffer.size() <= i)
+ if(i >= d_detail->d_min_output_buffer.size())
throw std::invalid_argument("hier_block2::min_output_buffer: port out of
range.");
- return d_min_output_buffer[i];
+ return d_detail->d_min_output_buffer[i];
}
void
- hier_block2::set_min_output_buffer(long min_output_buffer)
+ hier_block2::set_min_output_buffer(size_t min_output_buffer)
{
if(output_signature()->max_streams()>0)
{
- if(d_min_output_buffer.size() == 0)
+ if(d_detail->d_min_output_buffer.size() == 0)
throw std::length_error("hier_block2::min_output_buffer: out_sig
greater than zero, buff_vect isn't");
- for(int idx = 0; idx < output_signature()->max_streams(); idx++){
- d_min_output_buffer[idx] = min_output_buffer;
+ for(size_t idx = 0; idx < output_signature()->max_streams(); idx++){
+ d_detail->d_min_output_buffer[idx] = min_output_buffer;
}
}
}
void
- hier_block2::set_min_output_buffer(int port, long min_output_buffer)
+ hier_block2::set_min_output_buffer(int port, size_t min_output_buffer)
{
- if((size_t)port >= d_min_output_buffer.size())
+ if((size_t)port >= d_detail->d_min_output_buffer.size())
throw std::invalid_argument("hier_block2::min_output_buffer: port out of
range.");
else{
- d_min_output_buffer[port] = min_output_buffer;
+ d_detail->d_min_output_buffer[port] = min_output_buffer;
}
}
bool
- hier_block2::set_all_min_output_buffer(void)
+ hier_block2::all_min_output_buffer_p(void)
{
- if(d_min_output_buffer.size() > 0){
+ if(d_detail->d_min_output_buffer.size() > 0){
bool all_equal = true;
- for(int idx = 1; (idx < d_min_output_buffer.size()) && all_equal; idx++){
- if(d_min_output_buffer[0] != d_min_output_buffer[idx])
+ for(int idx = 1; (idx < d_detail->d_min_output_buffer.size()) &&
all_equal; idx++){
+ if(d_detail->d_min_output_buffer[0] !=
d_detail->d_min_output_buffer[idx])
all_equal = false;
}
return all_equal;
@@ -262,12 +262,12 @@ namespace gr {
}
}
bool
- hier_block2::set_all_max_output_buffer(void)
+ hier_block2::all_max_output_buffer_p(void)
{
- if(d_max_output_buffer.size() > 0){
+ if(d_detail->d_max_output_buffer.size() > 0){
bool all_equal = true;
- for(int idx = 1; (idx < d_max_output_buffer.size()) && all_equal; idx++){
- if(d_max_output_buffer[0] != d_max_output_buffer[idx])
+ for(int idx = 1; (idx < d_detail->d_max_output_buffer.size()) &&
all_equal; idx++){
+ if(d_detail->d_max_output_buffer[0] !=
d_detail->d_max_output_buffer[idx])
all_equal = false;
}
return all_equal;
diff --git a/gnuradio-runtime/lib/hier_block2_detail.cc
b/gnuradio-runtime/lib/hier_block2_detail.cc
index bab9240..5b935d1 100644
--- a/gnuradio-runtime/lib/hier_block2_detail.cc
+++ b/gnuradio-runtime/lib/hier_block2_detail.cc
@@ -30,6 +30,8 @@
#include <stdexcept>
#include <sstream>
#include <boost/format.hpp>
+#include <stdio.h>
+#include <typeinfo>
namespace gr {
@@ -56,6 +58,9 @@ namespace gr {
d_inputs = std::vector<endpoint_vector_t>(max_inputs);
d_outputs = endpoint_vector_t(max_outputs);
+
+ d_max_output_buffer = std::vector<size_t>(std::max(max_outputs,1), 0);
+ d_min_output_buffer = std::vector<size_t>(std::max(max_outputs,1), 0);
}
hier_block2_detail::~hier_block2_detail()
@@ -514,14 +519,21 @@ namespace gr {
// Only run setup_rpc if ControlPort config param is enabled.
bool ctrlport_on = prefs::singleton()->get_bool("ControlPort", "on",
false);
+ size_t min_buff(0), max_buff(0);
+ // Determine how the buffers should be set
+ bool set_all_min_buff = d_owner->all_min_output_buffer_p();
+ bool set_all_max_buff = d_owner->all_max_output_buffer_p();
// Get the min and max buffer length
- long min_buff(-1), max_buff(-1);
- bool set_all_min_buff = d_owner->set_all_min_output_buffer();
- bool set_all_max_buff = d_owner->set_all_max_output_buffer();
- if(set_all_min_buff)
+ if(set_all_min_buff){
+ if(HIER_BLOCK2_DETAIL_DEBUG)
+ printf("Getting (%s) min buffer\n",(d_owner->alias()).c_str());
min_buff = d_owner->min_output_buffer();
- if(set_all_max_buff)
+ }
+ if(set_all_max_buff){
+ if(HIER_BLOCK2_DETAIL_DEBUG)
+ printf("Getting (%s) max buffer\n",(d_owner->alias()).c_str());
max_buff = d_owner->max_output_buffer();
+ }
// For every block (gr::block and gr::hier_block2), set up the RPC
// interface.
@@ -537,10 +549,12 @@ namespace gr {
}
if(set_all_min_buff){
//sets the min buff for every block within hier_block2
- if(min_buff != -1){
+ if(min_buff != 0){
block_sptr bb = boost::dynamic_pointer_cast<block>(b);
if(bb != 0){
if(bb->min_output_buffer(0) != min_buff){
+ if(HIER_BLOCK2_DETAIL_DEBUG)
+ printf("Block (%s) min_buff
(%ld)\n",(bb->alias()).c_str(),min_buff);
bb->set_min_output_buffer(min_buff);
}
}
@@ -548,6 +562,8 @@ namespace gr {
hier_block2_sptr hh = boost::dynamic_pointer_cast<hier_block2>(b);
if(hh != 0){
if(hh->min_output_buffer(0) != min_buff){
+ if(HIER_BLOCK2_DETAIL_DEBUG)
+ printf("HBlock (%s) min_buff
(%ld)\n",(hh->alias()).c_str(),min_buff);
hh->set_min_output_buffer(min_buff);
}
}
@@ -556,10 +572,12 @@ namespace gr {
}
if(set_all_max_buff){
//sets the max buff for every block within hier_block2
- if(max_buff != -1){
+ if(max_buff != 0){
block_sptr bb = boost::dynamic_pointer_cast<block>(b);
if(bb != 0){
if(bb->max_output_buffer(0) != max_buff){
+ if(HIER_BLOCK2_DETAIL_DEBUG)
+ printf("Block (%s) max_buff
(%ld)\n",(bb->alias()).c_str(),max_buff);
bb->set_max_output_buffer(max_buff);
}
}
@@ -567,6 +585,8 @@ namespace gr {
hier_block2_sptr hh = boost::dynamic_pointer_cast<hier_block2>(b);
if(hh != 0){
if(hh->max_output_buffer(0) != max_buff){
+ if(HIER_BLOCK2_DETAIL_DEBUG)
+ printf("HBlock (%s) max_buff
(%ld)\n",(hh->alias()).c_str(),max_buff);
hh->set_max_output_buffer(max_buff);
}
}
@@ -583,10 +603,12 @@ namespace gr {
}
if(set_all_min_buff){
//sets the min buff for every block within hier_block2
- if(min_buff != -1){
+ if(min_buff != 0){
block_sptr bb = boost::dynamic_pointer_cast<block>(b);
if(bb != 0){
if(bb->min_output_buffer(0) != min_buff){
+ if(HIER_BLOCK2_DETAIL_DEBUG)
+ printf("Block (%s) min_buff
(%ld)\n",(bb->alias()).c_str(),min_buff);
bb->set_min_output_buffer(min_buff);
}
}
@@ -594,6 +616,8 @@ namespace gr {
hier_block2_sptr hh = boost::dynamic_pointer_cast<hier_block2>(b);
if(hh != 0){
if(hh->min_output_buffer(0) != min_buff){
+ if(HIER_BLOCK2_DETAIL_DEBUG)
+ printf("HBlock (%s) min_buff
(%ld)\n",(hh->alias()).c_str(),min_buff);
hh->set_min_output_buffer(min_buff);
}
}
@@ -602,10 +626,12 @@ namespace gr {
}
if(set_all_max_buff){
//sets the max buff for every block within hier_block2
- if(max_buff != -1){
+ if(max_buff != 0){
block_sptr bb = boost::dynamic_pointer_cast<block>(b);
if(bb != 0){
if(bb->max_output_buffer(0) != max_buff){
+ if(HIER_BLOCK2_DETAIL_DEBUG)
+ printf("Block (%s) max_buff
(%ld)\n",(bb->alias()).c_str(),max_buff);
bb->set_max_output_buffer(max_buff);
}
}
@@ -613,6 +639,8 @@ namespace gr {
hier_block2_sptr hh = boost::dynamic_pointer_cast<hier_block2>(b);
if(hh != 0){
if(hh->max_output_buffer(0) != max_buff){
+ if(HIER_BLOCK2_DETAIL_DEBUG)
+ printf("HBlock (%s) max_buff
(%ld)\n",(hh->alias()).c_str(),max_buff);
hh->set_max_output_buffer(max_buff);
}
}
@@ -729,16 +757,20 @@ namespace gr {
// Set the buffers of only the blocks connected to the hier output
if(!set_all_min_buff){
min_buff = d_owner->min_output_buffer(i);
- if(min_buff != -1){
+ if(min_buff != 0){
block_sptr bb = boost::dynamic_pointer_cast<block>(blk);
if(bb != 0){
int bb_src_port = d_outputs[i].port();
+ if(HIER_BLOCK2_DETAIL_DEBUG)
+ printf("Block (%s) Port (%d) min_buff
(%ld)\n",(bb->alias()).c_str(),bb_src_port,min_buff);
bb->set_min_output_buffer(bb_src_port, min_buff);
}
else{
hier_block2_sptr hh =
boost::dynamic_pointer_cast<hier_block2>(blk);
if(hh != 0){
int hh_src_port = d_outputs[i].port();
+ if(HIER_BLOCK2_DETAIL_DEBUG)
+ printf("HBlock (%s) Port (%d) min_buff
(%ld)\n",(hh->alias()).c_str(),hh_src_port,min_buff);
hh->set_min_output_buffer(hh_src_port, min_buff);
}
}
@@ -746,16 +778,20 @@ namespace gr {
}
if(!set_all_max_buff){
max_buff = d_owner->max_output_buffer(i);
- if(max_buff != -1){
+ if(max_buff != 0){
block_sptr bb = boost::dynamic_pointer_cast<block>(blk);
if(bb != 0){
int bb_src_port = d_outputs[i].port();
+ if(HIER_BLOCK2_DETAIL_DEBUG)
+ printf("Block (%s) Port (%d) max_buff
(%ld)\n",(bb->alias()).c_str(),bb_src_port,max_buff);
bb->set_max_output_buffer(bb_src_port, max_buff);
}
else{
hier_block2_sptr hh =
boost::dynamic_pointer_cast<hier_block2>(blk);
if(hh != 0){
int hh_src_port = d_outputs[i].port();
+ if(HIER_BLOCK2_DETAIL_DEBUG)
+ printf("HBlock (%s) Port (%d) max_buff
(%ld)\n",(hh->alias()).c_str(),hh_src_port,max_buff);
hh->set_max_output_buffer(hh_src_port, max_buff);
}
}
diff --git a/gnuradio-runtime/lib/hier_block2_detail.h
b/gnuradio-runtime/lib/hier_block2_detail.h
index df2d088..8c38c37 100644
--- a/gnuradio-runtime/lib/hier_block2_detail.h
+++ b/gnuradio-runtime/lib/hier_block2_detail.h
@@ -25,7 +25,6 @@
#include <gnuradio/api.h>
#include <gnuradio/hier_block2.h>
-#include <gnuradio/block.h>
#include <flat_flowgraph.h>
#include <boost/utility.hpp>
@@ -58,6 +57,10 @@ namespace gr {
void set_processor_affinity(const std::vector<int> &mask);
void unset_processor_affinity();
std::vector<int> processor_affinity();
+
+ // Track output buffer min/max settings
+ std::vector<size_t> d_max_output_buffer;
+ std::vector<size_t> d_min_output_buffer;
private:
// Private implementation data
diff --git a/gnuradio-runtime/swig/hier_block2.i
b/gnuradio-runtime/swig/hier_block2.i
index d2a33b4..12190d0 100644
--- a/gnuradio-runtime/swig/hier_block2.i
+++ b/gnuradio-runtime/swig/hier_block2.i
@@ -92,12 +92,12 @@ namespace gr {
std::vector<int> processor_affinity();
// Methods to manage block's min/max buffer sizes.
- long max_output_buffer(int i);
- void set_max_output_buffer(long max_output_buffer);
- void set_max_output_buffer(int port, long max_output_buffer);
- long min_output_buffer(int i);
- void set_min_output_buffer(long min_output_buffer);
- void set_min_output_buffer(int port, long min_output_buffer);
+ size_t max_output_buffer(int i);
+ void set_max_output_buffer(size_t max_output_buffer);
+ void set_max_output_buffer(int port, size_t max_output_buffer);
+ size_t min_output_buffer(int i);
+ void set_min_output_buffer(size_t min_output_buffer);
+ void set_min_output_buffer(int port, size_t min_output_buffer);
gr::hier_block2_sptr to_hier_block2(); // Needed for Python type coercion
};
- [Commit-gnuradio] [gnuradio] 03/43: gnuradio-runtime:: removed the individual port setting on hier_block2, current operation assuming the buffers are being set for latency and therefore all blocks are being set to a small amount, (continued)
- [Commit-gnuradio] [gnuradio] 03/43: gnuradio-runtime:: removed the individual port setting on hier_block2, current operation assuming the buffers are being set for latency and therefore all blocks are being set to a small amount, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 11/43: fec: LDPC cleaning up comments, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 30/43: grc: clean-up 'gnuradio-companion', add mode 'run from source', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 12/43: fec: re-shuffling LDPC make helper, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 31/43: grc: PropsDialog: apply button and hotkey (Ctrl+Enter), git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 40/43: fec: Move the definition of yp_kernel from the class into a temp variable in the main code. This variable is used just to find the actual Volk kernel, and its current use is not c++11 complaint. Moving it makes the code c++11 complaint on both GCC / libstdc++ and Clang / libc++., git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 35/43: Merge remote-tracking branch 'osh/ldpc_add', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 20/43: grc: Reworked save confirmation dialog to allow cancel option, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 42/43: Merge remote-tracking branch 'michaelld/misc_fixes', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 29/43: grc: move context def into Bars.py and add submenu, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 14/43: gnuradio-runtime: modified buffer length types to size_t, moved buffer length vectors into detail,
git <=
- [Commit-gnuradio] [gnuradio] 22/43: grc: close unsaved pages first (for cancel save option), git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 13/43: fec: ldpc GRC compat cleanup, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 36/43: Merge remote-tracking branch 'fengzhe/chunks_to_symbols_update', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 25/43: grc: set permissions for generated files, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 08/43: fec: adding ldpc encoder and decoder, initial compile working, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 23/43: grc: make use of GRC_HIER_PATH at runtime, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 33/43: Merge remote-tracking branch 'saikwolf/hier_buff_tweak', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 24/43: grc: use 'import' for grc-generated hier_blocks (#763), git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 02/43: gnuradio-runtime: updated hier_block2 and hier_block_detail to allow for propagation of min/max output buffer to all blocks within the hier, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 21/43: grc: Default button in save dialog is now 'save' instead of 'close without saving', git, 2015/04/02