3 ms·
Depending on your workload deliberately avoiding the prefetcher (which isn't particularly easy, mind you) ranges between a mild loss to 2-3 orders of magnitude
by keldaris 10y ago
Depending on your workload deliberately avoiding the prefetcher (which isn't particularly easy, mind you) ranges between a mild loss to 2-3 orders of magnitude in performance. As a trivial example, consider the element-wise addition of two large matrices. Without a prefetcher you would incur a large number (how large mostly depends on the ratio of the number of elements in your matrices and the available cache memory) of cache misses even during the most cache-friendly iteration pattern since the matrices are simply too large. On modern CPUs the prefetcher avoids these cache misses so well that the performance difference is approximately two orders of magnitude. Of course for this to work your traversal pattern has to be sufficiently predictable.
Generally, I think considering the prefetcher is roughly as important (and, indeed, inextricably linked) as considering the cache subsystem itself. Any performance sensitive code will benefit from careful consideration of memory access and traversal patterns.