Computer principle access block length by byte is 6, computer principle 4.11 Selected topic of cache memory

Example 1

It is assumed that the direct mapping method is adopted between the main memory and the Cache, and the block size is 16B. The capacity of the Cache data area is 64KB, the main memory address is 32 bits, and it is addressed by bytes. Require

1) Give the main memory address division in direct mapping mode

2) Complete the hardware implementation of Cache access

3) Calculate Cache capacity

untie:

1) Know from the title conditions:

Data block size 16B-------> 4-bit offset address within the block

The capacity of the Cache data area is 64KB---------"64KB/16B=4096 rows Cache-------" index field 12 bits

The number of bits in the Tag field is ---------"32-12-4=16 bits (Tag)

2)

bcd895d824eccffdf9d7430734910d73.png

3) Calculate the Cache capacity (assuming that the Cache also contains a significant bit in addition to data and tags)

The answer to the first question can be seen: Tag is 16bit

Knowing from the subject conditions and the working principle of Cache:

The data storage capacity of each row of Cache is 16*8=128bit

The total storage capacity of each row of Cache is: 1+16+128=145bit

The total Cache capacity is 4096 x 145=580Kbit

Example 2 Assume that the content capacity of a computer is 16MB, the capacity of the Cache is 16KB, each block is 8 words, and each word is 32 bits, and a Cache organization with a four-way group associative mapping (that is, each group in the Cache contains 4 word blocks) is designed. Way

1) Find the number of bits in each field in the main memory address field that satisfies the group-associative mapping

2) Set the initial state of the Cache to be empty, and the CPU accesses 100 words continuously from the 0th unit of the main memory (the main memory reads one word at a time), and repeats this sequence to read 8 times to find the hit rate of the storage access.

3) If the speed of the Cache is 6 times the speed of the main memory, find the access acceleration ratio of the storage system

untie:

1) 8*32 bits per block = 32B-----> 5 bits of offset address within the block

The number of Cache rows can also be heaped out to 16KB/32B=512 rows

The number of Cache groups is----"512/4=128 groups----"index field 7 bits

Tag field is: 24-5-7=12 bits

The total number of words in the data word length is 24 bits?

Because the content capacity is 16MB, converting it into bytes is 16 x 1024 x 1024=224, so the data word length is 24 bits, which are generally addressed by bytes by default.

2)

a41a9bd755781f07bfa2eecf2ee22b5d.png

The 100 units of main memory are divided into 13 blocks, which are in main memory group 0, while the cache has 128 groups, so the first 100 units of main memory are not paged.

The initial state is empty, each block is not hit for the first time, and the next 7 accesses are all hits

Unit 100 corresponds to 13 blocks, 13 misses in the first round of access, and all hits in the next seven rounds of access

The total hit rate for 8 loops is:

(100*8-13)/(8*100)=98.375%

3) Set the access cycle of the Cache as t, then the main memory access cycle is 6t

The time required to read all data directly from memory is:

T1=800*6t=4800t

The time to access 800 data through Cache is:

T2=13*6t+(800-13)*t=865t

Speedup of storage system access

S=T1/T2=(4800t/865t)=5.5

Example 3 Locality analysis, among the following programs A and B, which one has better spatial locality for array A[2048][2048] reference? What about temporal locality? How is the spatial and temporal locality of the variable sum?

ff1dca1a6d17daf947b757d425c189c2.png

8bf45c8e192d7465e4bcaff3ea79bdcc.png

Block A:

The array access order is consistent with the storage order, and the spatial locality is good!

Although the array is in the loop body, each element is only used once, and the time locality is poor!

The variable sum is in the loop body, and the time locality is good!

The variable sum has only one variable, and the spatial locality is poor!

Block B:

The array access order is inconsistent with the storage order, and the spatial locality is poor!

Although the array is in the loop body, each element is only used once, and the time locality is poor!

The variable sum is in the loop body, and the time locality is good!

The variable sum has only one variable, and the spatial locality is poor!

Original text: https://www.cnblogs.com/fate-/p/13172737.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324151831&siteId=291194637