Home
School Stuff
Java on FreeBSD
Back Up Fastmal

vee
Perl-FLaT
Google
 
Here are some programs that I did for this class. They all use the MPICH implementation of the MPI standard for parallel communications. These represent my first attempts at both "from scratch" c coding and parallel programs.

Conway's Game Of Life
C's GoL is a demostration on how complex patterns and behaviors can arise out of a simple set of rules. More details of this example of
cellular automata can be seen here. This stuff is really cool and very powerful. Cellular automata can actually be used make calculations and predict out comes, and they are equally as powerful as a Turing Machine (finite state automata). At some point I would love to incorporate OpenGL into this program so that it shows the animation in real time. An even cooler idea would be to have a cellular automata development environment that let you define complex rules on both 2d & 3D domains, run iterations, view the animation, and facilitate converting the resulting patterns into usable data...that seems very interesting to me - if only I had the time ;)

Files:
Note: if anyone comes up with an init.dat pattern, let me know so I can make it available - you will receive full credit :)

Instructions:
Unless otherwise noted, the above init files are 32x32 matrices. Because of my lack of c wizardry, the matrix for my implementation must be square, i.e., WIDTH == HEIGHT. That being said, here are some instructions to get you up and running quickly (assuming you have mpi installed).
  1. Download bde_life.c, animate.sh, and init.dat from above.
  2. Rename animate.sh.txt to animate.sh
  3. Make sure animate.sh is executabile - "chmod 755 animate.sh"
  4. Run animate.sh; usage: "./animate.sh matrix_dimension number_iterations num_procs"
For example, using the default init.dat:
#./animate.sh 32 100 1
The program will then run using init.dat as its initial cell configuration, for 32 iterations (or generations), on a single processor. When you run animate.sh, you will see the program output some frames to the screen. Behiond the scenes, each frame is being dumped into a directory called "frames". When the program is finished running, animate.sh will then cycle through the frames. The frames are outputted WITHOUT the zeros, so you can see the patterns that develop more easily.

On Parallelization:
Since this was my first parallel program ever, I distributed the global matrix to each processor. This is definitely NOT the way to do it, but there is not shame in doing things the straightforward way when you are ffirst learning something. I also screwed up the dynamic array allocation, so the matrix must be a square.

Parallel 2D Finite Difference Method
I implemented three different finite difference methods in parallel that are used to predict heat distribution in a 2d domain. This problem is very simple:
  • 1 external heat source applied at a single point long the boundary
  • All other parts of the boundary are held at 0.0 degrees (oC oroF, doesn't matter)
  • This is not done in the time domain, therefore there is no "t" in the equation
I used the following methods: Jacobi, Gauss-Seidel, and SOR.

Files:

Instructions:
The domain size is controlled at the top of the source code file using "WIDTH" and "HEIGHT". "H" is the spacing, so you will have a total of (WIDTH/H)*(HEIGHT/H) which results in more than WIDTH*HEIGHT elements if H is less than 1. I also experienced some problems with the convergence in the SOR method as I set W closer to 1.9. Here are the instructions needed to get this bad boy up and running (again, assuming you have mpi installed):
  1. Download bde_2dheat.c and compile.sh from above.
  2. Rename compile.sh.txt to compile.sh
  3. Makesre compile.sh is executable - "chmod 755 compile.sh"
  4. Run compile.sh; usage: "./compile.sh num_procs"
For example:
#./compile.sh 8
The program will then compile and run on 8 processors. Again, the domain size and nodal spacing is set at the op of the program. When the program is run, it will ask what method you wish to use and if you want to see the convergence criteria for each iteration. At the end of the run, you are told how many iterations it to to converge and how long in seconds it took to get there. The script, compile.sh, will then globalize the output files for you which shows the converged solution over the entire domain as of the last iteration.

On Parallelization::
This is covered in the slides and paper. It is done basically by assigning a block of rows to each process. Ghost rows are communicated at each iteration and the convergence is calculated using the L2-norm method, and is accomplished in part on a local scale, then reduced on the master node using an MPI_Reduce call of type MPI_SUM. Also, unlike my implementation of the GoL, each processor does not contain a copy of the global matrix. In fact, there is no point in which there is any globalization of the domain.


FreeBSD
Perl
DfBSD
LSU HPC
LONI
LSU CCT