From 208152cb9b7b882a9446f870a831fccd75ae7f8a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 14 Sep 2010 18:33:38 -0400 Subject: [PATCH] Remove src/mandelbrot/MS-codes_winter_2008/ It was an older version of MS-codes/, with few changes. --- src/mandelbrot/MS-codes_winter_2008/MS1.c | 119 -------- src/mandelbrot/MS-codes_winter_2008/MS2.c | 196 ------------- src/mandelbrot/MS-codes_winter_2008/MS3.c | 323 ---------------------- 3 files changed, 638 deletions(-) delete mode 100644 src/mandelbrot/MS-codes_winter_2008/MS1.c delete mode 100644 src/mandelbrot/MS-codes_winter_2008/MS2.c delete mode 100644 src/mandelbrot/MS-codes_winter_2008/MS3.c diff --git a/src/mandelbrot/MS-codes_winter_2008/MS1.c b/src/mandelbrot/MS-codes_winter_2008/MS1.c deleted file mode 100644 index aa31fe3..0000000 --- a/src/mandelbrot/MS-codes_winter_2008/MS1.c +++ /dev/null @@ -1,119 +0,0 @@ - -#include -#include - - /********************************/ - /* */ - /* The Mandelbrot Set */ - /* */ - /* z = z*z + c */ - /* */ - /********************************/ - -/* Simplified main() via two functions */ -/* iterate_map() and set_grid() */ - - -/* use: */ -/* */ -/* MS1 */ - - - /* Michel Vallieres */ - - - /* large distance; if |z| goes */ - /* beyond it, point C is not a */ - /* member of the set */ -#define LARGE_RADIUS 2.0 - /* Maximum number of iterations */ - /* before declaring a point in */ - /* the Mandelbrot set */ -#define MAX_ITERATIONS 120 - /* image size */ -#define NX 700 -#define NY 500 - - -void iterate_map( double c_real, double c_img, int *count ) -{ - double z_real, z_img, z_current_real, z_magnitude; - int counter; - - /* z starts a origin */ - z_real = 0.0; - z_img = 0.0; - /* set counter to zero */ - counter = 0; - /* iterate map for */ - /* MAX_ITERATIONS times or ...*/ - while ( counter < MAX_ITERATIONS ) - { - z_current_real = z_real; - z_real = z_real*z_real - z_img*z_img + c_real; - z_img = 2.0*z_current_real*z_img + c_img; - counter = counter + 1; - /* ... until magnitude of z */ - /* is larger than some */ - /* large radius */ - z_magnitude = z_real*z_real+z_img*z_img; - if ( z_magnitude > LARGE_RADIUS ) break; - } - /* write C real and */ - /* imaginary parts if */ - /* C belongs to the set */ - /* - if ( z_magnitude < LARGE_RADIUS ) - printf ( " %f %f \n ", c_real, c_img ); - */ - /* or iteration number */ - /* for all scanned C values */ - /* for color picture */ - count++; - printf ( " %f \n", (double)(255*counter) / (double)MAX_ITERATIONS ); - -} - - -void set_grid( double *crmin, double *crmax, double *cimin, - double *cimax, double *dcr, double *dci ) -{ - /* define grid spanning */ - /* the complex plane for */ - /* the C variable */ - *crmin = -1.7; - *crmax = 0.8; - *cimin = -1.1; - *cimax = 1.1; - /* C spacing on complex plane */ - *dcr = (*crmax - *crmin)/(NX-1); - *dci = (*cimax - *cimin)/(NY-1); -} - - - -int main( int argc, char *argv[] ) -{ - double c_real, c_img, crmin, crmax, cimin, cimax; - double dcr, dci; - int i, j; - int count; - /* setup C grid */ - set_grid( &crmin, &crmax, &cimin, &cimax, &dcr, &dci ); - - /* # points in set */ - count = 0; - - for ( j=0 ; j -#include -#include - - /********************************/ - /* */ - /* The Mandelbrot Set */ - /* */ - /* z = z*z + c */ - /* */ - /********************************/ - -/* Simplified main() via two functions */ -/* iterate_map() and set_grid() */ - -/* Slice image - strips parallel to real C */ -/* via functions */ -/* set_slices() and calculate_slice() */ - - -/* use: */ -/* */ -/* MS2 */ - - - /* Michel Vallieres */ - - - /* large distance; if |z| goes */ - /* beyond it, point C is not a */ - /* member of the set */ -#define LARGE_RADIUS 2.0 - /* Maximum number of iterations */ - /* before declaring a point in */ - /* the Mandelbrot set */ -#define MAX_ITERATIONS 120 - /* image size */ -#define NX 700 -#define NY 500 - /* # of slices parallel to C real */ -#define N_slices 64 - - - -/* Iterate the Mandelbrot map -- decide if the (input) point */ -/* in complex C plane belongs or not to the set */ -/* prints out the number of iterations pro-rated to */ -/* MAX_ITERATIONS */ -double iterate_map( double c_real, double c_img, int *count ) -{ - double z_real, z_img, z_current_real, z_magnitude; - double color; - int counter; - - /* z starts a origin */ - z_real = 0.0; - z_img = 0.0; - /* set counter to zero */ - counter = 0; - /* iterate map for */ - /* MAX_ITERATIONS times or ...*/ - while ( counter < MAX_ITERATIONS ) - { - z_current_real = z_real; - z_real = z_real*z_real - z_img*z_img + c_real; - z_img = 2.0*z_current_real*z_img + c_img; - counter = counter + 1; - /* ... until magnitude of z */ - /* is larger than some */ - /* large radius */ - z_magnitude = z_real*z_real+z_img*z_img; - if ( z_magnitude > LARGE_RADIUS ) break; - } - /* write C real and */ - /* imaginary parts if */ - /* C belongs to the set */ - /* - if ( z_magnitude < LARGE_RADIUS ) - printf ( " %f %f \n ", c_real, c_img ); - */ - /* or iteration number */ - /* for all scanned C values */ - /* for color picture */ - count++; - color = (double)(255*counter) / (double)MAX_ITERATIONS; - return color; - -} - - -/* Set up the grid in complex C plane to generate image */ -void set_grid( double *crmin, double *crmax, double *cimin, - double *cimax, double *dcr, double *dci ) -{ - /* define grid spanning */ - /* the complex plane for */ - /* the C variable */ - *crmin = -1.7; - *crmax = 0.8; - *cimin = -1.1; - *cimax = 1.1; - /* C spacing on complex plane */ - *dcr = (*crmax - *crmin)/(NX-1); - *dci = (*cimax - *cimin)/(NY-1); -} - - -/* Calculate the Mandelbrot set in slice */ -void calculate_slice( int slice, int *begin_slice, - int *end_slice, int *count, - double crmin, double cimin, double dcr, double dci, - double *store_slice ) -{ - int i, j, k; - double c_real, c_img, color; - /* store pointer */ - k = 0; - /* scan over slice */ - for ( j=begin_slice[slice] ; j<=end_slice[slice] ; j++ ) - { - for ( i=0 ; i0 ) - { - end_slice[slice]++; - leftover--; - } - temp = end_slice[slice]; - } - return average; -} - - - -int main( int argc, char *argv[] ) -{ - double c_real, c_img, crmin, crmax, cimin, cimax; - double dcr, dci, *store_slice; - int k, count, average; - int slice, begin_slice[1000], end_slice[1000]; - - /* set slicing */ - average = set_slices( begin_slice, end_slice ); - - /* setup C grid */ - set_grid( &crmin, &crmax, &cimin, &cimax, &dcr, &dci ); - - /* color storage */ - store_slice = (double *)malloc( NX*(average+1)*sizeof(double) ); - - /* # points in set */ - count = 0; - - /* scan over slices */ - for ( slice=0 ; slice -#include -#include -#include - - - /********************************/ - /* */ - /* The Mandelbrot Set */ - /* */ - /* z = z*z + c */ - /* */ - /********************************/ - -/* Simplified main() via two functions */ -/* iterate_map() and set_grid() */ - -/* Slice image - strips parallel to real C */ -/* via functions */ -/* set_slices() and calculate_slice() */ - -/* Parallel version -- Master-Slave model */ -/* */ -/* master() running on node zero */ -/* slave() running on all other nodes */ -/* */ - - - -/* use: */ -/* */ -/* mandelbrot_parallel */ - - - /* Michel Vallieres */ - - - /* large distance; if |z| goes */ - /* beyond it, point C is not a */ - /* member of the set */ -#define LARGE_RADIUS 2.0 - /* Maximum number of iterations */ - /* before declaring a point in */ - /* the Mandelbrot set */ -#define MAX_ITERATIONS 120 - /* image size */ -#define NX 700 -#define NY 500 - /* # of slices parallel to C real */ -#define N_slices 64 - /* Maximum # processes */ -#define MAX_PROCESSES 1000 - - - -/* Iterate the Mandelbrot map -- decide if the (input) point */ -/* in complex C plane belongs or not to the set */ -/* prints out the number of iterations pro-rated to */ -/* MAX_ITERATIONS */ -double iterate_map( double c_real, double c_img, int *count ) -{ - double z_real, z_img, z_current_real, z_magnitude; - double color; - int counter; - - /* z starts a origin */ - z_real = 0.0; - z_img = 0.0; - /* set counter to zero */ - counter = 0; - /* iterate map for */ - /* MAX_ITERATIONS times or ...*/ - while ( counter < MAX_ITERATIONS ) - { - z_current_real = z_real; - z_real = z_real*z_real - z_img*z_img + c_real; - z_img = 2.0*z_current_real*z_img + c_img; - counter = counter + 1; - /* ... until magnitude of z */ - /* is larger than some */ - /* large radius */ - z_magnitude = z_real*z_real+z_img*z_img; - if ( z_magnitude > LARGE_RADIUS ) break; - } - /* write C real and */ - /* imaginary parts if */ - /* C belongs to the set */ - /* - if ( z_magnitude < LARGE_RADIUS ) - printf ( " %f %f \n ", c_real, c_img ); - */ - /* or iteration number */ - /* for all scanned C values */ - /* for color picture */ - count++; - - color = (double)(255*counter) / (double)MAX_ITERATIONS; - return color; - -} - - -/* Set up the grid in complex C plane to generate image */ -void set_grid( double *crmin, double *crmax, double *cimin, - double *cimax, double *dcr, double *dci ) -{ - /* define grid spanning */ - /* the complex plane for */ - /* the C variable */ - *crmin = -1.7; - *crmax = 0.8; - *cimin = -1.1; - *cimax = 1.1; - /* C spacing on complex plane */ - *dcr = (*crmax - *crmin)/(NX-1); - *dci = (*cimax - *cimin)/(NY-1); -} - - -/* Calculate the Mandelbrot set in slice */ -void calculate_slice( int slice, int *begin_slice, - int *end_slice, int *count, - double crmin, double cimin, double dcr, double dci, - double *store_slice ) -{ - int i, j, k; - double c_real, c_img, color; - /* store pointer */ - k = 0; - /* scan over slice */ - for ( j=begin_slice[slice] ; j<=end_slice[slice] ; j++ ) - { - for ( i=0 ; i0 ) - { - end_slice[slice]++; - leftover--; - } - temp = end_slice[slice]; - offset[slice] = temp_offset; - temp_offset = temp_offset + NX * - ( end_slice[slice] - begin_slice[slice] + 1 ); - } - return average; -} - - -void slave(int my_rank, int *begin_slice, int *end_slice, - int average, double crmin, double cimin, double dcr, - double dci, double *store_slice ) -{ - static int count; - int number, slice; - MPI_Status status; - - for ( ; ; ) - { - /* a new slice to calculate */ - MPI_Recv( &slice, 1, MPI_INT, 0, 325, - MPI_COMM_WORLD, &status ); - /* suicide signal */ - if ( slice < 0 ) - { - /* MPI_Reduce( ); */ - MPI_Finalize(); - exit(0); - } - /* slice to calculate */ - calculate_slice( slice, begin_slice, end_slice, &count, - crmin, cimin, dcr, dci, store_slice ); - - /* send results back to master */ - number = NX * (average+1) ; - MPI_Ssend( store_slice, number, MPI_DOUBLE, 0, 327, - MPI_COMM_WORLD ); - - fprintf( stderr, "slave %d --> slice %d is calculated & sent\n", my_rank, slice ); - } -} - - - -void master(int numprocs, int *begin_slice, int *end_slice, - int average, double crmin, double cimin, double dcr, - double dci, double *store_slice, int *offset ) -{ - int k, k_slice, slice, process; - int number, source; - static int count; - static int list_slices[MAX_PROCESSES]; - int kill, recv_slice; - double mandelbrot[NX*NY]; - MPI_Status status; - /* # points in set */ - count = 0; - /* scan over slices */ - slice = 0; - /* send a slice to each slave */ - for ( process=1 ; process