Message Passing Interface (MPI)


Message Passing Interface (MPI) supports distributed memory system consisting of multiple computers with independent memory.

Sample MPI code

Compile (only MPI)

 
$ mpif90 -O2 calPi_MPI.F90 -o test
$ mpiifort -O2 calPi_MPI.F90 -o test
$ nohup mpirun -np 8 ./test &
			 

Compile (hybrid MPI and OpenMP)

Case1: On local machine:

 
$ mpif90 -fopenmp -O2 test_MPI.F90 -o test
$ mpiifort -qopenmp -O2 test_MPI.F90 -o test
Running:
export OMP_NUM_THREADS=12 && nohup mpirun -np 2 ./test &
			 

Case 2: On Tianhe-2:

 
$ mpif90 -openmp -heap-arrays -O2 test_MPI.F90 -o test
job.sh file:
#!/bin/bash
export OMP_NUM_THREADS=12 && yhrun -N 2 -n 4 -c 12 -p bigdata ./test
Running:
yhbatch -N 2 -p bigdata ./job.sh
			 

PBS file

 
# !/bin/bash
#PBS -N mpi2d
#PBS -l nodes=2:ppn=2
#PBS -j oe output.out
#PBS -l walltime=1000000:00:00
cd /DATA2/work/AoXu/testMPI_2D/
export OMP_NUM_THREADS=12
mpirun -hostfile $PBS_NODEFILE /DATA2/work/AoXu/testMPI_2D/mpi2d
			 

Example I: Calculate Pi

Example II: Poisson Solver

High performance computing techniques (Read more...)