Exemple #1
0
    from numpy import sin
    return sin(x - xp)


# print the input to screen
x = np.arange(N * nodes, dtype=np.float64)
xp = np.arange(N * nodes, dtype=np.float64)[::-1]
print("Input: %s\n" % x)

# map sin_diff to the workers, then print to screen
print("Running serial python ...")
y = map(sin_diff, x, xp)
print("Output: %s\n" % np.asarray(y))

# map sin_diff to the workers, then print to screen
print("Running mpi4py on %d cores..." % nodes)
y = MpiPool(nodes).map(sin_diff, x, xp)
print("Output: %s\n" % np.asarray(y))

# map sin_diff to the workers, then print to screen
print("Running multiprocesing on %d processors..." % nodes)
y = ProcessingPool(nodes).map(sin_diff, x, xp)
print("Output: %s\n" % np.asarray(y))

# map sin_diff to the workers, then print to screen
print("Running parallelpython on %d cpus..." % nodes)
y = ParallelPythonPool(nodes).map(sin_diff, x, xp)
print("Output: %s\n" % np.asarray(y))

# EOF
Exemple #2
0
def test_ppmap(obj):
    from pathos.pp import ParallelPythonPool
    p = ParallelPythonPool(2)
    x = [1, 2, 3]
    assert map(obj, x) == p.map(obj, x)
Exemple #3
0
    """sin squared of all data"""
    import numpy as np
    return np.sin(xi)**2


# print the input to screen
x = np.arange(N * nodes, dtype=np.float64)
print("Input: %s\n" % x)

# run sin2 in series, then print to screen
print("Running serial python ...")
y = map(sin2, x)
print("Output: %s\n" % np.asarray(y))

# map sin2 to the workers, then print to screen
print("Running mpi4py on %d cores..." % nodes)
y = MpiPool(nodes).map(sin2, x)
print("Output: %s\n" % np.asarray(y))

# map sin2 to the workers, then print to screen
print("Running multiprocesing on %d processors..." % nodes)
y = ProcessingPool(nodes).map(sin2, x)
print("Output: %s\n" % np.asarray(y))

# map sin2 to the workers, then print to screen
print("Running parallelpython on %d cpus..." % nodes)
y = ParallelPythonPool(nodes).map(sin2, x)
print("Output: %s\n" % np.asarray(y))

# EOF