0
Introduction to
Parallel Programming
using Python
Presented by: Samah Gad
July 11, 2013
Friday, July 12, 13
Road Map
Motivation
Forking Processes
Threads
Interprocess Communication - Overview
The multiprocessing Module - Overview
...
Motivation
Problem:
Most computers spend a lot of time
doing nothing.
Majority of the modern CPU’s capacity
is often spent...
Motivation -Cont.
Solution:
Running more than one program at a
time.
Dividing the CPU attention among a
set of tasks.
Para...
Parallel Processing in
Python
Two main ways to run tasks:
Process forks
Spawned threads
Python built-in tools like: os.for...
Forking Processes
Traditional ways to structure parallel
tasks.
Straight forward way to start an
independent program.
What...
Example 1
Friday, July 12, 13
Example 2
Friday, July 12, 13
Threads
Another way to start activities
running at the same time.
Lightweight processes
Run within the same single process...
Threads - Advantages:
Performance
Simplicity
Shared global memory
Portability
Friday, July 12, 13
Python Modules
Python Modules:
_thread module
threading modules
Both modules provide tools for
synchronizing access to sha...
The _thread Module
Start new independent threads of
execution within a process.
Doesn't support OOP
Platform independent m...
Example 3
Friday, July 12, 13
Example 4
Friday, July 12, 13
Synchronizing access to
shared objects and names
What is the problem?
Objects and namespaces in a process
that span the li...
Example 5
Friday, July 12, 13
Threading Module
Internally uses the _thread module to
implement objects that represent
threads and common synchronization...
Interprocess
Communication - Overview
Other solutions don’t support cross-
program communication
Sockets, Pipes, and Signa...
The multiprocessing
Module - Overview
Provide the best of processes and threads.
Platform independent.
Uses processes inst...
Reference
Title: Programming Python
Author: Mark Lutz
Publisher:O'Reilly Media; Fourth Edition
edition (January 7, 2011)
F...
Upcoming SlideShare
Loading in...5
×

Parallel programming using python

564

Published on

Published in: Technology, Education
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
564
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
25
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Transcript of "Parallel programming using python "

  1. 1. Introduction to Parallel Programming using Python Presented by: Samah Gad July 11, 2013 Friday, July 12, 13
  2. 2. Road Map Motivation Forking Processes Threads Interprocess Communication - Overview The multiprocessing Module - Overview Friday, July 12, 13
  3. 3. Motivation Problem: Most computers spend a lot of time doing nothing. Majority of the modern CPU’s capacity is often spent in an idle state. Friday, July 12, 13
  4. 4. Motivation -Cont. Solution: Running more than one program at a time. Dividing the CPU attention among a set of tasks. Parallel Processing, Multiprocessing, or Multitasking. Friday, July 12, 13
  5. 5. Parallel Processing in Python Two main ways to run tasks: Process forks Spawned threads Python built-in tools like: os.fork, threading, queue, and multiprocessing. Third Party domains offers more advanced tools. Friday, July 12, 13
  6. 6. Forking Processes Traditional ways to structure parallel tasks. Straight forward way to start an independent program. What is forking? Copying programs. Python Module - os.fork Friday, July 12, 13
  7. 7. Example 1 Friday, July 12, 13
  8. 8. Example 2 Friday, July 12, 13
  9. 9. Threads Another way to start activities running at the same time. Lightweight processes Run within the same single process. Friday, July 12, 13
  10. 10. Threads - Advantages: Performance Simplicity Shared global memory Portability Friday, July 12, 13
  11. 11. Python Modules Python Modules: _thread module threading modules Both modules provide tools for synchronizing access to shared objects with locks. Friday, July 12, 13
  12. 12. The _thread Module Start new independent threads of execution within a process. Doesn't support OOP Platform independent module. Friday, July 12, 13
  13. 13. Example 3 Friday, July 12, 13
  14. 14. Example 4 Friday, July 12, 13
  15. 15. Synchronizing access to shared objects and names What is the problem? Objects and namespaces in a process that span the life of threads are shared by all spawned threads. Solution: Threads automatically come with a cross-task communications Friday, July 12, 13
  16. 16. Example 5 Friday, July 12, 13
  17. 17. Threading Module Internally uses the _thread module to implement objects that represent threads and common synchronization tools. Manage threads with high-level class- based objects. Friday, July 12, 13
  18. 18. Interprocess Communication - Overview Other solutions don’t support cross- program communication Sockets, Pipes, and Signals Enable performing Inter-Process Communication (IPC) Friday, July 12, 13
  19. 19. The multiprocessing Module - Overview Provide the best of processes and threads. Platform independent. Uses processes instead of threads. Provide synchronizations tools. Leverage the capacity of multiple processors. Friday, July 12, 13
  20. 20. Reference Title: Programming Python Author: Mark Lutz Publisher:O'Reilly Media; Fourth Edition edition (January 7, 2011) Friday, July 12, 13
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×