Supercomputing Applications
Lab 06 Report Form - MPI Programming 2, MPI_Send and MPI_Bcast

  1. Your name: __________________________________, Period: _____, Date __________

  2. What is the difference between a send and a broadcast in MPI (Message Passing)?
    In MPI these are MPI_Send and MPI_Bcast.
    For help see communication in parallel programming: Point to Point communication (send and receive) and One to All broadcast.
    Also view the images for a point to point message and a one to all broadcast.
    
    
    
    
    
    
    
    
    
    
    
    
    
  3. In a point to point communication in MPI, one node (processor) issues an MPI_Send message to another node that uses MPI_Recv to obtain the message.
    In the example MPI_Send (C version) command below, identify what each of the six parameters represents. ("&" in C means "address of"). For help see MPI Routines
    
    MPI_Send(&pi, count, MPI_DOUBLE, 0, 10, MPI_COMM_WORLD);
    
       List the meaning of each parameter -
       
       &pi:
    
       count:
    
       MPI_DOUBLE:
    
       0:
    
       10:
    
       MPI_COMM_WORLD: (see Constants in the MPI Routines link above)
    
    
    In the example MPI_Recv (C version) command below, identify what each of the parameters represents.
        MPI_Recv(&pi, 1, MPI_DOUBLE, 1, 10, MPI_COMM_WORLD, &status);
    
        &pi:
    
        count:
     
        MPI_DOUBLE:
    
        0:
    
        10:
    
        &status - for MPI_Status see the constants and scroll down to find MPI_Status 
    
        
    
  4. List sections of code in your program with the MPI_Send and MPI_Recv commands.
    
    
    
    
    
    
    
  5. Define the parameters in the MPI_Bcast below:
    
       MPI_Bcast(&pi, 1, MPI_DOUBLE, source, MPI_COMM_WORLD);
    
       &pi:
    
       1:
    
       source:
    
    
    
    
    In the code below, the MPI_Bcast is not in the if statement, so all of the processes see the MPI_Bcast.
    
    	count = 1;
    	source = 0;
    	if (rank == source) {
    		pi = M_PI;
    		printf("Rank %d is broadcasting %.10f\n", rank, pi);
    	}
    	
    	MPI_Bcast(&pi, 1, MPI_DOUBLE, source, MPI_COMM_WORLD);
    	if (rank != source) {
    	    printf("Rank %d receives %.10f from process %d\n", rank, pi, source);
    	}
    
        Question: How does a process know whether it is sending or receiving the value of pi?
    
    
    
  6. List the section of your program that accomplishes the broadcast in version 2 of Lab 06.
    
    
    
    
    
    
    
    
    
    
    
  7. Version 3 passes the value along from process to process in a ring fashion. List the section of your code that accomplishes this
    
    
    
    
    
    
    
    
  8. List sample outputs for versions 1-3:
    Version 1:
    
    
    
    
    
    
    
    Version 2:
    
    
    
    
    
    
    
    
    
    
    Version 3: