diff options
Diffstat (limited to 'lib')
29 files changed, 189 insertions, 138 deletions
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); } |