In order to successfully complete this assignment you need to participate both individually and in groups during class. Have one of the instructors check your notebook and sign you out before leaving class. Turn in your assignment using D2L.
ICA 28: MPI Programming Basics#

Agenda for today’s class (70 minutes)#
(20 minutes) Pre class Review
(30 minutes) Pi Estimation
(20 minutes) Rumor Mill continued
1. Pre class Review#
✅ DO THIS: Discuss the difference between blocking and non-blocking communication. Then discuss scenarios when you would want to use one over the other. Record a summary of your discussion.
2. Pi Estimation#
Lets go back and consider the pi estimation algorithm we used previously:
#include <omp.h>
static long num_steps = 100000; double step;
#define NUM_THREADS 2
void main ()
{
int i, nthreads; double pi, sum[NUM_THREADS];
step = 1.0/(double) num_steps;
omp_set_num_threads(NUM_THREADS);
#pragma omp parallel
{
int i, id,nthrds;
double x;
id = omp_get_thread_num();
nthrds = omp_get_num_threads();
if (id == 0) nthreads = nthrds;
for (i=id, sum[id]=0.0;i< num_steps; i=i+nthrds) {
x = (i+0.5)*step;
sum[id] += 4.0/(1.0+x*x);
}
}
for(i=0, pi=0.0;i<nthreads;i++)pi += sum[i] * step;
}
✅ DO THIS: Discuss the potential cons for moving this example to a Shared Network system.
✅ DO THIS: Take the above example and turn it into an MPI Only program.
3. Rumor Mill continued#
For the last few minutes of class revisit the rumor mill example and see if you can start making modifications to run the example inside mpi.
Congratulations, we’re done!#
Have one of the instructors check your notebook and sign you out before leaving class. Turn in your assignment using D2L.
Written by Dr. Dirk Colbry, Michigan State University (Updated by Dr. Nathan Haut in Spring 2025)
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.