Skip to: Site menu | Main content

Gruple

Concurrent and parallel programming in Groovy

Demos Print

How to run the Gruple Demos

Introduction

Gruple comes with one demo, currently. More will probably be added in future. Below are the instructions on how to run the demo(s).

Mandelbrot Viewer: Visually demonstrating the Master-Worker pattern

The Mandelbrot demo uses the Master-Worker pattern to compute the Mandelbrot set and display it. To run it, go to the directory Examples and type "ant mandelbrot". This will launch the process dividing the job into 16 tasks among 4 workers and displaying the result in a 640x640 window. Once the graphic has finished drawing, click and drag to re-draw a close-up of the bracketed area.

To modify the numbers of tasks and workers, as well as the size of the display, edit build.properties and add the lines:

tasks=t

workers=s

width=w

height=h

With t, s, w, and h set to what you like. Please note the following:

  • The display looks better when height and width are equal (a square window)
  • The number of tasks must be equally divisible into the height. For example, 16 divides into 640 with no remainder, so it is fine. Similarly, 25 divides into 500, etc. Uneven divisors will result in images with missing stripes.

Hint

If you have a machine with more than one processor or core, try variations of the demo using workers from 1 up to the number of processors available. The difference in speed may be overwhelmed by the time taken to draw the image, but it could still be informative, especially if you have 4 or more processors/cores.

Credits

Please note that the Mandelbrot program was adapted from an example in:

Eric Freeman, Susanne Hupfer, and Ken Arnold. !JavaSpaces Principles, Patterns, and Practice, Addison Wesley, 1999.