summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/lib')
-rw-r--r--gnuradio-runtime/lib/CMakeLists.txt2
-rw-r--r--gnuradio-runtime/lib/buffer.cc18
-rw-r--r--gnuradio-runtime/lib/buffer_context.cc32
-rw-r--r--gnuradio-runtime/lib/flat_flowgraph.cc18
-rw-r--r--gnuradio-runtime/lib/host_buffer.cc60
-rw-r--r--gnuradio-runtime/lib/qa_host_buffer.cc14
-rw-r--r--gnuradio-runtime/lib/transfer_type.cc32
7 files changed, 89 insertions, 87 deletions
diff --git a/gnuradio-runtime/lib/CMakeLists.txt b/gnuradio-runtime/lib/CMakeLists.txt
index 6fcd31bac4..f91900f5cc 100644
--- a/gnuradio-runtime/lib/CMakeLists.txt
+++ b/gnuradio-runtime/lib/CMakeLists.txt
@@ -55,7 +55,6 @@ add_library(gnuradio-runtime
block_gateway_impl.cc
block_registry.cc
buffer.cc
- buffer_context.cc
buffer_double_mapped.cc
buffer_reader.cc
buffer_reader_sm.cc
@@ -92,6 +91,7 @@ add_library(gnuradio-runtime
top_block_impl.cc
tpb_detail.cc
tpb_thread_body.cc
+ transfer_type.cc
vmcircbuf.cc
vmcircbuf_createfilemapping.cc
vmcircbuf_mmap_shm_open.cc
diff --git a/gnuradio-runtime/lib/buffer.cc b/gnuradio-runtime/lib/buffer.cc
index 75fc447e8d..1f949f4ec9 100644
--- a/gnuradio-runtime/lib/buffer.cc
+++ b/gnuradio-runtime/lib/buffer.cc
@@ -80,7 +80,7 @@ buffer::buffer(buffer_mapping_type buf_type,
d_downstream_lcm_nitems(downstream_lcm_nitems),
d_write_multiple(0),
d_max_reader_output_multiple(downstream_max_out_mult),
- d_context(buffer_context::DEFAULT_INVALID)
+ d_transfer_type(transfer_type::DEFAULT_INVALID)
{
gr::configure_default_loggers(d_logger, d_debug_logger, "buffer");
@@ -256,18 +256,20 @@ std::ostream& operator<<(std::ostream& os, const buffer& buf)
return os;
}
-void buffer::set_context(const buffer_context& context)
+void buffer::set_transfer_type(const transfer_type& type)
{
- if ((d_context == buffer_context::DEFAULT_INVALID) || (d_context == context)) {
- // Set the context if the existing value is the default or if it is the
+ if ((d_transfer_type == transfer_type::DEFAULT_INVALID) ||
+ (d_transfer_type == type)) {
+ // Set the transfer type if the existing value is the default or if it is the
// same as what's already been set
- d_context = context;
+ d_transfer_type = type;
} else {
- // Otherwise error out as the context value cannot be changed after
+ // Otherwise error out as the transfer type value cannot be changed after
// it is set
std::ostringstream msg;
- msg << "Block: " << link()->identifier() << " has context " << d_context
- << " assigned. Cannot change to context " << context << ".";
+ msg << "Block: " << link()->identifier() << " has transfer type "
+ << d_transfer_type << " assigned. Cannot change to transfer type " << type
+ << ".";
GR_LOG_ERROR(d_logger, msg.str());
throw std::runtime_error(msg.str());
}
diff --git a/gnuradio-runtime/lib/buffer_context.cc b/gnuradio-runtime/lib/buffer_context.cc
deleted file mode 100644
index 9cd27add36..0000000000
--- a/gnuradio-runtime/lib/buffer_context.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2021 BlackLynx, Inc.
- *
- * This file is part of GNU Radio
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-#include <gnuradio/buffer_context.h>
-
-namespace gr {
-
-std::ostream& operator<<(std::ostream& os, const buffer_context& context)
-{
- switch (context) {
- case buffer_context::DEFAULT_INVALID:
- return os << "DEFAULT_INVALID";
- case buffer_context::HOST_TO_DEVICE:
- return os << "HOST_TO_DEVICE";
- case buffer_context::DEVICE_TO_HOST:
- return os << "DEVICE_TO_HOST";
- case buffer_context::HOST_TO_HOST:
- return os << "HOST_TO_HOST";
- case buffer_context::DEVICE_TO_DEVICE:
- return os << "DEVICE_TO_DEVICE";
- default:
- return os << "Unknown buffer context: " << static_cast<int>(context);
- }
-}
-
-} // namespace gr
diff --git a/gnuradio-runtime/lib/flat_flowgraph.cc b/gnuradio-runtime/lib/flat_flowgraph.cc
index ef96ef21ac..3856b170d9 100644
--- a/gnuradio-runtime/lib/flat_flowgraph.cc
+++ b/gnuradio-runtime/lib/flat_flowgraph.cc
@@ -201,26 +201,26 @@ void flat_flowgraph::connect_block_inputs(basic_block_sptr block)
if (!src_grblock)
throw std::runtime_error("connect_block_inputs found non-gr::block");
- // In order to determine the buffer context, we need to examine both
+ // In order to determine the buffer's transfer type, we need to examine both
// the upstream and the downstream buffer_types
buffer_type src_buf_type =
src_grblock->output_signature()->stream_buffer_type(src_port);
buffer_type dest_buf_type =
grblock->input_signature()->stream_buffer_type(dst_port);
- buffer_context context;
+ transfer_type buf_xfer_type;
if (src_buf_type == buffer_double_mapped::type &&
dest_buf_type == buffer_double_mapped::type) {
- context = buffer_context::HOST_TO_HOST;
+ buf_xfer_type = transfer_type::HOST_TO_HOST;
} else if (src_buf_type != buffer_double_mapped::type &&
dest_buf_type == buffer_double_mapped::type) {
- context = buffer_context::DEVICE_TO_HOST;
+ buf_xfer_type = transfer_type::DEVICE_TO_HOST;
} else if (src_buf_type == buffer_double_mapped::type &&
dest_buf_type != buffer_double_mapped::type) {
- context = buffer_context::HOST_TO_DEVICE;
+ buf_xfer_type = transfer_type::HOST_TO_DEVICE;
} else if (src_buf_type != buffer_double_mapped::type &&
dest_buf_type != buffer_double_mapped::type) {
- context = buffer_context::DEVICE_TO_DEVICE;
+ buf_xfer_type = transfer_type::DEVICE_TO_DEVICE;
}
buffer_sptr src_buffer;
@@ -255,12 +255,12 @@ void flat_flowgraph::connect_block_inputs(basic_block_sptr block)
}
}
- // Set buffer's context
- src_buffer->set_context(context);
+ // Set buffer's transfer type
+ src_buffer->set_transfer_type(buf_xfer_type);
std::ostringstream msg;
msg << "Setting input " << dst_port << " from edge " << (*e).identifier()
- << " context: " << context;
+ << " transfer type: " << buf_xfer_type;
GR_LOG_DEBUG(d_debug_logger, msg.str());
detail->set_input(dst_port,
diff --git a/gnuradio-runtime/lib/host_buffer.cc b/gnuradio-runtime/lib/host_buffer.cc
index 6e1a1d1003..535a7a5286 100644
--- a/gnuradio-runtime/lib/host_buffer.cc
+++ b/gnuradio-runtime/lib/host_buffer.cc
@@ -55,7 +55,7 @@ void host_buffer::post_work(int nitems)
#ifdef BUFFER_DEBUG
std::ostringstream msg;
msg << "[" << this << "] "
- << "host_buffer [" << d_context << "] -- post_work: " << nitems;
+ << "host_buffer [" << d_transfer_type << "] -- post_work: " << nitems;
GR_LOG_DEBUG(d_logger, msg.str());
#endif
@@ -65,26 +65,26 @@ void host_buffer::post_work(int nitems)
// NOTE: when this function is called the write pointer has not yet been
// advanced so it can be used directly as the source ptr
- switch (d_context) {
- case buffer_context::HOST_TO_DEVICE: {
+ switch (d_transfer_type) {
+ case transfer_type::HOST_TO_DEVICE: {
// Copy data from host buffer to device buffer
void* dest_ptr = &d_device_base[d_write_index * d_sizeof_item];
device_memcpy(dest_ptr, write_pointer(), nitems * d_sizeof_item);
} break;
- case buffer_context::DEVICE_TO_HOST: {
+ case transfer_type::DEVICE_TO_HOST: {
// Copy data from device buffer to host buffer
void* dest_ptr = &d_base[d_write_index * d_sizeof_item];
device_memcpy(dest_ptr, write_pointer(), nitems * d_sizeof_item);
} break;
- case buffer_context::DEVICE_TO_DEVICE:
+ case transfer_type::DEVICE_TO_DEVICE:
// No op
break;
default:
std::ostringstream msg;
- msg << "Unexpected context for host_buffer: " << d_context;
+ msg << "Unexpected transfer type for host_buffer: " << d_transfer_type;
GR_LOG_ERROR(d_logger, msg.str());
throw std::runtime_error(msg.str());
}
@@ -115,21 +115,21 @@ bool host_buffer::do_allocate_buffer(size_t final_nitems, size_t sizeof_item)
void* host_buffer::write_pointer()
{
void* ptr = nullptr;
- switch (d_context) {
- case buffer_context::HOST_TO_DEVICE:
+ switch (d_transfer_type) {
+ case transfer_type::HOST_TO_DEVICE:
// Write into host buffer
ptr = &d_base[d_write_index * d_sizeof_item];
break;
- case buffer_context::DEVICE_TO_HOST:
- case buffer_context::DEVICE_TO_DEVICE:
+ case transfer_type::DEVICE_TO_HOST:
+ case transfer_type::DEVICE_TO_DEVICE:
// Write into "device" buffer
ptr = &d_device_base[d_write_index * d_sizeof_item];
break;
default:
std::ostringstream msg;
- msg << "Unexpected context for host_buffer: " << d_context;
+ msg << "Unexpected transfer type for host_buffer: " << d_transfer_type;
GR_LOG_ERROR(d_logger, msg.str());
throw std::runtime_error(msg.str());
}
@@ -140,21 +140,21 @@ void* host_buffer::write_pointer()
const void* host_buffer::_read_pointer(unsigned int read_index)
{
void* ptr = nullptr;
- switch (d_context) {
- case buffer_context::HOST_TO_DEVICE:
- case buffer_context::DEVICE_TO_DEVICE:
+ switch (d_transfer_type) {
+ case transfer_type::HOST_TO_DEVICE:
+ case transfer_type::DEVICE_TO_DEVICE:
// Read from "device" buffer
ptr = &d_device_base[read_index * d_sizeof_item];
break;
- case buffer_context::DEVICE_TO_HOST:
+ case transfer_type::DEVICE_TO_HOST:
// Read from host buffer
ptr = &d_base[read_index * d_sizeof_item];
break;
default:
std::ostringstream msg;
- msg << "Unexpected context for host_buffer: " << d_context;
+ msg << "Unexpected transfer type for host_buffer: " << d_transfer_type;
GR_LOG_ERROR(d_logger, msg.str());
throw std::runtime_error(msg.str());
}
@@ -169,14 +169,14 @@ bool host_buffer::input_blocked_callback(int items_required,
#ifdef BUFFER_DEBUG
std::ostringstream msg;
msg << "[" << this << "] "
- << "host_buffer [" << d_context << "] -- input_blocked_callback";
+ << "host_buffer [" << d_transfer_type << "] -- input_blocked_callback";
GR_LOG_DEBUG(d_logger, msg.str());
#endif
bool rc = false;
- switch (d_context) {
- case buffer_context::HOST_TO_DEVICE:
- case buffer_context::DEVICE_TO_DEVICE:
+ switch (d_transfer_type) {
+ case transfer_type::HOST_TO_DEVICE:
+ case transfer_type::DEVICE_TO_DEVICE:
// Adjust "device" buffer
rc = input_blocked_callback_logic(items_required,
items_avail,
@@ -186,8 +186,8 @@ bool host_buffer::input_blocked_callback(int items_required,
host_buffer::device_memmove);
break;
- case buffer_context::DEVICE_TO_HOST:
- case buffer_context::HOST_TO_HOST:
+ case transfer_type::DEVICE_TO_HOST:
+ case transfer_type::HOST_TO_HOST:
// Adjust host buffer
rc = input_blocked_callback_logic(
items_required, items_avail, read_index, d_base, std::memcpy, std::memmove);
@@ -195,7 +195,7 @@ bool host_buffer::input_blocked_callback(int items_required,
default:
std::ostringstream msg;
- msg << "Unexpected context for host_buffer: " << d_context;
+ msg << "Unexpected transfer type for host_buffer: " << d_transfer_type;
GR_LOG_ERROR(d_logger, msg.str());
throw std::runtime_error(msg.str());
}
@@ -208,20 +208,20 @@ bool host_buffer::output_blocked_callback(int output_multiple, bool force)
#ifdef BUFFER_DEBUG
std::ostringstream msg;
msg << "[" << this << "] "
- << "host_buffer [" << d_context << "] -- output_blocked_callback";
+ << "host_buffer [" << d_transfer_type << "] -- output_blocked_callback";
GR_LOG_DEBUG(d_logger, msg.str());
#endif
bool rc = false;
- switch (d_context) {
- case buffer_context::HOST_TO_DEVICE:
- case buffer_context::HOST_TO_HOST:
+ switch (d_transfer_type) {
+ case transfer_type::HOST_TO_DEVICE:
+ case transfer_type::HOST_TO_HOST:
// Adjust host buffer
rc = output_blocked_callback_logic(output_multiple, force, d_base, std::memmove);
break;
- case buffer_context::DEVICE_TO_HOST:
- case buffer_context::DEVICE_TO_DEVICE:
+ case transfer_type::DEVICE_TO_HOST:
+ case transfer_type::DEVICE_TO_DEVICE:
// Adjust "device" buffer
rc = output_blocked_callback_logic(
output_multiple, force, d_device_base, host_buffer::device_memmove);
@@ -229,7 +229,7 @@ bool host_buffer::output_blocked_callback(int output_multiple, bool force)
default:
std::ostringstream msg;
- msg << "Unexpected context for host_buffer: " << d_context;
+ msg << "Unexpected transfer type for host_buffer: " << d_transfer_type;
GR_LOG_ERROR(d_logger, msg.str());
throw std::runtime_error(msg.str());
}
diff --git a/gnuradio-runtime/lib/qa_host_buffer.cc b/gnuradio-runtime/lib/qa_host_buffer.cc
index e8f29afe8d..c710d3ec48 100644
--- a/gnuradio-runtime/lib/qa_host_buffer.cc
+++ b/gnuradio-runtime/lib/qa_host_buffer.cc
@@ -13,10 +13,10 @@
#endif
#include <gnuradio/block.h>
-#include <gnuradio/buffer_context.h>
#include <gnuradio/buffer_reader.h>
#include <gnuradio/host_buffer.h>
#include <gnuradio/random.h>
+#include <gnuradio/transfer_type.h>
#include <boost/test/unit_test.hpp>
#include <cstdlib>
#include <iostream>
@@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(t0)
gr::buffer_sptr buf(
gr::host_buffer::make_host_buffer(nitems, sizeof(int), nitems, 1, nop, nop));
- buf->set_context(gr::buffer_context::HOST_TO_HOST);
+ buf->set_transfer_type(gr::transfer_type::HOST_TO_HOST);
gr::buffer_reader_sptr rdr1(gr::buffer_add_reader(buf, 0, nop));
@@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE(t1)
gr::buffer_sptr buf(
gr::host_buffer::make_host_buffer(nitems, sizeof(int), nitems, 1, nop, nop));
- buf->set_context(gr::buffer_context::HOST_TO_HOST);
+ buf->set_transfer_type(gr::transfer_type::HOST_TO_HOST);
gr::buffer_reader_sptr rdr1(gr::buffer_add_reader(buf, 0, nop));
@@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE(t2)
gr::buffer_sptr buf(
gr::host_buffer::make_host_buffer(nitems, sizeof(int), nitems, 1, nop, nop));
- buf->set_context(gr::buffer_context::HOST_TO_HOST);
+ buf->set_transfer_type(gr::transfer_type::HOST_TO_HOST);
gr::buffer_reader_sptr rdr1(gr::buffer_add_reader(buf, 0, nop));
@@ -198,7 +198,7 @@ BOOST_AUTO_TEST_CASE(t3)
gr::buffer_sptr buf(
gr::host_buffer::make_host_buffer(nitems, sizeof(int), nitems, 1, nop, nop));
- buf->set_context(gr::buffer_context::HOST_TO_HOST);
+ buf->set_transfer_type(gr::transfer_type::HOST_TO_HOST);
gr::buffer_reader_sptr rdr1(gr::buffer_add_reader(buf, 0, nop));
gr::buffer_reader_sptr rdr2(gr::buffer_add_reader(buf, 0, nop));
@@ -249,7 +249,7 @@ BOOST_AUTO_TEST_CASE(t4)
gr::buffer_sptr buf(
gr::host_buffer::make_host_buffer(nitems, sizeof(int), nitems, 1, nop, nop));
- buf->set_context(gr::buffer_context::HOST_TO_HOST);
+ buf->set_transfer_type(gr::transfer_type::HOST_TO_HOST);
gr::buffer_reader_sptr rdr1(gr::buffer_add_reader(buf, 0, nop));
@@ -298,7 +298,7 @@ BOOST_AUTO_TEST_CASE(t5)
gr::buffer_sptr buf(
gr::host_buffer::make_host_buffer(nitems, sizeof(int), nitems, 1, nop, nop));
- buf->set_context(gr::buffer_context::HOST_TO_HOST);
+ buf->set_transfer_type(gr::transfer_type::HOST_TO_HOST);
gr::buffer_reader_sptr rdr1(gr::buffer_add_reader(buf, 0, nop));
diff --git a/gnuradio-runtime/lib/transfer_type.cc b/gnuradio-runtime/lib/transfer_type.cc
new file mode 100644
index 0000000000..befb3e4a39
--- /dev/null
+++ b/gnuradio-runtime/lib/transfer_type.cc
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2021 BlackLynx, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+#include <gnuradio/transfer_type.h>
+
+namespace gr {
+
+std::ostream& operator<<(std::ostream& os, const transfer_type& type)
+{
+ switch (type) {
+ case transfer_type::DEFAULT_INVALID:
+ return os << "DEFAULT_INVALID";
+ case transfer_type::HOST_TO_DEVICE:
+ return os << "HOST_TO_DEVICE";
+ case transfer_type::DEVICE_TO_HOST:
+ return os << "DEVICE_TO_HOST";
+ case transfer_type::HOST_TO_HOST:
+ return os << "HOST_TO_HOST";
+ case transfer_type::DEVICE_TO_DEVICE:
+ return os << "DEVICE_TO_DEVICE";
+ default:
+ return os << "Unknown transfer type: " << static_cast<int>(type);
+ }
+}
+
+} // namespace gr