Nicolas,

The GNU Radio scheduler hands your block a certain number of samples
everytime the blocks work function is called. The work function gets called
many times over the course of a running flowgraph. To be technically
correct, the scheduler tells your block how much memory it has to store
output (noutput_items) and makes sure you have enough input to produce an
output, which it learned from the forecast() function. In your case, you're
seeing the scheduler give 4096 samples to the block in a call to work. This
doesn't mean you are stuck using only 4096 samples, it just means you have
to write your code so that it collects what it needs over the course of
several calls to work and then computes an output. I know this is hard to
understand for beginners, but it's central to how GNU Radio works, so worth
absorbing.

set_output_multiple() gives you a little more control on what noutput_items
will be. For example, set_output_multiple(100000) tells the scheduler that
it shouldn't call your work function unless it can provide 100,000
noutput_items or more. That means it could be 200,000, 300,000, N*100,000
where N is a positive integer. If you overuse this, you might hurt
performance of your flowgraph, because you're placing additional
constraints on the scheduler. I try to avoid it unless I find I really need
it. I almost never need it.

Hope that helps,
Rich

On Thu, Sep 10, 2015 at 9:37 AM, Martin Braun <martin.br...@ettus.com>
wrote:

> On 10.09.2015 07:25, Nicolas Cuervo Benavides wrote:
> > 1. Where does the 4096 comes from? it is 2¹², which I don't recall being
> > 12 the size of one datatype that is involved in my function. It is
> > directly a value from scheduler and always the same?
>
> This value is pretty much random; 4096 works well with pages, but it
> could be any other value. noutput_items is how much valid items you have
> in your buffer. On the *first run*, all other values will be zero (but
> after that, they may contain old samples).
>
> > 2. If it is not always the same value, how I am indirectly fixing that
> > amount of samples? I would like, if possible, to save more samples as it
> > would reduce the variance of the calculations.
>
> You need to construct your block to handle *any* number of samples,
> unless you constrain it e.g. with set_output_multiple(). Your variance
> can be calculated over several work() calls, until you've read enough
> samples.
>
> Your code may have some other issues, but it's hard to say without
> seeing the rest of the work function.
>
> M
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to