File: mpi_world

package info (click to toggle)
pyina 0.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 548 kB
  • sloc: python: 2,666; makefile: 34
file content (52 lines) | stat: -rwxr-xr-x 1,691 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 1997-2016 California Institute of Technology.
# Copyright (c) 2016-2025 The Uncertainty Quantification Foundation.
# License: 3-clause BSD.  The full license text is available at:
#  - https://github.com/uqfoundation/pyina/blob/master/LICENSE
#
# helper script to setup your mpi environment

import pyina.__main__
from pyina.__main__ import *
__doc__ = pyina.__main__.__doc__


if __name__=="__main__":
    import sys
    from pyina.launchers import MpiPool

    if sys.argv[-1] == "--kill":
        print("killing all...")
        kill_all()
    elif len(sys.argv) > 2:
        if sys.argv[1] == "--workers":
            print("seting up mpi...")
            MASTERINFO = set_master()
            nodes = sys.argv[2:]
            nodes = [node.strip('[()]').strip(',').strip() for node in nodes]
            #nodes = nodes.strip('[()]').split(',')
            set_workers(nodes,MASTERINFO)
       #elif sys.argv[1] == "--alias": 
       #    print "setting up mpi python..."
       #    nodes = sys.argv[2:]
       #    nodes = [node.strip('[()]').strip(',').strip() for node in nodes]
       #    for node in nodes:
       #        alias(int(node))
        elif sys.argv[1] == "--fetch":
            nnodes = int(sys.argv[2])
            try:
                pool = MpiPool()
                pool.nodes = nnodes
                hostnames = pool.map(host, range(nnodes))
                print('\n'.join(hostnames))
            except: # "--help"
                print(__doc__)
        else: # "--help"
            print(__doc__)
    else: # "--help"
        print(__doc__)


# End of file