Professional Documents
Culture Documents
Lecture8 Allocation
Lecture8 Allocation
Scheduling
❚ Defines an architecture by selecting hardware resources
which are necessary to implement a given system.
❚ The components can be, for example, microprocessors,
micro-controllers, DSP s, ASIP s, ASIC s, FPGA s,
memories, buses or point-to-point links.
Kris Kuchcinski ❚ Usually made manually with a support of estimation
tools.
Krzysztof.Kuchcinski@cs.lth.se ❚ In simple cases can be performed automatically using
optimization strategy.
2014-08-26 2
2014-08-26 1
❚ After allocation the partitioning of system functionality to ❚ Depending on the computation model scheduling can be
selected components can be done. done off-line or during run-time.
❚ The partitioning defines the assignment of tasks to ❚ Static vs. dynamic scheduling.
particular components. ❚ RTOS support for dynamic scheduling.
❚ If there is number of tasks assigned to the same ❚ Scheduling can address advanced execution
component, which does not support parallel execution, techniques, such as software pipelining.
the execution order need to be decided — task
scheduling. ❚ Can be applied to tasks allocated to hardware, software
as well as hardware operations and software
instructions.
2014-08-26 3 2014-08-26 4
2014-08-26 5 2014-08-26 6
1
High-Level Synthesis Scheduling High-Level Synthesis Scheduling (cont d)
x u y dx
Synthesis of the following code 3 x u dx 3 y u dx x dx 3 x u dx 3 y u dx x dx
end;
scheduled register
data-flow graph data-flow graph allocation
7 8
x x
F G
2014-08-26 11 2014-08-26 12
2
Data Path Allocation HLS typical process (cont d)
❚ Control Allocation
E<0:7> A<0:7> C<0:7> B<0:7>D<0:7>
Load R3 Load R4
❙ Selection of control
style (PLA, random logic, etc.)
M1 M2 M3 M4 Add, Load R2
Mul, Load R4
❙ Signal/condition design
* +
Add, Load R1
G F
Data part
Mul, Load R2
Control part
2014-08-26 13 2014-08-26 14
8 7 10
6 + 6 + x
7 10 ALAP schedule
ASAP schedule x
2014-08-26 17 2014-08-26 18
3
List Scheduling List Scheduling
Control
step 1 3
❚ Constructive scheduling algorithm which selects 1 2 3 4 5 + x
+ + x + x 1
operation to be assigned to control steps based on a 4 5
priority function. 6 7 8 2 + x
- + +
❚ Priority function can be different in different versions of 2
3 +
list scheduling algorithms: 9 10
x x 6
❙ higher priority to operations with low mobility, or 4
-
Distribution Graph
Distribution Graph (cont d)
Control step 1/2 1/2 1/2 1/3 1/3 1/2 1/2 1/2 1/3
Control step Addition/Subtraction DG Multiplication DG
1 + x +
+
1
1 3 4 x
2 2 +
-
5 2
3 6 8
x
x +
3
10
4 9 7
4
4
Force Calculation Forced Directed Scheduling Algorithm
❚ the force associated with the tentative assignment of ❚ Once all the forces are calculated, the operation-control
an operation to c-step j is equal to the difference step pair with the lowest force is scheduled.
between the distribution value in that c-step and the ❚ The distribution graphs and forces are then updated and
average of the distribution values for the c-steps the above process is repeated until all operations are
bounded by the operation s time frame. scheduled.
t
DG(i)
Force( j ) = DG( j ) − ∑
i= f t − ( f + 1)
❚ assignment of operation 10 to control step 3
Force(3) = DGmult(3) - average DGmult value over time
frame of operation 10 = 1.333 - (1.333 + 1)/2 = 0.167,
Force(4) = -0.167
2014-08-26 25 2014-08-26 26
❚ Control constructs h1
not
&
❙ conditional sharing — sharing of resources for
mutually exclusive operations,
&
h3 +
❙ speculative execution.
❚ Chaining and multi-cycling.
&
h7 +
❚ Pipelined components. not
+
❚ Pipelining. h10
&
❚ Registers and memory allocation.
+
❚ Low-power issues.
2014-08-26 27 2014-08-26 28
adder multiplier
h1
&
h10 h3, h6, h9
h3 h5 h2
h1
x x
h2 h3
& & & c
h3 h10, h2, h6, h7, h8, h9 c
not c not c
h5 h9
h7 h8 h6 h6 h10, h3, h7, h9
& & &
h7 h3, h6 + +
h8 h3, h9 + +
h10 h9 h9 h10, h3, h5, h6, h8
& &
5
Speculative Execution Chaining and multicycling
c + 100 ns
c
+ +
+
50 ns x
200 ns Multicycle
+
speculatively 100 ns
executed operation
2014-08-26 31 2014-08-26 32
i1 i2 i3 i4 i5 i6
multiplier 1 +
+ +
+
+ +
50 ns x x x
+ +
+
100 ns + + +
x
x + x
+ i7 i8 +
+ + + +
x + + x
+ x x +
+ +
+ + +
2014-08-26 33 2014-08-26 34
Scheduling of H.261
Pipelining — Example Video Coding Algorithm
6
Scheduling of H.261
Video Coding Algorithm Real-Time Scheduling
task i
Ci Di
2014-08-26 39 2014-08-26 40
❚ Much like static data-flow. ❚ Rate Monotonic Scheduling (RMS) — a task with a
shorter period is assigned a higher priority.
❚ If there are arbitrary task periods the schedule duration
is equal least common multiplier (LCM) of task periods ❚ RMS is optimal — no fixed priority scheme does better.
(MPEG 44.1 kHz * 30 Hz requires 132 300 repetitions).
❚ Problem with sporadic tasks.
2014-08-26 41 2014-08-26 42
7
Rate Monotonic Scheduling- An Example Rate Monotonic Scheduling
20ms 40ms
❚ Utilization
Ci
Task2 Utilization = ∑
Ti i
Task1
❚ All deadlines met when utilization ≤ n(21/n- 1)
T2 ❙ For n=2, 2*(2 1/ 2-1) = 0.83,
T1
❙ For n → ∞ , n(21/n- 1) → ln(2) = 0.69
❚ An example
Task Period (T) Rate (1/T) Exec Time (C) Utilization(U)
Task2 1 100 ms 10 Hz 20 ms 0.2
2 150 ms 6.67 Hz 40 ms 0.267
Task1
3 350 ms 2.86 Hz 100 ms 0.286
Priority(Task1) < Priority(Task2) ❚ 0.753 < 0.779 (=3*(21/3 -1) => tasks are schedulable
2014-08-26 43 2014-08-26 44
❚ Table of tasks with a task priority and its state (enables, ❚ Access to a shared resource should be mutually
etc.). exclusive to access a resource
❚ At context switch select the task with the highest priority. ❙ lock the resource → critical section starts
❘ may fail and block the task
❚ Linear complexity, O(n) where n = number of tasks.
❙ process the resource
❙ unlock the resource critical section ends
Task C1 C2
2014-08-26 45 2014-08-26 46
❙ Deadlock
❙ Priority inversion
❚ Methods for solving priority inversion problem Deadlock
Priority H C2
❙ priority inheritance,
❙ priority ceiling protocol. Priority L C1
2014-08-26 47 2014-08-26 48
8
Priority Inversion Priority Inheritance
2014-08-26 49 2014-08-26 50
❚ Chained blocking:
Priority H C
ceiling(C) =H ❙ a job can have several critical sections,
Priority M
❙ it can be blocked whenever it wants to enter a critical
Priority L C section
❙ this generates overhead in terms of task switching.
❚ The main idea is to reduce the occurrence of priority
Priority H C
inversions by preventing multiple priority inversions; a
job will be blocked at most once before it enters its first
Priority M critical section.
Priority L C ❚ The solution prevents deadlock.
priority H
2014-08-26 51 2014-08-26 52
2014-08-26 53 2014-08-26 54
9
Earliest Deadline First Earliest Deadline First
❚ Minimizes number of missed deadlines. ❚ EDF can achieve 100% utilization until overload occurs.
❚ Tasks with earliest deadline has priority. ❚ Cannot guarantee meeting deadlines for arbitrary data
❚ An Example arrival times.
❚ An example
Task Period (T) Rate (1/T) Exec Time (C) Utilization (U)
C1=2, T1=5 Task2
A 20 ms 50 Hz 10 ms 0.5
C2=4, T2=7 Task1 B 50 ms 20 Hz 25 ms 0.5
2 5 7 10 14 A1 A2 B1 A3 A4 A5,B2
non-decreasing deadlines
0 10 20 30 40 50 60 70 80 90 100
2014-08-26 55 2014-08-26 56
2014-08-26 57 2014-08-26 58
2014-08-26 59 2014-08-26 60
10
Context-switching time Literature
❚ Non-zero context switch time can push limits of a tight ❚ P. Eles, K. Kuchcinski and Z. Peng, System Synthesis
schedule. with VHDL, Kluwer Academic Publisher, 1998.
❚ Hard to calculate effects -- depends on order of context ❚ Any book on real-time scheduling, e.g.,
switches. Alan Burns and Andy Wellings, Real-Time Systems and
❚ In practice, OS context switch overhead is small. Programming Languages, Addison Wesley, 1996.
2014-08-26 61 2014-08-26 62
11