[Top][All Lists]

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

[Discuss-gnuradio] multi thread fft execution

From: Mostafa Alizadeh
Subject: [Discuss-gnuradio] multi thread fft execution
Date: Sat, 25 Oct 2014 13:33:35 +0330

Hi all, 
I have the following c++ code which gets fft by sliding on sample by sample fo the input. 

     * The private constructor
    sliding_fft_impl::sliding_fft_impl(uint fft_size)
      : gr::sync_block("sliding_fft",
              gr::io_signature::make(1, 1, sizeof(gr_complex)),
              gr::io_signature::make(1, 1, fft_size * sizeof(gr_complex))),
        d_fft = new fft::fft_complex (d_fft_size, 1, 2);

        delete d_fft;

    sliding_fft_impl::work(int noutput_items,
			  gr_vector_const_void_star &input_items,
			  gr_vector_void_star &output_items)
        const gr_complex *in = (const gr_complex *) input_items[0];
        gr_complex *out = (gr_complex *) output_items[0];

        memcpy(d_fft->get_inbuf(), in, d_fft_size * sizeof(gr_complex));
        memcpy(out, d_fft->get_outbuf(), d_fft_size * sizeof(gr_complex));

        //delete d_fft;
        return 1;

If I run the fft execution on 2 threads, or more, is there any "race" problem between these 2 threads and the work one? Inj another words, is it possible that this work being called before finishing the fft execution?

If it is so, there will be a race problem because "work" wants to write on d_fft->get_inbuf() while fft execution wants to read from it! 

please help me with this code. I don't know why at the runtime, the data I give at the output aren't desired after a while!!


reply via email to

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