summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/python
diff options
context:
space:
mode:
authorDavid Sorber <david.sorber@blacklynx.tech>2021-05-12 08:59:21 -0400
committermormj <34754695+mormj@users.noreply.github.com>2021-10-25 11:27:01 -0400
commit788827ae116bef871e144abd39b1e4482208eabe (patch)
treedcfee04a77db5bb3c8042be5b0b95c54bf8759c9 /gnuradio-runtime/python
parentb8713810a2d07ac1a632bd7bfb23f3f48f67e222 (diff)
runtime: Custom Buffer/Accelerator Device Support - Milestone 1
Custom Buffer/Accelerator Device Support - Milestone 1 changes: * Refactored existing single mapped buffer code and created single mapped buffer abstraction; wrapping within single mapped buffers is handled explicitly by input blocked and output blocked callbacks that are called from block_executor * Added simple custom buffer allocation interface (NOTE: this interface will change for milestone 2) * Accelerated blocks are still responsible for data transfer but the custom buffer interface eliminates the double copy problem Signed-off-by: David Sorber <david.sorber@blacklynx.tech>
Diffstat (limited to 'gnuradio-runtime/python')
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/bindings/CMakeLists.txt1
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/bindings/basic_block_python.cc4
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/bindings/block_detail_python.cc5
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/bindings/block_python.cc2
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/bindings/buffer_python.cc5
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/bindings/buffer_reader_python.cc126
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/bindings/logger_python.cc4
-rw-r--r--gnuradio-runtime/python/gnuradio/gr_unittest.py19
8 files changed, 157 insertions, 9 deletions
diff --git a/gnuradio-runtime/python/gnuradio/gr/bindings/CMakeLists.txt b/gnuradio-runtime/python/gnuradio/gr/bindings/CMakeLists.txt
index 14eb501ddb..dbc74b0529 100644
--- a/gnuradio-runtime/python/gnuradio/gr/bindings/CMakeLists.txt
+++ b/gnuradio-runtime/python/gnuradio/gr/bindings/CMakeLists.txt
@@ -17,6 +17,7 @@ messages/msg_queue_python.cc
block_gateway_python.cc
# block_registry_python.cc
buffer_python.cc
+ buffer_reader_python.cc
constants_python.cc
endianness_python.cc
expj_python.cc
diff --git a/gnuradio-runtime/python/gnuradio/gr/bindings/basic_block_python.cc b/gnuradio-runtime/python/gnuradio/gr/bindings/basic_block_python.cc
index f18fce2c9a..933d651fa7 100644
--- a/gnuradio-runtime/python/gnuradio/gr/bindings/basic_block_python.cc
+++ b/gnuradio-runtime/python/gnuradio/gr/bindings/basic_block_python.cc
@@ -13,8 +13,8 @@
/* If manual edits are made, the following tags should be modified accordingly. */
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
-/* BINDTOOL_HEADER_FILE(basic_block.h) */
-/* BINDTOOL_HEADER_FILE_HASH(9239cc3381582f5f44010485cd48fa72) */
+/* BINDTOOL_HEADER_FILE(basic_block.h) */
+/* BINDTOOL_HEADER_FILE_HASH(5c1d5b8a3666a2e0e7a6fafae07afa29) */
/***********************************************************************************/
#include <pybind11/complex.h>
diff --git a/gnuradio-runtime/python/gnuradio/gr/bindings/block_detail_python.cc b/gnuradio-runtime/python/gnuradio/gr/bindings/block_detail_python.cc
index 219c95b153..979c19f2f2 100644
--- a/gnuradio-runtime/python/gnuradio/gr/bindings/block_detail_python.cc
+++ b/gnuradio-runtime/python/gnuradio/gr/bindings/block_detail_python.cc
@@ -13,8 +13,8 @@
/* If manual edits are made, the following tags should be modified accordingly. */
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
-/* BINDTOOL_HEADER_FILE(block_detail.h) */
-/* BINDTOOL_HEADER_FILE_HASH(274b4f673ac76cedd3ef6d466afab2fc) */
+/* BINDTOOL_HEADER_FILE(block_detail.h) */
+/* BINDTOOL_HEADER_FILE_HASH(61794baf0e727516eb0eedc08753a17a) */
/***********************************************************************************/
#include <pybind11/complex.h>
@@ -25,6 +25,7 @@ namespace py = pybind11;
#include <gnuradio/block_detail.h>
#include <gnuradio/buffer.h>
+#include <gnuradio/buffer_reader.h>
// pydoc.h is automatically generated in the build directory
#include <block_detail_pydoc.h>
diff --git a/gnuradio-runtime/python/gnuradio/gr/bindings/block_python.cc b/gnuradio-runtime/python/gnuradio/gr/bindings/block_python.cc
index 78c5b03cfe..9660a7f245 100644
--- a/gnuradio-runtime/python/gnuradio/gr/bindings/block_python.cc
+++ b/gnuradio-runtime/python/gnuradio/gr/bindings/block_python.cc
@@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(block.h) */
-/* BINDTOOL_HEADER_FILE_HASH(5df7331a717fb7c436eac2fc20991858) */
+/* BINDTOOL_HEADER_FILE_HASH(238d129ad018daa3146ff1d8867dc356) */
/***********************************************************************************/
#include <pybind11/complex.h>
diff --git a/gnuradio-runtime/python/gnuradio/gr/bindings/buffer_python.cc b/gnuradio-runtime/python/gnuradio/gr/bindings/buffer_python.cc
index 89845d2e28..de7d4edf1c 100644
--- a/gnuradio-runtime/python/gnuradio/gr/bindings/buffer_python.cc
+++ b/gnuradio-runtime/python/gnuradio/gr/bindings/buffer_python.cc
@@ -13,8 +13,8 @@
/* If manual edits are made, the following tags should be modified accordingly. */
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
-/* BINDTOOL_HEADER_FILE(buffer.h) */
-/* BINDTOOL_HEADER_FILE_HASH(69b17e66fac6e29f860466846a64feab) */
+/* BINDTOOL_HEADER_FILE(buffer.h) */
+/* BINDTOOL_HEADER_FILE_HASH(e5247f4fe5b5873c66eed72880194981) */
/***********************************************************************************/
#include <pybind11/complex.h>
@@ -25,6 +25,7 @@ namespace py = pybind11;
#include <gnuradio/block.h>
#include <gnuradio/buffer.h>
+#include <gnuradio/buffer_reader.h>
// pydoc.h is automatically generated in the build directory
#include <buffer_pydoc.h>
diff --git a/gnuradio-runtime/python/gnuradio/gr/bindings/buffer_reader_python.cc b/gnuradio-runtime/python/gnuradio/gr/bindings/buffer_reader_python.cc
new file mode 100644
index 0000000000..23e2f39d10
--- /dev/null
+++ b/gnuradio-runtime/python/gnuradio/gr/bindings/buffer_reader_python.cc
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+/***********************************************************************************/
+/* This file is automatically generated using bindtool and can be manually edited */
+/* The following lines can be configured to regenerate this file during cmake */
+/* If manual edits are made, the following tags should be modified accordingly. */
+/* BINDTOOL_GEN_AUTOMATIC(0) */
+/* BINDTOOL_USE_PYGCCXML(0) */
+/* BINDTOOL_HEADER_FILE(buffer_reader.h) */
+/* BINDTOOL_HEADER_FILE_HASH(451fcbd61f40b7d17a151474869aad75) */
+/***********************************************************************************/
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/block.h>
+#include <gnuradio/buffer_reader.h>
+// pydoc.h is automatically generated in the build directory
+#include <buffer_pydoc.h>
+
+void bind_buffer_reader(py::module& m)
+{
+
+ using buffer_reader = ::gr::buffer_reader;
+
+ py::class_<buffer_reader, std::shared_ptr<buffer_reader>>(
+ m, "buffer_reader", D(buffer_reader))
+
+ .def(py::init<gr::buffer_reader const&>(),
+ py::arg("arg0"),
+ D(buffer_reader, buffer_reader))
+
+
+ .def("declare_sample_delay",
+ &buffer_reader::declare_sample_delay,
+ py::arg("delay"),
+ D(buffer_reader, declare_sample_delay))
+
+
+ .def("sample_delay", &buffer_reader::sample_delay, D(buffer_reader, sample_delay))
+
+
+ .def("items_available",
+ &buffer_reader::items_available,
+ D(buffer_reader, items_available))
+
+
+ .def("buffer", &buffer_reader::buffer, D(buffer_reader, buffer))
+
+
+ .def("max_possible_items_available",
+ &buffer_reader::max_possible_items_available,
+ D(buffer_reader, max_possible_items_available))
+
+
+ .def("read_pointer", &buffer_reader::read_pointer, D(buffer_reader, read_pointer))
+
+
+ .def("update_read_pointer",
+ &buffer_reader::update_read_pointer,
+ py::arg("nitems"),
+ D(buffer_reader, update_read_pointer))
+
+
+ .def("set_done",
+ &buffer_reader::set_done,
+ py::arg("done"),
+ D(buffer_reader, set_done))
+
+
+ .def("done", &buffer_reader::done, D(buffer_reader, done))
+
+
+ .def("mutex", &buffer_reader::mutex, D(buffer_reader, mutex))
+
+
+ .def("nitems_read", &buffer_reader::nitems_read, D(buffer_reader, nitems_read))
+
+
+ .def("reset_nitem_counter",
+ &buffer_reader::reset_nitem_counter,
+ D(buffer_reader, reset_nitem_counter))
+
+
+ .def("get_sizeof_item",
+ &buffer_reader::get_sizeof_item,
+ D(buffer_reader, get_sizeof_item))
+
+
+ .def("link", &buffer_reader::link, D(buffer_reader, link))
+
+
+ .def("get_tags_in_range",
+ &buffer_reader::get_tags_in_range,
+ py::arg("v"),
+ py::arg("abs_start"),
+ py::arg("abs_end"),
+ py::arg("id"),
+ D(buffer_reader, get_tags_in_range))
+
+ ;
+
+
+ m.def("buffer_add_reader",
+ &::gr::buffer_add_reader,
+ py::arg("buf"),
+ py::arg("nzero_preload"),
+ py::arg("link") = gr::block_sptr(),
+ py::arg("delay") = 0,
+ D(buffer_add_reader));
+
+
+ m.def("buffer_reader_ncurrently_allocated",
+ &::gr::buffer_reader_ncurrently_allocated,
+ D(buffer_reader_ncurrently_allocated));
+}
diff --git a/gnuradio-runtime/python/gnuradio/gr/bindings/logger_python.cc b/gnuradio-runtime/python/gnuradio/gr/bindings/logger_python.cc
index 8ec43201fb..cccc60fe30 100644
--- a/gnuradio-runtime/python/gnuradio/gr/bindings/logger_python.cc
+++ b/gnuradio-runtime/python/gnuradio/gr/bindings/logger_python.cc
@@ -13,8 +13,8 @@
/* If manual edits are made, the following tags should be modified accordingly. */
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
-/* BINDTOOL_HEADER_FILE(logger.h) */
-/* BINDTOOL_HEADER_FILE_HASH(eaf28bcaeb7c34dc0fca3fdd4a9860c0) */
+/* BINDTOOL_HEADER_FILE(logger.h) */
+/* BINDTOOL_HEADER_FILE_HASH(6d4f118d476b888f79737f835ed27a4d) */
/***********************************************************************************/
#include <pybind11/complex.h>
diff --git a/gnuradio-runtime/python/gnuradio/gr_unittest.py b/gnuradio-runtime/python/gnuradio/gr_unittest.py
index 6177f0f32f..ebd47019a5 100644
--- a/gnuradio-runtime/python/gnuradio/gr_unittest.py
+++ b/gnuradio-runtime/python/gnuradio/gr_unittest.py
@@ -110,6 +110,25 @@ class TestCase(unittest.TestCase):
self.assertComplexAlmostEqual2(x, y, abs_eps, rel_eps, msg)
for (x, y) in zip(a, b)
])
+
+
+ def assertSequenceEqualGR(self, data_in, data_out):
+ """
+ Note this function exists because of this bug: https://bugs.python.org/issue19217
+ Calling self.assertEqual(seqA, seqB) can hang if seqA and seqB are not equal.
+ """
+ if len(data_in) != len(data_out):
+ print('Lengths do not match: {:d} -- {:d}'.format(len(data_in), len(data_out)))
+ self.assertTrue(len(data_in) == len(data_out))
+ total_miscompares = 0
+ for idx, item in enumerate(zip(data_in, data_out)):
+ if item[0] != item[1]:
+ total_miscompares += 1
+ print('Miscompare at: {:d} ({:d} -- {:d})'.format(idx, item[0], item[1]))
+ if total_miscompares > 0:
+ print('Total miscompares: {:d}'.format(total_miscompares))
+ self.assertTrue(total_miscompares == 0)
+
def waitFor(
self,