Difference between revisions of "CSC352 Homework 3 2017"

From dftwiki3
Jump to: navigation, search
(The dish array)
Line 9: Line 9:
 
==Question==
 
==Question==
 
<br />
 
<br />
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 at least 1000 generations on a dish of 10,000 lines, where each line is 80 characters long?
+
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 />

Revision as of 16:28, 5 April 2017

--D. Thiebaut (talk) 15:26, 5 April 2017 (EDT)



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


  1. You may find this 2-Node, Game of Life, MPI code useful to get started.
  2. You are allowed to use the Hadoop01/02/03/04 cluster if you run into too much trouble connecting to AWS.


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] );

}