data locality

11
COMPILER DESIGN PRESENTED BY SYAMLAL.S.S NO:528 II MCA NMCC

Upload: syam-lal

Post on 18-Aug-2015

32 views

Category:

Education


0 download

TRANSCRIPT

COMPILER DESIGN

PRESENTED BY

SYAMLAL.S.S

NO:528

II MCA

NMCC

Topic:

DATA LOCALITY

Data Locality

It is the property that, references to the same memory location or adjacent locations are reused within a short period of time

Good data locality is essential for good application performance.

Applications with poor data locality reduce the effectiveness of the cache, causing long stall times waiting for memory accesses.

Temporal Locality

It occurs when the same data is used several times within a short period.

There are two kinds of locality:

1.Temporal Locality2.Spatial Locality

Spatial Locality

It occurs when different data elements that are located near to each other are used within a short period of time.

An important form of spatial locality occurs when all the elements that appear on one cache line are used together.

The effect of this spatial locality is that cache misses are minimized, with a resulting important speedup of the program.

Example1:

Fig: Program to find the squares of the differences (a) without loop fusion (b) with loop fusion

[Image from: The Dragon book 2nd edition]

First loop finds the differences, the second finds the squares.

The fused loop(fig.b) has better performances because it has better data locality.

Example2:Sequential and parallel code for zeroing an

array

The two examples above illustrate several important characteristics associated with numeric applications

operating on arrays:

• Array code often has many parallelizable loops.

• When loops have parallelism, their iterations can be executed in arbitrary order ; they can be reordered to improve data locality drastically.

• As we create large units of parallel computation that are independent of each other, executing these serially tends to produce good data locality.

References:

Compilers ‐ Principles, Techniques, and Tools by A. Aho, M. Lam (2nd edition), R. Sethi, and J.Ullman, Addison‐Wesley.

www.google.com

Thank You!