Difference between revisions of "CSC352 Homework 3 2017"

From dftwiki3
Jump to: navigation, search
(Additional Information)
(The dish array)
Line 22: Line 22:
 
==The dish array==
 
==The dish array==
 
<br />
 
<br />
 +
You may want to use the function createDish() illustrated in the code below to create a dish of 10,000 lines.
 
<br />
 
<br />
 +
::<source lang="C">
 +
// 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 />

Revision as of 15:03, 5 April 2017

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



Game of Life on MPI


Question


How big an MPI cluster do you need on AWS to gain a speedup greater than 1.0 for 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 useful to get started.

The dish array


You may want to use the function createDish() illustrated in the code below to create a dish of 10,000 lines.

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

}