Write an MPI program to simulate Conway's Game of Life cellular automaton. The program should take as input two values, m (the grid dimension, use an mxm grid) and k (the number of time steps). The...

1 answer below »
Write an MPI program to simulate Conway's Game of Life cellular automaton. The program should take as input two values, m (the grid dimension, use an mxm grid) and k (the number of time steps). The initial state of the system could be defined in the code. The m x m grid must be partitioned across multiple processes (i.e., each process is responsible for updating m x m/p grid values). Use MPI_Sendrecv for inter-process communication of boundary cells. Vary the number of MPI processes, and determine running time for different values of m (e.g., m = 5000, m = 10,000) and k (maybe 10, 100). Also, determine the time spent in inter-process communication.
What fraction of the overall running time is spent in inter-process communication? How does the code scale with increasing grid size and increasing MPI process concurrencies?


#include #include #include #include #include static double get_walltime() { struct timeval tp; gettimeofday(&tp, NULL); return ((double) (tp.tv_sec) + 1e-6 * tp.tv_usec); } int main(int argc, char **argv) { if (argc != 3) { printf("%s \n", argv[0]); printf("Program for parallel Game of Life\n"); printf("with 1D grid partitioning\n"); printf(": grid dimension (an mxm grid is created)\n"); printf(": number of time steps\n"); printf("(initial pattern specified inside code)\n"); exit(1); } unsigned long m, k; m = atol(argv[1]); k = atol(argv[2]); int *grid_current; int *grid_next; grid_current = (int *) malloc(m * m * sizeof(int)); if (grid_current == NULL) { printf("Error allocating memory for grid_current!\n"); exit(1); } grid_next = (int *) malloc(m * m * sizeof(int)); if (grid_next == NULL) { printf("Error allocating memory for grid_next!\n"); exit(1); } int i, j, t; /* static initalization, so that we can verify output */ /* using very simple initialization right now */ /* this isn't a good check for parallel debugging */ for (i=0; i
Answered 385 days AfterJan 18, 2021

Answer To: Write an MPI program to simulate Conway's Game of Life cellular automaton. The program should take...

Sathishkumar answered on Feb 08 2022
115 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here