#include #include #include #include "fish.h" #define RANDOM(r) ((random()%10000)*r/10000.0) #define DT 0.1 /* time step resolution */ #define SIZE 256 /* width of ocean */ #define PROCS CMMD_partition_size() #define ME CMMD_self_address() float cell[10][SIZE+2]; /* cell owned by each proc */ float count[10][SIZE+2]; /* neighbor counts */ /* the procs are laid from top to down in a 1-D array*/ main() { struct arg_data args; int fish; int tsteps; int psteps; int x,y; int i,j,k,t; int next_proc; int ROW; CMMD_enable_host (); CMMD_receive_bc_from_host (&args, sizeof (struct arg_data)); fish = args.fish; tsteps = args.tsteps; psteps = args.psteps; CMNA_timer_clear (0); CMNA_timer_start (0); ROW = SIZE/PROCS; /* initialize random number generator */ srandom(CMMD_self_address()); /* initialize cell */ for (i=0;i=4) cell[i][j] = 0; /* send info. to host for display */ if (++k > psteps) { k = 0; CMMD_send(CMMD_host_node(),0,&cell[1][0], sizeof(float)*ROW*(SIZE+2)); } } /* synchronize with host to end program */ CMNA_timer_stop (0); CMMD_reduce_to_host_double (CMNA_timer_busy (0), CMMD_combiner_dmax); return; }