在学习csapp, 看完了第六章。标记一下, 所以直接引用csapp书中内容了:
Putting It Together: Exploiting Locality in Your Programs (The Impact of Caches on Program Performance)
Programmers who understand the nature of the memory hierarchy can exploit this understanding to write
more efficient programs, regardless of the specific memory system organization. In particular, we recommend
the following techniques:
Focus your attention on the inner loops where the bulk of the computations and memory accesses
occur.
Try to maximize the spatial locality in your programs by reading data objects sequentially, in the order
they are stored in memory.
Try to maximize the temporal locality in your programs by using a data object as often as possible
once it has been read from memory.
Remember that miss rates are only one (albeit important) factor that determines the performance
of your code. The number of memory accesses also plays an important role, and sometimes it is
necessary to trade off between the two.

本文探讨了如何通过理解内存层次结构来提高程序效率。主要技术包括关注内循环、最大化空间局部性和时间局部性,以及平衡缓存未命中率与内存访问次数。

6287

被折叠的 条评论
为什么被折叠?



