CS 137 Electronic Design Automation Day 20 November
CS 137: Electronic Design Automation Day 20: November 23, 2005 Scheduling Variants and Approaches 1 CALTECH CS 137 Fall 2005 -- De. Hon
Today • Scheduling – Force-Directed – SAT/ILP – Branch-and-Bound 2 CALTECH CS 137 Fall 2005 -- De. Hon
Last Time • • Resources aren’t free Share to reduce costs Schedule operations on resources Greedy approximation algorithm 3 CALTECH CS 137 Fall 2005 -- De. Hon
Force-Directed • Problem: how exploit schedule freedom (slack) to minimize instantaneous resources – Directly solve time constrained – Trying to minimize resources 4 CALTECH CS 137 Fall 2005 -- De. Hon
Force-Directed • Given a node, can schedule anywhere between ASAP and ALAP schedule time – Between latest schedule predecessor and ALAP – Between ASAP and already scheduled successors • N. b. : Scheduling node will limit freedom of nodes in path 5 CALTECH CS 137 Fall 2005 -- De. Hon
Single Resource Challenge A 1 A 3 A 5 A 2 A 4 A 6 A 7 A 8 A 9 A 10 A 11 A 12 A 13 B 2 B 1 B 3 B 10 B 11 B 4 B 5 B 6 B 7 B 8 B 9 CALTECH CS 137 Fall 2005 -- De. Hon 6
Force-Directed • If everything where scheduled, except for the target node, we would: – examine resource usage in all timeslots allowed by precedence – place in timeslot which has least increase maximum resources 7 CALTECH CS 137 Fall 2005 -- De. Hon
Force-Directed • Problem: don’t know resource utilization during scheduling • Strategy: estimate resource utilization 8 CALTECH CS 137 Fall 2005 -- De. Hon
Force-Directed Estimate • Assume a node is uniformly distributed within slack region – between earliest and latest possible schedule time • Use this estimate to identify most used timeslots 9 CALTECH CS 137 Fall 2005 -- De. Hon
Single Resource Challenge 2 2 2 2 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 10
Single Resource Challenge 2 2 2 2 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 11
Single Resource Challenge 2 2 2 2 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 12
Single Resource Challenge 2 2 2 2 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 13
Single Resource Challenge 2 2 2 2 8 8 8 2 3/9 8 8 2 1/9 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 14
Force-Directed • Scheduling a node will shift distribution – all of scheduled node’s cost goes into one timeslot – predecessor/successors may have freedom limited so shift their contributions • Want to shift distribution to minimize maximum resource utilization (estimate) 15 CALTECH CS 137 Fall 2005 -- De. Hon
Single Resource Challenge 2 2 2 8 8 8 2 Repeat 8 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 16
Single Resource Challenge 2 2 2 8 8 8 2 Repeat 8 8 8 2 3/9 8 8 2 1/9 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 17
Single Resource Challenge 2 2 2 2 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 18
Single Resource Challenge 2 2 2 2 8 8 8 3 4/9 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 19
Single Resource Challenge 2 2 2 2 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 20
Single Resource Challenge 2 2 2 2 8 8 8 8 3 2/9 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 21
Single Resource Challenge 2 2 2 2 8 8 8 2 3/9 8 8 2 1/9 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 22
Single Resource Challenge 2 2 2 2 8 8 8 8 2 3/9 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 23
Single Resource Challenge 2 2 2 2 8 8 8 8 2 3/9 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 24
Single Resource Challenge 2 2 2 2 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 25
Single Resource Challenge 2 2 2 2 8 8 8 8 3 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 26
Single Resource Challenge 2 2 2 2 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 27
Single Resource Challenge 2 2 2 2 8 8 8 8 2 13/18 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 28
Single Resource Challenge 2 2 2 2 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 29
Single Resource Challenge 2 2 2 2 8 8 8 8 3 2/9 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 30
Single Resource Challenge 2 2 2 2 8 8 8 8 2 13/18 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 31
Single Resource Challenge 2 2 2 2 8 8 8 8 2 13/18 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 32
Single Resource Challenge 2 2 2 2 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 33
Single Resource Challenge 2 2 2 2 8 8 8 8 2 13/18 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 34
Single Resource Challenge 2 2 2 2 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 35
Single Resource Challenge 2 2 2 2 8 8 8 8 2 13/18 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 36
Single Resource Challenge 2 2 2 2 8 8 8 8 2 13/18 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 37
Single Resource Challenge 2 2 2 2 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 38
Single Resource Challenge 2 2 2 2 8 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 39
Single Resource Challenge 2 2 2 2 8 8 8 8 Many steps… 8 8 CALTECH CS 137 Fall 2005 -- De. Hon 40
Force-Directed Algorithm 1. ASAP/ALAP schedule to determine range of times for each node 2. Compute estimated resource usage 3. Pick most constrained node (in largest time slot…) – – – Evaluate effects of placing in feasible time slots (compute forces) Place in minimum cost slot and update estimates Repeat until done 41 CALTECH CS 137 Fall 2005 -- De. Hon
Time • Evaluate force of putting in timeslot O(NT) – Potentially perturbing slack on net prefix/postfix for this node N – Each node potentially in T slots • Evaluate all timeslots can put in O(NT 2) • N nodes to place • O(N 2 T 2) – Loose bound--don’t get both T slots and N perturbations 42 CALTECH CS 137 Fall 2005 -- De. Hon
SAT/ILP (Integer-Linear Programming) 43 CALTECH CS 137 Fall 2005 -- De. Hon
Two Constraint Challenge • Processing elements have limited memory – Instruction memory (data memory) • Tasks have different requirements for compute and instruction memory – i. e. Run length not correlated to code length 44 CALTECH CS 137 Fall 2005 -- De. Hon
Task • Task: schedule tasks onto PEs obeying both memory and compute capacity limits Example and ILP solution From Plishker et al. NSCD 2004 CALTECH CS 137 Fall 2005 -- De. Hon 45
Task • Task: schedule tasks onto PEs obeying both memory and compute capacities • two capacity partitioning problem – …actually, didn’t say anything about communication… • two capacity bin packing problem • Task: i <Ci, Ii> 46 CALTECH CS 137 Fall 2005 -- De. Hon
SAT Packing • Ai, j – task i assigned to resource j Constraints • Coverage constraints • Uniqueness constraints • Cardinality constraints – PE compute – PE memory 47 CALTECH CS 137 Fall 2005 -- De. Hon
Allow Code Sharing • Two tasks of same type can share code • Instead of memory capacity – Vector of memory usage • Compute PE Imem vector – As OR of task vectors assigned to it • Compute mem space as sum of nonzero vector entries 48 CALTECH CS 137 Fall 2005 -- De. Hon
Allow Code Sharing • Two tasks of same type can share code • Task has vector of memory uage – Task i needs set of instructions k: Ti, k • Compute PE Imem vector – OR (all i): PE. Imemj, k+=Ai, j * Ti, k • PE Mem space – PE. Total_Imemj= (PE. Imemj, k*Instrs(k)) 49 CALTECH CS 137 Fall 2005 -- De. Hon
Symmetries • As with partitioning, many symmetries • Speedup with symmetry breaking – Tasks in same class are equivalent – PEs indistinguishable – Total ordering on tasks and PEs – Add constraints to force tasks to be assigned to PEs by ordering – Plishker claims “significant runtime speedup” – Using GALENA [DAC 2003] psuedo-Boolean SAT solver 50 CALTECH CS 137 Fall 2005 -- De. Hon
Plishker Task Example 51 CALTECH CS 137 Fall 2005 -- De. Hon
Results Greedy (first-fit) binpack SAT/ILP Solve Solutions in < 1 second 52 CALTECH CS 137 Fall 2005 -- De. Hon
Why can they do this? • Ignore precedence? • Ignore Interconnect? 53 CALTECH CS 137 Fall 2005 -- De. Hon
Why can they do this? • Ignore precedence? – feed forward, buffered • Ignore Interconnect? – Through shared memory, not dominant? 54 CALTECH CS 137 Fall 2005 -- De. Hon
Interconnect Buffers • Allow “Software Pipelining” Each data item Spatial we would pipeline, running all three at once Think of each schedule instance as one timestep in spatial pipeline. 55 CALTECH CS 137 Fall 2005 -- De. Hon
Interconnect Buffer B C A B C C A PE 1 B C A PE 0 C A A C A 50 C A 100 B 50 B C C B B A A 56 CALTECH CS 137 Fall 2005 -- De. Hon
Add Precedence to SAT/ILP? • Assign start time to each task • Precedence: constrain start of each task to be greater than start+run of each predecessor • Time Exclusivity: constrain nonoverlap of start+run-1 on nodes on same PE – Maybe formulate as order on PE – And make PE order predecessor like a task predecessor? Untested conjecture CALTECH CS 137 Fall 2005 -- De. Hon 57
Memory Schedule Variants • Persistent: holds memory whole time – E. g. task state, instructions • Task temporary: only uses memory space while task running • Intra-Task: use memory between point of production and consumption – E. g. Def-Use chains 58 CALTECH CS 137 Fall 2005 -- De. Hon
Memory Schedule Variants • Persistent: – Binpacking in memory • Task temporary: – Co-schedule memory slot with execution • Intra-Task: – Lifetime in memory depends on scheduling def and last use – Phase Ordered: Register coloring 59 CALTECH CS 137 Fall 2005 -- De. Hon
Branch-and-Bound 60 CALTECH CS 137 Fall 2005 -- De. Hon
Brute-Force • Try all schedules • Branching/Backtracking Search • Start w/ nothing scheduled (ready queue) • At each move (branch) pick: – available resource time slot – ready task (predecessors completed) – schedule task on resource 61 CALTECH CS 137 Fall 2005 -- De. Hon
Example T 1 T 4 T 6 T 2 T 5 T 3 T 1 time 1 T 3 time 1 idle time 1 Target: 2 FUs idle time 2 T 2 time 1 T 4 time 2 T 3 time 2 62 CALTECH CS 137 Fall 2005 -- De. Hon
Branching Search • Explores entire state space – finds optimum schedule • Exponential work – O (N(resources*time-slots) ) • Many schedules completely uninteresting 63 CALTECH CS 137 Fall 2005 -- De. Hon
Reducing Work 1. Canonicalize “equivalent” schedule configurations 2. Identify “dominating” schedule configurations 3. Prune partial configurations which will lead to worse (or unacceptable results) 64 CALTECH CS 137 Fall 2005 -- De. Hon
“Equivalent” Schedules • If multiple resources of same type – assignment of task to particular resource at a particular timeslot is not distinguishing T 1 T 3 T 2 T 1 Keep track of resource usage by capacity at time-slot. 65 CALTECH CS 137 Fall 2005 -- De. Hon
“Equivalent” Schedule Prefixes T 1 T 4 T 6 T 2 T 5 T 3 T 1 T 2 T 4 T 3 T 4 66 CALTECH CS 137 Fall 2005 -- De. Hon
“Non-Equivalent” Schedule Prefixes T 1 T 4 T 6 T 2 T 5 T 3 T 1 T 3 T 2 T 1 T 3 67 CALTECH CS 137 Fall 2005 -- De. Hon
Pruning Prefixes? • I’m not sure there is an efficient way (general)? • Keep track of schedule set – walk through state-graph of scheduled prefixes – unfortunately, set is power-set so 2 N – …but not all feasible, so shape of graph may simplify 68 CALTECH CS 137 Fall 2005 -- De. Hon
Dominant Schedules • A strictly shorter schedule – scheduling the same or more tasks – will always be superior to the longer schedule T 3 T 2 T 5 T 4 T 1 T 3 T 2 CALTECH CS 137 Fall 2005 -- De. Hon T 4 T 5 T 3 T 4 T 1 T 2 T 5 69
Pruning • If can establish a particular schedule path will be worse than one we’ve already seen – we can discard it w/out further exploration • In particular: – LB=current schedule time + lower_bound_estimate – if LB greater than existing solution, prune 70 CALTECH CS 137 Fall 2005 -- De. Hon
Pruning Techniques Establish Lower Bound on schedule time • Critical Path (ASAP schedule) • Resource Bound • Critical Chain 71 CALTECH CS 137 Fall 2005 -- De. Hon
“Critical Chain” Lower Bound • Bottleneck resource present coupled resource and latency bound Single red resource 72 CALTECH CS 137 Fall 2005 -- De. Hon
“Critical Chain” Lower Bound • Bottleneck resource present coupled resource and latency bound Single red resource Critical path 5 Resource Bound (1, 1) 4 Critical Chain (1, 1) 7 73 CALTECH CS 137 Fall 2005 -- De. Hon
Alpha-Beta Search • Generalization – keep both upper and lower bound estimates on partial schedule • Lower bounds from CP, RB, CC • Upper bounds with List Scheduling – expand most promising paths • (least upper bound, least lower bound) – prune based on lower bounds exceeding known upper bound – (technique typically used in games/Chess) 74 CALTECH CS 137 Fall 2005 -- De. Hon
Alpha-Beta • Each scheduling decision will tighten – lower/upper bound estimates • Can choose to expand – – least current time (breadth first) least lower bound remaining (depth first) least lower bound estimate least upper bound estimate • Can control greediness – weighting lower/upper bound – selecting “most promising” 75 CALTECH CS 137 Fall 2005 -- De. Hon
Note • Aggressive pruning and ordering – can sometimes make polynomial time in practice – often cannot prove will be polynomial time – usually represents problem structure we still need to understand 76 CALTECH CS 137 Fall 2005 -- De. Hon
Multiple Resources • Works for multiple resource case • Computing lower-bounds per resource – resource constrained • Sometimes deal with resource coupling – e. g. must have 1 A and 1 B simultaneously or in fixed time slot relation • e. g. bus and memory port 77 CALTECH CS 137 Fall 2005 -- De. Hon
Summary • • Resource estimates and Refinement SAT/ILP Schedule Software Pipelining Branch-and-bound search – “equivalent” states – dominators – estimates/pruning 78 CALTECH CS 137 Fall 2005 -- De. Hon
Admin • Class – Friday (no holiday) – Next week: • Monday, Friday • No Wed. • Next week’s reading all online 79 CALTECH CS 137 Fall 2005 -- De. Hon
Big Ideas: • Estimate Resource Usage • Use dominators to reduce work • Techniques: – – Force-Directed SAT/ILP Coloring Search • Branch-and-Bound • Alpha-Beta 80 CALTECH CS 137 Fall 2005 -- De. Hon
- Slides: 80