Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This question is regarding the cache performance of the following C code for a b

ID: 3772554 • Letter: T

Question

This question is regarding the cache performance of the following C code for a bubble sort implementation. Variables i, j, v1, v2 are register variables. Note the code is different from the textbook one: It scans the whole array for n times. This is a naive (but correct) implementation of bubble sort. The L1 data cache is 1 KB, direct mapped, with 32-byte blocks. In other words, there are 32 cache blocks and each block is 32-byte. Assume that there is no instruction cache misses, the data cache is initially empty, and the input array v[] is always aligned with 32-byte boundaries. [7] If n = 128 (and thus the size of the array is 512 bytes), what is the number of cache misses?

Explanation / Answer

As n= 128

each element will be 4 bytes.. so total 128x4 = 512 bytes

So number of cahces will be

On an average for bubble sort 64 byte, it will have 5933 cache miss.

So for 512 bytes , we will have 5933 x 8 (since 8x64 = 512) ====> 47464 cache misses.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote