2

I have installed both Open MPI and FFTW onto my mac. I've successfully used FFTW, now I'm trying to use it with MPI.

Here is what I am trying to run:

int main(int argc, char **argv){ clock_t time0, time1; int N = 10; fftw_complex *in, *out; fftw_plan p; MPI_Init(&argc, &argv); fftw_mpi_init(); in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N); out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N); p = fftw_mpi_plan_dft_1d(N, in, out,MPI_COMM_WORLD, FFTW_FORWARD, FFTW_ESTIMATE); for (int i = 0; i<N; i++) { in[i]=i+(i+1)*I; } time0 = clock(); fftw_execute(p); time1 = clock(); printf(" FFT time = %f \n\n", (float)(time1 - time0)/CLOCKS_PER_SEC); fftw_destroy_plan(p); fftw_free(in); fftw_free(out); MPI_Finalize(); return 0; } 

Here is how I am attempting to compile:

gcc -I/usr/local/include test.c -L/usr/local/lib -lfftw3_mpi 

This is nearly identical to how I compiled without mpi and all worked fine:

gcc -I/usr/local/include test.c -L/usr/local/lib -lfftw3 

But Now I see a lot of this:

enter image description here

How can I fix this issue? I know I installed OpenMPI, the installation of FFTW failed without it.

5
  • I will try that Commented Sep 14, 2016 at 19:20
  • do you know how to do so? Commented Sep 14, 2016 at 19:26
  • 1
    I did that and still had the same issue but with different functions so I also added -lfftw3 and now it works, thank you!! Commented Sep 14, 2016 at 19:41
  • 1
    Actually it looks like OpenMPI isn't that straightforward -- try mpicc -I/usr/local/include test.c -L/usr/local/lib -lfftw3_mpi Commented Sep 14, 2016 at 20:25
  • it compiled both ways, both saw the same time computing the fft Commented Sep 14, 2016 at 21:36

1 Answer 1

1
  1. Add -lfftw3 after -lfftw3_mpi

  2. Use mpicxx instead of gcc

Command: mpicxx test.c -lfftw3_mpi -lfftw3

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.