Last change
on this file since 3818 was
3776,
checked in by ole, 18 years ago
|
Made parallel abstraction work on sequential machine without pypar.
Work on simple parallel example (plotting)
|
File size:
977 bytes
|
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 | try: |
---|
8 | import pypar |
---|
9 | except: |
---|
10 | print 'WARNING: Could not import pypar - defining sequential interface' |
---|
11 | def size(): return 1 |
---|
12 | def rank(): return 0 |
---|
13 | |
---|
14 | def get_processor_name(): |
---|
15 | import os |
---|
16 | try: |
---|
17 | hostname = os.environ['HOST'] |
---|
18 | except: |
---|
19 | try: |
---|
20 | hostname = os.environ['HOSTNAME'] |
---|
21 | except: |
---|
22 | hostname = 'Unknown' |
---|
23 | |
---|
24 | return hostname |
---|
25 | |
---|
26 | def abort(): |
---|
27 | import sys |
---|
28 | sys.exit() |
---|
29 | |
---|
30 | def finalize(): pass |
---|
31 | |
---|
32 | def barrier(): pass |
---|
33 | |
---|
34 | def time(): |
---|
35 | import time |
---|
36 | return time.time() |
---|
37 | |
---|
38 | def send(*args, **kwargs): |
---|
39 | pass |
---|
40 | |
---|
41 | def receive(*args, **kwargs): |
---|
42 | pass |
---|
43 | |
---|
44 | pypar_available = False |
---|
45 | else: |
---|
46 | from pypar import * |
---|
47 | pypar_available = True |
---|
Note: See
TracBrowser
for help on using the repository browser.