4

I'm unable to get FFTW to link to my code in order to use its functions in my code. I have spent enough time on this that I am considering giving up on it.

I am very familiar with GSL, and have used the linear algebra libraries extensively with good results. GSL also has a set of FFT functions that seem to do the same things as FFTW. Are they just as good? Or is FFTW significantly better, and worth spending more time to try to get it to work?

(By the way, my error is that using g++ on a remote system on which I am not the admin, I am unable to compile my code to recognize references to FFTW calls. My makefile includes -L/libdirectory -lfftw3 but I still get undefined references for some (not all) fftw functions).

Here is the source:
#include "fftw3.h"
in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * length);

Here is the relevant compile command:
g++ -std=c++0x -fPIC ... -lm ... -L/libdirectory -lfftw3

Here is the error:
/source.cc: undefined reference to 'fftw_malloc'

Note that the compiler is able to find fftw3.h. I also can declare objects such as fftw_complex and fftw_plan.

EDIT: I still can't get my Makefile to link the static library. However, I was able to recompile with shared libraries and those seem to have worked so far. I still would like to see some benchmarks newer than 11 years old, though!

Machinus
  • 109
  • 10
  • Why not post your build commands and error messages for the FFTW build in a new question and see if people here can help you fix it ? – Paul R Mar 25 '16 at 06:56
  • Here is the source: **`#include "fftw3.h"`** **`in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * length);`** Here is the relevant compile command: **`g++ -std=c++0x -fPIC ... -lm ... -L/libdirectory -lfftw3`** Here is the error: **`/source.cc: undefined reference to 'fftw_malloc'`** – Machinus Mar 25 '16 at 09:22
  • Please hit [edit] and add the source, build command and error message to your question. – Paul R Mar 25 '16 at 09:26
  • Okay, added to main question. Should I delete this? – Machinus Mar 25 '16 at 21:16

1 Answers1

1

You didn't mention what you would consider "significantly better" which could means a variety of things from speed, accuracy, ease of use, maintenance, licensing, etc. But I assume you are primarily interested in speed and accuracy comparisons.

For the speed aspect, the reference section of GNU GSL documentation mentions:

For large-scale FFT work we recommend the use of the dedicated FFTW library by Frigo and Johnson. The FFTW library is self-optimizing—it automatically tunes itself for each hardware platform in order to achieve maximum performance.

So according to GSL developers' own admission, FFTW is expected to outperform GSL. How much so? You can have a look at this speed performance benchmark from FFTW which suggests that GSL is about 3-4 times slower than FFTW 3. Note that this benchmark hasn't been done with g++ (and there doesn't seem to be another readily available benchmark for the gcc compilers from FFTW's site which includes GSL), and quite likely on a machine with different than yours, so your own results may vary. On the accuracy front this accuracy benchmark from FFTW suggests that they have similar accuracy for most case (with FFTW being slightly more accurate) but that GSL tend to exhibit accuracy degradation for real data and larger transform sizes.

For sake of completeness I'll briefly mention that as far as licensing goes, they both offer GNU GPL license, but FFTW also offers a non-free license, which could be considered better by someone for which the GNU GPL license is problematic. Otherwise for ease-of-use and maintenance, they are both actively developed and offer different but similarly complex APIs. So for those aspects, preference of one library over the other may be based on factors other that the FFT's implementation merits.

SleuthEye
  • 14,379
  • 2
  • 32
  • 61
  • I looked at those benchmarks before I posted. They appear to be around 15 years old, and in that time GSL has undergone major releases. I was hoping there would be someone with more recent experience with GSL that might know if they closed the gap. I expect a dedicated FFT library to perform better, obviously, but if GSL has narroed the difference then it might be acceptable to use it since it already works for me. – Machinus Mar 25 '16 at 21:16
  • 2
    The benchmark includes GSL 1.7 ([release date 2005-09-14](http://git.savannah.gnu.org/cgit/gsl.git/tag/?id=release-1-7)), and the FFT part of GSL has only had [minor changes](http://git.savannah.gnu.org/cgit/gsl.git/log/fft) that didn't touch the core algorithm implementation. It's unlikely that improvements in the compiler benefited GSL (which it wasn't designed to take advantage of) significantly more than FFTW (which has actively evolved to take advantage of new compiler and architecture). – SleuthEye Mar 26 '16 at 12:24