CN-122019413-A - Cache management method, cache, computing device and system
Abstract
The embodiment of the disclosure provides a cache management method, a cache, a computing device and a system, and relates to the technical field of chips. The cache management method comprises the steps of determining a first cache line used for storing a target object accessed by a cache access request from a plurality of cache lines of a cache according to the obtained cache access request, detecting whether the current hit number of the first cache line is greater than or equal to a preset expected hit number threshold value when attribute information of the first cache line meets a first setting condition, wherein the first setting condition comprises that the replacement priority of the first cache line is the first priority, and adjusting the replacement priority of the first cache line from the first priority to the second priority if the current hit number of the first cache line is greater than or equal to the expected hit number threshold value, wherein the cache line of the second priority is replaced before the cache line of the first priority in a cache replacement operation.
Inventors
- Request for anonymity
- Request for anonymity
Assignees
- 上海壁仞科技股份有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260402
Claims (14)
- 1. A method for cache management, applied to a cache, the method comprising: determining a first cache line for storing a target object accessed by the cache access request from a plurality of cache lines of the cache according to the acquired cache access request; Detecting whether the current hit number of the first cache line is greater than or equal to a set expected hit number threshold when the attribute information of the first cache line meets a first set condition, wherein the first set condition comprises that the replacement priority of the first cache line is a first priority; And if the current hit number of the first cache line is greater than or equal to the expected hit number threshold, adjusting the replacement priority of the first cache line from the first priority to a second priority, wherein the cache line of the second priority is replaced before the cache line of the first priority in a cache replacement operation.
- 2. The method of claim 1, wherein the step of determining the position of the substrate comprises, The cache includes at least one candidate counter; The attribute information of the first cache line comprises a counter identifier, wherein the counter identifier is used for representing whether the first cache line is allocated with a first counter used for recording the number of times of the first cache line hit from the candidate counters, and the first setting condition further comprises that the first cache line is allocated with the first counter.
- 3. The method of claim 2, wherein the detecting whether the current hit count of the first cache line is greater than or equal to a set expected hit count threshold comprises: Updating a first counter corresponding to the first cache line when the first cache line is hit; detecting whether a current hit count of the first cache line is greater than or equal to the expected hit count threshold based on the first counter.
- 4. The method of claim 3, wherein a first initial value assigned to the first cache line by the first counter is configured to be greater than or equal to the expected hit count threshold; The updating of the first counter corresponding to the first cache line comprises the steps of subtracting the value of the first counter; The detecting whether the current hit number of the first cache line is greater than or equal to the expected hit number threshold based on the first counter comprises determining that the current hit number of the first cache line is greater than or equal to the expected hit number threshold when the updated value of the first counter is less than or equal to a preset target value, wherein the preset target value is a value determined based on the first initial value and the expected hit number threshold.
- 5. The method of claim 2, wherein the determining a first cache line from the plurality of cache lines of the cache for storing the target object accessed by the cache access request comprises: if the cache access request misses the cache, a first cache line is allocated for the target object, a replacement priority of the first cache line is configured as a first priority, an expected hit count threshold of the first cache line is determined, the first counter is allocated for the first cache line, and a counter identification is configured for the first cache line, or And if the cache access request hits the cache, taking the hit cache line as the first cache line.
- 6. The method of claim 5, wherein allocating the first counter for the first cache line and configuring the value of the counter identification for the cache line comprises: When there is a candidate counter in the idle state in the cache, allocating the candidate counter in the idle state as a valid first counter to the first cache line, configuring the counter identification of the first cache line as the identification of the first counter, or And when the candidate counter in the idle state does not exist in the cache, determining that the first cache line is not allocated with a valid first counter, and configuring the counter identification of the first cache line as an invalid identification representing the first counter which is not allocated.
- 7. The method according to claim 2, wherein the method further comprises: for a second cache line meeting a second set condition, detecting whether the duration of the miss of the second cache line is greater than or equal to a set expected duration threshold; And if the duration time is greater than or equal to the expected duration time threshold, adjusting the replacement priority of the second cache line from the second priority to a third priority, wherein the cache line of the third priority is replaced before the cache line of the second priority in the cache replacement operation, and the second setting condition comprises that the replacement priority of the second cache line is the second priority.
- 8. The method of claim 7, wherein the second set of conditions further comprises the second cache line being assigned a second counter, the second counter being used to count a duration of time the second cache line is missed; The detecting whether the duration of the miss of the second cache line is greater than or equal to a set expected duration threshold value comprises: Configuring a value of the second counter to a second initial value when the second cache line is hit, and periodically updating the second counter corresponding to the second cache line based on the cached timer; determining whether the duration is greater than or equal to the expected duration threshold based on the updated second counter.
- 9. The method of claim 8, wherein the step of determining the position of the first electrode is performed, The second cache line and the first cache are the same target cache line, and the second counter and the first counter are the same target counter in the at least one candidate counter; when the replacement priority of the target cache line is adjusted from the first priority to a second priority, the second initial value is determined based on the expected duration threshold, and the value of the target counter is configured to be the second initial value.
- 10. The method of any one of claims 1 to 9, wherein the target object is an instruction object and the expected hit count threshold is a count threshold determined based on the number of threads executing the instruction object.
- 11. The method according to any one of claims 1 to 9, wherein, The cache is a last level cache of a computing device, the last level cache comprising a plurality of cache lines for storing instruction objects and/or data objects; The cache access request includes an indication field for indicating whether the target object is an instruction object.
- 12. A cache for performing the method of any of claims 1 to 11.
- 13. A computing device, comprising: a plurality of computing units; a cache, the cache being connected to the computing unit, the cache being for performing the method of any one of claims 1 to 11.
- 14. A computing system comprising a control device for controlling the computing device to perform a computing task and the computing device of claim 13.
Description
Cache management method, cache, computing device and system Technical Field The present disclosure relates to the field of chip technologies, and in particular, to a cache management method, a cache, a computing device, and a system. Background Computing devices represented by graphics processors (Graphics Processing Unit, GPUs) are widely used in the field of general computing, and have become core hardware in application scenarios such as artificial intelligence (ARTIFICIAL INTELLIGENCE, AI) and scientific computing. In such applications, instructions and data executed by a program are typically stored in memory, read and operated on by a computing unit (or computing core) within the computing device. With the processing speed of the computing unit far exceeding the access speed of the memory, the memory access has severely restricted the computing performance, and in order to alleviate this speed difference, a cache (cache) may be provided in the computing device, for temporarily storing recently accessed instructions and/or data. Because the access delay of the cache is far lower than that of the memory, the computing unit preferentially acquires the instruction and/or the data from the cache, and the processing efficiency of the computing device can be improved. Due to the limited capacity of the cache, in order to improve the utilization efficiency of the cache resources, when the cache is full and new instructions and/or data need to be stored, an appropriate cache line can be selected in the cache to replace the cache data based on the replacement priority. In the related art, a replacement priority may be set for each cache line when the respective cache lines are allocated, and when the cache is full and needs replacement, a cache line may be preferentially selected from the cache lines with the highest replacement priority for replacement. However, in practical application, the method has the problems that a cache which is not accessed cannot be replaced in time, and the like, so that the cache utilization rate is low, and the performance of the computing equipment is affected. Disclosure of Invention It is an object of embodiments of the present disclosure to provide a new solution regarding cache management. According to a first aspect of an embodiment of the present disclosure, there is provided a cache management method applied to a cache, the method including: determining a first cache line for storing a target object accessed by the cache access request from a plurality of cache lines of the cache according to the acquired cache access request; Detecting whether the current hit number of the first cache line is greater than or equal to a set expected hit number threshold when the attribute information of the first cache line meets a first set condition, wherein the first set condition comprises that the replacement priority of the first cache line is a first priority; And if the current hit number of the first cache line is greater than or equal to the expected hit number threshold, adjusting the replacement priority of the first cache line from the first priority to a second priority, wherein the cache line of the second priority is replaced before the cache line of the first priority in a cache replacement operation. Optionally, the cache includes at least one candidate counter; The attribute information of the first cache line comprises a counter identifier, wherein the counter identifier is used for representing whether the first cache line is allocated with a first counter used for recording the number of times of the first cache line hit from the candidate counters, and the first setting condition further comprises that the first cache line is allocated with the first counter. Optionally, the detecting whether the current hit number of the first cache line is greater than or equal to a set expected hit number threshold includes: Updating a first counter corresponding to the first cache line when the first cache line is hit; detecting whether a current hit count of the first cache line is greater than or equal to the expected hit count threshold based on the first counter. Optionally, the first initial value of the first counter allocated to the first cache line is configured to be greater than or equal to the expected hit number threshold; The updating of the first counter corresponding to the first cache line comprises the steps of subtracting the value of the first counter; The detecting whether the current hit number of the first cache line is greater than or equal to the expected hit number threshold based on the first counter comprises determining that the current hit number of the first cache line is greater than or equal to the expected hit number threshold when the updated value of the first counter is less than or equal to a preset target value, wherein the preset target value is a value determined based on the first initial value and the expected hit number threshold. Option