FFTW / fftw3

DO NOT CHECK OUT THESE FILES FROM GITHUB UNLESS YOU KNOW WHAT YOU ARE DOING. (See below.)
GNU General Public License v2.0
2.72k stars 661 forks source link

Need help in building fftw . #273

Closed mohit9638iitk closed 2 years ago

mohit9638iitk commented 2 years ago

I want to overload the MPI_Sendrecv() function of fftw. I have one header file named as "lib.h" and code in file named as "lib.c".

For simple example (say mpi_3d_fftw3.cpp) I do command line compilation ;-

  1. $ mpicc -c -Wall -Werror -fpic lib.c (this create a executable "lib.o").
  2. $mpicc mpi_3d_fftw.cpp lib.o -o fftw_non_block -lfftw3_mpi -lfftw3 -lm

So, basically mpi_3d_fftw.cpp will call fftw_execute and internally it uses MPI_Sendrecv() for communication purpose. By compiling with lib.o executable, fftw uses my version of MPI_Sendrecv().

I want to know how to link my library with fftw so that I do not have to compile with my executable for every code.

Please help me in doing this thing.

hominhquan commented 2 years ago

There are two possible solutions AFAIK:

  1. Dynamic linking (most often): You can compile your code to a separate libmy_mpi.so and use the LD_PRELOAD trick.
  2. Static linking: the best way IMO is to compile FFTW with -D MPI_Sendrecv=MPI_Sendrecv_custom and ensure to have the MPI_Sendrecv_custom() symbol in your libmy_mpi.a
mohit9638iitk commented 2 years ago

Thanks @hominhquan ,it has helped me a lot.