Docsity

Improving Memory performance For Irregular Application - Slides | CMSC 714, Study notes of Computer Science

Toggle sidebar
bg1
1
Improving Memory Hierarchy
Performance for Irregular
Applications Using Data and
Computation Reorderings
By: John Mellor-Crummey, David Whalley, Ken Kennedy
Presented By: Saeed Alaei
Outline
๎š„Memory hierarchies and performance.
๎š„Data and computation reordering in general.
๎š„Regular vs. Irregular applications.
๎š„Space filling curves:
๎š…Hilbert curve
๎š…Morton curve
๎š„Data and computation reordering approaches.
๎š„Experimental results
Memory performance
๎š„Gap between CPU speed and memory speed
has increased rapidly.
๎š„Multi-level memory hierarchies are used to
address this memory access bottleneck.
๎š„Irregular applications underutilize the memory
hierarchies.
๎š„Data and computation reordering can greatly
help.
Data reordering
for(i=0;i<n;i++)
for(j=0;j<n;j++)
for(k=0;k<n;k++)
C[i][j]+=A[i][k]*B[k][j];
for(i=0;i<n;i++)
for(j=0;j<n;j++)
for(k=0;k<n;k++)
C[i][j]+=A[i][k]*BT[j][k];
Computation reordering
for(i=0;i<n;i++)
for(j=0;j<n;j++)
for(k=0;k<n;k++)
C[i][j]+=A[i][k]*B[k][j];
for(i=0;i<n;i++)
for(k=0;k<n;k++)
for(j=0;j<n;j++)
C[i][j]+=A[i][k]*B[k][j];
Regular vs. Irregular Applications
๎š„Regular applications:
๎š…Static analysis and fixed access pattern.
๎š…Techniques:
๎š„Loop blocking.
๎š„Data prefetching.
๎š…Instances:
๎š„Matrix multiplication/inversion.
๎š„Irregular applications:
๎š…Dynamic analysis, access pattern unknown until runtime.
๎š…Proposed techniques:
๎š„Dynamic data reordering before major computation phase.
๎š„Computations reordering by blocking.
pf3
pf4
pf5

Partial preview of the text

Download Improving Memory performance For Irregular Application - Slides | CMSC 714 and more Study notes Computer Science in PDF only on Docsity!

Improving Memory Hierarchy

Performance for Irregular

Applications Using Data and

Computation Reorderings

By: John Mellor-Crummey, David Whalley, Ken Kennedy

Presented By: Saeed Alaei

Outline

ย„ Memory hierarchies and performance. ย„ Data and computation reordering in general. ย„ Regular vs. Irregular applications. ย„ Space filling curves:

Hilbert curve

Morton curve ย„ Data and computation reordering approaches. ย„ Experimental results

Memory performance

ย„ Gap between CPU speed and memory speed has increased rapidly. ย„ Multi-level memory hierarchies are used to address this memory access bottleneck. ย„ Irregular applications underutilize the memory hierarchies.

ย„ Data and computation reordering can greatly help.

Data reordering

for(i=0;i<n;i++) for(j=0;j<n;j++) for(k=0;k<n;k++) C[i][j]+=A[i][k]*B[k][j];

for(i=0;i<n;i++) for(j=0;j<n;j++) for(k=0;k<n;k++) C[i][j]+=A[i][k]*BT[j][k];

Computation reordering

for(i=0;i<n;i++) for(j=0;j<n;j++) for(k=0;k<n;k++) C[i][j]+=A[i][k]*B[k][j];

for(i=0;i<n;i++) for(k=0;k<n;k++) for(j=0;j<n;j++) C[i][j]+=A[i][k]*B[k][j];

Regular vs. Irregular Applications

ย„ Regular applications:

Static analysis and fixed access pattern.

Techniques: ย„ Loop blocking. ย„ Data prefetching.

Instances: ย„ Matrix multiplication/inversion. ย„ Irregular applications:

Dynamic analysis, access pattern unknown until runtime.

Proposed techniques: ย„ Dynamic data reordering before major computation phase. ย„ Computations reordering by blocking.

Irregular applications

ย„ Poor spatial and temporal locality.

ย„ Bandwidth and latency problems:

Cache miss.

TLB miss.

ย„ Instances:

N-Body simulation.

N-Body

Space Filling Curve

ย„ A space-filling curve for some finite space of d dimensions ( d โ‰ฅ 2) is a continuous, non-smooth curve that passes arbitrarily close to every point. ย„ Each point in a d -dimensional space can be mapped to the nearest position along a 1- dimensional spacefilling curve by applying a sequence of bit-level logical operations to its d - dimensional coordinates

Hilbert Curves

Morton Curves

X=

Y=

M=

Reordering

ย„ Data Reordering

ย„ Computation Reordering

Space Filling Curve Computation Reordering

ย„ Changes the order of elements in the interaction list. ย„ The order of particle information remains unchanged. ย„ Improves temporal locality.

Computation Reordering by Blocking

Computation Reordering by Blocking (contโ€™d)

0 1 2 3 4 5 P

PP PP P (^) P

Px P P

P

Pz

P

Py P

P P 0

1

2

3

ย„ Blocking can also be done base on different approaches (e.g. by taking the address).

Computation Reordering by Blocking (contโ€™d)

ย„ Blocking can be extended to multiple levels. ย„ A blocking factor depends on architectural characteristics:

Size of cache lines or page size for TLB.

The number of sets in the cache.

Associativity.

Replacement policy.

โ€ฆ

Computation Reordering by Blocking (contโ€™d)

ย„ The recursive divide and conquer approach can be used to achieve a machine independent blocking.

Computation Reordering by Blocking (contโ€™d)

ย„ For each pair [Pi, Pj] in the interaction list,

we compute the interleaving of

[block_of(Pi) , block_of(Pj)].

ย„ This is equivalent to using a Morton curve.

ย„ A Hilbert curve can also be used.

ย„ Both Hilbert and Morton curve give a

recursive blocking.

Applying The Techniques

ย„ Particle codes:

Moldyn (a synthetic benchmark).

Magi

CHAD

Moldyn

ย„ A synthetic benchmark for molecular dynamics simulation. ย„ Closely resembles the N-Body example. ย„ The time consuming part is the computeForces function called on list of interactions. ย„ The experiment:

Performed SGI O2 based on R10000 MIPS.

256,000 particles, over 27 million interactions.

Moldyn โ€“ base line program

Block Number

Interaction Number

Moldyn โ€“ Hilbert Curve

Block Number

Interaction Number

Moldyn โ€“ Multi-level โ€“ first 10K

Block Number

Interaction Number

Moldyn โ€“ Multi-level โ€“ first 100K

Block Number

Interaction Number