Ejemplo n.º 1
0
def run_pool(obj):
    from pyina.launchers import Mpi
    p = Mpi(2)
    x = [1, 2, 3]
    y = list(map(obj, x))
    p.scatter = False
    assert p.map(obj, x) == y
    p.source = True
    assert p.map(obj, x) == y
    p.scatter = True
    assert p.map(obj, x) == y
    p.source = False
    assert p.map(obj, x) == y
Ejemplo n.º 2
0
def test_pool(obj):
    from pyina.launchers import Mpi
    p = Mpi(2)
    x = [1,2,3]
    y = map(obj, x)
    p.scatter = False
    assert p.map(obj, x) == y
    p.source = True
    assert p.map(obj, x) == y
    p.scatter = True
    assert p.map(obj, x) == y
    p.source = False
    assert p.map(obj, x) == y
Ejemplo n.º 3
0
#!/usr/bin/env python
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 1997-2016 California Institute of Technology.
# Copyright (c) 2016-2017 The Uncertainty Quantification Foundation.
# License: 3-clause BSD.  The full license text is available at:
#  - http://trac.mystic.cacr.caltech.edu/project/pathos/browser/pyina/LICENSE

from pyina.launchers import Mpi

def host(id):
    import socket
    return "Rank: %d -- %s" % (id, socket.gethostname())

print "Explicitly using the MPI launcher, we will execute..."
pool = Mpi(4)
print "10 items on 4 nodes using a worker pool:"
res1 = pool.map(host, range(10))
print pool
print '\n'.join(res1)
print ''

print "10 items on 4 nodes using scatter-gather:"
pool.scatter = True
res2 = pool.map(host, range(10))
print pool
print '\n'.join(res2)

# end of file
Ejemplo n.º 4
0
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 1997-2016 California Institute of Technology.
# Copyright (c) 2016-2018 The Uncertainty Quantification Foundation.
# License: 3-clause BSD.  The full license text is available at:
#  - https://github.com/uqfoundation/pyina/blob/master/LICENSE

from pyina.launchers import Mpi


def host(id):
    import socket
    return "Rank: %d -- %s" % (id, socket.gethostname())


print("Explicitly using the MPI launcher, we will execute...")
pool = Mpi(4)
print("10 items on 4 nodes using a worker pool:")
res1 = pool.map(host, range(10))
print(pool)
print('\n'.join(res1))
print('')

print("10 items on 4 nodes using scatter-gather:")
pool.scatter = True
res2 = pool.map(host, range(10))
print(pool)
print('\n'.join(res2))

# end of file