Docsity

Lecture Notes on MPI - The Complete Reference | CS 843, Study notes of Computer Science

Partial preview of the text

Download Lecture Notes on MPI - The Complete Reference | CS 843 and more Study notes Computer Science in PDF only on Docsity!

MPI The Complete Reference

Scientic and Engineering Computation

Janusz Kowalik Editor

DataParal lel Programming on MIMD Computers by Philip J Hatcher and Michael J Quinn 

Unstructured Scientic Computation on Scalable Multiprocessors edited by Piyush Mehrotra Jo el Saltz and Rob ert Voigt 

Paral lel Computational Fluid Dynamics Implementations and Results edited by Horst D Simon 

Enterprise Integration Modeling Proceedings of the First International Conference edited by Charles J Petrie Jr 

The High Performance Fortran Handbook by Charles H Ko elb el David B Loveman Rob ert S Schreib er Guy L Steele Jr and Mary E Zosel 

Using MPI Portable Paral lel Programming with the MessagePassing Interface by William Gropp Ewing Lusk and Anthony Skjellum 

PVM Paral lel Virtual MachineA Users Guide and Tutorial for Network Paral lel Computing by Al Geist Adam Beguelin Jack Dongarra Weicheng Jiang Bob Manchek and Vaidy Sunderam 

Enabling Technologies for Petaops Computing by Thomas Sterling Paul Messina and Paul H Smith

An Introduction to HighPerformance Scientic Computing by Lloyd D Fosdick Elizab eth R Jessup Carolyn JC Schauble and Gitta Domik

Practical Paral lel Programming by Gregory V Wilson

MPI The Complete Reference by Marc Snir Steve Otto Steven HussLederman David Walker and Jack Don garra

c  Massachusetts Institute of Technology

All rights reserved No part of this b o ok may b e repro duced in any form by any electronic or mechanical means including photo copying recording or information storage and retrieval without p ermission in writing from the publisher

Parts of this b o ok came from MPI A Message Passing Interface Standard by the Message Passing Interface Forum That do cument is c the University of Tennessee These sections were copied by p ermission of the University of Tennessee

This b o ok was set in LaTEX by the authors and was printed and b ound in the United States of America

Library of Congress Catalog Card Numb er  

Contents

Series Foreword ix Preface xi

 Intro duction 

 The Goals of MPI 

 Who Should Use This Standard 

 What Platforms are Targets for Implementation 

 What is Included in MPI

 What is Not Included in MPI

 Version of MPI

 MPI Conventions and Design Choices

 Semantic Terms

 Language Binding 

 PointtoPoint Communication 

 Intro duction and Overview 

 Blo cking Send and Receive Op erations 

 Datatyp e Matching and Data Conversion 

 Semantics of Blo cking Pointtop oint 

 Example  Jacobi iteration 

 SendReceive 

 Null Pro cesses 

 Nonblo cking Communication 

 Multiple Completions

 Prob e and Cancel

 Persistent Communication Requests 

 CommunicationComplete Calls with Null Request Handles

 Communication Mo des 

 UserDened Datatyp es and Packing 

 Intro duction 

Contents vii

 Pro cess Top ologies  

 Intro duction    Virtual Top ologies    Overlapping Top ologies   Emb edding in MPI   Cartesian Top ology Functions   Graph Top ology Functions   Top ology Inquiry Functions    An Application Example  

Environmental Management 

 Implementation Information   Timers and Synchronization   Initialization and Exit   Error Handling   Interaction with Executing Environment 

The MPI Proling Interface 

 Requirements   Discussion   Logic of the Design   Examples   Multiple Levels of Interception 

Conclusions 

 Design Issues 

 Portable Programming with MPI 

 Heterogeneous Computing with MPI 

 MPI Implementations 

 Extensions to MPI 

Bibliography 

viii Contents

Index  Constants Index  Function Index 

Preface

MPI the Message Passing Interface is a standardized and p ortable message passing system designed by a group of researchers from academia and industry to function on a wide variety of parallel computers The standard denes the syntax and semantics of a core of library routines useful to a wide range of users writing p ortable messagepassing programs in Fortran or C Several welltested and ecient implementations of MPI already exist including some that are free and in the public domain These are b eginning to foster the development of a parallel software industry and there is excitement among computing researchers and vendors that the development of p ortable and scalable largescale parallel applications is now feasible The MPI standardization eort involved over  p eople from  organizations mainly from the United States and Europ e Most of the ma jor vendors of con current computers at the time were involved in MPI along with researchers from universities government lab oratories and industry The standardization pro cess b egan with the Workshop on Standards for Message Passing in a Distributed Mem ory Environment sp onsored by the Center for Research on Parallel Computing held April   in Williamsburg Virginia  A preliminary draft pro p osal known as MPI was put forward by Dongarra Hemp el Hey and Walker in Novemb er  and a revised version was completed in February   In Novemb er  a meeting of the MPI working group was held in Minneap olis at which it was decided to place the standardization pro cess on a more formal fo oting The MPI working group met every weeks throughout the rst  months of  The draft MPI standard was presented at the Sup ercomputing  conference in Novemb er  After a p erio d of public comments which resulted in some changes in MPI version  of MPI was released in June  These meetings and the email discussion together constituted the MPI Forum memb ership of which has b een op en to all memb ers of the high p erformance com puting community This b o ok serves as an annotated reference manual for MPI and a complete sp ecication of the standard is presented We rep eat the material already published in the MPI sp ecication do cument   though an attempt to clarify has b een made The annotations mainly take the form of explaining why certain design choices were made how users are meant to use the interface and how MPI implementors should construct a version of MPI Many detailed illustrative programming examples are also given with an eye toward illuminating the more advanced or subtle features of MPI The complete interface is presented in this b o ok and we are not hesitant to ex

MPI The Complete Reference

xiv Preface

 Chapter 

of the features of each system Though message passing is often thought of in the context of distributedmemory parallel computers the same co de can run well on a sharedmemory parallel computer It can run on a network of workstations or indeed as a set of pro cesses running on a single workstation Knowing that ecient MPI implementations exist across a wide variety of computers gives a high degree of exibility in co de development debugging and in cho osing a platform for pro duction runs Another typ e of compatibility oered by MPI is the ability to run transparently on heterogeneous systems that is collections of pro cessors with distinct archi tectures It is p ossible for an MPI implementation to span such a heterogeneous collection yet provide a virtual computing mo del that hides many architectural dif ferences The user need not worry whether the co de is sending messages b etween pro cessors of like or unlike architecture The MPI implementation will automat ically do any necessary data conversion and utilize the correct communications proto col However MPI do es not prohibit implementations that are targeted to a single homogeneous system and do es not mandate that distinct implementations b e interop erable Users that wish to run on an heterogeneous system must use an MPI implementation designed to supp ort heterogeneity Portability is central but the standard will not gain wide usage if this was achieved at the exp ense of p erformance For example Fortran is commonly used over assem bly languages b ecause compilers are almost always available that yield acceptable p erformance compared to the nonp ortable alternative of assembly languages A crucial p oint is that MPI was carefully designed so as to allow ecient implementa tions The design choices seem to have b een made correctly since MPI implemen tations over a wide range of platforms are achieving high p erformance comparable to that of less p ortable vendorsp ecic systems An imp ortant design goal of MPI was to allow ecient implementations across machines of diering characteristics For example MPI carefully avoids sp ecifying how op erations will take place It only sp ecies what an op eration do es logically As a result MPI can b e easily implemented on systems that buer messages at the sender receiver or do no buering at all Implementations can take advantage of sp ecic features of the communication subsystem of various machines On machines with intelligent communication copro cessors much of the message passing proto col can b e ooaded to this copro cessor On other systems most of the communication co de is executed by the main pro cessor Another example is the use of opaque ob jects in MPI By hiding the details of how MPIsp ecic ob jects are represented each implementation is free to do whatever is b est under the circumstances Another design choice leading to eciency is the avoidance of unnecessary work

Intro duction 

MPI was carefully designed so as to avoid a requirement for large amounts of extra information with each message or the need for complex enco ding or deco ding of message headers MPI also avoids extra computation or tests in critical routines since this can degrade p erformance Another way of minimizing work is to en courage the reuse of previous computations MPI provides this capability through constructs such as p ersistent communication requests and caching of attributes on communicators The design of MPI avoids the need for extra copying and buering of data in many cases data can b e moved from the user memory directly to the wire and b e received directly from the wire to the receiver memory MPI was designed to encourage overlap of communication and computation so as to take advantage of intelligent communication agents and to hide communication latencies This is achieved by the use of nonblo cking communication calls which separate the initiation of a communication from its completion Scalability is an imp ortant goal of parallel pro cessing MPI allows or supp orts scalability through several of its design features For example an application can create subgroups of pro cesses that in turn allows collective communication op er ations to limit their scop e to the pro cesses involved Another technique used is to provide functionality without a computation that scales as the numb er of pro cesses For example a twodimensional Cartesian top ology can b e sub divided into its onedimensional rows or columns without explicitly enumerating the pro cesses

Finally MPI as all go o d standards is valuable in that it denes a known mini mum b ehavior of messagepassing implementations This relieves the programmer from having to worry ab out certain problems that can arise One example is that MPI guarantees that the underlying transmission of messages is reliable The user need not check if a message is received correctly

  The Goals of MPI

The goal of the Message Passing Interface simply stated is to develop a widely used standard for writing messagepassing programs As such the interface should establish a practical p ortable ecient and exible standard for message passing A list of the goals of MPI app ears b elow

 Design an application programming interface Although MPI is currently used as a runtime for parallel compilers and for various libraries the design of MPI primarily reects the p erceived needs of application programmers  Allow ecient communication Avoid memorytomemory copying allow overlap

Intro duction 

executes a dierent co de It is also suitable for those written in the more restricted style of Single Program Multiple Data SPMD where all pro cesses follow the same execution path through the same program Although no explicit supp ort for threads is provided the interface has b een designed so as not to prejudice their use With this version of MPI no supp ort is provided for dynamic spawning of tasks such supp ort is exp ected in future versions of MPI see Section   MPI provides many features intended to improve p erformance on scalable parallel computers with sp ecialized interpro cessor communication hardware Thus we ex p ect that native highp erformance implementations of MPI will b e provided on such machines At the same time implementations of MPI on top of standard Unix inter pro cessor communication proto cols will provide p ortability to workstation clusters and heterogeneous networks of workstations Several proprietary native imple mentations of MPI and public domain p ortable implementation of MPI are now available See Section  for more information ab out MPI implementations

  What is Included in MPI

The standard includes

 Pointtop oint communication  Collective op erations  Pro cess groups  Communication domains  Pro cess top ologies  Environmental Management and inquiry  Proling interface  Bindings for Fortran and C

  What is Not Included in MPI

MPI do es not sp ecify

 Explicit sharedmemory op erations  Op erations that require more op erating system supp ort than was standard dur ing the adoption of MPI for example interruptdriven receives remote execution or active messages  Program construction to ols  Debugging facilities

 Chapter 

 Explicit supp ort for threads  Supp ort for task management  IO functions

There are many features that were considered and not included in MPI This happ ened for a numb er of reasons the time constraint that was selfimp osed by the MPI Forum in nishing the standard the feeling that not enough exp erience was available on some of these topics and the concern that additional features would delay the app earance of implementations Features that are not included can always b e oered as extensions by sp ecic implementations Future versions of MPI will address some of these issues see Section  

  Version of MPI

The original MPI standard was created by the Message Passing Interface Forum MPIF The public release of version  of MPI was made in June  The MPIF b egan meeting again in March   One of the rst tasks undertaken was to make clarications and corrections to the MPI standard The changes from version  to version  of the MPI standard were limited to corrections that were deemed urgent and necessary This work was completed in June  and version  of the standard was released This b o ok reects the up dated version  of the MPI standard

 MPI Conventions and Design Choices

This section explains notational terms and conventions used throughout this b o ok

 Do cument Notation

Rationale Throughout this do cument the rationale for design choices made in the interface sp ecication is set o in this format Some readers may wish to skip these sections while readers interested in interface design may want to read them carefully End of rationale

Advice to users Throughout this do cument material that sp eaks to users and illustrates usage is set o in this format Some readers may wish to skip these sections while readers interested in programming in MPI may want to read them carefully End of advice to users