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 21. Students must come to class the next day prepared to discuss the material covered in this assignment.


Pre-Class Assignment: The Message Passing Interface (MPI)

Goals for today's pre-class assignment

  1. Distributed Memory Systems
  2. Quick Send / Recieve Example
  3. Initializing MPI job
  4. Basic Send/Recieve
  5. Finishing a job
  6. MPI Example
  7. Assignment wrap up

1. Distributed Memory Systems

QUESTION: In a Distributed Memory System we no longer can pass information though memory. How is data passed in a distributed memory system?

Put your answer here.


2. Quick Send / Recieve Example

A GPU does not do automatic memory caching like a CPU. Instead you need to do all of work for memory management yourself. The following video gives a brief overview of the concept of tiling.

QUESTION: In the example showed in the video there are four (4) processors. When the program is done, which processor has the final answer?

Put your answer here


3. Initializing MPI job

The following code initializes a typical MPI job. Read the MPI documentation and answer the questions.

int rank, size;

MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank); // Rank (ID) of this process
MPI_Comm_size(MPI_COMM_WORLD, &size); // Total size of MPI job

QUESTION: What is MPI_COMM_WORLD?

Put your answer here.

QUESTION: Where is the MPI_COMM_WORLD Defined?

Put your answer here.

QUESTION: It is possible to use something besides MPI_COMMM_WORLD, provide an example when this might be useful in your program?

Put your answer here.


4. Basic Send/Recieve

Read the following blog post provides a good descrtiption of how to use MPI Send/Recieve

http://mpitutorial.com/tutorials/mpi-send-and-receive/

int MPI_Send( void* data,
              int count,
              MPI_Datatype datatype,
              int destination,
              int tag,
              MPI_Comm communicator) 

int MPI_Recv( void* data,
              int count,
              MPI_Datatype datatype,
              int source,
              int tag,
              MPI_Comm communicator,
              MPI_Status* status)

Example Send and recieves:

MPI_Send(&processor_name,str_length,MPI_INT,0,1,MPI_COMM_WORLD);
MPI_Recv(&hostname[0][proc],str_length,MPI_INT,proc,1,MPI_COMM_WORLD,&status);

The types of data (and their C equivelents) are as follows.

MPI datatype C equivalent
MPI_SHORT short int
MPI_INT int
MPI_LONG long int
MPI_LONG_LONG long long int
MPI_UNSIGNED_CHAR unsigned char
MPI_UNSIGNED_SHORT unsigned short int
MPI_UNSIGNED unsigned int
MPI_UNSIGNED_LONG unsigned long int
MPI_UNSIGNED_LONG_LONG unsigned long long int
MPI_FLOAT float
MPI_DOUBLE double
MPI_LONG_DOUBLE long double
MPI_BYTE char

QUESTION: In the above example code, the MPI_INT data type is incorrect, which data type should be used instead?

Put your answer here.

QUESTION: Although MPI_INT is an error, why doesn't it cause a bug in the code?

Put your answer here.


5. Finishing a job

At the end of the program you need to include the MPI_Finalize function to close down all of the communication channels and clean up the program.

MPI_Finalize();

6. MPI Example

DO THIS: Use the getexample command to download the HelloMPI program and get it to compile and run on the HPCC.

QUESTION: Analyze the code (it is short). See if you can find the MPI related commands and try to figure out what they do. What are their inputs? What are their outputs? What do they do?

Put your observations here.

QUESTION: How far did you get with the MPI Example? Where did you get stuck?

Put your answer to the above question here


7. 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: Did you get the example to run on the HPCC? If not, where did you get stuck?

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.