我是fftw库的新手。我最近从here下载了一个简单的mpi-fftw代码。当我在Ubuntu 18.04上将代码编译为
时,我从libfftw3_mpi.a中有一些对mpi函数的未定义引用mpicc -I /usr/local/include -L /usr/local/lib simple_mpi_example.c -o simple_mpi_example -lfftw3_mpi -lfftw3 -lm
我正在使用较旧的gcc-5
进行编译。
我尝试在装有gcc-8的Mac上运行相同的东西,但没有问题。因此,我在Ubuntu上使用较新版本的gcc运行了相同的操作,但仍然存在相同的问题。
#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;
}
编译时,输出如下
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