0

I am new to fftw library. I recently downloaded a simple mpi-fftw code from here. I have some undefined references to mpi functions from libfftw3_mpi.a when I compile the code on Ubuntu 18.04 as

mpicc -I /usr/local/include -L /usr/local/lib  simple_mpi_example.c -o simple_mpi_example -lfftw3_mpi -lfftw3 -lm

I am using older gcc-5 for the compilation.

I tried to run the same thing on a mac with gcc-8 and I did not have a problem. So I ran the same thing with a newer version of gcc on Ubuntu and still had the same issue.

#include <fftw3-mpi.h>

int main(int argc, char **argv){
const ptrdiff_t N0 = 10000, N1 = 10000;
fftw_plan plan;
fftw_complex *data; //local data of course
ptrdiff_t alloc_local, local_n0, local_0_start, i, j;

MPI_Init(&argc, &argv);
fftw_mpi_init();

/* get local data size and allocate */
alloc_local = fftw_mpi_local_size_2d(N0, N1, MPI_COMM_WORLD,
                                  &local_n0, &local_0_start);
data = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) *          
alloc_local);

printf("%i\n", local_n0);
/* create plan for forward DFT */
plan = fftw_mpi_plan_dft_2d(N0, N1, data, data, MPI_COMM_WORLD,
                         FFTW_FORWARD, FFTW_ESTIMATE);

/* initialize data to some function my_function(x,y) */
for (i = 0; i < local_n0; ++i) for (j = 0; j < N1; ++j){
  data[i*N1 + j][0]=local_0_start; 
  data[i*N1 + j][1]=i;
}

/* compute transforms, in-place, as many times as desired */
fftw_execute(plan);

fftw_destroy_plan(plan);
fftw_free(data);
MPI_Finalize();
printf("finalize\n");
return 0;
}

When I compile it, the output is as follows

simple_mpi_example.c:18:10: warning: format ‘%i’ expects argument of 
type ‘int’, but argument 2 has type ‘ptrdiff_t {aka long int}’ [-
Wformat=]
printf("%i\n", local_n0);
      ^
/usr/local/lib/libfftw3_mpi.a(api.o): In function `bogosity_hook':
api.c:(.text+0x2c): undefined reference to `ompi_mpi_comm_null'
/usr/local/lib/libfftw3_mpi.a(api.o): In function `nowisdom_hook':
api.c:(.text+0x8c): undefined reference to `ompi_mpi_comm_null'
/usr/local/lib/libfftw3_mpi.a(api.o): In function `wisdom_ok_hook':
api.c:(.text+0x110): undefined reference to `ompi_mpi_comm_null'
api.c:(.text+0x1bb): undefined reference to `ompi_mpi_unsigned'
api.c:(.text+0x1f8): undefined reference to `ompi_mpi_op_land'
api.c:(.text+0x1ff): undefined reference to `ompi_mpi_int'
/usr/local/lib/libfftw3_mpi.a(api.o): In function `cost_hook':
api.c:(.text+0x29c): undefined reference to `ompi_mpi_comm_null'
api.c:(.text+0x2a8): undefined reference to `ompi_mpi_op_sum'
api.c:(.text+0x2b6): undefined reference to `ompi_mpi_op_max'
api.c:(.text+0x2cb): undefined reference to `ompi_mpi_double'
/usr/local/lib/libfftw3_mpi.a(transpose-alltoall.o): In function                 
`apply':
transpose-alltoall.c:(.text+0x95): undefined reference to     
`ompi_mpi_double'
transpose-alltoall.c:(.text+0x125): undefined reference to     
`ompi_mpi_double'
transpose-alltoall.c:(.text+0x16c): undefined reference to 
`ompi_mpi_double'
transpose-alltoall.c:(.text+0x19e): undefined reference to 
`ompi_mpi_double'
/usr/local/lib/libfftw3_mpi.a(transpose-pairwise.o):transpose-    
pairwise.c:(.text+0x34a): more undefined references to 
`ompi_mpi_double' follow
/usr/local/lib/libfftw3_mpi.a(any-true.o): In function 
`fftw_mpi_any_true':
any-true.c:(.text+0x2d): undefined reference to `ompi_mpi_op_lor'
any-true.c:(.text+0x34): undefined reference to `ompi_mpi_int'
/tmp/ccHXT0fP.o: In function `main':
simple_mpi_example.c:(.text+0x5f): undefined reference to 
`ompi_mpi_comm_world'
simple_mpi_example.c:(.text+0xba): undefined reference to 
`ompi_mpi_comm_world'
/usr/local/lib/libmpi.a(mpl_bt.o): In function `backtrace_libback':
mpl_bt.c:(.text+0x110): undefined reference to 
`backtrace_create_state'
mpl_bt.c:(.text+0x129): undefined reference to `backtrace_print'
/usr/local/lib/libmpi.a(ad_iwrite.o): In function 
`ADIOI_GEN_aio_wait_fn':
ad_iwrite.c:(.text+0x147): undefined reference to `aio_suspend'
ad_iwrite.c:(.text+0x19a): undefined reference to `aio_error'
ad_iwrite.c:(.text+0x1ad): undefined reference to `aio_return'
/usr/local/lib/libmpi.a(ad_iwrite.o): In function 
`ADIOI_GEN_aio_poll_fn':
ad_iwrite.c:(.text+0x336): undefined reference to `aio_error'
ad_iwrite.c:(.text+0x355): undefined reference to `aio_return'
/usr/local/lib/libmpi.a(ad_iwrite.o): In function `ADIOI_GEN_aio':
ad_iwrite.c:(.text+0x470): undefined reference to `aio_write'
ad_iwrite.c:(.text+0x4c9): undefined reference to `aio_read'
collect2: error: ld returned 1 exit status
Makefile:4: recipe for target 'simple_mpi_example' failed
make: *** [simple_mpi_example] Error 1
ray
  • 5,454
  • 1
  • 18
  • 40
  • 1
    double check you are using Open MPI `mpicc` and not MPICH one. – Gilles Gouaillardet Jan 23 '19 at 11:33
  • Yes! I am using the openmpi version. mpirun (Open MPI) 2.1.1 Report bugs to http://www.open-mpi.org/community/help/ –  Jan 23 '19 at 11:38
  • Try adding `--showme` to your command line to double check `-lmpi` is **after** `-lfftw 3`. Are you sure there is no `libmpi.so` lib from MPICH in /usr/local/lib ? – Gilles Gouaillardet Jan 23 '19 at 13:24
  • 1
    `gcc -I /usr/local/include -L /usr/local/lib simple_mpi_example.c -o simple_mpi_example -lfftw3_mpi -lfftw3 -lm -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent/include -I/usr/lib/x86_64-linux-gnu/openmpi/include -pthread -L/usr//lib -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi` –  Jan 23 '19 at 14:11
  • What about the second part ? – Gilles Gouaillardet Jan 24 '19 at 10:51
  • I did find some old files from the mpich installation. I redownloaded the tar ball and did perform sudo make distclean and sudo make uninstall but I still have some mpich files. Could you suggest how i can remove them please? –  Jan 30 '19 at 23:00
  • There is nothing like a good old `rm` – Gilles Gouaillardet Jan 30 '19 at 23:22
  • I was able to remove mpich properly and there were some remnants from an apt installation too which I could remove and It seems to work well now. Thanks a lot for your help. Really appreciate it. –  Jan 31 '19 at 18:12

0 Answers0