Report Due: Thursday Feb 6 at the beginning of class
(turn in a hard copy of your report in class, and
push report.tex source to your Lab01 repo before 1:15pm)
Here is some documentation that I give to CS31 students about working with partners. It is a brief guide for good practices, and my expectations for how CS students should be working together on labs.
The coding part:
You and your partner will start with one of your solutions to the
CS31 pthreads GOL lab.
And also see the CS31 sequential GOL lab for
input file format and GOL rules. It is possible that
your pthreads gol lab may have had slightly different specifications than
this one from Fall'17, which is fine for your starting point for this lab.
If you used the ParaVisi gui animation in your lab, you will not need that feature
in this lab.
At a minimum you will change your CS31 code in the following ways (more details here):
The main part of this lab consists of:
mkdir cs87 mkdir cs87/labs cd cs87/labs
git clone [your_Lab01_URL]Then cd into your Lab01-you-partner subdirectory.
Makefile report.tex run.sh testedges.txtIf this didn't work, or for more detailed instructions on git see: the Using Git page (follow the instructions for repos on Swarthmore's GitHub Enterprise server).
Whichever one you are starting with (or if you want to start from scratch together that is fine too), copy the over pthreads gol.c (and any other .h or .c files) into your cs87 Lab01 repo to use as the starting point for this lab. Make sure the copied version compiles and runs (and fix the Makefile if not), then add these files you copied over to your git repo, commit, and push:
git add gol.c git add Makefile git add mytestfile.txt ... git commit git pushYour partner should now be able to do git pull to grab what you pushed to your shared repo.
You may also want to add to your repo config files that you may have from CS31 for initializing a GOL board (you can easily create new ones too, and you will want to create new ones for large scale experiments).
1 x 0 0 0 0 0 0 0 x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x 0 0 0 0 0 0 x 1 x 0 0 0 0 0 0 x x x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x 0 0 0 0 0 0 x 1 x 0 0 0You can test correctness with the testedges.txt file (patterns on edges should not wrap around the world across iterations).
# compile with -g for testing and debugging: gcc -g -Wall -Werror=vla -o gol gol.c -lpthread # with optimizations on -02, -g off for experiments: gcc -O2 -Wall -Werror=vla -o gol gol.c -lpthreadIf it doesn't, it means you have one or more functions in your program that use run-time variable sized array allocation on the stack. This is bad. Instead, space should be dynamically allocated on the heap (via malloc) and then passed into functions that need to use it. You should fix this.
./gol -t t { -n n -m m -k k [-s] | -f infile} [-x] [-c]
-t t: number of threads
-n n: number of rows in the game board
-m m: number of columns in the game board
-k k: number of iterations
-s: initialize to oscillator pattern (default is random)
-f infile: read in board config info from an input file
-x: disable ascii animation (printing out board every iteration)
(default is to run with animation/printing)
-c: do column partitioning (default is row portioning)
-h: print out this help message
This syntax for command line arguments supports command line arguments in any order and optional command line arguments. You will use
getopt to parse command line arguments (more details below).
The example getopt code uses a C switch statement. If you are not familiar with switch statments, see Chapter 2.9.1 switch statements in Dive Into Systems textbook.
NOTE: if your CS31 pthreads gol also included a run mode with a ParaVisi gui animation, you DO NOT need to support this run mode for this assignment. If you choose to leave it in, then you should add another command line option to enable this run mode (-g). Otherwise, remove the Paravisi gui code paths from your gol.c file. I suggest making this change before the others, and compile and test out your gol with the CS31 command line options, then commit these changes before doing the others.
There are two ways to run gol and initialize the game board:
./gol -t 16 -f infile # init to values read in from the file "infile"
./gol -t 4 -n 20 -m 30 -k 100 -s # init a 20x30 board to oscillator pattern
./gol -t 4 -n 20 -m 30 -k 100 # init a 20x30 board to random pattern
# about 25% of randomly selected cells
# to 1 works okay, but you decide
# use column-portioning across threads
The -t option is required and works with both initialization modes.
The -x and -c options are optional and work with either initialization mode. The -x option is necessary when running timed experiments. If the -f option is NOT used, then the board is initialized to one of two patterns:
#include<stdlib.h> #include<time.h> srand(time(NULL)); // call once in your program to seed rand num generator int val = rand(); // returns the next random number between 0 and RAND_MAXUse the random value in some function to decide if a cell is 1 or 0. The mod operator in C is % (e.g. 10 % 3 is 1) Be careful in your random init function to make sure you are not setting too large a proportion of the world's cell to live...all cells may die after a few iterations if the world is too overpopulated.
Here are some example command lines:
# initialize 20x30 board to an oscillator pattern, run with 8 threads # print out board to stdout after each iteration: ./gol -t 8 -n 20 -m 30 -k 100 -s # initialize program from data read in from "infile", run with 16 threads, # column partition, do not print any output to stdout for this run ./gol -t 16 -f infile -c -x # run with 4 threads, init board from file, row partition, do not print to stdout ./gol -t 4 -f infile -xYour program should handle badly formed command lines (e.g. print out an error message and exit instead of using incompatible or incomplete command line options).
You should run multiple runs of each experiment. For example, don't just do a single timed run of 16 threads for 512x512 and 10 iterations, but run this same experiment multiple times (5 or 10 times each). The purpose of multiple runs is to determine how consistent your times are (look at the standard deviation across runs), and to also see if you have some odd outliers (which may indicate that something else was running on the computer that interfered with a run, and that you should discard this result).
Be careful to control experimental runs as much as possible. If other people are using the machine you using to run experiments, their use can interfere with your results. Here are some resources to see what is going on on machines:
Also, make sure that the grid sizes are not too large to fit in RAM. I don't think this really will be a problem, but double check your a run with your largest sizes before running experiments to see if the system is swapping. To do this as you run, in another window run:
watch -n 1 cat /proc/swaps Filename Type Size Used Priority /dev/sda2 partition 2072344 0 -1If you notice the Used value going above 0, your grid sizes are too big to fit into RAM (or there are too many other memory intensive applications running on this machine), and you need to find an idle machine.
In addition, we have a few machines in the server room that are only for cs87 students. Use these for both your initial experiments, and some final experiements Each of these machines have 8 or 12 cores, you should share them all for testing, but I've assigned you each a "first choice" machine for your testing and experiment development to distribute the load. If a machine is down email `local-staff`, and again, you should all share these machines (the 12 node one in particular may be one that other teams will want to try out).
cardamom 8 : Gus and Ford crabby 8 : Christina and Lamia cucumber 8 : Keon and Jonathan elderberry 8 : Ayaka and Minh hyssop 8 : Rich and Brendan mint 8 : Haochen and Danielle parsley 8 : Kevin and Zach stew 8 : Kat and Kyra zucchini 12 : Sam and MickeyFor at least some, and possibly all, of your final experiment runs use chervil. You may use chervil to develop and test your set of experiments too, but please be mindful that all groups need some alone time on this machine for final experiment runs. I will likely set up a google signup sheet next week to reserve times to run your experiements alone on chervil.
chervil: is a physical 16 core, and 32 hyper-threaded "core", machine that only CS87 students have access to. This machine will provide an isolated platform for final experiment runs. Each group will need to take turns on this machine for running their final set of experiments, so as not to interfere with each other's results.
I'll add a google sign-up sheet for you to reserve some runtimes on chervil over the next week.
For running on lab machines, take a look at the Lab Machine specs page contains information about most of the CS lab machines, including the number of CPUs (click on the processors link). We have machines with 6-12 cores, and you have access to chervil with 16 physical cores and 32 hyper-threaded cores. Trying some experiements on machines with different numbers of cores.
As much as possible, it is good to run all of one set of your experiments on the same machine, or at least on identical machines. However, it may be intersting to see a few runs of the same problem size on machines with different numbers of cores.
Finally, be aware of other groups wanting to run experiments on the
8 and 12 node machines reserved for our class and on chervil.
So, please don't run experiments on a machine
for hours and hours or days and days. And, logout when you are not
using a machine to run experiments. You can run who to see
if someone is logged in, and run run top -H or htop to
help you guess/see if a machine is currently used,
before deciding it is okay for you to use to run super intensive
experiments. And please log out of CS lab machines when you are done using
them so that it is easier for others to tell if the machine really is
being used or someone just didn't logout and left atom and web browsers
running (this is the normal state in which you will find most CS lab machines,
and it is often difficult to tell if someone is actually using the machine when
you ssh into one...just check by running who and top, and guess as best
you can). And remember, for the machines reserved for 87, someone may be
logged out but running a lot of experiements in screen, so make
sure to run top for a minute or so to be certain it is not in use.
There is, however, a difference between negative results (well designed experiments that produce unexpected results) and bad results (results from poorly designed experiments).
Also, here is a nice description of strong and weak scalability. You do not need to present your result data in terms of strong and weak scalability functions. Speed-up (Sequential Time/Parallel Time), or even average run times (with stddev), over different axes of change may be more useful for this assignment. However, it may be useful to know the difference between these to when presenting or discussing some of your results in your report.
I also have an example program using getopts that you can copy over and try out:
cp -r ~newhall/public/getopts_example/* .
FILE *in;
in = fopen(input_file, "r");
if(in == NULL) {
perror("fopen failed. Exiting\n");
exit(1);
}
$ cat /proc/cpuinfo $ cat /proc/meminfo
To run a bash script file, first make sure the script file is executable:
ls -l # lists file permissions (rwx) x: means execute is setYou can set execute permission on a file using chmod:
chomd 700 testrun.sh # sets rwx permission for file ownerThen run the script at the unix prompt:
./testrun.shIt is often useful to redirect the output from these runs to a file. For, example to redirect stdout and stderr to a file named "resultfile":
./testrun.sh &> resultfile
Or to run your bash script inside script to capture its output to a file.
See bash shell programing links for more information.
$ script results Script started, file is results % ./run ... % exit Script done, file is results $ dos2unix -f results $ dos2unix -f resultsscreen is useful for running a long set of experiments: you can run scripts from within a screen session late at night, wake up the next morning re-attach to the screen session and see the results.
make clean git add gol.c report.tex ... git commit git push git status
See the Using git page "Troubleshooting" section for git help.