Sunuyu indir
Sunum yükleniyor. Lütfen bekleyiniz
1
PYTHON ILE PARALEL PROGRAMLAMA
ORÇUN ULUTAŞ
2
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
3
YER ALDIĞI PROJELER Belender, GIMP, Inkscape Linux dağıtımları
Django Framework Apache Bittorrnet Google, Yahoo, Facebook GERN, NASA
4
Python Syntax
5
Python Syntax
6
PRALLEL LIBRARIES MPI4PY pyMPI Python PROCESS MULTI PROCESSING
Python Parallel
7
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)
8
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)
9
MPI import mpi if mpi.rank == 0: print "size=",mpi.size print "rank=",mpi.rank,"/size=",mpi.size
10
root@linuxpc:/home/se364/python# mpirun –np 2 python mpi.py
mypi = for rank 0 Computed value of pi on 2 processors is Using samples.
11
PPROCESS python process.py 1 3
12
root@linuxpc:/home/se364/python# python pyocr.py
s for traditional, serial computation. s for parallel computation.
13
MULTI PROCESSING p = multiprocessing.Pool() po = p.map_async(fn, args) result = po.get()
14
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')
15
root@linuxpc:/home/se364/python# python mp2.py
[0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
16
PP root@linuxpc:/home/se364/python# python mp2.py
Start at: Mon Dec 16 23:43: Start doing something Do something... ... do something else... 1 I'm done 2 I'm done End at: Mon Dec 16 23:43:
Benzer bir sunumlar
© 2024 SlidePlayer.biz.tr Inc.
All rights reserved.