summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.txt2
-rw-r--r--include/gnuradio/block.hpp16
-rw-r--r--include/gnuradio/gras.hpp15
-rw-r--r--include/gnuradio/sbuffer.hpp16
-rw-r--r--lib/block.cpp5
-rw-r--r--lib/block_allocator.cpp1
-rw-r--r--lib/block_task.cpp9
-rw-r--r--lib/element_impl.hpp1
-rw-r--r--swig/gras.i1
9 files changed, 46 insertions, 20 deletions
diff --git a/TODO.txt b/TODO.txt
index 2bdea83..132b2a0 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -14,12 +14,10 @@
* allocation
** hooks for advanced allocation
** override the default allocator (output token, recommended bytes)
-** set allocator affinity hook
* python wrapper for block will come from grextras
* bring in numanuma
** thread prio
** thread affinity
-** memory affinity
* track memcpys for block usage stats
* runtime history, input/output multiple change?
** resend the hint to the allocator and possibly re-allocate
diff --git a/include/gnuradio/block.hpp b/include/gnuradio/block.hpp
index 459e25b..abfb07e 100644
--- a/include/gnuradio/block.hpp
+++ b/include/gnuradio/block.hpp
@@ -18,6 +18,7 @@
#define INCLUDED_GNURADIO_BLOCK_HPP
#include <gnuradio/element.hpp>
+#include <gnuradio/sbuffer.hpp>
#include <gnuradio/tags.hpp>
#include <gruel/pmt.h>
#include <vector>
@@ -199,6 +200,21 @@ struct GRAS_API Block : Element
//! scheduler calls when the topology is updated, can be overloaded
virtual bool check_topology(int ninputs, int noutputs);
+ /*******************************************************************
+ * routines related to affinity and allocation
+ ******************************************************************/
+
+ /*!
+ * Set the node affinity of this block.
+ * This call affects how output buffers are allocated.
+ * By default memory is allocated by malloc.
+ * When the affinity is set, virtual memory
+ * will be locked to a physical CPU/memory node.
+ */
+ void set_buffer_affinity(const Affinity &affinity);
+
+ //TODO overload for allocate output buffer(index)
+
};
} //namespace gnuradio
diff --git a/include/gnuradio/gras.hpp b/include/gnuradio/gras.hpp
index 23aab4c..1e0087a 100644
--- a/include/gnuradio/gras.hpp
+++ b/include/gnuradio/gras.hpp
@@ -38,21 +38,6 @@ struct SBufferImpl;
void intrusive_ptr_add_ref(SBufferImpl*);
void intrusive_ptr_release(SBufferImpl*);
-struct Affinity
-{
- Affinity(void)
- {
- value = -1;
- }
-
- operator long long(void) const
- {
- return value;
- }
-
- long long value;
-};
-
} //namespace gnuradio
#endif /*INCLUDED_GNURADIO_GRAS_HPP*/
diff --git a/include/gnuradio/sbuffer.hpp b/include/gnuradio/sbuffer.hpp
index c0e13c8..71a588a 100644
--- a/include/gnuradio/sbuffer.hpp
+++ b/include/gnuradio/sbuffer.hpp
@@ -23,6 +23,22 @@
namespace gnuradio
{
+//! A small wrapper to represent a node affinity
+struct Affinity
+{
+ Affinity(void)
+ {
+ value = -1;
+ }
+
+ operator long long(void) const
+ {
+ return value;
+ }
+
+ long long value;
+};
+
//! The callback function type when buffers dereference
typedef boost::function<void(SBuffer &)> SBufferDeleter;
diff --git a/lib/block.cpp b/lib/block.cpp
index 406e16b..48b18f3 100644
--- a/lib/block.cpp
+++ b/lib/block.cpp
@@ -240,3 +240,8 @@ bool Block::check_topology(int, int)
{
return true;
}
+
+void Block::set_buffer_affinity(const Affinity &affinity)
+{
+ (*this)->buffer_affinity = affinity;
+}
diff --git a/lib/block_allocator.cpp b/lib/block_allocator.cpp
index 5e24a00..708b35b 100644
--- a/lib/block_allocator.cpp
+++ b/lib/block_allocator.cpp
@@ -93,6 +93,7 @@ void ElementImpl::handle_allocation(const tsbe::TaskInterface &task_iface)
SBufferConfig config;
config.memory = NULL;
config.length = bytes;
+ config.affinity = this->buffer_affinity;
config.token = this->output_buffer_tokens[i];
SBuffer buff(config);
//buffer derefs here and the token messages it back to the block
diff --git a/lib/block_task.cpp b/lib/block_task.cpp
index a9b88bd..cddfb97 100644
--- a/lib/block_task.cpp
+++ b/lib/block_task.cpp
@@ -130,10 +130,13 @@ void ElementImpl::handle_task(const tsbe::TaskInterface &task_iface)
this->consume_called[i] = false;
//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)
- {
+ if (
+ potential_inline and
+ input_inline_enables[i] and
+ output_inline_index < num_outputs and
+ buff.get_affinity() == this->buffer_affinity
+ ){
//copy buffer reference but push with zero length, same offset
SBuffer new_obuff = buff;
new_obuff.length = 0;
diff --git a/lib/element_impl.hpp b/lib/element_impl.hpp
index 0ec4650..18edfce 100644
--- a/lib/element_impl.hpp
+++ b/lib/element_impl.hpp
@@ -150,6 +150,7 @@ struct ElementImpl
} block_state;
Token token;
size_t hint; //some kind of allocation hint
+ Affinity buffer_affinity;
std::vector<std::vector<BufferHintMessage> > output_allocation_hints;
diff --git a/swig/gras.i b/swig/gras.i
index 6df63e8..fc1447b 100644
--- a/swig/gras.i
+++ b/swig/gras.i
@@ -31,6 +31,7 @@
%ignore gnuradio::IOSignature::operator->();
%ignore gnuradio::IOSignature::operator->() const;
+%include <gnuradio/sbuffer.hpp>
%include <gnuradio/element.hpp>
%include <gnuradio/tags.hpp>
%include <gnuradio/block.hpp>