Archive for HTML5

Distributed Mandelbrot computation with HTML5 workers

Computing fractals usually requires lots of CPU cycles and taking advantage of today’s multicore processors allows us to speed-up the computation. The HTML5 specification defines a new API for parallel computation known as Web Workers. In the example available here, the Mandelbrot figure is computed with HTML5 workers and displayed using an HTML5 canvas.

The Mandelbrot fractal figure

The distributed computation is made according to the scheduler/worker scheme.

The scheduler is responsible for starting the workers, feeding them with the description of their task, and drawing a dot on the canvas for each result received from a worker. Assuming that the work is distributed among n workers, the drawing area is divided in n equal parts and each worker receives its part of the work. A worker iterates on the dots contained in its area and evaluates the Mandelbrot value for each dot. Each computed value is then communicated to the scheduler through the event handling system defined by the web workers API.


Leave a Comment