Data prefetching method and device

By obtaining address history records and predicting the number and distance of address jumps, high-coverage and high-accuracy data prefetching is achieved in the processor, solving the problem of mismatch between data processing speed and memory access speed and improving processor performance.

CN114721974BActive Publication Date: 2025-09-19HYGON INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210177713.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-25
Publication Date
2025-09-19
Estimated Expiration
2042-02-25

AI Technical Summary

Technical Problem

The existing technology has a problem in the processor that the data processing speed is much faster than the data memory access speed, which causes the processor to wait for memory data to return, resulting in a low cache hit rate and affecting overall performance.

Method used

By obtaining the address to be accessed and the access address history, the number of prefetch address jumps and the reference address distance are determined, and this information is used to predict and fetch data from the memory to the cache in advance, supporting data prefetching in non-single address interval access modes.

Benefits of technology

It improves the coverage and accuracy of data prefetching, reduces cache misses, and improves the overall performance of the processor while being compatible with the existing single address interval access mode.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114721974B_ABST
    Figure CN114721974B_ABST
Patent Text Reader

Abstract

The embodiments of the present disclosure provide a data prefetching method, apparatus, computer program product and computer-readable storage medium that support non-single address interval access modes. The method provided by the embodiments of the present disclosure obtains an address to be accessed and an access address history record; determines the number of prefetch address jumps based on the access address history record; determines a reference address distance based on the access address history record and the determined number of prefetch address jumps; and determines a prefetch address for data prefetching based on the determined reference address distance and the address to be accessed. The data prefetching method provided by the embodiments of the present disclosure improves the coverage of prefetching, reduces cache misses, and improves the accuracy of prefetching. In addition, the prefetching method has low storage overhead and running overhead, and is fully compatible with the existing prefetching of single address interval access modes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computers and processors, and more particularly, to a data prefetching method, apparatus, computer program product, and computer-readable storage medium. Background Art

[0002] As computing demands grow rapidly and the total amount of data continues to expand, in order to match the computer's data storage and processing capabilities, how to improve data access efficiency is one of the key research directions of computers and processors.

[0003] Modern processors are developing rapidly, but memory is developing more slowly. Data processing speed far outstrips memory access speed, forcing processors to spend significant time waiting for data to be returned from memory. Caching technology allows faster upper-level memory to act as a buffer for lower-level memory. If a cache hit occurs, data in the upper-level memory can be read or written directly. However, a cache miss requires many clock cycles to move data from memory to the cache, potentially stalling the central processing unit (CPU) pipeline during this time, resulting in significant cost. To address this issue, current cache designs often employ prefetching technology. Prefetching predicts future access addresses and preemptively fetches data from memory into the CPU's internal cache, or from a lower-level cache to a higher-level cache. When a computer accesses a memory address, it first checks the cache to see if the data for that address exists. If so, the data is directly read from the cache, resulting in a cache hit. If the data is not in the cache, the data must be read from memory, resulting in a cache miss. If the prediction is accurate, the data will be ready in the cache when it is actually needed, thus "hiding" the memory access latency and improving the overall performance of the processor.

[0004] Therefore, a data prefetching method with high prefetch coverage, high accuracy and low cache miss efficiency is needed to improve the problem of mismatch between data processing speed and data access speed, thereby improving the data processing efficiency of the computer. Summary of the Invention

[0005] In order to solve the above problems, the present invention obtains the address to be accessed and the access address history record; determines the number of prefetch address jumps according to the access address history record; determines the reference address distance based on the access address history record and the determined number of prefetch address jumps; and determines the prefetch address for data prefetching based on the determined reference address distance and the address to be accessed.

[0006] The data prefetching method provided by the embodiments of the present disclosure supports non-single address interval access modes, improving prefetch coverage, reducing cache misses, and increasing prefetch accuracy. Furthermore, the prefetching method has low storage and runtime overhead and is fully compatible with existing prefetching using a single address interval access mode.

[0007] Embodiments of the present disclosure provide a data pre-fetching method and device.

[0008] An embodiment of the present disclosure provides a data prefetching method, which includes: obtaining an address to be accessed and an access address history record; determining the number of prefetch address jumps based on the access address history record; determining a reference address distance based on the access address history record and the determined number of prefetch address jumps; and determining a prefetch address for data prefetching based on the determined reference address distance and the address to be accessed.

[0009] An embodiment of the present disclosure provides a data prefetching method, wherein the data prefetching method includes: a prefetching training process and a data prefetching process, wherein the prefetching training process trains the address distance and the number of reference prefetching address jumps based on the access address history record, wherein, when the training is completed, the number of prefetching address jumps is the trained reference prefetching address jump number, and the reference address distance is the trained address distance; the data prefetching process determines the prefetching address for data prefetching based on the determined reference address distance and the address to be accessed.

[0010] An embodiment of the present disclosure provides a data prefetching method, wherein the training of the reference address distance and the training of the prefetch address jump number are performed in association, wherein, during the prefetching training process, the prefetch address jump number is determined based on the access address history record, and further comprises: obtaining the reference prefetch address jump number; for a first address in the access address history record, determining the access address obtained after jumping according to the reference prefetch address jump number in the access address history record as the second address; determining the address distance between the first address and the second address; and performing at least one of the following operations based on the recorded address distance and the determined address distance: in the case where the recorded address distance is an invalid value, updating the recorded address distance using the determined address distance, and updating the recorded address distance using the second address. first address; when the recorded address distance is a valid value, the determined address distance is not equal to the recorded address distance, and the reference prefetch address jump number does not exceed the first threshold, the reference prefetch address jump number is increased, the recorded address distance is set to an invalid value, or the recorded address distance is not updated, and the first address is updated using the second address; when the recorded address distance is a valid value, the determined address distance is not equal to the recorded address distance, and the reference prefetch address jump number exceeds the first threshold, the reference prefetch address jump number is initialized, the address distance is retrained, and the first address is updated using the second address; when the recorded address distance is a valid value and the determined address distance is equal to the recorded address distance, the first address is updated using the second address.

[0011] An embodiment of the present disclosure provides a data prefetching method, wherein, during the prefetching training process, a reference address distance is determined based on the access address history record and the determined number of prefetching address jumps, and further includes: using the reference prefetching address jump number stored when the training is completed as the prefetching address jump number, and determining the reference address distance based on the number of prefetching address jumps obtained from the training, and the first address and the second address corresponding to the time when the training is completed; or using the address distance stored when the training is completed as the reference address distance, wherein the stored address distance is associated with the number of prefetching address jumps and the first address when the training is completed.

[0012] An embodiment of the present disclosure provides a data prefetching method, wherein, during the data prefetching process, the prefetching address to be prefetched is determined based on the determined reference address distance and the address to be accessed, and further includes: obtaining the number of prefetching address jumps; for the first address in the access address history record, determining the access address obtained after jumping according to the number of prefetching address jumps in the access address history record as the second address; determining the address distance between the first address and the second address; and performing at least one of the following operations based on the reference address distance and the determined address distance: when the determined address distance is equal to the reference address distance, increasing the number of repetitions of the recorded address distance, and updating the first address with the second address; when the determined address distance is not equal to the reference address distance, decreasing the number of repetitions of the recorded address distance, and when the number of repetitions of the reference address distance is lower than a third threshold, retraining the address distance, and updating the first address with the second address; or when the determined address distance is not equal to the reference address distance, retraining the address distance, and updating the first address with the second address.

[0013] An embodiment of the present disclosure provides a data prefetching device, which includes: an access address acquisition module, configured to acquire an address to be accessed and an access address history record; a prefetch address jump number determination module, configured to determine the number of prefetch address jumps based on the access address history record; a reference address distance determination module, configured to determine a reference address distance based on the access address history record and the determined number of prefetch address jumps; and a prefetch address determination module, configured to determine a prefetch address for data prefetching based on the determined reference address distance and the address to be accessed.

[0014] An embodiment of the present disclosure provides a computer program product, which includes computer software code. When the computer software code is executed by a processor, it provides the above method.

[0015] An embodiment of the present disclosure provides a computer-readable storage medium having computer-executable instructions stored thereon, which, when executed by a processor, provide the above method.

[0016] The embodiments of the present disclosure provide a data prefetching method, apparatus, computer program product, and computer-readable storage medium. The data prefetching method provided by the embodiments of the present disclosure improves the coverage of prefetching, reduces cache misses, and improves the accuracy of prefetching. In addition, the prefetching method has low storage overhead and operation overhead, and can support data prefetching in a single address interval access mode with the same address interval between adjacent addresses, and can also support data prefetching in a non-single address interval access mode with a fixed address distance between access addresses after a fixed number of addresses, and has stronger compatibility and universality. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] To more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some exemplary embodiments of the present disclosure, and those skilled in the art can derive other drawings based on these drawings without inventive effort.

[0018] Figure 1 is a schematic diagram illustrating a memory hierarchy structure according to an embodiment of the present disclosure;

[0019] Figure 2 is a schematic diagram illustrating a prefetcher structure for prefetching data according to an address interval according to an embodiment of the present disclosure;

[0020] Figure 3 is a schematic flow chart illustrating prefetching data according to address intervals according to an embodiment of the present disclosure;

[0021] Figure 4 is a schematic flow chart illustrating a method for prefetching data according to an embodiment of the present disclosure;

[0022] Figure 5 is a schematic diagram illustrating a prefetcher structure for prefetching data according to address distance according to an embodiment of the present disclosure;

[0023] Figure 6 is a schematic flow chart illustrating prefetching data according to address distance according to an embodiment of the present disclosure;

[0024] Figure 7 is a schematic flow chart illustrating a method for calculating address distance according to an embodiment of the present disclosure;

[0025] Figure 8 is a schematic diagram illustrating a data prefetching device according to an embodiment of the present disclosure; and

[0026] Figure 9 is a schematic diagram illustrating a storage medium according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0027] In order to make the purpose, technical solutions and advantages of the present disclosure more apparent, the following will describe in detail exemplary embodiments of the present disclosure with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all the embodiments of the present disclosure, and it should be understood that the present disclosure is not limited to the exemplary embodiments described herein.

[0028] Furthermore, in this specification and the drawings, steps and elements having substantially the same or similar features are denoted by the same or similar reference numerals, and repeated descriptions of these steps and elements will be omitted.

[0029] In addition, in this specification and the drawings, elements are described in singular or plural form, depending on the embodiment. However, the singular and plural forms are appropriately selected for the situations presented merely for convenience of explanation and are not intended to limit the present disclosure thereto. Therefore, the singular form may include the plural form, and the plural form may also include the singular form, unless the context clearly indicates otherwise.

[0030] In addition, in this specification and the drawings, the terms "first\second" are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It is understandable that "first\second" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present invention described herein can be implemented in an order other than that illustrated or described herein.

[0031] Prefetching technology is to issue a prefetch request before the cache is likely to fail, so that the data is stored in the cache in advance when it is actually used, thereby avoiding processor stalls caused by cache failure. As a part of the processor, the prefetcher can predict the address. Its implementation method is: through the "historical" addresses that have been accessed, it finds the rules or access patterns between the access addresses, and then infers the addresses to be accessed in the future based on the current access address. As an example, the data prefetching method provided by the embodiment of the present disclosure can be used to fetch data from the memory to the cache located inside the central processing unit, or to fetch data from the lower-level cache to the higher-level cache in advance (for example, L2 cache to L1 cache).

[0032] In summary, the solutions provided by the embodiments of the present disclosure relate to the fields of prefetch technology, processors, etc. The embodiments of the present disclosure will be further described below with reference to the accompanying drawings.

[0033] Figure 1 Schematic diagram showing a memory hierarchy structure according to an embodiment of the present disclosure. Figure 1As shown in the figure, computers have multiple types of memory. L0 memory is the register, located in the CPU. Cache is located between the register and the main memory and is typically composed of static random access memory (SRAM). Cache includes L1 cache, L2 cache, and L3 cache, with storage levels decreasing in order from L1 to L3. L4 memory is the main memory and is typically composed of dynamic random access memory (DRAM). L5 memory is local secondary storage, typically consisting of a local disk. L6 memory is remote secondary storage, typically consisting of distributed file systems, web servers, and so on.

[0034] The relationship between the various levels of memory is as follows: CPU registers store data from cache memory; L1 cache stores data from L2 cache; L2 cache stores data from L3 cache; L3 cache stores data from main memory; main memory stores data from local disk; local disk stores data from remote network servers. The capacity, processing speed and price of each memory have Figure 1 The relationship shown is that from L6 level memory to L0 level memory, the storage capacity becomes smaller, the processing speed becomes faster, and the price becomes higher.

[0035] During program processing, main memory (i.e., memory) stores all the data and instructions required for program execution. Because cache access speeds are much faster than memory, when the processor needs to read or write data, it first fetches the data from memory into the cache. The cache stores a copy of the data in memory, and then directly reads and writes the data copy in the cache to reduce memory access latency. To speed up memory access, a prefetcher module in the processor predicts some of the data to be accessed and fetches this data from memory into the cache in advance. When the data is actually needed, it directly accesses the data already prepared in the cache, effectively saving memory access time.

[0036] It should be understood that the data prefetching method provided by the embodiments of the present disclosure is not only applicable to the case from memory to cache, but also the data prefetching from L3 cache to L2 cache, from L2 cache to L1 cache, and so on, from low-speed (large-capacity) memory to high-speed (small-capacity) memory can use the data prefetching method provided by the present disclosure to achieve the purpose of improving prefetch coverage, reducing cache misses, improving prefetch accuracy, and enhancing prefetch stability.

[0037] Current data prefetching typically uses a fixed address interval access mode. This approach can identify access patterns with a single address interval, but cannot identify relatively complex access patterns with non-single address intervals. Furthermore, under this fixed address interval access mode, non-single address intervals can sometimes be misidentified as single address intervals, leading to erroneous prefetching. This will be explained in detail below with reference to the following embodiments.

[0038] Figure 2 FIG. 4 is a schematic diagram illustrating a prefetcher structure for prefetching data according to an address interval according to an embodiment of the present disclosure.

[0039] like Figure 2 As shown, the prefetcher includes: storage records of the access address, the previous access address, the address interval, and the prefetch status. For each memory access instruction, the computer stores the access address and forms a historical record of the access address. The interval between the addresses can be obtained by subtracting the address of the current access from the address of the previous access. If the two address intervals are the same, the number of repetitions of the address interval is increased by 1. If the number of repetitions of the address interval reaches a predetermined number, it is considered that the address access has a fixed address interval, the prefetch training is successful, and a fixed address interval is obtained. After the prefetch training is completed, it enters the data prefetch stage. The computer adds the address to be accessed each time to the address interval obtained through training to obtain the prefetched address, backs it up from the memory in advance and stores it in the cache. When the prefetch address is used later, the computer can directly read the data from the cache, thereby effectively reducing the memory access time.

[0040] For example, for the address access sequence: A, A+2, A+4, A+6..., the address intervals between two adjacent access addresses are 2, 2, 2..., with a fixed address interval of 2 between them. Assuming that the address interval appears twice, that is, prefetch training is successful, then when accessing address sequence A+2, address interval 2 appears for the first time. When accessing address sequence A+4, address interval 2 appears for the second time. At this time, prefetch training is successful, and address A+6 (4+2=6) is prefetched in advance. When accessing address A+6, this address has already been stored in the cache in advance, and the computer can read the data directly from the cache, thereby effectively reducing memory access time.

[0041] Figure 3 FIG. 4 is a schematic flow chart illustrating prefetching data according to address intervals according to an embodiment of the present disclosure.

[0042] like Figure 3As shown, the process of prefetching data according to the address interval mainly includes a prefetch training process and a data prefetch process. The prefetch training process trains the address interval to be used for data prefetching, and the data prefetch process determines the prefetch address to be prefetched based on the determined address interval and the previously recorded address interval.

[0043] During the prefetch training process, the address interval is determined based on the address difference between the current address to be accessed and the previous address to be accessed.

[0044] In the early stage of prefetch training, there may be no recorded address interval. In this case, the recorded address interval is updated using the currently determined address interval.

[0045] After determining the address interval, determine whether the address interval calculated in the previous step is the same as the historical address interval.

[0046] If a recorded address interval exists and the determined address interval is different from the recorded address interval, the number of repetitions of the recorded address interval is decremented, and the next address to be accessed is obtained and the address interval is determined. If the number of repetitions of the recorded address interval is lower than a first threshold, the recorded address interval is retrained. The first threshold here may be 0, but is not limited thereto.

[0047] The figure only shows one processing method. It should be understood that when there is a recorded address interval and the determined address interval is different from the recorded address interval, the recorded address interval can also be directly retrained.

[0048] Optionally, the address distance can be further trained to obtain the address interval for prefetching data. When there is a recorded address interval and the determined address interval is the same as the recorded address interval, the number of repetitions of the recorded address interval is incremented. If the number of repetitions of the recorded address interval does not exceed the second threshold, the address is accessed, the address interval is calculated, and compared with the record of the address interval. If the number of repetitions of the recorded address interval exceeds the second threshold, it is determined that the training of the recorded address interval is completed. It should be noted that the second threshold here is set in advance based on experience and prefetching data requirements. Its purpose is to verify that the recorded address interval appears multiple times and there is a regularity between the addresses to be accessed.

[0049] After the pre-fetch training process is completed, the data pre-fetch process begins.

[0050] During the data prefetch process, the address still needs to be accessed. The address interval is calculated according to a method similar to the prefetch training process and compared with the recorded address interval. It should be noted that in this stage, the recorded address interval is the address interval that has undergone prefetch training.

[0051] During data prefetching, when the determined address interval is the same as the recorded address interval, the number of repetitions of the recorded address interval is incremented, and data is prefetched based on the recorded address interval; otherwise, when the determined address interval is different from the recorded address interval, the number of repetitions of the recorded address interval is decremented, and data prefetching continues according to the recorded address interval, and when the number of repetitions of the recorded address interval is lower than a third threshold, the recorded address interval is retrained.

[0052] The figure shows only one processing method. It should be understood that when the determined address interval is different from the recorded address interval, the recorded address interval can also be directly retrained. The third threshold here can be 0, but is not limited thereto.

[0053] Optionally, in the prefetch training process and the data prefetch process, the counter for recording the number of repetitions of the address interval may be the same counter or different counters.

[0054] Through analysis Figure 2 and Figure 3 The data prefetching method described in the previous section prefetches data according to address intervals. It can be found that this data prefetching method has the following limitations:

[0055] 1. Unable to identify access patterns that are not single address intervals

[0056] Figure 2 and Figure 3 The described method of prefetching data by address interval can accurately identify access patterns with a single fixed address interval, but it cannot identify relatively complex access patterns that do not have a single fixed address interval. For example, when traversing a structure array with one character type member (occupying 1 byte of memory), one integer member (occupying 4 bytes of memory), and one double-precision floating-point number member (occupying 8 bytes of memory), the address access sequence is: A, A+1, A+5, A+13, A+14, A+18, A+26, A+27, A+31, A+39, etc., and the sequence formed by two adjacent address intervals is: 1, 4, 8, 1, 4, 8, 1, 4, 8, etc. It can be seen that this address interval is not fixed and unique, but rather a repeating sequence of address intervals (1, 4, 8). The method of prefetching data by address interval cannot identify this non-single address interval access pattern.

[0057] 2. Prefetching that causes errors

[0058] The method of prefetching data based on address intervals can also misidentify access patterns that are not single address intervals as single address interval access patterns, resulting in incorrect prefetches. For example, if a structure array with three consecutive integer members (each occupying 4 bytes of memory) and one double-precision floating-point member (occupying 8 bytes of memory) is accessed, the address access sequence is: A, A+4, A+8, A+16, A+20, A+24, A+32, ..., and the sequence formed by two adjacent address intervals is: 4, 4, 8, 4, 4, 8, .... If the method of prefetching data based on address intervals is used, assuming that the address interval appears twice (prefetch training is successful), the address interval will be identified as 4. When accessing A+8, A+12 will be prefetched. However, A+12 is not in the actual address sequence used, resulting in an incorrect prefetch. Incorrect prefetches not only waste memory bandwidth and block normal memory accesses, but also fetch erroneous data, causing cache contamination and degrading overall system performance.

[0059] To address the above issues, the present disclosure proposes a method for prefetching data based on address distance. This method determines the prefetch address for data prefetching based on a reference address distance. Although the address intervals between adjacent addresses in an address sequence vary, it is possible to have a fixed address distance after jumping a specific number of addresses. The method disclosed herein utilizes the address distance after jumping a specific number of addresses to prefetch data, enabling data prefetching that supports non-single address interval access modes.

[0060] It should be noted that the address interval in this article refers to the interval between two adjacent access addresses, while the address distance refers to the distance between the previously recorded access address and the address obtained by jumping a specific number of addresses from the previously recorded access address. The address distance may be the distance between non-adjacent access addresses. For example, for the address access sequence: A, A+1, A+5, A+13, etc., the address intervals between two adjacent access addresses can be: 1, 4, 8, etc. Assuming that the address distance is determined by jumping two addresses, the address distance between address A and address A+13, obtained by jumping two addresses from address A, is 13.

[0061] Figure 4 is a schematic flow chart 400 illustrating a data prefetching method according to an embodiment of the present disclosure.

[0062] like Figure 4 As shown, in step S401, data prefetching begins. First, the prefetcher obtains the address to be accessed and the access address history record.

[0063] Optionally, the obtained access address can be stored in a prefetcher and updated according to the address access time. For two adjacent access addresses, the address interval between them is generally related to the data type of the accessed data. For example, when the data type of the accessed data is a character type (occupying 1 byte of memory), the address interval between two adjacent access addresses is 1; when the data type of the accessed data is an integer type (occupying 4 bytes of memory), the address interval between two adjacent access addresses is 4; when the data type of the accessed data is a double-precision floating-point type (occupying 8 bytes of memory), the address interval between two adjacent access addresses is 8...

[0064] In step S402 , the prefetcher determines the number of prefetch address jumps based on the access address history record in step S401 .

[0065] It should be understood that generally, for the data prefetching method of the present disclosure, the number of prefetch address jumps is at least one, but the data prefetching method of the present disclosure is also applicable to the case where the number of prefetch address jumps is zero (ie, no jump).

[0066] In step S403 , the prefetcher determines a reference address distance based on the access address history record in step S401 and the number of prefetch address jumps determined in step S402 .

[0067] Optionally, the reference address distance can be a positive number or a negative number. That is, when the access addresses increase in sequence (e.g., A, A+2, A+4, ...), the address interval between two adjacent access addresses is a positive number, and thus the reference address distance is also a positive number; when the access addresses decrease in sequence (e.g., A, A-2, A-4, ...), the address interval between two adjacent access addresses is a negative number, and thus the reference address distance is also a negative number.

[0068] Optionally, in step S403, a first counter for recording the number of prefetch address jumps and a second counter for recording the number of current address jumps may be used to determine the access address obtained after jumping according to the number of prefetch address jumps, thereby determining the reference address distance.

[0069] Finally, in step S404 , based on the determined reference address distance and the address to be accessed, a prefetch address for data prefetching is determined.

[0070] Optionally, Figure 4The reference address distance described in the text is trained, that is, the data prefetching method may include: a prefetching training process and a data prefetching process, wherein the prefetching training process trains the address distance and the number of reference prefetching address jumps based on the access address history record, and when the prefetching training is completed, the number of prefetching address jumps is the trained reference prefetching address jump number, and the reference address distance is the trained address distance; the data prefetching process determines the prefetching address for data prefetching based on the determined reference address distance and the address to be accessed.

[0071] Figure 5 FIG. 4 is a schematic diagram illustrating a prefetcher structure for prefetching data according to address distance according to an embodiment of the present disclosure.

[0072] like Figure 5 As shown, the prefetcher includes storage records of the access address, the previous access address, the number of prefetched address jumps, the number of current address jumps, the address distance, and the prefetch status. It can be seen that the difference between the prefetcher structure that prefetches data based on address distance and the prefetcher structure that prefetches data based on address interval is that the prefetcher that prefetches data based on address interval stores the address interval and prefetches data based on the address interval between two adjacent addresses; while the prefetcher that prefetches data based on address distance stores the address distance and prefetches data based on the address distance. The number of prefetched address jumps and the current address jump number are used to control the update of the previously recorded access address, thereby determining the address distance between the access address and the previously recorded access address. This data prefetching method has low storage and runtime overhead.

[0073] Figure 6 is a schematic flow chart illustrating prefetching data according to address distance according to an embodiment of the present disclosure.

[0074] In order to more clearly illustrate the differences between the method of prefetching data according to address distance and the method of prefetching data according to address interval, Figure 6 In the data prefetching method (i.e. Figure 3 ) Different key steps are shown in grey dotted boxes.

[0075] The data prefetching method disclosed herein may include a prefetching training process and a data prefetching process. The prefetching training process trains to obtain a reference address distance to be used for data prefetching, and the data prefetching process determines a prefetch address to be used for data prefetching based on the determined reference address distance and an address to be accessed.

[0076] After the prefetch training starts, the current address distance is calculated and compared with the record of address distance.

[0077] If it is determined that the current address distance is different from the record of the address distance, continue to determine whether the number of prefetch address jumps exceeds the first threshold. If the number of prefetch address jumps exceeds the first threshold, initialize the reference prefetch address jump number and restart the prefetch training; if the number of prefetch address jumps does not exceed the first threshold, increment the reference prefetch address jump number and continue to calculate the address distance based on the new reference prefetch address jump number.

[0078] If it is determined that the current address distance is the same as the recorded address distance, the number of repetitions of the recorded address distance is increased until the number of repetitions of the recorded address distance exceeds a second threshold, and it is determined that the training of the prefetched address jump number and the reference address distance is completed.

[0079] After the pre-fetch training process is completed, the data pre-fetch process begins.

[0080] After the prefetch training starts, the current address distance is calculated and compared with the reference address distance.

[0081] If it is determined that the current address distance is different from the recorded address distance, the number of repetitions of the recorded address distance is decreased, and data prefetching is continued according to the recorded address distance. When the number of repetitions of the recorded address distance is lower than the third threshold, prefetching training is restarted.

[0082] If it is determined that the current address distance is the same as the recorded address distance, the number of repetitions of the recorded address distance is incremented, and data is continuously pre-fetched based on the recorded address distance.

[0083] More specifically, during the prefetch training process, the reference prefetch address jump number is obtained; for the first address in the access address history record, the access address obtained after jumping according to the reference prefetch address jump number in the access address history record is determined as the second address, and then the address distance between the first address and the second address is determined.

[0084] The address distance between the first address and the second address may be calculated by taking the difference between the first address and the second address, and the determined address distance may be either a positive number or a negative number.

[0085] The initial value of the reference prefetch address jump number may be 0, but is not limited thereto.

[0086] In the early stage of training, there may be no recorded address distance, and the recorded address distance is an invalid value. In this case, the recorded address distance is updated using the determined address distance, and the first address is updated using the second address.

[0087] In the subsequent training process, there is a recorded address distance, and the recorded address distance is a valid value. At this time, it is determined whether the determined address distance is equal to the recorded address distance.

[0088] If the address distance is not equal to the recorded address distance, then it is determined whether the reference prefetch address jump number exceeds a first threshold. If the reference prefetch address jump number does not exceed the first threshold at this time, then the reference prefetch address jump number is incremented, the recorded address distance is set to an invalid value, or the recorded address distance is not updated, and the first address is updated using the second address until the determined address distance is equal to the recorded address distance. If the address distance is not equal to the recorded address distance, and the reference prefetch address jump number exceeds the first threshold, then the reference prefetch address jump number is initialized, the address distance is retrained, and the first address is updated using the second address.

[0089] If the determined address distance is equal to the recorded address distance, the recorded address distance may be used as the reference address distance, and it is determined that the training of the prefetch address jump quantity and the reference address distance is completed.

[0090] Optionally, the address distance may be further trained to obtain a reference address distance and a number of pre-fetched address jumps. Specifically, if the determined address distance is the same as the recorded address distance, the number of repetitions of the recorded address distance is incremented, and the first address is updated using the second address until the number of repetitions of the recorded address distance exceeds a second threshold. If the number of repetitions of the recorded address distance exceeds the second threshold, the recorded address distance is used as the reference address distance, and training of the number of pre-fetched address jumps and the reference address distance is determined to be complete.

[0091] Among them, the reference address distance when the training is completed can be determined by the following methods: using the reference prefetch address jump number stored when the training is completed as the prefetch address jump number, and determining the reference address distance based on the prefetch address jump number obtained by training, and the first address and second address corresponding to the training when the training is completed; or using the address distance stored when the training is completed as the reference address distance, wherein the stored address distance is associated with the prefetch address jump number and the first address when the training is completed.

[0092] After the pre-fetch training process is completed, the data pre-fetch process begins.

[0093] During the data prefetch process, it is first determined whether the current address jump number reaches the prefetch address jump number.

[0094] When the number of current address jumps is equal to the number of prefetched address jumps, for the first address in the access address history record, the access address obtained after jumping according to the number of prefetched address jumps in the access address history record is determined as the second address, and the first address is updated using the second address, otherwise the number of current address jumps is increased, and access to the next address is continued.

[0095] After determining the address distance, the determined address distance is compared with the reference address distance. If the determined address distance is equal to the reference address distance, the recorded number of repetitions of the address distance is incremented, the first address is updated using the second address, and data prefetching continues based on the recorded address distance. If the determined address distance is not equal to the reference address distance, the recorded number of repetitions of the address distance is decremented. If the number of repetitions of the reference address distance is lower than a third threshold, the address distance is retrained, and the first address is updated using the second address. The third threshold here can be 0, but is not limited to this.

[0096] The figure only shows one processing method. It should be understood that when the determined address distance is not equal to the reference address distance, the recorded address distance can be directly retrained and the first address can be updated using the second address.

[0097] Optionally, in the prefetch training process and the data prefetch process, the counter for recording the number of repetitions of the address distance may be the same counter or different counters.

[0098] It should be noted that during the prefetch training process, the determined address distance is compared with the recorded address distance. After the training is completed, a reference address distance is obtained. During the data prefetch process, the determined address distance is compared with the reference address distance. During the prefetch training process, the training is based on the number of prefetch address jumps. After the training is completed, the number of prefetch address jumps and the reference address distance are obtained. During the data prefetch process, the reference address distance is used to prefetch data. The reference address distance is associated with the number of prefetch address jumps. The reference address distance is the address distance between the first address in the access address history record and the second address obtained by jumping from the first address to the number of prefetch address jumps.

[0099] Through with Figure 3It can be seen from the comparison that the method of prefetching data according to address distance is different from the method of prefetching data according to address interval in that: the method of prefetching data according to address interval prefetches data according to the address interval between two adjacent addresses; while the method of prefetching data according to address distance prefetches data according to the trained reference address distance. In the case where the address intervals between adjacent addresses in an address sequence are different, there may be a situation where there is a fixed interval after each jump of a specific number of addresses. The method described in the present disclosure uses the reference address distance obtained after jumping according to the number of jumps of the prefetched address to prefetch data, which can support data prefetching in non-single address interval access modes. Moreover, the method of prefetching data according to address distance is also compatible with the situation where the address intervals between adjacent addresses are the same, and has stronger compatibility and universality.

[0100] Figure 7 is a schematic flowchart illustrating a method for calculating address distance according to an embodiment of the present disclosure.

[0101] for Figure 6 In the prefetch training phase of the data prefetch method described in , when calculating the address distance, the current address jump number is recorded, and the initial value of the current address jump number is 0.

[0102] The computer accesses the address and compares the number of jumps to the current address with the number of jumps to the reference prefetched address.

[0103] In the case that the current address jump number is less than the reference prefetch address jump number, the current address jump number is incremented and the next address is accessed.

[0104] When the current address jump number is equal to the reference prefetch address jump number, it is determined that the access address history has jumped according to the reference prefetch address jump number, and the access address obtained after jumping according to the reference prefetch address jump number is used as the second address.

[0105] It should be noted that both the pre-fetch training process and the data pre-fetch process can refer to Figure 7 The method in calculates address distance.

[0106] During prefetch training, the reference prefetch address jump number is trained, the current address jump number is compared with the reference prefetch address jump number, and when the current address jump number and the reference prefetch address jump number are equal, the address distance between the current address and the previously recorded address is calculated and compared with the recorded address distance. After training is completed, the prefetch address jump number used for data prefetching is obtained.

[0107] During data prefetching, the current address jump number is compared with the prefetch address jump number, and when the current address jump number is equal to the prefetch address jump number, the address distance between the current address and the previously recorded address is calculated, and the address distance is compared with the reference address distance determined through training.

[0108] Table 1 illustrates an example of the relationship between access addresses and address intervals during prefetch training and data prefetching, according to an embodiment of the present disclosure. To more clearly illustrate the overall process, rows in the table where the access address of the previous record has changed are grayed out. In Table 1, the number of prefetch address jumps is the trained reference number of prefetch address jumps, and the reference address distance is the trained address distance.

[0109] Table 1

[0110]

[0111]

[0112] According to the embodiment described in Table 1, the address intervals for accesses in this segment are all positive numbers, and the intervals between accessed addresses are not fixed values, but are distributed according to a pattern of 1, 4, 8, 1, 4, 8, ... Assuming that the first threshold for the number of prefetch address jumps is 16, and that training is successful if the same address distance appears twice, the computer prefetches data according to the process described below when accessing addresses.

[0113] When the computer accesses address A, A is the first address accessed. The previously recorded access address is unknown and is denoted by x. The number of current address jumps, the number of reference prefetch address jumps, and the number of address distance repetitions are all 0. After address A is accessed, the previously recorded access address is updated from x to A.

[0114] When the computer accesses address A+1, the previously recorded access address is A, the address distance is 0, the reference prefetch address jump count is 0, and the current address jump count is 0. After accessing address A+1, the previously recorded access address is updated from A to A+1, the address distance is updated from x to 1, and the number of repetitions of address distance 1 is updated from 0 to 1. Here, the repetition count of 1 indicates that address distance 1 occurs once. The next step is to determine whether the reference prefetch address jump count of 0 and address distance 1 are adhered to by the following address.

[0115] When the address accessed by the computer is A+5, the previously recorded access address is A+1, and the address distance between them is 4. At this time, the determined address distance 4 is different from the recorded address distance 1. It is confirmed that prefetching data by jumping 0 addresses cannot meet the requirements. Since the number of reference prefetch address jumps does not exceed the first threshold 16 at this time, the training can still be restarted after the reference prefetch address jump number is increased. The reference prefetch address jump number is updated from 0 to 1, the record of the previously recorded access address is updated from A+1 to A+5, the address distance is updated from 1 to x, and the number of repetitions of the address distance is updated from 1 to 0.

[0116] When the computer accesses address A+13, the previously recorded access address is A+5, and the reference prefetch address jump number is 1. Since training is restarted here, the address distance is unknown and is still recorded as x. The current address jump number is 0, and the number of repetitions of the address distance is 0. Moreover, since the current address jump number 0 is less than the reference prefetch address jump number 1, after accessing address A+13, the current address jump number is updated from 0 to 1, but the recorded address distance, the number of repetitions of the address distance, and the reference prefetch address jump number do not change.

[0117] When the address accessed by the computer is A+14, the previously recorded access address is A+5, the address distance is x, the reference prefetch address jump number is 1, and the current address jump number is 1. Since the current address jump number is equal to the reference prefetch address jump number, after accessing address A+14, the required reference prefetch address jump number has been completed, and the current address A+14 is determined as the second address. The address distance between the current address A+14 and the previously recorded access address A+5 is calculated, and the previously recorded access address is updated from A+5 to A+14, and the address distance is updated from x to 9. Moreover, after accessing address A+14, the current address jump number is updated from 1 to 0, and the number of repetitions of address distance 9 is updated from 0 to 1. Here, the number of repetitions 1 means that the address distance 1 appears once. The following procedure determines whether the reference prefetch address jump number 1 and the address distance 9 are complied with by the next address.

[0118] When the address accessed by the computer is A+18, the previously recorded access address is A+14, the reference prefetch address jump number is 1, and the current address jump number is 0. Since the current address jump number 0 is less than the reference prefetch address jump number 1 at this time, the required reference prefetch address jump number has not been made. After accessing the address A+13, the current address jump number is updated from 0 to 1, but the recorded address distance and the reference prefetch address jump number do not change.

[0119] When the address accessed by the computer is A+26, the previously recorded access address is A+14, and the address distance between them is 12. At this time, the determined address distance 12 is different from the recorded address distance 9. It is confirmed that prefetching data by jumping 1 address cannot meet the requirements. Since the number of reference prefetch address jumps does not exceed the first threshold 16 at this time, the training can still be restarted after the number of reference prefetch address jumps is increased. The number of reference prefetch address jumps is updated from 1 to 2, the record of the previously recorded access address is updated from A+14 to A+26, the address distance is updated from 9 to x, and the number of repetitions of the address distance is updated from 1 to 0.

[0120] When the computer accesses address A+27, the previously recorded access address is A+26, and the reference prefetch address jump number is 2. Since training is restarted here, the address distance is unknown and is still recorded as x. The current address jump number is 0, and the number of repetitions of the address distance is 0. Moreover, since the current address jump number 0 is less than the reference prefetch address jump number 2 at this time, the required reference prefetch address jump number has not been made. After accessing address A+27, the current address jump number is updated from 0 to 1, but the recorded address distance, the number of repetitions of the address distance, and the reference prefetch address jump number do not change.

[0121] When the address accessed by the computer is A+31, the previously recorded access address is A+26, the reference prefetch address jump number is 2, the address distance is unknown and is still recorded as x, the current address jump number is 1, and the number of repetitions of the address distance is 0. Since the current address jump number 1 is less than the reference prefetch address jump number 2 at this time, the required reference prefetch address jump number has not been made. After accessing the address A+31, the current address jump number is updated from 1 to 2, but the recorded address distance, the number of repetitions of the address distance and the reference prefetch address jump number do not change.

[0122] When the address accessed by the computer is A+39, the previously recorded access address is A+26, the address distance is x, the reference prefetch address jump number is 2, and the current address jump number is 2. Since the current address jump number is equal to the reference prefetch address jump number, after accessing address A+39, the required reference prefetch address jump number has been completed, and the current address A+39 is determined as the second address. The address distance between the current address A+39 and the previously recorded access address A+26 is calculated, and the previously recorded access address is updated from A+26 to A+39, and the address distance is updated from x to 13. Moreover, after accessing address A+39, the current address jump number is updated from 2 to 0, and the number of repetitions of address distance 13 is updated from 0 to 1. Here, the number of repetitions 1 means that the address distance 1 appears once. It is then determined whether the reference prefetch address jump number 2 and the address distance 13 are complied with by the next address.

[0123] When the address accessed by the computer is A+40, the previously recorded access address is A+39, the reference prefetch address jump number is 2, and the current address jump number is 0. Since the current address jump number 0 is less than the reference prefetch address jump number 2 at this time, the required reference prefetch address jump number has not been made. After accessing the address A+40, the current address jump number is updated from 0 to 1, but the recorded address distance, the number of repetitions of the address distance, and the reference prefetch address jump number do not change.

[0124] When the address accessed by the computer is A+44, the previously recorded access address is A+39, the reference prefetch address jump number is 2, and the current address jump number is 1. Since the current address jump number 1 is less than the reference prefetch address jump number 2 at this time, the required reference prefetch address jump number has not been made. After accessing the address A+44, the current address jump number is updated from 1 to 2, but the recorded address distance, the number of repetitions of the address distance, and the reference prefetch address jump number do not change.

[0125] When the address accessed by the computer is A+52, the number of reference prefetch address jumps is 2, and the number of current address jumps is 2. Since the number of current address jumps is equal to the number of reference prefetch address jumps, after accessing address A+52, the required number of reference prefetch address jumps has been completed, and the current address A+52 is determined as the second address, and the address distance between the current address A+52 and the previously recorded access address A+39 is calculated. The previously recorded access address is updated from A+39 to A+52, and the determined address distance is 13. At this time, the determined address distance 13 is the same as the recorded address distance 13. The number of repetitions of the address distance 13 is updated from 1 to 2, and the current address jump number is updated from 2 to 0. Since the training is successful when the same address distance appears twice, the prefetch training process ends at this time. The address distance obtained after training is 13, that is, the reference address distance is 13; the number of reference prefetch address jumps obtained after training is 2, that is, the number of prefetch address jumps is 2. In the subsequent data prefetch process, data prefetching will be performed according to the reference address distance 13. The prefetched address here is A+65 (that is, 52+13=65).

[0126] When the address accessed by the computer is A+53, the previously recorded access address is A+52, the prefetch address jump number is 2, and the current address jump number is 0. Since the current address jump number 0 is less than the prefetch address jump number 2 at this time, the required prefetch address jump number has not been made. After accessing the address A+53, the current address jump number is updated from 0 to 1, but the recorded address distance, the number of repetitions of the address distance, and the reference prefetch address jump number do not change.

[0127] When the address accessed by the computer is A+57, the previously recorded access address is A+52, the prefetch address jump number is 2, and the current address jump number is 1. Since the current address jump number 1 is less than the reference address jump number 2 at this time, the required prefetch address jump number has not been performed. After accessing the address A+57, the current address jump number is updated from 1 to 2, but the recorded address distance, the number of repetitions of the address distance, and the reference prefetch address jump number do not change.

[0128] When the address accessed by the computer is A+65, the number of prefetch address jumps is 2, and the number of current address jumps is 2. Since the number of current address jumps is equal to the number of prefetch address jumps, after accessing address A+65, the required number of prefetch address jumps has been completed, and the current address A+65 is determined as the second address. The address distance between the current address A+65 and the previously recorded access address A+52 is calculated. The previously recorded access address is updated from A+52 to A+65, and the determined address distance is 13. At this time, the determined address distance 13 is the same as the reference address distance 13. The number of repetitions of the address distance 13 is updated from 2 to 3, and the current address jump number is updated from 2 to 0. At this time, the address prefetched according to the reference address distance 13 is A+78 (i.e., 65+13=78). At the same time, it can be seen here that the address A+65 has been obtained in advance in the previous prefetch process, and the prefetch hit is obtained.

[0129] The subsequent process of prefetching data by the computer is similar and will not be described in detail here.

[0130] It should be noted that in the present disclosure, the previously recorded access address does not refer to the previous access address between two adjacent access addresses, but rather refers to the address obtained after jumping according to the reference prefetch address jump number or the prefetch address jump number and recorded in the address access record (for example, addresses A+1, A+5, A+14, A+26, A+39, etc. in Table 1). The address access record only records the addresses obtained after jumping according to the required prefetch address jump number, and does not record the intermediate address values ​​during the jumping process (for example, addresses A+13, A+18, A+27, A+31, etc. in Table 1).

[0131] It should be understood that the embodiment in Table 1 takes the case where the same address distance appears twice as training success as an example but not a limitation, and the number of repetitions of the address distance indicating successful pre-fetch training may also be other values.

[0132] In the embodiment of Table 1, when the recorded address distance is a valid value, the determined address distance is not equal to the recorded address distance, and the number of reference prefetch address jumps does not exceed the first threshold, the recorded address distance is set to an invalid value (i.e., x). Alternatively, the recorded address distance may not be updated at this time, and the recorded address distance remains unchanged from the previous record.

[0133] In the embodiment of Table 1, the first threshold of 16 is an example but not a limitation. The first threshold may also be other values, which may be determined according to the prefetcher structure or storage space, or set based on experience.

[0134] Through the analysis of the above prefetch training process and data prefetch process, it can be seen that the prefetch data method provided by the embodiments of the present disclosure supports non-single address interval access modes (for example, address intervals of 1, 4, 8, 1, 4, 8, etc.), improving the prefetch coverage, reducing cache misses, and improving the accuracy of prefetch. In addition, the prefetch method only needs to add a counter to record the number of prefetch address jumps and a counter to record the number of current address jumps, and replaces the record of address intervals with the record of reference address distances. The storage overhead and operation overhead are low, and it is fully compatible with the existing prefetch of single address interval access mode.

[0135] Figure 8 is a schematic diagram illustrating a data prefetching device according to an embodiment of the present disclosure.

[0136] The data pre-fetching device 800 may include an access address acquiring module 801 , a pre-fetch address jump number determining module 802 , a reference address distance determining module 803 , and a pre-fetch address determining module 804 .

[0137] According to an embodiment of the present disclosure, the access address acquisition module 801 may be configured to acquire an address to be accessed and an access address history record.

[0138] Optionally, the obtained access address and the access address history record are stored in the prefetcher respectively. In the present disclosure, the obtained access address is updated according to the address access time, and the access address history record is updated only after the access address history record jumps according to the reference prefetch address jump number.

[0139] According to an embodiment of the present disclosure, the prefetch address jump number determining module 802 may be configured to determine the prefetch address jump number according to the access address history record.

[0140] Optionally, the training of the reference address distance and the number of pre-fetch address jumps may be obtained through training.

[0141] Optionally, the training of the reference address distance and the training of the prefetch address jump number can be performed in association, wherein, in the prefetch training process, the determination of the prefetch address jump number based on the access address history record can also include: obtaining the reference prefetch address jump number; for the first address in the access address history record, determining the access address obtained after jumping according to the reference prefetch address jump number in the access address history record as the second address; determining the address distance between the first address and the second address; and based on the recorded address distance and the determined address distance, performing at least one of the following operations: in the case where the recorded address distance is an invalid value, updating the recorded address distance using the determined address distance, and updating the first address using the second address; in the case where the recorded address distance is an invalid value, When the address distance is a valid value, the determined address distance is not equal to the recorded address distance, and the reference prefetch address jump number does not exceed the first threshold, the reference prefetch address jump number is increased, the recorded address distance is set to an invalid value, or the recorded address distance is not updated, and the first address is updated using the second address; when the recorded address distance is a valid value, the determined address distance is not equal to the recorded address distance, and the reference prefetch address jump number exceeds the first threshold, the reference prefetch address jump number is initialized, the address distance is retrained, and the first address is updated using the second address; when the recorded address distance is a valid value and the determined address distance is equal to the recorded address distance, the first address is updated using the second address.

[0142] Optionally, for the first address in the access address history record, determining the access address obtained after jumping according to the reference prefetch address jump number in the access address history record as the second address may also include: for the address after the first address, determining its corresponding current address jump number, and when the current address jump number is less than the reference prefetch address jump number, increasing the current address jump number and continuing to access the next address; and when the current address jump number is equal to the reference prefetch address jump number, determining that it has jumped according to the reference prefetch address jump number in the access address history record, and using the access address obtained after jumping according to the reference prefetch address jump number as the second address.

[0143] According to an embodiment of the present disclosure, the reference address distance determining module 803 may be configured to determine the reference address distance based on the access address history record and the determined number of prefetch address jumps.

[0144] Optionally, during the pre-fetch training process, when the recorded address distance is a valid value and the determined address distance is equal to the recorded address distance, the first address is updated using the second address, which may also include: when the determined address distance is the same as the recorded address distance, increasing the number of repetitions of the recorded address distance, and updating the first address using the second address until the number of repetitions of the recorded address distance exceeds a second threshold; when the number of repetitions of the recorded address distance exceeds the second threshold, using the recorded address distance as the reference address distance, and determining that the training of the pre-fetch address jump number and the reference address distance is completed.

[0145] Optionally, during the prefetch training process, the reference address distance is determined based on the access address history record and the determined number of prefetch address jumps, and it may also include: using the reference prefetch address jump number stored when the training is completed as the prefetch address jump number, and determining the reference address distance based on the number of prefetch address jumps obtained during the training, and the first address and the second address corresponding to the time when the training is completed; or using the address distance stored when the training is completed as the reference address distance, wherein the stored address distance is associated with the number of prefetch address jumps and the first address when the training is completed.

[0146] According to an embodiment of the present disclosure, the prefetch address determining module 804 may be configured to determine a prefetch address for data prefetching based on the determined reference address distance and the address to be accessed.

[0147] Optionally, in the data prefetching process, the determining of the prefetch address for data prefetching based on the determined reference address distance and the address to be accessed may also include: obtaining the number of prefetch address jumps; for the first address in the access address history record, determining the access address obtained after jumping according to the number of prefetch address jumps in the access address history record as the second address; determining the address distance between the first address and the second address; and performing at least one of the following operations based on the reference address distance and the determined address distance: when the determined address distance is equal to the reference address distance, increasing the number of repetitions of the recorded address distance, and updating the first address with the second address; when the determined address distance is not equal to the reference address distance, decreasing the number of repetitions of the recorded address distance, and when the number of repetitions of the reference address distance is lower than a third threshold, retraining the address distance, and updating the first address with the second address; or when the determined address distance is not equal to the reference address distance, retraining the address distance, and updating the first address with the second address.

[0148] Optionally, during data prefetching, for the first address in the access address history record, determining the access address obtained after jumping according to the prefetch address jump number in the access address history record as the second address may also include: for the address after the first address, determining its corresponding current address jump number, and when the current address jump number is less than the prefetch address jump number, increasing the current address jump number and continuing to access the next address; and when the current address jump number is equal to the prefetch address jump number, determining that it has jumped according to the prefetch address jump number in the access address history record, and using the access address obtained after jumping according to the prefetch address jump number as the second address.

[0149] It should be understood that the data prefetching method described in the present disclosure can be implemented in hardware, software, or a combination of software and hardware. In general, the various example embodiments of the present disclosure can be implemented in hardware or dedicated circuits, software, firmware, logic, or any combination thereof. Certain aspects can be implemented in hardware, while other aspects can be implemented in firmware or software that can be executed by a controller, microprocessor or other computing device. When various aspects of the embodiments of the present disclosure are illustrated or described as block diagrams, flow charts or using some other graphical representation, it will be understood that the boxes, devices, systems, techniques or methods described herein can be implemented as non-limiting examples in hardware, software, firmware, dedicated circuits or logic, general hardware or controllers or other computing devices, or some combination thereof.

[0150] It should be noted that the flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions and operations of the methods and devices according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or part of a circuit, and the module, program segment, or part of the circuit contains at least one executable instruction or hardware circuit for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0151] Embodiments of the present disclosure also provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the data prefetching method according to an embodiment of the present disclosure.

[0152] According to yet another aspect of the present disclosure, a computer-readable storage medium is provided. Figure 9 A schematic diagram 4000 of a storage medium according to the present disclosure is shown.

[0153] like Figure 9 As shown, the computer storage medium 4020 stores computer-readable instructions 4010. When the computer-readable instructions 4010 are executed by the processor, the instruction processing method according to the embodiment of the present disclosure described with reference to the above figures can be executed. The computer-readable storage medium in the embodiment of the present disclosure can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. The non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct memory bus random access memory (DR RAM). It should be noted that memory of the methods described herein is intended to include, but is not limited to, these and any other suitable types of memory. It should be noted that memory of the methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0154] Embodiments of the present disclosure provide a data prefetching method, apparatus, computer program product, and computer-readable storage medium that support a non-single address interval access mode.

[0155] The method provided by the embodiment of the present disclosure obtains an address to be accessed and an access address history record; determines the number of prefetch address jumps based on the access address history record; determines a reference address distance based on the access address history record and the determined number of prefetch address jumps; and determines a prefetch address for data prefetching based on the determined reference address distance and the address to be accessed. The data prefetching method provided by the embodiment of the present disclosure improves the coverage of prefetching, reduces cache misses, and improves the accuracy of prefetching. In addition, the prefetching method has low storage overhead and operation overhead, and can support data prefetching in a single address interval access mode with the same address interval between adjacent addresses, and can also support data prefetching in a non-single address interval access mode with a fixed address distance between access addresses after a fixed number of addresses, and has stronger compatibility and universality.

[0156] This disclosure uses specific terms to describe the embodiments of the present disclosure. For example, "first / second embodiment," "one embodiment," and / or "some embodiments" refer to a certain feature, structure, or characteristic associated with at least one embodiment of the present disclosure. Therefore, it should be emphasized and noted that "one embodiment," "an embodiment," or "an alternative embodiment" mentioned two or more times in different locations in this specification does not necessarily refer to the same embodiment. In addition, certain features, structures, or characteristics in one or more embodiments of the present disclosure may be appropriately combined.

[0157] Unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. It should also be understood that terms such as those defined in common dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant technology and should not be interpreted in an idealized or highly formal sense, unless expressly defined as such herein.

[0158] The above is an illustration of the present invention and should not be considered as limiting thereof. Although several exemplary embodiments of the present invention have been described, it will be readily understood by those skilled in the art that many modifications may be made to the exemplary embodiments without departing from the novel teachings and advantages of the present invention. Therefore, all such modifications are intended to be included within the scope of the present invention as defined by the claims. It should be understood that the above is an illustration of the present invention and should not be considered as being limited to the specific embodiments disclosed, and modifications to the disclosed embodiments and other embodiments are intended to be included within the scope of the appended claims. The present invention is defined by the claims and their equivalents.

Claims

1. A data prefetching method, comprising: Get the address to be visited and the history of the address visited; Determining the number of prefetch address jumps based on the access address history; Determining a reference address distance based on the access address history record and the determined number of prefetch address jumps, wherein addresses in the access address history record that are separated by the number of prefetch address jumps have a fixed reference address distance; and Determine a prefetch address for data prefetching based on the determined reference address distance and the address to be accessed, The data prefetching method includes: a prefetching training process, wherein the training of the reference address distance and the training of the prefetching address jump number are performed in association, and when the training is completed, the prefetching address jump number is the trained reference prefetching address jump number, and the reference address distance is the trained address distance, wherein, during the prefetching training process, the prefetching address jump number is determined based on the access address history record, and further comprising: Get the reference prefetch address jump count; For a first address in the access address history record, determining an access address obtained after jumping according to the reference prefetch address jump number in the access address history record as a second address; determining an address distance between the first address and a second address; and Based on the recorded address distance and the determined address distance, perform at least one of the following operations: When the recorded address distance is an invalid value, updating the recorded address distance using the determined address distance, and updating the first address using the second address; If the recorded address distance is a valid value, the determined address distance is not equal to the recorded address distance, and the reference prefetch address jump number does not exceed a first threshold, incrementing the reference prefetch address jump number, setting the recorded address distance to an invalid value, or not updating the recorded address distance, and updating the first address with the second address; When the recorded address distance is a valid value, the determined address distance is not equal to the recorded address distance, and the reference prefetch address jump number exceeds a first threshold, initializing the reference prefetch address jump number, retraining the address distance, and updating the first address with the second address; When the recorded address distance is a valid value and the determined address distance is equal to the recorded address distance, the first address is updated using the second address.

2. The data prefetching method according to claim 1, wherein: The number of prefetch address jumps is at least one.

3. The data prefetching method according to claim 1, wherein: The step of determining, for the first address in the access address history record, an access address obtained after jumping according to the reference prefetch address jump number in the access address history record as the second address further comprises: For the addresses after the first address, determine the corresponding current address jump number, In the case that the current address jump number is less than the reference prefetch address jump number, incrementing the current address jump number and continuing to access the next address; and When the current address jump number is equal to the reference prefetch address jump number, it is determined that the access address history has jumped according to the reference prefetch address jump number, and the access address obtained after jumping according to the reference prefetch address jump number is used as the second address.

4. The data prefetching method according to claim 1, in, In the prefetch training process, when the recorded address distance is a valid value and the determined address distance is equal to the recorded address distance, updating the first address by using the second address further includes: When the determined address distance is the same as the recorded address distance, incrementing the number of repetitions of the recorded address distance and updating the first address with the second address until the number of repetitions of the recorded address distance exceeds a second threshold; When the number of repetitions of the recorded address distance exceeds a second threshold, the recorded address distance is used as the reference address distance, and it is determined that the training of the prefetch address jump number and the reference address distance is completed.

5. The data prefetching method according to claim 4, wherein: In the prefetch training process, determining a reference address distance based on the access address history record and the determined number of prefetch address jumps further includes: Using the reference prefetch address jump number stored when the training is completed as the prefetch address jump number, and determining the reference address distance based on the prefetch address jump number obtained by training and the first address and the second address corresponding to the training completion; or The address distance stored when the training is completed is used as the reference address distance, wherein the stored address distance is associated with the number of pre-fetch address jumps and the first address when the training is completed.

6. The data prefetching method according to claim 1, wherein: The data pre-fetching method further includes: a data pre-fetching process, The data prefetching process determines a prefetching address for data prefetching based on the determined reference address distance and the address to be accessed.

7. The data prefetching method according to claim 6, wherein: In the data prefetching process, the determining of a prefetch address for data prefetching based on the determined reference address distance and the address to be accessed further includes: Obtaining a prefetch address jump number; for a first address in the access address history record, determining an access address obtained after jumping according to the prefetch address jump number in the access address history record as a second address; determining an address distance between the first address and a second address; and Based on the reference address distance and the determined address distance, perform at least one of the following operations: When the determined address distance is equal to the reference address distance, the number of repetitions of the recorded address distance is incremented, and the first address is updated using the second address; When the determined address distance is not equal to the reference address distance, the number of repetitions of the recorded address distance is decreased; when the number of repetitions of the reference address distance is lower than a third threshold, the address distance is retrained, and the first address is updated using the second address; or when the determined address distance is not equal to the reference address distance, the address distance is retrained, and the first address is updated using the second address.

8. The data prefetching method according to claim 7, wherein: In the data prefetch process, for the first address in the access address history record, determining an access address obtained after jumping according to the prefetch address jump number in the access address history record as the second address, further comprising: For the addresses after the first address, determine the corresponding current address jump number, In the case that the current address jump number is less than the pre-fetch address jump number, the current address jump number is incremented and the next address is accessed; and When the current address jump number is equal to the prefetch address jump number, it is determined that the access address history has jumped according to the prefetch address jump number, and the access address obtained after jumping according to the prefetch address jump number is used as the second address.

9. The data prefetching method according to claim 1, wherein: The reference address distance is a positive number or a negative number.

10. A data pre-fetching device, comprising: The access address acquisition module is configured to: acquire the address to be accessed and the access address history record; a prefetch address jump number determination module, configured to: determine the prefetch address jump number according to the access address history record; a reference address distance determination module configured to: determine a reference address distance based on the access address history record and the determined number of prefetch address jumps, wherein addresses in the access address history record that are separated by the number of prefetch address jumps have a fixed reference address distance; and The prefetch address determination module is configured to: determine a prefetch address for data prefetching based on the determined reference address distance and the address to be accessed, The data prefetch device is used to perform a prefetch training process, wherein the training of the reference address distance and the training of the prefetch address jump number are performed in association, and when the training is completed, the prefetch address jump number is the trained reference prefetch address jump number, and the reference address distance is the trained address distance, wherein, during the prefetch training process, The prefetch address jump number determining module is configured to: obtain a reference prefetch address jump number; The reference address distance determination module is configured to: For a first address in the access address history record, determining an access address obtained after jumping according to the reference prefetch address jump number in the access address history record as a second address; determining an address distance between the first address and a second address; and Based on the recorded address distance and the determined address distance, perform at least one of the following operations: When the recorded address distance is an invalid value, updating the recorded address distance using the determined address distance, and updating the first address using the second address; If the recorded address distance is a valid value, the determined address distance is not equal to the recorded address distance, and the reference prefetch address jump number does not exceed a first threshold, incrementing the reference prefetch address jump number, setting the recorded address distance to an invalid value, or not updating the recorded address distance, and updating the first address with the second address; When the recorded address distance is a valid value, the determined address distance is not equal to the recorded address distance, and the reference prefetch address jump number exceeds a first threshold, initializing the reference prefetch address jump number, retraining the address distance, and updating the first address with the second address; When the recorded address distance is a valid value and the determined address distance is equal to the recorded address distance, the first address is updated using the second address.

11. The data pre-fetching device according to claim 10, wherein: The data pre-fetching device is also used to perform a data pre-fetching process, The data prefetching process determines a prefetching address for data prefetching based on the determined reference address distance and the address to be accessed.

12. A computer program product, comprising computer software codes, wherein when executed by a processor, the computer software codes are used to implement the data prefetching method according to any one of claims 1 to 9.

13. A computer-readable storage medium having computer-executable instructions stored thereon, wherein the instructions are used to implement the data prefetching method according to any one of claims 1 to 9 when executed by a processor.

Citation Information

Patent Citations

  • Detecting multiple stride sequences for prefetching

    US20140359221A1