diff options
50 files changed, 383 insertions, 243 deletions
diff --git a/Apology b/Apology -Subproject 39f22a50578e321e7fd9c5face7a375da243c24 +Subproject 132718e729bbb6e9d18a6f776eca4a3187978f0 diff --git a/Theron b/Theron -Subproject 87cbb28824ea255e3dedc93ababe5f7639de504 +Subproject 1d3b0b2dce36ae38981303b13aff705e20f0f07 diff --git a/gnuradio b/gnuradio -Subproject bb3e2754a0e28396fa722725978986c2cc0e57c +Subproject 517b057e732eee9504510f1171d44c98f1ceec9 diff --git a/include/gnuradio/block.hpp b/include/gnuradio/block.hpp index 25cf77c..81984f0 100644 --- a/include/gnuradio/block.hpp +++ b/include/gnuradio/block.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_BLOCK_HPP #define INCLUDED_GNURADIO_BLOCK_HPP @@ -27,6 +27,65 @@ namespace gnuradio { +//! Configuration parameters for an input port +struct GRAS_API InputPortConfig +{ + InputPortConfig(void); + + /*! + * Set buffer inlining for this port config. + * Inlining means that the input buffer can be used as an output buffer. + * The goal is to make better use of cache and memory bandwidth. + * + * By default, inlining is disabled on all input ports. + * The user should enable inlining on an input port + * when it is understood that the work function will read + * before writting to a particular section of the buffer. + * + * The scheduler will inline a buffer when + * * inlining is enabled on the particular input port + * * block holds the only buffer reference aka unique + * * the input buffer has the same affinity as the block + * * the input port has a buffer look-ahead of 0 + * + * Default = false. + */ + bool inline_buffer; + + /*! + * Set the number of input buffer look-ahead items. + * When num look-ahead items are not consumed, + * they will be available for the next work call. + * This is used to implement sample memory for + * things like sliding dot products/FIR filters. + * + * Default = 0. + */ + size_t lookahead_items; +}; + +//! Configuration parameters for an output port +struct GRAS_API OutputPortConfig +{ + OutputPortConfig(void); + + /*! + * Set an output reserve requirement such that work is called + * with an output buffer at least reserve items in size. + * + * Default = 1. + */ + size_t reserve_items; + + /*! + * Constrain the maximum number of items that + * work can be called with for this port. + * + * Default = 0 aka disabled. + */ + size_t maximum_items; +}; + template <typename PtrType> struct WorkBuffer { //! get a native pointer type to this buffer @@ -65,68 +124,28 @@ template <typename PtrType> struct WorkBuffer struct GRAS_API Block : Element { - enum - { - WORK_CALLED_PRODUCE = -2, - WORK_DONE = -1 - }; - - enum tag_propagation_policy_t - { - TPP_DONT = 0, - TPP_ALL_TO_ALL = 1, - TPP_ONE_TO_ONE = 2 - }; + //! Contruct an empty/null block Block(void); + //! Create a new block given the name Block(const std::string &name); /******************************************************************* - * Basic routines from basic block + * Deal with input and output port configuration ******************************************************************/ - //! Get the number of history items (default 0) - size_t input_history(const size_t which_input = 0) const; + //! Get the configuration rules of an input port + InputPortConfig input_config(const size_t which_input = 0) const; - /*! - * Set the number of items that will be saved from the previous run. - * Input buffers will begin with an overlap of the previous's buffer's - * num history items. This is used to implement sample memory for - * things like sliding dot products/FIR filters. - */ - void set_input_history(const size_t history, const size_t which_input = 0); - - void set_output_multiple(const size_t multiple, const size_t which_output = 0); - - size_t output_multiple(const size_t which_output = 0) const; - - void consume(const size_t which_input, const size_t how_many_items); - - void consume_each(const size_t how_many_items); - - void produce(const size_t which_output, const size_t how_many_items); + //! Set the configuration rules for an input port + void set_input_config(const InputPortConfig &config, const size_t which_input = 0); - /*! - * Set buffer inlining for this input. - * Inlining means that the input buffer can be used as an output buffer. - * The goal is to make better use of cache and memory bandwidth. - * - * By default, inlining is disabled on all input ports. - * The user should enable inlining on an input port - * when it is understood that the work function will read - * before writting to a particular section of the buffer. - * - * The scheduler will inline a buffer when - * * inlining is enabled on the particular input port - * * block holds the only buffer reference aka unique - * * the input buffer has the same affinity as the block - * * the input port has a buffer history of 0 items - */ - void set_input_inline(const size_t which_input, const bool enb); + //! Get the configuration rules of an output port + OutputPortConfig output_config(const size_t which_output = 0) const; - //! Get the buffer inlining state - bool input_inline(const size_t which_input) const; + //! Set the configuration rules for an output port + void set_output_config(const OutputPortConfig &config, const size_t which_output = 0); /*! * Enable fixed rate logic. @@ -145,9 +164,36 @@ struct GRAS_API Block : Element double relative_rate(void) const; /******************************************************************* - * Tag related routines from basic block + * Deal with data production and consumption + ******************************************************************/ + + //! Return options for the work call + enum + { + WORK_CALLED_PRODUCE = -2, + WORK_DONE = -1 + }; + + //! Call during work to consume items + void consume(const size_t which_input, const size_t how_many_items); + + //! Call during work to consume items + void consume_each(const size_t how_many_items); + + //! Call during work to produce items, must return WORK_CALLED_PRODUCE + void produce(const size_t which_output, const size_t how_many_items); + + /******************************************************************* + * Deal with tag handling and tag configuration ******************************************************************/ + enum tag_propagation_policy_t + { + TPP_DONT = 0, + TPP_ALL_TO_ALL = 1, + TPP_ONE_TO_ONE = 2 + }; + uint64_t nitems_read(const size_t which_input); uint64_t nitems_written(const size_t which_output); @@ -197,7 +243,7 @@ struct GRAS_API Block : Element typedef std::vector<WorkBuffer<void *> > OutputItems; //! The official call into the work routine (overload please) - virtual int Work( + virtual int work( const InputItems &input_items, const OutputItems &output_items ) = 0; @@ -211,6 +257,15 @@ struct GRAS_API Block : Element //! scheduler calls when the topology is updated, can be overloaded virtual bool check_topology(int ninputs, int noutputs); + /*! + * Set if the work call should be interruptible by stop(). + * Some work implementations block with the expectation of + * getting a boost thread interrupt in a blocking call. + * Set set_interruptible_work(true) if this is the case. + * By default, work implementations are not interruptible. + */ + void set_interruptible_work(const bool enb); + /******************************************************************* * routines related to affinity and allocation ******************************************************************/ diff --git a/include/gnuradio/element.hpp b/include/gnuradio/element.hpp index 6c2790d..f009862 100644 --- a/include/gnuradio/element.hpp +++ b/include/gnuradio/element.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_ELEMENT_HPP #define INCLUDED_GNURADIO_ELEMENT_HPP diff --git a/include/gnuradio/gr_block.h b/include/gnuradio/gr_block.h index 4d35aa0..038c0dc 100644 --- a/include/gnuradio/gr_block.h +++ b/include/gnuradio/gr_block.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GR_BLOCK_H #define INCLUDED_GNURADIO_GR_BLOCK_H @@ -51,7 +51,7 @@ struct GRAS_API gr_block : gnuradio::Block template <typename T> void set_msg_handler(T msg_handler){/*LOL*/} //! implements work -> calls general work - int Work( + int work( const InputItems &input_items, const OutputItems &output_items ); @@ -77,18 +77,13 @@ struct GRAS_API gr_block : gnuradio::Block gr_vector_void_star &output_items ); - unsigned history(void) const - { - //implement off-by-one history compat - return this->input_history()+1; - } + unsigned history(void) const; - void set_history(unsigned history) - { - //implement off-by-one history compat - if (history == 0) history++; - this->set_input_history(history-1); - } + void set_history(unsigned history); + + unsigned output_multiple(void) const; + + void set_output_multiple(unsigned multiple); void set_alignment(const size_t alignment); @@ -104,6 +99,22 @@ struct GRAS_API gr_block : gnuradio::Block void set_decimation(const size_t); + int max_noutput_items(void) const; + + void set_max_noutput_items(int); + + void unset_max_noutput_items(void); + + bool is_set_max_noutput_items(void) const; + + ///////////// TODO ////////////////////// + void set_max_output_buffer(long){} + void set_max_output_buffer(int, long){} + long max_output_buffer(size_t){return 0;} + void set_min_output_buffer(long){} + void set_min_output_buffer(int, long){} + long min_output_buffer(size_t){return 0;} + }; typedef boost::shared_ptr<gr_block> gr_block_sptr; diff --git a/include/gnuradio/gr_hier_block2.h b/include/gnuradio/gr_hier_block2.h index 16b3b86..956cb1d 100644 --- a/include/gnuradio/gr_hier_block2.h +++ b/include/gnuradio/gr_hier_block2.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GR_HIER_BLOCK2_H #define INCLUDED_GNURADIO_GR_HIER_BLOCK2_H diff --git a/include/gnuradio/gr_io_signature.h b/include/gnuradio/gr_io_signature.h index aba4ae6..0b32efb 100644 --- a/include/gnuradio/gr_io_signature.h +++ b/include/gnuradio/gr_io_signature.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GR_IO_SIGNATURE_H #define INCLUDED_GNURADIO_GR_IO_SIGNATURE_H diff --git a/include/gnuradio/gr_sync_block.h b/include/gnuradio/gr_sync_block.h index f588505..cb81e67 100644 --- a/include/gnuradio/gr_sync_block.h +++ b/include/gnuradio/gr_sync_block.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GR_SYNC_BLOCK_H #define INCLUDED_GNURADIO_GR_SYNC_BLOCK_H diff --git a/include/gnuradio/gr_sync_decimator.h b/include/gnuradio/gr_sync_decimator.h index c5cec07..43f94be 100644 --- a/include/gnuradio/gr_sync_decimator.h +++ b/include/gnuradio/gr_sync_decimator.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GR_SYNC_DECIMATOR_H #define INCLUDED_GNURADIO_GR_SYNC_DECIMATOR_H diff --git a/include/gnuradio/gr_sync_interpolator.h b/include/gnuradio/gr_sync_interpolator.h index 0545223..b165ce8 100644 --- a/include/gnuradio/gr_sync_interpolator.h +++ b/include/gnuradio/gr_sync_interpolator.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GR_SYNC_INTERPOLATOR_H #define INCLUDED_GNURADIO_GR_SYNC_INTERPOLATOR_H diff --git a/include/gnuradio/gr_tags.h b/include/gnuradio/gr_tags.h index ab4f569..e4c9508 100644 --- a/include/gnuradio/gr_tags.h +++ b/include/gnuradio/gr_tags.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GR_TAGS_H #define INCLUDED_GR_TAGS_H diff --git a/include/gnuradio/gr_top_block.h b/include/gnuradio/gr_top_block.h index 5b4f8d9..3a56bf6 100644 --- a/include/gnuradio/gr_top_block.h +++ b/include/gnuradio/gr_top_block.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GR_TOP_BLOCK_H #define INCLUDED_GNURADIO_GR_TOP_BLOCK_H @@ -37,6 +37,30 @@ struct GRAS_API gr_top_block : gnuradio::TopBlock this->update(); } + void start(const size_t max_items) + { + this->set_max_noutput_items(max_items); + gnuradio::TopBlock::start(); + } + + void run(const size_t max_items) + { + this->set_max_noutput_items(max_items); + gnuradio::TopBlock::run(); + } + + int max_noutput_items(void) const + { + return this->global_config().maximum_output_items; + } + + void set_max_noutput_items(int max_items) + { + gnuradio::GlobalBlockConfig config = this->global_config(); + config.maximum_output_items = max_items; + this->set_global_config(config); + } + }; typedef boost::shared_ptr<gr_top_block> gr_top_block_sptr; diff --git a/include/gnuradio/gr_types.h b/include/gnuradio/gr_types.h index 0da08cc..872cadc 100644 --- a/include/gnuradio/gr_types.h +++ b/include/gnuradio/gr_types.h @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GRNURADIO_TYPES_H #define INCLUDED_GRNURADIO_TYPES_H diff --git a/include/gnuradio/gras.hpp b/include/gnuradio/gras.hpp index 93b2ef1..1759be1 100644 --- a/include/gnuradio/gras.hpp +++ b/include/gnuradio/gras.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_GRAS_HPP #define INCLUDED_GNURADIO_GRAS_HPP diff --git a/include/gnuradio/hier_block.hpp b/include/gnuradio/hier_block.hpp index c22594b..8c337e3 100644 --- a/include/gnuradio/hier_block.hpp +++ b/include/gnuradio/hier_block.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_HIER_BLOCK_HPP #define INCLUDED_GNURADIO_HIER_BLOCK_HPP diff --git a/include/gnuradio/io_signature.hpp b/include/gnuradio/io_signature.hpp index 58398f5..b6b11a5 100644 --- a/include/gnuradio/io_signature.hpp +++ b/include/gnuradio/io_signature.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_IO_SIGNATURE_HPP #define INCLUDED_GNURADIO_IO_SIGNATURE_HPP diff --git a/include/gnuradio/tags.hpp b/include/gnuradio/tags.hpp index e730178..d8414d8 100644 --- a/include/gnuradio/tags.hpp +++ b/include/gnuradio/tags.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_TAGS_HPP #define INCLUDED_GNURADIO_TAGS_HPP diff --git a/include/gnuradio/top_block.hpp b/include/gnuradio/top_block.hpp index a0a057f..bab67ee 100644 --- a/include/gnuradio/top_block.hpp +++ b/include/gnuradio/top_block.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_GNURADIO_TOP_BLOCK_HPP #define INCLUDED_GNURADIO_TOP_BLOCK_HPP @@ -22,38 +22,37 @@ namespace gnuradio { +struct GRAS_API GlobalBlockConfig +{ + GlobalBlockConfig(void); + + /*! + * Constrain the maximum number of items that + * work can be called with for all output ports. + * + * Default = 0 aka disabled. + */ + size_t maximum_output_items; +}; + struct GRAS_API TopBlock : HierBlock { TopBlock(void); TopBlock(const std::string &name); + //! Get the global block config settings + const GlobalBlockConfig &global_config(void) const; + + //! Set the global block config settings + void set_global_config(const GlobalBlockConfig &config); + /*! * Commit changes to the overall flow graph. * Call this after modifying connections. - * Update is called automatically by start/stop/run. - */ - void update(void); - - /*! - * Set the buffer allocation hint. - * This affects the size of buffers. + * Commit is called automatically by start/stop/run. */ - void set_buffer_hint(const size_t hint); - - //! Combined hint + start - void start(const size_t hint) - { - this->set_buffer_hint(hint); - this->start(); - } - - //! Combined hint + run - void run(const size_t hint) - { - this->set_buffer_hint(hint); - this->run(); - } + void commit(void); /*! * Run is for finite flow graph executions. diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 956e5e1..8f90824 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -113,7 +113,7 @@ set(test_headers ${RUNTIME_SOURCE_DIR}/gr_unittests.h ) foreach(header ${test_headers}) - execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${header} ${GRAS_BINARY_DIR}/include) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${header} ${GRAS_BINARY_DIR}/include) endforeach(header) ######################################################################## @@ -129,7 +129,7 @@ set(runtime_copy_headers #copy the headers to a place that is in the include path foreach(runtime_copy_header ${runtime_copy_headers}) - execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${runtime_copy_header} ${GRAS_BINARY_DIR}/include) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${runtime_copy_header} ${GRAS_BINARY_DIR}/include) endforeach(runtime_copy_header) file(GLOB runtime_headers "${GRAS_SOURCE_DIR}/include/gnuradio/*") @@ -153,14 +153,17 @@ set(runtime_copy_swigs #makes swig doc generator happy execute_process( COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/runtime/ - COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/runtime/nop.h + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/nop.h + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/nop.h + ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/runtime/nop.h ) #copy the headers to a place that is in the include path foreach(runtime_copy_header ${runtime_copy_swigs}) execute_process( COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/swig/ - COMMAND ${CMAKE_COMMAND} -E copy ${runtime_copy_header} ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/swig/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${runtime_copy_header} ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/swig/ ) endforeach(runtime_copy_header) diff --git a/lib/block.cpp b/lib/block.cpp index 40b220b..d6f6e2b 100644 --- a/lib/block.cpp +++ b/lib/block.cpp @@ -12,13 +12,25 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include "element_impl.hpp" #include <gnuradio/block.hpp> using namespace gnuradio; +InputPortConfig::InputPortConfig(void) +{ + inline_buffer = false; + lookahead_items = 0; +} + +OutputPortConfig::OutputPortConfig(void) +{ + reserve_items = 1; + maximum_items = 0; +} + Block::Block(void) { //NOP @@ -38,11 +50,12 @@ Block::Block(const std::string &name): (*this)->block->block_state = BlockActor::BLOCK_STATE_INIT; //call block methods to init stuff - this->set_input_history(0); - this->set_output_multiple(1); + this->set_input_config(InputPortConfig()); + this->set_output_config(OutputPortConfig()); this->set_fixed_rate(true); this->set_relative_rate(1.0); this->set_tag_propagation_policy(TPP_ALL_TO_ALL); + this->set_interruptible_work(false); } template <typename V, typename T> @@ -65,26 +78,26 @@ typename V::value_type vector_get(const V &v, const size_t index) return v[index]; } -size_t Block::input_history(const size_t which_input) const +InputPortConfig Block::input_config(const size_t which_input) const { - return vector_get((*this)->block->input_history_items, which_input); + return vector_get((*this)->block->input_configs, which_input); } -void Block::set_input_history(const size_t history, const size_t which_input) +void Block::set_input_config(const InputPortConfig &config, const size_t which_input) { - vector_set((*this)->block->input_history_items, history, which_input); + vector_set((*this)->block->input_configs, config, which_input); if ((*this)->block->topology_init) (*this)->block->Push(UpdateInputsMessage(), Theron::Address()); } -size_t Block::output_multiple(const size_t which_output) const +OutputPortConfig Block::output_config(const size_t which_output) const { - return vector_get((*this)->block->output_multiple_items, which_output); + return vector_get((*this)->block->output_configs, which_output); } -void Block::set_output_multiple(const size_t multiple, const size_t which_output) +void Block::set_output_config(const OutputPortConfig &config, const size_t which_output) { - vector_set((*this)->block->output_multiple_items, multiple, which_output); + vector_set((*this)->block->output_configs, config, which_output); if ((*this)->block->topology_init) (*this)->block->Push(UpdateInputsMessage(), Theron::Address()); } @@ -109,16 +122,6 @@ void Block::produce(const size_t which_output, const size_t how_many_items) (*this)->block->produce_items[which_output] += how_many_items; } -void Block::set_input_inline(const size_t which_input, const bool enb) -{ - vector_set((*this)->block->input_inline_enables, enb, which_input); -} - -bool Block::input_inline(const size_t which_input) const -{ - return vector_get((*this)->block->input_inline_enables, which_input); -} - void Block::set_fixed_rate(const bool fixed_rate) { (*this)->block->enable_fixed_rate = fixed_rate; @@ -238,3 +241,8 @@ void Block::set_buffer_affinity(const Affinity &affinity) { (*this)->block->buffer_affinity = affinity; } + +void Block::set_interruptible_work(const bool enb) +{ + (*this)->block->interruptible_work = enb; +} diff --git a/lib/block_actor.cpp b/lib/block_actor.cpp index 6fc3e25..c0a294a 100644 --- a/lib/block_actor.cpp +++ b/lib/block_actor.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include <gras_impl/block_actor.hpp> #include <boost/thread/thread.hpp> diff --git a/lib/block_allocator.cpp b/lib/block_allocator.cpp index ad39159..2161eb9 100644 --- a/lib/block_allocator.cpp +++ b/lib/block_allocator.cpp @@ -12,13 +12,12 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include "element_impl.hpp" #include <gras_impl/block_actor.hpp> #include <boost/bind.hpp> #include <boost/foreach.hpp> -#include <boost/math/common_factor.hpp> using namespace gnuradio; @@ -43,31 +42,36 @@ void BlockActor::buffer_returner(const size_t index, SBuffer &buffer) static size_t recommend_length( const std::vector<OutputHintMessage> &hints, - const size_t output_multiple_bytes, - const size_t at_least_bytes + const size_t hint_bytes, + const size_t at_least_bytes, + const size_t at_most_bytes ){ - //step 1) find the LCM of all reserves to create a super-reserve - size_t lcm_bytes = output_multiple_bytes; + //step 1) find the min of all reserves to create a super-reserve + size_t min_bytes = at_least_bytes; BOOST_FOREACH(const OutputHintMessage &hint, hints) { - lcm_bytes = boost::math::lcm(lcm_bytes, hint.reserve_bytes); + min_bytes = std::max(min_bytes, hint.reserve_bytes); } //step 2) N x super reserve to minimize history edge case - size_t Nlcm_bytes = lcm_bytes; + size_t Nmin_bytes = min_bytes; BOOST_FOREACH(const OutputHintMessage &hint, hints) { - while (hint.history_bytes*EDGE_CASE_MITIGATION > Nlcm_bytes) + while (hint.history_bytes*EDGE_CASE_MITIGATION > Nmin_bytes) { - Nlcm_bytes += lcm_bytes; + Nmin_bytes += min_bytes; } } - while (at_least_bytes > Nlcm_bytes) + while (hint_bytes > Nmin_bytes) { - Nlcm_bytes += lcm_bytes; + Nmin_bytes += min_bytes; } - return std::min(Nlcm_bytes, AHH_TOO_MANY_BYTES); + //step 3) cap the maximum size by the upper bound (if set) + if (at_most_bytes) Nmin_bytes = std::min(Nmin_bytes, at_most_bytes); + else Nmin_bytes = std::min(Nmin_bytes, AHH_TOO_MANY_BYTES); + + return Nmin_bytes; } void BlockActor::handle_top_alloc(const TopAllocMessage &, const Theron::Address from) @@ -85,13 +89,14 @@ void BlockActor::handle_top_alloc(const TopAllocMessage &, const Theron::Address this->output_buffer_tokens.resize(num_outputs); for (size_t i = 0; i < num_outputs; i++) { - size_t at_least_items = this->hint; - if (at_least_items == 0) at_least_items = AT_LEAST_DEFAULT_ITEMS; + size_t hint_items = this->hint; + if (hint_items == 0) hint_items = AT_LEAST_DEFAULT_ITEMS; const size_t bytes = recommend_length( this->output_allocation_hints[i], - this->output_multiple_items[i]*this->output_items_sizes[i], - at_least_items*this->output_items_sizes[i] + hint_items*this->output_items_sizes[i], + this->output_configs[i].reserve_items*this->output_items_sizes[i], + this->output_configs[i].maximum_items*this->output_items_sizes[i] ); SBufferDeleter deleter = boost::bind(&BlockActor::buffer_returner, this, i, _1); diff --git a/lib/block_handlers.cpp b/lib/block_handlers.cpp index 6925a60..2e71ac1 100644 --- a/lib/block_handlers.cpp +++ b/lib/block_handlers.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include <gras_impl/block_actor.hpp> #include <boost/make_shared.hpp> @@ -85,8 +85,8 @@ void BlockActor::handle_top_token( //TODO, schedule this message as a pre-allocation message //tell the upstream about the input requirements OutputHintMessage output_hints; - output_hints.history_bytes = this->input_history_items[i]*this->input_items_sizes[i]; - output_hints.reserve_bytes = this->input_multiple_items[i]; + output_hints.history_bytes = this->input_configs[i].lookahead_items*this->input_items_sizes[i]; + output_hints.reserve_bytes = this->input_reserve_items[i]; output_hints.token = this->input_tokens[i]; this->post_upstream(i, output_hints); @@ -130,7 +130,7 @@ void BlockActor::handle_top_thread_group( //spawn a new thread if this block is a source this->thread_group = message; this->interruptible_thread.reset(); //erase old one - if (this->get_num_inputs() == 0) //its a source + if (this->interruptible_work) { this->interruptible_thread = boost::make_shared<InterruptibleThread>( this->thread_group, boost::bind(&BlockActor::task_work, this) diff --git a/lib/block_task.cpp b/lib/block_task.cpp index d1ff52b..a64b3d7 100644 --- a/lib/block_task.cpp +++ b/lib/block_task.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include <gras_impl/block_actor.hpp> #include "tag_handlers.hpp" @@ -120,7 +120,7 @@ void BlockActor::handle_task(void) //continue; if ( potential_inline and - input_inline_enables[i] and + input_configs[i].inline_buffer and output_inline_index < num_outputs and buff.get_affinity() == this->buffer_affinity ){ @@ -159,10 +159,6 @@ void BlockActor::handle_task(void) { forecast_again_you_jerk: fcast_ninput_items = work_ninput_items; - { - num_output_items /= this->output_multiple_items.front(); - num_output_items *= this->output_multiple_items.front(); - } block_ptr->forecast(num_output_items, fcast_ninput_items); for (size_t i = 0; i < num_inputs; i++) { @@ -248,14 +244,11 @@ void BlockActor::handle_task(void) GRAS_FORCE_INLINE void BlockActor::conclusion(void) { - + //missing at least one upstream provider? //since nothing else is coming in, its safe to mark done - if (this->inputs_done.all()) //no upstream providers + if (this->any_inputs_done() or this->forecast_fail) { - if (not this->input_queues.all_ready() or this->forecast_fail) - { - this->mark_done(); - } + this->mark_done(); } //still have IO ready? kick off another task diff --git a/lib/debug.cpp b/lib/debug.cpp index f2c3700..988994f 100644 --- a/lib/debug.cpp +++ b/lib/debug.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include <gras_impl/debug.hpp> diff --git a/lib/element.cpp b/lib/element.cpp index c7afb8b..9987bd4 100644 --- a/lib/element.cpp +++ b/lib/element.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include "element_impl.hpp" #include <gnuradio/element.hpp> diff --git a/lib/element_impl.hpp b/lib/element_impl.hpp index 988bbbf..90c4fe2 100644 --- a/lib/element_impl.hpp +++ b/lib/element_impl.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_LIBGRAS_ELEMENT_IMPL_HPP #define INCLUDED_LIBGRAS_ELEMENT_IMPL_HPP diff --git a/lib/gr_block.cpp b/lib/gr_block.cpp index 821722b..dea455c 100644 --- a/lib/gr_block.cpp +++ b/lib/gr_block.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include "element_impl.hpp" #include <gr_block.h> @@ -34,7 +34,7 @@ gr_block::gr_block( this->set_output_signature(output_signature); } -int gr_block::Work( +int gr_block::work( const InputItems &input_items, const OutputItems &output_items ){ @@ -72,7 +72,7 @@ bool gr_block::is_unaligned(void) size_t gr_block::fixed_rate_noutput_to_ninput(const size_t noutput_items) { - return (*this)->block->input_history_items[0] + + return (*this)->block->input_configs[0].lookahead_items + size_t((noutput_items/this->relative_rate())); } @@ -95,3 +95,52 @@ void gr_block::set_decimation(const size_t decim) { this->set_relative_rate(1.0/decim); } + +unsigned gr_block::history(void) const +{ + //implement off-by-one history compat + return this->input_config().lookahead_items+1; +} + +void gr_block::set_history(unsigned history) +{ + gnuradio::InputPortConfig config = this->input_config(); + //implement off-by-one history compat + if (history == 0) history++; + config.lookahead_items = history-1; + this->set_input_config(config); +} + +unsigned gr_block::output_multiple(void) const +{ + return this->output_config().reserve_items+1; +} + +void gr_block::set_output_multiple(unsigned multiple) +{ + gnuradio::OutputPortConfig config = this->output_config(); + config.reserve_items = multiple; + this->set_output_config(config); +} + +int gr_block::max_noutput_items(void) const +{ + return this->output_config().maximum_items; +} + +void gr_block::set_max_noutput_items(int max_items) +{ + gnuradio::OutputPortConfig config = this->output_config(); + config.maximum_items = max_items; + this->set_output_config(config); +} + +void gr_block::unset_max_noutput_items(void) +{ + this->set_max_noutput_items(0); +} + +bool gr_block::is_set_max_noutput_items(void) const +{ + return this->max_noutput_items() != 0; +} diff --git a/lib/gr_hier_block2.cpp b/lib/gr_hier_block2.cpp index 7b61d0f..b40755a 100644 --- a/lib/gr_hier_block2.cpp +++ b/lib/gr_hier_block2.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include <gr_hier_block2.h> diff --git a/lib/gr_sync_block.cpp b/lib/gr_sync_block.cpp index 5344ac8..e883861 100644 --- a/lib/gr_sync_block.cpp +++ b/lib/gr_sync_block.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include "element_impl.hpp" #include <gr_sync_block.h> diff --git a/lib/gr_top_block.cpp b/lib/gr_top_block.cpp index 9c4b68e..3b3a5f3 100644 --- a/lib/gr_top_block.cpp +++ b/lib/gr_top_block.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include <gr_top_block.h> diff --git a/lib/gras_impl/bitset.hpp b/lib/gras_impl/bitset.hpp index 24bc2df..5ea2acb 100644 --- a/lib/gras_impl/bitset.hpp +++ b/lib/gras_impl/bitset.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_LIBGRAS_IMPL_BITSET_HPP #define INCLUDED_LIBGRAS_IMPL_BITSET_HPP diff --git a/lib/gras_impl/block_actor.hpp b/lib/gras_impl/block_actor.hpp index f321f22..bbe6d6c 100644 --- a/lib/gras_impl/block_actor.hpp +++ b/lib/gras_impl/block_actor.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_LIBGRAS_IMPL_BLOCK_ACTOR_HPP #define INCLUDED_LIBGRAS_IMPL_BLOCK_ACTOR_HPP @@ -110,14 +110,18 @@ struct BlockActor : Apology::Worker void sort_tags(const size_t index); void trim_tags(const size_t index); void conclusion(void); + GRAS_FORCE_INLINE bool any_inputs_done(void) + { + if (this->inputs_done.none()) return false; + return ((~this->input_queues.ready_bitset()) & this->inputs_done).any(); + } //per port properties std::vector<size_t> input_items_sizes; std::vector<size_t> output_items_sizes; - std::vector<size_t> input_history_items; - std::vector<size_t> output_multiple_items; - std::vector<size_t> input_multiple_items; - std::vector<bool> input_inline_enables; + std::vector<InputPortConfig> input_configs; + std::vector<OutputPortConfig> output_configs; + std::vector<size_t> input_reserve_items; //keeps track of production std::vector<uint64_t> items_consumed; @@ -158,6 +162,7 @@ struct BlockActor : Apology::Worker Block::tag_propagation_policy_t tag_prop_policy; //interruptible thread stuff + bool interruptible_work; SharedThreadGroup thread_group; boost::shared_ptr<InterruptibleThread> interruptible_thread; @@ -165,7 +170,7 @@ struct BlockActor : Apology::Worker int work_ret; inline void task_work(void) { - this->work_ret = block_ptr->Work(this->input_items, this->output_items); + this->work_ret = block_ptr->work(this->input_items, this->output_items); } //is the fg running? diff --git a/lib/gras_impl/buffer_queue.hpp b/lib/gras_impl/buffer_queue.hpp index b3c9cf7..bde4986 100644 --- a/lib/gras_impl/buffer_queue.hpp +++ b/lib/gras_impl/buffer_queue.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_LIBGRAS_IMPL_BUFFER_QUEUE_HPP #define INCLUDED_LIBGRAS_IMPL_BUFFER_QUEUE_HPP diff --git a/lib/gras_impl/debug.hpp b/lib/gras_impl/debug.hpp index a817e12..03ad30f 100644 --- a/lib/gras_impl/debug.hpp +++ b/lib/gras_impl/debug.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_LIBGRAS_IMPL_DEBUG_HPP #define INCLUDED_LIBGRAS_IMPL_DEBUG_HPP diff --git a/lib/gras_impl/input_buffer_queues.hpp b/lib/gras_impl/input_buffer_queues.hpp index 5adb06d..d9d864c 100644 --- a/lib/gras_impl/input_buffer_queues.hpp +++ b/lib/gras_impl/input_buffer_queues.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_LIBGRAS_IMPL_INPUT_BUFFERS_HPP #define INCLUDED_LIBGRAS_IMPL_INPUT_BUFFERS_HPP @@ -41,7 +41,7 @@ struct InputBufferQueues void init( const std::vector<size_t> &input_history_items, - const std::vector<size_t> &input_multiple_items, + const std::vector<size_t> &input_reserve_items, const std::vector<size_t> &input_item_sizes ); @@ -53,6 +53,11 @@ struct InputBufferQueues void resize(const size_t size); + GRAS_FORCE_INLINE const BitSet &ready_bitset(void) const + { + return _bitset; + } + GRAS_FORCE_INLINE void push(const size_t i, const SBuffer &buffer) { ASSERT(not _queues[i].full()); @@ -106,7 +111,6 @@ struct InputBufferQueues std::vector<boost::circular_buffer<SBuffer> > _queues; std::vector<size_t> _history_bytes; std::vector<size_t> _reserve_bytes; - std::vector<size_t> _multiple_bytes; std::vector<size_t> _post_bytes; std::vector<boost::shared_ptr<BufferQueue> > _aux_queues; std::vector<bool> _in_aux_buff; @@ -120,24 +124,14 @@ GRAS_FORCE_INLINE void InputBufferQueues::resize(const size_t size) _queues.resize(size, boost::circular_buffer<SBuffer>(MAX_QUEUE_SIZE)); _history_bytes.resize(size, 0); _reserve_bytes.resize(size, 0); - _multiple_bytes.resize(size, 0); _post_bytes.resize(size, 0); _aux_queues.resize(size); _in_aux_buff.resize(size, false); } -static size_t round_up_to_multiple(const size_t at_least, const size_t multiple) -{ - size_t result = (multiple*at_least)/multiple; - while (result < at_least) result += multiple; - ASSERT((multiple*result)/multiple == result); - return result; -} - - GRAS_FORCE_INLINE void InputBufferQueues::init( const std::vector<size_t> &input_history_items, - const std::vector<size_t> &input_multiple_items, + const std::vector<size_t> &input_reserve_items, const std::vector<size_t> &input_item_sizes ){ if (this->size() == 0) return; @@ -146,7 +140,7 @@ GRAS_FORCE_INLINE void InputBufferQueues::init( for (size_t i = 0; i < this->size(); i++) { - ASSERT(input_multiple_items[i] > 0); + ASSERT(input_reserve_items[i] > 0); _aux_queues[i] = boost::shared_ptr<BufferQueue>(new BufferQueue()); @@ -154,20 +148,20 @@ GRAS_FORCE_INLINE void InputBufferQueues::init( const size_t old_history = _history_bytes[i]; _history_bytes[i] = input_item_sizes[i]*input_history_items[i]; - //calculate the input multiple aka reserve size - _multiple_bytes[i] = input_item_sizes[i]*input_multiple_items[i]; - _multiple_bytes[i] = std::max(size_t(1), _multiple_bytes[i]); + //calculate the input reserve aka reserve size + _reserve_bytes[i] = input_item_sizes[i]*input_reserve_items[i]; + _reserve_bytes[i] = std::max(size_t(1), _reserve_bytes[i]); - //calculate the input multiple aka reserve size - _reserve_bytes[i] = round_up_to_multiple( - _history_bytes[i] + _multiple_bytes[i], - _multiple_bytes[i] + //calculate the input reserve aka reserve size + _reserve_bytes[i] = std::max( + _history_bytes[i] + _reserve_bytes[i], + _reserve_bytes[i] ); //post bytes are the desired buffer size to escape the edge case - _post_bytes[i] = round_up_to_multiple( + _post_bytes[i] = std::max( input_item_sizes[i]*max_history_items + _reserve_bytes[i], - _multiple_bytes[i] + _reserve_bytes[i] ); //allocate mini buffers for history edge conditions @@ -214,8 +208,6 @@ GRAS_FORCE_INLINE SBuffer InputBufferQueues::front(const size_t i, const bool co //same buffer, different offset and length SBuffer buff = front; if (conserve_history) buff.length -= _history_bytes[i]; - buff.length /= _multiple_bytes[i]; - buff.length *= _multiple_bytes[i]; //set the flag that this buffer *might* be inlined as an output buffer potential_inline = unique and (buff.length == front.length); @@ -316,7 +308,7 @@ GRAS_FORCE_INLINE void InputBufferQueues::consume(const size_t i, const size_t b if (_enqueued_bytes[i] < _history_bytes[i]) { _history_bytes[i] = 0; - _reserve_bytes[i] = _multiple_bytes[i]; + _reserve_bytes[i] = 1; //cant be 0 } __update(i); diff --git a/lib/gras_impl/interruptible_thread.hpp b/lib/gras_impl/interruptible_thread.hpp index 9ac7349..1cb9b64 100644 --- a/lib/gras_impl/interruptible_thread.hpp +++ b/lib/gras_impl/interruptible_thread.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_LIBGRAS_IMPL_INTERRUPTIBLE_THREAD_HPP #define INCLUDED_LIBGRAS_IMPL_INTERRUPTIBLE_THREAD_HPP diff --git a/lib/gras_impl/messages.hpp b/lib/gras_impl/messages.hpp index ed0ef81..81c66b7 100644 --- a/lib/gras_impl/messages.hpp +++ b/lib/gras_impl/messages.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_LIBGRAS_IMPL_MESSAGES_HPP #define INCLUDED_LIBGRAS_IMPL_MESSAGES_HPP diff --git a/lib/gras_impl/output_buffer_queues.hpp b/lib/gras_impl/output_buffer_queues.hpp index 69c5eb0..a740b2d 100644 --- a/lib/gras_impl/output_buffer_queues.hpp +++ b/lib/gras_impl/output_buffer_queues.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_LIBGRAS_IMPL_OUTPUT_BUFFER_QUEUES_HPP #define INCLUDED_LIBGRAS_IMPL_OUTPUT_BUFFER_QUEUES_HPP diff --git a/lib/gras_impl/token.hpp b/lib/gras_impl/token.hpp index d5b438a..db5f047 100644 --- a/lib/gras_impl/token.hpp +++ b/lib/gras_impl/token.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_LIBGRAS_IMPL_TOKEN_HPP #define INCLUDED_LIBGRAS_IMPL_TOKEN_HPP diff --git a/lib/hier_block.cpp b/lib/hier_block.cpp index 9a25597..ef29cc2 100644 --- a/lib/hier_block.cpp +++ b/lib/hier_block.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include "element_impl.hpp" #include <gnuradio/hier_block.hpp> diff --git a/lib/input_handlers.cpp b/lib/input_handlers.cpp index 193647d..574aee4 100644 --- a/lib/input_handlers.cpp +++ b/lib/input_handlers.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include <gras_impl/block_actor.hpp> #include <boost/foreach.hpp> @@ -56,13 +56,9 @@ void BlockActor::handle_input_check(const InputCheckMessage &message, const Ther //an upstream block declared itself done, recheck the token this->inputs_done.set(index, this->input_tokens[index].unique()); - - if (this->inputs_done.all()) //no upstream providers + if (this->any_inputs_done()) //missing an upstream provider { - if (not this->input_queues.all_ready()) - { - this->mark_done(); - } + this->mark_done(); } } diff --git a/lib/output_handlers.cpp b/lib/output_handlers.cpp index 5165b2a..c3d8392 100644 --- a/lib/output_handlers.cpp +++ b/lib/output_handlers.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include <gras_impl/block_actor.hpp> #include <boost/foreach.hpp> diff --git a/lib/sbuffer.cpp b/lib/sbuffer.cpp index 6662bb7..3133caa 100644 --- a/lib/sbuffer.cpp +++ b/lib/sbuffer.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include <gnuradio/sbuffer.hpp> #include <numanuma.hpp> diff --git a/lib/tag_handlers.hpp b/lib/tag_handlers.hpp index 0a89ef1..9e20bc0 100644 --- a/lib/tag_handlers.hpp +++ b/lib/tag_handlers.hpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef INCLUDED_LIBGRAS_TAG_HANDLERS_HPP #define INCLUDED_LIBGRAS_TAG_HANDLERS_HPP diff --git a/lib/top_block.cpp b/lib/top_block.cpp index b2c2e8d..c93bda5 100644 --- a/lib/top_block.cpp +++ b/lib/top_block.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include "element_impl.hpp" #include <gnuradio/top_block.hpp> @@ -20,6 +20,11 @@ using namespace gnuradio; +GlobalBlockConfig::GlobalBlockConfig(void) +{ + maximum_output_items = 0; +} + TopBlock::TopBlock(void) { //NOP @@ -48,18 +53,11 @@ void ElementImpl::top_block_cleanup(void) << std::flush; } -void TopBlock::update(void) +void TopBlock::commit(void) { this->start(); //ok to re-start, means update } -void TopBlock::set_buffer_hint(const size_t hint) -{ - TopHintMessage message; - message.hint = hint; - (*this)->executor->post_all(message); -} - void TopBlock::start(void) { (*this)->executor->commit(); diff --git a/lib/topology_handler.cpp b/lib/topology_handler.cpp index b24bb98..7e0c710 100644 --- a/lib/topology_handler.cpp +++ b/lib/topology_handler.cpp @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #include <gras_impl/block_actor.hpp> @@ -38,7 +38,7 @@ void resize_fill_grow(V &v, const size_t new_len, const T &fill) template <typename V> void resize_fill_back(V &v, const size_t new_len) { - if (v.empty()) v.push_back(0); + if (v.empty()) v.resize(1); resize_fill_grow(v, new_len, v.back()); } @@ -59,9 +59,8 @@ void BlockActor::handle_topology( fill_item_sizes_from_sig(this->output_items_sizes, block_ptr->output_signature(), num_outputs); //resize and fill port properties - resize_fill_back(this->input_history_items, num_inputs); - resize_fill_back(this->output_multiple_items, num_outputs); - resize_fill_grow(this->input_inline_enables, num_inputs, false); + resize_fill_back(this->input_configs, num_inputs); + resize_fill_back(this->output_configs, num_outputs); //resize the bytes consumed/produced resize_fill_grow(this->items_consumed, num_inputs, 0); @@ -111,18 +110,21 @@ void BlockActor::handle_update_inputs( const size_t num_outputs = this->get_num_outputs(); //impose input reserve requirements based on relative rate and output multiple - resize_fill_grow(this->input_multiple_items, num_inputs, 1); + resize_fill_grow(this->input_reserve_items, num_inputs, 1); + std::vector<size_t> input_lookahead_items(num_inputs); for (size_t i = 0; i < num_inputs; i++) { + input_lookahead_items[i] = this->input_configs[i].lookahead_items; + //TODO, this is a little cheap, we only look at output multiple [0] - const size_t multiple = (num_outputs)?this->output_multiple_items.front():1; + const size_t multiple = (num_outputs)?this->output_configs.front().reserve_items:1; if (this->enable_fixed_rate) { - this->input_multiple_items[i] = size_t(std::ceil(multiple/this->relative_rate)); + this->input_reserve_items[i] = size_t(std::ceil(multiple/this->relative_rate)); } - if (this->input_multiple_items[i] == 0) this->input_multiple_items[i] = 1; + if (this->input_reserve_items[i] == 0) this->input_reserve_items[i] = 1; } //init the history comprehension on input queues - this->input_queues.init(this->input_history_items, this->input_multiple_items, this->input_items_sizes); + this->input_queues.init(input_lookahead_items, this->input_reserve_items, this->input_items_sizes); } diff --git a/swig/gras.i b/swig/gras.i index b56318d..4a605f5 100644 --- a/swig/gras.i +++ b/swig/gras.i @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. %rename(io_signature) gr_make_io_signature; %rename(io_signature2) gr_make_io_signature2; diff --git a/swig/runtime.i b/swig/runtime.i index 4c9d0ea..6b1999b 100644 --- a/swig/runtime.i +++ b/swig/runtime.i @@ -12,7 +12,7 @@ // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License -// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. +// along with this program. If not, see <http://www.gnu.org/licenses/>. #define GR_CORE_API #define GRAS_API |