Shared Memory Parallel Programming

CS/IT 451 & CS 551 – Parallel Processing Threads POSIX Thread Basics Synchronization in Pthreads Thread Cancellation Composite Synchronization Asynchr...
Author: Ernest Gardner
6 downloads 0 Views 422KB Size
CS/IT 451 & CS 551 – Parallel Processing Threads POSIX Thread Basics Synchronization in Pthreads Thread Cancellation Composite Synchronization Asynchronous Programming OpenMP

1

Shared Memory Parallel Programming Lecture 2.5 – Programming with Shared Memory

CS/IT 451 & CS 551 – Parallel Processing

Shared Memory

Threads POSIX Thread Basics Synchronization in Pthreads Thread Cancellation Composite Synchronization Asynchronous Programming OpenMP

• Shared address space – Process based models – private by default – Lightweight process & thread model – shared … – Directive based model – create & synch. threads

• Parallelization focus – expressing concurrency – synchronization – minimizing overheads

• Paradigm variations

2

– data sharing – concurrency model – synchronization support Lecture 2.5 – Programming with Shared Memory

CS/IT 451 & CS 551 – Parallel Processing Threads POSIX Thread Basics Synchronization in Pthreads Thread Cancellation Composite Synchronization

Quiz 2.5.1 • Will every parallelization paradigm work equally well for every application?

Asynchronous Programming OpenMP

No – consider the difference between the traveling salesman problem and weather prediction.

3

Lecture 2.5 – Programming with Shared Memory

CS/IT 451 & CS 551 – Parallel Processing

Processes

Threads POSIX

http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V40F_HTML/AQ2DPDTK/TITLE.HTM

Thread Basics Synchronization in Pthreads Thread Cancellation Composite Synchronization Asynchronous Programming OpenMP

4

Lecture 2.5 – Programming with Shared Memory

CS/IT 451 & CS 551 – Parallel Processing

Threads

Threads POSIX

http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V40F_HTML/AQ2DPDTK/TITLE.HTM

Thread Basics Synchronization in Pthreads Thread Cancellation Composite Synchronization Asynchronous Programming OpenMP

5

Lecture 2.5 – Programming with Shared Memory

CS/IT 451 & CS 551 – Parallel Processing Threads POSIX Thread Basics Synchronization in Pthreads Thread Cancellation Composite Synchronization Asynchronous Programming

Quiz 2.5.2 • Would all threads share the same instruction pointer or would they each have their own?

OpenMP

Each thread will have its own IP so that threads can operate independently (but normally in a cooperative fashion). 6

Lecture 2.5 – Programming with Shared Memory

CS/IT 451 & CS 551 – Parallel Processing Threads POSIX Thread Basics Synchronization in Pthreads Thread Cancellation Composite Synchronization Asynchronous Programming OpenMP

Threads • A thread is a single stream of control in the flow of a program. • Consider the code excerpt for (row=0; row