Docsity

Memory Performance Optimization: Techniques for Irregular Applications - Prof. Alan L. Sus, Study notes of Computer Science

Partial preview of the text

Download Memory Performance Optimization: Techniques for Irregular Applications - Prof. Alan L. Sus and more Study notes Computer Science in PDF only on Docsity!

Improving Performance byUsing Memory Better

Jonathan Turpie

Improving Memory Hierarchy Performancefor Irregular Applications Using Data and

Computation Reorderings

John Mellor-Crummey, DavidWhalley, Ken Kennedy

Problem

 The memory hierarchy makes things thatseem slower faster

 Need to keep things in cache instead ofevicting them

  Data ReorderingComputation Reordering

First Touch Reordering

5 3 1 9 0 8 2 4 7 6 D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7 D 8 D (^9)

First Touch Reordering

 Traversing the entire data set requirestwo memory accesses

 The first access is probably cached, butnot the second

 Reordering the data may result in betteroverall performance

First Touch Reordering

5 3 1 9 0 8 2 4 7 6 D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7 D 8 D (^9)

First Touch Reordering

5 3 1 9 0 8 2 4 7 6 D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7 D 8 D (^9)

5 D 5

First Touch Reordering

D 5 3 1 9 0 8 2 4 7 6 D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7 D 8 D (^9)

5 D 5

Space Filling Curve Reordering

  Use a space filling curve (fractal pattern)Data points that are near each other in

physical space will probably be close inmemory

Space Filling Curve Reordering

 Independent of the data access pattern  As long as it uses data points that are

 Additional computation is necessary tophysically close together

translate discrete physical coordinatesinto a memory address

 Sometimes data is not close in memory

Computational Reordering

 If possible, change the order that data isaccessed to match memory

 Jump through loop iterations instead ofjumping through memory

 Only works if the data can be processedout of order

Space Filling Curve Reordering

 Process physical data points in a spacefilling curve order

 If point (xyj±1) are probably in cachei , y j ) was just processed, (xi±1,

 If another point near (xnext, it will probably need some of (xi , y j ) is processedi±1,

yj±1)

MemSpy: Analyzing MemorySystem Bottlenecks in Programs

Margaret Martonosi, Anoop Gupta,and Thomas Anderson

MemSpy

 MemSpy is a tool for looking at theperformance of data access patterns

 MemSpy provides statistics for codeblocks and for data blocks

 Provides information about what part ofmemory is performing badly

 Works on parallel programs

MemSpy

 Collection of statistics is done usinghardware features

  Use fairly fine resolutionStatistics are put into bins for the code

that executed during that time and forthe data that was used

 Each memory address is mapped to abin

MemSpy

 Memory bins are associated withvariables

  There can be a lot of variables to trackMemory gets allocated dynamically

 Many variables behave similarly^ ^ MemSpy^ only^ tracks heap allocated memory

 MemSpy groups all memory that wasallocated from the same part of the code

MemSpy

 The data is stored in a small piece ofmemory which is indexed by the lower k

 bits of the memory addressThere is a trade off between taking up

more cache blocks with this array andhaving collisions

MemSpy

MemSpy

MemSpy

  All the problems are cache missesAlmost all of the misses are being

 caused by Matrix YProbable cause is the blocks are too big

to fit into cache or Y is not contiguous