Class MandelbrotSetHyb2
- java.lang.Object
-
- edu.rit.hyb.fractal.MandelbrotSetHyb2
-
public class MandelbrotSetHyb2 extends java.lang.ObjectClass MandelbrotSetHyb2 is a hybrid parallel program that calculates the Mandelbrot Set. The program runs with one process per node and multiple threads per process. The program uses the master-worker pattern for load balancing. Each process in the program is an independent worker process. Each worker process calculates a series of row slices of the Mandelbrot Set image, as assigned by the master thread. Within each row slice, the threads of the worker process calculate the rows of the slice in parallel. Each worker writes its own slices to its own (partial) PJG image file. The per-worker image files can be combined offline into a single image file if desired.The row slices are determined by the pj.schedule property specified on the command line; the default is to divide the rows evenly among the worker processes (i.e. no load balancing). For further information about the pj.schedule property, see class PJProperties.
Within each row slice, the rows are partitioned among the threads of the worker process using the parallel loop schedule specified by the last command line argument. If this argument is missing, the default is to divide the rows evenly among the threads (i.e. no load balancing). For further information, see the parse() method in class IntegerSchedule.
Usage: java -Dpj.np=Kp -Dpj.nt=Kt [ -Dpj.schedule=procschedule ] edu.rit.hyb.fractal.MandelbrotSetHyb2 width height xcenter ycenter resolution maxiter gamma filename [ thrschedule ]
Kp = Number of parallel processes
Kt = Number of parallel threads per process
procschedule = Load balancing schedule for processes
width = Image width (pixels)
height = Image height (pixels)
xcenter = X coordinate of center point
ycenter = Y coordinate of center point
resolution = Pixels per unit
maxiter = Maximum number of iterations
gamma = Used to calculate pixel hues
filename = PJG image file name
thrschedule = Load balancing schedule for threadsIf filename is specified as, for example, "image.pjg", then the per-worker image files are named "image_0.pjg", "image_1.pjg", and so on through Kp-1.
The program considers a rectangular region of the complex plane centered at (xcenter,ycenter) of width pixels by height pixels, where the distance between adjacent pixels is 1/resolution. The program takes each pixel's location as a complex number c and performs the following iteration:
z0 = 0
zi+1 = zi2 + cuntil zi's magnitude becomes greater than or equal to 2, or i reaches a limit of maxiter. The complex numbers c where i reaches a limit of maxiter are considered to be in the Mandelbrot Set. (Actually, a number is in the Mandelbrot Set only if the iteration would continue forever without zi becoming infinite; the foregoing is just an approximation.) The program creates an image with the pixels corresponding to the complex numbers c and the pixels' colors corresponding to the value of i achieved by the iteration. Following the traditional practice, points in the Mandelbrot set are black, and the other points are brightly colored in a range of colors depending on i. The exact hue of each pixel is (i/maxiter)gamma. The image is stored in a Parallel Java Graphics (PJG) file specified on the command line.
The computation is performed in parallel in multiple processors. The program measures the computation's running time, including the time to write the image file.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static voidmain(java.lang.String[] args)Mandelbrot Set main program.
-
DMelt 3.0 © DataMelt by jWork.ORG