Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

Exam (elaborations) ENGR 325 ENGR 325 HOMEWORK #7 KEY FALL 2015

Beoordeling
-
Verkocht
-
Pagina's
8
Cijfer
A+
Geüpload op
27-04-2022
Geschreven in
2021/2022

Exam (elaborations) ENGR 325 ENGR 325 HOMEWORK #7 KEY FALL 2015

Instelling
Vak

Voorbeeld van de inhoud

ENGR 325 ENGR 325 HOMEWORK #7 KEY FALL P2015
age|1




ENGR 325

HOMEWORK #7 KEY

FALL 2015



1. (5) In this exercise we look at memory locality properties of matrix computation. The following code
is written in C, where elements within the same row are stored contiguously. Assume each word is
a 32-bit integer. (P&H 5.1, §5.1)
for (I=0; I<8; I++)
for (J=0; J<8000; J++) A[I]
[J]=B[I][0]+A[J][I];
a. How many 32-bit integers can be stored in a 16-byte cache block?
b. References to which variables exhibit temporal locality?
c. References to which variables exhibit spatial locality?
Locality is affected by both the reference order and data layout. The same computation can also be
written below in Matlab, which differs from C by storing matrix elements within the same column
contiguously in memory.
for I=1:8
for J=1:8000
A(I,J)=B(I,0)+A(J,I);
en
d end
d. How many 16-byte cache blocks are needed to store all 32-bit matrix elements being
referenced?
e. References to which variables exhibit temporal locality?
f. References to which variables exhibit spatial locality?
SOLUTION:
a. Each 32-bit integer requires 4 bytes to store, therefore FOUR 32-bit integers can be stored in
the 16-byte block.
b. Consider the access sequence:
A[0][0] = B[0][0] + A[0][0]
A[1][0] = B[0][0] + A[0][1]
A[2][0] = B[0][0] + A[0][2]

A[7999] = B[0][0] + A[0]
[0] [7999]
A[0][1] = B[1][0] + A[1][0]

⇒ Variables I, J, and B[I][0] exhibit temporal locality.

, Page|2


c. Variables A[I][J] and B[I][0] exhibit spatial locality.
d. Consider the access sequence:
A(1,1) = B(1,0 + A(1,1)
)
A(1,2) = B(1,0 + A(2,1)
)
A(1,3) = B(1,0 + A(3,1)
)

A(1,8000) = B(1,0 + A(8000,1
) )
A(2,1) = B(2,0 + A(1,2)
)
A(2,2) = B(2,0 + A(2,2)
)

A(2,8000) = B(2,0 + B(8000,2
) )

A(8,1) = B(8,0 + A(1,8)
)
A(8,2) = B(8,0 + A(2,8)
)

A(8,8000) = B(8,0 + A(8000,8
) )


Matrix A begins as an 8-row by 8000-column matrix and is transformed into an 8000-row by
8- column matrix. So for the A matrices:
Elements = 8 x 8000 = 64,000
Total elements in the beginning and ending matrix: 64000 x 2 =
128,000 Matrix elements per cache block: 4, as per 5.1.1.
Total cache blocks: 128,000 ÷ 4 = 32,000
Note, however, that the “upper left” eight by eight elements overlap, so cache is not
needed for those. Therefore we can subtract 8 x 8 ÷ 4 = 16 cache blocks.
For the B matrix:
Elements = 8 x 1 = 8
Matrix Elements per cache block: 4, as
above Total cache blocks: 8 ÷ 4 = 2
Total 16-byte cache blocks = 32000 – 16 + 2 ⇒ 31,986 cache blocks are required.
e. As in 5.1.2, variables I, J, and B(I,0) exhibit temporal locality.
f. Unlike in C, in MATLAB matrix elements in the same column are stored contiguously. Therefore
the variables A(J,I) and B(I,0) exhibit spatial locality.
2. (10) Caches are important to providing a high-performance memory hierarchy to processors. Below
is a list of 32-bit memory address references, given as word addresses:

Geschreven voor

Vak

Documentinformatie

Geüpload op
27 april 2022
Aantal pagina's
8
Geschreven in
2021/2022
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

€8,86
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
EvaTee Phoenix University
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
5226
Lid sinds
4 jaar
Aantal volgers
3570
Documenten
56016
Laatst verkocht
21 uur geleden
TIGHT DEADLINE? I CAN HELP

Many students don\'t have the time to work on their academic papers due to balancing with other responsibilities, for example, part-time work. I can relate. kindly don\'t hesitate to contact me, my study guides, notes and exams or test banks, are 100% graded

3,8

952 beoordelingen

5
453
4
167
3
174
2
48
1
110

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen