#include #include #include #define N 20 int main(int argc, char* argv[]){ int my_id, num_procs; int i,j; int rem, num_local_row; int *matrix; int proc_up, proc_down; MPI_Status status1, status2; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD,&my_id); MPI_Comm_size(MPI_COMM_WORLD,&num_procs); /* numer of rows for each mpi task */ rem= N % num_procs; num_local_row = (N - rem)/num_procs; if(my_id < rem) num_local_row = num_local_row+1; matrix = (int*) malloc(((num_local_row+2)*N)*sizeof(int)); /* inizialization of the local matrix */ for(i=0; i