Presentation is loading. Please wait.

Presentation is loading. Please wait.

EECS 262a Advanced Topics in Computer Systems Lecture 12 Multiprocessor/Realtime Scheduling October 8 th, 2012 John Kubiatowicz and Anthony D. Joseph Electrical.

Similar presentations


Presentation on theme: "EECS 262a Advanced Topics in Computer Systems Lecture 12 Multiprocessor/Realtime Scheduling October 8 th, 2012 John Kubiatowicz and Anthony D. Joseph Electrical."— Presentation transcript:

1 EECS 262a Advanced Topics in Computer Systems Lecture 12 Multiprocessor/Realtime Scheduling October 8 th, 2012 John Kubiatowicz and Anthony D. Joseph Electrical Engineering and Computer Sciences University of California, Berkeley http://www.eecs.berkeley.edu/~kubitron/cs262

2 10/10/20122cs262a-S12 Lecture-12 Today’s Papers Implementing Constant-Bandwidth Servers upon Multiprocessor Platforms Sanjoy Baruah, Joel Goossens, and Giuseppe Lipari. Appears in Proceedings of Real-Time and Embedded Technology and Applications Symposium, (RTAS), 2002. Composing Parallel Software Efficiently with Lithe Heidi Pan, Benjamin Hindman, Krste Asanovic. Appears in Conference on Programming Languages Design and Implementation (PLDI), 2010 Thoughts?

3 10/10/20123cs262a-S12 Lecture-12 The Future is Parallel Software Challenge: How to build many different large parallel apps that run well?  Can’t rely solely on compiler/hardware: limited parallelism & energy efficiency  Can’t rely solely on hand-tuning: limited programmer productivity

4 10/10/20124cs262a-S12 Lecture-12 Composability is Essential Composability is key to building large, complex apps. BLAS App 1App 2 code reuse BLAS same library implementation, different apps modularity App same app, different library implementations MKL BLAS Goto BLAS

5 10/10/20125cs262a-S12 Lecture-12 OpenMP MKL Motivational Example Sparse QR Factorization (Tim Davis, Univ of Florida) Column Elimination Tree Frontal Matrix Factorization OS TBB System Stack Hardware Software Architecture SPQR

6 10/10/20126cs262a-S12 Lecture-12 TBB, MKL, OpenMP Intel’s Threading Building Blocks (TBB) –Library that allows programmers to express parallelism using a higher-level, task-based, abstraction –Uses work-stealing internally (i.e. Cilk) –Open-source Intel’s Math Kernel Library (MKL) –Uses OpenMP for parallelism OpenMP –Allows programmers to express parallelism in the SPMD-style using a combination of compiler directives and a runtime library –Creates SPMD teams internally (i.e. UPC) –Open-source implementation of OpenMP from GNU (libgomp)

7 10/10/20127cs262a-S12 Lecture-12 Suboptimal Performance Speedup over Sequential Matrix Performance of SPQR on 16-core AMD Opteron System

8 10/10/20128cs262a-S12 Lecture-12 Out-of-the-Box Configurations OS TBB OpenMP Hardware Core 0 Core 1 Core 2 Core 3 virtualized kernel threads

9 10/10/20129cs262a-S12 Lecture-12 Providing Performance Isolation Using Intel MKL with Threaded Applications http://www.intel.com/support/performancetools/libraries/mkl/sb/CS-017177.htm

10 10/10/201210cs262a-S12 Lecture-12 “Tuning” the Code Speedup over Sequential Matrix Performance of SPQR on 16-core AMD Opteron System

11 10/10/201211cs262a-S12 Lecture-12 Partition Resources OS TBB OpenMP Hardware Core 0 Core 1 Core 2 Core 3 Tim Davis’ “tuned” SPQR by manually partitioning the resources.

12 10/10/201212cs262a-S12 Lecture-12 “Tuning” the Code (continued) Speedup over Sequential Matrix Performance of SPQR on 16-core AMD Opteron System

13 10/10/201213cs262a-S12 Lecture-12 Harts: Hardware Threads OS Core 0 virtualized kernel threads Core 1Core 2Core 3 OS Core 0Core 1Core 2Core 3 harts Applications requests harts from OS Application “schedules” the harts itself (two-level scheduling) Can both space-multiplex and time- multiplex harts … but never time- multiplex harts of the same application  Expose true hardware resources

14 10/10/201214cs262a-S12 Lecture-12 Sharing Harts (Dynamically) OS TBB OpenMP Hardware time

15 10/10/201215cs262a-S12 Lecture-12 How to Share Harts? OMP TBB CLR Cilk call graph CLR scheduler hierarchy TBBCilk OpenMP  Hierarchically: Caller gives resources to callee to execute  Cooperatively: Callee gives resources back to caller when done

16 10/10/201216cs262a-S12 Lecture-12 A Day in the Life of a Hart Non-preemptive scheduling. CLR TBBCilk OpenMP TBB Sched: next? time TBB SchedQ executeTBB task TBB Sched: next? execute TBB task TBB Sched: next? nothing left to do, give hart back to parent CLR Sched: next? Cilk Sched: next?

17 10/10/201217cs262a-S12 Lecture-12 Child Scheduler Parent Scheduler Lithe (ABI) Cilk Scheduler interface for sharing harts TBB Scheduler unregisterenteryieldrequestregister TBB SchedulerOpenMP Scheduler unregisterenteryieldrequestregister Caller Callee returncall returncall interface for exchanging values  Analogous to function call ABI for enabling interoperable codes.

18 10/10/201218cs262a-S12 Lecture-12 A Few Details … A hart is only managed by one scheduler at a time The Lithe runtime manages the hierarchy of schedulers and the interaction between schedulers Lithe ABI only a mechanism to share harts, not policy

19 10/10/201219cs262a-S12 Lecture-12 } Putting It All Together func(){ register(TBB); request(2); time Lithe-TBB SchedQ unregister(TBB); Lithe-TBB SchedQ enter(TBB); yield(); Lithe-TBB SchedQ enter(TBB); yield();

20 10/10/201220cs262a-S12 Lecture-12 Synchronization Can’t block a hart on a synchronization object Synchronization objects are implemented by saving the current “context” and having the hart re-enter the current scheduler #pragma omp barrier OpenMP Scheduler unregisterenteryieldrequestregister enter #pragma omp barrier (block context) yield request(1) enter time TBB Scheduler unregisterenteryieldrequestregister request (resume context) enter (unblock context)

21 10/10/201221cs262a-S12 Lecture-12 21 Lithe Contexts Includes notion of a stack Includes context-local storage There is a special transition context for each hart that allows it to transition between schedulers easily (i.e. on an enter, yield)

22 10/10/201222cs262a-S12 Lecture-12 22 Lithe-compliant Schedulers TBB –Worker model –~180 lines added, ~5 removed, ~70 modified (~1,500 / ~8,000 total) OpenMP –Team model –~220 lines added, ~35 removed, ~150 modified (~1,000 / ~6,000 total)

23 10/10/201223cs262a-S12 Lecture-12 23 Overheads? TBB –Example micro-benchmarks that Intel includes with releases OpenMP –NAS benchmarks (conjugate gradient, LU solver, and multigrid)

24 10/10/201224cs262a-S12 Lecture-12 Flickr Application Server GraphicsMagick parallelized using OpenMP Server component parallelized using threads (or libprocess processes) Spectrum of possible implementations: –Process one image upload at a time, pass all resources to OpenMP (via GraphicsMagick) +Easy implementation -Can’t overlap communication with computation, some network links are slow, images are different sizes, diminishing returns on resize operations –Process as many images as possible at a time, run GraphicsMagick sequentially +Also easy implementation -Really bad latency when low-load on server, 32 core machine underwhelmed –All points in between … +Account for changing load, different image sizes, different link bandwidth/latency -Hard to program

25 10/10/201225cs262a-S12 Lecture-12 Flickr-Like App Server (Lithe) Tradeoff between throughput saturation point and latency. OpenMP Lithe Graphics Magick Libprocess App Server 25

26 10/10/201226cs262a-S12 Lecture-12 Case Study: Sparse QR Factorization Different matrix sizes deltaX creates ~30,000 OpenMP schedulers … Rucci creates ~180,000 OpenMP schedulers Platform: Dual-socket 2.66 GHz Intel Xeon (Clovertown) with 4 cores per socket (8 total cores)

27 10/10/201227cs262a-S12 Lecture-12 Case Study: Sparse QR Factorization ESOCRucci Lithe: 354.7 Tuned: 360.0 Out-of-the-box:576.9 Sequential:970.5 Tuned: 70.8 Out-of-the-box:111.8 Sequential:172.1 Lithe: 66.7

28 10/10/201228cs262a-S12 Lecture-12 Case Study: Sparse QR Factorization landmark Tuned: 2.5 Out-of-the-box:4.1 Sequential:3.4 Lithe: 2.3 deltaX Tuned: 14.5 Out-of-the-box:26.8 Sequential:37.9 Lithe: 13.6

29 10/10/201229cs262a-S12 Lecture-12 Is this a good paper? What were the authors’ goals? What about the evaluation/metrics? Did they convince you that this was a good system/approach? Were there any red-flags? What mistakes did they make? Does the system/approach meet the “Test of Time” challenge? How would you review this paper today?

30 10/10/201230cs262a-S12 Lecture-12 Characteristics of a RTS Slides adapted from Frank Drew Extreme reliability and safety –Embedded systems typically control the environment in which they operate –Failure to control can result in loss of life, damage to environment or economic loss Guaranteed response times –We need to be able to predict with confidence the worst case response times for systems –Efficiency is important but predictability is essential »In RTS, performance guarantees are: Task- and/or class centric Often ensured a priori »In conventional systems, performance is: System oriented and often throughput oriented Post-processing (… wait and see …) Soft Real-Time –Attempt to meet deadlines with high probability –Important for multimedia applications

31 10/10/201231cs262a-S12 Lecture-12 Terminology Scheduling: –Define a policy of how to order tasks such that a metric is maximized/minimized –Real-time: guarantee hard deadlines, minimize the number of missed deadlines, minimize lateness Dispatching: –Carry out the execution according to the schedule –Preemption, context switching, monitoring, etc. Admission Control: –Filter tasks coming into they systems and thereby make sure the admitted workload is manageable Allocation: –Designate tasks to CPUs and (possibly) nodes. Precedes scheduling

32 10/10/201232cs262a-S12 Lecture-12 Non-Real-Time Scheduling Primary Goal: maximize performance Secondary Goal: ensure fairness Typical metrics: –Minimize response time –Maximize throughput –E.g., FCFS (First-Come-First-Served), RR (Round-Robin)

33 10/10/201233cs262a-S12 Lecture-12 Example: Workload Characteristics Tasks are preemptable, independent with arbitrary arrival (=release) times Times have deadlines (D) and known computation times (C) Tasks execute on a uniprocessor system Example Setup:

34 10/10/201234cs262a-S12 Lecture-12 Example: Non-preemptive FCFS Scheduling

35 10/10/201235cs262a-S12 Lecture-12 Example: Round-Robin Scheduling

36 10/10/201236cs262a-S12 Lecture-12 Real-Time Scheduling Primary goal: ensure predictability Secondary goal: ensure predictability Typical metrics: –Guarantee miss ration = 0 (hard real-time) –Guarantee Probability(missed deadline) < X% (firm real- time) –Minimize miss ration / maximize completion ration (firm real-time) –Minimize overall tardiness; maximize overall usefulness (soft real-time) E.g., EDF (Earliest Deadline First), LLF (Least Laxity First), RMS (Rate-Monotonic Scheduling), DM (Deadline Monotonic Scheduling) Real-time is about enforcing predictability, and does not equal to fast computing!!!

37 10/10/201237cs262a-S12 Lecture-12 Scheduling: Problem Space Uni-processor / multiprocessor / distributed system Periodic / sporadic /aperiodic tasks Independent / interdependant tasks Preemptive / non-preemptive Tick scheduling / event-driven scheduling Static (at design time) / dynamic (at run-time) Off-line (pre-computed schedule), on-line (scheduling decision at runtime) Handle transient overloads Support Fault tolerance

38 10/10/201238cs262a-S12 Lecture-12 Task Assignment and Scheduling Cyclic executive scheduling (  later) Cooperative scheduling –scheduler relies on the current process to give up the CPU before it can start the execution of another process A static priority-driven scheduler can preempt the current process to start a new process. Priorities are set pre-execution –E.g., Rate-monotonic scheduling (RMS), Deadline Monotonic scheduling (DM) A dynamic priority-driven scheduler can assign, and possibly also redefine, process priorities at run-time. –Earliest Deadline First (EDF), Least Laxity First (LLF)

39 10/10/201239cs262a-S12 Lecture-12 Simple Process Model Fixed set of processes (tasks) Processes are periodic, with known periods Processes are independent of each other System overheads, context switches etc, are ignored (zero cost) Processes have a deadline equal to their period –i.e., each process must complete before its next release Processes have fixed worst-case execution time (WCET)

40 10/10/201240cs262a-S12 Lecture-12 Performance Metrics Completion ratio / miss ration Maximize total usefulness value (weighted sum) Maximize value of a task Minimize lateness Minimize error (imprecise tasks) Feasibility (all tasks meet their deadlines)

41 10/10/201241cs262a-S12 Lecture-12 Scheduling Approaches (Hard RTS) Off-line scheduling / analysis (static analysis + static scheduling) –All tasks, times and priorities given a priori (before system startup) –Time-driven; schedule computed and hardcoded (before system startup) –E.g., Cyclic Executives –Inflexible –May be combined with static or dynamic scheduling approaches Fixed priority scheduling (static analysis + dynamic scheduling) –All tasks, times and priorities given a priori (before system startup) –Priority-driven, dynamic(!) scheduling »The schedule is constructed by the OS scheduler at run time –For hard / safety critical systems –E.g., RMA/RMS (Rate Monotonic Analysis / Rate Monotonic Scheduling) Dynamic priority schededuling –Tasks times may or may not be known –Assigns priorities based on the current state of the system –For hard / best effort systems –E.g., Least Completion Time (LCT), Earliest Deadline First (EDF), Least Slack Time (LST)

42 10/10/201242cs262a-S12 Lecture-12 Cyclic Executive Approach Clock-driven (time-driven) scheduling algorithm Off-line algorithm Minor Cycle (e.g. 25ms)- gcd of all periods Major Cycle (e.g. 100ms) - lcm of all periods Construction of a cyclic executive is equivalent to bin packing ProcessPeriodComp. Time A2510 B258 C505 D 4 E1002

43 10/10/201243cs262a-S12 Lecture-12 Frank DrewsReal-Time Systems Cyclic Executive (cont.)

44 10/10/201244cs262a-S12 Lecture-12 Cyclic Executive: Observations No actual processes exist at run-time –Each minor cycle is just a sequence of procedure calls The procedures share a common address space and can thus pass data between themselves. –This data does not need to be protected (via semaphores, mutexes, for example) because concurrent access is not possible All ‘task’ periods must be a multiple of the minor cycle time

45 10/10/201245cs262a-S12 Lecture-12 Cyclic Executive: Disadvantages With the approach it is difficult to: incorporate sporadic processes; incorporate processes with long periods; –Major cycle time is the maximum period that can be accommodated without secondary schedules (=procedure in major cycle that will call a secondary procedure every N major cycles) construct the cyclic executive, and handle processes with sizeable computation times. –Any ‘task’ with a sizeable computation time will need to be split into a fixed number of fixed sized procedures.

46 10/10/201246cs262a-S12 Lecture-12 Next Time: Online Scheduling


Download ppt "EECS 262a Advanced Topics in Computer Systems Lecture 12 Multiprocessor/Realtime Scheduling October 8 th, 2012 John Kubiatowicz and Anthony D. Joseph Electrical."

Similar presentations


Ads by Google