예제 #1
0
#!/usr/bin/env python
#
# 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/pathos/blob/master/LICENSE

from pathos.parallel import stats
from pathos.parallel import ParallelPool as Pool
pool = Pool()


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


print("Evaluate 10 items on 2 cpus")  #FIXME: reset lport below
pool.ncpus = 2
pool.servers = ('localhost:5653', )
res5 = pool.map(host, range(10))
print(pool)
print('\n'.join(res5))
print(stats())
print('')

# end of file
예제 #2
0
            word_count[word] = 1
    return word_count

def top_ten(wordcount):
    for key, value in sorted(word_count.items(), key=operator.itemgetter(1), reverse=True)[:10]:
        print key, value

def wordcount(f):
    words = word_list(f)
    clean = cleanup(words)
    word_dict(clean)

if __name__ == '__main__':
    info('Mainline function')

    pool.ncpus = 2
    pool.servers = ('localhost:17320',)

    words = pool.map(m_word_list, f) 
    pool.join()

    pool.servers = ('localhost:17320',)
    clean_list = pool.map(m_cleanup, words)
    pool.join(clean_list, )

    pool.servers = ('localhost:17320',)
    word_count = pool.map(word_dict, cleanlist)
    pool.join(word_count, )

    top_ten(word_count)
예제 #3
0
#!/usr/bin/env python
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 1997-2016 California Institute of Technology.
# Copyright (c) 2016-2019 The Uncertainty Quantification Foundation.
# License: 3-clause BSD.  The full license text is available at:
#  - https://github.com/uqfoundation/pathos/blob/master/LICENSE

from pathos.parallel import stats
from pathos.parallel import ParallelPool as Pool
pool = Pool()

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


print("Evaluate 10 items on 2 cpus") #FIXME: reset lport below
pool.ncpus = 2
pool.servers = ('localhost:5653',)
res5 = pool.map(host, range(10))
print(pool)
print('\n'.join(res5))
print(stats())
print('')

# end of file
예제 #4
0
@author: snake91
'''

from pathos.parallel import ParallelPool as Pool
import time
pool = Pool()


def host(idhost):
    import socket
    from math import sin
    sumhost = 0
    for i in range(1, 1000):
        for j in range(1, 10000):
            sumhost = sumhost + sin(i / j)

    return "Rank: %d -- %s. %f" % (idhost, socket.gethostname(),
                                   sumhost + idhost)


pool.ncpus = 20
print("Evaluate on " + str(pool.ncpus) + " cpus")

pool.servers = ('192.168.1.113:5653', '192.168.1.109:5654')

res5 = pool.amap(host, range(16))
while not res5.ready():
    time.sleep(1)

print("\n".join(res5.get()))
예제 #5
0
from pathos.parallel import ParallelPool as Pool
pool = Pool()


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


print("Evaluate 10 items on 2 cpus")  #FIXME: reset lport below
pool.ncpus = 2
pool.servers = ('56v6f22-l:55577', )
res5 = pool.map(host, range(10))
print(pool)
print('\n'.join(res5))
# print(stats())
print('')

# end of file