Memory Hierarchy
For which access pattern is hardware prefetching especially effective?
- AReading an array in order at a fixed interval (stride)
- BFollowing a linked list one element at a time from the head
- CLooking up a hash table with random keys
Show answer and explanation
Answer: A. Reading an array in order at a fixed interval (stride)
A hardware prefetcher detects regularity in recent addresses, such as sequential or constant-stride patterns, predicts upcoming addresses and loads them ahead of time. Reading an array at a fixed stride is easy to predict, so the benefit is large. In a linked list the next element's address is unknown until the current one is read, so there is no pattern to predict. Random-key hash lookups also lack address regularity, so prefetching helps little.
- A. Correct. Regular strides are easy to predict, so the benefit is large.
- B. The next address is unknown until the current element is read, so it cannot be predicted.
- C. Addresses have no regularity, so the benefit is small.