Max - Rows Send - Data - Tag Return - Data - Tag Max - Rows Max - Rows
Max - Rows Send - Data - Tag Return - Data - Tag Max - Rows Max - Rows
Partial Sum
#include <stdio.h>
#include <mpi.h>
int array[max_rows];
int array2[max_rows];
root_process = 0;
/* find out MY process ID, and how many processes were started. */
if(my_id == root_process) {
/* initialize an array */
sum = 0;
for(i = 0; i < avg_rows_per_process + 1; i++) {
sum += array[i];
}
/* and, finally, I collet the partial sums from the slave processes,
* print them, and add them to the grand sum, and print it */
sender = status.MPI_SOURCE;
sum += partial_sum;
}
else {
partial_sum = 0;
for(i = 0; i < num_rows_received; i++) {
partial_sum += array2[i];
}