summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-core/src/python/gnuradio/gr/qa_affinity.py49
-rw-r--r--gnuradio-runtime/include/gr_block.h8
-rw-r--r--gnuradio-runtime/include/gr_block_detail.h4
-rw-r--r--gnuradio-runtime/lib/gr_block.cc2
-rw-r--r--gnuradio-runtime/lib/gr_block_detail.cc2
-rw-r--r--gnuradio-runtime/swig/gr_block.i4
-rw-r--r--gr-blocks/lib/qa_gr_top_block.cc2
-rw-r--r--gruel/src/include/gruel/thread.h6
-rw-r--r--gruel/src/lib/thread.cc40
9 files changed, 83 insertions, 34 deletions
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_affinity.py b/gnuradio-core/src/python/gnuradio/gr/qa_affinity.py
new file mode 100644
index 0000000000..7b3ca6ed63
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_affinity.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest
+
+class test_affinity(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_000(self):
+ # Just run some data through and make sure it doesn't puke.
+ src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+
+ src = gr.vector_source_f(src_data)
+ snk = gr.vector_sink_f()
+
+ src.set_processor_affinity([0,])
+ self.tb.connect(src, snk)
+ self.tb.run()
+
+ a = src.processor_affinity()
+
+ self.assertEqual((0,), a)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_affinity, "test_affinity.xml")
diff --git a/gnuradio-runtime/include/gr_block.h b/gnuradio-runtime/include/gr_block.h
index 0b7bbf3eda..a25bb4a528 100644
--- a/gnuradio-runtime/include/gr_block.h
+++ b/gnuradio-runtime/include/gr_block.h
@@ -513,9 +513,9 @@ class GR_RUNTIME_API gr_block : public gr_basic_block {
/*!
* \brief Set the thread's affinity to processor core \p n.
*
- * \param mask a vector of unsigned ints of the core numbers available to this block.
+ * \param mask a vector of ints of the core numbers available to this block.
*/
- void set_processor_affinity(const std::vector<unsigned int> &mask);
+ void set_processor_affinity(const std::vector<int> &mask);
/*!
* \brief Remove processor affinity to a specific core.
@@ -525,7 +525,7 @@ class GR_RUNTIME_API gr_block : public gr_basic_block {
/*!
* \brief Get the current processor affinity.
*/
- std::vector<unsigned int> processor_affinity() { return d_affinity; }
+ std::vector<int> processor_affinity() { return d_affinity; }
// ----------------------------------------------------------------------------
@@ -543,7 +543,7 @@ class GR_RUNTIME_API gr_block : public gr_basic_block {
int d_max_noutput_items; // value of max_noutput_items for this block
int d_min_noutput_items;
tag_propagation_policy_t d_tag_propagation_policy; // policy for moving tags downstream
- std::vector<unsigned int> d_affinity; // thread affinity proc. mask
+ std::vector<int> d_affinity; // thread affinity proc. mask
bool d_pc_rpc_set;
protected:
diff --git a/gnuradio-runtime/include/gr_block_detail.h b/gnuradio-runtime/include/gr_block_detail.h
index c197266769..d24148f951 100644
--- a/gnuradio-runtime/include/gr_block_detail.h
+++ b/gnuradio-runtime/include/gr_block_detail.h
@@ -159,9 +159,9 @@ class GR_RUNTIME_API gr_block_detail {
/*!
* \brief Set core affinity of block to the cores in the vector mask.
*
- * \param mask a vector of unsigned ints of the core numbers available to this block.
+ * \param mask a vector of ints of the core numbers available to this block.
*/
- void set_processor_affinity(const std::vector<unsigned int> &mask);
+ void set_processor_affinity(const std::vector<int> &mask);
/*!
* \brief Unset core affinity.
diff --git a/gnuradio-runtime/lib/gr_block.cc b/gnuradio-runtime/lib/gr_block.cc
index 8c8b85dc7e..2830a999ea 100644
--- a/gnuradio-runtime/lib/gr_block.cc
+++ b/gnuradio-runtime/lib/gr_block.cc
@@ -301,7 +301,7 @@ gr_block::is_set_max_noutput_items()
}
void
-gr_block::set_processor_affinity(const std::vector<unsigned int> &mask)
+gr_block::set_processor_affinity(const std::vector<int> &mask)
{
d_affinity = mask;
if(d_detail) {
diff --git a/gnuradio-runtime/lib/gr_block_detail.cc b/gnuradio-runtime/lib/gr_block_detail.cc
index c85c0e9fba..af767da8ec 100644
--- a/gnuradio-runtime/lib/gr_block_detail.cc
+++ b/gnuradio-runtime/lib/gr_block_detail.cc
@@ -218,7 +218,7 @@ gr_block_detail::get_tags_in_range(std::vector<gr_tag_t> &v,
}
void
-gr_block_detail::set_processor_affinity(const std::vector<unsigned int> &mask)
+gr_block_detail::set_processor_affinity(const std::vector<int> &mask)
{
if(threaded) {
try {
diff --git a/gnuradio-runtime/swig/gr_block.i b/gnuradio-runtime/swig/gr_block.i
index a80f64d027..a53489f9a2 100644
--- a/gnuradio-runtime/swig/gr_block.i
+++ b/gnuradio-runtime/swig/gr_block.i
@@ -83,9 +83,9 @@ class gr_block : public gr_basic_block {
float pc_work_time_var();
// Methods to manage processor affinity.
- void set_processor_affinity(const gr_vector_uint &mask);
+ void set_processor_affinity(const std::vector<int> &mask);
void unset_processor_affinity();
- gr_vector_uint processor_affinity();
+ std::vector<int> processor_affinity();
// internal use
gr_block_detail_sptr detail () const { return d_detail; }
diff --git a/gr-blocks/lib/qa_gr_top_block.cc b/gr-blocks/lib/qa_gr_top_block.cc
index 9833ed7f8b..cb75cd14d0 100644
--- a/gr-blocks/lib/qa_gr_top_block.cc
+++ b/gr-blocks/lib/qa_gr_top_block.cc
@@ -269,7 +269,7 @@ void qa_gr_top_block::t11_set_block_affinity()
gr_block_sptr src (gr::blocks::null_source::make(sizeof(float)));
gr_block_sptr snk (gr::blocks::null_sink::make(sizeof(float)));
- std::vector<unsigned int> set(1, 0), ret;
+ std::vector<int> set(1, 0), ret;
src->set_processor_affinity(set);
tb->connect(src, 0, snk, 0);
diff --git a/gruel/src/include/gruel/thread.h b/gruel/src/include/gruel/thread.h
index 60832675cd..10c6c38ccc 100644
--- a/gruel/src/include/gruel/thread.h
+++ b/gruel/src/include/gruel/thread.h
@@ -75,7 +75,7 @@ namespace gruel {
* support in this way since 10.5 is not what we want or can use in
* this fashion).
*/
- GRUEL_API void thread_bind_to_processor(const std::vector<unsigned int> &mask);
+ GRUEL_API void thread_bind_to_processor(const std::vector<int> &mask);
/*! \brief Convineince function to bind the current thread to a single core.
*
@@ -87,7 +87,7 @@ namespace gruel {
* support in this way since 10.5 is not what we want or can use in
* this fashion).
*/
- GRUEL_API void thread_bind_to_processor(unsigned int n);
+ GRUEL_API void thread_bind_to_processor(int n);
/*! \brief Bind a thread to a set of cores.
*
@@ -101,7 +101,7 @@ namespace gruel {
* support in this way since 10.5 is not what we want or can use in
* this fashion).
*/
- GRUEL_API void thread_bind_to_processor(gr_thread_t thread, const std::vector<unsigned int> &mask);
+ GRUEL_API void thread_bind_to_processor(gr_thread_t thread, const std::vector<int> &mask);
/*! \brief Convineince function to bind the a thread to a single core.
diff --git a/gruel/src/lib/thread.cc b/gruel/src/lib/thread.cc
index 8ebe822fbf..a5116b687b 100644
--- a/gruel/src/lib/thread.cc
+++ b/gruel/src/lib/thread.cc
@@ -38,33 +38,33 @@ namespace gruel {
}
void
- thread_bind_to_processor(unsigned int n)
+ thread_bind_to_processor(int n)
{
- std::vector<unsigned int> mask(1, n);
+ std::vector<int> mask(1, n);
thread_bind_to_processor(get_current_thread_id(), mask);
}
void
- thread_bind_to_processor(const std::vector<unsigned int> &mask)
+ thread_bind_to_processor(const std::vector<int> &mask)
{
thread_bind_to_processor(get_current_thread_id(), mask);
}
void
- thread_bind_to_processor(gr_thread_t thread, unsigned int n)
+ thread_bind_to_processor(gr_thread_t thread, int n)
{
- std::vector<unsigned int> mask(1, n);
+ std::vector<int> mask(1, n);
thread_bind_to_processor(thread, mask);
}
void
- thread_bind_to_processor(gr_thread_t thread, const std::vector<unsigned int> &mask)
+ thread_bind_to_processor(gr_thread_t thread, const std::vector<int> &mask)
{
//DWORD_PTR mask = (1 << n);
DWORD_PTR dword_mask = 0;
- std::vector<unsigned int> _mask = mask;
- std::vector<unsigned int>::iterator itr;
+ std::vector<int> _mask = mask;
+ std::vector<int>::iterator itr;
for(itr = _mask.begin(); itr != _mask.end(); itr++)
dword_mask |= (1 << (*itr));
@@ -106,25 +106,25 @@ namespace gruel {
}
void
- thread_bind_to_processor(unsigned int n)
+ thread_bind_to_processor(int n)
{
// Not implemented on OSX
}
void
- thread_bind_to_processor(gr_thread_t thread, unsigned int n)
+ thread_bind_to_processor(gr_thread_t thread, int n)
{
// Not implemented on OSX
}
void
- thread_bind_to_processor(const std::vector<unsigned int> &mask)
+ thread_bind_to_processor(const std::vector<int> &mask)
{
// Not implemented on OSX
}
void
- thread_bind_to_processor(gr_thread_t thread, const std::vector<unsigned int> &mask)
+ thread_bind_to_processor(gr_thread_t thread, const std::vector<int> &mask)
{
// Not implemented on OSX
}
@@ -157,32 +157,32 @@ namespace gruel {
}
void
- thread_bind_to_processor(unsigned int n)
+ thread_bind_to_processor(int n)
{
- std::vector<unsigned int> mask(1, n);
+ std::vector<int> mask(1, n);
thread_bind_to_processor(get_current_thread_id(), mask);
}
void
- thread_bind_to_processor(const std::vector<unsigned int> &mask)
+ thread_bind_to_processor(const std::vector<int> &mask)
{
thread_bind_to_processor(get_current_thread_id(), mask);
}
void
- thread_bind_to_processor(gr_thread_t thread, unsigned int n)
+ thread_bind_to_processor(gr_thread_t thread, int n)
{
- std::vector<unsigned int> mask(1, n);
+ std::vector<int> mask(1, n);
thread_bind_to_processor(thread, mask);
}
void
- thread_bind_to_processor(gr_thread_t thread, const std::vector<unsigned int> &mask)
+ thread_bind_to_processor(gr_thread_t thread, const std::vector<int> &mask)
{
cpu_set_t set;
size_t len = sizeof(cpu_set_t);
- std::vector<unsigned int> _mask = mask;
- std::vector<unsigned int>::iterator itr;
+ std::vector<int> _mask = mask;
+ std::vector<int>::iterator itr;
CPU_ZERO(&set);
for(itr = _mask.begin(); itr != _mask.end(); itr++)