The number of bits required by the LRU algorithm in the CPU cache

Source: Internet
Author: User

reference:algorithm LRU, how many bits needed for implement this algorithm?

question: How many bits does it take to use the LRU replacement algorithm in the CPU cache?

Workaround:
For n-channel-connected caches, the number of bits required per cache block for LRU is log2 (n), so the number of bits required per set is N*LOG2 (n).

(Original: Assuming you mean a 4-way set-associative cache:
A "Perfect" LRU would essentially is assigning each line an exact index in the order of usage. You can also think of this as an ' age '. So each of the 4 elements would require a index of 2 bits (since we need to count 4 distinct ages) stating it location I n the LRU order-this means 2 bits * 4 ways, per each set of the cache.
In the general case of n ways, you ' d need log2 (n) bits per line, or N*LOG2 (n) bits per set.

By the the-by, there is cheaper ways to reach a almost-lru behavior, see for e.g. Pseudo LRU which would only require 3 bit s for the entire set in your case (or in general: #ways-1))

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The number of bits required by the LRU algorithm in the CPU cache

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.