Remove src/mandelbrot/MS-codes_winter_2008/
authorW. Trevor King <wking@drexel.edu>
Tue, 14 Sep 2010 22:33:38 +0000 (18:33 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 14 Sep 2010 22:33:38 +0000 (18:33 -0400)
It was an older version of MS-codes/, with few changes.

src/mandelbrot/MS-codes_winter_2008/MS1.c [deleted file]
src/mandelbrot/MS-codes_winter_2008/MS2.c [deleted file]
src/mandelbrot/MS-codes_winter_2008/MS3.c [deleted file]

diff --git a/src/mandelbrot/MS-codes_winter_2008/MS1.c b/src/mandelbrot/MS-codes_winter_2008/MS1.c
deleted file mode 100644 (file)
index aa31fe3..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-
-#include <math.h>
-#include <stdio.h>
-
-                /********************************/
-                /*                              */
-                /*     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<NY; j++ )
-   {
-     for ( i=0 ; i<NX; i++ )
-     {
-        c_real = crmin + i*dcr;
-        c_img = cimin + j*dci;
-                                       /* iterate Mandelbrot map */
-        iterate_map( c_real, c_img, &count );
-     }
-
-   }
-
-}
diff --git a/src/mandelbrot/MS-codes_winter_2008/MS2.c b/src/mandelbrot/MS-codes_winter_2008/MS2.c
deleted file mode 100644 (file)
index 523324a..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-                /********************************/
-                /*                              */
-                /*     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 ; i<NX ; i++ )
-    {
-       c_real = crmin + i*dcr;
-       c_img = cimin + j*dci;
-                                       /* iterate Mandelbrot map */
-       color = iterate_map( c_real, c_img, count );
-
-                                        /* store resulting color */
-       store_slice[k] = color;
-       k++;
-    }
-  }
-}
-
-
-/* Setup the slices through which compute the Mandelbrot set  */
-int set_slices( int *begin_slice, int *end_slice )
-{
-  int slice, average, leftover, temp;
-
-  average = NY / N_slices;
-  leftover = NY % N_slices;
-  temp = -1;
-  for ( slice=0 ; slice<N_slices ; slice++ )
-    {
-      begin_slice[slice] = temp + 1;
-      end_slice[slice] = begin_slice[slice] + average - 1;
-      if ( leftover >0 )
-       {
-          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<N_slices ; slice++ )
-     { 
-                                        /* generate Mandelbrot set */
-                                        /*  in each slice          */
-       calculate_slice( slice, begin_slice, end_slice, &count,
-                          crmin, cimin, dcr, dci, store_slice );
-
-       fprintf(stderr,"%d %d %d %d \n", 
-               slice, NX, end_slice[slice], begin_slice[slice] );
-
-       for ( k=0; k<NX*(end_slice[slice]-begin_slice[slice]+1) ; k++ )
-          printf( " %f \n", store_slice[k] );
-     }
-
-}
-
diff --git a/src/mandelbrot/MS-codes_winter_2008/MS3.c b/src/mandelbrot/MS-codes_winter_2008/MS3.c
deleted file mode 100644 (file)
index a81ea29..0000000
+++ /dev/null
@@ -1,323 +0,0 @@
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <mpi.h>
-
-
-                /********************************/
-                /*                              */
-                /*     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 ; i<NX ; i++ )
-    {
-       c_real = crmin + i*dcr;
-       c_img = cimin + j*dci;
-                                        /* iterate Mandelbrot map */
-       color = iterate_map( c_real, c_img, count );
-
-                                        /* store resulting color */
-       store_slice[k] = color;
-       k++;
-    }
-  }
-}
-
-
-/* Setup the slices through which compute the Mandelbrot set  */
-int set_slices( int *begin_slice, int *end_slice, int *offset )
-{
-  int slice, average, leftover, temp, temp_offset;
-  MPI_Status status;
-
-  average = NY / N_slices;
-  leftover = NY % N_slices;
-  temp = -1;
-  temp_offset = 0;
-  for ( slice=0 ; slice<N_slices ; slice++ )
-    {
-      begin_slice[slice] = temp + 1;
-      end_slice[slice] = begin_slice[slice] + average - 1;
-      if ( leftover >0 )
-        {
-          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<numprocs ; process++ )
-     { 
-                                        /* generate Mandelbrot set */
-                                        /*  in each process        */
-       MPI_Ssend( &slice, 1, MPI_INT, process, 325, 
-               MPI_COMM_WORLD );
-       list_slices[process] = slice;
-       slice++;
-     }
-
-
-   for ( k_slice=0 ; k_slice<N_slices ; k_slice++ )
-     {
-                                        /* receive a slice */
-       number = NX * ( average+1);
-       MPI_Recv( store_slice, number, MPI_DOUBLE, MPI_ANY_SOURCE, 327, 
-                       MPI_COMM_WORLD, &status );
-                                        /* source of slice */
-       source = status.MPI_SOURCE;
-                                        /* received slice */ 
-       recv_slice = list_slices[source];
-                                        /* send a slice to this slave */
-       if ( slice < N_slices )
-        {      
-            MPI_Ssend( &slice, 1, MPI_INT, source, 325, 
-                                        MPI_COMM_WORLD );
-            list_slices[source] = slice;
-            slice++;
-        }
-                                        /* actual number */
-       number = NX * ( end_slice[recv_slice]-begin_slice[recv_slice]+1 );
-                                        /* store set in matrix */
-       for ( k=0 ; k<number ; k++ )
-        mandelbrot[offset[recv_slice]+k] = store_slice[k];
-
-     }   
-
-                                        /* ouput Mandelbrot set */
-   fprintf( stderr, " The Mandelbrot Set will be written out \n" );
-   for ( k=0; k<NX*NY ; k++ )
-          printf( " %f \n", mandelbrot[k] );
-
-   fprintf( stderr, " The Mandelbrot Set has been written out \n" );
-
-                                        /* end all processes */
-   kill = -1;
-   for ( process=1 ; process<numprocs ; process++ )
-     { 
-       MPI_Ssend( &kill, 1, MPI_INT, process, 325, 
-               MPI_COMM_WORLD );
-     }
-   MPI_Finalize();
-   exit( 0 );
-}
-
-
-
-int main( int argc, char *argv[] )
-{
-   double crmin, crmax, cimin, cimax; 
-   double dcr, dci;
-   int    average;
-   int    begin_slice[1000], end_slice[1000], offset[1000];
-   int    my_rank, numprocs;
-   double *store_slice;
-
-                                        /* MPI exposure  */
-   MPI_Init( &argc, &argv );
-   MPI_Comm_size( MPI_COMM_WORLD, &numprocs );
-   MPI_Comm_rank( MPI_COMM_WORLD, &my_rank );
-
-                                        /* set slicing */
-   average = set_slices( begin_slice, end_slice, offset );
-
-                                        /* setup C grid */
-   set_grid( &crmin, &crmax, &cimin, &cimax, &dcr, &dci );
-                                        /* color storage */
-   store_slice = (double *)malloc( NX*(average+1)*sizeof(double) );
-
-                                        /* master node */
-   if ( my_rank == 0 )
-     {
-       master( numprocs, begin_slice, end_slice, average,
-                crmin, cimin, dcr, dci, store_slice, offset );
-     }
-                                        /* slave nodes  */
-   else
-     {
-       slave( my_rank, begin_slice, end_slice, average,
-               crmin, cimin, dcr, dci, store_slice );
-     }
-
-}
-
-