source: branches/numpy_misc/tools/acceptance_tests/mandelbrot/mandel_parallel_cyclic.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.2 KB
Line 
1#!/usr/bin/env python
2       
3"""Parallel program computing the Mandelbrot set using static,
4   cyclic load balancing.
5
6   This is probably the best approach for this problem.
7
8   Ole Nielsen, SUT 2003
9"""
10
11from mandelbrot import calculate_region_cyclic
12from mandelplot import plot
13import pypar
14
15# User definable parameters
16kmax = 2**15  # Maximal number of iterations (=number of colors)
17M = N = 700   # width = height = N (200 or 700)
18
19# Region in complex plane [-2:2]
20real_min = -2.0
21real_max =  1.0
22imag_min = -1.5
23imag_max =  1.5
24
25#Initialise
26t = pypar.time()
27P = pypar.size()
28p = pypar.rank()
29processor_name = pypar.get_processor_name()
30
31print 'Processor %d initialised on node %s' %(p,processor_name)
32
33
34# Parallel computation
35A = calculate_region_cyclic(real_min, real_max, imag_min,
36                            imag_max, kmax,
37                            M, N, p, P)
38
39print 'Processor %d: time = %.2f' %(p, pypar.time() - t)
40
41
42# Communication phase
43if p == 0:
44    for d in range(1, P):
45        A += pypar.receive(source=d)
46
47    print 'Computed region in %.2f seconds' %(pypar.time()-t)
48    #plot(A, kmax)       
49else:
50    pypar.send(A, destination=0)
51
52pypar.finalize()               
53
54
55
56
57
Note: See TracBrowser for help on using the repository browser.