Last change
on this file since 8543 was
8513,
checked in by steve, 13 years ago
|
Adding working asynchronous update_ghosts
|
File size:
1.2 KB
|
Line | |
---|
1 | """Abstract parallel interface - suitable for sequential programs |
---|
2 | |
---|
3 | Use pypar for parallism if installed. |
---|
4 | Otherwise define a rudimentary interface for sequential execution. |
---|
5 | """ |
---|
6 | |
---|
7 | class NullStream: |
---|
8 | def write(self,text): |
---|
9 | pass |
---|
10 | |
---|
11 | |
---|
12 | |
---|
13 | |
---|
14 | try: |
---|
15 | import sys |
---|
16 | #sys.stdout = NullStream() |
---|
17 | import pypar |
---|
18 | #sys.stdout = sys.__stdout__ |
---|
19 | except: |
---|
20 | print 'WARNING: Could not import pypar - defining sequential interface' |
---|
21 | def size(): return 1 |
---|
22 | def rank(): return 0 |
---|
23 | |
---|
24 | def get_processor_name(): |
---|
25 | import os |
---|
26 | try: |
---|
27 | hostname = os.environ['HOST'] |
---|
28 | except: |
---|
29 | try: |
---|
30 | hostname = os.environ['HOSTNAME'] |
---|
31 | except: |
---|
32 | hostname = 'Unknown' |
---|
33 | |
---|
34 | return hostname |
---|
35 | |
---|
36 | def abort(): |
---|
37 | import sys |
---|
38 | sys.exit() |
---|
39 | |
---|
40 | def finalize(): pass |
---|
41 | |
---|
42 | def barrier(): pass |
---|
43 | |
---|
44 | def time(): |
---|
45 | import time |
---|
46 | return time.time() |
---|
47 | |
---|
48 | def send(*args, **kwargs): |
---|
49 | pass |
---|
50 | |
---|
51 | def receive(*args, **kwargs): |
---|
52 | pass |
---|
53 | |
---|
54 | def reduce(*args, **kwargs): |
---|
55 | pass |
---|
56 | |
---|
57 | MIN = None |
---|
58 | |
---|
59 | pypar_available = False |
---|
60 | else: |
---|
61 | import sys |
---|
62 | sys.stdout = NullStream() |
---|
63 | from pypar import * |
---|
64 | sys.stdout = sys.__stdout__ |
---|
65 | pypar_available = True |
---|
Note: See
TracBrowser
for help on using the repository browser.