Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to...
Transcript of Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to...
![Page 1: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/1.jpg)
����������
�����������������������Computer Systems: A Programmer’s Perspective����������������
![Page 2: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/2.jpg)
���������������
�����������������
������
���������
���������
���������
���������������
...
������
���������
���������
���������
���������������
����������������������������������
�����������
�����������������������Computer Systems: A Programmer’s Perspective����������������
![Page 3: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/3.jpg)
����������������
���������
�����������������
��������������
�����������������
��������������
���������������������
��������������
������������������
�����������������
�������������������
�����������������������������������
���������������������������
��������������������������������������
����������������������
��������������������� ��������������������������
��������������������������������������������������� �����������������������Computer Systems: A Programmer’s Perspective����������������
![Page 4: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/4.jpg)
������������������
�����������������������Computer Systems: A Programmer’s Perspective����������������
![Page 5: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/5.jpg)
�������������������
�������������������������int�����������������
��� �������� �������
���� �������� ���������� ��������� ��������� ������� ������� ������� ������� �������� ����
�
![Page 6: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/6.jpg)
�������������������
�������������������������int�����������������
��� �������� �������
���� �������� ���������� ��������� ��������� ������� ������� ������� ������� �������� ����
������������������������
������������������������
����������������������
����������������������
�
![Page 7: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/7.jpg)
�������������������
�����������������������������int�����������������
��� �������� �������
���� �������� ���������� ���������� ���������� �������� �������� �������� �������� ��������� �����
������������������������
������������������������
����������������������
����������������������
�
![Page 8: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/8.jpg)
������������
��
��
�����������
0x765428 42
0x8005C0 79
�
![Page 9: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/9.jpg)
������������
0x765428?��
��
�����������
0x765428 42
0x8005C0 79
�
![Page 10: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/10.jpg)
������������
0x765428?��
��
�����������
0x765428 42
0x8005C0 79
��
![Page 11: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/11.jpg)
������������
0x765428?��
��
�����������
0x765428 42
0x8005C0 79
��
![Page 12: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/12.jpg)
������������
0x765428?��
��
�����������
0x765428 42
0x8005C0 79
��
![Page 13: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/13.jpg)
������������
0x765428?��
��
0x765428 42
�����������
0x765428 42
0x8005C0 79
��
![Page 14: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/14.jpg)
������������
0x765428?��
0x765428 42
��
0x765428 42
�����������
0x765428 42
0x8005C0 79
��
![Page 15: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/15.jpg)
������������
42��
0x765428 42
��
0x765428 42
�����������
0x765428 42
0x8005C0 79
��
![Page 16: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/16.jpg)
������������
0x765428?
temporal locality
��
0x765428 42
��
0x765428 42
�����������
0x765428 42
0x8005C0 79
��
![Page 17: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/17.jpg)
������������
0x765428?��
0x765428 42
��
0x765428 42
�����������
0x765428 42
0x8005C0 79
��
![Page 18: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/18.jpg)
������������
42��
0x765428 42
��
0x765428 42
�����������
0x765428 42
0x8005C0 79
��
![Page 19: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/19.jpg)
������������
0x8005C0?��
0x765428 42
��
0x765428 42
�����������
0x765428 42
0x8005C0 79
��
![Page 20: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/20.jpg)
������������
0x8005C0?��
0x765428 42
��
0x765428 42
�����������
0x765428 42
0x8005C0 79
��
![Page 21: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/21.jpg)
������������
0x8005C0?��
0x765428 42
��
0x765428 42
�����������
0x765428 42
0x8005C0 79
��
![Page 22: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/22.jpg)
������������
0x8005C0?��
0x765428 42
��
0x765428 42
�����������
0x765428 42
0x8005C0 79
��
![Page 23: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/23.jpg)
������������
0x8005C0?��
0x765428 42
��
0x765428 42
0x8005C0 79
�����������
0x765428 42
0x8005C0 79
��
![Page 24: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/24.jpg)
������������
0x8005C0?��
0x8005C0 79
��
0x765428 42
0x8005C0 79
�����������
0x765428 42
0x8005C0 79
��
![Page 25: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/25.jpg)
������������
79��
0x8005C0 79
��
0x765428 42
0x8005C0 79
�����������
0x765428 42
0x8005C0 79
��
![Page 26: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/26.jpg)
������������
0x765428?��
0x8005C0 79
��
0x765428 42
0x8005C0 79
�����������
0x765428 42
0x8005C0 79
��
![Page 27: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/27.jpg)
������������
0x765428?��
0x8005C0 79
��
0x765428 42
0x8005C0 79
�����������
0x765428 42
0x8005C0 79
��
![Page 28: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/28.jpg)
������������
0x765428?��
0x8005C0 79
��
0x765428 42
0x8005C0 79
�����������
0x765428 42
0x8005C0 79
��
![Page 29: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/29.jpg)
������������
0x765428?��
0x765428 42
��
0x765428 42
0x8005C0 79
�����������
0x765428 42
0x8005C0 79
��
![Page 30: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/30.jpg)
������������
42��
0x765428 42
��
0x765428 42
0x8005C0 79
�����������
0x765428 42
0x8005C0 79
��
![Page 31: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/31.jpg)
������������
��
��
�����������
0x765420 42 5
0x8005C0 79
��
![Page 32: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/32.jpg)
������������
0x765428?��
��
�����������
0x765420 42 5
0x8005C0 79
��
![Page 33: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/33.jpg)
������������
0x765428?��
��
�����������
0x765420 42 5
0x8005C0 79
��
![Page 34: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/34.jpg)
������������
0x765428?��
��
�����������
0x765420 42 5
0x8005C0 79
��
![Page 35: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/35.jpg)
������������
0x765428?��
��
�����������
0x765420 42 5
0x8005C0 79
��
![Page 36: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/36.jpg)
������������
0x765428?��
��
0x765420 42 5
�����������
0x765420 42 5
0x8005C0 79
��
![Page 37: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/37.jpg)
������������
0x765428?��
0x765420 42 5
��
0x765420 42 5
�����������
0x765420 42 5
0x8005C0 79
��
![Page 38: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/38.jpg)
������������
42��
0x765420 42 5
��
0x765420 42 5
�����������
0x765420 42 5
0x8005C0 79
��
![Page 39: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/39.jpg)
������������
0x765430?
spatial locality
��
0x765420 42 5
��
0x765420 42 5
�����������
0x765420 42 5
0x8005C0 79
��
![Page 40: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/40.jpg)
������������
0x765430?��
0x765420 42 5
��
0x765420 42 5
�����������
0x765420 42 5
0x8005C0 79
��
![Page 41: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/41.jpg)
������������
5��
0x765420 42 5
��
0x765420 42 5
�����������
0x765420 42 5
0x8005C0 79
��
![Page 42: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/42.jpg)
�������������������
�����������������������������int�����������������
��� �������� �������
���� �������� ���������� ���������� ���������� �������� �������� �������� �������� ��������� �����
����������������������������������
����������������������������������
��������������������������������
����������������������
���������int�
��
![Page 43: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/43.jpg)
��������
Temporal locality
A previously used address is likely to be used again soon
Cache hierarchy������������������������������������������������������
Spatial locality
Newly used addresses are likely to be near recently usedaddresses
Blocking�����������������������������������������������������
�����
![Page 44: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/44.jpg)
������������������
long data[MAXELEMS]; int test(int elems, int stride) { long i, sx2 = stride*2, sx3 = stride*3, sx4 = stride*4; long acc0 = 0, acc1 = 0, acc2 = 0, acc3 = 0; long length = elems; long limit = length - sx4; for (i = 0; i < limit; i += sx4) { acc0 = acc0 + data[i]; acc1 = acc1 + data[i+stride]; acc2 = acc2 + data[i+sx2]; acc3 = acc3 + data[i+sx3]; } for (; i < length; i++) { acc0 = acc0 + data[i]; } return ((acc0 + acc1) + (acc2 + acc3));}
�����������������������Computer Systems: A Programmer’s Perspective�����������������
![Page 45: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/45.jpg)
�������������������
�����������������������Computer Systems: A Programmer’s Perspective�����������������
![Page 46: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/46.jpg)
���������������������
���
���
��� ��� ��� ���
���
��������0x765428
�����������������������Computer Systems: A Programmer’s Perspective�����������������
![Page 47: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/47.jpg)
���������������������
���
���
��� ��� ��� ���
���
�����������������
��������
�� �
��������������
�������������
������
�����������������������Computer Systems: A Programmer’s Perspective�����������������
![Page 48: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/48.jpg)
���������������������
���
���
��� ��� ��� ���
���
�����������������
��������
����������
��������������
�������������
������
�����������������������Computer Systems: A Programmer’s Perspective�����������������
![Page 49: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/49.jpg)
���������������������
���
���
��� ��� ��� ���
���
�����������������
��������
����������
��������������
�������������
������
���cache line
�����������������������Computer Systems: A Programmer’s Perspective�����������������
![Page 50: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/50.jpg)
���������������������
���������������������
�����
� ����� �
���
���
��� ��� ��� ���
���
�����������������
��������
��� �
������
��� �
������
�������������
������
�����������������������Computer Systems: A Programmer’s Perspective�����������������
![Page 51: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/51.jpg)
���������������������
���������������������
�����
� ����� �
���
���
��� ��� ��� ���
���
�����������������
��������
��� �
������
��� �
������
�������������
������
�����������������������Computer Systems: A Programmer’s Perspective�����������������
![Page 52: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/52.jpg)
���������������������
���������������������
�����
� ����� �
���
���
��� ��� ��� ���
���
�����������������
��������
��� �
������
��� �
������
�������������
������
�-way associative cache �������direct-mapped cache
�������������������������������������������Computer Systems: A Programmer’s Perspective�����������������
![Page 53: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/53.jpg)
���������������������
���������������������
�����
� ����� �
���
���
��� ��� ��� ���
���
�����������������
��������
��� �
������
��� �
������
�������������
������
�
�
���������
��� ... ��������
�����������������������Computer Systems: A Programmer’s Perspective�����������������
![Page 54: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/54.jpg)
���������������������
���������������������
�����
� ����� �
���
���
��� ��� ��� ���
���
�����������������
��������
��� �
������
��� �
������
�������������
������
�
�
���������
��� ... ��������
�����������������������Computer Systems: A Programmer’s Perspective�����������������
![Page 55: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/55.jpg)
���������������������
�������������������������������
1 1 0 0 1 1
1 0 1 0 1 0
0
1 1 0 1 1 0
��������0 1 0 1 0 0 1 1 0 0
��
![Page 56: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/56.jpg)
���������������������
�������������������������������
1 1 0 0 1 1
1 0 1 0 1 0
0
1 1 0 1 1 0
��������0 1 0 1 0 0 1 1 0 0
��
![Page 57: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/57.jpg)
���������������������
�������������������������������
1 1 0 0 1 1
1 0 1 0 1 0
0
1 1 0 1 1 0
��������0 1 0 1 0 0 1 1 0 0
��
![Page 58: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/58.jpg)
���������������������
�������������������������������
�����
1 1 0 0 1 1
1 0 1 0 1 0
0
1 1 0 1 1 0
��������0 1 0 1 0 0 1 1 0 0
�������
��
![Page 59: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/59.jpg)
���������������������
�������������������������������
�����
1 1 0 0 1 1
1 0 1 0 1 0
0
1 1 0 1 1 0
��������0 1 0 1 0 0 1 1 0 0
�������
int�����������
��
![Page 60: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/60.jpg)
���������������������
�������������������������������
1 1 0 0 1 1
1 1 1 1 1 1
0
1 1 0 1 1 0
��������0 1 0 1 0 0 1 1 0 0
��
![Page 61: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/61.jpg)
���������������������
�������������������������������
1 1 0 0 1 1
1 1 1 1 1 1
0
1 1 0 1 1 0
��������0 1 0 1 0 0 1 1 0 0
��
![Page 62: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/62.jpg)
���������������������
�������������������������������
�����
1 1 0 0 1 1
1 1 1 1 1 1
0
1 1 0 1 1 0
��������0 1 0 1 0 0 1 1 0 0
�������������
��
![Page 63: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/63.jpg)
���������������������
�������������������������������
�������
1 1 0 0 1 1
0 0 1 0 1 0
0
1 1 0 1 1 0
��������0 1 0 1 0 0 1 1 0 0
��
![Page 64: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/64.jpg)
���������������������
�����������������������
1 1 0 0 1 1 0
1 0 1 0 1 0 1 1 1 0 1 1
0 1 1 1 0 0 0
1 1 0 1 1 0 1 1 0 0 1 0
��������0 1 0 1 0 0 1 1 0 0
��
![Page 65: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/65.jpg)
���������������������
�����������������������
1 1 0 0 1 1 0
1 0 1 0 1 0 1 1 1 0 1 1
0 1 1 1 0 0 0
1 1 0 1 1 0 1 1 0 0 1 0
��������0 1 0 1 0 0 1 1 0 0
��
![Page 66: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/66.jpg)
���������������������
�����������������������
1 1 0 0 1 1 0
1 0 1 0 1 0 1 1 1 0 1 1
0 1 1 1 0 0 0
1 1 0 1 1 0 1 1 0 0 1 0
��������0 1 0 1 0 0 1 1 0 0
��
![Page 67: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/67.jpg)
���������������������
�����������������������
1 1 0 0 1 1 0
1 0 1 0 1 0 1 1 1 0 1 1
0 1 1 1 0 0 0
1 1 0 1 1 0 1 1 0 0 1 0
��������0 1 0 1 0 0 1 1 0 0
��
![Page 68: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/68.jpg)
����������������������
�����������miss�������������������������������������
� ���������������������������������
� �����������������������������������
�����������������������Computer Systems: A Programmer’s Perspective��������������������
![Page 69: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/69.jpg)
������
�����������������������������������������������������������������
What to do on a write-hit?Write-through������������������������������Write-back���������������������������������������
What to do on a write-miss?Write-allocate�����������������������������������No-write-allocate���������������������������
������������������������� ���������������������������������� ��������������������������� ← good assumption
�����������������������Computer Systems: A Programmer’s Perspective��������������������
![Page 70: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/70.jpg)
��������������������������
�������������������� ������������������������ ������������ �������������������� ���������������������������
struct { int x; int y;} grid[16][16];
sizeof(grid[0][0])���2*sizeof(int)������grid����������������������������
sizeof(grid)���16*16*2*sizeof(int)���������������grid���������������������������
�����
![Page 71: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/71.jpg)
��������������������������
���grid�������������������������
�����������������
��
![Page 72: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/72.jpg)
��������������������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_x += grid[i][j].x;
��
![Page 73: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/73.jpg)
��������������������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_x += grid[i][j].x;
i���� j���� ����
��
![Page 74: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/74.jpg)
��������������������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_x += grid[i][j].x;
i���� j���� ����
��
![Page 75: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/75.jpg)
��������������������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_x += grid[i][j].x;
i���� j���� ����i���� j���� ���
��
![Page 76: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/76.jpg)
��������������������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_x += grid[i][j].x;
i���� j���� ����i���� j���� ���i���� j���� ���
��
![Page 77: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/77.jpg)
��������������������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_x += grid[i][j].x;
i���� j���� ����i���� j���� ���i���� j���� ���i���� j���� ���
��
![Page 78: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/78.jpg)
��������������������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_x += grid[i][j].x;
i���� j���� ����i���� j���� ���i���� j���� ���i���� j���� ���i���� j���� ����
��
![Page 79: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/79.jpg)
��������������������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_x += grid[i][j].x;
���i���� j����� ���
��
![Page 80: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/80.jpg)
��������������������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_x += grid[i][j].x;
���i���� j����� ���i���� j���� ����
��
![Page 81: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/81.jpg)
��������������������������
� � � �
� � � �
� � �� ��
�� �� �� ��
�� �� �� ��
�� �� �� ��
�� �� �� ��
�� �� �� ��
� � � �
� � � �
� � �� ��
�� �� �� ��
�� �� �� ��
�� �� �� ��
�� �� �� ��
�� �� �� ��
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_x += grid[i][j].x;
���i���� j����� ���i���� j���� ����
��
![Page 82: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/82.jpg)
��������������������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_x += grid[i][j].x;
���i���� j����� ���i���� j���� ����
��
![Page 83: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/83.jpg)
��������������������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_x += grid[i][j].x;
Miss rate:����
��
![Page 84: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/84.jpg)
�������������������
���grid�������������������������
�����������������
for (j = 0; j < 16; j++) for (i = 0; i < 16; i++) total_x += grid[i][j].x;
�����j���������
��
![Page 85: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/85.jpg)
�������������������
���grid�������������������������
�����������������
for (j = 0; j < 16; j++) for (i = 0; i < 16; i++) total_x += grid[i][j].x;
i���� j���� ����
��
![Page 86: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/86.jpg)
�������������������
���grid�������������������������
�����������������
for (j = 0; j < 16; j++) for (i = 0; i < 16; i++) total_x += grid[i][j].x;
i���� j���� ����i���� j���� ����
��
![Page 87: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/87.jpg)
�������������������
���grid�������������������������
�����������������
for (j = 0; j < 16; j++) for (i = 0; i < 16; i++) total_x += grid[i][j].x;
i���� j���� ����i���� j���� ����i���� j���� ����
��
![Page 88: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/88.jpg)
�������������������
���grid�������������������������
�����������������
for (j = 0; j < 16; j++) for (i = 0; i < 16; i++) total_x += grid[i][j].x;
���i���� j���� ����
��
![Page 89: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/89.jpg)
�������������������
���grid�������������������������
�����������������
for (j = 0; j < 16; j++) for (i = 0; i < 16; i++) total_x += grid[i][j].x;
���i���� j���� ����i���� j���� ����
��
![Page 90: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/90.jpg)
�������������������
���grid�������������������������
�����������������
for (j = 0; j < 16; j++) for (i = 0; i < 16; i++) total_x += grid[i][j].x;
Miss rate:�����
��
![Page 91: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/91.jpg)
�������������������
���grid�������������������������
�����������������
for (j = 0; j < 16; j++) for (i = 0; i < 16; i++) total_x += grid[i][j].x;
����������������⇒column as inner loop
��
![Page 92: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/92.jpg)
�����������������������
���grid�������������������������
����������64
������������
�����
for (j = 0; j < 16; j++) for (i = 0; i < 16; i++) total_x += grid[i][j].x;
���i���� j���� ����i���� j���� ����
���
![Page 93: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/93.jpg)
�����������������������
���grid�������������������������
����������64�����
for (j = 0; j < 16; j++) for (i = 0; i < 16; i++) total_x += grid[i][j].x;
���i����� j���� ����
���
![Page 94: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/94.jpg)
�����������������������
���grid�������������������������
����������64�����
for (j = 0; j < 16; j++) for (i = 0; i < 16; i++) total_x += grid[i][j].x;
���i����� j���� ����i���� j���� ���
���
![Page 95: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/95.jpg)
�����������������������
���grid�������������������������
����������64�����
for (j = 0; j < 16; j++) for (i = 0; i < 16; i++) total_x += grid[i][j].x;
������������������⇒��������������������
���
![Page 96: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/96.jpg)
�����������������������
� � � �
� � � �
� � �� ��
�� �� �� ��
�� �� �� ��
�� �� �� ��
�� �� �� ��
�� �� �� ��
� � � �
� � � �
� � �� ��
�� �� �� ��
�� �� �� ��
�� �� �� ��
�� �� �� ��
�� �� �� ��
���grid�������������������������
����������������2
for (j = 0; j < 16; j++) for (i = 0; i < 16; i++) total_x += grid[i][j].x;
�������������������������������������������������
���
![Page 97: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/97.jpg)
��������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_x += grid[i][j].x; for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_y += grid[i][j].y;
���
![Page 98: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/98.jpg)
��������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_x += grid[i][j].x; for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) total_y += grid[i][j].y;
Miss rate:����
���
![Page 99: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/99.jpg)
��������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) { total_x += grid[i][j].x; total_y += grid[i][j].y; }
���
![Page 100: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/100.jpg)
��������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) { total_x += grid[i][j].x; total_y += grid[i][j].y; }
i���� j���� ����
���
![Page 101: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/101.jpg)
��������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) { total_x += grid[i][j].x; total_y += grid[i][j].y; }
i���� j���� ����i���� j���� ���
���
![Page 102: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/102.jpg)
��������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) { total_x += grid[i][j].x; total_y += grid[i][j].y; }
i���� j���� ����i���� j���� ���i���� j���� ���
���
![Page 103: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/103.jpg)
��������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) { total_x += grid[i][j].x; total_y += grid[i][j].y; }
i���� j���� ����i���� j���� ���i���� j���� ���i���� j���� ���
���
![Page 104: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/104.jpg)
��������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) { total_x += grid[i][j].x; total_y += grid[i][j].y; }
Miss rate:������
���
![Page 105: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/105.jpg)
��������������
���grid�������������������������
�����������������
for (i = 0; i < 16; i++) for (j = 0; j < 16; j++) { total_x += grid[i][j].x; total_y += grid[i][j].y; }
���������������⇒fuse to improve locality
���
![Page 106: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/106.jpg)
�����������������������
����������������⇒�column as inner loop
������������������⇒���������������������
���������������⇒�fuse to improve locality
���������������������������������
��������������������1
������������������
�������
![Page 107: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/107.jpg)
���������������������
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];
i
k
A
� k
j
B
� i
j
C
�����������������������Computer Systems: A Programmer’s Perspective������������������
![Page 108: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/108.jpg)
���������������������
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];
i
k
A
� k
j
B
� i
j
C
�����������
�����������������������Computer Systems: A Programmer’s Perspective������������������
![Page 109: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/109.jpg)
���������������������
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];
i
k
A
� k
j
B
� i
j
C
������������
�����������������������Computer Systems: A Programmer’s Perspective������������������
![Page 110: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/110.jpg)
���������������������
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];
i
k
A
� k
j
B
� i
j
C
������������������ ����������������� ��������������������������
�����������������������Computer Systems: A Programmer’s Perspective������������������
![Page 111: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/111.jpg)
���������������������
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];
i
k
A[i][★]
k
j
B[★][j]
i
j
C[i][j]
������������������������������������������
�����������������������Computer Systems: A Programmer’s Perspective������������������
![Page 112: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/112.jpg)
���������������������
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];
i
k
A[i][★]
k
j
B[★][j]
i
j
C[i][j]
���������� 0.25 � 1.0 � 0.0 ��1.25
�����������������������Computer Systems: A Programmer’s Perspective������������������
![Page 113: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/113.jpg)
�����������������������ijk
for (i = 0; i < n; i++) for (j = 0; j < n; j++) { sum = 0.0; for (k = 0; k < n; k++) sum += A[i][k] * B[k][j]; C[i][j] += sum; }
i
k
A[i][★]
k
j
B[★][j]
i
j
C[i][j]
���������� 0.25 � 1.0 � 0.0 ��1.25
�����������������������Computer Systems: A Programmer’s Perspective������������������
![Page 114: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/114.jpg)
�����������������������jik
for (j = 0; j < n; j++) for (i = 0; i < n; i++) { sum = 0.0; for (k = 0; k < n; k++) sum += A[i][k] * B[k][j]; C[i][j] += sum; }
���������������������
i
k
A[i][★]
k
j
B[★][j]
i
j
C[i][j]
���������� 0.25 � 1.0 � 0.0 ��1.25
�����������������������Computer Systems: A Programmer’s Perspective������������������
![Page 115: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/115.jpg)
�����������������������kij
for (k = 0; k < n; k++) for (i = 0; i < n; i++) { a = A[i][k]; for (j = 0; j < n; j++) C[i][j] += a * B[k][j]; }
i
k
A[i][k]
k
j
B[k][★]
i
j
C[i][★]
���������� 0.0 � 0.25 � 0.25 ��0.5
�����������������������Computer Systems: A Programmer’s Perspective������������������
![Page 116: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/116.jpg)
�����������������������ikj
for (i = 0; i < n; i++) for (k = 0; k < n; k++) { a = A[i][k]; for (j = 0; j < n; j++) C[i][j] += a * B[k][j]; }
���������������������
i
k
A[i][k]
k
j
B[k][★]
i
j
C[i][★]
���������� 0.0 � 0.25 � 0.25 ��0.5
�����������������������Computer Systems: A Programmer’s Perspective������������������
![Page 117: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/117.jpg)
�����������������������jki
for (j = 0; j < n; j++) for (k = 0; k < n; k++) { b = B[k][j]; for (i = 0; i < n; i++) C[i][j] += A[i][k] * b; }
i
k
A[★][k]
k
j
B[k][j]
i
j
C[★][j]
���������� 1.0 � 0.0 � 1.0 ��2.0
�����������������������Computer Systems: A Programmer’s Perspective������������������
![Page 118: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/118.jpg)
�����������������������kji
for (k = 0; k < n; k++) for (j = 0; j < n; j++) { b = B[k][j]; for (i = 0; i < n; i++) C[i][j] += A[i][k] * b; }
���������������������
i
k
A[★][k]
k
j
B[k][j]
i
j
C[★][j]
���������� 1.0 � 0.0 � 1.0 ��2.0
�����������������������Computer Systems: A Programmer’s Perspective������������������
![Page 119: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/119.jpg)
���������������������������
���
![Page 120: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/120.jpg)
���������������������
for (k = 0; k < n; k++) for (i = 0; i < n; i++) { a = A[i][k]; for (j = 0; j < n; j++) C[i][j] += a * B[k][j]; }
i
k
A[i][k]
k
j
B[k][★]
i
j
C[i][★]
���
![Page 121: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/121.jpg)
���������������������
for (k = 0; k < n; k++) for (i = 0; i < n; i++) { a = A[i][k]; for (j = 0; j < n; j++) C[i][j] += a * B[k][j]; }
i
k
A[i][k]
k
j
B[k][★]
i
j
C[i][★]
���������������������������B�����������������
���
![Page 122: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/122.jpg)
���������������������
for (k = 0; k < n; k++) for (i = 0; i < n; i++) { a = A[i][k]; for (j = 0; j < n; j++) C[i][j] += a * B[k][j]; }
i
k
A[i][k]
k
j
B[k][★]
i
j
C[i][★]
���������������������������������� ����� ����C��������������������������B
���
![Page 123: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/123.jpg)
������������������������������
for (i = 0; i < n; i += W) for (j = 0; j < n; j += W) for (k = 0; k < n; k += W) for (ii = i; ii < i+W; ii++) for (jj = j; jj < j+W; jj++) for (kk = k; kk < k+W; kk++) C[ii][jj] += A[ii][kk] * B[kk][jj];
���W�W������ i
k
A
k
j
B
i
j
C
�����������������������Computer Systems: A Programmer’s Perspective������������������
![Page 124: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/124.jpg)
������������������������������
for (i = 0; i < n; i += W) for (j = 0; j < n; j += W) for (k = 0; k < n; k += W) for (ii = i; ii < i+W; ii++) for (jj = j; jj < j+W; jj++) for (kk = k; kk < k+W; kk++) C[ii][jj] += A[ii][kk] * B[kk][jj];
���W�W������ i
k
A
k
j
B
i
j
C
������������������������⇒�0.25����������
�����������������������Computer Systems: A Programmer’s Perspective������������������
![Page 125: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/125.jpg)
������������������������������
for (i = 0; i < n; i += W) for (j = 0; j < n; j += W) for (k = 0; k < n; k += W) for (ii = i; ii < i+W; ii++) for (jj = j; jj < j+W; jj++) for (kk = k; kk < k+W; kk++) C[ii][jj] += A[ii][kk] * B[kk][jj];
���W�W������ i
k
A
k
j
B
i
j
C
�����������������������������0.25����������
�������������� ������������������
�����������������������Computer Systems: A Programmer’s Perspective����������������������
![Page 126: Temporal locality A previously used address is likely to be used again soon Cache hierarchy What to do on a write-hit? Write-through Write-back](https://reader031.fdocuments.in/reader031/viewer/2022041700/5e414f394cdc661eeb58c0c7/html5/thumbnails/126.jpg)
������������������������������
for (i = 0; i < n; i += W) for (j = 0; j < n; j += W) for (k = 0; k < n; k += W) for (ii = i; ii < i+W; ii++) for (jj = j; jj < j+W; jj++) for (kk = k; kk < k+W; kk++) C[ii][jj] += A[ii][kk] * B[kk][jj];
���W�W������ i
k
A
k
j
B
i
j
C
0.25���� �������� �
������ �
�
��
⇒� �������������
�����������������������Computer Systems: A Programmer’s Perspective����������������������