<jupyter_start><jupyter_text>[Link to this document's Jupyter Notebook](./0328--MPI_Errors_pre-class-assignment.ipynb) 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](At-its-core,-MPI-is-Simple)2. [Error Handling In MPI](Error-Handling-In-MPI)3. [More on MPI Tags](More-on-MPI-Tags)4. [Assignment wrap up](Assignment-wrap-up) --- 1. At its core, MPI is SimpleRemember that most MPI programs can be written using just these six functions, only two of which are non-trivial:* MPI_INIT* MPI_COMM_SIZE* MPI_COMM_RANK* MPI_SEND* MPI_RECV* MPI_FINALIZEIf you can remember these functions the rest is easy. --- 2. Error Handling In MPIYou should also do error handling in MPI some things to note are:* By default, an error causes all processes to abort (sometimes the message is not that helpful).* The user can cause routines to return (with an error code) instead.Parallel programs are hard to debug. It is always a good habit to activly manage errors.   &9989; **DO THIS:** Find a reference that explains how to handle errors in MPI.   &9989; **QUESTION:** What is the reference link you found on handling errors in MPI? Put your answer to the above question here. &9989; **DO THIS:** Review the following code we got to work on the HPCC last week.  Add code to include errors handling.  ```c++    /* Needed for printing */     include               include     /* Get the MPI header file */    include     include      /* 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);    }``` &9989; **QUESTION:** Where you able to figure out how to get the error handling to work? Put your answer to the above question here. &9989; **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* Messages are sent with an accompanying user-defined integer tag, to assist the receiving process in identifying the message.* Messages can be screened at the receiving end by specifying a specific tag, or not screened by specifying MPI_ANY_TAG as the tag in a receive.* Some non-MPI message-passing systems have called tags “message types”. MPI calls them tags to avoid confusion with datatypes. &9989; **QUESTION:** How many different tags are used in the above example? Put your answer to the above question here. &9989; **QUESTION:** How are the tags being used? Put your answer to the above question here. --- 4. Assignment wrap upPlease 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](https://cmse.msu.edu/cmse401-pc-survey)If you have trouble with the embedded form, please make sure you log on with your MSU google account at [googleapps.msu.edu](https://googleapps.msu.edu) and then click on the direct link above. &9989; **Assignment-Specific QUESTION:**  What is the reference link you found on handling errors in MPI? Put your answer to the above question here &9989; **QUESTION:**  Summarize what you did in this assignment. Put your answer to the above question here &9989; **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 &9989; **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 &9989; **QUESTION:** What was the **most** challenging part of this assignment for you?  Put your answer to the above question here &9989; **QUESTION:** What was the **least** challenging part of this assignment for you?  Put your answer to the above question here &9989; **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 &9989; **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 &9989; **QUESTION:** Approximately how long did this pre-class assignment take? Put your answer to the above question here<jupyter_code>from IPython.display import HTML
HTML(
"""
<iframe 
	src="https://cmse.msu.edu/cmse401-pc-survey" 
	width="100%" 
	height="500px" 
	frameborder="0" 
	marginheight="0" 
	marginwidth="0">
	Loading...
</iframe>
"""
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08997050147492626, 'fraction_numerical': 0.01982956407735169, 'mean_word_length': 3.990188062142273, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '428793', 'license': 'MIT', 'n_tokens_mistral': 1792, 'n_tokens_neox': 1667, 'n_words': 804, 'path': 'assignments/0328--MPI_Errors_pre-class-assignment.ipynb', 'repo_name': 'msu-cmse-courses/cmse401-S21-student', 'size': '6102'}