Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.
-
Upload
sybil-stephens -
Category
Documents
-
view
241 -
download
0
Transcript of Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.
![Page 1: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/1.jpg)
Introduction to Parallel Programming
with C and MPI at MCSR
Part 2
Broadcast/Reduce
![Page 2: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/2.jpg)
Collective Message Passing
• Broadcast– Sends a message from one to all processes in the group
• Scatter– Distributes each element of a data array to a different
process for computation
• Gather– The reverse of scatter…retrieves data elements into an
array from multiple processes
![Page 3: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/3.jpg)
Collective Message Passing w/MPI
MPI_Bcast() Broadcast from root to all other processes
MPI_Gather() Gather values for group of processes
MPI_Scatter() Scatters buffer in parts to group of processes
MPI_Alltoall() Sends data from all processes to all processes
MPI_Reduce() Combine values on all processes to single val
MPI_Reduce_Scatter() Broadcast from root to all other processes
MPI_Bcast() Broadcast from root to all other processes
![Page 4: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/4.jpg)
Log in to mimosa & get workshop files
A. Use secure shell to login to mimosa using your assigned training account:
ssh [email protected] [email protected]
See lab instructor for password.
B. Copy workshop files into your home directory by running: /usr/local/apps/ppro/prepare_mpi_workshop
![Page 5: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/5.jpg)
Examine, compile, and execute add_mpi.c
![Page 6: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/6.jpg)
Examine, compile, and execute add_mpi.c
![Page 7: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/7.jpg)
Examine, compile, and execute add_mpi.c
![Page 8: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/8.jpg)
Examine, compile, and execute add_mpi.c
![Page 9: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/9.jpg)
Examine, compile, and execute add_mpi.c
![Page 10: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/10.jpg)
Examine, compile, and execute add_mpi.c
![Page 11: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/11.jpg)
Examine add_mpi.pbs
![Page 12: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/12.jpg)
Submit PBS Script: add_mpi.pbs
![Page 13: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/13.jpg)
Examine Output and Errors add_mpi.c
![Page 14: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/14.jpg)
Determine Speedup
![Page 15: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/15.jpg)
Determine Parallel Efficiency
![Page 16: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/16.jpg)
How Could Speedup/Efficiency Improve?
![Page 17: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/17.jpg)
What Happens to ResultsWhen MAXSIZE NotEvenly Divisible by n?
![Page 18: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/18.jpg)
Exercise 1:Change Code to Work When
MAXSIZE is Not EvenlyDivisible by n
![Page 19: Introduction to Parallel Programming with C and MPI at MCSR Part 2 Broadcast/Reduce.](https://reader035.fdocuments.net/reader035/viewer/2022062322/56649e9c5503460f94b9d38e/html5/thumbnails/19.jpg)
Exercise 2:Change Code to Improve Speedup