CSC630, Spring 2014 Assignment Single and Parallel Implementation of Game of Life
CSC630, Spring 2014 Assignment Single and Parallel Implementation of Game of Life
Assignment
Single and Parallel Implementation of Game of Life
A two-dimensional (2-D) binary cellular automaton consists of a two-dimensional m x n grid together
with an initial assignment of zeros and ones to cells of the grid and a next-state function for updating
the alues at the cells! "he updating function is applied simultaneously to all the cells! "he alue of the
next-state function at an indiidual cell will depend on the current alue at the grid point and eight
neighbors (four neighbors immediately aboe# below# to the right# and to the left of the cell# and the four
diagonally ad$acent neighbors% upper-left# upper-right# lower-left and lower-left neighbors)!
&ohn 'onway(s )ame of *ife (http%++en!wi,ipedia!org+wi,i+'onway-s.)ame.of.*ife) is a well-,nown
example! /n it# cells with ones are alie# while cells with zeroes are dead! 0pdating corresponds to
finding the next generation# and the new alue of a cell depends on all eight immediately ad$acent
neighbors! "he neighborhood for cells at the edges of the grid extends to the cells that wrap around the
grid (e!g! one of the neighbors of the first row# first column cell include the first row# last column and first
column last row)! "he rules are the following%
a! *iing cell with one or zero neighbors will die from loneliness!
b! *iing cells with two or three neighbors will surie into the next generation!
c! *iing cells with four or more neighbors will die from oercrowding!
d! 1mpty cells with exactly three neighbors will come to life!
2utside boarder of the m x n grid is dead in the sense that there is neer an organism in these
nonexistent cells! "he assignment brea,s down into 3arts
(4) 5rite a serial )ame of *ife program that simulates a 2-D binary cellular automaton using the
aboe rules and ma,e sure your implementation is correct! "he program should hae code to let
the user enter the maximum number of generations# the filename of a input text file that holds the
4 and 6 alues of the initial m7428 and n79: grid configuration and an output filename to hold
results of the cell alues of the subse;uent grid generations! <oweer# for program deelopment
this user interaction can be commented out and the number of generations# input filename and
output filename can be hardcoded! "he input file is proided for you and found at
+shared+dlewis+src+spring+gol.grid!txt! After each generation is computed# the program should
print a blan, line# then a line )eneration = where = is generation number and then a blan,
line! >ollowing that# the 2D grid for that generation should be printed to the output text file!
"here should be 466 generations performed! ?ut this number might increase if it appears it is
needed! @ou also need to calculate and print out the execution time for the program! Document
your code liberally!
(2) Design a parallel algorithm to modify the serial )ame of *ife algorithm into a parallel program
using A3/ collectie operations! 0se the same input information and generate the same output
information as the serial program did in part 4! Bun the program with 2# :# 8# 49# C2# and 9:
processors! Document the mean of the execution time for 46 runs of each of the number of
processors and store them in a spreadsheet!
(C) 5rite a report that describes how you designed and implement the parallel program! 0se the run
time in the spreadsheet to compute the same speed up information created for the dewpoint
program! Becommend the optimal number of processors for running this )ame of *ife program!
Submission% @ou will leae in your src+gol directory
(4) Dource code (' or 'EE) for the serial program called gol.single!c
(2) Dource code (' or 'EE with mpi function) for the parallel program called gol.multi!c
(C) "he output text file that stores all the generations of your 428 x 9: grids call gol.output.single!txt
and gol.output.multi!txt
1mail your report to Aar,!*ewisFusm!edu and use your student id E last name E gol!doc as its filename!
ue date% Due date for part 4 is 04!11!13
Due date for part 2 and C is 04!2"!13