您的位置:首页 > 运维架构

mpi+openmp程序需要注意事项

2013-05-12 17:36 295 查看
编译的选项

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 SuiteProgramming Environment module nameCommand line option for OpenMP
Portland GroupPrgEnv-pgi-mp
PathscalePrgEnv-pathscale-mp
Cray CompilersPrgEnv-craynone needed
Intel Compilers (Hopper only)PrgEnv-intel-openmp
GNU CompilersPrgEnv-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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: