Conflict misses are common in real programs and can cause baffling performance problems. Conflict misses in direct-mapped caches typically occur when programs access arrays whose sizes are a power of 2. For example, consider a function that computers the dot product of two vectors:
float dotprod(float x[8], float y[8])
{
float sum = 0.0;
for (int i=0; i!=8; ++i)
sum += x[i]*y[i];
return sum;
}
This function has good spatial locality with respect x and y, and so we might expect it to enjoy a good number of cache hits. Unfortunately, this is not always true.Suppose that floats are 4 bytes, that xis loaded into the 32 bytes of contiguous memory starting at address 0, and that y starts immediately after x