Problem Bank 47: Assignment I
Problem Bank 47: Assignment I
Problem Bank 47
Assignment Description:
The assignment aims to provide deeper understanding of cache by analysing its behaviour
using cache implementation of CPU- OS Simulator. The assignment has three parts.
● Part I deals with Cache Memory Management with Direct Mapping
● Part II deals with Cache Memory Management with Associative Mapping
● Part III deals with Cache Memory Management with Set Associative Mapping
Submission: You will have to submit this documentation file and the name of the file should
be GROUP-NUMBER.pdf. For Example, if your group number is 1, then the file name
should be GROUP-1.pdf.
Submit the assignment by 22nd December 2021, through canvas only. File submitted by any
means outside CANVAS will not be accepted and marked.
In case of any issues, please drop an email to the course TAs, Ms. Michelle Gonsalves
(michelle.gonsalves@wilp.bits-pilani.ac.in).
Caution!!!
Assignments are designed for individual groups which may look similar, and you may not
notice minor changes in the assignments. Hence, refrain from copying or sharing documents
with others. Any evidence of such practice will attract severe penalty.
Evaluation:
● The assignment carries 13 marks
● Grading will depend on
o Contribution of each student in the implementation of the assignment
o Plagiarism or copying will result in -13 marks
************************FILL IN THE DETAILS GIVEN BELOW**************
Assignment Set Number:
Contribution Table:
Contribution (This table should contain the list of all the students in the group. Clearly
mention each student’s contribution towards the assignment. Mention “No Contribution” in
cases applicable.)
b) Plot a single graph of Cache hit ratio Vs Block size with respect to cache size = 8, 16
and 32. Comment on the graph that is obtained. -
Chart Title
90.00%
80.00%
70.00%
60.00%
50.00%
40.00%
30.00%
20.00%
10.00%
0.00%
1 2 3
%Hit Ratio Cache size 8 %Hit Ratio Cache size 16 %Hit Ratio Cache size 32
By increasing the cache size, the hit ratio improved, hence the performance of the program
improved. The higher the cache size, the functioning of CPU is better.
c) Fill the below table and write a small note on your observation from the data cache.
● Block Size =16
● Cache Size = 16
● Cache Type = Direct Mapped
Addresses Data Miss (%)
0048 00 29.6%
0049 02 29.6%
0050 00 29.6%
0051 05 29.6%
0052 02 29.6%
0053 00 29.6%
0054 00 29.6%
0055 02 29.6%
0056 00 29.6%
0057 0A 29.6%
0058 02 29.6%
0059 00 29.6%
0060 05 29.6%
0061 02 29.6%
0062 00 29.6%
0063 05 29.6%
Part II: Associative Mapped Cache
a) Execute the above program by setting block size to 2, 4, 8, 16 and 32 for cache size = 8,
16 and 32. Record the observation in the following table.
b) Plot a single graph of Cache hit ratio Vs Block size with respect to cache size = 8, 16 and
32. Comment on the graph that is obtained.
Chart Title
100.00%
90.00%
80.00%
70.00%
60.00%
50.00%
40.00%
30.00%
20.00%
10.00%
0.00%
1 2 3
%Hit Ratio Cache size 8 %Hit Ratio Cache size 16 %Hit Ratio Cache size 32
By increasing the cache size, the hit ratio improved, hence the performance of the program
improved. The higher the cache size, the functioning of CPU is better.
c) Fill up the following table for three different replacement algorithms and state which
replacement algorithm is better and why?
There is no significant difference in the misses and hit ratio for the different algorithms.
The marginal difference as observed for the hit ratio from the above table, we can conclude
LRU algorithm performs better than the other algorithms.
d) Plot the graph of Cache Hit Ratio Vs Cache size with respect to different replacement
algorithms. Comment on the graph that is obtained.
Chart Title
70.00%
60.00%
50.00%
40.00%
30.00%
20.00%
10.00%
0.00%
1 2 3 4 5
Irrespective of algorithms that we use, it can be concluded that increase in the cache size,
improves the hit ratio.
Part III: Set Associative Mapped Cache
Execute the above program by setting the following Parameters:
● Number of sets (Set Blocks): 2 way
● Cache Type: Set Associative
● Replacement: LRU/FIFO/Random
a) Fill up the following table for three different replacement algorithms and state which
replacement algorithm is better and why?
Replacement Algorithm: Random
Block Size Cache size Miss Hit Hit ratio
2 4 127 92 42.01%
2 16 99 120 54.79%
2 32 93 126 57.53%
2 64 87 132 60.27%
2 8 68 151 68.95%
2 16 60 159 72.60%
2 32 54 165 75.34%
2 64 45 174 79.45%
2 8 60 159 72.60%
2 16 55 164 74.89%
2 32 51 168 76.71%
2 64 44 175 79.91%
There is no significant difference in the misses and hit ratio for the different algorithms.
The marginal difference as observed for the hit ratio from the above table, we can conclude
LRU algorithm performs better than the other algorithms.
c) Plot the graph of Cache Hit Ratio Vs Cache size with respect to different replacement
algorithms. Comment on the graph that is obtained.
Chart Title
90.00%
80.00%
70.00%
60.00%
50.00%
40.00%
30.00%
20.00%
10.00%
0.00%
1 2 3 4 5
Irrespective of algorithms that we use, it can be concluded that increase in the cache size,
improves the hit ratio.
c) Fill in the following table and analyse the behaviour of Set Associate Cache. Which one is
better and why?
Replacement Algorithm: LRU
Block Size, Set Blocks Miss Hit Hit ratio
Cache size
2, 64 2 – Way 86 (39.2%) 133 0.60
2, 64 4 – Way 85(38.8%) 134 0.61
2, 64 8 – Way 85(38.8%) 134 0.61
Rush’s values
Replacement Algorithm: LRU
Block Size, Set Blocks Miss Hit Hit ratio
Cache size
2, 64 2 – Way 44(20%) 175 0.79
2, 64 4 – Way 43(19.6%) 176 0.80
2, 64 8 – Way 43(19.6%) 176 0.80
As the number of set blocks increases(the number of sets decreases), the number of misses
reduce and the hits increase. We can conclude that the 8 - way set blocks perform better with
the LRU algorithm.