- Timestamp:
- 06/01/13 20:42:22 (3 years ago)
- Location:
- branches/HPCtut
- Files:
-
- 7 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/HPCtut/all_scatter_gather.py
r534 r672 11 11 12 12 import numpy as np 13 from pyina. ez_map import ez_map2 as mpi_map # mpi4py14 from pathos.m p_map import mp_map # multiprocessing15 from pathos.pp _map import pp_map # parallelpython13 from pyina.launchers import Mpi as MpiPool 14 from pathos.multiprocessing import ProcessingPool 15 from pathos.pp import ParallelPythonPool 16 16 nodes = 2; N = 3 17 17 … … 36 36 # map sin2 to the workers, then print to screen 37 37 print("Running mpi4py on %d cores..." % nodes) 38 y = mpi_map(sin2, x, nnodes=nodes)38 y = MpiPool(nodes).map(sin2, x) 39 39 print("Output: %s\n" % np.asarray(y)) 40 40 … … 42 42 # map sin2 to the workers, then print to screen 43 43 print("Running multiprocesing on %d processors..." % nodes) 44 y = mp_map(sin2, x, nproc=nodes)44 y = ProcessingPool(nodes).map(sin2, x) 45 45 print("Output: %s\n" % np.asarray(y)) 46 46 … … 48 48 # map sin2 to the workers, then print to screen 49 49 print("Running parallelpython on %d cpus..." % nodes) 50 y = pp_map(sin2, x, ncpus=nodes, servers=('mycpu.mydomain.com',))50 y = ParallelPythonPool(nodes).map(sin2, x) 51 51 print("Output: %s\n" % np.asarray(y)) 52 52 -
branches/HPCtut/all_scatter_gather2.py
r534 r672 11 11 12 12 import numpy as np 13 from pyina. ez_map import ez_map2 as mpi_map # mpi4py14 from pathos. pp_map import pp_map # parallelpython15 from pathos. mp_map import mp_map # multiprocessing13 from pyina.launchers import Mpi as MpiPool 14 from pathos.multiprocessing import ProcessingPool 15 from pathos.pp import ParallelPythonPool 16 16 nodes = 2; N = 3 17 17 … … 36 36 # map sin_diff to the workers, then print to screen 37 37 print("Running mpi4py on %d cores..." % nodes) 38 y = mpi_map(sin_diff, x, xp, nnodes=nodes) 38 y = MpiPool(nodes).map(sin_diff, x, xp) 39 print("Output: %s\n" % np.asarray(y)) 40 41 42 # map sin_diff to the workers, then print to screen 43 print("Running multiprocesing on %d processors..." % nodes) 44 y = ProcessingPool(nodes).map(sin_diff, x, xp) 39 45 print("Output: %s\n" % np.asarray(y)) 40 46 … … 42 48 # map sin_diff to the workers, then print to screen 43 49 print("Running parallelpython on %d cpus..." % nodes) 44 y = pp_map(sin_diff, x, xp, ncpus=nodes) 45 print("Output: %s\n" % np.asarray(y)) 46 47 48 # map sin2 to the workers, then print to screen 49 print("Running multiprocesing on %d processors..." % nodes) 50 y = mp_map(sin_diff, x, xp, nproc=nodes) 50 y = ParallelPythonPool(nodes).map(sin_diff, x, xp) 51 51 print("Output: %s\n" % np.asarray(y)) 52 52 -
branches/HPCtut/optimize.py
r534 r672 32 32 33 33 # minimize the function 34 from itertools import imap # itertools 35 results = imap(the_solver, model, x0, **kwds) 34 results = map(the_solver, model, x0) 36 35 37 36 # find the results with the lowest energy -
branches/HPCtut/optimize_cheby_diffev_map.py
r534 r672 2 2 """ 3 3 Solve Nth-order Chebyshev polynomial coefficients with Differential Evolution. 4 Launch optimizers in parallel with itertools map.4 Launch optimizers with python's map. 5 5 6 Requires: development version of mystic 6 Requires: development version of mystic, pathos 7 7 http://pypi.python.org/pypi/mystic 8 http://pypi.python.org/pypi/pathos 8 9 """ 9 10 … … 28 29 29 30 # minimize the function 30 results = mapper( solver, x0, **kwds)31 results = mapper(nodes).map(solver, x0) 31 32 32 33 # find the results with the lowest energy … … 51 52 52 53 # get the map functions 53 from itertools import imap # itertools54 from pathos.python import PythonSerial as serial 54 55 55 56 … … 58 59 print "Function: %s" % target 59 60 print "Solver: %s" % 'diffev' 60 optimize(diffev_chebyshev, imap, nodes=1, target=target)61 optimize(diffev_chebyshev, serial, nodes=1, target=target) 61 62 62 63 -
branches/HPCtut/optimize_cheby_powell_map.py
r534 r672 2 2 """ 3 3 Solve Nth-order Chebyshev polynomial coefficients with Powell's method. 4 Launch optimizers in parallel with itertools map.4 Launch optimizers with python's map. 5 5 6 Requires: development version of mystic 6 Requires: development version of mystic, pathos 7 7 http://pypi.python.org/pypi/mystic 8 http://pypi.python.org/pypi/pathos 8 9 """ 9 10 … … 28 29 29 30 # minimize the function 30 results = mapper( solver, x0, **kwds)31 results = mapper(nodes).map(solver, x0) 31 32 32 33 # find the results with the lowest energy … … 51 52 52 53 # get the map functions 53 from itertools import imap # itertools54 from pathos.python import PythonSerial as serial 54 55 55 56 … … 58 59 print "Function: %s" % target 59 60 print "Solver: %s" % 'fmin_powell' 60 optimize(powell_chebyshev, imap, nodes=1, target=target)61 optimize(powell_chebyshev, serial, nodes=1, target=target) 61 62 62 63 -
branches/HPCtut/optimize_cheby_powell_mpimap.py
r534 r672 2 2 """ 3 3 Solve Nth-order Chebyshev polynomial coefficients with Powell's method. 4 Launch optimizers in parallel with mpi4pymap.4 Launch optimizers with mpi4py's map. 5 5 6 6 Requires: development version of mystic, pyina … … 29 29 30 30 # minimize the function 31 results = mapper( solver, x0, **kwds)31 results = mapper(nodes).map(solver, x0) 32 32 33 33 # find the results with the lowest energy … … 52 52 53 53 # get the map functions 54 from pyina. ez_map import ez_map2 as mpi_map # mpi4py54 from pyina.launchers import Mpi as mpipool 55 55 56 56 … … 59 59 print "Function: %s" % target 60 60 print "Solver: %s" % 'fmin_powell' 61 optimize(powell_chebyshev, mpi _map, nodes=10, target=target, nnodes=10)61 optimize(powell_chebyshev, mpipool, nodes=10, target=target) 62 62 63 63 -
branches/HPCtut/optimize_cheby_powell_mpmap.py
r534 r672 2 2 """ 3 3 Solve Nth-order Chebyshev polynomial coefficients with Powell's method. 4 Launch optimizers in parallel with multiprocessingmap.4 Launch optimizers with multiprocessing's map. 5 5 6 6 Requires: development version of mystic, pathos … … 29 29 30 30 # minimize the function 31 results = mapper( solver, x0, **kwds)31 results = mapper(nodes).map(solver, x0) 32 32 33 33 # find the results with the lowest energy … … 52 52 53 53 # get the map functions 54 from pathos.m p_map import mp_map # multiprocessing54 from pathos.multiprocessing import ProcessingPool as mppool 55 55 56 56 … … 59 59 print "Function: %s" % target 60 60 print "Solver: %s" % 'fmin_powell' 61 optimize(powell_chebyshev, mp _map, nodes=10, target=target, nproc=10)61 optimize(powell_chebyshev, mppool, nodes=10, target=target) 62 62 63 63 -
branches/HPCtut/optimize_cheby_powell_ppmap.py
r534 r672 2 2 """ 3 3 Solve Nth-order Chebyshev polynomial coefficients with Powell's method. 4 Launch optimizers in parallel with parallelpythonmap.4 Launch optimizers with parallelpython's map. 5 5 6 6 Requires: development version of mystic, pathos … … 29 29 30 30 # minimize the function 31 results = mapper( solver, x0, **kwds)31 results = mapper(nodes).map(solver, x0) 32 32 33 33 # find the results with the lowest energy … … 52 52 53 53 # get the map functions 54 from pathos.pp _map import pp_map # parallelpython54 from pathos.pp import ParallelPythonPool as pppool 55 55 56 56 … … 59 59 print "Function: %s" % target 60 60 print "Solver: %s" % 'fmin_powell' 61 optimize(powell_chebyshev, pp _map, nodes=10, target=target, ncpus=10)61 optimize(powell_chebyshev, pppool, nodes=10, target=target) 62 62 63 63 -
branches/HPCtut/optimize_powell.py
r534 r672 34 34 35 35 # minimize the function 36 results = mapper( the_solver, model, x0, **kwds)36 results = mapper(nodes).map(the_solver, model, x0) 37 37 38 38 # find the results with the lowest energy … … 51 51 52 52 # get the map functions 53 from itertools import imap # itertools54 from pathos.pp _map import pp_map # parallelpython55 from pathos.m p_map import mp_map # multiprocessing56 from pyina. ez_map import ez_map2 as mpi_map # mpi4py53 from pathos.python import PythonSerial as serial 54 from pathos.pp import ParallelPythonPool as pppool 55 from pathos.multiprocessing import ProcessingPool as mppool 56 from pyina.launchers import Mpi as mpipool 57 57 58 58 … … 63 63 print "Solver: %s" % 'fmin_powell' 64 64 #NOTE: some of the below should fail, due to how objects are shipped in map 65 optimize(the_solver, imap, nodes=1, target=target)66 #optimize(the_solver, pp_map, nodes=1, target=target, ncpus=1)67 #optimize(the_solver, mpi_map, nodes=1, target=target, nnodes=1)68 #optimize(the_solver, mp _map, nodes=1, target=target, nproc=1)65 optimize(the_solver, serial, nodes=2, target=target) 66 #optimize(the_solver, mppool, nodes=2, target=target) 67 #optimize(the_solver, pppool, nodes=2, target=target) 68 #optimize(the_solver, mpipool, nodes=2, target=target) #XXX: Fails 69 69 70 70 -
branches/HPCtut/optimize_rosen_powell_map.py
r534 r672 2 2 """ 3 3 Minimize the Rosenbrock function with Powell's method. 4 Launch optimizers in parallel with itertools map.4 Launch optimizers with python's map. 5 5 6 Requires: development version of mystic 6 Requires: development version of mystic, pathos 7 7 http://pypi.python.org/pypi/mystic 8 http://pypi.python.org/pypi/pathos 8 9 """ 9 10 … … 28 29 29 30 # minimize the function 30 results = mapper( solver, x0, **kwds)31 results = mapper(nodes).map(the_solver, model, x0) 31 32 32 33 # find the results with the lowest energy … … 51 52 52 53 # get the map functions 53 from itertools import imap # itertools54 from pathos.python import PythonSerial as serial 54 55 55 56 … … 58 59 print "Function: %s" % target 59 60 print "Solver: %s" % 'fmin_powell' 60 optimize(powell_rosen, imap, nodes=10, target=target)61 optimize(powell_rosen, serial, nodes=10, target=target) 61 62 62 63
Note: See TracChangeset
for help on using the changeset viewer.