Data prefetching method, device, equipment, medium and product
By using preset program counter tables in data prefetching to determine stream prefetch mode and other prefetching modes, the problems of large overhead search and high storage cost in the prior art are solved, and more efficient data prefetching is achieved.
Patent Information
- Application Number
- CN202510551069.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-04-29
AI Technical Summary
Existing multi-modal data prefetch algorithms perform poorly in different types of access sequences, resulting in large overhead search and high storage costs.
Determine whether the stream prefetch mode is adopted by the preset program counter table. If it is not satisfied, the other prefetch modes will be judged, and multi-modes will be used to determine step by step to avoid redundant information storage.
Reduces the overhead and storage cost of prefetch mode, and improves the efficiency and performance of data prefetching.
Smart Images

Figure CN120066989A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage, and in particular, to a data prefetching method, apparatus, device, medium, and product. Background Art
[0002] For complex application scenarios, a single data prefetching algorithm cannot exhibit optimal performance in different types of memory access sequences. Currently, in the general design of multi-mode data prefetching algorithms, a miss request is sent to multiple data prefetching units simultaneously to try to find a suitable prefetching mode, which incurs a large search overhead, and each data prefetching algorithm maintains its own table to record content, resulting in a high storage cost.
[0003] It can be seen that how to reduce the prefetching mode search overhead and storage cost is a problem that needs to be solved by those skilled in the art. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide a data prefetching method, apparatus, device, medium, and product to reduce the prefetching mode search overhead and storage cost. The specific solutions are as follows:
[0005] In a first aspect, the present invention provides a data prefetching method, including:
[0006] Obtain target miss information; wherein, the target miss information includes first instruction address information corresponding to a program counter and first missing data address information;
[0007] Obtain stream prefetching mode determination information from a preset program counter table based on the target miss information, and generate a prefetch address corresponding to the stream prefetching mode when it is determined that the preset stream prefetching mode condition is satisfied based on the target miss information and the stream prefetching mode determination information, so as to perform data prefetching based on this prefetch address;
[0008] If the preset stream prefetching mode condition is not satisfied, determine a first target entry in the preset program counter table, where the first target entry is a data entry including second instruction address information identical to the first instruction address information, and the first target entry includes position information of data entries corresponding to the first instruction address information in multiple other prefetching mode determination tables;
[0009] Perform determination of other prefetching modes based on the position information in the first target entry, and generate a prefetch address corresponding to the other prefetching mode when it is determined to adopt the other prefetching mode, so as to perform data prefetching based on this prefetch address.
[0010] In a second aspect, the present invention provides a data prefetching apparatus, including:
[0011] A missing information acquisition module, configured to acquire target missing information; wherein, the target missing information includes first instruction address information corresponding to a program counter and first missing data address information;
[0012] A stream prefetch mode processing module, configured to acquire stream prefetch mode determination information from a preset program counter table based on the target missing information, and generate a prefetch address corresponding to the stream prefetch mode when it is determined that a preset stream prefetch mode condition is satisfied based on the target missing information and the stream prefetch mode determination information, so as to perform data prefetch based on the prefetch address;
[0013] A target entry determination module, configured to determine a first target entry in the preset program counter table if the preset stream prefetch mode condition is not satisfied, wherein the first target entry is a data entry including second instruction address information identical to the first instruction address information, and the first target entry includes position information of data entries corresponding to the first instruction address information in multiple other prefetch mode determination tables;
[0014] A multi-prefetch mode processing module, configured to perform determination of other prefetch modes based on the position information in the first target entry, and generate a prefetch address corresponding to the other prefetch mode when it is determined to adopt the other prefetch mode, so as to perform data prefetch based on the prefetch address.
[0015] In a third aspect, the present invention provides an electronic device, including:
[0016] A memory, configured to store a computer program;
[0017] A processor, configured to execute the computer program to implement the steps of the foregoing data prefetch method.
[0018] In a fourth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the foregoing data prefetch method are implemented.
[0019] In a fifth aspect, the present invention provides a computer program product, including computer programs / instructions, and when the computer programs / instructions are executed by a processor, the steps of the foregoing data prefetch method are implemented.
[0020] As can be seen from the above solution, the present invention provides a data prefetching method, including: obtaining target missing information; wherein, the target missing information includes first instruction address information corresponding to a program counter and first missing data address information; obtaining stream prefetching mode determination information from a preset program counter table based on the target missing information, and generating a prefetch address corresponding to the stream prefetching mode when it is determined that a preset stream prefetching mode condition is satisfied based on the target missing information and the stream prefetching mode determination information, so as to perform data prefetching based on this prefetch address; if the preset stream prefetching mode condition is not satisfied, determining a first target entry in the preset program counter table, where the first target entry is a data entry including second instruction address information identical to the first instruction address information, and the first target entry includes position information of data entries corresponding to the first instruction address information in multiple other prefetching mode determination tables; determining other prefetching modes based on the position information in the first target entry, and generating a prefetch address corresponding to the other prefetching mode when it is determined to adopt the other prefetching mode, so as to perform data prefetching based on this prefetch address.
[0021] It can be seen that the beneficial effects of the present invention are as follows: determining whether to adopt the stream prefetching mode through the preset program counter table, and performing the determination of other prefetching modes when the stream prefetching mode is not adopted. In this way, multi-mode hierarchical determination is carried out, avoiding the process of triggering the search and determination of all prefetching modes for the same missing information. Moreover, the preset program counter table includes position information of data entries corresponding to the first instruction address information in multiple other prefetching mode determination tables, realizing the indexing of other prefetching mode determination tables and being able to avoid redundant information in various prefetching mode determination tables. In this way, the prefetching mode search overhead and storage cost are reduced.
[0022] Correspondingly, a data prefetching device, device, medium and product provided by the present invention also have the above technical effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0024] Figure 1 It is a flowchart of a data prefetching method provided by an embodiment of the present invention;
[0025] Figure 2 It is a block diagram of the overall structure of a multi-mode data prefetching unit provided by an embodiment of the present invention;
[0026] Figure 3 Schematic diagram of a prefetching process provided by an embodiment of the present invention;
[0027] Figure 4 Schematic diagram of prefetching training provided by an embodiment of the present invention;
[0028] Figure 5 Schematic diagram of a space division provided by an embodiment of the present application;
[0029] Figure 6 Schematic diagram of the training process of a spatial bit vector sequence provided by an embodiment of the present application;
[0030] Figure 7 Schematic diagram of a prefetching process provided by an embodiment of the present application;
[0031] Figure 8 Schematic diagram of an arbitration filtering unit provided by an embodiment of the present invention;
[0032] Figure 9 Schematic diagram of the prefetching degree training process provided by an embodiment of the present invention;
[0033] Figure 10 Schematic diagram of the structure of a data prefetching device disclosed by an embodiment of the present invention;
[0034] Figure 11 Schematic diagram of the structure of an electronic device disclosed by an embodiment of the present invention. Detailed implementation manners
[0035] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0036] The terms "including" and "having" in the specification of the present invention and any deformations related to "including" and "having" are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may include steps or units not listed.
[0037] To enable those skilled in the art to better understand the solution of the present invention, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific implementation manners.
[0038] Next, a data prefetching method provided by an embodiment of the present invention will be introduced in detail. Figure 1A flowchart of a data prefetching method provided by an embodiment of the present invention. The data prefetching method includes:
[0039] Step S11: Obtain target missing information; wherein, the target missing information includes first instruction address information corresponding to a program counter and first missing data address information.
[0040] It can be understood that the program counter is a key register in the CPU, which is used to store the memory address of the next instruction. In the embodiment of the present invention, the instruction is identified by the instruction address information stored in the program counter, and any instruction can access the cache once or multiple times. The missing data address information is the address where there is no data in the cache and a miss occurs when accessing the cache.
[0041] In an optional implementation manner, when a preset data prefetching condition is satisfied, the missing information is added to a trigger queue, where the missing information includes instruction address information corresponding to the program counter and missing data address information; correspondingly, obtaining the target missing information includes: obtaining the target missing information from the trigger queue.
[0042] Wherein, the preset data prefetching condition may be the occurrence of preset missing information, such as L2_Miss information. The L2_Miss information is the missing information generated when the corresponding data cannot be found in the secondary cache in a multi-level cache. The trigger queue follows the first-in, first-out principle, and the target missing information is the missing information dequeued from the trigger queue following the first-in, first-out principle. And, in an optional implementation manner, before adding the missing information to the trigger queue, it can be first checked whether there is consistent missing information in the trigger queue. If not, it is added; otherwise, it is not added.
[0043] Step S12: Obtain stream prefetching mode determination information from a preset program counter table based on the target missing information, and generate a prefetch address corresponding to the stream prefetching mode when it is determined that a preset stream prefetching mode condition is satisfied based on the target missing information and the stream prefetching mode determination information, so as to perform data prefetching based on the prefetch address.
[0044] Wherein, the preset program counter table is a preset table, and the table contains multiple data entries. Each data entry contains predefined fields. The stream prefetching mode determination information is information related to judging the stream prefetching mode, and may be the recorded data missing address.
[0045] In an alternative embodiment, the first target entry and the second target entry can be determined from a preset program counter table, where the second target entry is a data entry containing the instruction address information in the most recently matched missing information; the second missing data address information is obtained from the first target entry and the second target entry; the second missing data address information is the previous missing data address information corresponding to the instruction address information in the first target entry or the second target entry. That is, in the first target entry, the second missing data address information is the previous missing data address information corresponding to the first instruction address information, and in the second target entry, it is the previous missing data address information included in this entry. If the difference between any obtained second missing data address information and the first missing data address information is 1, it is determined that the preset stream prefetch mode condition is satisfied. Add 1 to the first missing data address information to obtain the prefetch address corresponding to the stream prefetch mode. There is no need to perform subsequent judgments of other prefetch modes for this target missing information.
[0046] Step S13: If the preset stream prefetch mode condition is not satisfied, determine the first target entry in the preset program counter table, where the first target entry is a data entry containing the second instruction address information that is the same as the first instruction address information, and the first target entry contains the position information of the data entries corresponding to the first instruction address information in multiple other prefetch mode determination tables.
[0047] Step S14: Based on the position information in the first target entry, perform the determination of other prefetch modes. When it is determined to adopt other prefetch modes, generate the prefetch address corresponding to the other prefetch modes for data prefetch based on this prefetch address.
[0048] In an alternative embodiment, other prefetching modes include a stride prefetching mode, and the corresponding prefetching mode decision table is a preset stride table; correspondingly, determining other prefetching modes based on the position information in the first target entry includes: if the first target entry exists and the difference between the second missing data address information and the first missing data address information in the first target entry is not 1, then according to the position information of the data entry corresponding to the first instruction address information in the preset stride table in the first target entry, determine a third target entry corresponding to this position information from the preset stride table; obtain stride information from the third target entry to obtain a first stride information, if the first stride information is the same as the difference between the second missing data address information and the first missing data address information, and the first stride information meets the preset credibility condition, then determine that the stride prefetching mode is adopted. Generate a prefetch address corresponding to the other prefetching mode, add the first missing data address information and the first stride information to obtain the prefetch address corresponding to the stride prefetching mode. There is no need to perform subsequent judgments of other prefetching modes for this target missing information.
[0049] In an alternative embodiment, other prefetching modes include a space-based prefetching mode, and the corresponding prefetching mode decision table is a preset area table; correspondingly, determining other prefetching modes based on the position information in the first target entry includes: if the first stride information is inconsistent with the difference or does not meet the preset credibility condition, then according to the position information of the data entry corresponding to the first instruction address information in the preset area table in the first target entry, determine a fourth target entry corresponding to this position information from the preset area table; extract the data within a preset bit range in the first missing data address information to obtain a first offset value; if a fifth target entry is determined in the preset area table, then determine that the space-based prefetching mode is adopted; wherein, the fifth target entry is a data entry including a second offset value that is the same as the first offset value. It can be understood that there may be multiple fourth target entries, and the embodiments of the present application can determine the fifth target entry therefrom. Further, generating a prefetch address corresponding to the other prefetching mode includes: obtaining the prefetch address of the space-based prefetching mode based on the first missing data address information and the bit vector sequence in the fifth target entry. Wherein, the space bit vector sequence represents the access situation corresponding to the same space base address in the fifth target entry.
[0050] In an alternative embodiment, if the first target entry or the second target entry does not exist in the preset program counter table, the prefetch mode is determined to be offset prefetch; if the first stride information is inconsistent with the difference value or does not meet the preset credibility condition, and the position information of the data entry corresponding to the first instruction address information in the preset region table does not exist in the first target entry, it is determined to adopt the offset prefetch mode. Further, if the optimal offset value is recorded in the preset offset value record, the prefetch address corresponding to the offset prefetch mode is determined based on the first missing data address information and the optimal offset value.
[0051] Further, for the offset prefetch process, if there is no optimal offset value, the offset value is set to 0, indicating that no prefetch address is calculated. At this time, no prefetch is issued (because this is already the last level at this step, and if there is no suitable one here, the overall pattern has not been found). The calculation of the prefetch address is the trigger address + the offset value. If the prefetch degree is 2, in addition to issuing the trigger address + the offset value, the trigger address + 2 * the offset value is also issued, and so on.
[0052] It can be understood that in the embodiments of the present invention, the main storage structures involved in the present invention include Trigger_queue (trigger queue), PC_table (program counter table, i.e., the preset program counter table), Stride_table (stride table, i.e., the preset stride table), region_table (region table, i.e., the preset region table), delta (offset value record, i.e., the preset offset value record), train_table (training table, i.e., the preset training table), score_table (score table, i.e., the preset score table), and RR_table (past memory access table, i.e., the preset address table), and the main logical structure is the arbiter & fliter (arbitration and filtering unit) module. Refer to Figure 2 shown Figure 2 which is an overall structural block diagram of a multi-mode data prefetch unit provided by an embodiment of the present invention. It may include an index unit, a stride unit, a region unit, a training unit, an offset unit, and an arbitration and filtering unit, and may include a trigger queue, a prefetch queue, and a training queue.
[0053] Refer to Figure 3 shown Figure 3 which is a schematic diagram of a prefetch process provided by an embodiment of the present invention. The prefetch process is as Figure 3As shown, the prefetch trigger information is the missing information. Taking the L2_Miss information as an example of the address information for triggering prefetch, the L2_Miss related information sent out will first be sent to the trigger queue for buffering. When it is determined that there is no request duplication, the missing request information, that is, the missing information, will be added to the tail of the trigger queue. Then, the trigger queue will be sent to the index unit in the order of first in first out. The index unit will first search for the entry corresponding to the same PC (i.e., the instruction address information corresponding to the program counter) and the nearest missing address in the PC table (i.e., the program counter table). After taking it out, it will calculate the difference between the missing address and the recorded address. If the difference is 1, it indicates the trigger stream access feature, and the missing address will be incremented by 1 and sent to the arbitration filtering unit, and the trigger address will not perform subsequent prefetch triggering work. If there is an entry with the same PC and the difference is not 1, the missing information and the difference will be sent to the stride unit for triggering. If the above conditions are not met, it will be directly sent to the offset unit. The stride unit will directly determine the entry position in the stride table according to the information provided by the PC table, and compare the difference with the recorded stride to check whether the counter meets the emission threshold condition, that is, the preset credibility condition. If it is met, the missing address will be added to the stride to obtain the prefetch address and sent to the arbitration filtering unit. If it is not met, it will be judged whether the corresponding information of the region table is found in the PC table. If it is found, it will be sent to the region table. If it is not found, it will be sent to the offset unit. The region unit will compare the entry (which can be a group) returned by the PC in the region table with the offset (i.e., the offset value) to find whether there is an entry with the same offset. If found, the prefetch address will be calculated according to the bit vector sequence stored therein and sent to the arbitration filtering module. If not found, the prefetch trigger will end. The best offset value obtained by training the score table and the RR table is stored in the delta. When a missing address is sent and there is a valid best offset value, they will be added together to obtain the prefetch address and sent to the arbitration filtering unit. The arbitration filtering unit is used to receive the prefetch requests (i.e., the requests corresponding to the prefetch addresses) from different modules and perform arbitration. It comprehensively judges whether the prefetch request is emitted according to information such as the accuracy information of historical prefetch requests, the cache status information, and the empty / full status of the prefetch queue, and feedbacks the relevant information of the prefetch degree to other modules through the cache status, and emits the prefetch address to the prefetch queue for queuing. The relevant information of the prefetch address is also recorded in the arbitration filtering unit to judge the accuracy of the prefetch.
[0054] Further, in an alternative embodiment, it is also possible to: obtain training information; wherein, the training information includes third instruction address information corresponding to a program counter and third missing data address information; check whether a sixth target entry exists in a preset program counter table; wherein, the sixth target entry is a data entry including fourth instruction address information identical to the third instruction address information, if the sixth target entry exists in the preset program counter table, and the sixth target entry includes position information of a data entry corresponding to the third instruction address information in the preset stride table, then record this position information as first position information; obtain fourth missing data address information from the sixth target entry; wherein, the fourth missing data address information is the previous missing data address information corresponding to the third instruction address information; calculate the difference between the fourth missing data address information and the third missing data address information to obtain stride information, denoted as second stride information; obtain the stride information in the data entry corresponding to the first position information in the preset stride table, denoted as third stride information; if the third stride information is the same as the second stride information, then perform an increment operation on a preset counter in the data entry corresponding to the first position information in the preset stride table, otherwise perform a decrement operation on the counter; wherein, if the count value of the preset counter is greater than a preset threshold, it indicates that the third stride information meets the preset confidence condition.
[0055] Further, embodiments of the present invention can also split the third missing data address information in the training information based on a preset high - order bit range, a preset middle - order bit range, and a preset low - order bit range to obtain a high - order part, a middle - order part, and a low - order part; perform a hash calculation on the high - order part to obtain a spatial region index; perform a preset calculation on the spatial region index and the middle - order part to obtain spatial base address identification information, and store this spatial base address in a preset training table; remove the in - block offset bits from the low - order part to obtain an offset value within the spatial region, and record this offset value in the preset training table; when an eviction address of the cache is obtained, calculate the spatial base address and the offset address corresponding to the eviction address, if a spatial base address and an offset address consistent with those corresponding to the eviction address are found in the preset training table, then determine that the training of the data entry corresponding to the eviction address in the preset region table is completed, and add the position information of this data entry in the preset region table to the preset program counter table. Wherein, the eviction address of the cache is the address at which data needs to be evicted when the cache is full when placing data in the cache. The in - block offset bits are the offset bits in the cache line for storing data.
[0056] Further, in the embodiment of the present invention, the third missing data address information may also be subtracted from the historical training address in the preset address table to obtain a first address difference, where the historical training address is the missing data address information in the historical training information; check whether there is a second address difference identical to the first address difference in the preset score table; if there is an identical second address difference, increase the score corresponding to the identical second address difference; when the preset optimal offset value update condition is satisfied, use the second address difference with the highest score and exceeding the preset score threshold as the optimal offset value and update it to the preset offset value record.
[0057] See Figure 4 as shown in Figure 4 FIG. 1 is a prefetch training schematic diagram provided by the present invention, taking L1D_Miss (i.e., the missing information corresponding to the first-level cache) and prefetch success as training requests as an example. The missing information and prefetch success information of L1D are used as training information and will be first sent to the training queue. After error checking to ensure there are no duplicates, they are sent to the PC table, training table, and offset unit in the first-in, first-out order. After the training request information arrives at the PC table, it will first check whether the entry information in the stride table has been recorded in it. If found, determine the position information of the corresponding entry and send it to the stride table. If not found, select the replacement entry information according to the replacement policy (such as LRU (i.e., Least Recently Used), PLRU (i.e., Pseudo-Least Recently Used), etc.) and update the entry situation, and then send the relevant information to the stride table for training. After the stride table obtains the training request information and the PC table search result, it updates the entry. If it is an update of an existing entry, subtract the training address from the recorded address to obtain the current stride, and compare it with the stride stored in the entry. If they are the same, increment the corresponding counter by 1; otherwise, decrement the counter by 1. If the counter has reached 0 and a decrement operation occurs, update the stride value recorded in the entry to the newly calculated stride and set the counter to 1. If it is to replace an existing entry, set the counter and stride to 0, indicating that no calculation steps have been experienced. In any case, after the search, update the address recorded in the entry to the latest missing address. After the training table obtains the training information, it will divide and split the training address, obtain the index information of the spatial region through high-order hash calculation, and perform operations (such as splicing, AND, OR, etc.) with the median to obtain the tag information, i.e., the spatial base address. The remaining low-order part after removing the in-block offset bits is used as the offset value within the spatial region, and the corresponding entry information is updated.
[0058] After receiving the eviction information in the training table, the corresponding entry will be searched according to the obtained information. If found and the corresponding conditions are met, the corresponding entry information will be evicted to the specified entry in the region table (if the region table is full, the replacement entry will be determined according to the replacement algorithm), and the PC (instruction address) and the stored entry position will be sent to the PC table for update operations.
[0059] The offset value training logic includes three parts: the score table, the RR table, and the delta. The RR table records the training addresses that have occurred in the past. The score table maintains multiple different offset values and their corresponding score values. After a new training address arrives, it will be subtracted from the past training addresses, and then it will be checked whether there are the same entries in the score table to maintain the scores. Every other training cycle, the offset with the highest score and meeting the threshold will be selected as the best offset and stored in the delta. If the conditions are not met, the corresponding delta will be set to 0, indicating that there is no suitable delta.
[0060] The information recorded in the PC table includes PC (instruction address information), last_address (the previous missing address under this PC), the Stride_table entry position, the region_table entry position, the r-bit (the most recent missing address), and the v-bit (valid bit, indicating whether this entry contains valid data). Thanks to the lookup method similar to the multi-level page table, the PC and last_address do not need to be recorded in the other tables, which can save a large amount of storage space. The Stride_table only needs to record the stride, the v-bit, and the counter. The region_table needs to record the spatial region base address, the bit vector sequence, the prefetch mode (starting from the left or right of the offset value in the spatial vector sequence to calculate the prefetch address), and the v-bit. The delta only includes the best offset value. The Train_table records more information, including the P index and label generated by the PC, the label of the spatial region, the offset value for creating the spatial region, the access times of the cache blocks in this spatial region, the prefetch direction, i.e., the aforementioned prefetch mode, and the v-bit.
[0061] Before designing the prefetch unit, the size of the spatial region will be set according to the number of entries that can be recorded in the table, and the memory address will be divided into multiple spatial regions according to the size of the spatial region. The high bits of each spatial region are the same, which is called the spatial base address. Figure 5 For example, if the size of the spatial region is set to 10 cache lines, all memory addresses will be divided into multiple regions based on 10, with the high bits as the spatial base address and the low bits as the offset value within the space. Before the occurrence, all the first offsets and the spatial bit vector sequences are 0. When the size of the spatial region is 10, ten spatial bit vectors are maintained, and the initial sequence is ten 0s. For example, see Figure 5As shown Figure 5 is a schematic diagram of space division provided by an embodiment of the present application.
[0062] Further, referring to Figure 6 as shown Figure 6 is a schematic diagram of the training process of a space bit vector sequence provided by an embodiment of the present application, which is the content in the training table. Assume that the access to this space area has not occurred yet. At this time, the first memory access address that comes will be set as the address for the first access to this space area. When accessing for the first time, if the memory access address is 12, at this time, split the high-order 10 as the space base address and 2 as the offset. Take 2 as the first offset, and set the 2nd position in the space bit vector sequence to 1 (counting from the 0th). After that, the memory access address is 24. At this time, it is retrieved that the space base address is different from the space base address recorded before the current entry. Since it is not maintained in this entry, it is maintained in its corresponding entry. Then comes a memory access address of 15, which is split into 10 and 5, and set the 5th bit vector in the corresponding sequence to 1, and so on. When the memory access address of 10 comes, set the 0th bit to 1. When a cache eviction signal is received, end the maintenance of this space bit vector and record it as a space stream memory access feature. And during the recording process, each time an address in this area is accessed, the access count is incremented. And so on, continuously maintain the table entry information. The PC index and the tag are used to identify and find the corresponding entry, which are recorded after the first memory access. Since the same PC may access multiple space areas, there may be multiple entries under the same PC. Therefore, the PC and the base address are used to determine the specific entry position. It should be noted that, for the sake of easy understanding, in the embodiment of the present application, the memory access address is 12, and at this time, the high-order 10 is split as the space base address and 2 as the offset for description. However, in actual applications, the base address and offset determination method adopted is the aforementioned method, that is, based on the preset high-order bit range, preset middle-order bit range, and preset low-order bit range, the data address information is split to obtain the high-order part, middle-order part, and low-order part; perform a hash calculation on the high-order part to obtain a space area index; perform a preset calculation on the space area index and the middle-order part to obtain a space base address identification information, and remove the in-block offset bits from the low-order part to obtain an offset value within the space area.
[0063] The training process continues until an eviction address is received from the cache (i.e., a new address arrives in the cache and needs to be stored, and an entry needs to be found to be replaced by the new entry. The address recorded in the replaced entry is the eviction address). The eviction address is split in the same way to obtain the spatial base address and the offset value. The spatial base address and the offset value are used to find the entry in the training table with the same spatial base address and offset value. If found, it is considered that the training of the spatial region where the entry is located ends, and it is judged whether it can be recorded in the region table. First, check whether the access count exceeds the threshold. If it exceeds the threshold, calculate the prefetch pattern (i.e., the prefetch direction). If there are more bit vectors larger than the first offset, it is incrementing and recorded as 1; otherwise, it is 0. And the entry is recorded in the region table. The record position in the region table and the position of the evicted entry are fed back to the PC table.
[0064] See Figure 7 as shown in Figure 7 FIG. is a schematic diagram of a prefetching process provided by an embodiment of the present application, and the process of the stride table is omitted. Figure 7 The identifier in it is the PC tag, and the cache eviction address is the cache eviction address. The entry position corresponding to the PC will be found in the PC table, and the memory access address is split into a spatial base address and an offset and compared. Assume that the memory access address (trigger address) is 32, which is split into a spatial base address 30 and an offset 2. At this time, the offset 2 is the same as the first offset recorded in the entry row of the region table, so the match is successful. As Figure 7 can be seen, at this time, bits 0, 2, 3, 5, and 8 are 1, so the corresponding offsets in this space are 0, 2, 3, 5, and 8. Add the spatial base address 30 obtained by splitting the trigger address to the offset values in turn to obtain the prefetch addresses 33, 35, 38, 30, which are issued according to the position from near to far, and the number of issued addresses is related to the prefetch degree. If the prefetch degree is 1, only one address 33 is issued; if the prefetch degree is 2, two addresses 33 and 35 are issued, and so on. The prefetch addresses are calculated preferentially in one direction (increasing / decreasing). Further, in an alternative embodiment, data prefetching is performed based on the prefetch addresses of each prefetch pattern according to a preset priority.
[0065] Further, in an alternative embodiment, data prefetching is performed based on the prefetch addresses of each prefetch pattern, including: performing data prefetching based on the prefetch addresses of each prefetch pattern and the prefetch degree; wherein, the prefetch degree is determined based on one or more performance information.
[0066] Further, see Figure 8 as shown in Figure 8Schematic diagram of an arbitration filtering unit provided by an embodiment of the present invention. Prefetch requests from PC_table, stride_table, delta, and region_tabled are sent to this unit. When there are simultaneous arrivals, the prefetch requests sent to the fliter (i.e., the arbitration filtering unit) are judged according to the priority order of PC_table > stride_table > delta > region_table.
[0067] To prevent the situation where a certain prefetcher (i.e., the unit of the corresponding prefetch mode) has been unable to issue a prefetch address for too long, resulting in timeliness problems, a starvation counter counter is set. When there is a prefetch request from this source, the corresponding valid bit will be set to 1, and the corresponding counter will be incremented by 1 each time it is not selected. When the preset value is reached, the priority of the prefetch request from this source will be forcibly increased to ensure that the prefetch request will not be issued too long.
[0068] The fliter will comprehensively consider the received prefetch accuracy rate, performance status, cache status, and bus bandwidth status to judge information such as the prefetch degree. As shown below, the fliter will obtain the corresponding information from the CSR (i.e., Control and Status Registers) register bank, prefetch history table, and bus every fixed clock cycle and make a judgment.
[0069] The filter will first judge the value of the accuracy rate. If it is lower than the accuracy rate threshold 0, it means that the value of the accuracy rate is too low. At this time, the prefetch address issued by the prefetcher will be suspended. The prefetch address issued during the suspension will be stored in a specific area of the prefetch history table and continuously tracked and trained (not actually issued). Wait until the accuracy rate obtained by training is higher than this threshold and then make a judgment.
[0070] Then the filter will judge whether the bus bandwidth pressure score is lower than the set threshold. If it is higher than the threshold, it means that the bus is already under too much pressure when processing existing miss requests. Too many prefetch requests will cause the bus bandwidth to be occupied, affecting the normal backfill requests. At this time, it is judged whether the accuracy rate corresponding to each type of prefetch request is higher than the first accuracy rate. If it is higher, the original prefetch degree is maintained. If it is lower, the prefetch degree is reduced.
[0071] If the bus bandwidth pressure fraction is lower than the set threshold, the comprehensive evaluation score is calculated based on the cache status returned by the CSR register. The evaluation basis includes factors such as cache miss rate, cache line replacement rate, cache line idle quantity, memory access latency, etc. If the evaluated score is lower than the threshold, the prefetch accuracy is compared with the first accuracy threshold. If it is lower than the threshold, the prefetch degree is decreased by one; if it is higher than the threshold, the original prefetch degree is maintained. If the score evaluated for the cache status is higher than the set threshold, the second accuracy threshold is evaluated. If it is lower than this value, the original prefetch degree is maintained; if it is higher than this value, the prefetch degree is increased by one.
[0072] As Figure 9 shown, Figure 9 FIG. is a schematic diagram of a prefetch degree training process provided by an embodiment of the present invention. This module sets three situations for the prefetch unit to stop. The first is when the prefetch accuracy is lower than the accuracy threshold 0, which means that the prefetch accuracy is too low and will cause too much negative impact. In this case, the prefetch unit is paused first. The second is when the bus bandwidth pressure is too high. This threshold can have a multiple relationship with the previously mentioned bus bandwidth pressure fraction threshold. At this time, the prefetch request will affect the time of the normal memory access fill request and may have a negative impact on performance. The third is when the software requests to stop. The prefetch unit is controlled through the corresponding CSR register. At this time, the prefetch unit stops sending the prefetch address to the prefetch queue.
[0073] When the prefetch unit stops, training continues. The calculated prefetch address is sent to a dedicated register for storage and continuous tracking. When the corresponding conditions are met, the prefetch degree is set to the default value and the normal process resumes. The corresponding conditions include that the accuracy meets the threshold, the bus bandwidth pressure is not so high, and the software stops the prefetch unit. When restarting, except for the accuracy factor, the other prefetch degrees maintained during training are used. After the stop and restart caused by the accuracy factor, the prefetch degree is set to 1. In the embodiments of the present application, accuracy threshold 0, accuracy threshold 1, and accuracy threshold 2 are set.
[0074] The prefetch queue sends the prefetch address according to the first-in-first-out principle. When the prefetch address is full, the filter is paused from sending the prefetch address. Before sending, it will first check whether there are existing entries in the MSHR (i.e., the miss status register) and CacheLine (i.e., the cache line). If there are existing entries, they are fed back to the filter as one of the bases for cache status score evaluation.
[0075] The prefetch requests sent by the filter to the prefetch queue are recorded in the prefetch history table simultaneously. When bus backfill occurs, the entries are checked in the prefetch history table and the backfill time is recorded. When a memory access hit occurs, it is searched in the prefetch history table to determine whether it is a hit of the prefetch request, and the corresponding prefetch success request and backfill-related information are fed back to the prefetch module as the basis for training the prefetch address. When the table is full, the earliest entry is evicted and recorded as a prefetch failure (even if the prefetch address is used, it is a premature prefetch with timeliness issues), and the corresponding counter is incremented by 1. The prefetch accuracy is calculated based on the value of this counter at fixed clock intervals and fed back to the filter.
[0076] The embodiment of the present invention adopts a method similar to a multi-level page table, and reduces the storage of duplicate information in the remaining storage tables through the indexing method of the PC table. When prefetching is triggered, it can be determined which type of prefetch request is satisfied through the PC table, without the need to search multiple tables in parallel, reducing the power consumption required for searching. The judgment logic for the same triggered prefetch address is set inside the multi-mode prefetch unit, and the implicit priority condition is used to avoid issuing prefetch addresses for data that will not be used, reducing performance loss. Through the multiple judgment logic for the triggered prefetch address, the most suitable memory access pattern is ensured to be found and the prefetch address is issued to the greatest extent. A filter is set up to dynamically adjust the prefetch degree by combining the cache state, bus bandwidth, and prefetch performance. When there is high bus bandwidth pressure, too low accuracy, and software regulation, the prefetch unit can be turned off to avoid performance loss. When the prefetch address is turned off, the prefetch address and prefetch degree are continuously trained to achieve rapid recovery. A prefetch history table is set up to evaluate the prefetch performance internally and feed back the signals required by other prefetch units, improving the design versatility and avoiding modifying the cache to implement the function.
[0077] It can be seen that the method of indexing the multi-level page table by the PC table can effectively reduce the storage cost. When prefetching is triggered, it is not necessary to check multiple tables simultaneously. Some requests can be filtered out through the PC table, reducing the additional power consumption caused by searching. By using the implicit priority condition inside, unnecessary prefetch requests are reduced, and the power consumption and operation loss are reduced. The possibility of issuing the prefetch address is maximally improved through multi-level judgment, increasing the coverage rate. The prefetch degree is adjusted through the filter and software adjustment is supported, improving the adaptability to different types of application programs. The prefetch performance parameters are recorded inside the prefetch unit, avoiding modification of external units during reuse and improving the reusability.
[0078] In addition, in the embodiments of the present invention, the best offset value determination unit can adopt different types of offset prefetchers. For example, the example uses a modified structure of BOP (Best Offset Prefetcher), and others such as Berti (a prefetching based on local increment) and SandBox (Sandbox Prefetcher) can also achieve similar effects. Similarly, the spatial prefetcher in this example is a modified structure of SMS (Spatial Memory Streaming Prefetcher), and using other spatial prefetchers can achieve similar effects. More different types of prefetchers can be added in the form of lookup tables with more levels based on performance metrics such as accuracy or coverage to achieve complementary effects. The prefetch degree can be directly adjusted by software.
[0079] See Figure 10 As shown, the embodiments of the present invention disclose a data prefetching device, including:
[0080] A missing information acquisition module 71, configured to acquire target missing information; where the target missing information includes first instruction address information corresponding to a program counter and first missing data address information;
[0081] A stream prefetching mode processing module 72, configured to acquire stream prefetching mode determination information from a preset program counter table based on the target missing information, and generate a prefetch address corresponding to the stream prefetching mode when it is determined that a preset stream prefetching mode condition is satisfied based on the target missing information and the stream prefetching mode determination information, so as to perform data prefetching based on the prefetch address;
[0082] A target entry determination module 73, configured to determine a first target entry in the preset program counter table if the preset stream prefetching mode condition is not satisfied, where the first target entry is a data entry including second instruction address information identical to the first instruction address information, and the first target entry includes position information of data entries corresponding to the first instruction address information in multiple other prefetching mode determination tables;
[0083] A multi-prefetching mode processing module 74, configured to perform determination of other prefetching modes based on the position information in the first target entry, and generate a prefetch address corresponding to the other prefetching mode when it is determined to adopt the other prefetching mode, so as to perform data prefetching based on the prefetch address.
[0084] In an alternative embodiment, the stream prefetching mode processing module 72 may specifically be configured to:
[0085] Determine the first target entry and the second target entry from a preset program counter table, where the second target entry is a data entry containing the instruction address information in the most recently matched missing information;
[0086] Obtain second missing data address information from the first target entry and the second target entry; wherein the second missing data address information is the previous missing data address information corresponding to the instruction address information in the first target entry or the second target entry.
[0087] In an optional implementation manner, the stream prefetch mode processing module 72 may specifically be used for:
[0088] If the difference between any obtained second missing data address information and the first missing data address information is 1, it is determined that the preset stream prefetch mode condition is satisfied.
[0089] In an optional implementation manner, the stream prefetch mode processing module 72 may specifically be used for:
[0090] Add 1 to the first missing data address information to obtain a prefetch address corresponding to the stream prefetch mode.
[0091] In an optional implementation manner, the multi-prefetch mode processing module 74 may specifically be used for: when other prefetch modes include a stride prefetch mode, the corresponding prefetch mode determination table is a preset stride table; if there is the first target entry and the difference between the second missing data address information in the first target entry and the first missing data address information is not 1, then determine a third target entry corresponding to the position information of the data entry corresponding to the first instruction address information in the preset stride table from the preset stride table according to the position information of the data entry corresponding to the first instruction address information in the first target entry in the preset stride table; obtain stride information from the third target entry to obtain a first stride information, if the first stride information is the same as the difference between the second missing data address information and the first missing data address information, and the first stride information meets the preset credibility condition, then determine to adopt the stride prefetch mode. Add the first missing data address information to the first stride information to obtain a prefetch address corresponding to the stride prefetch mode.
[0092] In an alternative embodiment, the multi-prefetch mode processing module 74 may be specifically configured to: when other prefetch modes include a space-based prefetch mode, the corresponding prefetch mode determination table is a preset area table; according to the position information of the data entry corresponding to the first instruction address information in the preset area table in the first target entry, determine a fourth target entry corresponding to the position information from the preset area table; extract the data within the preset bit range in the first missing data address information to obtain a first offset value; if a fifth target entry is determined in the preset area table, determine that the space-based prefetch mode is adopted; wherein, the fifth target entry is a data entry including a second offset value that is the same as the first offset value. Based on the first missing data address information and the bit vector sequence in the fifth target entry, obtain the prefetch address of the space-based prefetch mode. Wherein, the space bit vector sequence represents the access situation corresponding to the same space base address in the fifth target entry.
[0093] In an alternative embodiment, the apparatus may also be configured to: if the first target entry or the second target entry does not exist in the preset program counter table, determine the prefetch mode as offset prefetch; if the first stride information is inconsistent with the difference or does not meet the preset confidence condition, and the position information of the data entry corresponding to the first instruction address information in the preset area table does not exist in the first target entry, determine that the offset prefetch mode is adopted. If an optimal offset value is recorded in the preset offset value record, determine the prefetch address corresponding to the offset prefetch mode based on the first missing data address information and the optimal offset value.
[0094] In an alternative embodiment, the apparatus further includes a queue adding module, configured to add missing information to a trigger queue when a preset data prefetch condition is satisfied, where the missing information includes the instruction address information corresponding to the program counter and the missing data address information; correspondingly, the missing information obtaining module 71 is specifically configured to obtain target missing information from the trigger queue.
[0095] Further, the apparatus further includes a training module, configured to:
[0096] Obtain training information; wherein the training information includes the third instruction address information corresponding to the program counter and the third missing data address information;
[0097] Check whether a sixth target entry exists in the preset program counter table; wherein the sixth target entry is a data entry including a fourth instruction address information that is the same as the third instruction address information;
[0098] If there is a sixth target entry in the preset program counter table, and the position information of the data entry corresponding to the third instruction address information in the preset stride table is included in the sixth target entry, then record this position information as the first position information;
[0099] Obtain fourth missing data address information from the sixth target entry; wherein, the fourth missing data address information is the previous missing data address information corresponding to the third instruction address information;
[0100] Calculate the difference between the fourth missing data address information and the third missing data address information to obtain stride information, denoted as the second stride information;
[0101] Obtain the stride information in the data entry corresponding to the first position information in the preset stride table, denoted as the third stride information;
[0102] If the third stride information is the same as the second stride information, perform an increment operation on the preset counter in the data entry corresponding to the first position information in the preset stride table, otherwise perform a decrement operation on the preset counter;
[0103] Wherein, if the count value of the preset counter is greater than a preset threshold, it indicates that the third stride information meets the preset credibility condition.
[0104] Based on a preset high-order bit range, a preset middle-order bit range, and a preset low-order bit range, split the third missing data address information in the training information to obtain a high-order part, a middle-order part, and a low-order part;
[0105] Perform a hash calculation on the high-order part to obtain a spatial region index;
[0106] Perform a preset calculation on the spatial region index and the middle-order part to obtain a spatial base address, and store this spatial base address in a preset training table;
[0107] Remove the in-block offset bits from the low-order part to obtain an offset value within the spatial region, and record this offset value in the preset training table;
[0108] When an eviction address cached is obtained, calculate the spatial base address and the offset address corresponding to the eviction address. If a spatial base address and an offset address that are the same as those corresponding to the eviction address are found in the preset training table, it is determined that the training of the data entry corresponding to the eviction address in the preset region table is completed, and add the position information of this data entry in the preset region table to the preset program counter table.
[0109] Subtract the third missing data address information from the historical training addresses in the preset address table to obtain a first address difference, where the historical training addresses are the missing data address information in the historical training information;
[0110] Check whether there is a second address difference identical to the first address difference in the preset score table;
[0111] If there is an identical second address difference, increase the score corresponding to the identical second address difference;
[0112] When the preset optimal offset value update condition is satisfied, use the second address difference with the highest score and exceeding the preset score threshold as the optimal offset value to update the preset offset value record.
[0113] Furthermore, the device includes a data prefetch module: used to perform data prefetching based on the prefetch addresses of each prefetch mode according to a preset priority.
[0114] In an alternative embodiment, the data prefetch module is specifically configured to perform data prefetching based on the prefetch addresses of each prefetch mode and the prefetch degree; wherein, the prefetch degree is determined based on one or more performance information.
[0115] It can be seen that the beneficial effects of the present invention are as follows: Determine whether to adopt the stream prefetch mode through the preset program counter table. In the case of not adopting the stream prefetch mode, perform the determination of other prefetch modes. In this way, multi-mode step-by-step determination avoids the situation where the same missing information triggers the search and determination process of all prefetch modes. Moreover, the preset program counter table contains the position information of the data entries corresponding to the first instruction address information in various other prefetch mode determination tables, realizing the indexing of other prefetch mode determination tables and avoiding redundant information in various prefetch mode determination tables. In this way, the prefetch mode search overhead and storage cost are reduced.
[0116] Figure 10 For the description of the features in the corresponding embodiments, reference can be made to Figure 1 the relevant descriptions of the corresponding embodiments, which will not be elaborated here one by one.
[0117] Figure 11 The following is a structural diagram of an electronic device provided by an embodiment of the present invention, as Figure 11 shown. The electronic device includes: a memory 80 for storing computer programs;
[0118] a processor 81 for implementing the steps of the data prefetch method in the above embodiment when executing the computer program.
[0119] Among them, the processor 81 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 81 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 81 may also include a main processor and a coprocessor. The main processor is a processor used to process data in the wake state, also known as the central processing unit (CPU); the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 81 may be integrated with a graphics processing unit (GPU), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 81 may further include an artificial intelligence (AI) processor, and the AI processor is used to process computational operations related to machine learning.
[0120] The memory 80 may include one or more computer-readable storage media, and the computer-readable storage media may be non-transitory. The memory 80 may further include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash storage devices. In this embodiment, the memory 80 is at least used to store the following computer program 801. After the computer program is loaded and executed by the processor 81, it can implement the relevant steps of the data prefetch method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 80 may further include an operating system 802 and data 803, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 802 may include Windows, Unix, Linux, etc. The data 803 may include, but is not limited to, cache data, etc.
[0121] In some embodiments, the electronic device may further include a display screen 82, an input / output interface 83, a communication interface 84, a power supply 85, and a communication bus 86.
[0122] Those skilled in the art can understand that Figure 11 the structure shown in
[0123] It can be understood that if the data prefetching method in the above embodiments is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the current technology, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods in the various embodiments of the present invention. The foregoing storage media include: USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), electrically erasable programmable ROMs, registers, hard disks, removable disks, CD-ROMs, magnetic disks, or optical disks, and other media that can store program codes.
[0124] Based on this, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the data prefetching method as described above are implemented.
[0125] Next, a computer program product provided by an embodiment of the present invention will be introduced. The computer program product described below can be referred to each other with other embodiments described in this article.
[0126] A computer program product includes a computer program / instructions. When the computer program / instructions are executed by a processor, the steps of the data prefetching method disclosed above are implemented.
[0127] The above has introduced in detail a data prefetching method, device, equipment, medium, and product provided by an embodiment of the present invention. The various embodiments in the specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The same or similar parts among the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple. For the relevant parts, refer to the description of the method part.
[0128] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this article can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0129] The above has introduced in detail a data prefetching method, device, equipment, medium and product provided by the present invention. Specific examples are used in this article to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the protection scope of the present invention.
Claims
1. A data pre-fetching method, characterized in that: include: Obtaining target missing information; wherein the target missing information includes first instruction address information and first missing data address information corresponding to the program counter; Acquire stream prefetch mode determination information from a preset program counter table based on the target missing information, and generate a prefetch address corresponding to the stream prefetch mode when it is determined that a preset stream prefetch mode condition is met based on the target missing information and the stream prefetch mode determination information, so as to perform data prefetching based on the prefetch address; If the preset stream prefetch mode condition is not met, determining a first target entry in the preset program counter table, wherein the first target entry is a data entry containing second instruction address information that is the same as the first instruction address information, and the first target entry contains location information of data entries corresponding to the first instruction address information in a plurality of other prefetch mode determination tables; Other prefetch modes are determined based on the position information in the first target entry, and when it is determined that other prefetch modes are to be adopted, prefetch addresses corresponding to other prefetch modes are generated so as to perform data prefetching based on the prefetch addresses.
2. The data pre-fetching method according to claim 1, characterized in that: Acquiring stream prefetch mode determination information based on the target missing information from a preset program counter table, comprising: Determine the first target entry and the second target entry from a preset program counter table, wherein the second target entry is a data entry containing the address information of the instruction that was most recently matched to the missing information; Second missing data address information is obtained from the first target entry and the second target entry; wherein the second missing data address information is the last missing data address information corresponding to the instruction address information in the first target entry or the second target entry.
3. The data pre-fetching method according to claim 2, characterized in that: Also includes: If the difference between any second missing data address information obtained and the first missing data address information is 1, it is determined that the preset stream prefetch mode condition is met.
4. The data pre-fetching method according to claim 3, characterized in that: Generate the prefetch address corresponding to the stream prefetch mode, including: The first missing data address information is increased by 1 to obtain a prefetch address corresponding to the stream prefetch mode.
5. The data pre-fetching method according to claim 3, characterized in that: Other prefetch modes include a stride prefetch mode, and the corresponding prefetch mode determination table is a preset stride table; Accordingly, determining other prefetch modes based on the position information in the first target entry includes: If the first target entry exists, and the difference between the second missing data address information in the first target entry and the first missing data address information is not 1, determining a third target entry corresponding to the position information from the preset stride table according to the position information of the data entry corresponding to the first instruction address information in the preset stride table in the first target entry; Acquire stride information from the third target entry to obtain the first step information, and if the first step information and the difference between the second missing data address information and the first missing data address information are the same, and the first step information meets a preset credibility condition, determine to adopt the stride prefetch mode.
6. The data pre-fetching method according to claim 5, characterized in that: Generate prefetch addresses corresponding to other prefetch modes, including: The first missing data address information is added to the first stride information to obtain a prefetch address corresponding to the stride prefetch mode.
7. The data pre-fetching method according to claim 5, characterized in that: Other prefetch modes include space-based prefetch modes, and the corresponding prefetch mode determination table is a preset area table; Accordingly, determining other prefetch modes based on the position information in the first target entry includes: According to the position information of the data entry corresponding to the first instruction address information in the preset area table in the first target entry, determining a fourth target entry corresponding to the position information from the preset area table; Extracting data within a preset bit range in the first missing data address information to obtain a first offset value; If a fifth target entry is determined in the preset area table, determining to adopt a space-based prefetching mode; The fifth target entry is a data entry including a second offset value that is consistent with the first offset value.
8. The data pre-fetching method according to claim 7, characterized in that: Generate prefetch addresses corresponding to other prefetch modes, including: Based on the first missing data address information and the spatial bit vector sequence in the fifth target entry, a prefetch address of the space-based prefetch mode is obtained, wherein the spatial bit vector sequence represents an access situation corresponding to the same spatial base address in the fifth target entry.
9. The data pre-fetching method according to claim 7, characterized in that: Also includes: If the first target entry or the second target entry does not exist in the preset program counter table, determining the prefetch mode as offset prefetch; If the first step information is inconsistent with the difference, or does not meet the preset credibility condition, and the location information of the data entry corresponding to the first instruction address information in the preset area table does not exist in the first target entry, it is determined to adopt the offset prefetch mode.
10. The data pre-fetching method according to claim 9, characterized in that: Also includes: If an optimal offset value is recorded in the preset offset value record, a prefetch address corresponding to the offset prefetch mode is determined based on the first missing data address information and the optimal offset value.
11. The data pre-fetching method according to claim 1, characterized in that: Also includes: When the preset data pre-fetch condition is met, missing information is added to the trigger queue, wherein the missing information includes instruction address information corresponding to the program counter and missing data address information; Accordingly, obtain the target missing information, including: The target missing information is obtained from the trigger queue.
12. The data pre-fetching method according to claim 10, characterized in that: Also includes: Acquire training information; wherein the training information includes third instruction address information and third missing data address information corresponding to the program counter; Checking whether there is a sixth target entry in the preset program counter table; wherein the sixth target entry is a data entry containing fourth instruction address information that is the same as the third instruction address information; If there is a sixth target entry in the preset program counter table, and the sixth target entry includes position information of a data entry corresponding to the third instruction address information in the preset stride table, the position information is recorded as the first position information; Acquire fourth missing data address information from the sixth target entry; wherein the fourth missing data address information is the last missing data address information corresponding to the third instruction address information; Calculate the difference between the fourth missing data address information and the third missing data address information to obtain stride information, which is recorded as second stride information; Obtain the stride information in the data entry corresponding to the first position information in the preset stride table, and record it as the third stride information; If the third stride information is the same as the second stride information, then performing an addition operation on a preset counter in the data entry corresponding to the first position information in the preset stride table; otherwise, performing a subtraction operation on the preset counter; Wherein, if the count value of the preset counter is greater than a preset threshold, it indicates that the third stride information meets the preset credibility condition.
13. The data pre-fetching method according to claim 12, characterized in that: Also includes: Splitting the third missing data address information in the training information based on a preset high-order bit range, a preset middle-order bit range, and a preset low-order bit range to obtain a high-order part, a middle-order part, and a low-order part; Performing hash calculation on the high-order part to obtain a spatial region index; Performing a preset calculation on the spatial region index and the median part to obtain a spatial base address, and storing the spatial base address in a preset training table; Removing the offset bit in the block from the low-order part to obtain an offset value in the spatial region, and recording the offset value in the preset training table; When the cached eviction address is obtained, the space base address and the offset address corresponding to the eviction address are calculated. If the space base address and the offset address that are consistent with the space base address and the offset address corresponding to the eviction address are found in the preset training table, it is determined that the training of the data entry corresponding to the eviction address in the preset area table is completed, and the location information of the data entry in the preset area table is added to the preset program counter table.
14. The data pre-fetching method according to claim 13, characterized in that: Also includes: Subtracting the third missing data address information from the historical training address in the preset address table to obtain a first address difference, wherein the historical training address is the missing data address information in the historical training information; Searching in a preset score table whether there is a second address difference that is the same as the first address difference; If there is an identical second address difference, the score corresponding to the identical second address difference is increased; When the preset optimal offset value update condition is met, the second address difference value with the highest score and exceeding the preset score threshold is updated as the optimal offset value to the preset offset value record.
15. The data pre-fetching method according to claim 14, characterized in that: Also includes: Data prefetching is performed based on the prefetch addresses of each prefetching mode according to a preset priority.
16. The data pre-fetching method according to any one of claims 1 to 15, characterized in that: Data prefetching is performed based on the prefetch address of each prefetch mode, including: Prefetching data based on the prefetch address and prefetch degree of each prefetch mode; The prefetch degree is determined based on one or more performance information.
17. A data pre-fetching device, characterized in that: include: A missing information acquisition module, used to acquire target missing information; wherein the target missing information includes first instruction address information and first missing data address information corresponding to the program counter; a stream prefetch mode processing module, configured to obtain stream prefetch mode determination information from a preset program counter table based on the target missing information, and generate a prefetch address corresponding to the stream prefetch mode when it is determined based on the target missing information and the stream prefetch mode determination information that a preset stream prefetch mode condition is met, so as to perform data prefetching based on the prefetch address; a target entry determination module, configured to determine a first target entry in the preset program counter table if the preset stream prefetch mode condition is not satisfied, wherein the first target entry is a data entry containing second instruction address information that is the same as the first instruction address information, and the first target entry contains location information of data entries corresponding to the first instruction address information in a plurality of other prefetch mode determination tables; The multi-prefetch mode processing module is used to determine other prefetch modes based on the position information in the first target entry, and when it is determined that other prefetch modes are adopted, generate prefetch addresses corresponding to other prefetch modes so as to prefetch data based on the prefetch addresses.
18. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the steps of the data prefetching method according to any one of claims 1 to 16.
19. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data pre-fetching method according to any one of claims 1 to 16 are implemented.
20. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the data pre-fetching method according to any one of claims 1 to 16 are implemented.
Citation Information
Patent Citations
Memory access mode recognition method and device and electronic equipment
CN115795442A
Prefetching method and device, electronic equipment and readable storage medium
CN118069548A
Adaptive data prefetching method and device capable of being adjusted and optimized, and electronic equipment
CN118113345A
Data prefetching method and device, electronic equipment and readable storage medium
CN118276946A
Spatial memory streaming confidence mechanism
US20180329822A1
Cited By
Training method and device of fixed step length prefetcher based on instruction address
CN121560780A
Data prefetching method and device and chip
CN121560781A
Data prefetching methods, devices and chips
CN121560781B