Memory hierarchy--"in-depth understanding of computer systems" chapter sixth reading notes

Source: Internet
Author: User

1. Several storage technologies
    • random access to memory Ram, RAM is divided into two categories: static SRAM and dynamic DRAM.
      • Static SRAM features: smaller capacity, faster than dynamic DRAM, so the price is also higher. Typically used as a cache of CPU and memory.
      • Dynamic DRAM features: larger capacity, slower than SRAM, the price is relatively low. Generally used as system memory.
    • disk storage, which is an external I/O device, is characterized by a large storage capacity, but slower reading speed and cheaper price. In general, the time to read information from disk is in milliseconds, reading from DRAM is 100,000 times times faster than reading from disk, and reading from SRAM is 1 million times times faster than reading from disk.
      • Because the structure of the disk is a disc, the disk is distributed on a track (different radii have different tracks), each visit to find the corresponding track, and then disk rotation to the corresponding revelation location, therefore, disk sector access time = seek time + rotation time + transmission time.
2. Locality

In a program, a program tends to refer to data items that are adjacent to other recently referenced data items, or the recently referenced data item itself, which is called the principle of locality. For example, in the loop of a two-dimensional array, the locality of the Loop 1 is better than the Loop 2.

 /* has a well-localized program */
int loop1 (int " Span style= "color: #000000;" > Array[m][n]) { int i = 0 , j = 0 , sum = 0 ; for (i = 0 ; i < M;i++ for (j = 0 ; J < N;j++) sum += A[i][j]; return sum;}
/* Poorly localized programs */
int Array[m][n]) { int000; for 0; i < m;i++ ) { for0; j < n;j++ ) + = A[j][i] ; return sum;}

Program locality can be summarized as follows:

    • A program that repeatedly references a variable has good time locality.
    • For a program with a reference pattern with a step size of K, the smaller the step size, the better the spatial locality. In contrast, the program space in the memory to jump with large step jumps is very poor.
    • The loop has a good time and spatial locality for taking orders. The smaller the loop body, the more the loop iteration number, the better the locality.
3. Cache memory

As the speed gap between the CPU and main memory is not increasing, the early system designers were forced to insert a small SRAM between the CPU register and main memory to tell the cache memory. Later, as the speed gap between the various memory structures in the system increased, the cache technology was also used in the memory structure, such as disk and memory.

The cache is designed to reduce the speed differences between memory hierarchies, and the effect is to access the lower-level memory structure, a larger block of the direct lower-level memory structure is stored in the cache memory. This allows you to quickly get data from the cache memory the next time you want to access the neighboring data of the previous data. It is for this reason to write programs that are well-localized.

Memory hierarchy--"in-depth understanding of computer systems" chapter sixth reading notes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.