







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








Referencing values not yet ready causes operation pipeline to stall
VLIW processors: can issue one operation per functional unit in each cycle Superscalar processors: tries to issue the next k instructions if possible Instruction Scheduler Original code Reordered code
Instruction scheduling Dependence graph
Each node n ∈ N is a single operation type(n) : type of functional-unit that can execute n delay(n): number of cycles required to complete n Edge (n1,n2) ∈ N indicates n2 uses result of n1 as operand G is acyclic within each basic block a: loadAI rarp, @w r b: add r1, r1 r c: loadAI rarp, @x r d: mult r1, r2 r e: loadAi rarp, @y r f: mult r1, r2 r g: loadAI rarp, @z r h: mult r1, r2 r i: storeAI r1 rarp, 0 a b c d e f g h i Dependence graph
Given a dependence graph D = (N,E), a schedule S maps each node n ∈ N to the cycle number that n should be issued. Each schedule S must satisfy three constraints Well-formed: for each node n ∈ N, S(n) >= 1; there is at least one node n ∈ N such that S(n) = 1 Correctness: if (n1,n2) ∈ E, then S(n1) + delay(n1) <= S(n2) Feasibility: for each cycle i >= 1 and each functional-unit type t, (number of node n where type(n)=t and S(n)=i) ≤ (number of functional-unit t on the target machine) Given a well-formed schedule S that is both correct and feasible, the length of the schedule is L(s) = max(S(n) + delay(n)) n ∈ N A schedule S is time-optimal if it is the shortest For all other schedules Sj (which contain the same set of operations), L(S) <= L(Sj) (S has shorter length than Sj)
e overwrites the value of r2 that d uses There is an anti-dependence from d to e
Add anti-dependences as new edges in dependence graph; or Rename registers to eliminate anti-dependences a: loadAI rarp, @w r b: add r1, r1 r c: loadAI rarp, @x r d: mult r1, r2 r e: loadAi rarp, @y r f: mult r1, r2 r g: loadAI rarp, @z r h: mult r1, r2 r i: storeAI r1 rarp, 0 a b c d e f g h i Dependence graph
Each node ni can start only if all other nodes that ni depend on have finished Length of any dependence path n1n2…ni (any path in D) is delay(n1)+delay(n2)+…+delay(ni)
should schedule nodes on critical path as early as possible a: loadAI rarp, @w r b: add r1, r1 r c: loadAI rarp, @x r d: mult r1, r2 r e: loadAi rarp, @y r f: mult r1, r2 r g: loadAI rarp, @z r h: mult r1, r2 r i: storeAI r1 rarp, 0 a b c d e f g h i Dependence graph
cs5363 10
Cycle := 1 Ready := leaves of D Active := ∅ While (Ready ∪ Active ≠ ∅) if Ready ≠ ∅ then remove an opi (top priority) from Ready S(opi) := Cycle add opi to Active Cycle ++ for each opi ∈ Active if S(opi) + delay(opi) <= Cycle then remove opi from Active for each successor opj of opi in D Mark edge (opi,opj) ready if all edges to opj are ready then add opj to Ready a: loadAI rarp, @w r b: add r1, r1 r c: loadAI rarp, @x r d: mult r2, r3 r e: loadAi rarp, @y r f: mult r4, r5 r g: loadAI rarp, @z r h: mult r6, r7 r i: storeAI r8 rarp, 0 Example: a b c d e f g h i Dependence graph 3
cycle Ready active integer memory loadAI rarp, @w r loadAI rarp, @x r loadAi rarp, @y r add r11, r1 r mult r1, r2 r loadAI rarp, @z r mult r1, r3 r mult r1, r2 r storeAI r1 rarp, 0 start 1 2 3 4 5 6 7 9 11
Wait for all operations in one block to complete before proceeding to the next block Improvement: trace scheduling (across block boundaries)
Must allocate operations on specific functional units
Memory access may take different number of cycles depending on whether it is in the cache Advanced study: reordering computations to improve the performance memory access operations
Unstability in tie breaking of same-ranking operations Can use different priority ranking, e.g., length of longest path, number of immediate successors, number of descendents, …