• Tidak ada hasil yang ditemukan

5.3 HEALERS Algorithm

5.3.1 COMPUTE-SCHEDULE

COMPUTE-SCHEDULE attempts to allocate each taskTi ∈T onto the heterogeneous platform V such that their execution requirements within the given time-slice T Sk are satisfied. It first computes the shares required by each task in T Sk, and inserts them into the list L1 (Lines 2 to 5). As the tasks may possibly have distinct share values corresponding to each one of the m heterogeneous processing cores, there are m entries for each task in L1. Then, it sortsL1 innon-decreasing order of shares. Subsequently, it invokes SCHEDULE-NON-MIGRATE (Algorithm 17) to assign tasks whose shares can be fully allocated on any one of the available processing cores and then adds the rest of the tasks in list L2. It may be noted that L2 contains tasks whose execution demand shi,j,k in T Sk cannot be entirely fulfilled by the remaining capacities of any individual processing core. Therefore, these tasks must be allocated upon multiple cores each of which together satisfy its total execution requirement. Hence, tasks in L2 form the set of migrating tasks in T Sk. COMPUTE-SCHEDULE invokes SCHEDULE-MIGRATE (Algorithm 18) in order to allocate each migrating taskTi on more than one processing core. Each such core satisfies a fraction ofTi’s total execution demand.

5.3 HEALERS Algorithm

ALGORITHM 16: COMPUTE-SCHEDULE Input: T,V,T Sk, SMk

Output: Schedule Matrix SMk

1 Initialize the lists L1 =∅, L2 =∅ {COMPUTE-SHARES-REQUIRED by tasks at T Sk}

2 for i= 1 to n do

3 for j = 1 to m do

4 shi,j,k =dui,j × |T Sk|e

5 L1 =L1∪ {hi, j, shi,j,ki}

6 Sort L1 in non-decreasing order of shi,j,k

7 SCHEDULE-NON-MIGRATE(L1, L2, SMk, V)

8 SCHEDULE-MIGRATE(L2, SMk, V)

9 returnSMk

ALGORITHM 17: SCHEDULE-NON-MIGRATE Input: L1, L2,SMk, V

Output: SMk (Schedule matrix with non-migrating tasks), L2 (Sorted list of migrating tasks)

1 while L1 is not empty do

2 Extract the first element hi, j, shi,j,ki from L1

3 if τi can be allocated fully on Vj for shi,j,k then

4 Assign start and end times of τi onVj, i.e., SMk[i][j] = hstart time(Ti), end time(Ti)i

5 Decrement the capacity of Vk byshi,j,k

6 Delete all entries of Ti fromL1 and L2

7 else

8 Tentatively insert hi, j, shi,j,ki at end ofL2

9 returnSMk, L2

5.3.1.1 SCHEDULE-NON-MIGRATE

SCHEDULE-NON-MIGRATE attempts to assign start and end times to tasks which can be fully allocated onto any one of the m cores in the platform. In order to conduct such assignment, this function sequentially considers the sharesshi,j,k inL1 and attempts to allocate shi,j,k entirely on core Vk. If such an allocation is successful, task Ti becomes a non-migrating/fixed task in T Sk and the remaining capacity of Vj is decremented by shi,j,k. On the other hand, if allocation ofshi,j,k onVj is unsuccessful, it is removed from L1 and inserted in L2. Once a task Ti is scheduled, all its entries are deleted from both the lists L1 and L2 (Lines 3 to 8).

5.3.1.2 SCHEDULE-MIGRATE

This attempts to schedule tasks which require more than one processing core for their execution. First, it creates a list L3 from L2 to keep track of the unallocated share of Ti (Lines 2 to 4). Next, it extracts the first element (say, hi, j, shi,j,ki) from L3 and also computes the unused capacity ucj of Vj (Line 7). If ucj is non-zero, then SCHEDULE- MIGRATE computes the unallocated share of Ti with respect to Vj, i.e., usi,j (Lines 9 to 13). While utilizing the unused capacity of Vj, there are two possibilities (Lines 14 to 20):

• usi,j > ucj: This implies that the unallocated share ofTi is greater than the unused capacity of coreVj. Hence,Tiis partially scheduled onVj and the unallocated share of Ti is updated.

• usi,j ≤ ucj: This implies that the unused capacity of core Vj is sufficient enough to meet the unallocated demand of Ti. Hence, task Ti is allocated on Vj. Since, Ti’s allocation is completed, usi,j is reset to 0 and all entries of Ti are deleted from L3.

While scheduling a migrating task Ti, HEALERS attempts to ensure that Ti does not execute on multiple processing cores simultaneously (Lines 22 to 23). In order to schedule a migrating task Ti, HEALERS uses the following heuristic mechanism. First,

5.3 HEALERS Algorithm

non-terminating part of a migrating task is always scheduled at start of the time-slice on its available favoured core. Thereafter, all other parts of it’s execution are scheduled on cores in staircase fashion, where the starting time of the task on the second and subsequent cores is assigned by incrementing it’s end time on the previous core, by 1.

The starting and ending times of execution for each task in time-slice T Sk is stored in the Schedule Matrix SMk. In the absence of sufficient spare capacity to schedule a migrating task on multiple cores, HEALERS declares the scheduling of T on V to be infeasible. Otherwise, it returns the schedule matrix SMk, consisting of schedules for all ready tasks in the current time-slice T Sk.

ALGORITHM 18: SCHEDULE-MIGRATE Input: L2, SMk, V

Output: SMk (Schedule Matrix for all tasks)

1 while L2 is not empty do

2 Create a list L3 and initialize it to∅

3 Extract all entries of Ti from L2 and move to L3

4 Let usi,j be the unallocated share of Ti on Vj

5 while L3 is not empty do

6 Extract-out the first entry hi, j, shi,j,kifrom L3

7 Compute unused capacity of Vj: ucj

8 if ucj 6= 0 then

9 /* Compute unallocated share of Ti on Vj: usi,j*/

10 if Ti is not yet allocated partially on any core then

11 unallocated share of Ti w.r.t Vj: usi,j =shi,j,k

12 else

13 Let Vl be the last core in which Ti was partially scheduled

14 unallocated share of Ti w.r.t Vj: usi,j =usi,l×ui,j/ui,l

15 if usi,j > ucj then

16 Update SMk[i][j] to schedule Ti on Vj for the duration ucj

17 Update the unallocated share of Ti w.r.t Vj: usi,j =usi,j −ucj

18 else

19 Update SMk[i][j] to schedule Ti onVj for the duration ucj − dusi,je

20 Reset usi,j to 0

21 Delete all entries of Ti from L3

22 if (usi,j 6= 0) then

23 Declare the scheduling of T onV is infeasible

24 returnSMk

ALGORITHM 19: COMPUTE-EA-SCHEDULE Input: T Sk, SMk, Frequency Set F

Output: Schedule Matrix SMk at time-sliceT Sk

1 for each processor Vj ∈V do

2 Let |Tj| denotes the set of tasks scheduled on Vj in T Sk Compute unused capacity of Vj: ucj

3 if ucj 6= 0 then

4 Compute the frequency fopt for Vj using Eqn. (5.4)

5 if fopt < fcr then

6 Modify shares of each non-migrating task Ti onVj: shi,j,k =shi,j,k/fcr 7 Set fopt ←fcr

8 Calculate time duration tsm for which Vj can be suspended using Eqn. (5.6)

9 else

10 Modify shares of each non-migrating task Ti onVj: shi,j,k =shi,j,k/fopt

11 Determine the amount of time t1 (t1 ≤ |T Sk|) for whichVj should operate at frequency bfoptc

12 Update SMk for all tasks scheduled on Vj

13 return SMk