Quantcast
Channel: Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 2652

How to use both: FFTW3 and MKL

$
0
0

Hey!

I've got the the following problem:

I want to keep the flexibility within my code to switch between FFTW3 and MKL-FFT (with the purpose to test performance issues of both FFTs and thus, decide which to use in the final version).

Since the MKL provides the FFTW3 Interfaces, I thought it would be possible to maintain both FFTs without touching the code. According to the MKL-manual this is possible just by linking the correct libraries to your code. The problem is, that the FFTW3 interface of MKL is not within a separate library, it is already within the "basic" MKL-Libs (e.g. libmkl_intel_lp64). Consequently I don't know whether my code uses the original FFTW3 or the MKL-interface version. How can I explicilty choose the underlying FFT or is it not possible to use MKL features together with the original FFTW3?

But here in more detail:

For testing purpose I'v taken one of the fftw3 examples which is provided by the MKL (dp_plan_dft_1d.c) and compiled and linked it with fftw3:

icc -c dp_plan_dft_1d.c
icc dp_plan_dft_1d.o -o dp_plan_dft_1d -lfftw3

which works. This example is now linked to the fftw3. Without -lfftw3 there would be undefined references.

Further, my code will use other MKL-functions, so I've added a simple function (see attached code, first lines in main): vdAdd (adds to vectors element-wise):
vdAdd( myMklVar, test1, test2, addtest ); // see attached code for full change

Compiling and linking with

icc -c dp_plan_dft_1d.c
icc dp_plan_dft_1d.o -o dp_plan_dft_1d -lfftw3 -L /opt/intel/composerxe/mkl/lib/intel64/ -lmkl_core -lmkl_intel_lp64 -lmkl_sequential -lpthread -lm
./dp_plan_dft_1d

works also fine. But now, the fft-functions might be taken from MKL, since the interface handler is included in the MKL-Libs. Thus, when I remove -lfftw3, the code is works also - there are no undefined references. So, how can I be sure which FFT is used? Is it selected by the order of linking the libs? (Ok - I can check which FFT is used, by calling MKL-unsupported FFTW3 functions, but that's not convenient...)

I would have expected, that I have to link the MKL-FFTW3 interface explicitly with -lfftw3xc_intel (in exchange for "original" -lfftw3), otherwise there should be the undefined references for fftw functions, but obviously this is not necessary.

Did I get something wrong, or is it not possible to use MKL-features and the genuine FFTW3 together in the same code?

Cheers and thanks for answers!
Sebastian

AttachmentSize
Downloaddp_plan_dft_1d.c5.93 KB

Viewing all articles
Browse latest Browse all 2652

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>