# source:branches/numpy_misc/tools/acceptance_tests/mandelbrot/mandel_parallel_blockwise.py@6991

Last change on this file since 6991 was 6991, checked in by rwilson, 15 years ago

Initial commit of the cluster acceptance package.

• Property svn:executable set to `*`
File size: 1.4 KB
Line
1#!/usr/bin/env python
2
3"""Parallel program computing the Mandelbrot set using static partitioned
5
6   Due to the uneven work load of different regions,
7   this strategy will *not* generally lead to linear speedup
8
9   See mandel_parallel_dynamic.py for a better approach.
10
11   Ole Nielsen, SUT 2003
12"""
13
14from mandelbrot import calculate_region, balance
15from mandelplot import plot
16import pypar
17
18# User definable parameters
19kmax = 2**15   # Maximal number of iterations (=number of colors)
20M = N = 700    # width = height = N (200 or 700)
21
22# Region in complex plane
23real_min = -2.0
24real_max =  1.0
25imag_min = -1.5
26imag_max =  1.5
27
28#Initialise
29t = pypar.time()
30P = pypar.size()
31p = pypar.rank()
32processor_name = pypar.get_processor_name()
33
34print 'Processor %d initialised on node %s' %(p,processor_name)
35
36
37# Balanced work partitioning (row wise)
38Mlo, Mhi = pypar.balance(M, P, p)
39print 'p%d: [%d, %d], Interval length=%d' %(p, Mlo, Mhi, Mhi-Mlo)
40
41# Parallel computation
42A = calculate_region(real_min, real_max, imag_min, imag_max, kmax,
43                     M, N, Mlo = Mlo, Mhi = Mhi)
44
45print 'Processor %d: time = %.2f' %(p, pypar.time() - t)
46
47
48# Communication phase
49if p == 0:
50    for d in range(1, P):