YCP Logo Assignment 2: Sorting or Like-Like Cellular Automaton

Algorithm sketch due: Tuesday, February 10th by 11:59 PM

Program due: Friday, February 27th by 11:59 PM

Updated: Feb 17th - benchmarking information, due date extended

Your Task

You have two choices: using pthreads,

  • Implement and benchmark a parallel sorting algorithm (suggestion: merge sort), or
  • Implement and benchmark a parallel implementation of a general Life-like cellular automaton

Life-Like Cellular Automaton

Life-like cellular automata (LLCA's) are a class of cellular automata similar to Conway's Game of Life.

LLCA's have the following properties:

  • They are represented as grids of cells, each cell being either alive or dead.
  • The automaton progresses as a series of generations.
  • To compute a new generation n + 1 from a previous generation n, the number of neighbors of each cell in generation n is computed. The neighbors of a cell at position i, j are the 8 cells surrounding it at positions
    • i - 1, j - 1
    • i, j - 1
    • i + 1, j - 1
    • i - 1, j
    • i + i, j
    • i - 1, j + 1
    • i, j + 1
    • i + 1, j + 1

To specify an arbitrary LLCA, we simply need to know two pieces of information:

  • How many neighbors a dead cell in generation n must have if it is to survive (remain alive) in generation n + 1
  • How many neighbors an alive cell in generation n must have if it is to be born (become alive) in generation n + 1

A standard notation describes these two properties. It has the form

S / B

where S is the numbers of neighbors allowing an alive cell to survive, and B is the numbers of neighbors allowing a dead cell to be born.

For example, Conway's Game of Life is denoted

23/3

because an alive cell with either 2 or 3 neighbors survives in the next generation, and a dead cell with exactly 3 neighbors is born in the next generation.

Input/Output Format

A grid of cells is specified in a text file as follows.

The overall format of the file is a sequence of integer values, separated by whitespace characters. (A whitespace character is any character for which the C isspace function returns a true value.)

The first two integers specify the number of columns and number of rows in the grid.

The remaining integers in the file specify pairs of (column, row) values denoting grid locations containing cells that are alive.

Requirements (Sorting)

Your program should take two command line arguments:

  • The first argument is the name of a binary input file containing 32 bit integer values.
  • The second argument is the name of an output file to which the sorted values should be written (as binary data).

When the program exits, the output file should contain all of the data values in the original file, in sorted order.

NOTE: it will probably be easier and better to have the program take a single filename on the command line, and change the contents of this file (by sorting its elements). Please see me in person so we can discuss your options.

The program should use 4 threads to perform the computation.

Requirements (LLCA)

The program should take four command line arguments:

  • The first argument is an input file in the format described above (see Input/Output Format above). The input file specifies the configuration of generation 0.
  • The second argument is the name of an output file to write.
  • The third argument is an integer specifying the number of generations to simulate.
  • The fourth argument is a character string specifying the rules to use: for example, "23/3" to use the original Conway's Game of Life rules.

The output file should specify the cells which are alive when the simulation completes. Use the same format as the input file.

The program should use 4 threads to perform the computation.

Algorithm Sketch

A sketch of your algorithm is due Tuesday, Feb 10th.

The sketch should describe:

  • How the overall problem will be divided into chunks that can be processed by worker threads.
  • What communication between threads will be required.
  • What algorithm will be executed by the worker threads.

Your sketch can be fairly high level, but it should be detailed enough that someone familiar with pthreads could turn it into a program.

Getting Started on the Program

Download CS497_Assign2.zip. Extract the contents of the archive into a directory.

Using a Unix shell, use the cd command to navigate into the directory containing the extracted contents.

Using a text editor, open the file assign2.c.

When you run the make command, all of the programs in this directory will be compiled.

Benchmarking

Run parallel and sequential versions of your program on problems of various sizes. Plot both running time and speedup of the program for varying numbers of threads on each problem size. Speedup is defined as

runningTime / sequentialTime

where sequentialTime is the amount of time required to run the program using a single thread. The ideal speedup for a parallel program run with n threads is n; in practice, you will most likely see a speedup somewhat less than n. In some cases, you may actually see a speedup of less than 1, meaning that the parallel version of the program executes more slowly than the sequential version of the program. Such is life.

You can download CS497_Assign2_LifeData.zip and extract it. It contains sample input files (of varying sizes) and expected output files the the Life-Like Cellular Automaton. You can use these files as the varying-size problems. See the file README_data.txt for more information.

If you are implementing the sorting algorithm, you can copy one of the data files in the /usr/local/share/cs497_data directory, and run your sorting program on that file. The files 256M.data, 512M.dat, and 1G.dat should be large enough to get interesting running times.

Note: if you are doing the parallel sorting option, then you will need to be careful that you measure computation time and not I/O time when you collect your timing data. Please see me to discuss your options.

Analysis

Examine your running times and speedups. Was the parallel version of the program faster or slower than the sequential version?

If you did not observe a speedup, try to determine why there was no speedup. Think about what factors might be limiting the parallelism achieved. Try some experiments: change the program, run it again, and see if the speedup improves.

Report

Write a report with the following information:

  • A brief sketch of your algorithm
  • The running time and speedup plots
  • A discussion of whether or not your program achieved a speedup, and if not, what experiments you performed to try to improve the parallel speedup, and the results of those experiments were

Also, include a spreadsheet with your benchmark data and plots.

Submitting

Algorithm Sketch

To submit the algorithm sketch: upload a text document to the Marmoset server as assign2sketch:

https://camel.ycp.edu:8443/

The text document should be in MS Word, OpenOffice, plain text, or PDF format.

Program, Report, and Benchmark Data

First, make sure a copy of your report and spreadsheet are in your assignment directory.

Note: Make sure that the assignment directory does NOT contain any large data files. These may make the submission to large to be uploaded to the server.

To submit, run the command

make submit

When prompted, enter your Marmoset username and password. You should see a message indicating that the submission was successfully uploaded to the server.

Important: You should log into the server and download your submitted files. Check to make sure that the files you submitted were the ones you intended. The server URL is

https://camel.ycp.edu:8443