Lightning Introduction to MPI Programming



Similar documents
HPCC - Hrothgar Getting Started User Guide MPI Programming

Lecture 6: Introduction to MPI programming. Lecture 6: Introduction to MPI programming p. 1

High performance computing systems. Lab 1

To connect to the cluster, simply use a SSH or SFTP client to connect to:

Parallelization: Binary Tree Traversal

MPI Application Development Using the Analysis Tool MARMOT

Session 2: MUST. Correctness Checking

Parallel Programming with MPI on the Odyssey Cluster

LOAD BALANCING DISTRIBUTED OPERATING SYSTEMS, SCALABILITY, SS Hermann Härtig

Introduction to MPI Programming!

Message Passing Interface (MPI)

RA MPI Compilers Debuggers Profiling. March 25, 2009

MPI Runtime Error Detection with MUST For the 13th VI-HPS Tuning Workshop

HP-MPI User s Guide. 11th Edition. Manufacturing Part Number : B September 2007

Parallel Computing. Parallel shared memory computing with OpenMP

Performance and scalability of MPI on PC clusters

WinBioinfTools: Bioinformatics Tools for Windows Cluster. Done By: Hisham Adel Mohamed

Introduction to Cloud Computing

OpenMP & MPI CISC 879. Tristan Vanderbruggen & John Cavazos Dept of Computer & Information Sciences University of Delaware

Compute Cluster Server Lab 3: Debugging the parallel MPI programs in Microsoft Visual Studio 2005

Allinea Performance Reports User Guide. Version 6.0.6

Message Passing Interface (MPI)

Introduction. Reading. Today MPI & OpenMP papers Tuesday Commutativity Analysis & HPF. CMSC 818Z - S99 (lect 5)

MARMOT- MPI Analysis and Checking Tool Demo with blood flow simulation. Bettina Krammer, Matthias Müller

Message Passing with MPI

Introduction to Hybrid Programming

Debugging with TotalView

COMP/CS 605: Introduction to Parallel Computing Lecture 21: Shared Memory Programming with OpenMP

Load Balancing. computing a file with grayscales. granularity considerations static work load assignment with MPI

Parallel Astronomical Data Processing or How to Build a Beowulf Class Cluster for High Performance Computing?

Implementing MPI-IO Shared File Pointers without File System Support

Introduction to grid technologies, parallel and cloud computing. Alaa Osama Allam Saida Saad Mohamed Mohamed Ibrahim Gaber

McMPI. Managed-code MPI library in Pure C# Dr D Holmes, EPCC dholmes@epcc.ed.ac.uk

Agenda. Using HPC Wales 2

Charm++, what s that?!

Parallel I/O on Mira Venkat Vishwanath and Kevin Harms

How To Visualize Performance Data In A Computer Program

Hybrid Programming with MPI and OpenMP

How to Run Parallel Jobs Efficiently

High Performance Computing. MPI and PETSc

MUSIC Multi-Simulation Coordinator. Users Manual. Örjan Ekeberg and Mikael Djurfeldt

LS-DYNA Scalability on Cray Supercomputers. Tin-Ting Zhu, Cray Inc. Jason Wang, Livermore Software Technology Corp.

Why Choose C/C++ as the programming language? Parallel Programming in C/C++ - OpenMP versus MPI

R and High-Performance Computing

Informatica e Sistemi in Tempo Reale

Advanced MPI. Hybrid programming, profiling and debugging of MPI applications. Hristo Iliev RZ. Rechen- und Kommunikationszentrum (RZ)

Cloud-based OpenMP Parallelization Using a MapReduce Runtime. Rodolfo Wottrich, Rodolfo Azevedo and Guido Araujo University of Campinas

The CNMS Computer Cluster

Streamline Computing Linux Cluster User Training. ( Nottingham University)

Kommunikation in HPC-Clustern

Grid 101. Grid 101. Josh Hegie.

Evaluation of Java Message Passing in High Performance Data Analytics

The Double-layer Master-Slave Model : A Hybrid Approach to Parallel Programming for Multicore Clusters

Chapter 2 Parallel Architecture, Software And Performance

Parallel Debugging with DDT

An Introduction to Parallel Computing/ Programming

An Incomplete C++ Primer. University of Wyoming MA 5310

Source Code Transformations Strategies to Load-balance Grid Applications

MPI-Checker Static Analysis for MPI

Debugging and Profiling Lab. Carlos Rosales, Kent Milfeld and Yaakoub Y. El Kharma

Program Coupling and Parallel Data Transfer Using PAWS

Performance Tool Support for MPI-2 on Linux 1

SWARM: A Parallel Programming Framework for Multicore Processors. David A. Bader, Varun N. Kanade and Kamesh Madduri

Parallel and Distributed Computing Programming Assignment 1

Notes on the SNOW/Rmpi R packages with OpenMPI and Sun Grid Engine

Grid Engine Basics. Table of Contents. Grid Engine Basics Version 1. (Formerly: Sun Grid Engine)

Automated Testing of Installed Software

GPI Global Address Space Programming Interface

BLM 413E - Parallel Programming Lecture 3

Partitioning and Divide and Conquer Strategies

1.0. User Manual For HPC Cluster at GIKI. Volume. Ghulam Ishaq Khan Institute of Engineering Sciences & Technology

Bright Cluster Manager 5.2. User Manual. Revision: Date: Fri, 30 Nov 2012

Static Approximation of MPI Communication Graphs for Optimized Process Placement

Parallel Computing. Shared memory parallel programming with OpenMP

Load Imbalance Analysis

Channel Access Client Programming. Andrew Johnson Computer Scientist, AES-SSG

The Asterope compute cluster

16 node Linux cluster at SCFBio

Manual for using Super Computing Resources

Analysis of Binary Search algorithm and Selection Sort algorithm

Batch Scripts for RA & Mio

Interconnection Networks Programmierung Paralleler und Verteilter Systeme (PPV)

Overlapping Data Transfer With Application Execution on Clusters

A Java Based Tool for Testing Interoperable MPI Protocol Conformance

Transcription:

Lightning Introduction to MPI Programming May, 2015

What is MPI? Message Passing Interface A standard, not a product First published 1994, MPI-2 published 1997 De facto standard for distributed-memory parallel programming Many implementations: Open MPI, MPICH, MVAPICH, Intel MPI, Fortran, C and C++ bindings are part of the standard Python, Java & others exist, of varying quality!

Hello Parallel World! hello.c #include <stdio.h> #include "mpi.h int main( int argc, char *argv[] ) { MPI_Init( &argc, &argv ); printf( "Hello, Parallel World!\n" ); MPI_Finalize(); return 0; }

Building & Running......with Open MPI at ACENET hello.c $ which mpicc /usr/local/openmpi/bin/mpicc $ mpicc hello_mpi.c -o hello $ mpirun -np 2 hello Hello, Parallel World! Hello, Parallel World! $

Grid Engine Integration $ cat job.sh #$ -cwd #$ -j y #$ -l h_rt=0:5:0,test=true #$ -pe ompi* 4 mpirun hello $ qsub job.sh Your job 1234667 ( job.sh ) has been subm Notice mpirun np 4 not needed. Open MPI and Grid Engine communicate this.

Concepts Single-program, multiple-data (SPMD) MPMD also supported but rarely used Point-to-point communications: MPI_Send, MPI_Recv Collective communications: MPI_Reduce, MPI_Bcast, MPI_Scatter... Communicators : MPI_COMM_WORLD Parallel I/O

Process Rank & Count rank.f program myrank include 'mpif.h integer ierror,myrank,nprocs call MPI_Init(iError) call MPI_Comm_Rank(MPI_COMM_WORLD,myRank,iError) call MPI_Comm_Size(MPI_COMM_WORLD,nProcs,iError) write(*,*) 'This is proc ',myrank,' of ',nprocs call MPI_Finalize(iError) end MPI_Comm_Rank returns different rank for each process MPI_Comm_Size returns total number of processors

Communicators MPI_COMM_WORLD is the set of all processes in this MPI job Can define subsets called communicators Can do collective communications within subset Will only use MPI_COMM_WORLD in this talk

Point to Point Communication Basic routines are MPI_Send and MPI_Recv Every MPI_Send must match an MPI_Recv Message consists of Sender rank Receiver rank Envelope Tag (arbitrary integer) Data

MPI_Send & MPI_Recv rank.c if (myrank!= 0) { sprintf( msg, "Hello from process %d\n", myrank); MPI_Send( msg, NCHARS, MPI_CHAR, 0, receiver rank TAG, MPI_COMM_WORLD ); } else { for (source=1; source<nprocs; source++) { MPI_Recv( msg, NCHARS, MPI_CHAR, sender rank source, TAG, MPI_COMM_WORLD, &status ); printf( "%s", msg ); } printf( "...and hello from rank %d.\n", myrank ); }

Who Does What? Rank 1, 2, 3,... Rank 0 if (myrank!= 0) { // WORKER sprintf(&msg, %d\n,myrank); MPI_Send(msg, NCHARS, MPI_CHAR, 0, TAG, MPI_COMM_WORLD); } else { // myrank == 0 for (src=1; src<n; src++) { MPI_Recv(msg, NCHARS, MPI_CHAR, src, TAG, MPI_COMM_WORLD, &status); printf( "%s", msg ); } printf("...and hello from rank 0.\n"); } if (myrank!= 0) { sprintf(&msg, %d\n,myrank); MPI_Send(msg, NCHARS, MPI_CHAR, 0, TAG, MPI_COMM_WORLD); } else { // MASTER for (src=1; src<n; src++) { MPI_Recv(msg, NCHARS, MPI_CHAR, src, TAG, MPI_COMM_WORLD, &status); printf( "%s", msg ); } printf("...and hello from rank 0.\n"); }

Slow Motion Replay Rank 0 Rank 1 Rank 2 Rank 3 MPI_Recv(..1) processes 1 MPI_Recv(..2) processes 2 MPI_Recv(..3) processes 3 MPI_Send( ) done MPI_Send( waiting.. ) done MPI_Send( waiting...... waiting... ) done Look at all that time spent waiting! ------------ Time ------------>

Collective Communication Call same function from all processes Allows implementation to organize communications efficiently...and saves the programmer some work Examples MPI_Bcast (broadcast) MPI_Reduce (global summation) MPI_Scatter (distribute an array) MPI_Gather (collect an array)

Numerical Integration, parallel Proc 0 Proc 2 Proc 1 f(x) i f(x i )*Δ Proc 3 limit Δ 0 limit 1 x

Overlapping Communication Rank 0 Rank 1 Rank 2 Rank 3 recv from 1 add recv from 2 add done send to 0 done recv from 3 add send to 0 done send to 2 done ------------ Time ------------> Tree structure O(log n) time MPI_Reduce will do this for you!

Broadcast & Reduce integrate.c if (myrank == root) { ReadParams( limits ); } MPI_Bcast( limits, 2, MPI_REAL, root, MPI_COMM_WORLD ); width = (limits[1]-limits[0])/nprocs; mylimits[0] = limits[0] + width*myrank; mylimits[1] = mylimits[0] + width; mysum = Integrate( mylimits, nintervals ); MPI_Reduce( &mysum, &globalsum, 1, MPI_REAL, MPI_SUM, root, MPI_COMM_WORLD ); if (myrank == root) { printf( "sum is: %f\n", globalsum ); }

Scatter & Gather Rank 0 Rank 1 Rank 2 Rank 3

Parallel Input/Output Each process can open and close its own files in Open MPI This is normal input/output (I/O) Different MPI procs accessing the same file at the same time is Parallel I/O

Timing double starttime, endtime; starttime = MPI_Wtime(); //... stuff to be timed... endtime = MPI_Wtime(); printf( That took %f seconds, endtime-starttime); Standard time functions in C and Fortran 90 have shortcomings. MPI_Wtime portable but not necessarily synchronized between processes.

The Real World (sort of) Numol, Numerical Molecules, quantum chem A. D. Becke & R. M. Dickson, J. Chem. Phys. 92, 3610 (1990) ParNum, Parallel Numol (unpublished) uses eleven MPI functions: MPI_Init, MPI_Finalize, MPI_Comm_Rank, MPI_Comm_Size, MPI_Send, MPI_Recv, MPI_Bcast, MPI_Reduce, MPI_Barrier, MPI_Wtime, MPI_Get_processor_name...Plus 7 constants and one communicator, MPI_COMM_WORLD

http://www.mcs.anl.gov/research/projects/mpi/tutorial/index.html

http://www.cs.usfca.edu/~peter/ppmpi/

http://www.open-mpi.org

Example Code On ACEnet clusters, do tar xf /home/rdickson/public/mpi_demo.tar http://www.acceleratediscovery.ca/wiki/open_mpi http://www.acceleratediscovery.ca/wiki/parallel_jobs