diff options
author | Josh Blum | 2012-09-12 23:00:54 -0700 |
---|---|---|
committer | Josh Blum | 2012-09-12 23:00:54 -0700 |
commit | 87cd4fe7179a55f1ea34ea90744017c403838542 (patch) | |
tree | b5dc5037f8b63535e5f74e9f27817e4f2fa9af1e /lib | |
parent | c4785d122c6c0c0bd3163db1b9201eab9e286d5b (diff) | |
download | sandhi-87cd4fe7179a55f1ea34ea90744017c403838542.tar.gz sandhi-87cd4fe7179a55f1ea34ea90744017c403838542.tar.bz2 sandhi-87cd4fe7179a55f1ea34ea90744017c403838542.zip |
added inlining logic for input queue handling
Diffstat (limited to 'lib')
-rw-r--r-- | lib/block.cpp | 1 | ||||
-rw-r--r-- | lib/block_task.cpp | 23 | ||||
-rw-r--r-- | lib/gras_impl/input_buffer_queues.hpp | 14 |
3 files changed, 29 insertions, 9 deletions
diff --git a/lib/block.cpp b/lib/block.cpp index 6bbdcd8..39939cb 100644 --- a/lib/block.cpp +++ b/lib/block.cpp @@ -30,7 +30,6 @@ 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); diff --git a/lib/block_task.cpp b/lib/block_task.cpp index 3d9056e..114c073 100644 --- a/lib/block_task.cpp +++ b/lib/block_task.cpp @@ -107,20 +107,35 @@ void ElementImpl::handle_task(const tsbe::TaskInterface &task_iface) //------------------------------------------------------------------ size_t num_input_items = REALLY_BIG; //so big that it must std::min size_t input_tokens_count = 0; + size_t output_inline_index = 0; for (size_t i = 0; i < num_inputs; i++) { input_tokens_count += this->input_tokens[i].use_count(); ASSERT(this->input_queues.ready(i)); - const SBuffer buff = this->input_queues.front(i); + bool potential_inline; + const SBuffer buff = this->input_queues.front(i, potential_inline); + void *mem = buff.get(); const size_t items = buff.length/this->input_items_sizes[i]; - this->work_io_ptr_mask |= ptrdiff_t(buff.get()); - this->input_items[i]._mem = buff.get(); + this->work_io_ptr_mask |= ptrdiff_t(mem); + this->input_items[i]._mem = mem; this->input_items[i]._len = items; - this->work_input_items[i] = buff.get(); + this->work_input_items[i] = mem; this->work_ninput_items[i] = items; num_input_items = std::min(num_input_items, items); + + //inline dealings, how and when input buffers can be inlined into output buffers + //TODO, check that the buff.get_affinity() matches this block or we dont inline + //continue; + if (potential_inline and input_inline_enables[i] and output_inline_index < num_outputs) + { + //copy buffer reference but push with zero length, same offset + SBuffer new_obuff = buff; + new_obuff.length = 0; + this->output_queues.push_front(i, new_obuff); //you got inlined! + output_inline_index++; //done do this output port again + } } const bool inputs_done = num_inputs != 0 and input_tokens_count == num_inputs; diff --git a/lib/gras_impl/input_buffer_queues.hpp b/lib/gras_impl/input_buffer_queues.hpp index 44abcf1..2188509 100644 --- a/lib/gras_impl/input_buffer_queues.hpp +++ b/lib/gras_impl/input_buffer_queues.hpp @@ -53,7 +53,7 @@ struct InputBufferQueues * Otherwise, resolve pointers to the input buffer, * moving the memory and length by num history bytes. */ - SBuffer front(const size_t i); + SBuffer front(const size_t i, bool &potential_inline); /*! * Rules for consume: @@ -184,19 +184,25 @@ inline void InputBufferQueues::init( } -inline SBuffer InputBufferQueues::front(const size_t i) +inline SBuffer InputBufferQueues::front(const size_t i, bool &potential_inline) { //if (_queues[i].empty()) return BuffInfo(); ASSERT(not _queues[i].empty()); ASSERT(this->ready(i)); __prepare(i); - SBuffer &front = _queues[i].front(); - SBuffer buff = front; //copy new settings + const bool unique = front.unique(); + + //same buffer, different offset and length + SBuffer buff = front; buff.offset -= _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 (_history_bytes[i] == 0) and (buff.length == front.length); + return buff; } |