License GNU General Public License, version 2
Lines 11
Keywords
Hello World (24) mpi (4) mpi4py (2)
Included in this Library
Permissions
Owner: Stou S.
Viewable by Everyone
Editable by All Siafoo Users
Hide
Siafoo is here to make coding less frustrating and to save you time. Join Siafoo Now or Learn More

Parallel (mpi4py) Python Hello World Atom Feed 0

In Brief This is the most basic mpi4py program. When launched each process will obtain it's rank and print out the process pool size and machine name.... more
# 's
 1#!/bin/env python
2"""
3Parallel Hello World !!!
4"""
5
6from mpi4py import MPI
7import sys
8
9hwmess = "Hello, World!! I am process %d of %d on %s.\n"
10myrank = MPI.COMM_WORLD.Get_rank()
11nprocs = MPI.COMM_WORLD.Get_size()
12procnm = MPI.Get_processor_name()
13sys.stdout.write(hwmess % (myrank, nprocs, procnm))

This is the most basic mpi4py program. When launched each process will obtain it's rank and print out the process pool size and machine name.

For a more complex and possibly useful example check out the Simple MPI batch system