barriers-tut11 - Multicore Programming C to e Maste...

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

View Full Document Right Arrow Icon
Click to edit Master subtitle style Art of Multiprocessor Multicore Programming Barriers Tutorial 11 CS 0368-3469 Spring 2010
Background image of page 1

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

View Full DocumentRight Arrow Icon
Art of Multiprocessor 22 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
Background image of page 2
Art of Multiprocessor 33 Simple Video Game while ( true ) { frame.prepare(); frame.display(); }
Background image of page 3

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

View Full DocumentRight Arrow Icon
Art of Multiprocessor 44 Simple Video Game while ( true ) { frame.prepare(); frame.display(); } What about overlapping work? 1st thread displays frame 2nd prepares next frame
Background image of page 4
Art of Multiprocessor 55 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; }
Background image of page 5

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

View Full DocumentRight Arrow Icon
Art of Multiprocessor 66 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
Background image of page 6
Art of Multiprocessor 77 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
Background image of page 7

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

View Full DocumentRight Arrow Icon
Art of Multiprocessor 88 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
Background image of page 8
Art of Multiprocessor 99 Ideal Parallel Computation 0 0 0 1 1 1
Background image of page 9

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

View Full DocumentRight Arrow Icon
Art of Multiprocessor 1010 Ideal Parallel Computation 2 2 2 1 1 1
Background image of page 10
Art of Multiprocessor 1111 Real-Life Parallel Computation 0 0 0 1 1 zzz…
Background image of page 11

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

View Full DocumentRight Arrow Icon
Art of Multiprocessor 1212 Real-Life Parallel Computation 2 1 1 zzz… Uh, oh 0
Background image of page 12
Art of Multiprocessor 1313 Barrier Synchronization 0 0 0 barrier
Background image of page 13

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

View Full DocumentRight Arrow Icon
Art of Multiprocessor 1414 Barrier Synchronization barrier 1 1 1
Background image of page 14
Art of Multiprocessor 1515 Barrier Synchronization barrier No thread enters here Until every thread has left here
Background image of page 15

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

View Full DocumentRight Arrow Icon
Art of Multiprocessor 1616 Why Do We Care? Mostly of interest to Scientific & numeric computation Elsewhere Garbage collection Less common in systems programming Still important topic
Background image of page 16
Art of Multiprocessor 1717 Duality Dual to mutual exclusion Include others, not exclude them Same implementation issues Interaction with caches … Invalidation? Local spinning?
Background image of page 17

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

View Full DocumentRight Arrow Icon
Art of Multiprocessor 1818 Example: Parallel Prefix a b c d a a+b a+b+c +d before after
Background image of page 18
Art of Multiprocessor 1919 Parallel Prefix a b c d One thread Per entry
Background image of page 19

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

View Full DocumentRight Arrow Icon
Art of Multiprocessor 2020 Parallel Prefix: Phase 1 a b c d a a+ b b +c c +d
Background image of page 20
Art of Multiprocessor 2121 Parallel Prefix: Phase 2 a b c d a a+b a +b+c +c +d
Background image of page 21

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

View Full DocumentRight Arrow Icon
Art of Multiprocessor 2222 Parallel Prefix N threads can compute Parallel prefix Of N entries In log2 N rounds What if system is asynchronous? Why we need barriers
Background image of page 22
Art of Multiprocessor 2323 Prefix class  Prefix  extends  Thread {   private int [] a;  private int  i;   private  Barrier b;   public  Prefix( int [] a,                Barrier b, int i) {    this .a = a;    this .b = b;    this .i = i;  }
Background image of page 23

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

View Full DocumentRight Arrow Icon
Art of Multiprocessor 2424 Prefix
Background image of page 24
Image of page 25
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/11/2010 for the course COS COS226 taught by Professor Klazar during the Spring '10 term at University of Pretoria.

Page1 / 66

barriers-tut11 - Multicore Programming C to e Maste...

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

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