From: W. Trevor King Date: Tue, 14 Sep 2010 22:40:48 +0000 (-0400) Subject: Remove src/mandelbrot/legacy_codes/ X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2cb89ac68d085adb096e214ff0b9b8d2adf0b6e5;p=parallel_computing.git Remove src/mandelbrot/legacy_codes/ I'm not sure how these relate to the current codes in MS-codes/, but they claim to be legacy code, so I'm removing them. If you want them, they'll still be there in the history. --- diff --git a/src/mandelbrot/legacy_codes/m1.c b/src/mandelbrot/legacy_codes/m1.c deleted file mode 100644 index b138d6e..0000000 --- a/src/mandelbrot/legacy_codes/m1.c +++ /dev/null @@ -1,189 +0,0 @@ - - /**********************************/ - /* */ - /* The Mandelbrot Set */ - /* */ - /* z = z*z + c */ - /* */ - /* parallel version */ - /* */ - /**********************************/ /* m1.c */ - - - /* Michel Vallieres */ - -#include -#include -#include "mpi.h" - /* large distance; if |z| reaches */ - /* 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 80 -#define NX 600 /* image size */ -#define NY 500 -#define N_STRIPE 37 /* number of stripes */ -#define MAX_PROC 100 /* max # of processes */ - - /* prototypes */ -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n); -void grid_stripes( double *crmin, double *crmax, double *cimin, double *cimax, - int begin_stripe[], int last_stripe[] ); - - -int main( int argc, char *argv[] ) -{ - double crmin, crmax, cimin, cimax; - double store_iter[NY*(NX/N_STRIPE+1)]; - int begin_stripe[N_STRIPE], last_stripe[N_STRIPE]; - int stripe; - int store_n, i_point; - int count; - int myid, numprocs; - MPI_Status mesgStatus; - int stripe_in_proc[MAX_PROC], sent_stripe, recv_stripe, ip; - - /* start the MPI virtual machine */ - MPI_Init(&argc,&argv); - MPI_Comm_size(MPI_COMM_WORLD,&numprocs); - MPI_Comm_rank(MPI_COMM_WORLD,&myid); - /* initialize grid & stripes */ - grid_stripes ( &crmin, &crmax, &cimin, &cimax, begin_stripe, last_stripe ); - - /*****************/ - /* Master code */ - /*****************/ - if ( myid == 0 ) - { - /* initilalize send & recv counters */ - sent_stripe = 0; - recv_stripe = 0; - /* send a stripe to each slave */ - /* to start local calculation */ - for ( ip=1 ; ip 0 ) - { - last_stripe[0] = last_stripe[0] + 1; - left_over--; - } - /* other stripes */ - for ( stripe = 1; stripe < N_STRIPE ; stripe++ ) - { - begin_stripe[stripe] = last_stripe[stripe-1] + 1 ; - last_stripe[stripe] = begin_stripe[stripe] + w_stripe - 1; - if ( left_over > 0 ) - { - last_stripe[stripe] = last_stripe[stripe] + 1; - left_over--; - } - } -} - - - - -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n) -{ - double z_real, z_img, z_magnitude; - double c_real, c_img, z_current_real; - double dcr, dci; - int i, j; - int counter; - - /* scan C values on complex plane */ - dcr = (crmax - crmin)/(double)(NX-1); - dci = (cimax - cimin)/(double)(NY-1); - /* scan stripe */ - *store_n=0; - for ( i=i_min ; i<=i_max; i++ ) - { - for ( j=0 ; j LARGE_RADIUS ) break; - } - /* store iteration numbers */ - /* to plot the set */ - store_iter[*store_n] = - (double)(255*counter) / (double)MAX_ITERATIONS ; - (*store_n)++; - } - } -} - diff --git a/src/mandelbrot/legacy_codes/m2.c b/src/mandelbrot/legacy_codes/m2.c deleted file mode 100644 index 8a4dc51..0000000 --- a/src/mandelbrot/legacy_codes/m2.c +++ /dev/null @@ -1,219 +0,0 @@ - - /**********************************/ - /* */ - /* The Mandelbrot Set */ - /* */ - /* z = z*z + c */ - /* */ - /* parallel version */ - /* */ - /**********************************/ /* m2.c */ - - - /* Michel Vallieres */ - -#include -#include -#include "mpi.h" - /* large distance; if |z| reaches */ - /* 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 80 -#define NX 600 /* image size */ -#define NY 500 -#define N_STRIPE 37 /* number of stripes */ -#define MAX_PROC 100 /* max # of processes */ - - /* prototypes */ -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n); -void grid_stripes( double *crmin, double *crmax, double *cimin, double *cimax, - int begin_stripe[], int last_stripe[] ); - - -int main( int argc, char *argv[] ) -{ - double crmin, crmax, cimin, cimax; - double store_iter[NY*(NX/N_STRIPE+1)]; - int begin_stripe[N_STRIPE], last_stripe[N_STRIPE]; - int stripe; - int store_n, i_point; - int count; - int myid, numprocs; - MPI_Status mesgStatus; - int stripe_in_proc[MAX_PROC], sent_stripe, recv_stripe, from_node, - number_from_node, ip; - int end_signal; - - /* start the MPI virtual machine */ - MPI_Init(&argc,&argv); - MPI_Comm_size(MPI_COMM_WORLD,&numprocs); - MPI_Comm_rank(MPI_COMM_WORLD,&myid); - - /* initialize grid & stripes */ - grid_stripes ( &crmin, &crmax, &cimin, &cimax, begin_stripe, last_stripe ); - - /*****************/ - /* Master code */ - /*****************/ - if ( myid == 0 ) - { - - fprintf( stderr, " size of array = %d \n", NY*(NX/N_STRIPE+1) ); - - /* initilalize send counter */ - sent_stripe = 0; - /* send a stripe to each slave */ - /* to start local calculation */ - for ( ip=1 ; ip 0 ) - { - last_stripe[0] = last_stripe[0] + 1; - left_over--; - } - /* other stripes */ - for ( stripe = 1; stripe < N_STRIPE ; stripe++ ) - { - begin_stripe[stripe] = last_stripe[stripe-1] + 1 ; - last_stripe[stripe] = begin_stripe[stripe] + w_stripe - 1; - if ( left_over > 0 ) - { - last_stripe[stripe] = last_stripe[stripe] + 1; - left_over--; - } - } -} - - - - -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n) -{ - double z_real, z_img, z_magnitude; - double c_real, c_img, z_current_real; - double dcr, dci; - int i, j; - int counter; - - /* scan C values on complex plane */ - dcr = (crmax - crmin)/(double)(NX-1); - dci = (cimax - cimin)/(double)(NY-1); - /* scan stripe */ - *store_n=0; - for ( i=i_min ; i<=i_max; i++ ) - { - for ( j=0 ; j LARGE_RADIUS ) break; - } - /* store iteration numbers */ - /* to plot the set */ - store_iter[*store_n] = - (double)(255*counter) / (double)MAX_ITERATIONS ; - (*store_n)++; - } - } -} - diff --git a/src/mandelbrot/legacy_codes/m3.c b/src/mandelbrot/legacy_codes/m3.c deleted file mode 100644 index 82c8d7e..0000000 --- a/src/mandelbrot/legacy_codes/m3.c +++ /dev/null @@ -1,226 +0,0 @@ - - /**********************************/ - /* */ - /* The Mandelbrot Set */ - /* */ - /* z = z*z + c */ - /* */ - /* parallel version */ - /* */ - /**********************************/ /* m3.c */ - - /* Michel Vallieres */ - -#include -#include -#include "mpi.h" - /* large distance; if |z| reaches */ - /* 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 80 -#define NX 600 /* image size */ -#define NY 500 -#define N_STRIPE 37 /* number of stripes */ -#define MAX_PROC 100 /* max # of processes */ - - /* prototypes */ -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n); -void grid_stripes( double *crmin, double *crmax, double *cimin, double *cimax, - int begin_stripe[], int last_stripe[] ); - - -int main( int argc, char *argv[] ) -{ - double crmin, crmax, cimin, cimax; - double store_iter[NY*(NX/N_STRIPE+1)]; - int begin_stripe[N_STRIPE], last_stripe[N_STRIPE]; - int stripe; - int store_n, i_point; - int count; - int myid, numprocs; - MPI_Status mesgStatus; - int stripe_in_proc[MAX_PROC], sent_stripe, recv_stripe, from_node, - number_from_node, ip; - int end_signal; - - /* start the MPI virtual machine */ - MPI_Init(&argc,&argv); - MPI_Comm_size(MPI_COMM_WORLD,&numprocs); - MPI_Comm_rank(MPI_COMM_WORLD,&myid); - - /* initialize grid & stripes */ - grid_stripes ( &crmin, &crmax, &cimin, &cimax, begin_stripe, last_stripe ); - - /*****************/ - /* Master code */ - /*****************/ - if ( myid == 0 ) - { - - fprintf( stderr, " size of array = %d \n", NY*(NX/N_STRIPE+1) ); - - /* initilalize send counter */ - sent_stripe = 0; - /* send a stripe to each slave */ - /* to start local calculation */ - for ( ip=1 ; ip 0 ) - { - last_stripe[0] = last_stripe[0] + 1; - left_over--; - } - /* other stripes */ - for ( stripe = 1; stripe < N_STRIPE ; stripe++ ) - { - begin_stripe[stripe] = last_stripe[stripe-1] + 1 ; - last_stripe[stripe] = begin_stripe[stripe] + w_stripe - 1; - if ( left_over > 0 ) - { - last_stripe[stripe] = last_stripe[stripe] + 1; - left_over--; - } - } -} - - - - -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n) -{ - double z_real, z_img, z_magnitude; - double c_real, c_img, z_current_real; - double dcr, dci; - int i, j; - int counter; - - /* scan C values on complex plane */ - dcr = (crmax - crmin)/(double)(NX-1); - dci = (cimax - cimin)/(double)(NY-1); - /* scan stripe */ - *store_n=0; - for ( i=i_min ; i<=i_max; i++ ) - { - for ( j=0 ; j LARGE_RADIUS ) break; - } - /* store iteration numbers */ - /* to plot the set */ - store_iter[*store_n] = - (double)(255*counter) / (double)MAX_ITERATIONS ; - (*store_n)++; - } - } -} - diff --git a/src/mandelbrot/legacy_codes/m4.c b/src/mandelbrot/legacy_codes/m4.c deleted file mode 100644 index b42d236..0000000 --- a/src/mandelbrot/legacy_codes/m4.c +++ /dev/null @@ -1,241 +0,0 @@ - - /**********************************/ - /* */ - /* The Mandelbrot Set */ - /* */ - /* z = z*z + c */ - /* */ - /* parallel version */ - /* */ - /**********************************/ /* m4 */ - - - /* Michel Vallieres */ - -#include -#include -#include "mpi.h" - /* large distance; if |z| reaches */ - /* 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 80 -#define NX 600 /* image size */ -#define NY 500 -#define N_STRIPE 37 /* number of stripes */ -#define MAX_PROC 100 /* max # of processes */ - - /* prototypes */ -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n); -void grid_stripes( double *crmin, double *crmax, double *cimin, double *cimax, - int begin_stripe[], int last_stripe[] ); - - -int main( int argc, char *argv[] ) -{ - double crmin, crmax, cimin, cimax; - double store_iter[NY*(NX/N_STRIPE+1)]; - int begin_stripe[N_STRIPE], last_stripe[N_STRIPE]; - int stripe; - int store_n, i_point; - int count; - int myid, numprocs; - MPI_Status mesgStatus; - int stripe_in_proc[MAX_PROC], sent_stripe, recv_stripe, from_node, - number_from_node, ip; - int end_signal; - - /* start the MPI virtual machine */ - MPI_Init(&argc,&argv); - MPI_Comm_size(MPI_COMM_WORLD,&numprocs); - MPI_Comm_rank(MPI_COMM_WORLD,&myid); - - /* initialize grid & stripes */ - grid_stripes ( &crmin, &crmax, &cimin, &cimax, begin_stripe, last_stripe ); - - /*****************/ - /* Master code */ - /*****************/ - if ( myid == 0 ) - { - - fprintf( stderr, " size of array = %d \n", NY*(NX/N_STRIPE+1) ); - - /* initilalize send counter */ - sent_stripe = 0; - /* send a stripe to each slave */ - /* to start local calculation */ - for ( ip=1 ; ip 0 ) - { - last_stripe[0] = last_stripe[0] + 1; - left_over--; - } - /* other stripes */ - for ( stripe = 1; stripe < N_STRIPE ; stripe++ ) - { - begin_stripe[stripe] = last_stripe[stripe-1] + 1 ; - last_stripe[stripe] = begin_stripe[stripe] + w_stripe - 1; - if ( left_over > 0 ) - { - last_stripe[stripe] = last_stripe[stripe] + 1; - left_over--; - } - } -} - - - - -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n) -{ - double z_real, z_img, z_magnitude; - double c_real, c_img, z_current_real; - double dcr, dci; - int i, j; - int counter; - - /* scan C values on complex plane */ - dcr = (crmax - crmin)/(double)(NX-1); - dci = (cimax - cimin)/(double)(NY-1); - /* scan stripe */ - *store_n=0; - for ( i=i_min ; i<=i_max; i++ ) - { - for ( j=0 ; j LARGE_RADIUS ) break; - } - /* store iteration numbers */ - /* to plot the set */ - store_iter[*store_n] = - (double)(255*counter) / (double)MAX_ITERATIONS ; - (*store_n)++; - } - } -} - diff --git a/src/mandelbrot/legacy_codes/mandelbrot.c b/src/mandelbrot/legacy_codes/mandelbrot.c deleted file mode 100644 index 1d3e062..0000000 --- a/src/mandelbrot/legacy_codes/mandelbrot.c +++ /dev/null @@ -1,97 +0,0 @@ - -#include -#include - - /********************************/ - /* */ - /* The Mandelbrot Set */ - /* */ - /* z = z*z + c */ - /* */ - /********************************/ - -/* use: */ -/* */ -/* mandelbrot */ - - - /* Summer School 1995 */ - - - /* 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 80 - /* image size */ -#define NX 600 -#define NY 500 - - -int main( int argc, char * argv[] ) -{ - double z_real, z_img, z_magnitude; - double c_real, c_img, crmin, crmax, cimin, cimax, - dcr, dci, z_current_real; - int i, j, NX, NY; - int counter; - int count; - - /* define grid spanning */ - /* the complex plane for */ - /* the C variable */ - crmin=-1.7; - crmax = 0.8; - cimin = -1.0; - cimax = 1.0; - /* scan C values on complex plane */ - dcr = (crmax - crmin)/(NX-1); - dci = (cimax - cimin)/(NY-1); - - count = 0; - - for ( i=0 ; i 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 ", (double)(255*counter) / (double)MAX_ITERATIONS ); - } - - } - -} diff --git a/src/mandelbrot/legacy_codes/mandelbrot_1.c b/src/mandelbrot/legacy_codes/mandelbrot_1.c deleted file mode 100644 index d213d4e..0000000 --- a/src/mandelbrot/legacy_codes/mandelbrot_1.c +++ /dev/null @@ -1,191 +0,0 @@ - - /**********************************/ - /* */ - /* The Mandelbrot Set */ - /* */ - /* z = z*z + c */ - /* */ - /* Adapted to calculate the Set */ - /* in stripes parallel to Img axis*/ - /* */ - /* Improved routines structure */ - /* to facilitate parallel */ - /* implementation */ - /**********************************/ - - /* Michel Vallieres */ - -#include -#include -#include - /* large distance; if |z| reaches */ - /* 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 80 -#define NX 600 /* image size */ -#define NY 500 -#define N_STRIPE 37 /* number of stripes */ -#define MAX_PROCS 100 - - /* prototypes */ -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n); -void grid_stripes( double *crmin, double *crmax, double *cimin, double *cimax, - int begin_stripe[], int last_stripe[] ); - - -int main( int argc, char *argv[] ) -{ - double crmin, crmax, cimin, cimax; - double store_iter[NY*(NX/N_STRIPE+1)]; - int begin_stripe[N_STRIPE], last_stripe[N_STRIPE]; - int stripe; - int store_n, i_point; - int count; - int my_id, numprocs, ip; - int sent_stripe, recv_stripe, stripe_in_proc[MAX_PROCS]; - - MPI_Status mesgStatus; - - MPI_Init(&argc, &argv); /* start MPI virtual machine */ - - MPI_Comm_rank(MPI_COMM_WORLD, &my_id); - MPI_Comm_size(MPI_COMM_WORLD, &numprocs); - - - /* initialize grid & stripes */ - grid_stripes ( &crmin, &crmax, &cimin, &cimax, begin_stripe, last_stripe ); - - count = 0; - /**********/ - /* master */ - /**********/ - if(my_id == 0) - { - sent_stripe = 0; - recv_stripe = 0; /* logic of stripes */ - /* send original stripe to slaves */ - for( ip = 1; ip < numprocs; ip++) - { - MPI_Ssend(&sent_stripe, 1, MPI_INT, ip, 5, MPI_COMM_WORLD); - stripe_in_proc[ip] = sent_stripe; - sent_stripe++; - } - - } - /**********/ - /* slave */ - /**********/ - else - { - /* I'm getting a stripe to do, YAHOO! */ - MPI_Recv(&stripe, 1, MPI_INT, 0, 5, MPI_COMM_WORLD, &mesgStatus); - fprintf(stderr, "my ID: %d -- recieved stripe: %d \n", my_id, stripe); - - /* find the points in the set */ - compute_stripe( crmin, crmax, cimin, cimax, begin_stripe[stripe], - last_stripe[stripe], store_iter, &store_n); - } - - MPI_Finalize(); -} - - - - -void grid_stripes( double *crmin, double *crmax, double *cimin, double *cimax, - int begin_stripe[], int last_stripe[] ) -{ - int w_stripe, stripe, left_over; - /* define grid spanning */ - /* the complex plane for */ - /* the C variable */ - *crmin=-1.7; - *crmax = 0.8; - *cimin = -1.0; - *cimax = 1.0; - /* stripe definition */ - /* stripe # does not have to be */ - /* commensurate with grid size */ - /* in which case add 1 to some */ - /* stripes */ - w_stripe= NX/N_STRIPE; - left_over = NX % N_STRIPE; - /* fist stripe */ - begin_stripe[0] = 0; - last_stripe[0] = begin_stripe[0] + w_stripe - 1; - if ( left_over > 0 ) - { - last_stripe[0] = last_stripe[0] + 1; - left_over--; - } - /* other stripes */ - for ( stripe = 1; stripe < N_STRIPE ; stripe++ ) - { - begin_stripe[stripe] = last_stripe[stripe-1] + 1 ; - last_stripe[stripe] = begin_stripe[stripe] + w_stripe - 1; - if ( left_over > 0 ) - { - last_stripe[stripe] = last_stripe[stripe] + 1; - left_over--; - } - } -} - - - - -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n) -{ - double z_real, z_img, z_magnitude; - double c_real, c_img, z_current_real; - double dcr, dci; - int i, j; - int counter; - - /* scan C values on complex plane */ - dcr = (crmax - crmin)/(double)(NX-1); - dci = (cimax - cimin)/(double)(NY-1); - /* scan stripe */ - *store_n=0; - for ( i=i_min ; i<=i_max; i++ ) - { - for ( j=0 ; j LARGE_RADIUS ) break; - } - /* store iteration numbers */ - /* to plot the set */ - store_iter[*store_n] = - (double)(255*counter) / (double)MAX_ITERATIONS ; - (*store_n)++; - } - } -} - diff --git a/src/mandelbrot/legacy_codes/mandelbrot_2.c b/src/mandelbrot/legacy_codes/mandelbrot_2.c deleted file mode 100644 index 874c491..0000000 --- a/src/mandelbrot/legacy_codes/mandelbrot_2.c +++ /dev/null @@ -1,206 +0,0 @@ - - /**********************************/ - /* */ - /* The Mandelbrot Set */ - /* */ - /* z = z*z + c */ - /* */ - /* Adapted to calculate the Set */ - /* in stripes parallel to Img axis*/ - /* */ - /* Improved routines structure */ - /* to facilitate parallel */ - /* implementation */ - /**********************************/ - - /* Michel Vallieres */ - -#include -#include -#include - /* large distance; if |z| reaches */ - /* 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 80 -#define NX 600 /* image size */ -#define NY 500 -#define N_STRIPE 37 /* number of stripes */ -#define MAX_PROCS 100 - - /* prototypes */ -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n); -void grid_stripes( double *crmin, double *crmax, double *cimin, double *cimax, - int begin_stripe[], int last_stripe[] ); - - -int main( int argc, char *argv[] ) -{ - double crmin, crmax, cimin, cimax; - double store_iter[NY*(NX/N_STRIPE+1)]; - int begin_stripe[N_STRIPE], last_stripe[N_STRIPE]; - int stripe; - int store_n, i_point; - int count; - int my_id, numprocs, ip; - int sent_stripe, recv_stripe, stripe_in_proc[MAX_PROCS]; - int from_node, number_from_node; - - MPI_Status mesgStatus; - - MPI_Init(&argc, &argv); /* start MPI virtual machine */ - - MPI_Comm_rank(MPI_COMM_WORLD, &my_id); - MPI_Comm_size(MPI_COMM_WORLD, &numprocs); - - - /* initialize grid & stripes */ - grid_stripes ( &crmin, &crmax, &cimin, &cimax, begin_stripe, last_stripe ); - - count = 0; - /**********/ - /* master */ - /**********/ - if(my_id == 0) - { - sent_stripe = 0; - recv_stripe = 0; /* logic of stripes */ - /* send original stripe to slaves */ - for( ip = 1; ip < numprocs; ip++) - { - MPI_Ssend(&sent_stripe, 1, MPI_INT, ip, 5, MPI_COMM_WORLD); - stripe_in_proc[ip] = sent_stripe; - sent_stripe++; - } - - for( recv_stripe = 0; recv_stripe < N_STRIPE; recv_stripe++) - { - /* Recieve result back from a node */ - MPI_Recv(store_iter, NY*(NX/N_STRIPE+1), MPI_DOUBLE, MPI_ANY_SOURCE, 7, - MPI_COMM_WORLD, &mesgStatus); - from_node = mesgStatus.MPI_SOURCE; - MPI_Get_count( &mesgStatus, MPI_DOUBLE, &number_from_node ); - fprintf( stderr, "From node %d -- stripe & # %d %d \n", from_node, - stripe_in_proc[from_node], number_from_node ); - } - - } - /**********/ - /* slave */ - /**********/ - else - { - /* I'm getting a stripe to do, YAHOO! */ - MPI_Recv(&stripe, 1, MPI_INT, 0, 5, MPI_COMM_WORLD, &mesgStatus); - fprintf(stderr, "my ID: %d -- recieved stripe: %d \n", my_id, stripe); - - /* find the points in the set */ - compute_stripe( crmin, crmax, cimin, cimax, begin_stripe[stripe], - last_stripe[stripe], store_iter, &store_n); - - /* send stripe results back to master */ - MPI_Ssend(store_iter, store_n, MPI_DOUBLE, 0, 7, MPI_COMM_WORLD); - } - - MPI_Finalize(); -} - - - - -void grid_stripes( double *crmin, double *crmax, double *cimin, double *cimax, - int begin_stripe[], int last_stripe[] ) -{ - int w_stripe, stripe, left_over; - /* define grid spanning */ - /* the complex plane for */ - /* the C variable */ - *crmin=-1.7; - *crmax = 0.8; - *cimin = -1.0; - *cimax = 1.0; - /* stripe definition */ - /* stripe # does not have to be */ - /* commensurate with grid size */ - /* in which case add 1 to some */ - /* stripes */ - w_stripe= NX/N_STRIPE; - left_over = NX % N_STRIPE; - /* fist stripe */ - begin_stripe[0] = 0; - last_stripe[0] = begin_stripe[0] + w_stripe - 1; - if ( left_over > 0 ) - { - last_stripe[0] = last_stripe[0] + 1; - left_over--; - } - /* other stripes */ - for ( stripe = 1; stripe < N_STRIPE ; stripe++ ) - { - begin_stripe[stripe] = last_stripe[stripe-1] + 1 ; - last_stripe[stripe] = begin_stripe[stripe] + w_stripe - 1; - if ( left_over > 0 ) - { - last_stripe[stripe] = last_stripe[stripe] + 1; - left_over--; - } - } -} - - - - -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n) -{ - double z_real, z_img, z_magnitude; - double c_real, c_img, z_current_real; - double dcr, dci; - int i, j; - int counter; - - /* scan C values on complex plane */ - dcr = (crmax - crmin)/(double)(NX-1); - dci = (cimax - cimin)/(double)(NY-1); - /* scan stripe */ - *store_n=0; - for ( i=i_min ; i<=i_max; i++ ) - { - for ( j=0 ; j LARGE_RADIUS ) break; - } - /* store iteration numbers */ - /* to plot the set */ - store_iter[*store_n] = - (double)(255*counter) / (double)MAX_ITERATIONS ; - (*store_n)++; - } - } -} - diff --git a/src/mandelbrot/legacy_codes/mandelbrot_3.c b/src/mandelbrot/legacy_codes/mandelbrot_3.c deleted file mode 100644 index 7988869..0000000 --- a/src/mandelbrot/legacy_codes/mandelbrot_3.c +++ /dev/null @@ -1,224 +0,0 @@ - - /**********************************/ - /* */ - /* The Mandelbrot Set */ - /* */ - /* z = z*z + c */ - /* */ - /* Adapted to calculate the Set */ - /* in stripes parallel to Img axis*/ - /* */ - /* Improved routines structure */ - /* to facilitate parallel */ - /* implementation */ - /**********************************/ - - /* Michel Vallieres */ - -#include -#include -#include - /* large distance; if |z| reaches */ - /* 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 80 -#define NX 600 /* image size */ -#define NY 500 -#define N_STRIPE 37 /* number of stripes */ -#define MAX_PROCS 100 - - /* prototypes */ -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n); -void grid_stripes( double *crmin, double *crmax, double *cimin, double *cimax, - int begin_stripe[], int last_stripe[] ); - - -int main( int argc, char *argv[] ) -{ - double crmin, crmax, cimin, cimax; - double store_iter[NY*(NX/N_STRIPE+1)]; - int begin_stripe[N_STRIPE], last_stripe[N_STRIPE]; - int stripe; - int store_n, i_point; - int count; - int my_id, numprocs, ip; - int sent_stripe, recv_stripe, stripe_in_proc[MAX_PROCS]; - int from_node, number_from_node; - int end_signal; - - MPI_Status mesgStatus; - - MPI_Init(&argc, &argv); /* start MPI virtual machine */ - - MPI_Comm_rank(MPI_COMM_WORLD, &my_id); - MPI_Comm_size(MPI_COMM_WORLD, &numprocs); - - - /* initialize grid & stripes */ - grid_stripes ( &crmin, &crmax, &cimin, &cimax, begin_stripe, last_stripe ); - - count = 0; - /**********/ - /* master */ - /**********/ - if(my_id == 0) - { - sent_stripe = 0; - recv_stripe = 0; /* logic of stripes */ - /* send original stripe to slaves */ - for( ip = 1; ip < numprocs; ip++) - { - MPI_Ssend(&sent_stripe, 1, MPI_INT, ip, 5, MPI_COMM_WORLD); - stripe_in_proc[ip] = sent_stripe; - sent_stripe++; - } - - for( recv_stripe = 0; recv_stripe < N_STRIPE; recv_stripe++) - { - /* Recieve result back from a node */ - MPI_Recv(store_iter, NY*(NX/N_STRIPE+1), MPI_DOUBLE, MPI_ANY_SOURCE, 7, - MPI_COMM_WORLD, &mesgStatus); - from_node = mesgStatus.MPI_SOURCE; - MPI_Get_count( &mesgStatus, MPI_DOUBLE, &number_from_node ); - fprintf( stderr, "From node %d -- stripe & # %d %d \n", from_node, - stripe_in_proc[from_node], number_from_node ); - /* Termination logic. */ - end_signal = -1; - fprintf( stderr, "I'm sending a termination signal to %d \n", from_node); - fflush(stderr); - MPI_Ssend( &end_signal, 1, MPI_INT, from_node, 5, MPI_COMM_WORLD); - fprintf( stderr, "I have sent a termination signal to %d \n", from_node); - fflush(stderr); - } - - } - /**********/ - /* slave */ - /**********/ - else - { - for ( ; ; ) - { - /* I'm getting a stripe to do, YAHOO! */ - MPI_Recv(&stripe, 1, MPI_INT, 0, 5, MPI_COMM_WORLD, &mesgStatus); - fprintf(stderr, "my ID: %d -- recieved stripe: %d \n", my_id, stripe); - - if( stripe < 0) - { - fprintf(stderr, "Node %d is quitting. \n", my_id); - MPI_Finalize(); - exit(0); - } - - /* find the points in the set */ - compute_stripe( crmin, crmax, cimin, cimax, begin_stripe[stripe], - last_stripe[stripe], store_iter, &store_n); - - /* send stripe results back to master */ - MPI_Ssend(store_iter, store_n, MPI_DOUBLE, 0, 7, MPI_COMM_WORLD); - } - } - - MPI_Finalize(); -} - - - - -void grid_stripes( double *crmin, double *crmax, double *cimin, double *cimax, - int begin_stripe[], int last_stripe[] ) -{ - int w_stripe, stripe, left_over; - /* define grid spanning */ - /* the complex plane for */ - /* the C variable */ - *crmin=-1.7; - *crmax = 0.8; - *cimin = -1.0; - *cimax = 1.0; - /* stripe definition */ - /* stripe # does not have to be */ - /* commensurate with grid size */ - /* in which case add 1 to some */ - /* stripes */ - w_stripe= NX/N_STRIPE; - left_over = NX % N_STRIPE; - /* fist stripe */ - begin_stripe[0] = 0; - last_stripe[0] = begin_stripe[0] + w_stripe - 1; - if ( left_over > 0 ) - { - last_stripe[0] = last_stripe[0] + 1; - left_over--; - } - /* other stripes */ - for ( stripe = 1; stripe < N_STRIPE ; stripe++ ) - { - begin_stripe[stripe] = last_stripe[stripe-1] + 1 ; - last_stripe[stripe] = begin_stripe[stripe] + w_stripe - 1; - if ( left_over > 0 ) - { - last_stripe[stripe] = last_stripe[stripe] + 1; - left_over--; - } - } -} - - - - -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n) -{ - double z_real, z_img, z_magnitude; - double c_real, c_img, z_current_real; - double dcr, dci; - int i, j; - int counter; - - /* scan C values on complex plane */ - dcr = (crmax - crmin)/(double)(NX-1); - dci = (cimax - cimin)/(double)(NY-1); - /* scan stripe */ - *store_n=0; - for ( i=i_min ; i<=i_max; i++ ) - { - for ( j=0 ; j LARGE_RADIUS ) break; - } - /* store iteration numbers */ - /* to plot the set */ - store_iter[*store_n] = - (double)(255*counter) / (double)MAX_ITERATIONS ; - (*store_n)++; - } - } -} - diff --git a/src/mandelbrot/legacy_codes/mandelbrot_blocked.c b/src/mandelbrot/legacy_codes/mandelbrot_blocked.c deleted file mode 100644 index 9d87eb3..0000000 --- a/src/mandelbrot/legacy_codes/mandelbrot_blocked.c +++ /dev/null @@ -1,161 +0,0 @@ - - /**********************************/ - /* */ - /* The Mandelbrot Set */ - /* */ - /* z = z*z + c */ - /* */ - /* Adapted to calculate the Set */ - /* in stripes parallel to Img axis*/ - /* */ - /* Improved routines structure */ - /* to facilitate parallel */ - /* implementation */ - /**********************************/ - - /* Michel Vallieres */ - -#include -#include - /* large distance; if |z| reaches */ - /* 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 80 -#define NX 600 /* image size */ -#define NY 500 -#define N_STRIPE 37 /* number of stripes */ - - /* prototypes */ -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n); -void grid_stripes( double *crmin, double *crmax, double *cimin, double *cimax, - int begin_stripe[], int last_stripe[] ); - - -int main( int argc, char *argv[] ) -{ - double crmin, crmax, cimin, cimax; - double store_iter[NY*(NX/N_STRIPE+1)]; - int begin_stripe[N_STRIPE], last_stripe[N_STRIPE]; - int stripe; - int store_n, i_point; - int count; - /* initialize grid & stripes */ - grid_stripes ( &crmin, &crmax, &cimin, &cimax, begin_stripe, last_stripe ); - - count = 0; - /* scan over stripes */ - for( stripe = 0; stripe < N_STRIPE; stripe++ ) - { - /* find the points in the set */ - compute_stripe( crmin, crmax, cimin, cimax, begin_stripe[stripe], - last_stripe[stripe], store_iter, &store_n); - - /* output iteration # for plot */ - for ( i_point = 0 ; i_point < store_n ; i_point++ ) - { - count ++; - printf( " %f ", store_iter[i_point] ); - } - } -} - - - - -void grid_stripes( double *crmin, double *crmax, double *cimin, double *cimax, - int begin_stripe[], int last_stripe[] ) -{ - int w_stripe, stripe, left_over; - /* define grid spanning */ - /* the complex plane for */ - /* the C variable */ - *crmin=-1.7; - *crmax = 0.8; - *cimin = -1.0; - *cimax = 1.0; - /* stripe definition */ - /* stripe # does not have to be */ - /* commensurate with grid size */ - /* in which case add 1 to some */ - /* stripes */ - w_stripe= NX/N_STRIPE; - left_over = NX % N_STRIPE; - /* fist stripe */ - begin_stripe[0] = 0; - last_stripe[0] = begin_stripe[0] + w_stripe - 1; - if ( left_over > 0 ) - { - last_stripe[0] = last_stripe[0] + 1; - left_over--; - } - /* other stripes */ - for ( stripe = 1; stripe < N_STRIPE ; stripe++ ) - { - begin_stripe[stripe] = last_stripe[stripe-1] + 1 ; - last_stripe[stripe] = begin_stripe[stripe] + w_stripe - 1; - if ( left_over > 0 ) - { - last_stripe[stripe] = last_stripe[stripe] + 1; - left_over--; - } - } -} - - - - -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n) -{ - double z_real, z_img, z_magnitude; - double c_real, c_img, z_current_real; - double dcr, dci; - int i, j; - int counter; - - /* scan C values on complex plane */ - dcr = (crmax - crmin)/(double)(NX-1); - dci = (cimax - cimin)/(double)(NY-1); - /* scan stripe */ - *store_n=0; - for ( i=i_min ; i<=i_max; i++ ) - { - for ( j=0 ; j LARGE_RADIUS ) break; - } - /* store iteration numbers */ - /* to plot the set */ - store_iter[*store_n] = - (double)(255*counter) / (double)MAX_ITERATIONS ; - (*store_n)++; - } - } -} - diff --git a/src/mandelbrot/legacy_codes/mandelbrot_parallel.c b/src/mandelbrot/legacy_codes/mandelbrot_parallel.c deleted file mode 100644 index df95d10..0000000 --- a/src/mandelbrot/legacy_codes/mandelbrot_parallel.c +++ /dev/null @@ -1,256 +0,0 @@ - - /**********************************/ - /* */ - /* The Mandelbrot Set */ - /* */ - /* z = z*z + c */ - /* */ - /* parallel version */ - /* */ - /**********************************/ - - /* Michel Vallieres */ - -#include -#include -#include "mpi.h" - /* large distance; if |z| reaches */ - /* 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 80 -#define NX 600 /* image size */ -#define NY 500 -#define N_STRIPE 37 /* number of stripes */ -#define MAX_PROC 100 /* max # of processes */ - - /* prototypes */ -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n); -void grid_stripes( double *crmin, double *crmax, double *cimin, double *cimax, - int begin_stripe[], int last_stripe[] ); - - -int main( int argc, char *argv[] ) -{ - double crmin, crmax, cimin, cimax; - double store_iter[NY*(NX/N_STRIPE+1)]; - double global_store_iter[NY*NX]; - int begin_stripe[N_STRIPE], last_stripe[N_STRIPE]; - int stripe; - int store_n, i_point, offset; - int count; - int myid, numprocs; - MPI_Status mesgStatus; - int stripe_in_proc[MAX_PROC], sent_stripe, recv_stripe, from_node, - from_stripe, number_from_node, ip; - int end_signal; - - /* start the MPI virtual machine */ - MPI_Init(&argc,&argv); - MPI_Comm_size(MPI_COMM_WORLD,&numprocs); - MPI_Comm_rank(MPI_COMM_WORLD,&myid); - - /* initialize grid & stripes */ - grid_stripes ( &crmin, &crmax, &cimin, &cimax, begin_stripe, last_stripe ); - - /*****************/ - /* Master code */ - /*****************/ - if ( myid == 0 ) - { - - count = 0; - - /* initilalize send counter */ - sent_stripe = 0; - /* send a stripe to each slave */ - /* to start local calculation */ - for ( ip=1 ; ip 0 ) - { - last_stripe[0] = last_stripe[0] + 1; - left_over--; - } - /* other stripes */ - for ( stripe = 1; stripe < N_STRIPE ; stripe++ ) - { - begin_stripe[stripe] = last_stripe[stripe-1] + 1 ; - last_stripe[stripe] = begin_stripe[stripe] + w_stripe - 1; - if ( left_over > 0 ) - { - last_stripe[stripe] = last_stripe[stripe] + 1; - left_over--; - } - } -} - - - - -void compute_stripe( double crmin, double crmax, double cimin, double cimax, - int i_min, int i_max, double store_iter[], - int *store_n) -{ - double z_real, z_img, z_magnitude; - double c_real, c_img, z_current_real; - double dcr, dci; - int i, j; - int counter; - - /* scan C values on complex plane */ - dcr = (crmax - crmin)/(double)(NX-1); - dci = (cimax - cimin)/(double)(NY-1); - /* scan stripe */ - *store_n=0; - for ( i=i_min ; i<=i_max; i++ ) - { - for ( j=0 ; j LARGE_RADIUS ) break; - } - /* store iteration numbers */ - /* to plot the set */ - store_iter[*store_n] = - (double)(255*counter) / (double)MAX_ITERATIONS ; - (*store_n)++; - } - } -} - diff --git a/src/mandelbrot/legacy_codes/mandelbrot_sliced.c b/src/mandelbrot/legacy_codes/mandelbrot_sliced.c deleted file mode 100644 index 7b12aa2..0000000 --- a/src/mandelbrot/legacy_codes/mandelbrot_sliced.c +++ /dev/null @@ -1,132 +0,0 @@ - - /**********************************/ - /* */ - /* The Mandelbrot Set */ - /* */ - /* z = z*z + c */ - /* */ - /* Adapted to calculate the Set */ - /* in stripes parallel to Img axis*/ - /* */ - /**********************************/ - - /* Summer School 1995 */ - - -#include -#include - /* large distance; if |z| reaches */ - /* 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 80 -#define NX 500 -#define NY 500 -#define N_STRIPE 25 - - /* prototype */ -void compute_stripe( double crmin, double crmax, - double cimin, double cimax, double dcr, double dci, - int i_min, int i_max, double store_r[], double store_i[], - int *store_n); - -main() -{ - double crmin, crmax, cimin, cimax; - double dcr, dci; - double store_r[NY*NX/N_STRIPE], store_i[NY*NX/N_STRIPE]; - int w_stripe, stripe; - int i_min, i_max; - int store_n; - int i; - - /* define grid spanning */ - /* the complex plane for */ - /* the C variable */ - crmin=-1.7; - crmax = 0.8; - cimin = -1.0; - cimax = 1.0; - /* stripe definition */ - w_stripe= NX/N_STRIPE; - - /* scan C values on complex plane */ - dcr = (crmax - crmin)/(double)(NX-1); - dci = (cimax - cimin)/(double)(NY-1); - - /* scan over stripes */ - for( stripe = 0; stripe < N_STRIPE; stripe++ ) - { - i_min= stripe*w_stripe; - i_max= (stripe+1)*w_stripe - 1; - if( stripe == N_STRIPE-1 ) i_max = NX; - - /* find the points in the set */ - compute_stripe( crmin, crmax, cimin, cimax, dcr, dci, i_min, i_max, - store_r, store_i, &store_n); - /* output coordinates in set */ - /* - for( i=0; i< store_n; i++ ) - printf("%f %f\n", store_r[i], store_i[i]); - */ - } - -} - - -void compute_stripe( double crmin, double crmax, - double cimin, double cimax, double dcr, double dci, - int i_min, int i_max, double store_r[], double store_i[], - int *store_n) -{ - double z_real, z_img, z_magnitude; - double c_real, c_img, z_current_real; - int i, j; - int counter; - - *store_n=0; - for ( i=i_min ; i<=i_max; i++ ) - { - for ( j=0 ; j LARGE_RADIUS ) break; - } - /* store C real and */ - /* imaginary parts if */ - /* C belongs to the set */ - if ( z_magnitude < LARGE_RADIUS ) - { - store_r[*store_n]=c_real; - store_i[*store_n]=c_img; - (*store_n)++; - } - - printf ( " %f ", (double)(255*counter) / (double)MAX_ITERATIONS ); - } - - } - -} -