diff options
author | Josh Blum | 2012-09-12 21:37:49 -0700 |
---|---|---|
committer | Josh Blum | 2012-09-12 21:37:49 -0700 |
commit | c7720bd1b740094636b0b66e6286f4c14961d31f (patch) | |
tree | 64887e53b7987af2ba4813d99b13487fffbb9679 | |
parent | 081b95b570e06c3130aaf979b0feaae159901c9b (diff) | |
download | sandhi-c7720bd1b740094636b0b66e6286f4c14961d31f.tar.gz sandhi-c7720bd1b740094636b0b66e6286f4c14961d31f.tar.bz2 sandhi-c7720bd1b740094636b0b66e6286f4c14961d31f.zip |
added hooks for input buffer inlining
-rw-r--r-- | include/gnuradio/block.hpp | 21 | ||||
-rw-r--r-- | lib/block.cpp | 11 | ||||
-rw-r--r-- | lib/block_handlers.cpp | 1 | ||||
-rw-r--r-- | lib/element_impl.hpp | 5 | ||||
-rw-r--r-- | lib/gras_impl/output_buffer_queues.hpp (renamed from lib/gras_impl/vector_of_queues.hpp) | 25 |
5 files changed, 52 insertions, 11 deletions
diff --git a/include/gnuradio/block.hpp b/include/gnuradio/block.hpp index ff4ede7..2adc08c 100644 --- a/include/gnuradio/block.hpp +++ b/include/gnuradio/block.hpp @@ -89,6 +89,27 @@ struct GRAS_API Block : Element void produce(const size_t which_output, const size_t how_many_items); /*! + * 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, input port 0 is automatically inline enabled. + * Automatically inlining other points cannot be assumed safe. + * The user should override these assumptions for your work(). + * + * The scheduler will inline a buffer when + * * inlining is enabled on the particular input port + * * block holds the only buffer reference aka unique + * * buffer size is less than or equal to output buffer + * * 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 buffer inlining state + bool input_inline(const size_t which_input) const; + + /*! * Enable fixed rate logic. * When enabled, relative rate is assumed to be set, * and forecast is automatically called. diff --git a/lib/block.cpp b/lib/block.cpp index 9dd0028..6bbdcd8 100644 --- a/lib/block.cpp +++ b/lib/block.cpp @@ -30,6 +30,7 @@ Block::Block(const std::string &name): { this->set_history(0); this->set_output_multiple(1); + this->set_input_inline(0, true); this->set_fixed_rate(true); this->set_relative_rate(1.0); this->set_tag_propagation_policy(TPP_ALL_TO_ALL); @@ -107,6 +108,16 @@ void Block::produce(const size_t which_output, const size_t how_many_items) (*this)->produce_items[which_output] = how_many_items; } +void Block::set_input_inline(const size_t which_input, const bool enb) +{ + vector_set((*this)->input_inline_enables, enb, which_input); +} + +bool Block::input_inline(const size_t which_input) const +{ + return (*this)->input_inline_enables[which_input]; +} + void Block::set_fixed_rate(const bool fixed_rate) { (*this)->enable_fixed_rate = fixed_rate; diff --git a/lib/block_handlers.cpp b/lib/block_handlers.cpp index 3715615..2cb167f 100644 --- a/lib/block_handlers.cpp +++ b/lib/block_handlers.cpp @@ -152,6 +152,7 @@ void ElementImpl::topology_update(const tsbe::TaskInterface &task_iface) //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 the bytes consumed/produced resize_fill_grow(this->items_consumed, num_inputs, 0); diff --git a/lib/element_impl.hpp b/lib/element_impl.hpp index 44125b1..01a9791 100644 --- a/lib/element_impl.hpp +++ b/lib/element_impl.hpp @@ -20,7 +20,7 @@ #include <gras_impl/debug.hpp> #include <gras_impl/token.hpp> #include <gras_impl/messages.hpp> -#include <gras_impl/vector_of_queues.hpp> +#include <gras_impl/output_buffer_queues.hpp> #include <gras_impl/input_buffer_queues.hpp> #include <gras_impl/interruptible_thread.hpp> @@ -67,6 +67,7 @@ struct ElementImpl 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; //keeps track of production std::vector<uint64_t> items_consumed; @@ -97,7 +98,7 @@ struct ElementImpl //buffer queues and ready conditions InputBufferQueues input_queues; - VectorOfQueues<SBuffer> output_queues; + OutputBufferQueues<SBuffer> output_queues; //tag tracking std::vector<bool> input_tags_changed; diff --git a/lib/gras_impl/vector_of_queues.hpp b/lib/gras_impl/output_buffer_queues.hpp index 32e0b7f..cf3ea0c 100644 --- a/lib/gras_impl/vector_of_queues.hpp +++ b/lib/gras_impl/output_buffer_queues.hpp @@ -14,21 +14,21 @@ // 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/>. -#ifndef INCLUDED_LIBGRAS_IMPL_VECTOR_OF_QUEUES_HPP -#define INCLUDED_LIBGRAS_IMPL_VECTOR_OF_QUEUES_HPP +#ifndef INCLUDED_LIBGRAS_IMPL_OUTPUT_BUFFER_QUEUES_HPP +#define INCLUDED_LIBGRAS_IMPL_OUTPUT_BUFFER_QUEUES_HPP #include <boost/dynamic_bitset.hpp> #include <vector> -#include <queue> +#include <deque> namespace gnuradio { template <typename T> -struct VectorOfQueues +struct OutputBufferQueues { boost::dynamic_bitset<> _bitset; - std::vector<std::queue<T> > _queues; + std::vector<std::deque<T> > _queues; inline void resize(const size_t size) { @@ -38,7 +38,14 @@ struct VectorOfQueues inline void push(const size_t i, const T &value) { - _queues[i].push(value); + _queues[i].push_back(value); + _bitset.set(i); + } + + //! used for input buffer inlining + inline void push_front(const size_t i, const T &value) + { + _queues[i].push_front(value); _bitset.set(i); } @@ -54,13 +61,13 @@ struct VectorOfQueues inline void pop(const size_t i) { - _queues[i].pop(); + _queues[i].pop_front(); _bitset.set(i, not _queues[i].empty()); } inline void flush(const size_t i) { - _queues[i] = std::queue<T>(); + _queues[i] = std::deque<T>(); _bitset.reset(i); } @@ -89,4 +96,4 @@ struct VectorOfQueues } //namespace gnuradio -#endif /*INCLUDED_LIBGRAS_IMPL_VECTOR_OF_QUEUES_HPP*/ +#endif /*INCLUDED_LIBGRAS_IMPL_OUTPUT_BUFFER_QUEUES_HPP*/ |