Cache control method and device, program product, processor and storage medium

By calculating the retention value of the cache replacement algorithm candidate block in a multi-core processor and determining whether it is retained, the cache replacement strategy is optimized, which solves the problem of low cache hit rate and improves performance and adaptability.

CN119883951AActive Publication Date: 2025-04-25SHANDONG BOSUAN ZHIXIN INFORMATION TECHNOLOGY CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510361489.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-26
Publication Date
2025-04-25
Estimated Expiration
2045-03-26

AI Technical Summary

Technical Problem

In multi-core processors, the cache replacement algorithm is insufficiently adaptive, resulting in low cache hit rate and large performance losses.

Method used

By obtaining the eviction cache information and eviction history information of the current candidate block in the target cache area, the retention value of the current candidate block is calculated, and whether the current candidate block is retained is judged based on the retention value and value threshold, thereby optimizing the cache replacement strategy.

Benefits of technology

Improves the adaptability and cache hit rate of cache replacement policies, reduces the performance losses caused by cache misses, and reduces hardware overhead.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883951A_ABST
    Figure CN119883951A_ABST
Patent Text Reader

Abstract

The invention discloses a cache control method and device, a program product, a processor and a storage medium, and relates to the technical field of processors, the method is applied to a cache controller of the processor, and the method comprises the following steps: acquiring cache expelling information of a current candidate block in a target cache region; determining a retention value of the current candidate block according to the expulsion cache information and cache entries in the expulsion historical information set; judging whether the current candidate block is reserved or not according to the reserved value and a value threshold value; if yes, acquiring cache expelling information of the next candidate block in the target cache region; if not, expelling the current candidate block from the target cache region, and storing a cache entry corresponding to the expelling cache information in an expelling historical information set; according to the method, the retention value of the current candidate block selected by the cache replacement algorithm is determined by utilizing the expulsion historical information set to judge whether the current candidate block is possibly accessed again in the future, so that the adaptability and the cache hit rate of the cache replacement strategy are improved, and the performance loss caused by the cache miss is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of processor technology, and in particular to a cache control method, device, program product, processor and storage medium. Background Art

[0002] Currently, the rapid development of computer systems has led to a significant improvement in the performance of processors (such as central processing units (CPUs), but the relatively lagging development of memory technology has led to a widening gap between processor cycle time and memory access latency, which in turn has formed a "memory wall" problem. To meet this challenge, modern processors rely on a memory system consisting of a cache hierarchy, which improves the overall processing efficiency of the system by storing data as close to the processor as possible in the cache level. However, cache misses are inevitable in the cache system, which makes choosing an appropriate cache replacement strategy the key to optimizing system performance.

[0003] In the related technologies, the LRU (Least Recently Used) algorithm is currently one of the cache replacement algorithms widely used in processors. Its core idea is to replace the data block in the cache that has not been used for the longest time. However, in highly parallel computing scenarios, frequent cache replacement will not only lead to cache pollution, but may also cause performance bottlenecks and affect the overall performance of the system; especially in multi-core processor architectures, cache consistency issues further increase the complexity of cache management. In order to deal with these problems, predictive models are usually used to optimize cache replacement strategies. These models predict the most appropriate cache replacement strategy by analyzing characteristics such as data access frequency, memory access patterns, and instruction behavior; however, these models still lack adaptability when dealing with complex and dynamic computing environments.

[0004] Therefore, how to optimize the cache replacement algorithm in multi-core processors, improve the adaptability and cache hit rate of cache replacement strategies, and reduce the performance loss caused by cache misses is an urgent problem that needs to be solved today. Summary of the invention

[0005] The purpose of the present invention is to provide a cache control method, device, computer program product, processor and computer-readable storage medium to optimize the cache replacement algorithm in a multi-core processor, improve the adaptability of the cache replacement strategy and the cache hit rate, and reduce the performance loss caused by cache misses.

[0006] In order to solve the above technical problems, the present invention provides a cache control method, which is applied to a cache controller of a processor, comprising:

[0007] Obtaining eviction cache information of a current candidate block in a target cache area; wherein the current candidate block is a cache data to be evicted selected by a cache replacement algorithm, and the eviction cache information includes consistency state and sharing state information;

[0008] Determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set; wherein the cache entries include the consistency state and sharing state information of the evicted cache data;

[0009] Determining whether to retain the current candidate block according to the retention value and the value threshold;

[0010] If yes, obtaining the eviction cache information of the next candidate block in the target cache area, taking the next candidate block as the current candidate block, and executing the step of determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set;

[0011] If not, the current candidate block is evicted from the target cache area, and a cache entry corresponding to the evicted cache information is stored in the evicted history information set.

[0012] On the other hand, determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set includes:

[0013] Determine, according to each cache entry in the eviction history information set, each consistency state weight, each sharing quantity exceeding a threshold weight, and each sharing quantity not exceeding a threshold weight;

[0014] The retention value of the current candidate block is determined according to the consistency state weight, the sharing quantity exceeding the threshold weight, the sharing quantity not exceeding the threshold weight, and the consistency state and sharing state information in the eviction cache information.

[0015] On the other hand, the consistency state is a state in a modified-exclusive-shared-invalidated protocol, and the consistency state weight includes a dirty state weight, an exclusive state weight, and a shared state weight; determining the retention value of the current candidate block according to each of the consistency state weights, the shared quantity exceeding a threshold weight, the shared quantity not exceeding a threshold weight, and the consistency state and shared state information in the eviction cache information includes:

[0016] By V=w M *M+w E *E+w S *S+w AT *AT+w BT *BT, determine the retention value of the current candidate block; where V is the retention value, w M 、wE and w S are the dirty state weight, the exclusive state weight and the shared state weight respectively; M, E and S are the shared quantities corresponding to the shared state information in the eviction cache information when the consistency state in the eviction cache information is in the modified state, the exclusive state and the shared state respectively; w AT and w BT They are respectively the weight of the shared quantity exceeding the threshold value and the weight of the shared quantity not exceeding the threshold value; AT is 1 when the shared quantity exceeds the quantity threshold value, and is 0 when the shared quantity does not exceed the quantity threshold value; BT is 1 when the shared quantity does not exceed the quantity threshold value, and is 0 when the shared quantity exceeds the quantity threshold value.

[0017] On the other hand, according to each cache entry in the eviction history information set, determining each consistency state weight, each sharing quantity exceeding a threshold weight, and each sharing quantity not exceeding a threshold weight includes:

[0018] Determining a weight of each consistency state according to the number of cache entries in the eviction history information set and the consistency state of each cache entry;

[0019] Determine the weight of the shared quantity exceeding the threshold value and the weight of the shared quantity not exceeding the threshold value according to the number of cache entries in the eviction history information set, the first number, and the second number; wherein the first number is the number of cache entries whose shared quantity corresponding to the shared status information exceeds the quantity threshold, and the second number is the number of cache entries whose shared quantity corresponding to the shared status information does not exceed the quantity threshold.

[0020] On the other hand, before determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set, the method further includes:

[0021] Determining whether the number of cache entries in the eviction history information set meets the requirement;

[0022] If the requirements are met, the step of determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set is performed;

[0023] If it does not meet the requirements, the current candidate block is evicted from the target cache area, and a cache entry corresponding to the evicted cache information is added to the evicted history information set.

[0024] On the other hand, the eviction history information set is an eviction history table, and determining whether the number of cache entries in the eviction history information set meets the requirement includes:

[0025] Determining whether the number of cache entries in the eviction history table reaches a preset evaluation number;

[0026] If the preset evaluation number is reached, the step of determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set is performed;

[0027] If the preset evaluation quantity is not reached, the step of evicting the current candidate block from the target cache area and adding a cache entry corresponding to the evicted cache information to the evicted history information set is performed.

[0028] On the other hand, storing the cache entry corresponding to the eviction cache information in the eviction history information set includes:

[0029] If the number of cache entries in the eviction history information set is a preset full number, determining a target cache entry according to the storage time, miss time and / or current retention value of each cache entry in the eviction history information set;

[0030] The target cache entry is replaced by the cache entry corresponding to the eviction cache information.

[0031] On the other hand, determining a target cache entry according to the storage time, miss time and / or current retention value of each cache entry in the eviction history information set includes:

[0032] The cache entry with the longest miss time in the eviction history information set is determined as the target cache entry.

[0033] On the other hand, the cache entry also includes address information, threshold comparison information and a valid bit; the sharing status information in the cache entry is a sharer vector bit, and the threshold comparison information is used to indicate whether the sharing quantity corresponding to the sharer vector bit exceeds the quantity threshold.

[0034] In another aspect, the cache replacement algorithm is a least recently used algorithm.

[0035] On the other hand, the processor adopts a cache architecture with at least two layers, and the target cache area includes a bottom layer cache of the cache architecture.

[0036] On the other hand, judging whether to retain the current candidate block according to the retention value and the value threshold includes:

[0037] determining whether the retention value is greater than the value threshold;

[0038] If it is greater than the value threshold, it is determined to retain the current candidate block;

[0039] If it is not greater than the value threshold, it is determined not to retain the current candidate block.

[0040] On the other hand, obtaining eviction cache information of the current candidate block in the target cache area includes:

[0041] Get cache access request;

[0042] Checking whether the cache access request hits cache data in the cache of the processor;

[0043] If there is a miss, the cache replacement algorithm is used to determine the current candidate block in the target cache area, and obtain the eviction cache information of the current candidate block.

[0044] In another aspect, the method further comprises:

[0045] Checking whether the obtained cache access request hits a cache entry in the eviction history information set;

[0046] If a cache entry in the eviction history information set is hit, the hit cache entry is deleted from the eviction history information set.

[0047] On the other hand, before taking the next candidate block as the current candidate block and performing the step of determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set, the method further includes:

[0048] If the cache access request does not hit a cache entry in the eviction history information set, the consistency state weights, the sharing quantity exceeding threshold weights and the sharing quantity not exceeding threshold weights corresponding to the eviction history information set are updated according to the eviction cache information.

[0049] On the other hand, according to the eviction cache information, updating the consistency state weights, the weights of the number of shares exceeding the threshold, and the weights of the number of shares not exceeding the threshold corresponding to the eviction history information set includes:

[0050] Calculate the sum of the target consistency state weight and the first learning rate to obtain an updated target consistency state weight; wherein the target consistency state weight is the consistency state weight corresponding to the consistency state of the eviction cache information;

[0051] Normalize the updated target consistency state weight and other consistency state weights to obtain updated consistency state weights; wherein the sum of the updated consistency state weights is 1;

[0052] Calculate the sum of the target shared state weight and the second learning rate to obtain an updated target shared state weight; wherein the target shared state weight is a shared quantity exceeding a threshold weight or a shared quantity not exceeding a threshold weight corresponding to the shared state information of the eviction cache information;

[0053] The updated target sharing state weight and another sharing state weight are normalized to obtain the updated sharing quantity exceeding threshold weight and the sharing quantity not exceeding threshold weight; wherein the sum of the updated sharing quantity exceeding threshold weight and the sharing quantity not exceeding threshold weight is 1.

[0054] The present invention also provides a cache control device, which is applied to a cache controller of a processor, comprising:

[0055] An acquisition module is used to acquire eviction cache information of a current candidate block in a target cache area; wherein the current candidate block is a cache data to be evicted selected by a cache replacement algorithm, and the eviction cache information includes consistency state and sharing state information;

[0056] A determination module, configured to determine the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set; wherein the cache entries include the consistency state and sharing state information of the evicted cache data;

[0057] A judgment module, used for judging whether to retain the current candidate block according to the retention value and the value threshold;

[0058] A retaining module, configured to obtain eviction cache information of a next candidate block in the target cache area if the current candidate block is retained, and use the next candidate block as the current candidate block, and send a start signal to the determining module;

[0059] The eviction module is used to evict the current candidate block from the target cache area if the current candidate block is not retained, and store the cache entry corresponding to the eviction cache information in the eviction history information set.

[0060] The present invention also provides a computer program product, comprising a computer program / instruction, which implements the steps of the cache control method as described above when executed by a processor.

[0061] The present invention also provides a processor, comprising:

[0062] Memory for storing computer programs;

[0063] A cache controller is used to implement the steps of the cache control method as described above when executing the computer program.

[0064] In addition, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the cache control method described above are implemented.

[0065] A cache control method provided by the present invention is applied to a cache controller of a processor, comprising: obtaining eviction cache information of a current candidate block in a target cache area; wherein the current candidate block is a cache data to be evicted selected by a cache replacement algorithm, and the eviction cache information includes consistency state and sharing state information; determining the retention value of the current candidate block according to the eviction cache information and cache entries in an eviction history information set; wherein the cache entries include consistency state and sharing state information of evicted cache data; judging whether to retain the current candidate block according to the retention value and a value threshold; if so, obtaining the eviction cache information of the next candidate block in the target cache area, taking the next candidate block as the current candidate block, and executing the step of determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set; if not, evicting the current candidate block from the target cache area, and storing the cache entry corresponding to the eviction cache information in the eviction history information set.

[0066] It can be seen that the present invention can use the consistency state and shared state information of the evicted cache blocks in the eviction history information set to determine the retention value of the current candidate block selected by the cache replacement algorithm to determine whether the current candidate block may be accessed again in the future, thereby optimizing the cache replacement algorithm in the multi-core processor, improving the adaptability and cache hit rate of the cache replacement strategy, and reducing the performance loss caused by cache misses; and because the eviction history information set does not need to store specific cache block data, compared with the method of increasing cache capacity to improve cache hit rate, the hardware overhead is smaller. In addition, the present invention also provides a cache control device, a computer program product, a processor, and a computer-readable storage medium, which also have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0067] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0068] Figure 1 A flow chart of a cache control method provided by an embodiment of the present invention;

[0069] Figure 2 A structural diagram of a reinforcement learning system provided by an embodiment of the present invention;

[0070] Figure 3 A display diagram of an eviction history table provided by an embodiment of the present invention;

[0071] Figure 4A schematic diagram of a process flow of a cache replacement algorithm based on reinforcement learning provided by an embodiment of the present invention;

[0072] Figure 5 A schematic diagram of a reward feedback process of a cache control method provided by an embodiment of the present invention;

[0073] Figure 6 A schematic flow chart of another cache control method provided by an embodiment of the present invention;

[0074] Figure 7 A structural block diagram of a cache control device provided by an embodiment of the present invention;

[0075] Figure 8 A schematic diagram of the structure of a processor provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0076] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0077] Please refer to Figure 1 , Figure 1 A flow chart of a cache control method provided by an embodiment of the present invention. The method is applied to a cache controller of a processor and may include:

[0078] Step 101: Obtain eviction cache information of a current candidate block in a target cache area; wherein the current candidate block is a cache data to be evicted selected by a cache replacement algorithm, and the eviction cache information includes consistency state and sharing state information.

[0079] It can be understood that the target cache area in this embodiment can be a cache area in all caches of the processor that needs to be optimized for the cache replacement algorithm by the method provided by this embodiment. For example, when the processor adopts a cache architecture of at least two layers, the target cache area can include the bottom cache of the cache architecture; for example, when the processor adopts a three-layer cache architecture, the target cache area can include the third layer cache (i.e., L3 cache), such as Figure 2 As shown, the cache controller in this embodiment may be an L3 cache controller.

[0080] Correspondingly, the current candidate block in this embodiment can be a cache data (or cache block or cache line) currently required to be evicted selected by the cache replacement algorithm. The specific algorithm type of the cache replacement algorithm used in the target cache area in this embodiment can be set by the designer according to practical scenarios and user needs. For example, the cache replacement algorithm can use the LRU (least recently used) algorithm, or the LFU (Least Frequently Used) algorithm or other cache replacement algorithms, and this embodiment does not impose any restrictions on this.

[0081] Correspondingly, the eviction cache information of the current candidate block in this embodiment may include the consistency state and sharing state information of the current candidate block; wherein, the consistency state may be the state of the current candidate block in the adopted cache consistency protocol, such as when the cache consistency protocol is the MESI (Modified Exclusive Shared Invalidated) protocol, the consistency state may be the modified state (M state), the exclusive state (E state) or the shared state (S state); when the cache consistency protocol is the CHI (Coherent Hub Interface) protocol, the CHI protocol defines five states, namely, the invalid state (I state), the clean shared state (SC state), the dirty shared state (SD state), the clean exclusive state (UC state) and the dirty exclusive state (UD state), and the consistency state may be the SC state, the SD state, the UC state or the UD state.

[0082] It should be noted that the specific method for the cache controller to obtain the eviction cache information of the current candidate block in the target cache area in this step can be set by the designer according to the practical scenario and user needs, such as the method that the cache controller in the related art uses a cache replacement algorithm (such as an LRU algorithm) to determine the cache data that needs to be evicted. For example, in this step, the cache controller can obtain a cache access request; check whether the cache access request hits the cache data in the processor's cache; if it does not hit, use the cache replacement algorithm to determine the current candidate block in the target cache area, and obtain the eviction cache information of the current candidate block. That is to say, when the processor core performs cache access, the cache controller can detect whether the cache hits; if it hits, use the cache data that hits to complete the access; if it does not hit, the corresponding data can be searched from the main memory to complete the access and replace the cache data in the cache; and in the process of replacing the cache data in the cache, the cache replacement algorithm will be used to determine the current candidate block in the target cache area, and obtain the eviction cache information of the current candidate block, so as to determine whether to evict the current candidate block through the method provided by this embodiment to replace it with the corresponding data.

[0083] Step 102: Determine the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set; wherein the cache entries include the consistency state and sharing state information of the evicted cache data.

[0084] It can be understood that the eviction history information set in this embodiment can be a set of relevant information (ie, cache entries) of cache data (ie, cache blocks) that have been evicted historically in the target cache area. Figure 2 As shown, the eviction history information set can be used as an environment for the cache reinforcement learning system, and the recorded status of the historically evicted cache blocks (such as consistency status and sharing status information) is sent to the cache controller (L3 cache controller) as an intelligent agent, so that the cache controller can evaluate and determine whether to evict the current candidate block.

[0085] Correspondingly, the specific storage form of the eviction history information set in this embodiment can be set by the designer. For example, the eviction history information set can be stored in a table form, that is, the eviction history information set can be specifically an eviction history table; the eviction history information set can also be stored in an array or other forms, and this embodiment does not impose any restrictions on this.

[0086] Similarly, the specific content of each cache entry in the eviction history information set in this embodiment can be set by the designer according to practical scenarios and user needs. For example, the cache entry can include the consistency state and sharing state information of the evicted cache data; in order to conveniently reflect the consistency state of the cache data in the sharing state of each processor core, the sharing state information can be specifically a sharer vector bit, that is, the sharer vector bit can include the sharing state vector corresponding to each processor core to record which cores specifically share the consistency state; Figure 4 As shown, when the number of processor cores is 4, the sharer vector bit may include 4 sharing state vectors. When the sharing state vector is 1, it can indicate that the cache data is shared by the corresponding core. When the sharing state vector is 0, it can indicate that the cache data is not shared by the corresponding core. For example, the sharer vector bit is 0010, and the recorded consistency state is M state, indicating that the consistency state of the cache data in the second core among the four cores is M state. The cache entry may also include the address information of the evicted cache data (such as the cache line address) to facilitate subsequent checks on whether the cache entry is hit. The cache entry may also include threshold comparison information, which is used to indicate the result of comparing the number of processor cores that share the cache data (i.e., the sharing number) with the quantity threshold, such as indicating whether the sharing number exceeds the quantity threshold; Figure 4The threshold comparison information of 1 can indicate that the number of cache data shares exceeds the number threshold, and the threshold comparison information of 0 can indicate that the number of cache data shares does not exceed the number threshold, so as to facilitate the calculation of the weight of the number of shares exceeding the threshold and the weight of the number of shares not exceeding the threshold. The cache entry can also have a valid bit to facilitate the replacement and update of the cache entry. If the valid bit is 0, it can indicate that the cache entry is invalid and will be replaced later. As long as the cache entry does not include the evicted cache data, so that the resources it occupies are far less than the cache and the hardware overhead is reduced, this embodiment does not impose any restrictions on this.

[0087] It should be noted that, in this embodiment, the specific method of determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set can be set by the designer according to the practical scenario and user needs. For example, the cache controller can determine the retention value of the current candidate block according to the number of cache entries corresponding to each consistency state in the eviction history information set and the number of cache entries corresponding to the sharing number exceeding the number threshold and exceeding the number threshold; for example, the retention value of the current candidate block can be the sum of the first number of entries and the second number of entries corresponding to the current candidate block, the first number of entries can be the number of cache entries corresponding to the consistency state in the eviction cache information of the current candidate block, and the second number of entries can be the number of cache entries corresponding to the sharing number represented by the sharing state information in the eviction cache information of the current candidate block when it exceeds the number threshold or the number of cache entries corresponding to the sharing number not exceeding the number threshold.

[0088] In other embodiments, the cache controller may also determine the consistency state weights, the weights for the number of shares exceeding the threshold, and the weights for the number of shares not exceeding the threshold based on each cache entry in the eviction history information set; and determine the retention value of the current candidate block based on the consistency state weights, the weights for the number of shares exceeding the threshold, the weights for the number of shares not exceeding the threshold, and the consistency state and sharing state information in the eviction cache information.

[0089] For example, the sum of the weights of each consistency state is 1, and the sum of the weight of the shared quantity exceeding the threshold value and the weight of the shared quantity not exceeding the threshold value is 1. The above process of determining the weights of each consistency state, the weight of the shared quantity exceeding the threshold value and the weight of the shared quantity not exceeding the threshold value according to each cache entry in the eviction history information set may include: determining the weights of each consistency state according to the number of cache entries in the eviction history information set and the consistency state of each cache entry; determining the weight of the shared quantity exceeding the threshold value and the weight of the shared quantity not exceeding the threshold value according to the number of cache entries in the eviction history information set, the first number and the second number; wherein the first number is the number of cache entries whose shared quantity corresponding to the shared state information exceeds the quantity threshold value, and the second number is the number of cache entries whose shared quantity corresponding to the shared state information does not exceed the quantity threshold value. That is to say, the weight of each consistency state may be the quotient of the number of cache entries corresponding to each consistency state and the number of cache entries in the eviction history information set, the weight of the shared quantity exceeding the threshold value may be the quotient of the first number and the number of cache entries in the history information set, and the weight of the shared quantity not exceeding the threshold value may be the quotient of the second number and the number of cache entries in the history information set.

[0090] For example, when the consistency state is the state in the MESI protocol, the consistency state weight includes the dirty state weight, the exclusive state weight, and the shared state weight. The above process of determining the retention value of the current candidate block according to the consistency state weights, the weight of the shared quantity exceeding the threshold, the weight of the shared quantity not exceeding the threshold, and the consistency state and shared state information in the eviction cache information may include: by V=w M *M+w E *E+w S *S+w AT *AT+w BT *BT, determine the retention value of the current candidate block; where V is the retention value, w M 、w E and w S are the dirty state weight, exclusive state weight and shared state weight respectively; M, E and S are the number of shares corresponding to the shared state information in the eviction cache information when the consistency state in the eviction cache information is in the modified state, exclusive state and shared state respectively; w AT and w BTare the weights of the number of shares exceeding the threshold and the weights of the number of shares not exceeding the threshold, respectively; AT is 1 when the number of shares exceeds the threshold, and is 0 when the number of shares does not exceed the threshold; BT is 1 when the number of shares does not exceed the threshold, and is 0 when the number of shares exceeds the threshold. In other words, M is the corresponding number of shares when the consistency state in the eviction cache information is in the modified state, and is 0 when the consistency state in the eviction cache information is not in the modified state; E is the corresponding number of shares when the consistency state in the eviction cache information is in the exclusive state, and is 0 when the consistency state in the eviction cache information is not in the exclusive state; S is the corresponding number of shares when the consistency state in the eviction cache information is in the shared state, and is 0 when the consistency state in the eviction cache information is not in the shared state.

[0091] Correspondingly, when the consistency state is the state in the CHI protocol, the consistency state weight may also include a dirty state weight, an exclusive state weight, and a shared state weight; the UD state in the CHI protocol may be used as the above-mentioned M state, the UC state in the CHI protocol may be used as the above-mentioned M state, and the SD and SC states in the CHI protocol may be used as the S state, thereby using a formula similar to the formula used to determine the retention value in the above-mentioned MESI protocol, and making corresponding settings. This embodiment does not impose any restrictions on this.

[0092] Furthermore, in order to ensure the accuracy of the determination of the retention value and avoid invalid calculation processes, in this embodiment, before step 102, the cache controller can determine whether the number of cache entries in the eviction history information set meets the requirements; if it meets the requirements, it enters step 102; if it does not meet the requirements, the current candidate block is expelled from the target cache area, and the cache entry corresponding to the eviction cache information is added to the eviction history information set. In other words, when the number of cache entries in the eviction history information set is too small, the retention value of the current candidate block determined by using the eviction history information set is not accurate enough, so a candidate block selected by the cache replacement algorithm can be directly used to be evicted and replaced with the corresponding data.

[0093] Correspondingly, the above process of determining whether the number of cache entries in the eviction history information set meets the requirements may include: determining whether the number of cache entries in the eviction history information set (such as the eviction history table) reaches a preset evaluation number; if it reaches the preset evaluation number, it is determined that the requirements are met, and a step of determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set may be performed; if it does not reach the preset evaluation number, it is determined that the requirements are not met, and a step of evicting the current candidate block from the target cache area and adding a cache entry corresponding to the eviction cache information to the eviction history information set may be performed.

[0094] The present embodiment does not limit the specific value of the preset evaluation number. For example, the preset evaluation number may be a preset full number, that is, the maximum number of cache entries that can be stored in the eviction history information set (such as the eviction history table); Figure 4 As shown, when the cache is accessed, it can be determined whether the eviction history table is full; if the eviction history table is not full, the cache replacement is performed according to the LRU cache replacement algorithm in the relevant technology; if the eviction history table is full, a candidate block will be selected for replacement according to the LRU cache replacement algorithm in the relevant technology; and, before deciding whether the candidate block is replaced, the cache controller will calculate the retention value of the candidate block according to the cache entry in the eviction history table using the value function (such as the above-mentioned retention value determination formula) to determine whether it should be replaced; if the retention value of the candidate block is high, the candidate block can be retained for a second chance, and the next candidate block can be selected according to the LRU cache replacement algorithm; if the subsequently selected candidate block has a low value, the cache controller can perform a replacement operation to remove the candidate block from the cache and record the corresponding cache entry in the eviction history table.

[0095] Step 103: Determine whether to retain the current candidate block based on the retention value and the value threshold; if so, proceed to step 104.

[0096] It can be understood that in this step, the cache controller can determine whether to retain the current candidate block based on the retention value and value threshold of the current candidate block, that is, determine whether the current candidate block should be replaced; thereby, when the retention value of the current candidate block is high, the current candidate block is retained to give the current candidate block a second chance, so as to retain the buffer block with a higher probability of being accessed again in the future, thereby improving the cache hit rate.

[0097] Correspondingly, the specific method of determining whether to retain the current candidate block according to the retention value and the value threshold in this step can be set by the designer. For example, the cache controller can determine whether the retention value is greater than the value threshold; if it is greater than the value threshold, it is determined to retain the current candidate block and the process can proceed to step 104; if it is not greater than the value threshold, it is determined not to retain the current candidate block and the process can proceed to step 105. In other embodiments, the cache controller can also determine whether the retention value is less than the value threshold; if it is less than the value threshold, it is determined to retain the current candidate block; if it is not less than the value threshold, it is determined not to retain the current candidate block. This embodiment does not impose any restrictions on this.

[0098] Accordingly, the specific value of the value threshold in this embodiment can be set by the designer, for example, the value threshold can be a pre-set fixed value; the value threshold can also be a value that can be adaptively adjusted, such as the value threshold can be a value determined according to the retention value of each cache entry in the eviction history information set; for example, the value threshold can be the minimum retention value or the average retention value among the retention values ​​of all cache entries in the eviction history information set.

[0099] Step 104 : Obtain the eviction cache information of the next candidate block in the target cache area, and use the next candidate block as the current candidate block, and proceed to step 102 .

[0100] It is understandable that the next candidate block in this step may be the next cache data to be evicted selected by the cache replacement algorithm. In this step, when determining that the current candidate block needs to be retained, the cache controller may retain the current candidate block in the target cache area, and use the next candidate block (i.e., the next candidate block) selected by the cache replacement algorithm (such as the LRU algorithm) as the current candidate block, and return to step 102 to calculate the retention value of the new current candidate block to continue to determine whether the new current candidate block needs to be retained, until it is determined that the current candidate block does not need to be retained.

[0101] Correspondingly, in this step, the cache controller can also count the number of times the candidate block is selected in this cache access. When the number of selections does not reach the number threshold, it continues to obtain the eviction cache information of the next candidate block in the target cache area, and uses the next candidate block as the current candidate block to enter the process of step 102; if the number of selections reaches the number threshold, it can directly enter step 105 to avoid problems such as value assessment errors and long cache replacement time.

[0102] Further, such as Figure 2 As shown, in this embodiment, the weights can be adjusted dynamically based on reinforcement learning, so that through the interaction of reward signals between the cache controller (agent) and the expulsion history information set (environment), adaptive learning can be performed on how to take the best actions in different states to maximize the accumulated rewards. Figure 5 As shown, the reward signal can be fed back based on whether the access cache address in the cache access request hits the address information of the cache entry in the eviction history information set (eviction history table); if there is a hit cache entry in the eviction history information set, a negative reward signal is given, indicating that the current decision is not good and the weight needs to be adjusted; if there is no hit cache entry, a positive reward is given, indicating that the past eviction decision is effective, and the weight can be further optimized and adjusted, thereby dynamically adjusting the cache replacement strategy to adapt to different computing scenarios.

[0103] For example, in some embodiments, the method provided by this embodiment may further include checking whether the obtained cache access request hits a cache entry in the eviction history information set; if it hits a cache entry in the eviction history information set, deleting the hit cache entry from the eviction history information set, so as to feedback a negative reward signal by deleting the hit cache entry in the eviction history information set, thereby adjusting the weights (such as the above-mentioned consistency state weights, the weight of the shared quantity exceeding the threshold, and the weight of the shared quantity not exceeding the threshold) or directly evicting the current candidate block in this cache replacement.

[0104] Accordingly, in some embodiments, in this step, the next candidate block is used as the current candidate block. Before entering step 102, when the cache access request misses the cache entry in the eviction history information set, the consistency state weights, the sharing quantity exceeding the threshold weights, and the sharing quantity not exceeding the threshold weights corresponding to the eviction history information set may be updated according to the eviction cache information of the current candidate block; wherein the updated consistency state weight corresponding to the consistency state in the eviction cache information is greater than the consistency state weight before the update; the updated target sharing state weight corresponding to the sharing state information in the eviction cache information is greater than the target sharing state weight before the update; and the target sharing state weight is the sharing quantity exceeding the threshold weight or the sharing quantity not exceeding the threshold weight corresponding to the sharing state information of the eviction cache information.

[0105] For example, the process of updating the consistency state weights, the weight of the number of shares exceeding the threshold, and the weight of the number of shares not exceeding the threshold corresponding to the eviction history information set according to the eviction cache information of the current candidate block may include: calculating the sum of the target consistency state weight and the first learning rate to obtain the updated target consistency state weight; wherein the target consistency state weight is the consistency state weight corresponding to the consistency state of the eviction cache information; normalizing the updated target consistency state weight and other consistency state weights to obtain the updated consistency state weights; wherein the sum of the updated consistency state weights is 1; calculating the sum of the target shared state weight and the second learning rate to obtain the updated target shared state weight; wherein the target shared state weight is the weight of the number of shares exceeding the threshold or the weight of the number of shares not exceeding the threshold corresponding to the shared state information of the eviction cache information; normalizing the updated target shared state weight and another shared state weight to obtain the updated shared state weight exceeding the threshold and the shared state weight not exceeding the threshold; wherein the sum of the updated shared state weight exceeding the threshold and the shared state weight not exceeding the threshold is 1.

[0106] Correspondingly, the first learning rate and the second learning rate may be pre-set fixed values; or they may be values ​​adaptively adjusted according to the number of updates, such as decreasing accordingly as the number of weight updates increases. This embodiment does not impose any restrictions on this.

[0107] For example, if Figure 6 As shown, when the cache controller obtains a cache access request, it can check whether the processor's cache and eviction history table are hit respectively; if the cache hits, the cache access is completed using the hit cache block (i.e., cache data); if the cache misses, the cache block in the target cache area will be evicted, a new cache block will be replaced and written, and the cache entry of the cached block will be written into the eviction history table; if the address of the cache access request hits the cache entry hit in the eviction history table, the corresponding cache entry in the eviction history table is deleted; if the eviction history table is not hit during cache access, the cache entry corresponding to the cache block evicted this time is written into the eviction history table.

[0108] That is to say, in the case of the above cache miss, if the cache entry in the eviction history table is hit, the current candidate block selected by the cache replacement algorithm can be directly used as the buffer block to be evicted this time to complete the cache replacement of this cache access request, such as Figure 4 As shown, the calculation of the retention value of the current candidate block is performed only when the eviction history table is full. The process may also proceed to step 101 to obtain the eviction cache information of the current candidate block to calculate the retention value of the current candidate block so as to determine the buffer block that is finally evicted this time, and complete the cache replacement of this cache access request. That is, the above-mentioned preset evaluation number may be less than the preset full number.

[0109] Correspondingly, in the case of a cache miss, if the cache entry in the eviction history table is not hit, then step 101 may be entered to obtain the eviction cache information of the current candidate block to calculate the retention value of the current candidate block and thereby determine the buffer block that is finally evicted this time. Furthermore, when the current candidate block needs to be retained, before selecting the next candidate block as the new current candidate block and calculating the retention value of the new current candidate block, the eviction cache information of the retained current candidate block may be used to further update the weight, so as to calculate the retention value of the new current candidate block using the updated weight, thereby realizing an intelligent cache management strategy.

[0110] For example, there are 4 processor cores in the processor and the number threshold is 2, such as Figure 3 The eviction history table shown in the figure stores 10 cache entries. If the cache access request does not hit the eviction history table, the initial weight can be: w M =2∕10=0.2, w E =2∕10=0.2, w S =6∕10=0.6, w AT =4∕10=0.4, w BT=6∕10=0.6; Assuming a cache miss, the consistency state of the current candidate block selected by the cache replacement algorithm is S state, the sharer vector bits are 0110, and its retention value can be: V(S)= 0.2*0+0.2*0+0.6*2+0.4*0+0.6*1=1.8; If the value threshold is 1.5, the retention value of the current candidate block is greater than the value threshold, the current candidate block can be retained, and the cache replacement algorithm is used to select the next candidate block to continue the calculation of the retention value.

[0111] Accordingly, before using the cache replacement algorithm to select the next candidate block to continue the calculation of the retention value, the weight of the current candidate block can be updated, such as the first learning rate and the second learning rate are both 1, w S_new =0.6+0.1=0.7, and w E and w M After normalization, the updated w M =0.18, w E =0.18, w S =0.64; w BT_new =0.6+0.1=0.7, and w AT After normalization, the updated w AT =0.36, w BT =0.64; then the updated weight is used to calculate the retention value of the next candidate block to implement an intelligent cache management strategy.

[0112] This embodiment does not limit the specific order of checking whether the cache access request hits the processor's cache and whether it hits the eviction history table. Figure 6 As shown, after obtaining the cache access request, it is checked in parallel whether the processor cache is hit and whether the eviction history table is hit; it is also possible to first check whether the processor cache is hit, and then check whether the eviction history table is hit if the cache is not hit.

[0113] Step 105: evict the current candidate block from the target cache area, and store the cache entry corresponding to the eviction cache information in the eviction history information set.

[0114] It can be understood that in this step, when the cache controller determines that the current candidate block does not need to be retained, the cache controller can evict the current candidate block from the target cache area to replace the corresponding data; and store the cache entry corresponding to the current candidate block in the eviction history information set. For example, when the number of cache entries in the eviction history information set is less than the preset full number (that is, the eviction history information set is full), the cache entry corresponding to the current candidate block is directly written into the eviction history information set; when the number of cache entries in the eviction history information set is the preset full number, a target cache entry is determined according to the storage time, miss time and / or current retention value of each cache entry in the eviction history information set; and the cache entry corresponding to the eviction cache information replaces the target cache entry.

[0115] Correspondingly, the specific method of determining a target cache entry based on the storage time, miss time and / or current retention value of each cache entry in the eviction history information set can be set by the designer. For example, the cache controller can directly determine the cache entry with the longest miss time or the longest storage time as the target cache entry; Figure 6 As shown, when the eviction history table is full, the cache entry that has missed the longest time (i.e., the target cache entry) can be evicted from the eviction history table to be replaced by the cache entry corresponding to the current candidate block that does not need to be retained. The cache controller can also determine a cache entry with the lowest corresponding retention value (i.e., the current retention value) as the target cache entry. This embodiment does not impose any restrictions on this.

[0116] In this embodiment, the embodiment of the present invention can use the consistency state and sharing state information of the evicted cache block in the eviction history information set to determine the retention value of the current candidate block selected by the cache replacement algorithm to judge whether the current candidate block may be accessed again in the future, thereby optimizing the cache replacement algorithm in the multi-core processor, improving the adaptability and cache hit rate of the cache replacement strategy, and reducing the performance loss caused by cache misses; and because the eviction history information set does not need to store specific cache block data, compared with the method of increasing the cache capacity to improve the cache hit rate, the hardware overhead is smaller.

[0117] Corresponding to the above method embodiment, the embodiment of the present invention further provides a cache control device. The cache control device described below and the cache control method described above can be referred to each other.

[0118] Please refer to Figure 7 , Figure 7 This is a structural block diagram of a cache control device provided by an embodiment of the present invention. The device is applied to a cache controller of a processor and may include:

[0119] The acquisition module 10 is used to acquire the eviction cache information of the current candidate block in the target cache area; wherein the current candidate block is a cache data to be evicted selected by the cache replacement algorithm, and the eviction cache information includes consistency state and sharing state information;

[0120] A determination module 20, configured to determine the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set; wherein the cache entries include the consistency state and sharing state information of the evicted cache data;

[0121] A judgment module 30, used to judge whether to retain the current candidate block according to the retention value and the value threshold;

[0122] A retaining module 40 is used to obtain the eviction cache information of the next candidate block in the target cache area if the current candidate block is retained, and use the next candidate block as the current candidate block, and send a start signal to the determination module;

[0123] The eviction module 50 is configured to evict the current candidate block from the target cache area if the current candidate block is not to be retained, and store the cache entry corresponding to the eviction cache information in the eviction history information set.

[0124] In some embodiments, the determination module 20 may include:

[0125] A weight determination submodule, used to determine the weight of each consistency state, the weight of the shared quantity exceeding the threshold, and the weight of the shared quantity not exceeding the threshold according to each cache entry in the eviction history information set;

[0126] The value determination submodule is used to determine the retention value of the current candidate block according to the consistency state weights, the sharing quantity exceeding the threshold weights, the sharing quantity not exceeding the threshold weights, and the consistency state and sharing state information in the eviction cache information.

[0127] In some embodiments, the consistency state is a state in a modified-exclusive-shared-invalidated protocol, and the consistency state weight includes a dirty state weight, an exclusive state weight, and a shared state weight;

[0128] The value determination submodule can be specifically used to pass V=w M *M+w E *E+w S *S+w AT *AT+w BT *BT, determine the retention value of the current candidate block; where V is the retention value, w M 、w E and w Sare the dirty state weight, exclusive state weight and shared state weight respectively; M, E and S are the number of shares corresponding to the shared state information in the eviction cache information when the consistency state in the eviction cache information is in the modified state, exclusive state and shared state respectively; w AT and w BT They are the weights when the number of shares exceeds the threshold and the weights when the number of shares does not exceed the threshold respectively; AT is 1 when the number of shares exceeds the threshold, and is 0 when the number of shares does not exceed the threshold; BT is 1 when the number of shares does not exceed the threshold, and is 0 when the number of shares exceeds the threshold.

[0129] In some embodiments, the weight determination submodule may include:

[0130] A first determining unit, configured to determine a weight of each consistency state according to the number of cache entries in the eviction history information set and the consistency state of each cache entry;

[0131] The second determination unit is used to determine the weight of the shared quantity exceeding the threshold value and the weight of the shared quantity not exceeding the threshold value according to the number of cache entries in the eviction history information set, the first number, and the second number; wherein the first number is the number of cache entries whose shared quantity corresponding to the shared status information exceeds the quantity threshold, and the second number is the number of cache entries whose shared quantity corresponding to the shared status information does not exceed the quantity threshold.

[0132] In some embodiments, the apparatus may further include:

[0133] An entry determination module, used to determine whether the number of cache entries in the eviction history information set meets the requirement; if it meets the requirement, a start signal is sent to the determination module 20;

[0134] The direct eviction module is used to evict the current candidate block from the target cache area if it does not meet the requirements, and add the cache entry corresponding to the eviction cache information to the eviction history information set.

[0135] In some embodiments, the eviction history information set is an eviction history table, and the entry judgment module is specifically used to judge whether the number of cache entries in the eviction history table reaches a preset evaluation number; if it reaches the preset evaluation number, a start signal is sent to the determination module 20; if it does not reach the preset evaluation number, a start signal is sent to the direct eviction module.

[0136] In some embodiments, the eviction module 50 may include:

[0137] A replacement determination submodule, configured to determine a target cache entry according to a storage time, a miss time and / or a current retention value of each cache entry in the eviction history information set if the number of cache entries in the eviction history information set is a preset full number;

[0138] The eviction submodule is used to replace the target cache entry with the cache entry corresponding to the eviction cache information.

[0139] In some embodiments, the replacement determination submodule may be specifically configured to determine the cache entry with the longest miss time in the eviction history information set as the target cache entry.

[0140] In some embodiments, the cache entry also includes address information, threshold comparison information and a valid bit; the sharing status information in the cache entry is a sharer vector bit, and the threshold comparison information is used to indicate whether the sharing quantity corresponding to the sharer vector bit exceeds the quantity threshold.

[0141] In some embodiments, the cache replacement algorithm is a least recently used algorithm.

[0142] In some embodiments, the processor employs a cache architecture of at least two layers, and the target cache region comprises a bottom layer cache of the cache architecture.

[0143] In some embodiments, the determination module 20 can be specifically used to determine whether the retention value is greater than a value threshold; if it is greater than the value threshold, it is determined to retain the current candidate block and a start signal is sent to the retention module 40; if it is not greater than the value threshold, it is determined not to retain the current candidate block and a start signal is sent to the eviction module 50.

[0144] In some embodiments, the acquisition module 10 may include:

[0145] Access acquisition submodule, used to obtain cache access requests;

[0146] A cache check submodule, used to check whether a cache access request hits cache data in a cache of a processor;

[0147] The replacement selection submodule is used to use the cache replacement algorithm to determine the current candidate block in the target cache area if there is a miss, and obtain the eviction cache information of the current candidate block.

[0148] In some embodiments, the apparatus may further include:

[0149] An entry checking module, used to check whether the obtained cache access request hits the cache entry in the eviction history information set;

[0150] A negative reward module is used to delete the hit cache entry from the eviction history information set if the hit cache entry in the eviction history information set is hit.

[0151] In some embodiments, the retention module 40 may include:

[0152] The positive reward submodule is used for updating the consistency state weights, the sharing quantity exceeding threshold weights and the sharing quantity not exceeding threshold weights corresponding to the eviction history information set according to the eviction cache information, before taking the next candidate block as the current candidate block and executing the step of determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set, if the cache access request does not hit the cache entry in the eviction history information set.

[0153] In some embodiments, the positive reward submodule may include:

[0154] A first calculation unit is used to calculate the sum of the target consistency state weight and the first learning rate to obtain an updated target consistency state weight; wherein the target consistency state weight is a consistency state weight corresponding to the consistency state of the eviction cache information;

[0155] A first updating unit, configured to normalize the updated target consistency state weight and other consistency state weights to obtain updated consistency state weights; wherein the sum of the updated consistency state weights is 1;

[0156] A second calculation unit is used to calculate the sum of the target shared state weight and the second learning rate to obtain an updated target shared state weight; wherein the target shared state weight is a shared quantity exceeding a threshold weight or a shared quantity not exceeding a threshold weight corresponding to the shared state information of the evicted cache information;

[0157] The second updating unit is used to normalize the updated target sharing state weight and another sharing state weight to obtain the updated sharing quantity exceeding threshold weight and the sharing quantity not exceeding threshold weight; wherein the sum of the updated sharing quantity exceeding threshold weight and the sharing quantity not exceeding threshold weight is 1.

[0158] In this embodiment, the embodiment of the present invention can determine the retention value of the current candidate block selected by the cache replacement algorithm by using the consistency state and sharing state information of the evicted cache block in the eviction history information set through the determination module 20, so as to judge whether the current candidate block may be accessed again in the future, thereby optimizing the cache replacement algorithm in the multi-core processor, improving the adaptability and cache hit rate of the cache replacement strategy, and reducing the performance loss caused by cache misses; and because the eviction history information set does not need to store specific cache block data, compared with the method of increasing the cache capacity to improve the cache hit rate, the hardware overhead is smaller.

[0159] Corresponding to the above method embodiment, the embodiment of the present invention further provides a processor. The processor described below and the cache control method described above can refer to each other.

[0160] Please refer to Figure 8 , Figure 8 A schematic diagram of the structure of a processor provided by an embodiment of the present invention. The processor may include:

[0161] A memory D1, for storing computer programs;

[0162] The cache controller D2 is used to implement the steps of the cache control method provided in the above method embodiment when executing a computer program.

[0163] The processor provided in this embodiment may be specifically a central processing unit (CPU), or may be specifically other types of processors, such as a graphics processing unit (GPU).

[0164] Corresponding to the above method embodiment, an embodiment of the present invention further provides a computer program product. The computer program product described below and the cache control method described above can be referred to in correspondence with each other.

[0165] A computer program product includes a computer program / instruction, which implements the steps of the cache control method provided by the above method embodiment when executed by a processor.

[0166] Corresponding to the above method embodiment, an embodiment of the present invention further provides a computer-readable storage medium. The computer-readable storage medium described below and the cache control method described above can be referred to in correspondence with each other.

[0167] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the cache control method of the above method embodiment are implemented.

[0168] The computer-readable storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., which can store program codes.

[0169] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the device, processor, computer program product and computer-readable storage medium disclosed in the embodiment, since they correspond to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.

[0170] The above is a detailed introduction to a cache control method, device, program product, processor and storage medium provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the present invention.

Claims

1. A cache control method, characterized in that: Cache controller for processors, including: Obtaining eviction cache information of a current candidate block in a target cache area; wherein the current candidate block is a cache data to be evicted selected by a cache replacement algorithm, and the eviction cache information includes consistency state and sharing state information; Determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set; wherein the cache entries include the consistency state and sharing state information of the evicted cache data; Determining whether to retain the current candidate block according to the retention value and the value threshold; If yes, obtaining the eviction cache information of the next candidate block in the target cache area, taking the next candidate block as the current candidate block, and executing the step of determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set; If not, the current candidate block is evicted from the target cache area, and a cache entry corresponding to the evicted cache information is stored in the evicted history information set.

2. The cache control method according to claim 1, characterized in that: Determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set includes: Determine, according to each cache entry in the eviction history information set, each consistency state weight, each sharing quantity exceeding a threshold weight, and each sharing quantity not exceeding a threshold weight; The retention value of the current candidate block is determined according to the consistency state weight, the sharing quantity exceeding the threshold weight, the sharing quantity not exceeding the threshold weight, and the consistency state and sharing state information in the eviction cache information.

3. The cache control method according to claim 2, characterized in that: The consistency state is a state in the modified-exclusive-shared-invalidated protocol, and the consistency state weight includes a dirty state weight, an exclusive state weight, and a shared state weight; according to each of the consistency state weights, the shared quantity exceeding a threshold weight, the shared quantity not exceeding a threshold weight, and the consistency state and shared state information in the eviction cache information, determining the retention value of the current candidate block, including: By V=w M *M+w E *E+w S *S+w AT *AT+w BT *BT, determine the retention value of the current candidate block; where V is the retention value, w M 、w E and w S are the dirty state weight, the exclusive state weight and the shared state weight respectively; M, E and S are the shared quantities corresponding to the shared state information in the eviction cache information when the consistency state in the eviction cache information is in the modified state, the exclusive state and the shared state respectively; w AT and w BT They are respectively the weight of the shared quantity exceeding the threshold value and the weight of the shared quantity not exceeding the threshold value; AT is 1 when the shared quantity exceeds the quantity threshold value, and is 0 when the shared quantity does not exceed the quantity threshold value; BT is 1 when the shared quantity does not exceed the quantity threshold value, and is 0 when the shared quantity exceeds the quantity threshold value.

4. The cache control method according to claim 2, characterized in that: Determining, according to each cache entry in the eviction history information set, each consistency state weight, each sharing quantity exceeding a threshold weight, and each sharing quantity not exceeding a threshold weight, including: Determining a weight of each consistency state according to the number of cache entries in the eviction history information set and the consistency state of each cache entry; Determine the weight of the shared quantity exceeding the threshold value and the weight of the shared quantity not exceeding the threshold value according to the number of cache entries in the eviction history information set, the first number, and the second number; wherein the first number is the number of cache entries whose shared quantity corresponding to the shared status information exceeds the quantity threshold, and the second number is the number of cache entries whose shared quantity corresponding to the shared status information does not exceed the quantity threshold.

5. The cache control method according to claim 1, characterized in that: Before determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set, the method further includes: Determining whether the number of cache entries in the eviction history information set meets the requirement; If the requirements are met, the step of determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set is performed; If it does not meet the requirements, the current candidate block is evicted from the target cache area, and a cache entry corresponding to the evicted cache information is added to the evicted history information set.

6. The cache control method according to claim 5, characterized in that: The eviction history information set is an eviction history table, and judging whether the number of cache entries in the eviction history information set meets the requirement includes: Determining whether the number of cache entries in the eviction history table reaches a preset evaluation number; If the preset evaluation number is reached, the step of determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set is performed; If the preset evaluation quantity is not reached, the step of evicting the current candidate block from the target cache area and adding a cache entry corresponding to the evicted cache information to the evicted history information set is performed.

7. The cache control method according to claim 1, characterized in that: Storing the cache entry corresponding to the eviction cache information in the eviction history information set includes: If the number of cache entries in the eviction history information set is a preset full number, determining a target cache entry according to the storage time, miss time and / or current retention value of each cache entry in the eviction history information set; The target cache entry is replaced by the cache entry corresponding to the eviction cache information.

8. The cache control method according to claim 7, characterized in that: Determining a target cache entry according to the storage time, miss time and / or current retention value of each cache entry in the eviction history information set includes: The cache entry with the longest miss time in the eviction history information set is determined as the target cache entry.

9. The cache control method according to claim 1, characterized in that: The cache entry also includes address information, threshold comparison information and a valid bit; the sharing status information in the cache entry is a sharer vector bit, and the threshold comparison information is used to indicate whether the sharing quantity corresponding to the sharer vector bit exceeds a quantity threshold.

10. The cache control method according to claim 1, characterized in that: The cache replacement algorithm is a least recently used algorithm.

11. The cache control method according to claim 1, characterized in that: The processor adopts a cache architecture of at least two layers, and the target cache area includes a bottom layer cache of the cache architecture.

12. The cache control method according to claim 1, characterized in that: According to the retention value and the value threshold, determining whether to retain the current candidate block includes: determining whether the retention value is greater than the value threshold; If it is greater than the value threshold, it is determined to retain the current candidate block; If it is not greater than the value threshold, it is determined not to retain the current candidate block.

13. The cache control method according to claim 1, characterized in that: Get the eviction cache information of the current candidate block in the target cache, including: Get cache access request; Checking whether the cache access request hits cache data in the cache of the processor; If there is a miss, the cache replacement algorithm is used to determine the current candidate block in the target cache area, and obtain the eviction cache information of the current candidate block.

14. The cache control method according to any one of claims 1 to 13, characterized in that: Also includes: Checking whether the obtained cache access request hits a cache entry in the eviction history information set; If a cache entry in the eviction history information set is hit, the hit cache entry is deleted from the eviction history information set.

15. The cache control method according to claim 14, characterized in that: Before taking the next candidate block as the current candidate block and executing the step of determining the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set, the method further includes: If the cache access request does not hit a cache entry in the eviction history information set, the consistency state weights, the sharing quantity exceeding threshold weights and the sharing quantity not exceeding threshold weights corresponding to the eviction history information set are updated according to the eviction cache information.

16. The cache control method according to claim 15, characterized in that: According to the eviction cache information, the consistency state weights, the weights of the number of shares exceeding the threshold, and the weights of the number of shares not exceeding the threshold corresponding to the eviction history information set are updated, including: Calculate the sum of the target consistency state weight and the first learning rate to obtain an updated target consistency state weight; wherein the target consistency state weight is the consistency state weight corresponding to the consistency state of the eviction cache information; Normalize the updated target consistency state weight and other consistency state weights to obtain updated consistency state weights; wherein the sum of the updated consistency state weights is 1; Calculate the sum of the target shared state weight and the second learning rate to obtain an updated target shared state weight; wherein the target shared state weight is a shared quantity exceeding a threshold weight or a shared quantity not exceeding a threshold weight corresponding to the shared state information of the eviction cache information; The updated target sharing state weight and another sharing state weight are normalized to obtain the updated sharing quantity exceeding threshold weight and the sharing quantity not exceeding threshold weight; wherein the sum of the updated sharing quantity exceeding threshold weight and the sharing quantity not exceeding threshold weight is 1.

17. A cache control device, characterized in that: Cache controller for processors, including: An acquisition module is used to acquire eviction cache information of a current candidate block in a target cache area; wherein the current candidate block is a cache data to be evicted selected by a cache replacement algorithm, and the eviction cache information includes consistency state and sharing state information; A determination module, configured to determine the retention value of the current candidate block according to the eviction cache information and the cache entries in the eviction history information set; wherein the cache entries include the consistency state and sharing state information of the evicted cache data; A judgment module, used for judging whether to retain the current candidate block according to the retention value and the value threshold; A retaining module, configured to obtain eviction cache information of a next candidate block in the target cache area if the current candidate block is retained, and use the next candidate block as the current candidate block, and send a start signal to the determining module; The eviction module is used to evict the current candidate block from the target cache area if the current candidate block is not retained, and store the cache entry corresponding to the eviction cache information in the eviction history information set.

18. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the cache control method according to any one of claims 1 to 16 are implemented.

19. A processor, characterized in that: include: Memory for storing computer programs; A cache controller, configured to implement the steps of the cache control method according to any one of claims 1 to 16 when executing the computer program.

20. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the cache control method according to any one of claims 1 to 16 are implemented.

Citation Information

Patent Citations

  • Multi-core processor directory cache replacement method

    CN104778132A

  • Catalog replacement method and system for directory-based cache consistency

    CN106909517A

  • Request processing method and device based on cache consistency directory, equipment and medium

    CN118260304A

  • Delay cache replacement method and device, equipment, storage medium and product

    CN119276939A

  • Multi-core processor cache coherence for reduced off-chip traffic

    EP2244189A1