• Keine Ergebnisse gefunden

4.2 Heuristic Approaches

4.2.2 Distributed Scheduling Heuristics

Scheduling algorithms for tasks with communication usually comprise two different phases [29]. At First a task selection phase, also called the prioritization phase, takes place and determines which task should be scheduled next. The second phase, a processor selection phase, determines the processor on which the task should be executed. In our scenario, the processor selection is fixed a priori, which means we focus on the task ordering mechanism of each heuristic.

4.2. Heuristic Approaches 65

TheHeterogeneous Earliest Finish Time(HEFT) [108] andDominant Sequence Clus-tering (DSC) [121] heuristics are examples for list-scheduling algorithms that main-tain a fixed priority list of tasks which is calculated once. Both heuristics use the length of the longest path (in terms of WCET and communication time) from a taskt, including the communication times, to a sink of the DAG for their task pri-oritization. We will use exit(t) to denote this path. HEFT simply ranks tasks by increasing exit(t) (c.f. Algorithm 2). The DSC heuristic uses the ERT of t plus exit(t) as the priority of t as shown inAlgorithm 3.

Algorithm 2 Heterogeneous Earliest Finish Time (HEFT) heuristic

1: functionScheduleAfter(t, releaset, Tsched)

2: blockedTime ←0

3: for alltsched ∈ Tsched do

4: if µt(t) =µt(tsched)∧tsched.C > releasetthen

5: blockedTime ←max(blockedTime, tsched.C−releaset)

6: t.S =releaset+blockedTime

7: return {Tsched∪t}

8: functionHEFT(T)

9: Tsched ← ∅

10: ∀t∈ T calculateexit(t) and t.ERT

11: for allt∈ T sorted by decreasingexit(t)do

12: Tsched← ScheduleAfter(t, t.ERT, Tsched)

Algorithm 3 Dominant Sequence Clustering (DSC) heuristic

1: functionDSC(T)

2: Tsched ← ∅

3: ∀t∈ T : calculatet.ERT

4: ∀t∈ T :blevel(t) =exit(t)

5: while T \ Tsched 6=∅ do

6: ∀t∈ T :tlevel(t) =t.ERT

7: t←arg max(tlevel(t) +blevel(t)) overt∈ T \ Tsched

8: Tsched← ScheduleAfter(t, t.ERT, Tsched)

9: ∀t∈ T \Tsched calc t.ERT using tsched.S ast.ERT for all tsched∈ Tsched

66 4. From Specification to Solutions

The Mobility Directed (MD) [120] heuristic chooses tasks based on their mobility, defined as the difference between a task’s LFT and its earliest start time (EST), divided by the task’s WCET. Although the EST is similar to the ERT, it is recal-culated after each task selection and takes into account the scheduling time of the other workflow tasks. The EST is calculated in line 7 of Algorithm 4.

Algorithm 4 Mobility Directed (MD) heuristic

1: function MD(T)

2: Tsched← ∅

3: ∀t∈ T : calculate t.ERT and t.LF T

4: whileT \ Tsched6=∅do

5: t←arg max(t.LF T|t|−t.ERT) over t∈ T \ Tsched

6: Tsched ← ScheduleAfter(t, t.ERT, Tsched)

7: ∀t∈ T \Tsched calc t.ERT using tsched.S ast.ERT for alltsched ∈ Tsched

Earliest Task First (ETF) [45] picks a task among the ready tasks, meaning tasks whose predecessors have already been scheduled, by choosing the task with the min-imum EST. Ties are broken by the task with the smallest LFT minus WCET as shown in Algorithm 5.

Algorithm 5 Earliest Task First (ETF) heuristic

1: function etf(T)

2: Tsched← ∅

3: ∀t∈ T : calculate t.ERT and t.LF T

4: whileT \ Tsched6=∅do

5: ReadyTasks ←args min(t.ERT) over t∈ T \ Tsched

6: t←arg min(t.LF T − |t|) over t∈ReadyTasks

7: Tsched ← ScheduleAfter(t, t.ERT, Tsched)

8: ∀t∈ T \Tsched calc t.ERT using tsched.S ast.ERT for alltsched ∈ Tsched We propose two additional scheduling heuristics: an adapted version of Potts’ heuris-tic [93] that works in a distributed environment with fixed task-placement, and the Least Delay heuristic (LD). Our proposed LD heuristic tries to determine the im-plications of scheduling each task in the ready set. The heuristic schedules each of the tasks in the ready set in a “what-if” manner and determines the EST of all tasks in the DAG based on this speculative scheduling. The resulting EST of each sink task is compared to its EST before the speculative scheduling, yielding a value for the expected delayt of the sink taskt. The maximumdelayt yields the delay for the entire workflow. The heuristic now chooses the task from the ready set that resulted in the minimum workflow delay. This heuristic has a high run-time complexity, but our evaluation (Section 4.3.1) shows it can generate solutions in many cases where the other heuristics failed to do so. The pseudocode is given in Algorithm 6.

4.2. Heuristic Approaches 67

The adapted Potts’ heuristic is set up by picking the task with the minimum LFT from the available ready set, meaning the current time on the task’s machine is equal or greater than the task’s EST. This initial step is also known as Schrage’s heuristic [93]. In most cases, Schrage’s heuristic yields valid schedules, meaning the DAG sinks do not violate the workflow deadline in the schedules. If the first pass of Schrage’s heuristic was unsuccessful, Potts’ heuristic then analyzes the resulting schedules and looks for a task A that violates its LFT.A is called the critical task.

This means there could be another task B with a smaller EST than A but with a larger latest starting time (LST) scheduled before A because A was not ready at that moment. If such a taskB, also called the interference task, exists on the same machine as A, we introduce an additional edge in the DAG from A toB to ensure that A will be scheduled before B. If no such task exists on the same machine as the critical task, we look for an interference task B0 on a different machine. We then take B0 as the new critical task and try to locate an interference task C on the same machine as B0. If C exists, we introduce an additional edge from C to B0 and continue as previously described. The modified workflow is then rescheduled with Schrage’s heuristic. Pseudocode for the modified Potts’ heuristic is shown in Algorithm 7.

Algorithm 6 Least Delay heuristic (LD)

1: functionLeastDelay(T,G)

2: Tsched ← ∅

3: ∀t∈ T : calculatet.ERT andexit(t)

4: while T \ Tsched 6=∅ do

5: Ttmp← Tsched

6: minDelay← ∞

7: tminDelay← ∅

8: for alltroot∈ T \ Tsched:P rec(troot) =∅ do . Unscheduled roots

9: Ttmp ← ScheduleAfter(troot, troot.ERT, Ttmp)

10: Tmp ← ∀t∈ T \ Ttmp calc. t.ERT using t.S ast.ERT fort∈ Ttmp

11: delay ← max(Tmp(tleaf) − t.ERT) for tleaf ∈ T \ Tsched : Succ(tleaf) =∅

12: if delay < minDelay∨(delay =minDelay∧maxLen < exit(troot)) then. Scheduling current root leads to a smaller delay in the leafs than before

13: tminDelay←troot

14: minDelay←delay

15: maxLen←exit(troot)

16: Tsched← ScheduleAfter(tminDelay, tminDelay.ERT, Tsched)

17: ∀t∈ T \Tsched calc t.ERT using tsched.S ast.ERT for all tsched∈ Tsched

68 4. From Specification to Solutions

Algorithm 7 Modified Potts’ heuristic for distributed systems

1: function Potts(T)

2: AbsoluteEarliest ← ∀t∈ T : calculate t.EST

3: fori≤number of tasks inT do

4: TSchrage ← SchragesHeuristic(T)

5: if TSchrage is a valid schedulethen. Valid if t.C of all DAG leafs≤DW 6: return TSchrage

7: else

8: interference← IdentifyInterference(TSchrage)

9: if interference 6=∅then

10: add new precedence relation crit≺interference toG

11: else

12: return Infeasible with Potts’ heuristic

13: return Infeasible with Potts’ heuristic

14: function SchragesHeuristic(T)

15: Tsched← ∅

16: ∀t∈ T : calculate t.LF T

17: whileT \ Tsched6=∅do

18: for all ti ∈ T \ Tsched ordered by increasing t.LF T do

19: machineClock ←max(tj.C) over tj ∈ Tsched∧µt(ti) =µt(tj)

20: if ti.ERT ≥machineClock then

21: t←ti

22: break for-loop

23: Tsched ← ScheduleAfter(t, t.ERT, Tsched)

24: ∀t∈ T \Tsched calc t.ERT using tsched.S ast.ERT for alltsched ∈ Tsched

25: return Tsched

26: function IdentifyInterference(T)

27: interference← ∅

28: for allt∈ T do .Identify critical task

29: if (t.C > t.LF T ∧t.S >AbsoluteEarliest(t))∨t.C > DWthen

30: crit ←t . tviolates its own deadline or the workflow deadline

31: break for-loop

32: for allt∈ T do .Identify interference task delaying the critical task

33: if µt(t) =µt(crit)∧crit.LF T < t.LF T ∧t⊀≺crit then

34: interference←t . tviolates local or workflow deadline

35: break for-loop

36: if interference6=∅then returninterference

37: crit ←arg max(t.ERT −AbsoluteEarliest(t)) over t∈P rec(crit)

38: for allt∈ T do

39: if µt(t) =µt(crit)∧crit.LF T < t.LF T ∧t⊀≺crit then

40: interference←t

41: break for-loop

42: return interference