• 沒有找到結果。

Hardness of Packing and Placement for Direct Mapped Cache

CHAPTER 4 PRACTICAL APPROACHES

4.1 Hardness of Packing and Placement for Direct Mapped Cache

Section 3.3 analyzes the properties of the packing and placement problem for the k-set direct mapped cache. It proposes a method to transform the object access trace to a graph by using the Degree-2 trace information. That graph expresses the relations between objects, memory blocks, and sets. The temporal relations among entities classify the edges in the graph into three types (Type-I, Type-B, and Type-S). The goal of the packing and placement problem is creating a memory layout that minimizes cache misses when reproduce the same object access trace. Due to the nature of the pair-wise trace information, we derive the following formula to estimate cache misses –

|BT| - ( Length(Type-I-Edges) + Length(Type-S-Edges) ) (4.1)

The length of the block access trace |BT| is a constant in this formula, but the lengths of Type-I edges and Type-S edges are derived by the object layout. In other words, maximizing the sum of lengths can minimize cache misses. It is easy to show

that minimizing the sum of length of all Type-B edges is a dual problem to Equation (4.1) by the following equation.

|BT| - (Length(Type-I-Edges) + Length(Type-S-Edges) )

=(Length(Type-I-Edges)+Length(Type-B-Edges)+Length(Type-S-Edges)) - Length(Type-I-Edges)+Length(Type-S-Edges))

= Length(Type-B-Edges)

(4.2)

Therefore, the packing and placement problem can be defined as follows.

Definition 4.1. Consider a K-set direct mapped cache and an object set allocating to the memory, defined as O = {o1, o2, o3,...}. The memory space is partitioned into K disjoint sets of memory blocks. A set denoted as si-=-{bi,1, bi,2, bi,3 … } represents a collection of memory blocks, where each bi,j denotes a memory block belonging the i-th set si. The size of each memory block bi,j is M. The purpose is to find a legal mapping function fpp(oi)  br,t that assigns each object to a memory block in a specific set. Meanwhile, it must satisfy the condition that

minimizing the following cost function –

 

In the last equation, w(oi, oj) is the value from the Degree-2 trace information, or the length of Type-B edges, equivalently.

Subsequently, we are going to show that finding an optimal solution for this problem is as hard as solving the MIN k-PARTITION problem. The MIN k-PARTITION is a dual problem of the MAX k-CUT [43].

Consider a graph G1=(V,E) with K partitions, where |V(G1)|=Q, and the each vertex is associated with value K. Since the vertex set V is divided into K partitions, the number of vertexes in each partition is denoted as (n1,n2,…nK), and the vertex set is

the r-th partition. In other words, the vertex subset { vr,1, … vr,n

r } contains vertexes belonging to the r-th partition. Figure 4.1 shows an example of G1, and the dashed lines divide the graph G1 into partitions. We use different notations to distinguish edges within and across partitions. p(vr,h, vr,s) denotes the length of an edge inside the r-th partition, and w(vr,h, vq,s) denotes the length of an edge across two distinct partitions.

Since the graph G1 is assumed to satisfy the conditions of MIN k-PARTITION, it implies the summing up length of edges within the same partitions ∑p(u,v) gets the minimum comparing to other geometrics of the partitioned G1. In the meanwhile, the condition ∑w(x,y) >∑p(u,v) is hold.

Next, we create a mapping F(v) to transform G1=(V,E) to G2=(V’,E’), where G2=(V’,E’) is a restricted version for the packing and placement problem for the direct mapped cache. The mapping F(v) works in the following way.

 vi,jV, F(vi,j)={v’i,j,1,…,v’i,j,K}, where v’V’. (4.4)

The mapping means evenly splitting every vertex vi,j into K fractional vertexes.

The value is evenly distributed to fractions as well, that is, the value of each fraction vi,j,t is 1

KK . As a result, we can get a transformed vertex set, written as )}

v’i,j,K} are connected to each other and become a KK complete graph. Therefore,

 

2

1 K

K edges are appended to the edge set E’(G2). Edge length h is given to all these

kind of edges, and its value is given as h = ∑w(x,y)+∑p(u,v), that equals to the summing up lengths of all inter-partition edges. This ensures h is the greatest value among all edge lengths in E(G1). The fractional vertex v’i,j,1 replaces the role of vi,j, and edges connected to vi,j are re-attached to v’i,j,1 correspondingly. Therefore, the edge set E’(G2) is expressed as follows.

For example, the graph G2 in Figure 4.2 is constructed from the graph G1 in Figure 4.1 using the discussed method. The vertexes and the sub-graph enclosed by a shadow area in G2 are expanded from a single vertex in G1.

Next, we are going to show that the optimal partition layout of G1 that satisfies MIN k-PARTITION can be transformed and becomes an optimal layout of G2 for the K-set packing and placement problem. That is, G2 can be used to represent an object access graph. Each vertex v’i,j,t represents an object and its value corresponds to the size of an object. The length of an edge is marked by the Degree-2 trace information.

Besides, block size constraint is assumed K. Since each vertex subset { vr,1, vr,2, … vr,n

r} belongs to the same partition in G1, the vertex subset { {v’r,1,1, …, v’r,1,K }…{ v’r,n

r,1, … v’r,n

r,K } } is grouped into the same r-th partition in G2. Consider the sub-graph enclosed within the r-th partition. The length of edges connects

v’r,x,1 and v’r,y,1, which is p(u,v), both are smaller than h.

( holds by our scheme. Therefore, every subset

{ v’r,t,1, v’r,t,2,…,v’r,t,K } can be consolidated to a memory block and that makes the sum of objects in a memory block fulfills the problem requirement. Since the lengths of all Type-B edges are exactly p(u,v), and p

 

u,v w

 

x,y hK(K2 1)Qholds.

Therefore, the layout satisfies the problem requirements.

Subsequently, the K-set packing and placement problem is as hard as MIN k-PARTITION, as well as MAX k-CUT. Since there is no polynomial time algorithm to

find an optimal layout to satisfy MIN k-PARTITION, neither solves the K-set packing and placement problem.

v

1,1 p1

v

1,2 p2

v

1,3

v

2,1 p3

v

2,2 p4

v

2,3

v

3,1 p5

v

3,2 p6

v

3,3

v

4,1 p7

v

4,2 p8

v

4,3

w1 w2 w3

w4 w5 w6

w7 w8 w9

Figure 4.1. A partitioned graph satisfies MIN k-PARTITION. The symbols w i and p

i denote edge lengths.

V4,3,1

Figure 4.2. A sample graph transformed from Figure 4.1.