mpi4py run python script on HPCC with multi nodes for simple parallel programming.

The following test was carried on on AHPCC of Univ. of Arkansas. I used two nodes, each node has 12 cores. The output of script showed two nodes (compute1279 and compute1280) were both used. More introduction can be found at http://materials.jeremybejarano.com/MPIwithPython/pointToPoint.html. “rank” can be used to allocate the cores. Dividing the data into several lists could achieve simple parallel computing.

The HPCC manager Pawel Wolinski taught me about this.

###############################################################

#!/usr/bin/env python
“””
Parallel Hello World
“””

from mpi4py import MPI
import sys

size = MPI.COMM_WORLD.Get_size()
rank = MPI.COMM_WORLD.Get_rank()
name = MPI.Get_processor_name()

sys.stdout.write(
“Hello, World! I am process %d of %d on %s.\n”
% (rank, size, name))

#################################################################

qsub -I -V -q debug12core -l nodes=2:ppn=12

module load gcc/4.6.3 python/2.7.5 impi/4.0.3
mpirun -np 16 -f $PBS_NODEFILE python helloworld.py

#$PBS_NODEFILE is a variable defined by the queueing system that stores the path to a file containing a list of ndoes assigned to your job

The output is
Hello, World! I am process 9 of 16 on compute1279.
Hello, World! I am process 5 of 16 on compute1279.
Hello, World! I am process 7 of 16 on compute1279.
Hello, World! I am process 10 of 16 on compute1279.
Hello, World! I am process 2 of 16 on compute1279.
Hello, World! I am process 6 of 16 on compute1279.
Hello, World! I am process 4 of 16 on compute1279.
Hello, World! I am process 1 of 16 on compute1279.
Hello, World! I am process 3 of 16 on compute1279.
Hello, World! I am process 11 of 16 on compute1279.
Hello, World! I am process 0 of 16 on compute1279.
Hello, World! I am process 8 of 16 on compute1279.
Hello, World! I am process 12 of 16 on compute1280.
Hello, World! I am process 13 of 16 on compute1280.
Hello, World! I am process 14 of 16 on compute1280.
Hello, World! I am process 15 of 16 on compute1280.