Introduction to MPI Programming!



Similar documents
Lightning Introduction to MPI Programming

HPCC - Hrothgar Getting Started User Guide MPI Programming

Streamline Computing Linux Cluster User Training. ( Nottingham University)

High performance computing systems. Lab 1

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

Grid 101. Grid 101. Josh Hegie.

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

SGE Roll: Users Guide. Version Edition

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

GRID Computing: CAS Style

MOSIX: High performance Linux farm

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

Parallelization: Binary Tree Traversal

MPI Application Development Using the Analysis Tool MARMOT

RA MPI Compilers Debuggers Profiling. March 25, 2009

Session 2: MUST. Correctness Checking

Introduction to Sun Grid Engine (SGE)

Manual for using Super Computing Resources

Introduction to Cloud Computing

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

High Performance Computing Facility Specifications, Policies and Usage. Supercomputer Project. Bibliotheca Alexandrina

BLM 413E - Parallel Programming Lecture 3

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

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

Grid Engine. Application Integration

INF-110. GPFS Installation

Grid Engine Users Guide p1 Edition

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

PARALLEL & CLUSTER COMPUTING CS 6260 PROFESSOR: ELISE DE DONCKER BY: LINA HUSSEIN

How to Run Parallel Jobs Efficiently

Running applications on the Cray XC30 4/12/2015

Lecture 2 Parallel Programming Platforms

Symmetric Multiprocessing

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

MPI / ClusterTools Update and Plans

High Performance Computing

High Performance Computing

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

Scalability and Classifications

Improved LS-DYNA Performance on Sun Servers

Client/Server Computing Distributed Processing, Client/Server, and Clusters

Installing and running COMSOL on a Linux cluster

Middleware and Distributed Systems. Introduction. Dr. Martin v. Löwis

Introduction to Linux and Cluster Basics for the CCR General Computing Cluster

The Asterope compute cluster

Parallel Computing. Parallel shared memory computing with OpenMP

Analysis and Implementation of Cluster Computing Using Linux Operating System

Agenda. Using HPC Wales 2

Introduction to Cloud Computing

16 node Linux cluster at SCFBio

An Introduction to High Performance Computing in the Department

User s Manual

Performance Tool Support for MPI-2 on Linux 1

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

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

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

The SUN ONE Grid Engine BATCH SYSTEM

Principles and characteristics of distributed systems and environments

NEC HPC-Linux-Cluster

Linux tools for debugging and profiling MPI codes

The CNMS Computer Cluster

How To Visualize Performance Data In A Computer Program

- An Essential Building Block for Stable and Reliable Compute Clusters

Parallel Debugging with DDT

Applications of Passive Message Logging and TCP Stream Reconstruction to Provide Application-Level Fault Tolerance. Sunny Gleason COM S 717

SLURM Workload Manager

Linux Cluster Computing An Administrator s Perspective

Virtual Machines.

Debugging with TotalView

Hodor and Bran - Job Scheduling and PBS Scripts

THE EXPAND PARALLEL FILE SYSTEM A FILE SYSTEM FOR CLUSTER AND GRID COMPUTING. José Daniel García Sánchez ARCOS Group University Carlos III of Madrid

Ra - Batch Scripts. Timothy H. Kaiser, Ph.D. tkaiser@mines.edu

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

CPSC 226 Lab Nine Fall 2015

CPS221 Lecture: Operating System Structure; Virtual Machines

Intro to Intel Galileo - IoT Apps GERARDO CARMONA

Batch Scripts for RA & Mio

Using WestGrid. Patrick Mann, Manager, Technical Operations Jan.15, 2014

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

Allinea Performance Reports User Guide. Version 6.0.6

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

Introduction to the SGE/OGS batch-queuing system

Introduction to Running Hadoop on the High Performance Clusters at the Center for Computational Research

24/08/2004. Introductory User Guide

Miami University RedHawk Cluster Working with batch jobs on the Cluster

Automated Testing of Installed Software

Chapter 3 Operating-System Structures

ELEC 377. Operating Systems. Week 1 Class 3

Petascale Software Challenges. Piyush Chaudhary High Performance Computing

Overview. Lecture 1: an introduction to CUDA. Hardware view. Hardware view. hardware view software view CUDA programming

Hack the Gibson. John Fitzpatrick Luke Jennings. Exploiting Supercomputers. 44Con Edition September Public EXTERNAL

High-Performance Reservoir Risk Assessment (Jacta Cluster)

Transcription:

Introduction to MPI Programming! Rocks-A-Palooza II! Lab Session! 2006 UC Regents! 1!

Modes of Parallel Computing! SIMD - Single Instruction Multiple Data!!processors are lock-stepped : each processor executes single instruction in synchronism on different data! SPMD - Single Program Multiple Data!!processors run asynchronously a personal copy of a program! MIMD - Multiple Instruction Multiple Data!!processors run asynchronously: each processor has its own data and its own instructions! MPMD - Multiple Program Multiple Data! 2006 UC Regents! 2!

MPI in Parallel Computing! MPI addresses message-passing mode of parallel computation! Processes have separate address spaces! Processes communicate via sending and receiving messages! MPI is designed mainly for SPMD/MIMD (or distributed memory parallel supercomputer)! Each process is run on a separate node! Communication is over high-performance switch! Paragon, IBM SP2, Meiko CS-2, Thinking Machines CM-5, NCube-2, and Cray T3D! MPI can support shared memory programming model! Multiple processes can read/write to the same memory location! SGI Onyx, Challenge, Power Challenge, Power Challenge Array, IBM SMP, Convex Exemplar, and the Sequent Symmetry! MPI exploits Network Of Workstations (heterogeneous)! Sun, DEC, Hewlett-Packard, SGI, IBM, Intel and Pentium (various Linux OS)! 2006 UC Regents! 3!

What is MPI?! Message Passing application programmer Interface! Designed to provide access to parallel hardware! Clusters! Heterogeneous networks! Parallel computers! Provides for development of parallel libraries! Message passing! Point-to-point message passing operations! Collective (global) operations! Additional services! Environmental inquiry! Basic timing info for measuring application performance! Profiling interface for external performance monitoring! 2006 UC Regents! 4!

MPI advantages! Mature and well understood! Backed by widely-supported formal standard (1992)! Porting is easy! Efficiently matches the hardware! Vendor and public implementations available! User interface:! Efficient and simple (vs. PVM)! Buffer handling! Allow high-level abstractions! Performance! 2006 UC Regents! 5!

MPI disadvantages! MPI 2.0 includes many features beyond message passing! Execution control environment depends on implementation! 2006 UC Regents! 6!

MPI features! Thread safety! Point-to-point communication! Modes of communication! standard synchronous ready buffered Structured buffers! Derived datatypes! Collective communication! Native built-in and user-defined collective operations! Data movement routines! Profiling! Users can intercept MPI calls and call their own tools! 2006 UC Regents! 7!

Communication modes! standard! send has no guarantee that corresponding receive routine has started! synchronous! send and receive can start before each other but complete together! ready! used for accessing fast protocols! user guarantees that matching receive was posted! use with care!! buffered! send may start and return before matching receive! buffer space must be provided! 2006 UC Regents! 8!

Communication modes (contʼd)! All routines are! Blocking - return when they are locally complete! Send does not complete until buffer is empty! Receive does not complete until buffer is full! Completion depends on! size of message! amount of system buffering! Non-blocking - returns immediately and allows next statement to execute! Use to overlap communication and computation when time to send data between processes is large! Immediately returns request handle that can be used for querying and waited on,! Completion detected by MPI_Wait() or MPI_Test()! 2006 UC Regents! 9!

Point-to-point vs. collective! point-to-point, blocking MPI_Send/MPI_Recv! MPI_Send(start, count, datatype, dest, tag, comm )! MPI_Recv(start, count, datatype, source, tag, comm, status)! simple but inefficient! most work is done by process 0:! Get data and send it to other processes (they idle)! May be compute! Collect output from the processes! collective operations to/from all! MPI_Bcast(start, count, datatype, root, comm)! MPI_Reduce(start, result, count, datatype, operation, root, comm)! called by all processes! simple, compact, more efficient! must have the same size for count and datatype! result has significance only on node 0! 2006 UC Regents! 10!

MPI complexity! MPI extensive functionality is provided by many (125+) functions! Do I Need them all?! No need to learn them all to use MPI! Can use just 6 basic functions! MPI_Init MPI_Comm_size MPI_Comm_rank MPI_Send or MPI_Bcast MPI_Recv MPI_Reduce MPI_Finalize! Flexibility: use more functions as required! 2006 UC Regents! 11!

To be or not to be MPI user! Use if:!! Your data do not fit data parallel model!! Need portable parallel program!! Writing parallel library! Donʼt use if:!! Donʼt need any parallelism!! Can use libraries!! Can use fortran! 2006 UC Regents! 12!

Writing MPI programs! provide basic MPI definitions and types! #include mpi.h! start MPI! MPI_Init( &argc, &argv );! provide local non-mpi routines! exit MPI! MPI_Finalize();! see /opt/mpich/gnu/examples! /opt/mpich/gnu/share/examples! 2006 UC Regents! 13!

Compiling MPI programs! From a command line:! mpicc -o prog prog.c! Use profiling options (specific to mpich)! -mpilog Generate log files of MPI calls! -mpitrace Trace execution of MPI calls! -mpianim Real-time animation of MPI (not available on all systems)! --help Find list of available options! Use makefile!! get Makefile.in template and create Makefile! mpireconfig Makefile! compile! make progname! 2006 UC Regents! 14!

Running MPI program! Depends on your implementation of MPI! For mpich:! mpirun -np2 foo!!# run MPI program! For lam:! lamboot -v lamhosts!!# starts LAM! mpirun -v -np 2 foo!!# run MPI program! lamclean -v!!!# rm all user processes! mpirun!!!# run another program! lamclean! lamhalt!!!# stop LAM! 2006 UC Regents! 15!

Common MPI flavors on Rocks! 2006 UC Regents! 16!

MPI flavors path! /opt + MPI flavor + interconnect + compiler + bin/ + executable! MPICH + Ethernet + GNU!!!!/opt/mpich/ethernet/gnu/bin/! MPICH + Myrinet + GNU!!!/opt/mpich/myrinet/gnu/bin/! MPICH + Ethernet + INTEL!!!/opt/mpich/ethernet/intel/bin/! MPICH + Myrinet + INTEL!!!/opt/mpich/myrinet/intel/bin/! LAM + Ethernet + GNU!!!/opt/lam/ethernet/gnu/bin/! LAM + Myrinet + GNU!!!/opt/lam/myrinet/gnu/bin/! LAM + Ethernet + INTEL!!!/opt/lam/ethernet/intel/bin/! LAM + Myrinet + INTEL!!!/opt/lam/myrinet/intel/bin/!!!C:!mpicc!!C++:!mpiCC!!!F77:!mpif77!!F90:!mpif90! 2006 UC Regents! 17!

What provides MPI! 2006 UC Regents! 18!

Example 1: LAM hello! Execute all commands as a regular user! 1. Start ssh agent for key management! $ ssh-agent $SHELL! 2. Add your keys! $ ssh-add! (at prompt give your ssh passphrase)! 3. Make sure you have right mpicc:! $ which mpicc! (output must be /opt/lam/gnu/bin/mpicc)! 4. Create program source hello.c (see next page)! 2006 UC Regents! 19!

hello.c! #include "mpi.h"! #include <stdio.h>! int main(int argc,char *argv[])! {!!int myrank;!!mpi_init(&argc, &argv);!!mpi_comm_rank(mpi_comm_world, &myrank);!!fprintf(stdout, "Hello World, I am process %d\n", myrank);!!mpi_finalize();!!return 0;! }! 2006 UC Regents! 20!

Example 1 (contʼd)! 5. compile! $ mpicc -o hello hello.c! 6. create machines file with IPʼs of two nodes. Use your numbers here!! 198.202.156.1! 198.202.156.2! 7. start LAM! $ lamboot -v machines! 8. run your program! $ mpirun -np 2 -v hello! 9. clean after the run! $ lamclean -v! 10. stop LAM! $ lamhalt! 2006 UC Regents! 21!

Example1 output! $ ssh-agent $SHELL! $ ssh-add! Enter passphrase for /home/nadya/.ssh/id_rsa:! Identity added: /home/nadya/.ssh/id_rsa (/home/nadya/.ssh/id_rsa)! $ which mpicc! /opt/lam/gnu/bin/mpicc! $ mpicc -o hello hello.c! $ lamboot -v machines! LAM 7.1.1/MPI 2 C++/ROMIO - Indiana University! n-1<27213> ssi:boot:base:linear: booting n0 (rocks-155.sdsc.edu)! $ mpirun -np 2 -v hello! 27245 hello running on n0 (o)! 7791 hello running on n1! n-1<27213> ssi:boot:base:linear: booting n1 (10.255.255.254)! n-1<27213> ssi:boot:base:linear: finished! Hello World, I am process 0! Hello World, I am process 1! $ lamclean -v! killing processes, done! closing files, done! sweeping traces, done! cleaning up registered objects, done! sweeping messages, done! $ lamhalt! LAM 7.1.1/MPI 2 C++/ROMIO - Indiana University! 2006 UC Regents! 22!

Example 2: mpich cpi! 1. set your ssh keys as in example 1 (if not done already)! $ ssh-agent $SHELL! $ ssh-add! 2. copy example files to your working directory! $ cp /opt/mpich/gnu/examples/*.c.! $ cp /opt/mpich/gnu/examples/makefile.in.! 3. create Makefile! $ mpireconfig Makefile! 4. make sure you have right mpicc! $ which mpicc! If output lists path /opt/lam update the path:! $ export PATH=$/opt/mpich/gnu/bin:$PATH! 5. compile your program! $ make cpi! 6. run! $ mpirun -np 2 -machinefile machines cpi! or $ mpirun -nolocal -np 2 -machinefile machines cpi! 2006 UC Regents! 23!

Example 2 details! If using frontend and compute nodes in machines file use!!mpirun -np 2 -machinefile machines cpi! If using only compute nodes in machine file use!!mpirun -nolocal -np 2 -machinefile machines cpi! -nolocal - donʼt start job on frontend! -np 2 - start job on 2 nodes! -machinefile machines - nodes are specified in machinesfile! cpi - start program cpi! 2006 UC Regents! 24!

More examples! See CPU benchmark lab! how to run linpack! Additional examples in! /opt/mpich/gnu/examples! /opt/mpich/gnu/share/examples! 2006 UC Regents! 25!

Cleanup when an MPI Program Crashes! MPICH in Rocks uses shared memory segments to pass messages between processes on the same node! When an MPICH program crashes, it doesnʼt properly cleanup these shared memory segments! After a program crash, run:! $ cluster-fork sh /opt/mpich/gnu/sbin/cleanipcs! NOTE: this removes all shared memory segments for your user id! If you have other live MPI programs running, this will remove their shared memory segments too and cause that program to fail! 2006 UC Regents! 26!

Steps to combine SGE and MPI! 1. create SGE submit script! 2. run qsub command!!$ qsub runprog.sh!!$ qsub -pe mpich 32 runprog.sh! 3. check job status!!$ qstat -j! 2006 UC Regents! 27!

SGE submit script! Script contents! #!/bin/tcsh! #$ -S /bin/tcsh! setenv MPI=/path/to/MPI/binaries!! $MPI/mpirun -machinefile machines -np $NSLOTS appname! make it executable! $ chmod +x runprog.sh! 2006 UC Regents! 28!

Submit file options! # meet given resource request!!#$ -l h_rt=600! # specify interpreting shell for the job!!#$ -S /bin/sh! # use path for stadard output of job!!#$ -o path! # execute from current dir See man qsub for more options!!#$ -cwd! # run on 32 processes in mpich PE!!#$ -pe mpich 32! # Export all environmental variables!!#$ -V! # Export these environmental variables!!#$ -v MPI_ROOT,FOOBAR=BAR! 2006 UC Regents! 29!

Online resources! MPI standard:!!www-unix.mcs.anl.gov/mpi! Local Area Multicomputer MPI (LAM MPI):! www.osc.edu/lam.html! MPICH: www.mcs.anl.gov/mpi/mpich Aggregate Function MPI (AFMPI):! garage.ecn.purdue.edu/~papers Lam tutorial!www.lam-mpi.org/tutorials/one-step/lam.php 2006 UC Regents! 30!

Glossary! MPI - message passing interface! PVM - parallel virtual machine! LAM - local area multicomputer! P4-3rd generation parallel programming library, includes! message-passing and shared-memory components! Chameleon - high-performance portability package for!!! message passing on parallel supercomputers! Zipcode - portable system for writing of scalable libraries! ADI - abstract device architecture! 2006 UC Regents! 31!

Glossary (contʼd)! SIMD - Single Instruction Multiple Data! SPMD - Single Program Multiple Data! MIMD - Multiple Instruction Multiple Data! MPMD - Multiple Program Multiple Data! 2006 UC Regents! 32!