• 沒有找到結果。

4.3 Pinwheel Phase Alignment

4.3.1 Minimize the Total Delay

Given two pinwheel schedules for two neighboring nodes

N

j and

N

j+1, we dene the phase

h

j as the dierence between the start times of

T

nj and

T

nj+1. We choose the start time of

T

nj as the reference point because there is only one unique start time of

T

njin any pinwheel schedule. It must be true that 0

h

j

< C

nsince the schedule repeats every

C

n. The delay of

X

i between

N

j and

N

j+1,

d

ij, is a periodic function of

h

j with period

C

i.

d

ij can be dened as follows:

d

ij(

h

j) = (

h

j+



ij) mod

C

i 0

h

j

< C

n (4.3) where



ij is the delay for

T

ij when

h

j = 0. For the rest of this chapter, we sometimes use

d

ij as a shorthand for

d

ij(

h

j). The total delay of all tasks between nodes

N

j and

N

j+1 is dened as

!

j(

h

j) =Pi

d

ij(

h

j).

!

j has the following property.

Theorem 4.3

If the total delay

!

j(

h

j) between nodes

N

j and

N

j+1 has the minimum value when

h

j =

t

, it must be true that 9

i

,

d

ij(

t

) = 0.

52

0 2 4 6 8 10 12 14 16 18 20

0 5 10 15 20 25 30 35 40 45 50

phase hj

delay dij

d11 d21 d31 d41

d51 delay function for d31 total delay function minimum total delay

Figure 4.4: Delay functions and their sum

Proof: Assume

h

j =

t

0 is the optimal phase for

!

j and none of the

d

ij(

t

0)'s is equal to 0,

8

i

. Suppose the minimum of the

d

ij(

t

0)'s is

d

kj(

t

0). If we set the phase to

t

0;

d

kj(

t

0), all

d

ij's will be reduced by

d

kj(

t

0). So, at this new phase,

t

0;

d

kj(

t

0), the total delay is less than that at the phase

t

0 by the amount

n d

kj(

t

0), thus a contradiction. 2

Representing the Delay Function

Before we present the algorithm for nding the minimum total delay, we rst show how to eciently represent the delay function in our algorithm. The

d

ij function dened in Equation (4.3) is a set of discontinued line segments (e.g.

d

31 in Figure 4.4). Between discontinued points,

d

ij increases linearly with

h

j. At each discontinued point,

d

ij drops from

C

ito zero. When several

d

ijfunctions are combined, the resulting function is a serrated line. In a serrated line, the function value monotonically increases, with a constant slope, between discontinued points. In other words, each serrated line can be dened as a set of line segments with a constant slope. The delay functions and their total function for the example of Figure 4.2 is shown in Figure 4.4.

Suppose the total delay

!

j(

h

j) has the minimum value when

h

j =

t

. To nd

t

, we need to inspect all line segments in the serrated line Pi

d

ij(

h

j). From Theorem 4.3, we know that the minimum

!

j(

h

j) occurs at

h

j =

t

when at least one of the

d

ij(

t

) is 0, where it

is discontinued. By searching through all discontinued (or drop) points in 0

C

n), we can

nd the

t

value. Unfortunately, there are many drop points in 0

C

n). For example, if8

i

, 1 

i < n

,

C

i+1

=C

i = 2, there will be 2n;1 drop points. We would like to reduce the number of drop points to be searched.

We use a special data structure to cut down the domain size of a serrated line while keeping all signicant drop points (i.e. those with lower

!

j values). For example, to reduce the domain size of a serrated line

f

(

t

) from 100 to 25, we dene

f

0(

t

) = minf

f

(

t

)

f

(

t

+ 25)

f

(

t

+ 50)

f

(

t

+ 75)g

for 1 

t

 25. Conceptually, the serrated line is cut into equal portions, and only the minimum values of relative points in the portions are kept. To keep track of the original

h

j value, each point in our representation has two domains: the current domain and the original domain. Throughout the algorithms, the serrated line will be cut many times and only a subset of the original

!

j(

h

j) function is kept. However, each point in the nal serrated line has its unique

h

j value in the original domain. The data structure SLINE is dened below.

Denition: An SLINE

S

=f

s w

(

x y

) f(

p

1

a

1

p

01) (

p

2

a

2

p

02)

:::

ggis dened by 1.

s

is the slope of the line segments

2.

w

is the width, the current domain size

3. (

x y

) is the origin coordinates in the original domain

4. (

p

i

a

i

p

0i)'s are a sequence of drop points. For each point,

p

i is its current domain value,

p

0iis its original domain value, and

a

iis the drop amount. The points are sorted on the

p

i value.

2

Suppose

S

is an SLINE with

v

drop points and domain width

E

k, and

F

1

::: F

u are delay functions with period

E

w. Three operations have been dened for SLINE: SUM, MAX and CUT.

54

Figure 4.5: Cutting SLINE (S=CUTfW,4g)

1. SUMf

S F

1

::: F

ug is an SLINE that has the sum of all function values.

2. MAXf

S F

1

::: F

ug is an SLINE that has the maximum of all function values.

3. CUTf

S E

wg is an SLINE with

S

's domain size cut to

E

w but keeps the minimum values in

S

.

Figure 4.5 shows the CUT operation of SLINE. In the gure,

W

and

S

are SLINE's where

W

= f1 8 (0 2) f(3 5 3) (6 2 6)ggand

S

=

CUT

f

W

4g= f1 4 (4 1) f(2 2 6) (3 2 3)gg. Both SUMf

S F

1

::: F

ug and MAXf

S F

1

::: F

ug can be done in

O

(

v

+

u

lg

u

) time. The time complexity of CUTf

S E

wgis

O

(

v

lg(

E

k

=E

w)). The detailed denitions and algorithms for these SLINE operations are included in the Appendix C.

Minimizing the Total Delay Between Two Nodes

Again let

X

be a set of

n

transactions in a distributed system of

m

processors.

T

ij is the task of

X

i on node

N

j with execution time

e

ij. We group tasks according to their period values. Suppose there are

l

dierent period values, tasks with the shortest period,

E

1, are in group

G

1 and tasks with the longest period,

E

l, are in group

G

l. j

G

kjis the number of tasks in group

G

k and

E

k is the period value of task group

G

k. Therefore Plk=1j

G

kj=

n

. For any task

T

ij in group

G

k, the value of

d

ij(

h

j) is the same as the value of

d

ij(

h

j+

E

k).

Moreover, the sum of all

d

ij(

h

j)'s for all tasks in

G

k is also a periodic function of

h

j with period

E

k. We therefore may combine all delay functions of the same task group in one

SLINE.

We would like to nd the

h

j that minimizes Pni=1

d

ij(

h

j). Instead of searching through every point in the domain

E

l, we use the CUT operation to reduce the search domain but keep all potential

h

j values. In our algorithm, we add the delay functions (using SUM) one group at a time, until all groups are added, to form the subtotal delay function

S

. Before each SUM operation, we use the CUT operation to reduce the subtotal function

S

to the next (smaller) domain size.

Let kj(

h

j) be the sum of all

d

ij(

h

j)'s in the groups f

G

k,

G

k+1

::: G

lg. By denition, we know that kj(

h

j) is a periodic function with period

E

k, since

E

kj

E

i, for

k

+ 1

i



l

. We design the

minsum

algorithm for nding the minimum total delay as follows.

Algorithm minsum

(

j

)

Input:

E

1

::: E

l are the period lengths for

G

1

::: G

l

d

ij is the delay function for

X

i between

N

j and

N

j+1.

1

S

=f0

E

l (0 0) g //

S

is an SLINE representing the current subtotal function.

2

S

=

SUM

f

S F

lgwhere

F

l=f

d

ij j

d

ij 2

G

lg //

F

l is a collection of delay functions.

3

for k

=

l

;1

downto

1

do

f

4

S

=

CUT

f

S E

kg 

5

S

=

SUM

f

S F

kgwhere

F

k =f

d

ijj

d

ij 2

G

kg

6 g

7 return

t

where

S

(

t

) is the minimum.

In the

minsum

algorithm kj(

h

j) is implemented as an SLINE

S

with width

E

k. By applying CUT(

S E

k),

S

keeps all the points with the minimal kj(

h

j) value and also keeps track of their positions in the original domain.

Algorithm Complexity

Since the width of

S

is

E

k, each

d

ij in

G

k will only contribute one drop point in

S

. The number of new drop points added will be at most j

G

kj. Because Plk=1j

G

kj is

n

, the number of drop points in

S

will be no greater than

n

. The complexity of line 2 and line 5 is

O

(Plk=1(

n

+j

G

kjlgj

G

kj)), the complexity of line 4 is

O

(Plk;1=1

n

lg(

E

k+1

=E

k)), and the

56 complexity of line 7 is

O

(

n

). Since the (

E

k+1

=E

k)'s for a system are constants, the overall complexity of the algorithm is

O

(

n

lg

n

+

nl

).

Minimize the Total End-to-End Delay

For a sequence of nodes, the phases

h

j's between adjacent nodes can be adjusted dently. Therefore, the minimum total delay between any node pair can be achieved indepen-dently. To get the minimum total delay for all nodes, we only need to sum up the minimum total delay between any two consecutive pinwheels. That is

minsum

=Pmj=1;1

!

j. The time complexity to nd the minimum total delay of a

m

-node system is

O

(

mn

lg

n

+

mnl

).

相關文件