Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8289925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:38:32+00:00 2026-06-08T12:38:32+00:00

I’m doing some tests with FFTW using threads, the time of 1d transform(forward and

  • 0

I’m doing some tests with FFTW using threads, the time of 1d transform(forward and backward) of large double complex values is always better for 1 thread than 2-3 or 4 threads. Can someone help me to solve this problem ? Thank you!!

An output for 1 thread is:

time           N
0.001515        16384   
0.003364        32768   
0.002625        65536   
0.006060        131072  
0.016190        262144  
0.042389        524288  
0.091719        1048576         
0.209468        2097152         
0.523317        4194304        
1.196903        8388608      

while for 4 threads (results is similar for 2 or 3 threads…) :

time            N
0.002071        16384   
0.004009        32768  
0.007989        65536   
0.008715        131072  
0.020615        262144  
0.055483        524288  
0.159392        1048576         
0.322355        2097152         
0.761479        4194304         
1.647288        8388608         

I test my code on two different machine with same results.
machine 1 :

Ubuntu 10.04.1 LTS
2.6.32-24-generic  x86_64 GNU/Linux
gcc version 4.4.3 
Intel(R) Core(TM)2 Quad CPU    Q9550  @ 2.83GHz
ram 4gb

machine 2 :

Ubuntu 10.04.1 LTS
2.6.32-21-server  x86_64 GNU/Linux
gcc version 4.4.3 
Intel(R) Core(TM) i7 CPU         860  @ 2.80GHz
ram 8gb

I have code that generate random complex values and make forward and backward transform and take time of this two operation without take into account the calls for plan or memory allocations.

FFTW is configurated as :

./configure --prefix=/home/.... --enable-threads 

I try with -sse2 option too but with same results, 1 thread is always better.

I compile with :

gcc 1DFFTW.c -o 1DFFTW -I/$HOME/opt/fftw-3.3.2/include -L/$HOME/opt/fftw-3.3.2/lib -lrt -lfftw3_threads -lfftw3 -lpthread -lm

The important part of code is :

  if(nThreads>1){
     int err=fftw_init_threads();
     if (err==0) 
        printf("thread creation error : %d\n",err);
     else 
        fftw_plan_with_nthreads(nThreads);
  }
  int i;
  fftw_complex *in;
  fftw_complex *in2;

  fftw_complex *out;

  fftw_plan plan_backward;
  fftw_plan plan_forward;

  struct timespec start, stop;
  printf ( "\n" );
  printf ( "N= %d \n",n);

  in = fftw_malloc ( sizeof ( fftw_complex ) * n );

  srand ( time(NULL) );

  for ( i = 0; i < n; i++ )
  {
    in[i][0] = rand() / (double)RAND_MAX;
    in[i][1] = rand() / (double)RAND_MAX;
  }


  out = fftw_malloc ( sizeof ( fftw_complex ) * n );

  in2 = fftw_malloc ( sizeof ( fftw_complex ) * n );


  plan_forward = fftw_plan_dft_1d ( n, in, out, FFTW_FORWARD, FFTW_ESTIMATE );


  plan_backward = fftw_plan_dft_1d ( n, out, in2, FFTW_BACKWARD, FFTW_ESTIMATE );

  clock_gettime(CLOCK_PROCESS_CPUTIME_ID,&start);

  fftw_execute ( plan_forward );


  fftw_execute ( plan_backward );

  clock_gettime(CLOCK_PROCESS_CPUTIME_ID,&stop);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:38:35+00:00Added an answer on June 8, 2026 at 12:38 pm

    The multithreaded algorithm has overhead associated with distributing the task among multiple CPUs and consolidating the results of the individual sub-problem. You are measuring the CPU time, not the wall clock time.

    If you want to minimize CPU time, use one thread. That way, there’s no threading overhead. If you want to minimize wall time, use more threads.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am doing a simple coin flipping experiment for class that involves flipping a
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.