[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r3996 - gnuradio/branches/developers/jcorgan/hier/gnur
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r3996 - gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime |
Date: |
Thu, 16 Nov 2006 17:20:31 -0700 (MST) |
Author: jcorgan
Date: 2006-11-16 17:20:30 -0700 (Thu, 16 Nov 2006)
New Revision: 3996
Modified:
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.cc
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.h
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc
Log:
Work in progress.
Modified:
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
2006-11-16 23:13:31 UTC (rev 3995)
+++
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2.cc
2006-11-17 00:20:30 UTC (rev 3996)
@@ -29,6 +29,8 @@
#include <gr_io_signature.h>
#include <iostream>
+#define GR_HIER_BLOCK2_DEBUG 1
+
gr_hier_block2_sptr gr_make_hier_block2(const std::string &name,
gr_io_signature_sptr input_signature,
gr_io_signature_sptr output_signature)
@@ -120,6 +122,8 @@
void
gr_hier_block2::connect_children()
{
+ if (GR_HIER_BLOCK2_DEBUG)
+ std::cout << "Wiring up children for block " << name() << std::endl;
d_impl->connect_children();
}
Modified:
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.cc
2006-11-16 23:13:31 UTC (rev 3995)
+++
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.cc
2006-11-17 00:20:30 UTC (rev 3996)
@@ -27,7 +27,10 @@
#define GR_HIER_BLOCK2_IMPL_DEBUG 1
#include <gr_hier_block2_impl.h>
+#include <gr_block.h>
#include <gr_io_signature.h>
+#include <gr_block_detail.h>
+#include <gr_buffer.h>
#include <iostream>
gr_hier_block2_impl::gr_hier_block2_impl()
@@ -280,6 +283,46 @@
void
gr_hier_block2_impl::connect_children()
{
+ // Only process actually connected blocks
+ gr_basic_block_vector_t blocks = get_connected_blocks();
+ for (gr_basic_block_viter_t p = blocks.begin();
+ p != blocks.end(); p++) {
+
+ // Only work on actual gr_blocks (leaf nodes)
+ if ((*p)->is_terminal_p()) {
+ int ninputs, noutputs;
+ get_child_topology(*p, &ninputs, &noutputs);
+
+ // Create block detail, allocate buffer, and assign
+ gr_block_detail_sptr detail = gr_make_block_detail(ninputs,
noutputs);
+ for (int i = 0; i < noutputs; i++)
+ detail->set_output(i, allocate_buffer(*p, i));
+ }
+ }
+}
+
+gr_buffer_sptr
+gr_hier_block2_impl::allocate_buffer(gr_basic_block_sptr block, int port)
+{
+ int item_size = block->output_signature()->sizeof_stream_item(port);
+ int nitems = s_fixed_buffer_size/item_size;
+
+ // If any downstream blocks are decimators or have a large output_multiple,
+ // ensure we have a buffer at least twice their decimation
factor*output_multiple
+ std::vector<gr_block_sptr> blocks;
+ // blocks = calc_downstream_blocks(block, port);
+ for (std::vector<gr_block_sptr>::iterator p = blocks.begin();
+ p != blocks.end(); p++) {
+
+ int decimation = (int)(1.0/(*p)->relative_rate());
+ int multiple = (*p)->output_multiple();
+ int history = (*p)->history();
+ nitems = std::max(nitems, 2*(decimation*multiple+history));
+ }
+
if (GR_HIER_BLOCK2_IMPL_DEBUG)
- std::cout << "gr_hier_block2_impl:connect_children()" << std::endl;
+ std::cout << "Allocating output buffer of " << nitems
+ << " items, each of size " << item_size << std::endl;
+
+ return gr_make_buffer(nitems, item_size);
}
Modified:
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.h
===================================================================
---
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.h
2006-11-16 23:13:31 UTC (rev 3995)
+++
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_hier_block2_impl.h
2006-11-17 00:20:30 UTC (rev 3996)
@@ -76,6 +76,8 @@
typedef std::vector<gr_connection> gr_connection_vector_t;
typedef std::vector<gr_connection>::iterator gr_connection_viter_t;
+#define GR_FIXED_BUFFER_SIZE (32*(1L<<10))
+
class gr_hier_block2_impl : boost::noncopyable
{
private:
@@ -84,7 +86,8 @@
std::vector<gr_hier_component> d_components;
std::vector<gr_connection> d_connections;
-
+ static const int s_fixed_buffer_size = GR_FIXED_BUFFER_SIZE;
+
void define_component(const std::string &name, gr_basic_block_sptr
basic_block);
gr_basic_block_sptr get_block_by_name(const std::string &name);
std::string get_name_by_block(gr_basic_block_sptr basic_block);
@@ -100,7 +103,8 @@
gr_connection_vector_t calc_connections(const std::string &name, bool
check_inputs);
std::vector<int> calc_used_ports(const std::string &name, bool
check_inputs);
bool check_contiguity(gr_basic_block_sptr block, bool check_inputs);
-
+ gr_buffer_sptr allocate_buffer(gr_basic_block_sptr block, int port);
+
public:
~gr_hier_block2_impl();
};
Modified:
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc
===================================================================
---
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc
2006-11-16 23:13:31 UTC (rev 3995)
+++
gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime/gr_runtime_impl.cc
2006-11-17 00:20:30 UTC (rev 3996)
@@ -65,9 +65,6 @@
public:
virtual bool visit(gr_basic_block_sptr block)
{
- if (GR_RUNTIME_IMPL_DEBUG)
- std::cout << "Connecting block: " << block << std::endl;
-
block->connect_children();
return true; // failures are exceptions are this point
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r3996 - gnuradio/branches/developers/jcorgan/hier/gnuradio-core/src/lib/runtime,
jcorgan <=