A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding...

20
A COMPONENT-BASED DEFINITION OF SPATIAL LOCALITY Xiaoming Gu Chengliang Zhang Chen Ding University of Rochester Microsoft Corporation

Transcript of A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding...

Page 1: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

A COMPONENT-BASED DEFINITION OF SPATIAL

LOCALITY

Xiaoming Gu Chengliang Zhang

Chen DingUniversity of

RochesterMicrosoft Corporation

Page 2: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

TRADITIONAL DEFINITION OF SPATIAL LOCALITY

When a data element is accessed, the nearby data elements will also be accessed

Overall miss rate The fewer the misses, the better the layout

Page 3: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

QUESTIONS

Can the overall spatial locality be decomposed into finer components?

How much can the locality of a given data layout be improved?

Can a data layout be improved if the miss rate cannot be lowered?

Page 4: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

A COMPONENT-BASED DEFINITION OF SPATIAL LOCALITY

Based on the reuse distance Based on components

Page 5: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

REUSE DISTANCE

The reuse distance of a memory access is the number of distinct data elements accessed between this and the previous access to the same data.

∞ ∞ ∞ 2 0 2 0 1a b c a a b b a

Page 6: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

REUSE SIGNATURE

The distribution of all reuse distances In our experiment, we use log sized bins

0 1 2 ∞0

1

2

3

0 1 2-3 ∞2 1 2 3

Page 7: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

A COMPONENT-BASED DEFINITION OFSPATIAL LOCALITY

Spatial locality measures the change in reuse distance when the data block size changes from b1 to twice the size b2 = 2*b1.

∞ ∞ ∞ 2 0 2 0 1∞ 0 ∞ 1 0 0 0 0a b c a a b b a

b1

b2

Page 8: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

CASES OF CHANGEx yData layout

xTrace ...........................................

Case 1: ...........................................

Case 2: ...........................................

c d

x

x x

x xy

b2

b1

x y

s

Data layout

Page 9: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

CHANGES OF REUSE SIGNATURE

2 1 2 3

5 1 0 2

0-0 1-1 2-3 ∞

b2

b1

Page 10: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

DATA LAYOUT QUALITY

Effective spatial reuse: the bin they are located has been moved to left by at least C bins, when the block size is doubled

Ineffective spatial reuse: the other reuses In our experiment, we pick C to be 3 The data layout quality of a bin:

2 * effective spatial reuse / total spatial reuse

Page 11: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

COMPONENT

Data reuses of nearby bins that have a similar portion of effective spatial reuse

The spatial locality of a component is the weighted average of the spatial locality of each bin

We manually examine the bins and groups them into components

Page 12: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

EXPERIMENTAL SETTING

7 SPEC2000 (equake, art, swim, gzip, mcf, crafty, twolf) and 1 SPEC2006 (milc) Data size varies from 1.2MB to 72MB Trace length varies from 7.7 billion to 400 billion

Valgrind [NethercoteSeward’07] to collect traces

Augmented reuse distance analyzer [DingZhong’03] Several hundred times slower

Page 13: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

SWIM

Page 14: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

WHY OPTIMIZED SWIM BETTER

L1 miss rate L2 miss rate

Original version 10.4% 5.33%

Optimized version 9.7% 5.33%

L1 miss rate reduced by 6.7%

Performance increased by 8.1%

4% reference: 0.16 -> 0.99

Page 15: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

Good temporal locality

Good spatial locality

Poor Spatial locality

Page 16: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.
Page 17: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

DIFFERENT INPUTS

Component Spatial locality

Size (%)

ref input

swim-c1 0.25 5.1swim-c2 1 5.2

train input

swim-c1 0.25 5.1swim-c2 0.98 5.2

Page 18: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

POSSIBLE USES

User tuning [Levinthal] Superpage management Data-based cache hints [ Fang’05,

BeylsD’Hollander’05]

Page 19: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

RELATED WORK

Spatial locality [BuntMurphy’84,Weinberg+’05]

Component-based analysis [DingZhong’03,Shen+’03]

Spatial uses within a loop [WolfLam’91,McKiney+’96]

Page 20: A C OMPONENT - BASED D EFINITION OF S PATIAL L OCALITY Xiaoming GuChengliang Zhang Chen Ding University of RochesterMicrosoft Corporation.

SUMMARY

A quantitative model of spatial locality We have tested our new model on 8 SPEC

benchmark programs Among 18 components, 2 have good temporal

locality, 6 have good spatial locality, 4 have poor spatial locality/poor temporal locality/large

Possible uses