[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] buffer allocation

From: Suvda Myagmar
Subject: Re: [Discuss-gnuradio] buffer allocation
Date: Wed, 12 Jan 2005 08:01:45 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040922

In gr_block.h it says,
"Although blocks may consume data on each input stream at a different rate, all outputs streams must produce data at the same rate. That rate may be different from any of the input rates."

I don't understand this comment. I thought a given block may have only one output stream and multiple input streams. However, a given buffer may have one writer and multiple readers, and the readers must read at the same rate, right?

-Suvda Myagmar

Eric Blossom wrote:
On Tue, Jan 11, 2005 at 03:01:32PM -0600, Suvda Myagmar wrote:

Couple of questions about how buffers are allocated and used w.r.t. flow graph. References to input, output buffers are passed to a signal processing block as pointers to arrays, right?


What are signatures of  input/output streams and what's their purpose?

Type-checking the number and types of the input and output streams.

How data stored in buffers are being consumed, in chunks or all at once?

Chunks.  E.g., there may be more data say in the input buffer, but it
won't be consumed at this momement because there isn't enough room in
the output buffer to hold the tranformed data.  A block's general_work
or work method is only called when all constraints are satisfied.  The
constraints include the output multiple, the amount of input
available, how much output room it takes to hold the output produced
from this input, etc. See http://www.gnu.org/software/gnuradio/doc/classgr__block.html

During flow graph build, buffer size gets computed and allocated. Can somebody explain what parameters the buffer size depend on?

Right now the buffer sizes fixed (mostly). This will probably change.
Here's the code that does the calculation (from

class buffer_sizes (object):
    """compute buffer sizes to use"""
    def __init__ (self, flow_graph):
        # We could scan the graph here and determine individual sizes
        # based on relative_rate, number of readers, etc.

        # The simplest thing that could possibly work: all buffers same size
        self.fixed_buffer_size = 32*1024

    def allocate (self, m, index):
        """allocate buffer for output index of block m"""
        item_size = m.output_signature().sizeof_stream_item (index)
        nitems = self.fixed_buffer_size / item_size
        if 1 + m.output_multiple () > nitems:
            nitems = 1 + m.output_multiple ()
return buffer (nitems, item_size)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]