summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/block.cc
diff options
context:
space:
mode:
authorDavid Sorber <david.sorber@blacklynx.tech>2021-07-29 11:34:37 -0400
committermormj <34754695+mormj@users.noreply.github.com>2021-10-25 11:27:01 -0400
commitf3c558d88bc68d865f823c31e7d9aa78b3feab59 (patch)
tree026d8ff5568bc2c5ab731df29d87901cf1177e00 /gnuradio-runtime/lib/block.cc
parent788827ae116bef871e144abd39b1e4482208eabe (diff)
runtime: Custom Buffer/Accelerator Device Support - Milestone 2
Completion of custom buffer/accelerator device support changes: * Improved custom buffer interface by removing awkward memory allocation functions from the block class * Increased flexibility for creating custom buffers by allowing creation of buffer_single_mapped subclasses * Fully incorporated data movement abstraction into the custom buffer interface and the runtime itself; accelerated blocks are no longer directly responsible for their own data movement * Zero copy back-to-back accelerated blocks are now supported (data no longer needs to be moved back to the host between each block) Signed-off-by: David Sorber <david.sorber@blacklynx.tech> Signed-off-by: Mike Mason <mike.mason@blacklynx.tech>
Diffstat (limited to 'gnuradio-runtime/lib/block.cc')
-rw-r--r--gnuradio-runtime/lib/block.cc63
1 files changed, 38 insertions, 25 deletions
diff --git a/gnuradio-runtime/lib/block.cc b/gnuradio-runtime/lib/block.cc
index bb6ce95298..75f9dc6ae4 100644
--- a/gnuradio-runtime/lib/block.cc
+++ b/gnuradio-runtime/lib/block.cc
@@ -384,7 +384,8 @@ void block::set_min_output_buffer(int port, long min_output_buffer)
void block::allocate_detail(int ninputs,
int noutputs,
const std::vector<int>& downstream_max_nitems_vec,
- const std::vector<uint64_t>& downstream_lcm_nitems_vec)
+ const std::vector<uint64_t>& downstream_lcm_nitems_vec,
+ const std::vector<uint32_t>& downstream_max_out_mult_vec)
{
block_detail_sptr detail = make_block_detail(ninputs, noutputs);
@@ -393,8 +394,10 @@ void block::allocate_detail(int ninputs,
for (int i = 0; i < noutputs; i++) {
expand_minmax_buffer(i);
- buffer_sptr buffer = allocate_buffer(
- i, downstream_max_nitems_vec[i], downstream_lcm_nitems_vec[i]);
+ buffer_sptr buffer = allocate_buffer(i,
+ downstream_max_nitems_vec[i],
+ downstream_lcm_nitems_vec[i],
+ downstream_max_out_mult_vec[i]);
GR_LOG_DEBUG(d_debug_logger,
"Allocated buffer for output " + identifier() + " " +
std::to_string(i));
@@ -413,19 +416,24 @@ void block::allocate_detail(int ninputs,
set_detail(detail);
}
-buffer_sptr block::replace_buffer(uint32_t out_port, block_sptr block_owner)
+buffer_sptr
+block::replace_buffer(uint32_t src_port, uint32_t dst_port, block_sptr block_owner)
{
block_detail_sptr detail_ = detail();
- buffer_sptr orig_buffer = detail_->output(out_port);
+ buffer_sptr orig_buffer = detail_->output(src_port);
- // Make a new buffer but this time use the passed in block as the owner
- buffer_sptr new_buffer = make_buffer(orig_buffer->bufsize(),
- orig_buffer->get_sizeof_item(),
- orig_buffer->get_downstream_lcm_nitems(),
- shared_from_base<block>(),
- block_owner);
+ buffer_type buftype = block_owner->output_signature()->stream_buffer_type(dst_port);
- detail_->set_output(out_port, new_buffer);
+ // Make a new buffer but this time use the passed in block as the owner
+ buffer_sptr new_buffer =
+ buftype.make_buffer(orig_buffer->bufsize(),
+ orig_buffer->get_sizeof_item(),
+ orig_buffer->get_downstream_lcm_nitems(),
+ orig_buffer->get_max_reader_output_multiple(),
+ shared_from_base<block>(),
+ block_owner);
+
+ detail_->set_output(src_port, new_buffer);
return new_buffer;
}
@@ -435,7 +443,8 @@ void block::enable_update_rate(bool en) { d_update_rate = en; }
buffer_sptr block::allocate_buffer(int port,
int downstream_max_nitems,
- uint64_t downstream_lcm_nitems)
+ uint64_t downstream_lcm_nitems,
+ uint32_t downstream_max_out_mult)
{
int item_size = output_signature()->sizeof_stream_item(port);
@@ -473,14 +482,16 @@ buffer_sptr block::allocate_buffer(int port,
buffer_sptr buf;
#ifdef BUFFER_DEBUG
- // BUFFER DEBUG
GR_LOG_DEBUG(d_logger,
"Block: " + name() + " allocated buffer for output " + identifier());
#endif
+ // Grab the buffer type associated with the output port and use it to
+ // create the specified type of buffer
+ buffer_type buftype = output_signature()->stream_buffer_type(port);
+
try {
#ifdef BUFFER_DEBUG
- // BUFFER DEBUG
std::ostringstream msg;
msg << "downstream_max_nitems: " << downstream_max_nitems
<< " -- downstream_lcm_nitems: " << downstream_lcm_nitems
@@ -498,18 +509,20 @@ buffer_sptr block::allocate_buffer(int port,
}
GR_LOG_DEBUG(d_logger, msg.str());
#endif
- buf = make_buffer(nitems,
- item_size,
- downstream_lcm_nitems,
- shared_from_base<block>(),
- shared_from_base<block>());
+ buf = buftype.make_buffer(nitems,
+ item_size,
+ downstream_lcm_nitems,
+ downstream_max_out_mult,
+ shared_from_base<block>(),
+ shared_from_base<block>());
} catch (std::bad_alloc&) {
- buf = make_buffer(nitems,
- item_size,
- downstream_lcm_nitems,
- shared_from_base<block>(),
- shared_from_base<block>());
+ buf = buftype.make_buffer(nitems,
+ item_size,
+ downstream_lcm_nitems,
+ downstream_max_out_mult,
+ shared_from_base<block>(),
+ shared_from_base<block>());
}
// Set the max noutput items size here to make sure it's always