This is a mirror of official site: http://jasper-net.blogspot.com/

Parallel Programming: Understanding the impact of Critical Sections

| Thursday, July 7, 2011
In shared memory systems, multiple threads are not allowed to update shared data concurrently, known as the mutual exclusion principle. Instead, accesses to shared data are encapsulated in regions of code guarded by synchronization primitives (e.g. locks). Such guarded regions of code are called critical sections. The semantics of a critical section dictate that only one thread can execute it at a given time. Any other thread that requires access to shared data must wait for the current thread to complete the critical section.

There exists two types of critical sections in programs. I call them update critical sections and reduction critical sections.

Update Critical Sections
Update critical sections occur in the midst of the parallel kernels. They protect shared data which multiple threads try to read-modify-write during the kernel’s execution, instead of waiting till the end of the kernel’s execution. Their execution can be overlapped with the execution of non-critical-section code. The critical section protecting the maze data in the article on “Parallelizing Complex Programs” is a good example of an update critical section.

For simplicity, lets assume a kernel which has only one critical section. Each iteration of the loop spends one unit of time inside the critical section and three units of time outside the critical section. The following chart demonstrates the execution timeline of this critical section intensive application.

Screenshot20110618at12.11.05AM_thumb.png

Read more: Future chips
QR: parallel-programming-understanding-impact-critical-sections.html

Posted via email from Jasper-net

0 comments: