[Top][All Lists]

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

Re: [Discuss-gnuradio] Problem with large number of inputs.

From: Marcus Müller
Subject: Re: [Discuss-gnuradio] Problem with large number of inputs.
Date: Sun, 27 Jul 2014 19:40:17 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

As I said, you should use the gdb debugging approach to find the mistake.
gr_complex **in = (gr_complex) input_items; shouldn't compile, because
the types are incompatible.

I can't help you any further with the information you're offering.
Please share at least your complete general_work method, and the methods
that you use to calculate the input numbers. I stand by my opininion
that beauty lies in simplicity. If you want to make sure you don't do
more "for" iterations than you have inputs, iterate over the number of
inputs (input_items.size()) and not something you calculate yourself.
That's the simple approach of eliminating error sources.

Also, you're using a gr::block. If you play around with the forecast
method, you might trigger situations where you are asked to produce a
number of output items on different output streams, and have zero input
items on some input streams; I don't see you check for that in the code
excerpt you were sharing.
Again, it isn't very useful to share only a portion of your block,
especially when you are very sure yourself that this portion is correct,
if you want help identifying what goes wrong.

With best regards,
Marcus Müller

On 27.07.2014 19:21, Mostafa Alizadeh wrote:
> Thank you for your notes Marcus,
> As you said this is unnecessary process to point to the input_items in a
> for loop!!
> However, this is not the problem because I checked that I have the same
> number of iteration in the for loop as the number of input ports.
> The problem is somewhere else. *Again I must mention that if I use, only 8
> input ports, the code runs perfectly,* however, with 24 inputs, it does
> something wrong! (perhaps pointing to somewhere in the memory which is not
> allocated to the input as it seemed to allocated to the input!). In another
> words, when I want to access the first input of the first input port, I can
> write:
> gr_complex **in = (gr_complex) input_items;
> // for example
> cout << in[0][0] << endl;
> The program terminated with unexpected error!
> Please help me, where is the problem?? :(
> On Sun, Jul 27, 2014 at 4:21 AM, Marcus Müller <address@hidden>
> wrote:
>> Having your complete general_work function wouldn't have hurt my
>> understanding much...
>> I really can't make out what you're trying to do without doubt.
>> Anyway, from the code below I think "in" *must at least* have the same
>> number of entries that your for loop has iterations; did you just try using
>> d_group * N_FS(d_normal) instead of d_N_phich_group *
>> N_FS_phich(d_normal_cp) when allocating your array?
>> It seems to me that having two ways to determine how many inputs there is
>> a likely cause for mistake. Use the size() of the input_items to determine
>> how many inputs you really have, and assert(input_items.size() ==
>> number_of_inputs_like_I_calculate_it); to make sure things line up.
>> Also, the whole process seems unnecessary, since you do nothing more than
>> copying the pointers from input_items to in; the typecast is nothing but
>> syntactic magic and can be done by having "in = ((const gr_complex*)*)
>> input_items;"; also, I encourage you to use the C++-style explicit cast
>> operators (in this case, reinterpret_cast<>) for their clarity, but that's
>> more a question of personal liking :)
>> Greetings,
>> Marcus
>> On 26.07.2014 21:55, Mostafa Alizadeh wrote:
>>> Hi Marcus,
>>> You're right. I didn't clarify the problem.
>>> Actually in C++, I wrote:
>>> block_impl::block_impl(bool normal, int group)
>>>       : gr::block("phich_grouping",
>>>                   gr::io_signature::make(1, group * N_FS(normal), sizeof
>>> (gr_complex)),
>>>               gr::io_signature::make(1, 1, sizeof(gr_complex))),
>>> // N_FS function returns 8 or 4 depends on its input.
>>> // in the work function :
>>> // d_normal and d_group are defined in the .h file
>>> const gr_complex *in[d_N_phich_group * N_FS_phich(d_normal_cp)];
>>> for (int i=0; i<d_group * N_FS(d_normal); i++)
>>>         {
>>>             in[i] = (const gr_complex *) input_items[i];
>>> }
>>> when I set the "group" value to 3, the number of input ports would be 24.
>>> In this case, I want to access to one element of "in" like this:
>>> cout << " in " << in[0][0] << endl;
>>> I got the aforementioned error!
>>> But when I set "group = 1" which means 8 input ports, all things are
>> fine.
>>> any idea please,
>>> Best

reply via email to

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