Link to this document's Jupyter Notebook

In order to successfully complete this assignment you must do the required reading, watch the provided videos and complete all instructions. The embedded survey form must be entirely filled out and submitted on or before 11:59pm on Sunday March 28. Students must come to class the next day prepared to discuss the material covered in this assignment.


Pre-Class Assignment: MPI Errors

Goals for today's pre-class assignment

  1. At its core, MPI is Simple
  2. Error Handling In MPI
  3. More on MPI Tags
  4. Assignment wrap up

1. At its core, MPI is Simple

Remember that most MPI programs can be written using just these six functions, only two of which are non-trivial:

If you can remember these functions the rest is easy.


2. Error Handling In MPI

You should also do error handling in MPI some things to note are:

Parallel programs are hard to debug. It is always a good habit to activly manage errors.

DO THIS: Find a reference that explains how to handle errors in MPI.

QUESTION: What is the reference link you found on handling errors in MPI?

Put your answer to the above question here.

DO THIS: Review the following code we got to work on the HPCC last week. Add code to include errors handling.

/* Needed for printing */ 
    #include <stdio.h>          
    #include <stdlib.h>

    /* Get the MPI header file */
    #include <mpi.h>
    #include <unistd.h> 

    /* Max number of nodes to test */
    #define max_nodes 264  

    /* Largest hostname string hostnames */
    #define str_length 50       
    int main(int argc, char **argv)
    {
       /* Declare variables */
       int   proc, rank, size, namelen;
       int   ids[max_nodes];
       char  hostname[str_length][max_nodes];
       char  p_name[str_length];

       MPI_Status status;
       MPI_Init(&argc, &argv);
       MPI_Comm_rank(MPI_COMM_WORLD, &rank);
       MPI_Comm_size(MPI_COMM_WORLD, &size);
       MPI_Get_processor_name(p_name,&namelen);
    if (rank==0) {
       printf("Hello From: %s I am the receiving processor %d of %d\n",p_name, rank+1, size);
       for (proc=1;proc<size;proc++) {
          MPI_Recv(&hostname[0][proc], str_length,MPI_INT,proc, 1,MPI_COMM_WORLD,&status);
          MPI_Recv(&ids[proc], str_length,MPI_INT,proc, 2,MPI_COMM_WORLD,&status);
          printf("Hello From: %-20s I am processor %d of %d\n", &hostname[0][proc], ids[proc]+1, size);
       }
    } else { // NOT Rank 0
          srand(rank);
          int t = rand()%10+1;
          sleep(t);
          MPI_Send(&p_name,str_length, MPI_INT,0,1,MPI_COMM_WORLD);
          MPI_Send(&rank,str_length, MPI_INT,0,2,MPI_COMM_WORLD);
       }
       MPI_Finalize();

       return(0);
    }

QUESTION: Where you able to figure out how to get the error handling to work?

Put your answer to the above question here.

QUESTION: If so, what was most challenging/Interesting? If not, where did you get stuck?

Put your answer to the above question here.


3. More on MPI Tags

QUESTION: How many different tags are used in the above example?

Put your answer to the above question here.

QUESTION: How are the tags being used?

Put your answer to the above question here.


4. Assignment wrap up

Please fill out the form that appears when you run the code below. You must completely fill this out in order to receive credits for the assignment!

Direct Link to Google Form

If you have trouble with the embedded form, please make sure you log on with your MSU google account at googleapps.msu.edu and then click on the direct link above.

Assignment-Specific QUESTION: What is the reference link you found on handling errors in MPI?

Put your answer to the above question here

QUESTION: Summarize what you did in this assignment.

Put your answer to the above question here

QUESTION: What questions do you have, if any, about any of the topics discussed in this assignment after working through the jupyter notebook?

Put your answer to the above question here

QUESTION: How well do you feel this assignment helped you to achieve a better understanding of the above mentioned topic(s)?

Put your answer to the above question here

QUESTION: What was the most challenging part of this assignment for you?

Put your answer to the above question here

QUESTION: What was the least challenging part of this assignment for you?

Put your answer to the above question here

QUESTION: What kind of additional questions or support, if any, do you feel you need to have a better understanding of the content in this assignment?

Put your answer to the above question here

QUESTION: Do you have any further questions or comments about this material, or anything else that's going on in class?

Put your answer to the above question here

QUESTION: Approximately how long did this pre-class assignment take?

Put your answer to the above question here


Congratulations, we're done!

To get credit for this assignment you must fill out and submit the above survey from on or before the assignment due date.

Course Resources:

Written by Dr. Dirk Colbry, Michigan State University Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.