sdsc / p3dfft

P3DFFT stands for Parallel Three-Dimensional Fast Fourier Transforms. It is a library for large-scale computer simulations on parallel platforms. It implements 3D FFT and related algorithms such as Chebyshev transform (an important class of algorithm for simulations in a wide range of fields). P3DFFT uses 2D, or pencil, decomposition. For more information:
http://www.p3dfft.net
Other
56 stars 17 forks source link

How to specify openmpi and mpif90's directory during compilation #22

Closed Kai2510 closed 1 month ago

Kai2510 commented 2 months ago

Hello! I'm compiling p3dfft on ubuntu 22.04 (gcc 11.4) with openmpi 4.1.6, mpif90 and fftw 3.3.9 already installed. However, the openmpi is compiled and installed in '/opt/openmpi/' directory. I've ran configure script like this: ./configure --prefix=/opt/p3dfft/ --enable-fftw --with-fftw=/opt/fftw --enable-openmpi --enable-gnu LDFLAGS="-L/opt/openmpi/lib -lmpi_mpifh -lm" FCFLAGS="-fno-strict-aliasing"

The question is that I can't find method to specify the directory of openmpi. I can't even find variable related to openmpi's library. Currently, make leads to errors like this:

...(Some Warnings about  ‘-fno-strict-aliasing’)

../../build/bcomm1.F90:239:64: note: ‘mpi_alltoallv’ was previously declared here
  239 |            buf2,JrRcvCnts, JrRcvStrt,mpi_byte,mpi_comm_col,ierr)
      |                                                                ^
../../build/bcomm1.F90:239:64: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `exec_b_c1_._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fft_exec.F90:82: undefined reference to `omp_get_thread_num_'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `exec_f_c1_._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fft_exec.F90:307: undefined reference to `omp_get_thread_num_'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `exec_b_c2_same_._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fft_exec.F90:165: undefined reference to `omp_get_thread_num_'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `exec_f_c2_same_._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fft_exec.F90:361: undefined reference to `omp_get_thread_num_'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_fcomm2_many.constprop.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fcomm2.F90:98: undefined reference to `GOMP_parallel'
/usr/bin/ld: /opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fcomm2.F90:76: undefined reference to `GOMP_parallel'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_bcomm1_many.constprop.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/bcomm1.F90:50: undefined reference to `GOMP_parallel'
/usr/bin/ld: /opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/bcomm1.F90:90: undefined reference to `GOMP_parallel'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_bcomm2_many._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/bcomm2.F90:53: undefined reference to `omp_get_num_threads'
/usr/bin/ld: /opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/bcomm2.F90:53: undefined reference to `omp_get_thread_num'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_bcomm2_many._omp_fn.1':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/bcomm2.F90:119: undefined reference to `omp_get_num_threads'
/usr/bin/ld: /opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/bcomm2.F90:119: undefined reference to `omp_get_thread_num'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_pack_bcomm1._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/bcomm1.F90:170: undefined reference to `omp_get_num_threads'
/usr/bin/ld: /opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/bcomm1.F90:170: undefined reference to `omp_get_thread_num'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_unpack_bcomm1_many._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/bcomm1.F90:144: undefined reference to `omp_get_num_threads'
/usr/bin/ld: /opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/bcomm1.F90:144: undefined reference to `omp_get_thread_num'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_fcomm1_many._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fcomm1.F90:59: undefined reference to `omp_get_num_threads'
/usr/bin/ld: /opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fcomm1.F90:59: undefined reference to `omp_get_thread_num'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_fcomm1_many._omp_fn.1':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fcomm1.F90:102: undefined reference to `omp_get_num_threads'
/usr/bin/ld: /opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fcomm1.F90:102: undefined reference to `omp_get_thread_num'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_pack_fcomm2_many._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fcomm2.F90:112: undefined reference to `omp_get_num_threads'
/usr/bin/ld: /opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fcomm2.F90:112: undefined reference to `omp_get_thread_num'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_unpack_fcomm2._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fcomm2.F90:170: undefined reference to `omp_get_num_threads'
/usr/bin/ld: /opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fcomm2.F90:170: undefined reference to `omp_get_thread_num'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `exec_b_c2r_._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fft_exec.F90:259: undefined reference to `omp_get_thread_num_'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_ztran_f_same_many.constprop.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/ftran.F90:795: undefined reference to `GOMP_parallel'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_p3dfft_ftran_r2c_many.constprop.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fcomm1.F90:59: undefined reference to `GOMP_parallel'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o:/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fcomm1.F90:102: undefined reference to `GOMP_parallel'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_p3dfft_ftran_r2c_many.constprop.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/ftran.F90:766: undefined reference to `GOMP_parallel'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_p3dfft_ftran_r2c_many.constprop.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fft_exec.F90:304: undefined reference to `GOMP_parallel'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o:/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/btran.F90:276: more undefined references to `GOMP_parallel' follow
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `__p3dfft_MOD_init_plan._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/init_plan.F90:44: undefined reference to `omp_get_thread_num'
/usr/bin/ld: /opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/init_plan.F90:45: undefined reference to `omp_get_num_threads_'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `exec_f_r2c_._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fft_exec.F90:456: undefined reference to `omp_get_thread_num_'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `exec_ctrans_r2_same_._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fft_exec.F90:507: undefined reference to `omp_get_thread_num_'
/usr/bin/ld: /tmp/ccUJMyhA.ltrans0.ltrans.o: in function `exec_strans_r2_same_._omp_fn.0':
/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN/../../build/fft_exec.F90:727: undefined reference to `omp_get_thread_num_'
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:467:test_sine_many_f.x] 错误 1
make[3]: 离开目录“/opt/p3dfft/p3dfft-2.7.5/sample/FORTRAN”
make[2]: *** [Makefile:324:all-recursive] 错误 1
make[2]: 离开目录“/opt/p3dfft/p3dfft-2.7.5/sample”
make[1]: *** [Makefile:425:all-recursive] 错误 1
make[1]: 离开目录“/opt/p3dfft/p3dfft-2.7.5”
make: *** [Makefile:345:all] 错误 2
make: *** [Makefile:345:all] 错误 2

Obviously, the paralleled fortran code cannot be compiled properly. I have no idea about the error... So, has anyone met same problems? And how can I fix it? Thanks in advance.

Kai2510 commented 1 month ago

Problem solved. Firstly I installed openmp, then errors about omp_*** was eliminated. Then I manually specified mpicc, mpif90's path, and openmpi's library path.

./configure --prefix=/opt/p3dfft/ --enable-fftw --with-fftw=/opt/fftw --enable-openmpi --enable-gnu CC=/opt/openmpi/4.1.6/bin/mpicc FC=/opt/openmpi/4.1.6/bin/mpif90 FCFLAGS="-I/opt/openmpi/4.1.6/include/ -fno-strict-aliasing" CFLAGS=-I/opt/openmpi/4.1.6/include/ LIBS="-L/opt/openmpi/4.1.6/lib -lmpi_mpifh -lm"

Note that -lm should be specified in LIBS instead of FCFLAGS to avoid DSO link error mentioned in #17.