Difference between revisions of "CSC352 Homework 3 2017"
(→Additional Information) |
(→Additional Information) |
||
(14 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
---- | ---- | ||
<br /> | <br /> | ||
− | =Game of Life on | + | =Game of Life in MPI on AWS= |
<br /> | <br /> | ||
+ | <bluebox> | ||
+ | The due date for this assignment is April 20th, 2017, midnight. | ||
+ | </bluebox> | ||
==Question== | ==Question== | ||
<br /> | <br /> | ||
− | How | + | How large an MPI cluster do you need on AWS to gain a speedup greater than 1.0 for the Game of Life evolving for 3000 generations on a dish of 10,000 lines, where each line is 80 characters long? |
<br /> | <br /> | ||
<br /> | <br /> | ||
Line 17: | Line 20: | ||
==Additional Information== | ==Additional Information== | ||
<br /> | <br /> | ||
− | You may find this [[Game_of_Life_in_C_and_MPI| 2-Node, Game of Life, MPI code | + | # You may find this [[Game_of_Life_in_C_and_MPI| 2-Node, Game of Life, MPI code]] a good way to get started. |
+ | # You are allowed to use the Hadoop01/02/03/04 cluster if you run into too much trouble connecting to AWS. | ||
+ | # There is a better way to go from an ''N'' to an ''N+1''-node cluster than turning the ''N''-node cluster off, and starting a new ''(N+1)''-node cluster. Just grow your cluster by one node (or more) at a time with the [http://star.mit.edu/cluster/docs/0.93.3/manual/addremovenode.html '''addnode'''] starcluster-command. Check it out. | ||
<br /> | <br /> | ||
− | == | + | ==Recommendation== |
<br /> | <br /> | ||
+ | Run your program on your laptop (if you have installed MPI on it) or aurora first, while you are debugging it. Only when you are satisfied that your program runs correctly, should you port it to AWS. Since AWS charges by the hour, it is not worth paying for debugging time! | ||
<br /> | <br /> | ||
+ | ==Creating a 10,000-line Dish Array== | ||
+ | <br /> | ||
+ | You may want to use the function createDish() illustrated in the code below to create a dish of 10,000 lines. | ||
+ | <br /> | ||
+ | ::<source lang="C"> | ||
+ | /* | ||
+ | initDish.c | ||
+ | D. Thiebaut | ||
+ | |||
+ | Demo program for generating a dish with N lines, | ||
+ | where N is provided by the user, and where a pattern | ||
+ | of cell is repeated many times until N lines have | ||
+ | been created in the dish array. | ||
+ | The function createDish returns an array of N strings | ||
+ | where the strings are repetitions of the pattern stored | ||
+ | in the array pattern[]. | ||
+ | |||
+ | To compile and run: | ||
+ | |||
+ | gcc -o initDish initDish.c | ||
+ | ./initDish | ||
+ | |||
+ | */ | ||
+ | #include <stdio.h> | ||
+ | #include <stdlib.h> | ||
+ | #include <string.h> | ||
+ | |||
+ | char* pattern[] = { " ", | ||
+ | " # ", | ||
+ | " # # ### ", | ||
+ | " ## ", | ||
+ | " ", | ||
+ | " # ", | ||
+ | " # # ", | ||
+ | " ## ", | ||
+ | " ", | ||
+ | " ", | ||
+ | " ", | ||
+ | " ", | ||
+ | " # ", | ||
+ | " # # ", | ||
+ | " ## ", | ||
+ | " ", | ||
+ | " ", | ||
+ | " " }; | ||
+ | |||
+ | |||
+ | // createDish() | ||
+ | // input: N: the number of lines we want in dish. | ||
+ | // output: dish: an array of N lines, each line being taken | ||
+ | // from the array pattern, in a rotating manner. | ||
+ | char** createDish( int N ) { | ||
+ | int i; | ||
+ | int patternLength = sizeof( pattern )/sizeof( char * ); | ||
+ | char **dish; | ||
+ | |||
+ | //--- create an array of N strings --- | ||
+ | dish = (char **) malloc( N * sizeof( char * ) ); | ||
+ | |||
+ | //--- create N strings and "attach" them to an entry in --- | ||
+ | //--- dish. Copy one of the lines from pattern into the newly --- | ||
+ | //--- created string. --- | ||
+ | for ( i=0; i<N; i++ ) { | ||
+ | dish[i] = (char *) malloc( ( strlen( pattern[0] )+1 )*sizeof( char ) ); | ||
+ | strcpy( dish[i], pattern[i % patternLength ] ); | ||
+ | } | ||
+ | |||
+ | //--- return the fully populated array of N strings --- | ||
+ | return dish; | ||
+ | } | ||
+ | |||
+ | |||
+ | // ================================================================= | ||
+ | // MAIN: | ||
+ | // Creates a dish array of 40 lines and displays it. | ||
+ | // ================================================================= | ||
+ | |||
+ | int main( int argc, char** argv ) { | ||
+ | int i, N, length; | ||
+ | char** dish; | ||
+ | |||
+ | //--- define the number of lines wanted --- | ||
+ | N = 40; | ||
+ | |||
+ | //--- create an array of N lines --- | ||
+ | dish = createDish( N ); | ||
+ | |||
+ | //--- display it on the screen --- | ||
+ | for (i=0; i < N; i++ ) | ||
+ | printf( "%s\n", dish[i] ); | ||
+ | |||
+ | } | ||
+ | </source> | ||
<br /> | <br /> | ||
<br /> | <br /> |
Latest revision as of 03:34, 9 April 2017
--D. Thiebaut (talk) 15:26, 5 April 2017 (EDT)
Contents
Game of Life in MPI on AWS
The due date for this assignment is April 20th, 2017, midnight.
Question
How large an MPI cluster do you need on AWS to gain a speedup greater than 1.0 for the Game of Life evolving for 3000 generations on a dish of 10,000 lines, where each line is 80 characters long?
Test your program(s) on AWS for various size clusters, and submit a zip file containing:
- the C and MPI programs you will have written,
- any shell file you will have written to help answer the question,
- and a pdf showing the details of your analysis, including the timing of your code AWS.
Additional Information
- You may find this 2-Node, Game of Life, MPI code a good way to get started.
- You are allowed to use the Hadoop01/02/03/04 cluster if you run into too much trouble connecting to AWS.
- There is a better way to go from an N to an N+1-node cluster than turning the N-node cluster off, and starting a new (N+1)-node cluster. Just grow your cluster by one node (or more) at a time with the addnode starcluster-command. Check it out.
Recommendation
Run your program on your laptop (if you have installed MPI on it) or aurora first, while you are debugging it. Only when you are satisfied that your program runs correctly, should you port it to AWS. Since AWS charges by the hour, it is not worth paying for debugging time!
Creating a 10,000-line Dish Array
You may want to use the function createDish() illustrated in the code below to create a dish of 10,000 lines.
/* initDish.c D. Thiebaut Demo program for generating a dish with N lines, where N is provided by the user, and where a pattern of cell is repeated many times until N lines have been created in the dish array. The function createDish returns an array of N strings where the strings are repetitions of the pattern stored in the array pattern[]. To compile and run: gcc -o initDish initDish.c ./initDish */ #include <stdio.h> #include <stdlib.h> #include <string.h> char* pattern[] = { " ", " # ", " # # ### ", " ## ", " ", " # ", " # # ", " ## ", " ", " ", " ", " ", " # ", " # # ", " ## ", " ", " ", " " }; // createDish() // input: N: the number of lines we want in dish. // output: dish: an array of N lines, each line being taken // from the array pattern, in a rotating manner. char** createDish( int N ) { int i; int patternLength = sizeof( pattern )/sizeof( char * ); char **dish; //--- create an array of N strings --- dish = (char **) malloc( N * sizeof( char * ) ); //--- create N strings and "attach" them to an entry in --- //--- dish. Copy one of the lines from pattern into the newly --- //--- created string. --- for ( i=0; i<N; i++ ) { dish[i] = (char *) malloc( ( strlen( pattern[0] )+1 )*sizeof( char ) ); strcpy( dish[i], pattern[i % patternLength ] ); } //--- return the fully populated array of N strings --- return dish; } // ================================================================= // MAIN: // Creates a dish array of 40 lines and displays it. // ================================================================= int main( int argc, char** argv ) { int i, N, length; char** dish; //--- define the number of lines wanted --- N = 40; //--- create an array of N lines --- dish = createDish( N ); //--- display it on the screen --- for (i=0; i < N; i++ ) printf( "%s\n", dish[i] ); }