编译的选项
Intel
• Fortran : ifort,
• Fortran with MPI: mpif77, mpif90
• C/C++ :icc
• C/C++ with MPI: mpcc, mpCC
• Option to support OpenMP
• -openmp
Portland Group
• Fortran : pgf77, pgf90
• Fortran with MPI: mpif77, mpif90
• C/C++ :pgcc
• C/C++ with MPI: mpcc, mpCC
• Option to support OpenMP
• -mp
• pgifortref.pdf has good examples
1 openmp程序编译
(1)编译选项选择
Compiling to use OpenMP
OpenMP is supported in all four programming environments available on Franklin and Hopper; however, each compiler suite has a different syntax for enabling OpenMP.
Compiler Suite | Programming Environment module name | Command line option for OpenMP |
---|---|---|
Portland Group | PrgEnv-pgi | -mp |
Pathscale | PrgEnv-pathscale | -mp |
Cray Compilers | PrgEnv-cray | none needed |
Intel Compilers (Hopper only) | PrgEnv-intel | -openmp |
GNU Compilers | PrgEnv-gnu | -fopenmp |
gcc –fopenmp helloworld.c
运行时 export OMP_NUM_THREADS=4设定线程数
2mpi程序编译
mpirun -np 16 ./program
3 mpi+openmp混合编译
参考网址:http://www.nersc.gov/users/computational-systems/hopper/running-jobs/using-openmp-with-mpi/
http://geco.mines.edu/workshop/aug2010/slides/thu/hybrid.pdf
(1)fortran版本
编译:
mpif90 -o earthmo earthmo.f90 -openmp
使用哪个?
对于intel的mpirun,必须在mpirun后加上-env I_MPI_PIN_DOMAIN omp使得每个mpi进程会启动openmp线程。
通过export OMP_NUM_THREADS来控制每个MPI产生多少线程。
(2)c/ c++版本
gcc –fopenmp helloworld.c