summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJosh Blum2012-10-04 21:15:11 -0700
committerJosh Blum2012-10-04 21:15:11 -0700
commit709f8e97cc642e446d357612a6d6512d5a4c5330 (patch)
tree203a53e63fca96fe9e9a72d3fe386102d817b8d2 /lib
parent3600e927bf31ca46bb99ef2df83512112fa6a8b2 (diff)
downloadsandhi-709f8e97cc642e446d357612a6d6512d5a4c5330.tar.gz
sandhi-709f8e97cc642e446d357612a6d6512d5a4c5330.tar.bz2
sandhi-709f8e97cc642e446d357612a6d6512d5a4c5330.zip
implementation for the top block global config
Diffstat (limited to 'lib')
-rw-r--r--lib/block.cpp1
-rw-r--r--lib/block_allocator.cpp5
-rw-r--r--lib/block_handlers.cpp13
-rw-r--r--lib/element_impl.hpp1
-rw-r--r--lib/gras_impl/block_actor.hpp6
-rw-r--r--lib/gras_impl/debug.hpp2
-rw-r--r--lib/gras_impl/messages.hpp5
-rw-r--r--lib/register_messages.cpp3
-rw-r--r--lib/top_block.cpp14
9 files changed, 32 insertions, 18 deletions
diff --git a/lib/block.cpp b/lib/block.cpp
index d6f6e2b..84ae09e 100644
--- a/lib/block.cpp
+++ b/lib/block.cpp
@@ -46,7 +46,6 @@ Block::Block(const std::string &name):
(*this)->block->topology_init = false;
(*this)->block->forecast_fail = false;
(*this)->block->block_ptr = this;
- (*this)->block->hint = 0;
(*this)->block->block_state = BlockActor::BLOCK_STATE_INIT;
//call block methods to init stuff
diff --git a/lib/block_allocator.cpp b/lib/block_allocator.cpp
index 2161eb9..9b70824 100644
--- a/lib/block_allocator.cpp
+++ b/lib/block_allocator.cpp
@@ -89,12 +89,9 @@ void BlockActor::handle_top_alloc(const TopAllocMessage &, const Theron::Address
this->output_buffer_tokens.resize(num_outputs);
for (size_t i = 0; i < num_outputs; i++)
{
- size_t hint_items = this->hint;
- if (hint_items == 0) hint_items = AT_LEAST_DEFAULT_ITEMS;
-
const size_t bytes = recommend_length(
this->output_allocation_hints[i],
- hint_items*this->output_items_sizes[i],
+ AT_LEAST_DEFAULT_ITEMS*this->output_items_sizes[i],
this->output_configs[i].reserve_items*this->output_items_sizes[i],
this->output_configs[i].maximum_items*this->output_items_sizes[i]
);
diff --git a/lib/block_handlers.cpp b/lib/block_handlers.cpp
index 2e71ac1..1366e68 100644
--- a/lib/block_handlers.cpp
+++ b/lib/block_handlers.cpp
@@ -108,13 +108,20 @@ void BlockActor::handle_top_token(
this->Send(0, from); //ACK
}
-void BlockActor::handle_top_hint(
- const TopHintMessage &message,
+void BlockActor::handle_top_config(
+ const GlobalBlockConfig &message,
const Theron::Address from
){
MESSAGE_TRACER();
- this->hint = message.hint;
+ //overwrite with global config only if maxium_items is not set (zero)
+ for (size_t i = 0; i < this->output_configs.size(); i++)
+ {
+ if (this->output_configs[i].maximum_items == 0)
+ {
+ this->output_configs[i].maximum_items = message.maximum_output_items;
+ }
+ }
this->Send(0, from); //ACK
}
diff --git a/lib/element_impl.hpp b/lib/element_impl.hpp
index 90c4fe2..95f4f3a 100644
--- a/lib/element_impl.hpp
+++ b/lib/element_impl.hpp
@@ -45,6 +45,7 @@ struct ElementImpl
//top block stuff
SharedThreadGroup thread_group;
Token token;
+ GlobalBlockConfig top_config;
//things may be in this element
boost::shared_ptr<Apology::Topology> topology;
diff --git a/lib/gras_impl/block_actor.hpp b/lib/gras_impl/block_actor.hpp
index bbe6d6c..023011d 100644
--- a/lib/gras_impl/block_actor.hpp
+++ b/lib/gras_impl/block_actor.hpp
@@ -21,6 +21,7 @@
#include <gras_impl/bitset.hpp>
#include <gnuradio/gras.hpp>
#include <gnuradio/block.hpp>
+#include <gnuradio/top_block.hpp>
#include <Apology/Worker.hpp>
#include <gras_impl/token.hpp>
#include <gras_impl/messages.hpp>
@@ -59,7 +60,7 @@ struct BlockActor : Apology::Worker
this->RegisterHandler(this, &BlockActor::handle_top_active);
this->RegisterHandler(this, &BlockActor::handle_top_inert);
this->RegisterHandler(this, &BlockActor::handle_top_token);
- this->RegisterHandler(this, &BlockActor::handle_top_hint);
+ this->RegisterHandler(this, &BlockActor::handle_top_config);
this->RegisterHandler(this, &BlockActor::handle_top_thread_group);
this->RegisterHandler(this, &BlockActor::handle_input_tag);
@@ -85,7 +86,7 @@ struct BlockActor : Apology::Worker
void handle_top_active(const TopActiveMessage &, const Theron::Address);
void handle_top_inert(const TopInertMessage &, const Theron::Address);
void handle_top_token(const TopTokenMessage &, const Theron::Address);
- void handle_top_hint(const TopHintMessage &, const Theron::Address);
+ void handle_top_config(const GlobalBlockConfig &, const Theron::Address);
void handle_top_thread_group(const SharedThreadGroup &, const Theron::Address);
void handle_input_tag(const InputTagMessage &, const Theron::Address);
@@ -180,7 +181,6 @@ struct BlockActor : Apology::Worker
BLOCK_STATE_LIVE,
BLOCK_STATE_DONE,
} block_state;
- size_t hint; //some kind of allocation hint
Affinity buffer_affinity;
std::vector<std::vector<OutputHintMessage> > output_allocation_hints;
diff --git a/lib/gras_impl/debug.hpp b/lib/gras_impl/debug.hpp
index 03ad30f..2fae424 100644
--- a/lib/gras_impl/debug.hpp
+++ b/lib/gras_impl/debug.hpp
@@ -37,7 +37,7 @@ extern void *operator new(std::size_t n) throw (std::bad_alloc);
//-- define to enable these debugs:
//----------------------------------------------------------------------
//#define WORK_DEBUG
-//#define ASSERTING
+#define ASSERTING
//#define MESSAGE_TRACING
//----------------------------------------------------------------------
diff --git a/lib/gras_impl/messages.hpp b/lib/gras_impl/messages.hpp
index 81c66b7..ef87398 100644
--- a/lib/gras_impl/messages.hpp
+++ b/lib/gras_impl/messages.hpp
@@ -50,11 +50,6 @@ struct TopTokenMessage
Token token;
};
-struct TopHintMessage
-{
- size_t hint;
-};
-
//----------------------------------------------------------------------
//-- message to an input port
//-- do not ack
diff --git a/lib/register_messages.cpp b/lib/register_messages.cpp
index 18a3cd8..7c894fa 100644
--- a/lib/register_messages.cpp
+++ b/lib/register_messages.cpp
@@ -15,6 +15,7 @@
// along with io_sig program. If not, see <http://www.gnu.org/licenses/>.
#include <Theron/Register.h>
+#include <gnuradio/top_block.hpp>
#include <gras_impl/messages.hpp>
#include <gras_impl/interruptible_thread.hpp>
#include <Apology/Worker.hpp>
@@ -24,7 +25,7 @@ THERON_REGISTER_MESSAGE(gnuradio::TopAllocMessage);
THERON_REGISTER_MESSAGE(gnuradio::TopActiveMessage);
THERON_REGISTER_MESSAGE(gnuradio::TopInertMessage);
THERON_REGISTER_MESSAGE(gnuradio::TopTokenMessage);
-THERON_REGISTER_MESSAGE(gnuradio::TopHintMessage);
+THERON_REGISTER_MESSAGE(gnuradio::GlobalBlockConfig);
THERON_REGISTER_MESSAGE(gnuradio::SharedThreadGroup);
THERON_REGISTER_MESSAGE(gnuradio::InputTagMessage);
diff --git a/lib/top_block.cpp b/lib/top_block.cpp
index c93bda5..4973b59 100644
--- a/lib/top_block.cpp
+++ b/lib/top_block.cpp
@@ -53,6 +53,16 @@ void ElementImpl::top_block_cleanup(void)
<< std::flush;
}
+GlobalBlockConfig TopBlock::global_config(void) const
+{
+ return (*this)->top_config;
+}
+
+void TopBlock::set_global_config(const GlobalBlockConfig &config)
+{
+ (*this)->top_config = config;
+}
+
void TopBlock::commit(void)
{
this->start(); //ok to re-start, means update
@@ -70,6 +80,10 @@ void TopBlock::start(void)
(*this)->executor->post_all(message);
}
{
+ //send the global block config before alloc
+ (*this)->executor->post_all((*this)->top_config);
+ }
+ {
(*this)->executor->post_all(TopAllocMessage());
}
{