MPI and High Performance Computing: Systems and Programming Barry Britt, Systems Administrator Department of Computer Science Iowa State University.

Slides:



Advertisements
Similar presentations
MPI Basics Introduction to Parallel Programming and Cluster Computing University of Washington/Idaho State University MPI Basics Charlie Peck Earlham College.
Advertisements

CS 140: Models of parallel programming: Distributed memory and MPI.
Chapter 3. MPI MPI = Message Passing Interface Specification of message passing libraries for developers and users –Not a library by itself, but specifies.
Tutorial on MPI Experimental Environment for ECE5610/CSC
High Performance Computing
MPI Program Structure Self Test with solution. Self Test 1.How would you modify "Hello World" so that only even-numbered processors print the greeting.
Point-to-Point Communication Self Test with solution.
CS 240A: Models of parallel programming: Distributed memory and MPI.
Distributed Memory Programming with MPI. What is MPI? Message Passing Interface (MPI) is an industry standard message passing system designed to be both.
12b.1 Introduction to Message-passing with MPI UNC-Wilmington, C. Ferner, 2008 Nov 4, 2008.
Lecture 8 Objectives Material from Chapter 9 More complete introduction of MPI functions Show how to implement manager-worker programs Parallel Algorithms.
MPI (Message Passing Interface) Basics
Basics of Message-passing Mechanics of message-passing –A means of creating separate processes on different computers –A way to send and receive messages.
ORNL is managed by UT-Battelle for the US Department of Energy Crash Course In Message Passing Interface Adam Simpson NCCS User Assistance.
Director of Contra Costa College High Performance Computing Center
Bigben Pittsburgh Supercomputing Center J. Ray Scott
2.1 Message-Passing Computing ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, Jan 17, 2012.
1 MPI: Message-Passing Interface Chapter 2. 2 MPI - (Message Passing Interface) Message passing library standard (MPI) is developed by group of academics.
2.1 Message-Passing Computing ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, Jan 14, 2013.
MA471Fall 2003 Lecture5. More Point To Point Communications in MPI Note: so far we have covered –MPI_Init, MPI_Finalize –MPI_Comm_size, MPI_Comm_rank.
An Introduction to Parallel Programming and MPICH Nikolaos Hatzopoulos.
CS 240A Models of parallel programming: Distributed memory and MPI.
Introduction to Parallel Programming with C and MPI at MCSR Part 1 The University of Southern Mississippi April 8, 2010.
Introduction to Parallel Programming with C and MPI at MCSR Part 1 MCSR Unix Camp.
Parallel Programming with MPI Prof. Sivarama Dandamudi School of Computer Science Carleton University.
Message Passing Programming with MPI Introduction to MPI Basic MPI functions Most of the MPI materials are obtained from William Gropp and Rusty Lusk’s.
CS 838: Pervasive Parallelism Introduction to MPI Copyright 2005 Mark D. Hill University of Wisconsin-Madison Slides are derived from an online tutorial.
Message Passing Programming Model AMANO, Hideharu Textbook pp. 140-147.
Performance Oriented MPI Jeffrey M. Squyres Andrew Lumsdaine NERSC/LBNL and U. Notre Dame.
MPI Introduction to MPI Commands. Basics – Send and Receive MPI is a message passing environment. The processors’ method of sharing information is NOT.
An Introduction to Parallel Programming with MPI March 22, 24, 29, David Adams
Parallel Programming with MPI By, Santosh K Jena..
MA471Fall 2002 Lecture5. More Point To Point Communications in MPI Note: so far we have covered –MPI_Init, MPI_Finalize –MPI_Comm_size, MPI_Comm_rank.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, ©
CSCI-455/522 Introduction to High Performance Computing Lecture 4.
1 Message Passing Models CEG 4131 Computer Architecture III Miodrag Bolic.
Introduction to MPI CDP 1. Shared Memory vs. Message Passing Shared Memory Implicit communication via memory operations (load/store/lock) Global address.
Introduction to MPI Nischint Rajmohan 5 November 2007.
Programming distributed memory systems: Message Passing Interface (MPI) Distributed memory systems: multiple processing units working on one task (e.g.
An Introduction to MPI (message passing interface)
1 HPCI Presentation Kulathep Charoenpornwattana. March 12, Outline Parallel programming with MPI Running MPI applications on Azul & Itanium Running.
Introduction to Parallel Programming at MCSR Message Passing Computing –Processes coordinate and communicate results via calls to message passing library.
Introduction to HPC Workshop October Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
Message Passing Interface (MPI) 2 Amit Majumdar Scientific Computing Applications Group San Diego Supercomputer Center Tim Kaiser (now at Colorado School.
1 Running MPI on “Gridfarm” Bryan Carpenter February, 2005.
Project18 Communication Design + Parallelization Camilo A Silva BIOinformatics Summer 2008.
Timing in MPI Tarik Booker MPI Presentation May 7, 2003.
Chapter 5. Nonblocking Communication MPI_Send, MPI_Recv are blocking operations Will not return until the arguments to the functions can be safely modified.
3/12/2013Computer Engg, IIT(BHU)1 MPI-1. MESSAGE PASSING INTERFACE A message passing library specification Extended message-passing model Not a language.
1 Parallel and Distributed Processing Lecture 5: Message-Passing Computing Chapter 2, Wilkinson & Allen, “Parallel Programming”, 2 nd Ed.
Message Passing Interface Using resources from
Lecture 3 Point-to-Point Communications Dr. Muhammad Hanif Durad Department of Computer and Information Sciences Pakistan Institute Engineering and Applied.
1 Programming distributed memory systems Clusters Distributed computers ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, Jan 6, 2015.
Parallel Programming C. Ferner & B. Wilkinson, 2014 Introduction to Message Passing Interface (MPI) Introduction 9/4/
PVM and MPI.
MPI Basics.
MPI Message Passing Interface
Computer Systems and Networks
CS 584.
Introduction to Message Passing Interface (MPI)
Message Passing Models
May 19 Lecture Outline Introduce MPI functionality
Pattern Programming Tools
Parallel Processing Dr. Guy Tel-Zur.
Introduction to parallelism and the Message Passing Interface
MPI MPI = Message Passing Interface
Hello, world in MPI #include <stdio.h> #include "mpi.h"
Hello, world in MPI #include <stdio.h> #include "mpi.h"
MPI Message Passing Interface
Some codes for analysis and preparation for programming
Presentation transcript:

MPI and High Performance Computing: Systems and Programming Barry Britt, Systems Administrator Department of Computer Science Iowa State University

Purpose To give you: … an overview of some new system-level MPI functions … access to tools that you need to compile and run MPI jobs … some instruction in the creation and use of Makefiles … some instruction on how to tell time in C programs.

Makefiles

GNU Make  Enables the end user to build and install a package without worrying about the details.  Automatically figures out which files it needs to update based on which source files have changed.  Not language dependent  Not limited to building a package; can be used to install or uninstall

Makefile Rules A rule tells Make how to execute a series of commands in order to build a target from source files. Specifies a list of dependancies Dependancies should include ALL files that are dependancies for a target target: dependancies.... commands...

Example Makefile for C Source CC=gcc CFLAGS=-Wall INCLUDES= BINARIES=rand test.SUFFIXES:.c.o.c.o: $(CC) $(CFLAGS) -c $*.c all: $(BINARIES) rand.o: rand.c test.o: test.c rand: rand.o $(CC) $(CFLAGS) -o rand rand.o test: test.o $(CC) $(CFLAGS) -o test test.o clean: rm -f a.out core *.o $(BINARIES)

Example Makefile for C Source CC=gcc CFLAGS=-Wall INCLUDES= BINARIES=rand test Variables  CC is set to use the GCC compiler For MPI programs, set it to mpicc, not gcc  CFLAGS: -c:compile -Wall:set warnings to all

Example Makefile for C Source Target “clean”. Use by typing  make clean Rule states:  In my current directory, run: rm -f a.out core *.o $(BINARIES) rm -f a.out core *.o rand test clean: rm -f a.out core *.o $(BINARIES)

Example Makefile for C Source Makefile instruction on how to handle.c files and turn them into object (.o) files  Compile using $(CC) value with $(CFLAGS)  Compile each individual file into its appropriate.o file.SUFFIXES:.c.o.c.o: $(CC) $(CFLAGS) -c $*.c

Example Makefile for C Source Target: rand or test  Run $(CC) $(CFLAGS) -o rand rand.o  gcc -Wall -o rand rand.o If you were going to include external libraries to link, they would be linked at the end of the rule. rand.o:rand.c test.o: test.c rand:rand.o $(CC) $(CFLAGS) -o rand rand.o test:test.o $(CC) $(CFLAGS) -o test test.o

Random Matrix Generation

Random Generator for Matrices Rand  -f:filename to which to write the matrix  -c:number of matrix columns  -r:number of matrix rows  -h:help documentation  -s:seed  -m:max integer in matrix cells

Random Generator for Matrices Completely random generation for an m by n matrix Uses a random seed to create the matrix Output file  First line contains the number of rows and the number of columns  Subsequent lines contain matrix cell values, one per line.

Random Generator for Matrices For a Matrix with row length m, cell A[i,j] is on line:  m * i + j + 2  Lines are not zero-indexed for the purpose of this calculation. Therefore, for a 5 x 5 matrix (zero-indexed):  A[0, 0] is on line 2  A[0, 1] is on line 3  A[4, 4] is on line 26  A[2, 3] is on line 15

Calculating Run Time in C

Calculating Running Time in C #include int main() { struct timeval begin, end; double time; gettimeofday(&begin, NULL); sleep(10); gettimeofday(&end, NULL); time = (end.tv_sec - begin.tv_sec) +((end.tv_usec - begin.tv_usec) / ); printf("This program ran for %f seconds\n", time); return 0; }

C Time Includes seconds and microseconds Used by the gettimeofday() system call gettimeofday()  Returns the number of seconds (and microseconds) since the UNIX Epoch Is this completely accurate?  No, but it's VERY close (within a few microseconds).

C Time You MUST use the timeval struct for the gettimeofday() call On UNIX systems, you need to include sys/time.h to use this. Calculation of time is: (end seconds – begin seconds) + ((end microseconds – begin microseconds) / ) You can calculate:  Program run time  Algorithm execution time

Using the PBS Job Submission System

PBS (Torque/Maui) hpc-class job submission system qsub All queues are managed by the scheduler. PBS scripts can be created at: 

Example script #!/bin/csh #PBS -o BATCH_OUTPUT #PBS -e BATCH_ERRORS #PBS -lvmem=256Mb,pmem=256Mb,mem=256Mb,nodes=16:ppn=2,cput=2:00:00,walltime=1:00:00 # Change to directory from which qsub was executed cd $PBS_O_WORKDIR time mpirun -np 32

PBS Variables -l (resources)  vmem: total virtual memory  pmem: per task memory  mem: total aggregate memory  nodes – total number of nodes  ppn – processors per node  cput – CPU time  walltime – total time for all CPUs

PBS Variables vmem = pmem = mem total CPUs = nodes * ppn cput = walltime * ppn

PBS (Torque/Maui) Based on the previous script  BATCH_OUTPUT contains the output from the batch job  BATCH_ERRORS contains the error information from the batch job

Some other important information Max CPU – 32 for classwork Max memory – 2.0 GB Max swap – 2.0 GB Short queue -  4 nodes per job; 16 total CPUs  1 hour per job  2 total jobs per user

MPI Blocking vs. Non-Blocking Communication

MPI Communication Blocking Communication:  MPI_Send  MPI_Recv MPI_Send → Basic blocking send operation. Routine returns only after the application buffer in the sending task is free for reuse. MPI_Recv → Receive a message and block until the requested data is available in the application buffer in the receiving task.

MPI Communication Non-blocking Communication  MPI_Isend | MPI_Irecv  MPI_Wait | MPI_Test MPI_Isend → Identifies an area in memory to serve as a send buffer. Processing continues without waiting for the message to be copied out from the buffer. MPI_Irecv → Identifies an area in memory to serve as a receive buffer. Processing continues immediately without waiting for the message to be received and copied into the the buffer. MPI_Test → check the status of a non-blocking send or receive MPI_Wait → block until a specified non-blocking send or receive operation has completed

Why non-blocking communication? In some cases, it can increase performance. If there is an expensive operation you need to do, it helps speed up the program  Disk I/O  Heavy processing on already received data BE CAREFUL!!!  If you try to access a buffer when it isn't there, your program WILL fail.

int main (int argc, char **argv) { int myRank; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &myRank); if (myRank == 0) master(); else slave(); MPI_Finalize(); return 0; } int master() { int i, size, my_answer = 0, their_work = 0; MPI_Status status; MPI_Comm_size(MPI_COMM_WORLD, &size); for (i = 1; i < size; i++) { MPI_Recv ( &their_work, 1, MPI_INT, i, TAG, MPI_COMM_WORLD, &status); my_answer += their_work; } printf("The answer is: %d\n", my_answer); return 0; }

int slave() { int i, myRank, size, namelength, work = 0; char name[MPI_MAX_PROCESSOR_NAME]; MPI_Comm_rank(MPI_COMM_WORLD, &myRank); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Get_processor_name(name, &namelength); printf("[%s]: Adding the nubmers %d to %d = ", name, (100 / (size-1)) * (myRank-1) + 1, (100 / (size-1)) * myRank); for (i = (100 / (size-1)) * (myRank-1) + 1; i <= myRank * (100 / (size-1)); i++) { work = work + i; } printf("%d\n", work); MPI_Send(&work, 1, MPI_INT, 0, TAG, MPI_COMM_WORLD); return 0; }