Understanding Task Scheduling Algorithms. Kenjiro Taura

Similar documents
Shared-memory Parallel Programming with Cilk Plus

Beyond Nested Parallelism: Tight Bounds on Work-Stealing Overheads for Parallel Futures

The Data Locality of Work Stealing

Ownership of a queue for practical lock-free scheduling

Today: Amortized Analysis (examples) Multithreaded Algs.

Thread Scheduling for Multiprogrammed Multiprocessors

Analyzing Data Access of Algorithms and How to Make Them Cache-Friendly? Kenjiro Taura

Multithreaded Parallelism and Performance Measures

Distributed minimum spanning tree problem

Cilk. Cilk In 2008, ACM SIGPLAN awarded Best influential paper of Decade. Cilk : Biggest principle

CILK/CILK++ AND REDUCERS YUNMING ZHANG RICE UNIVERSITY

Shared-memory Parallel Programming with Cilk Plus

CSE 421 Applications of DFS(?) Topological sort

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

CS420: Operating Systems

A Framework for Space and Time Efficient Scheduling of Parallelism

Latency-Hiding Work Stealing

Treewidth and graph minors

Provably Efficient Non-Preemptive Task Scheduling with Cilk

Uninformed Search Methods

Brushing the Locks out of the Fur: A Lock-Free Work Stealing Library Based on Wool

Graph Algorithms Using Depth First Search

Verification of a Concurrent Deque Implementation

Theory of Computing Systems 2002 Springer-Verlag New York Inc.

Plan. 1 Parallelism Complexity Measures. 2 cilk for Loops. 3 Scheduling Theory and Implementation. 4 Measuring Parallelism in Practice

Chordal Graphs: Theory and Algorithms

Priority Queues. 1 Introduction. 2 Naïve Implementations. CSci 335 Software Design and Analysis III Chapter 6 Priority Queues. Prof.

Graph Algorithms. Chapter 22. CPTR 430 Algorithms Graph Algorithms 1

Binary search trees. Binary search trees are data structures based on binary trees that support operations on dynamic sets.

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?

implementing the breadth-first search algorithm implementing the depth-first search algorithm

The Cilk part is a small set of linguistic extensions to C/C++ to support fork-join parallelism. (The Plus part supports vector parallelism.

CS 240A: Shared Memory & Multicore Programming with Cilk++

How to Solve Complex Problems in Parallel (Parallel Divide and Conquer and Task Parallelism) Kenjiro Taura

CSE 260 Lecture 19. Parallel Programming Languages

Project 3. Building a parallelism profiler for Cilk computations CSE 539. Assigned: 03/17/2015 Due Date: 03/27/2015

Thread Scheduling for Multiprogrammed Multiprocessors

Parallel GC. (Chapter 14) Eleanor Ainy December 16 th 2014

DAGViz: A DAG Visualization Tool for Analyzing Task-Parallel Program Traces

A Work Stealing Scheduler for Parallel Loops on Shared Cache Multicores

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory. Demand Paging

Constraint Satisfaction Problems

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Introduction and Overview

Multithreaded Algorithms Part 1. Dept. of Computer Science & Eng University of Moratuwa

10708 Graphical Models: Homework 2

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

Multithreaded Programming in. Cilk LECTURE 1. Charles E. Leiserson

Address spaces and memory management

Processes. Process Concept

Virtual Memory. ICS332 Operating Systems

Computer Science 210 Data Structures Siena College Fall Topic Notes: Trees

Recursion. What is Recursion? Simple Example. Repeatedly Reduce the Problem Into Smaller Problems to Solve the Big Problem

The Parallel Persistent Memory Model

Virtual Memory COMPSCI 386

Uni-Address Threads: Scalable Thread Management for RDMA-based Work Stealing

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Keeping Order:! Stacks, Queues, & Deques. Travis W. Peters Dartmouth College - CS 10

Binary search trees 3. Binary search trees. Binary search trees 2. Reading: Cormen et al, Sections 12.1 to 12.3

VIRTUAL MEMORY READING: CHAPTER 9

Algorithm 23 works. Instead of a spanning tree, one can use routing.

The Relative Power of Synchronization Methods

CS301 - Data Structures Glossary By

Finding a -regular Supergraph of Minimum Order

Space vs Time, Cache vs Main Memory

Week 6. Data structures

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory

On the cost of managing data flow dependencies

Scheduling Multithreaded Computations by Work Stealing. Robert D. Blumofe. Charles E. Leiserson. 545 Technology Square. Cambridge, MA 02139

CPSC 221: Algorithms and Data Structures Lecture #1: Stacks and Queues

Operating Systems Virtual Memory. Lecture 11 Michael O Boyle

MC302 GRAPH THEORY Thursday, 10/24/13

Unit 2 Buffer Pool Management

CS 267 Applications of Parallel Computers. Lecture 23: Load Balancing and Scheduling. James Demmel

Efficient Work Stealing for Fine-Grained Parallelism

CSE 153 Design of Operating Systems

B-Trees and External Memory

Memory Management Outline. Operating Systems. Motivation. Paging Implementation. Accessing Invalid Pages. Performance of Demand Paging

3. Fundamental Data Structures

Chapter 8: Virtual Memory. Operating System Concepts

Data Structure. Recitation VII

Problem with Scanning an Infix Expression

Load Balancing. Minsoo Ryu. Department of Computer Science and Engineering. Hanyang University. Real-Time Computing and Communications Lab.

Scheduling Parallel Programs by Work Stealing with Private Deques

B-Trees and External Memory

Chapter 9: Virtual-Memory

Compsci 590.3: Introduction to Parallel Computing

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

Chapter 6: Demand Paging

DDS Dynamic Search Trees

JAVA CONCURRENCY FRAMEWORK. Kaushik Kanetkar

Linear Structures. Linear Structure. Implementations. Array details. List details. Operations 4/18/2013

Concurrent Skip Lists. Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit

Constraint Satisfaction Problems

UNINFORMED SEARCH. Announcements Reading Section 3.4, especially 3.4.1, 3.4.2, 3.4.3, 3.4.5

Linked Lists: The Role of Locking. Erez Petrank Technion

These notes present some properties of chordal graphs, a set of undirected graphs that are important for undirected graphical models.

Operating Systems. Week 9 Recitation: Exam 2 Preview Review of Exam 2, Spring Paul Krzyzanowski. Rutgers University.

W4231: Analysis of Algorithms

Assignment # 4 Selected Solutions

Section Summary. Introduction to Trees Rooted Trees Trees as Models Properties of Trees

Transcription:

Understanding Task Scheduling Algorithms Kenjiro Taura 1 / 48

Contents 1 Introduction 2 Work stealing scheduler 3 Analyzing execution time of work stealing 4 Analyzing cache misses of work stealing 5 Summary 2 / 48

Contents 1 Introduction 2 Work stealing scheduler 3 Analyzing execution time of work stealing 4 Analyzing cache misses of work stealing 5 Summary 3 / 48

Introduction T6 T8 T5 T7 T9 T10 T13 T16 T17 T18 T19 T15 T12 T14 T20 T21 T22 T4 T11 T23 T24 T25 T51 T52 T3 T29 T30 T50 T34 T26 T27 T28 T49 T53 T54 T33 T35 T36 T47 T48 T55 T46 T32 T37 T45 T56 T57 T58 T59 T2 T31 T60 T38 T39 T44 T61 T43 T63 T64 T42 T62 T65 T69 T70 T68 T71 T89 T67 T72 T73 T86 T88 T41 T66 T90 T91 T74 T75 T85 T87 T92 T76 T98 T99 T84 T95 T97 T1 T40 T79 T77 T78 T82 T80 T81 T83 T101 T100 T94 T96 T108 T107 T109 T93 T106 T110 T105 T111 T112 T104 T120 T114 T113 T115 T117 T116 T121 T118 T119 T102 T103 T124 T125 T126 T127 T0 T122 T123 T132 T133 T128 T129 T130 T131 T134 T137 T138 T135 T136 T153 T154 T152 T139 T140 T141 T142 T155 T156 T143 T144 T164 T158 T146 T163 T166 T165 T167 T171 T168 T169 T170 T157 T159 T160 T145 T147 T150 T148 T149 T151 T161 T162 T172 T173 T175 T184 T174 T176 T181 T177 T178 T179 T180 T185 T182 T183 T187 T186 T188 T190 T189 T193 T191 T192 T195 T194 T196 T198 T197 T199 in this part, we study how tasks in task parallel programs are scheduled what can we expect about its performance void ms(elem * a, elem * a_end, elem * t, int dest) { long n = a_end - a; if (n == 1) {... } else {... create task(ms(a, c, t, 1 - dest)); ms(c, a_end, t + nh, 1 - dest); wait tasks; } } 4 / 48

Goals understand a representative scheduling algorithm (work stealing scheduler) execution time (without modeling communication): how much time does a scheduler take to finish a computation? in particular, how close is it to greedy schedulers? data access (communication) cost: when a computation is executed in parallel by a scheduler, how much data are transferred (caches memory, caches cache)? in particular, how much are they worse (or better) than those of the serial execution? 5 / 48

Contents 1 Introduction 2 Work stealing scheduler 3 Analyzing execution time of work stealing 4 Analyzing cache misses of work stealing 5 Summary 6 / 48

Model of computation assume a program performs the following operations create task(s): create a task that performs S wait tasks: waits for completion of tasks it has created (but has not waited for) e.g., 1 int fib(n) { 2 if (n < 2) return 1; 3 else { 4 int x, y; 5 create_task({ x = fib(n - 1); }); // share x 6 y = fib(n - 2); 7 wait_tasks; 8 return x + y; 9 } 10 } 7 / 48

Model of computation model an execution as a DAG (directed acyclic graph) node: a sequence of instructions edge: dependency assume no other dependencies besides induced by create task(s) and wait tasks e.g., (note C 1 and C 2 may be subgraphs, not single nodes) 1 P 1 2 create_task(c 1 ); 3 P 2 4 create_task(c 2 ); 5 P 3 6 wait_tasks; 7 P 4 P 1 P 2 C 1 P 3 C 2 P 4 8 / 48

Terminologies and remarks a single node in the DAG represents a sequence of instructions performing no task-related operations note that a task a single node, but = a sequence of nodes C 1 P 1 P 2 we say a node is ready when all its predecessors have finished; we say a task is ready to mean a node of it becomes ready C 2 P 4 P 3 9 / 48

Work stealing scheduler a state of the art scheduler of task parallel systems the main ideas invented in 1990: Mohr, Kranz, and Halstead. Lazy task creation: a technique for increasing the granularity of parallel programs. ACM conference on LISP and functional programming. originally termed Lazy Task Creation, but essentially the same strategy is nowadays called work stealing 10 / 48

Work stealing scheduler: data structure top bottom ready deques executing tasks W 0 W 1 W 2 W n 1 ready tasks each worker maintains its ready deque that contains ready tasks the top entry of each ready deque is an executing task 11 / 48

Work stealing scheduler : in a nutshell work-first; when creating a task, the created task gets executed first (before the parent) LIFO execution order within a worker; without work stealing, the order of execution is as if it were a serial program create task(s) S wait tasks noop FIFO stealing; it partitions tasks at points close to the root of the task tree it is a practical approximation of a greedy scheduler, in the sense that any ready task can be (eventually) stolen by any idle worker 12 / 48

Work stealing scheduler in action describing a scheduler boils down to defining actions on each of the following events (1) create task (2) a worker becoming idle (3) wait tasks (4) a task termination we will see them in detail 13 / 48

Work stealing scheduler in action top bottom W 0 W 1 W 2 W n 1 (1) worker W encounters create task(s): 14 / 48

Work stealing scheduler in action top S P bottom W 0 W 1 W 2 W n 1 (1) worker W encounters create task(s): 1 W pushes S to its deque 2 and immediately starts executing S 14 / 48

Work stealing scheduler in action top S P bottom W 0 W 1 W 2 W n 1 (2) a worker with empty deque repeats work stealing: 14 / 48

Work stealing scheduler in action top S P bottom W 0 W 1 W 2 W n 1 (2) a worker with empty deque repeats work stealing: 1 picks a random worker V as the victim 14 / 48

Work stealing scheduler in action top bottom W 0 W 1 W 2 W n 1 (2) a worker with empty deque repeats work stealing: 1 picks a random worker V as the victim 2 steals the task at the bottom of V s deque 14 / 48

Work stealing scheduler in action top bottom W 0 W 1 W 2 W n 1 (3) a worker W encounters wait tasks: there are two cases 14 / 48

Work stealing scheduler in action top bottom W 0 W 1 W 2 W n 1 (3) a worker W encounters wait tasks: there are two cases 1 tasks to wait for have finished W just continues the task 14 / 48

Work stealing scheduler in action top bottom W 0 W 1 W 2 W n 1 (3) a worker W encounters wait tasks: there are two cases 1 tasks to wait for have finished W just continues the task 14 / 48

Work stealing scheduler in action top bottom W 0 W 1 W 2 W n 1 (3) a worker W encounters wait tasks: there are two cases 1 tasks to wait for have finished W just continues the task 2 otherwise pops the task from its deque (the task is now blocked, and W will start work stealing) 14 / 48

Work stealing scheduler in action top bottom W 0 W 1 W 2 W n 1 (3) a worker W encounters wait tasks: there are two cases 1 tasks to wait for have finished W just continues the task 2 otherwise pops the task from its deque (the task is now blocked, and W will start work stealing) 14 / 48

Work stealing scheduler in action top bottom W 0 W 1 W 2 W n 1 (4) when W encounters the termination of a task T, W pops T from its deque. there are two cases about T s parent P : 14 / 48

Work stealing scheduler in action top bottom T W 0 W 1 W 2 W n 1 P (4) when W encounters the termination of a task T, W pops T from its deque. there are two cases about T s parent P : 1 P is blocked and now becomes ready again W enqueues and continues to P 14 / 48

Work stealing scheduler in action top bottom P W 0 W 1 W 2 W n 1 (4) when W encounters the termination of a task T, W pops T from its deque. there are two cases about T s parent P : 1 P is blocked and now becomes ready again W enqueues and continues to P 14 / 48

Work stealing scheduler in action top T P bottom W 0 W 1 W 2 W n 1 (4) when W encounters the termination of a task T, W pops T from its deque. there are two cases about T s parent P : 1 P is blocked and now becomes ready again W enqueues and continues to P 2 other cases no particular action; continues to the next task in its deque or starts work stealing if it becomes empty 14 / 48

Work stealing scheduler in action top P bottom W 0 W 1 W 2 W n 1 (4) when W encounters the termination of a task T, W pops T from its deque. there are two cases about T s parent P : 1 P is blocked and now becomes ready again W enqueues and continues to P 2 other cases no particular action; continues to the next task in its deque or starts work stealing if it becomes empty 14 / 48

Work stealing scheduler in action top bottom T P W 0 W 1 W 2 W n 1 (4) when W encounters the termination of a task T, W pops T from its deque. there are two cases about T s parent P : 1 P is blocked and now becomes ready again W enqueues and continues to P 2 other cases no particular action; continues to the next task in its deque or starts work stealing if it becomes empty 14 / 48

Work stealing scheduler in action top bottom P W 0 W 1 W 2 W n 1 (4) when W encounters the termination of a task T, W pops T from its deque. there are two cases about T s parent P : 1 P is blocked and now becomes ready again W enqueues and continues to P 2 other cases no particular action; continues to the next task in its deque or starts work stealing if it becomes empty 14 / 48

A note about the cost of operations top S P bottom W 0 W 1 W 2 W n 1 with work stealing, the cost of a task creation is cheap, unless its parent is stolen 1 a task gets created 2 the control jumps to the new task 3 when finished, the control returns back to the parent (as it has not been stolen) 15 / 48

A note about the cost of operations top S P bottom W 0 W 1 W 2 W n 1 much like a procedure call, except: the parent and the child each needs a separate stack, as the parent might be executed concurrently with the child, as the parent might be executed without returning from the child, the parent generally cannot assume callee save registers are preserved the net overhead is 100-200 instructions, from task creation to termination 15 / 48

What you must remember when using work stealing systems when using (good) work stealing scheduler, don t try to match the number of tasks to the number of processors bad idea 1: create P tasks when you have P processors bad idea 2 (task pooling): keep exactly P tasks all the time and let each grab work they are effective with OS-managed threads or processes but not with work stealing schedulers remember: keep the granularity of a task above a constant factor of task creation overhead (so the relative overhead is a sufficiently small constant. e.g., 2%) good idea: make the granularity 5000 cycles 16 / 48

Contents 1 Introduction 2 Work stealing scheduler 3 Analyzing execution time of work stealing 4 Analyzing cache misses of work stealing 5 Summary 17 / 48

Analyzing execution time of work stealing we analyze execution time of work stealing scheduler in terms of T 1 (total work) and T (critical path) Blumofe et al. Scheduling multithreaded computations by work stealing Journal of the ACM 46(5). 1999. due to the random choices of victims, the upper bound is necessarily probabilistic (e.g., T P with a probability ) for mathematical simplicity, we are satisfied with the result about average execution time 18 / 48

Analyzing execution time of work stealing the main result: with P processors, E(T P ) T 1 P + ct, with c a small constant reflecting the cost of a work steal remember the greedy scheduler theorem? T P T 1 P + T 19 / 48

Recap : DAG model recall the DAG model of computation T 1 : total work (= execution time by a single processor) T : critical path (= execution time by an arbitrarily many processors) T P : execution time by P processors two obvious lower bounds of execution time of any scheduler: T P T 1 P, T P T T 20 / 48

Recap : greedy scheduler greedy scheduler: a worker is never idle, as long as any ready task is left ready nodes the greedy scheduler theorem: any greedy scheduler achieves the following upper bound T P T 1 P + T considering both T 1 and T P are lower bounds, this shows any greedy scheduler is within a factor of two of optimal 21 / 48

Proof of the greedy scheduler theorem : settings for the sake of simplifying analysis, assume all nodes take a unit time to execute (longer nodes can be modeled by a chain of unit-time nodes) there are P workers workers execute in a lockstep manner 22 / 48

Proof of the greedy scheduler theorem : settings ready nodes 3 5 6 7 1 2 4 in each time step, either of the following happens 23 / 48

Proof of the greedy scheduler theorem : settings ready nodes 3 5 6 7 1 2 4 in each time step, either of the following happens (S) there are P ready tasks each worker executes any ready task (Saturated) 23 / 48

Proof of the greedy scheduler theorem : settings ready nodes 6 5 2 3 4 1 in each time step, either of the following happens (S) there are P ready tasks each worker executes any ready task (Saturated) (U) there are P ready tasks each ready task is executed by any worker (Unsaturated) 23 / 48

Proof of the greedy scheduler theorem : settings ready nodes in each time step, either of the following happens (S) there are P ready tasks each worker executes any ready task (Saturated) (U) there are P ready tasks each ready task is executed by any worker (Unsaturated) 23 / 48

Proof of the greedy scheduler theorem consider a path from the start node to the end node, of which a node is always ready (let s call such a path a ready path) exercise: prove there is a ready path terminated ready 24 / 48

Proof of the greedy scheduler theorem consider a path from the start node to the end node, of which a node is always ready (let s call such a path a ready path) exercise: prove there is a ready path at each step, either of the following must happen terminated ready 24 / 48

Proof of the greedy scheduler theorem consider a path from the start node to the end node, of which a node is always ready (let s call such a path a ready path) exercise: prove there is a ready path at each step, either of the following must happen (S) all P workers execute a node, or terminated ready 24 / 48

Proof of the greedy scheduler theorem consider a path from the start node to the end node, of which a node is always ready (let s call such a path a ready path) exercise: prove there is a ready path at each step, either of the following must happen (S) all P workers execute a node, or (U) the ready node in the path gets executed terminated ready 24 / 48

Proof of the greedy scheduler theorem consider a path from the start node to the end node, of which a node is always ready (let s call such a path a ready path) exercise: prove there is a ready terminated path ready at each step, either of the following must happen (S) all P workers execute a node, or (U) the ready node in the path gets executed (S) happens T 1 /P times and (U) T times 24 / 48

Proof of the greedy scheduler theorem consider a path from the start node to the end node, of which a node is always ready (let s call such a path a ready path) exercise: prove there is a ready terminated path ready at each step, either of the following must happen (S) all P workers execute a node, or (U) the ready node in the path gets executed (S) happens T 1 /P times and (U) T times therefore, the end node will be executed in T P (T 1 /P + T ) steps 24 / 48

What about work stealing scheduler? what is the difference between the genuine greedy scheduler and work stealing scheduler? the greedy scheduler finds ready tasks with zero delays any practically implementable scheduler will inevitably cause some delays, from the time a node becomes ready until the time it gets executed in the work stealing scheduler, the delay is the time to randomly search other workers deques for ready tasks, without knowing which deques have tasks to steal 25 / 48

Analyzing work stealing scheduler : settings a similar setting with greedy scheduler all nodes take a unit time P workers 26 / 48

Analyzing work stealing scheduler : settings a similar setting with greedy scheduler all nodes take a unit time P workers each worker does the following in each time step its deque is not empty executes the node designated by the algorithm its deque is empty attempts to steal a node; if it succeeds, the node will be executed in the next step 26 / 48

Analyzing work stealing scheduler : settings a similar setting with greedy scheduler all nodes take a unit time P workers each worker does the following in each time step its deque is not empty executes the node designated by the algorithm its deque is empty attempts to steal a node; if it succeeds, the node will be executed in the next step remarks on work stealing attempts if the chosen victim has no ready tasks (besides the one executing), an attempt fails when two or more workers choose the same victim, only one can succeed in a single time 26 / 48

The overall strategy of the proof steal attempts P T 1 T P in each time step, each processor is either executes a node or attempts a steal if we can estimate the number of steal attempts (succeeded or not), we can estimate the execution time by: T P = T 1 + steal attempts P 27 / 48

Analyzing work stealing scheduler ready how many steal attempts? executed similar to the proof of greedy scheduler, consider a ready path (a path from the start node to the end node, of which a node is always ready) the crux is how many steal attempts are enough to make a progress along a ready path 28 / 48

The number of steal attempts: the key observation a task at the bottom of the deque will be stolen by a steal attempt with probability 1/P thus, on average, such a task will be stolen within P steal attempts, and is executed in the next step create task P steal attempts we are going to extend the argument to any ready task along a ready path, and establish an average number of steal attempts for any ready task to get executed 29 / 48

How many steal attempts to occur for any ready task to get executed? there are five types of edges (A) create task child (B) create task the continuation (C) wait task the continuation (D) last node of a task the parent s continuation after the corresponding wait (E) non-task node the continuation create task (A) create task (B) wait tasks (C) wait tasks (D) 30 / 48

How many steal attempts to occur for any ready task to get executed? the successor of type (A), (C), (D), and (E) is executed immediately after the predecessor is executed (recall the path is a ready path) create task (A) create task (B) wait tasks (C) wait tasks (D) 30 / 48

How many steal attempts to occur for any ready task to get executed? only the successor of type (B) edges may need a steal attempt to get executed as has been discussed, tasks at the bottom of a deque need P attempts on average create task (A) create task (B) wait tasks (C) wait tasks (D) 30 / 48

How many steal attempts to occur for any ready task to get executed? a subtlety arises, as ready tasks are not necessarily at the bottom of a deque y cannot be stolen until x has been stolen create task (A) x create task (B) y wait tasks (C) wait tasks (D) 30 / 48

When a task becomes stealable? create task in general, in order for the continuation of a create task (n) to be stolen, create task continuations of all create tasks along create task the path from the start node to n must be stolen so we define a node n to be critical iff it is ready and for all create task nodes along the create task n path from the start node to n, its continuation node has been executed then we have a critical node is at the bottom of a deque; and a critical node is, on average, executed within P steal attempts a ready path 31 / 48

Summary of the proof (1) there is a ready path (2) define a critical node as in the previous slide (3) with this definition a critical node will be stolen, on average, within P steal attempts (4) a critical node will be executed one time step after stolen, so will be finished within 2P steal attempts (5) the length of any ready path is T (6) from (4) and (5), any path will take 2T P steal attempts to finish (7) therefore E(T P ) T 1 + 2T P P T 1 P + 2T 32 / 48

Extensions we assumed a steal attempt takes a single time step, but it can be generalized; if a steal attempt takes a time steps, E(T P ) T 1 P + 2aT we can also probabilistically bound the execution time the basis is the probability that a critical node takes cp steal attempts to be executed is e c ( 1 1 ) cp e c P based on this we bound the probability that a path of length l takes ClP steal attempts, for a large enough constant C 33 / 48

Contents 1 Introduction 2 Work stealing scheduler 3 Analyzing execution time of work stealing 4 Analyzing cache misses of work stealing 5 Summary 34 / 48

Analyzing cache misses of work stealing we like to know the amount of data transfers between a processor s cache and { main memory, other caches }, under a task parallel scheduler in particular, we like to understand how is it worse (or better) than its serial execution hardware thread (virtual core, CPU) L1 cache L2 cache memory controller L3 cache 35 / 48

An analysis methodology of serial computation we have learned how to analyze data transfer between the cache and main memory, in single processor machines the key was to identify cache-fitting subcomputations (working set size C words) a cache-fitting subcomputation induces C words data transfers cache main memory capacity C capacity C C C 36 / 48

Minor remarks (data transfer vs. cache misses) we hereafter identify a single data transfer from/to a cache and a single cache miss in real machines, some data transfers do not lead to cache misses due to prefetches we use a simpler term cache misses to mean any data transfer from/to a cache 37 / 48

What s different in parallel execution? the argument that cache misses by a cache-fitting subcomputation C no longer holds in parallel execution consider two subcomputations A and B 1 create_task({ A }); 2 B A B assume A and B together fit in the cache a parallel execution may execute A and B on different processors, which may turn what would originally be a cache hit in B into a miss C 38 / 48

What s different in parallel execution? so a parallel execution might increase cache misses but how much? The data locality of work stealing. SPAA 00 Proceedings of the twelfth annual ACM symposium on Parallel algorithms and architectures. 39 / 48

Problem settings P processors ( P workers) caches are private to each processor (no shared caches) consider only a single-level cache, with the capacity of C words LRU replacement: i.e., a cache holds most recently accessed C distinct words caches capacity of each C main memory capacity 40 / 48

The key observation we have learned the work stealing scheduler tends to preserve much of the serial execution order extra cache misses are caused by work stealings a work stealing essentially brings a subcomputation to a processor with unknown cache states A B????? 41 / 48

The key questions key question 1: how many extra misses can occur when a subcomputation moves to an unknown cache states? hit miss initial cache states (different) executed instructions (identical) key question 2: how many times work stealings happen? (we know an answer) 42 / 48

Roadmap (1) bound the number of extra cache misses that occurs each time a node is drifted (i.e., executed in a different order with the serial execution) (2) we know an upper bound on the number of steals (3) from (2), bound the number of drifted nodes combine (1) and (3) to derive an upper bound on the total number of extra cache misses 43 / 48

Extra misses per drifted node when caches are LRU, the two cache states converge to an identical state, after no more than C cache misses occur in either cache initial cache states (different) C transfers (misses) C transfers (misses) this is because the cache is LRU (holds most recently accessed distinct C words) extra cache misses for each drifted node C 44 / 48

A bound on the drifted nodes let v a node in the DAG and u the node that would immediately precedes v in the serial execution we say v is drifted when u and v are not executed consecutively on the same processor without a detailed proof, we note: work stealing drifted would immediately precede a drifted node in the serial order the number of drifted nodes in the work stealing scheduler 2 the number of steals 45 / 48

The main result the average number of work stealings 2P T the average number of drifted nodes 4P T the average number of extra cache misses 4CP T average execution time T P T 1 P + 4mCT, where m is the cost of a single cache miss 46 / 48

Contents 1 Introduction 2 Work stealing scheduler 3 Analyzing execution time of work stealing 4 Analyzing cache misses of work stealing 5 Summary 47 / 48

Summary the basics of work stealing scheduler work-first (preserve serial execution order) steal tasks from near the root average execution time (without cost of communication) T P T 1 P + 2T with the cost of communication T P T 1 P + 4mCT where mc essentially represents the time to fill the cache 48 / 48