1 / 16

PYTHON ILE PARALEL PROGRAMLAMA

Learn about Python's parallel programming capabilities, syntax, and libraries like MPI4PY and multiprocessing, enabling efficient code execution across multiple processes. Explore examples and projects incorporating Python parallelism.

donn
Download Presentation

PYTHON ILE PARALEL PROGRAMLAMA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 frommpi4pyimport 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 frommpi4pyimport 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 = 3.1454 for rank 0 Computed value of pi on 2 processors is 3.1417 Using 120000 samples.

  11. PPROCESS root@linuxpc:/home/se364/python# python process.py 1 3

  12. root@linuxpc:/home/se364/python# python pyocr.py 6.716026 s for traditional, serial computation. 4.041723 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 ('module name:', '__main__') ('parent process:', 4815) ('process id:', 4816) ('hello', 'bob')

  15. root@linuxpc:/home/se364/python# python mp2.py 3.1415927 [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: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

More Related