Masterpraktikum - Scientific Computing, High Performance Computing

Similar documents
Masterpraktikum - Scientific Computing, High Performance Computing

Department of Informatics V. HPC-Lab. Session 4: MPI, CG M. Bader, A. Breuer. Alex Breuer

Topic Notes: Message Passing Interface (MPI)

Introduction to MPI, the Message Passing Library

MPI. (message passing, MIMD)

Distributed Memory Systems: Part IV

ECE 574 Cluster Computing Lecture 13

HPC Parallel Programing Multi-node Computation with MPI - I

Review of MPI Part 2

Message Passing Interface - MPI

Message Passing Interface

Message Passing Interface. most of the slides taken from Hanjun Kim

High-Performance Computing: MPI (ctd)

Parallel Computing MPI. Christoph Beetz. September 7, Parallel Computing. Introduction. Parallel Computing

CSE 613: Parallel Programming. Lecture 21 ( The Message Passing Interface )

Message Passing Interface

Message Passing Interface: Basic Course

Introduction to the Message Passing Interface (MPI)

Standard MPI - Message Passing Interface

Parallel programming MPI

Parallel Programming

Parallel Programming. Using MPI (Message Passing Interface)

Distributed Memory Programming with MPI

Practical Introduction to Message-Passing Interface (MPI)

Distributed Systems + Middleware Advanced Message Passing with MPI

Outline. Communication modes MPI Message Passing Interface Standard

Outline. Communication modes MPI Message Passing Interface Standard. Khoa Coâng Ngheä Thoâng Tin Ñaïi Hoïc Baùch Khoa Tp.HCM

High Performance Computing

MPI Tutorial. Shao-Ching Huang. High Performance Computing Group UCLA Institute for Digital Research and Education

Programming with MPI Collectives

Introduction to MPI. HY555 Parallel Systems and Grids Fall 2003

MPI Collective communication

MPI MESSAGE PASSING INTERFACE

Topics. Lecture 7. Review. Other MPI collective functions. Collective Communication (cont d) MPI Programming (III)

Intermediate MPI features

Practical Course Scientific Computing and Visualization

MPI - The Message Passing Interface

Practical Scientific Computing: Performanceoptimized

NUMERICAL PARALLEL COMPUTING

Practical Scientific Computing: Performanceoptimized

Message Passing Interface - MPI

15-440: Recitation 8

Non-Blocking Communications

MPI point-to-point communication

Non-Blocking Communications

Introduction to Parallel Programming

Parallel Programming, MPI Lecture 2

Basic MPI Communications. Basic MPI Communications (cont d)

Introduzione al Message Passing Interface (MPI) Andrea Clematis IMATI CNR

Introduction to MPI Part II Collective Communications and communicators

Message Passing with MPI

Working with IITJ HPC Environment

The MPI Message-passing Standard Practical use and implementation (V) SPD Course 6/03/2017 Massimo Coppola

Introduction to MPI. May 20, Daniel J. Bodony Department of Aerospace Engineering University of Illinois at Urbana-Champaign

L15: Putting it together: N-body (Ch. 6)!

CS 470 Spring Mike Lam, Professor. Distributed Programming & MPI

Communication Characteristics in the NAS Parallel Benchmarks

MPI 5. CSCI 4850/5850 High-Performance Computing Spring 2018

Recap of Parallelism & MPI

CS 470 Spring Mike Lam, Professor. Distributed Programming & MPI

Advanced Message-Passing Interface (MPI)

UNIVERSITY OF MORATUWA

MPI: Parallel Programming for Extreme Machines. Si Hammond, High Performance Systems Group

Agenda. MPI Application Example. Praktikum: Verteiltes Rechnen und Parallelprogrammierung Introduction to MPI. 1) Recap: MPI. 2) 2.

Scientific Computing

Introduction to MPI part II. Fabio AFFINITO

Programming Scalable Systems with MPI. Clemens Grelck, University of Amsterdam

MPI MESSAGE PASSING INTERFACE

COMP 322: Fundamentals of Parallel Programming. Lecture 34: Introduction to the Message Passing Interface (MPI), contd

MA471. Lecture 5. Collective MPI Communication

Introduction to MPI: Part II

Programming Using the Message Passing Paradigm

CS 426. Building and Running a Parallel Application

Collective Communications

Welcome to the introductory workshop in MPI programming at UNICC

Cluster Computing MPI. Industrial Standard Message Passing

Topics. Lecture 6. Point-to-point Communication. Point-to-point Communication. Broadcast. Basic Point-to-point communication. MPI Programming (III)

MPI MESSAGE PASSING INTERFACE

Parallel Computing Paradigms

Introduction to MPI. Ricardo Fonseca.

Message-Passing Computing

Collective Communication in MPI and Advanced Features

Praktikum: Verteiltes Rechnen und Parallelprogrammierung Introduction to MPI

Introduction to MPI Programming Part 2

First day. Basics of parallel programming. RIKEN CCS HPC Summer School Hiroya Matsuba, RIKEN CCS

A2 - Message Passing Interface (MPI)

Parallel Programming in C with MPI and OpenMP

Tutorial 2: MPI. CS486 - Principles of Distributed Computing Papageorgiou Spyros

INTRODUCTION TO MPI VIRTUAL TOPOLOGIES

Capstone Project. Project: Middleware for Cluster Computing

High Performance Computing Course Notes Message Passing Programming III

OpenMP and MPI parallelization

Programming SoHPC Course June-July 2015 Vladimir Subotic MPI - Message Passing Interface

Data parallelism. [ any app performing the *same* operation across a data stream ]

High Performance Computing Course Notes Message Passing Programming III

Lecture 9: MPI continued

Part - II. Message Passing Interface. Dheeraj Bhardwaj

Bryan Carpenter, School of Computing

More about MPI programming. More about MPI programming p. 1

. Programming Distributed Memory Machines in MPI and UPC. Kenjiro Taura. University of Tokyo

Transcription:

Masterpraktikum - Scientific Computing, High Performance Computing Message Passing Interface (MPI) and CG-method Michael Bader Alexander Heinecke Technische Universität München, Germany

Outline MPI Hello World P2P communication Collective operations Virtual topologies and communicators CG-method in a nutshell 2

Hello World #include <mpi.h> void main(int argc, char **argv){ int rank, size; MPI Init(&argc, &argv); MPI Comm rank(mpi COMM WORLD, &rank); MPI Comm size(mpi COMM WORLD, &size); printf("hello World! (rank %d of %d)", rank, size); MPI Finalize(); } compile mpicc -o hello hello.c execute mpirun -np number of processes./hello 3

Hello World #include <mpi.h> void main(int argc, char **argv){ int rank, size; MPI Init(&argc, &argv); MPI Comm rank(mpi COMM WORLD, &rank); MPI Comm size(mpi COMM WORLD, &size); printf("hello World! (rank %d of %d)", rank, size); MPI Finalize(); } int MPI Comm size(mpi Comm comm, int *size) Returns the number of processes in the communicator MPI COMM WORLD : Predefined standard communicator. Includes all processes of a parallel application. int MPI Comm rank(mpi Comm comm, int *size) Returns the process number of the executing process. 4

Point-to-Point Communication MPI Send(void *buf, int count, MPI Datatype datatype, int dest, int tag, MPI Comm communicator); MPI Recv(void *buf, int count, MPI Datatype datatype, int source, int tag, MPI Comm communicator, MPI Status *status); Blocking operations (return when buffer can be reused) rank (dest/source) and tag of send- and recieve-call must match Wildcards for recieve-calls MPI ANY SOURCE, MPI ANY TAG, MPI STATUS IGNORE Messages with same destination rank do not overtake each other (order preservation) 5

MPI Datatypes MPI datatype MPI CHAR MPI SHORT MPI INT MPI LONG MPI UNSIGNED CHAR MPI UNSIGNED... MPI FLOAT MPI DOUBLE C datatype signed char signed short int signed int signed long int unsigned char unsigned int float double 6

Point-to-Point Communication MPI Send(void *buf, int count, MPI Datatype datatype, int dest, int tag, MPI Comm communicator); MPI Recv(void *buf, int count, MPI Datatype datatype, int source, int tag, MPI Comm communicator, MPI Status *status); Blocking operations (return when buffer can be reused) rank (dest/source) and tag of send- and recieve-call must match Wildcards for recieve-calls MPI ANY SOURCE, MPI ANY TAG, MPI STATUS IGNORE Messages with same destination rank do not overtake each other (order preservation) 7

Point-to-Point Communication Example: ring.c... int rank, size, dest, src; double *s buf, *r buf; MPI Status status;... dest = (rank + 1) % size; src = (rank - 1 + size) % size; MPI Send(s buf,2,mpi DOUBLE,dest,0,MPI COMM WORLD); MPI Recv(r buf,2,mpi DOUBLE,src,0,MPI COMM WORLD,&status);... 8

Point-to-Point Communication Example: ring.c... int rank, size, dest, src; double *s buf, *r buf; MPI Status status;... dest = (rank + 1) % size; src = (rank - 1 + size) % size; MPI Send(s buf,2,mpi DOUBLE,dest,0,MPI COMM WORLD); MPI Recv(r buf,2,mpi DOUBLE,src,0,MPI COMM WORLD,&status);... Deadlock! 9

Non-blocking Communication MPI Isend(void *buf, int count, MPI Datatype datatype, int dest, int tag, MPI Comm communicator, MPI Request *request); MPI Irecv(void *buf, int count, MPI Datatype datatype, int source, int tag, MPI Comm communicator, MPI Request *request); Returns immediately Separates communication into three phases (1) initiate communication (2) do something else (3) wait for communication to complete MPI Request-object is used to test / wait for completition. 10

Non-blocking Communication MPI Wait(MPI Request *request, MPI Status *status); Waits until pending communication is finished. MPI Test(MPI Request *request, int *flag, MPI Status *status); Tests if pending communication is finished. Other routines MPI Waitall, MPI Testall MPI Waitany, MPI Testany MPI Waitsome, MPI Testsome 11

Collective Operations Three types of collective operations Synchronization (MPI Barrier,...) Communication (MPI Bcast,...) Reduction (MPI Allreduce,...) Must be executed by all processes of the communicator All collective operations are blocking operations MPI 3.0 will contain non-blocking collective operations 12

Collective Operations MPI Barrier (MPI Comm comm); Blocks until all processes of the communicator have reached the barrier. 13

Collective Operations MPI Bcast (void *buf, int count, MPI Datatype dtype, int root, MPI Comm comm); 14

Collective Operations MPI Gather(void *sendbuf, int sendcnt, MPI Datatype sendtype, void* recvbuf, int recvcnt, MPI Datatype recvtype, int root, MPI Comm comm); MPI Scatter(void *sendbuf, int sendcnt, MPI Datatype sendtype, void *recvbuf, int recvcnt, MPI Datatype recvtype, int root, MPI Comm comm); 15

Collective Operations MPI Alltoall(void *sendbuf, int sendcount, MPI Datatype sendtype, void *recvbuf, int recvcount, MPI Datatype recvtype, MPI Comm comm); 16

Collective Operations MPI Reduce (void* sbuf, void* rbuf, int count, MPI Datatype dtype,mpi Op op, int root, MPI Comm comm); Accumulates the elements in sbuf and delivers the results to process root. MPI Op is a Reduction Operation Handle. Possible values: MPI MAX (Maximum) MPI MIN (Minimum) MPI SUM (Sum) MPI PROD (Product) MPI BAND (Bitwise AND)... Similar routines: MPI Allreduce, MPI Reduce scatter 17

Virtual Topologies Processes of a communicator (e.g. MPI COMM WORLD) can be mapped to a Cartesian Topology a Graph Topology Allow convenient process naming with cartesian process coordinates. May lead to better performance (network aware programming). 18

Virtual Topologies MPI Cart create(mpi Comm comm old, int ndims, int *dims, int *periods, int reorder, MPI Comm *comm cart); Creates a communicator with cartesian topology MPI Cart sub(mpi Comm comm, int *remain dims, MPI Comm *newcomm); Cuts a grid up into slices. 19

Virtual Topologies MPI Cart rank(mpi Comm comm, int *coords, int *rank); Converts grid coordinates into process rank. MPI Cart coords(mpi Comm comm, int rank, int maxdims, int *coords); Returns the grid coordinates of process rank. 20

Other useful routines double MPI Wtime(); Returns the elapsed time on the calling processor 21

Resources MPI 2.2 Standard http://www.mpi-forum.org/docs/mpi-2.2/mpi22-report.pdf List of MPI routines http://mpi.deino.net/mpi functions/ 22

Solving Systems of Linear Equations 23

Solving Systems of Linear Equations Given: A x = b, A regular, b known Direct Methods Gauß LU Decomposition QR Decomposition Iterative Methods Splitting Methods (Jacobi, Gauß-Seidl, SOR) Projection Methods CG, GMRES, BiCGSTAB QR Decomposition 24

CG Method Method to solve SLEs with a symmetric, positive definite system matrix Details: An Introduction to the Conjugate Gradient Method Without the Agonizing Pain by Jonathan Richard Shewchuk Idea: Minimize: F(x) = 1 2 (Ax, x) (b, x) F(x) = 1 2 (A + AT )x b = Ax b Definition residual: r = b Ax i 25

CG Method - Code 26

Laplace Equation Here: x R 2 Solve: f ( x) = 0 we have Dirichlet boundary conditions we employ a regular full grid we do not construct the matrix, we use an implicitly given operator finite differences, e.g. in 1D: f (x) = f (x+h) 2 f (x)+ f (x h) h 2 27