Last change
on this file since 7293 was
6991,
checked in by rwilson, 16 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 | |
---|
11 | from mandelbrot import calculate_region_cyclic |
---|
12 | from mandelplot import plot |
---|
13 | import pypar |
---|
14 | |
---|
15 | # User definable parameters |
---|
16 | kmax = 2**15 # Maximal number of iterations (=number of colors) |
---|
17 | M = N = 700 # width = height = N (200 or 700) |
---|
18 | |
---|
19 | # Region in complex plane [-2:2] |
---|
20 | real_min = -2.0 |
---|
21 | real_max = 1.0 |
---|
22 | imag_min = -1.5 |
---|
23 | imag_max = 1.5 |
---|
24 | |
---|
25 | #Initialise |
---|
26 | t = pypar.time() |
---|
27 | P = pypar.size() |
---|
28 | p = pypar.rank() |
---|
29 | processor_name = pypar.get_processor_name() |
---|
30 | |
---|
31 | print 'Processor %d initialised on node %s' %(p,processor_name) |
---|
32 | |
---|
33 | |
---|
34 | # Parallel computation |
---|
35 | A = calculate_region_cyclic(real_min, real_max, imag_min, |
---|
36 | imag_max, kmax, |
---|
37 | M, N, p, P) |
---|
38 | |
---|
39 | print 'Processor %d: time = %.2f' %(p, pypar.time() - t) |
---|
40 | |
---|
41 | |
---|
42 | # Communication phase |
---|
43 | if 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) |
---|
49 | else: |
---|
50 | pypar.send(A, destination=0) |
---|
51 | |
---|
52 | pypar.finalize() |
---|
53 | |
---|
54 | |
---|
55 | |
---|
56 | |
---|
57 | |
---|
Note: See
TracBrowser
for help on using the repository browser.