PYTHON ILE PARALEL PROGRAMLAMA ORÇUN ULUTAŞ
PYTHON Nedir ? Python yorumlanabilir script tabanlı bir dilidir. Çoklu platform desteği Geniş kütüphane desteği Web ve masaüstü uygulamalar geliştirilebilir
YER ALDIĞI PROJELER Belender, GIMP, Inkscape Linux dağıtımları Django Framework Apache Bittorrnet Google, Yahoo, Facebook GERN, NASA
Python Syntax
Python Syntax
PRALLEL LIBRARIES MPI4PY pyMPI Python PROCESS MULTI PROCESSING Python Parallel
MPI4PY from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() if rank == 0: data = {'a': 7, 'b': 3.14} comm.send(data, dest=1, tag=11) elif rank == 1: data = comm.recv(source=0, tag=11)
Broadcast from mpi4py import MPI comm = MPI. COMM_WORLD rank = comm Broadcast from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() if rank == 0: data = {'key1' : [7, 2.72, 2+3j], 'key2' : ( 'abc', 'xyz')} else: data = None data = comm.bcast(data, root=0)
MPI import mpi if mpi.rank == 0: print "size=",mpi.size print "rank=",mpi.rank,"/size=",mpi.size
root@linuxpc:/home/se364/python# mpirun –np 2 python mpi.py mypi = 3.1454 for rank 0 Computed value of pi on 2 processors is 3.1417 Using 120000 samples.
PPROCESS root@linuxpc:/home/se364/python# python process.py 1 3
root@linuxpc:/home/se364/python# python pyocr.py 6.716026 s for traditional, serial computation. 4.041723 s for parallel computation.
MULTI PROCESSING p = multiprocessing.Pool() po = p.map_async(fn, args) result = po.get()
root@linuxpc:/home/se364/python# python mp.py main line ('module name:', '__main__') ('parent process:', 4436) ('process id:', 4815) function f ('parent process:', 4815) ('process id:', 4816) ('hello', 'bob')
root@linuxpc:/home/se364/python# python mp2.py 3.1415927 [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
PP root@linuxpc:/home/se364/python# python mp2.py Start at: Mon Dec 16 23:43:35 2013 Start doing something Do something... ... do something else... 1 I'm done 2 I'm done End at: Mon Dec 16 23:43:40 2013