14~Chapter_17 - Barrier Synchronization Companion slides...

Info iconThis preview shows pages 1–18. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Barrier Synchronization Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Art of Multiprocessor Programming 2 Simple Video Game • Prepare frame for display – By graphics coprocessor • “soft real-time” application – Need at least 35 frames/second – OK to mess up rarely Art of Multiprocessor Programming 3 Simple Video Game while ( true ) { frame.prepare(); frame.display(); } Art of Multiprocessor Programming 4 Simple Video Game while ( true ) { frame.prepare(); frame.display(); } • What about overlapping work? – 1 st thread displays frame – 2 nd prepares next frame Art of Multiprocessor Programming 5 Two-Phase Rendering while ( true ) { if (phase) { frame[0].display(); } else { frame[1].display(); } phase = !phase; } while ( true ) { if (phase) { frame[1].prepare(); } else { frame[0].prepare(); } phase = !phase; } Art of Multiprocessor Programming 6 Two-Phase Rendering while (true) { if (phase) { frame[0].display(); } else { frame[1].display(); } phase = !phase; } while (true) { if (phase) { frame[1].prepare(); } else { frame[0].prepare(); } phase = !phase; } Even phases Art of Multiprocessor Programming 7 Two-Phase Rendering while (true) { if (phase) { frame[0].display(); } else { frame[1].display(); } phase = !phase; } while (true) { if (phase) { frame[1].prepare(); } else { frame[0].prepare(); } phase = !phase; } odd phases Art of Multiprocessor Programming 8 Synchronization Problems • How do threads stay in phase? • Too early? – “we render no frame before its time” • Too late? – Recycle memory before frame is displayed Art of Multiprocessor Programming 9 Ideal Parallel Computation 1 1 1 Art of Multiprocessor Programming 10 Ideal Parallel Computation 2 2 2 1 1 1 Art of Multiprocessor Programming 11 Real-Life Parallel Computation 1 1 zzz… Art of Multiprocessor Programming 12 Real-Life Parallel Computation 2 1 1 zzz … Uh, oh Art of Multiprocessor Programming 13 Barrier Synchronization barrier Art of Multiprocessor Programming 14 Barrier Synchronization barrier 1 1 1 Art of Multiprocessor Programming 15 Barrier Synchronization barrier No thread enters here Until every thread has left here Art of Multiprocessor Programming 16 Why Do We Care? • Mostly of interest to – Scientific & numeric computation • Elsewhere – Garbage collection – Less common in systems programming – Still important topic Art of Multiprocessor Programming 17 Duality • Dual to mutual exclusion – Include others, not exclude them • Same implementation issues – Interaction with caches … • Invalidation?...
View Full Document

Page1 / 107

14~Chapter_17 - Barrier Synchronization Companion slides...

This preview shows document pages 1 - 18. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online