octave-maintainers
[Top][All Lists]
Advanced

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

Multithreaded FFTW3 in octave?


From: John W. Eaton
Subject: Multithreaded FFTW3 in octave?
Date: Wed, 12 Dec 2012 08:30:17 -0500

On 12-Dec-2012, Andreas Weber wrote:

| Dear maintainers,
| 
| Why does octave not use the multithreaded FFTW3 libs or am I missing a 
| configure flag?

Because no one has done the work for it?

| I tried some changes (set nthreads fixed to 6)
| 
| diff -r 0dcaf0e68a79 liboctave/numeric/oct-fftw.cc
| --- a/liboctave/numeric/oct-fftw.cc    Wed Dec 12 10:02:46 2012 +0100
| +++ b/liboctave/numeric/oct-fftw.cc    Wed Dec 12 13:43:46 2012 +0100
| @@ -64,6 +64,9 @@
|     simd_align[0] = simd_align[1] = false;
|     inplace[0] = inplace[1] = false;
|     n[0] = n[1] = dim_vector ();
| +
| +  fftw_init_threads();
| +  fftw_plan_with_nthreads(6);

Clearly we can't just set nthreads to 6 unconditionally...

| And another quick&dirty hack to link octave against "libfftw3_threads" 
| in src/Makefile
| 
| After these 3 changes and compilation I run "make check" and all fft 
| test ran fine. Then I made a little test:
| 
| for k=1:5
|      a=rand(5000,5000);
|      tic;
|      b=fft2(a);
|      toc;
| endfor
| 
| Output without multithreading FFTW:
| Elapsed time is 1.37438 seconds.
| Elapsed time is 1.38043 seconds.
| Elapsed time is 1.3756 seconds.
| Elapsed time is 1.37472 seconds.
| Elapsed time is 1.4059 seconds.
| 
| Output with multithreading FFTW (above 3 changes):
| Elapsed time is 0.521382 seconds.
| Elapsed time is 0.519745 seconds.
| Elapsed time is 0.519839 seconds.
| Elapsed time is 0.52183 seconds.
| Elapsed time is 0.518955 seconds.
| 
| Used CPU is AMD Phenom(tm) II X6 1055T Processor

That looks like a nice performance improvement.  Would you like to
propose a complete patch that

  * makes the number of threads configurable by the user (probably by
    adding a new fftw_max_nthreads function or similar)

  * documents the new configuration function

  * adds a configure test for this feature (unless it can be assumed
    to be present in every reasonable FFTW installation today) and
    checks for the necessary library

?

jwe


reply via email to

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