Virtual address prefetching device, processor and prefetching method
By dynamically adjusting the trust levels of N prefetch strategies, the problem of insufficient precision of virtual address prefetch strategies is solved, the flexibility and reliability of the prefetch device are improved, and the performance of the processor is enhanced.
Patent Information
- Application Number
- CN202510805467.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-16
- Publication Date
- 2025-09-26
AI Technical Summary
In the prior art, the virtual address prefetching strategy has insufficient prefetching accuracy, which leads to a decrease in processor performance. In particular, when the program memory access pattern changes, the TLB hit rate is not high.
A virtual address prefetch device is used to dynamically adjust the trust of N prefetch strategies through the combination of a cache module, a query module and a decision module. The trust status of the prefetch strategy is updated according to the virtual address that is missed in the memory access instruction stream, and the prefetch operation is adaptively adjusted.
The flexibility and reliability of the prefetch device are improved, the accuracy of the prefetch operation is enhanced, the fluctuation of the TLB hit rate is reduced, and the performance of the processor is improved.
Smart Images

Figure CN120705078A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a virtual address prefetching device, processor, and prefetching method. Background Art
[0002] Virtual address prefetching technology refers to a technology in which, during the process of accessing memory, the prefetch device predicts the virtual addresses that may be accessed next based on the current memory access pattern, and loads the page table entries corresponding to the VPNs (Virtual Page Numbers) of these virtual addresses that may be accessed into the TLB (Translation Lookaside Buffer) in advance to reduce the number of memory accesses.
[0003] The key to virtual address prefetching is whether the prefetching strategy of the prefetching device can accurately predict the VPN of the virtual address that may be accessed next. In related technologies, the prefetching strategy of the prefetching device usually adopts a single prefetching strategy, such as the next-line prefetching strategy, or selects from multiple prefetching strategies based on predefined rules.
[0004] However, a single prefetch strategy has the problem of insufficient prefetching precision, resulting in a low hit rate of page table entries prefetched into the TLB, affecting processor performance; the method of selecting from multiple prefetching strategies based on predefined rules relies on the accuracy of the rules. When the program's memory access pattern changes outside the scope of the rule definition, the problem of insufficient prefetching precision also exists. Summary of the Invention
[0005] The present application provides a virtual address prefetching device, processor, and prefetching method to solve the technical problems existing in the related art. Specifically, it includes the following technical solutions.
[0006] In a first aspect, the present application provides a virtual address prefetch device, the prefetch device comprising: a cache module configured to cache prefetch virtual page numbers VPN in N prediction queues, the prefetch VPNs in the N prediction queues corresponding to virtual addresses of page table entries cached in a translation lookaside buffer (TLB) module that did not hit a memory access instruction stream; a query module configured to query the prefetch VPNs in the N prediction queues respectively based on the VPN of a next virtual address of a first virtual address in the memory access instruction stream, to obtain query results for the N prediction queues, wherein the first virtual address is the virtual address of a page table entry cached in the TLB module that did not hit a memory access instruction stream; A decision module is configured to update the trust of the N prefetch strategies in the decision module according to the query result; determine the prefetch VPN of the second virtual address according to the updated trust and the trust status of the first prefetch strategy, the first prefetch strategy is the prefetch strategy corresponding to the first virtual address in the N prefetch strategies, the second virtual address is the virtual address of the next page table entry cached in the TLB module that misses the first virtual address in the memory access instruction stream, and the trust status of the N prefetch strategies indicates the reliability of the N prefetch strategies; wherein N is an integer greater than or equal to 2, and the N prefetch strategies correspond one-to-one to the N prediction queues.
[0007] In some possible implementations, the query result includes a hit or a miss, and when the decision module updates the trust of the N prefetch strategies in the decision module according to the query result, it is configured to: when the query results of the N prediction queues are different, increase the trust of the prefetch strategy corresponding to the prediction queue whose query result is a hit in the N prediction queues; and reduce the trust of the prefetch strategy corresponding to the prediction queue whose query result is a miss in the N prediction queues.
[0008] In some possible implementations, the N prefetch strategies include a second prefetch strategy corresponding to the second virtual address, and when the decision module determines the prefetch VPN of the second virtual address based on the updated trust level and the trust status of the first prefetch strategy, it is configured to: determine the second prefetch strategy based on the updated trust level and the trust status of the first prefetch strategy; determine the prefetch VPN of the second virtual address based on the VPN of the second virtual address and the second prefetch strategy.
[0009] In some possible implementations, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; when the decision module determines the second prefetch strategy based on the updated trust degree and the trust state of the first prefetch strategy, it is configured as follows: if the trust state of the first prefetch strategy is the first trust state, and the first trust degree of the updated first prefetch strategy is the highest among the updated trust degrees of the N prefetch strategies, the first prefetch strategy is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the first trust state.
[0010] In some possible implementations, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; when the decision module determines the second prefetch strategy based on the updated trust and the trust state of the first prefetch strategy, it is configured as follows: if the trust state of the first prefetch strategy is the first trust state, and the first trust of the first prefetch strategy is not the highest among the updated trusts of the N prefetch strategies, the first prefetch strategy is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the second trust state.
[0011] In some possible implementations, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; when the decision module determines the second prefetch strategy based on the updated trust level and the trust state of the first prefetch strategy, it is configured as follows: if the trust state of the first prefetch strategy is the second trust state, and the first trust level of the first prefetch strategy is not the highest among the updated trust levels of the N prefetch strategies, the prefetch strategy among the N prefetch strategies corresponding to the highest trust level among the multiple trust levels is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the second trust state.
[0012] In some possible implementations, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; when the decision module determines the second prefetch strategy based on the updated trust degree and the trust state of the first prefetch strategy, it is configured as follows: if the trust state of the first prefetch strategy is the second trust state, and the first trust degree of the first prefetch strategy is the highest among the updated trust degrees of the N prefetch strategies, the first prefetch strategy is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the first trust state.
[0013] In some possible implementations, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; when the decision module determines the second prefetch strategy based on the updated trust and the trust state of the first prefetch strategy, it is configured as: if the trust state of the first prefetch strategy is the second trust state, and the updated trust levels of the N prefetch strategies are the same, the N prefetch strategies are determined as the second prefetch strategies.
[0014] In some possible implementations, the N prediction queues manage the pre-fetched VPNs based on a first-in-first-out principle.
[0015] In a second aspect, the present application provides a processor, comprising a prefetch device and an execution unit, wherein the execution unit is used to receive a prefetch VPN of the prefetch device and perform a prefetch operation according to the prefetch VPN, and the prefetch device is such as the prefetch device described in any one of the first aspects of the present application.
[0016] In a third aspect, the present application provides a method for prefetching a virtual address, the method comprising: querying the prefetch VPNs in the N prediction queues respectively according to the VPN of the next virtual address of the first virtual address in the memory access instruction stream, and obtaining query results of the N prediction queues, wherein the first virtual address is the virtual address of the page table entry cached in the TLB module that is not hit in the memory access instruction stream, and the prefetch VPN corresponds to the virtual address of the page table entry cached in the TLB module that is not hit in the memory access instruction stream; updating the N prefetch decision modules in the prefetch device according to the query results. The trust degree of the strategy is updated; a prefetch VPN of the second virtual address is determined according to the updated trust degree and the trust state of the first prefetch strategy, the first prefetch strategy is the prefetch strategy corresponding to the first virtual address in the N prefetch strategies, the second virtual address is the virtual address of the next miss of the first virtual address in the memory access instruction stream and the cached page table entry in the TLB module, and the trust state of the N prefetch strategies indicates the reliability of the N prefetch strategies; wherein N is an integer greater than or equal to 2, and the N prefetch strategies correspond to the N prediction queues one-to-one.
[0017] In some possible implementations, the query result includes a hit or a miss, and updating the trust of the N prefetch strategies in the decision module based on the query result includes: when the query results of the N prediction queues are different, increasing the trust of the prefetch strategy corresponding to the prediction queue whose query result is a hit in the N prediction queues; and reducing the trust of the prefetch strategy corresponding to the prediction queue whose query result is a miss in the N prediction queues.
[0018] In some possible implementations, the N prefetch strategies include a second prefetch strategy corresponding to the second virtual address, and determining the prefetch VPN of the second virtual address based on the updated trust and the trust status of the first prefetch strategy includes: determining the second prefetch strategy based on the updated trust and the trust status of the first prefetch strategy; determining the prefetch VPN of the second virtual address based on the VPN of the second virtual address and the second prefetch strategy.
[0019] In some possible implementations, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; determining the second prefetch strategy based on the updated trust and the trust state of the first prefetch strategy includes: if the trust state of the first prefetch strategy is the first trust state, and the first trust of the updated first prefetch strategy is the highest among the updated trusts of the N prefetch strategies, determining the first prefetch strategy as the second prefetch strategy, and determining the trust state of the second prefetch strategy as the first trust state.
[0020] In some possible implementations, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; determining the second prefetch strategy based on the updated trust and the trust state of the first prefetch strategy includes: if the trust state of the first prefetch strategy is the first trust state, and the first trust of the first prefetch strategy is not the highest among the updated trusts of the N prefetch strategies, determining the first prefetch strategy as the second prefetch strategy, and determining the trust state of the second prefetch strategy as the second trust state.
[0021] In some possible implementations, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; determining the second prefetch strategy based on the updated trust level and the trust state of the first prefetch strategy includes: if the trust state of the first prefetch strategy is the second trust state, and the first trust level of the first prefetch strategy is not the highest among the updated trust levels of the N prefetch strategies, determining the prefetch strategy among the N prefetch strategies corresponding to the highest trust level among the multiple trust levels as the second prefetch strategy, and determining the trust state of the second prefetch strategy as the second trust state.
[0022] In some possible implementations, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; determining the second prefetch strategy based on the updated trust and the trust state of the first prefetch strategy includes: if the trust state of the first prefetch strategy is the second trust state, and the first trust of the first prefetch strategy is the highest among the updated trusts of the N prefetch strategies, determining the first prefetch strategy as the second prefetch strategy, and determining the trust state of the second prefetch strategy as the first trust state.
[0023] In some possible implementations, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; determining the second prefetch strategy based on the updated trust and the trust state of the first prefetch strategy includes: if the trust state of the first prefetch strategy is the second trust state, and the updated trust levels of the N prefetch strategies are the same, determining the N prefetch strategies as the second prefetch strategies.
[0024] In some possible implementations, the N prediction queues manage the pre-fetched VPNs based on a first-in-first-out principle.
[0025] In a fourth aspect, the present application provides a computer-readable storage medium on which program instructions for prefetching virtual addresses are stored. When the program instructions are executed by one or more processors, the processors implement the method described in any one of the third aspects of the present application.
[0026] In a fifth aspect, the present application provides a computer program product, which includes a computer program, and the computer program is executed by a processor to enable the computer to implement any method described in the third aspect of the present application.
[0027] The beneficial effects of the technical solution provided by this application include at least:
[0028] The technical solution provided by the present application can save all the prefetch VPNs corresponding to the memory access instructions that do not hit the page table entries cached in the TLB module in the memory access instruction stream into the cache module, so that the accuracy of the prefetch strategy corresponding to the first memory access instruction can be verified based on the VPN carried by the next memory access instruction of the first memory access instruction that indicates the VPN that the program actually wants to access next, and the prefetch VPN predicted by the prefetch device, and the trust of the N prefetch strategies can be updated, so that when determining the prefetch VPN corresponding to the second memory access instruction, adaptive adjustments can be made. In addition, in order to avoid the fluctuation of the trust of the N prefetch strategies when the memory access mode of the program occasionally changes, which may cause unexpected adjustments in the prefetch device, after the trust of the N prefetch strategies is updated, the prefetch device will further consider the reliability of the prefetch strategy, which is conducive to improving the flexibility and reliability of the prefetch device. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0030] Figure 1 It is a schematic diagram of the architecture of a prefetch device that integrates a prefetch function and adopts a single prefetch strategy;
[0031] Figure 2 It is a schematic diagram of the architecture of a prefetching device that integrates a prefetching function and selects from multiple prefetching strategies based on preset rules;
[0032] Figure 3 Schematic diagram of the structure of a virtual address prefetching device provided in an embodiment of the present application;
[0033] Figure 4 Schematic diagram of the architecture of the pre-fetching device provided in an embodiment of the present application;
[0034] Figure 5 is a flowchart of a virtual address prefetching method provided by an embodiment of the present application;
[0035] Figure 6 It is a structural diagram of the processor provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0037] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0038] In a system that adopts memory virtualization technology, when a memory access subject, such as a program running in the system, has a need to access memory, the memory access subject actually directly accesses the virtual address allocated by the system, and its memory access process includes the following steps: (1) querying the page table entry cached in the TLB according to the VPN of the virtual address in the memory access instruction stream; (2) if the page table entry cached in the TLB hits, converting the virtual address into a physical address according to the hit page table entry, and then accessing the memory based on the physical address; or, (3) if the page table entry cached in the TLB does not hit, accessing the memory, querying the page table stored in the memory according to the VPN, converting the virtual address into a physical address according to the hit page table entry in the page table, and then accessing the memory based on the physical address.
[0039] The memory access instruction stream is used to indicate the sequential sequence of virtual addresses indicated by the memory access request of the memory access subject. The page table is used to indicate the set of mapping relationships between the VPN of the virtual address and the PPN (Physical Page Number) of the physical address. A page table entry cached in the TLB hits, that is, a page table entry cached in the TLB exists that corresponds to the VPN of the virtual address; a page table entry cached in the TLB misses, that is, a page table entry cached in the TLB does not exist that corresponds to the VPN of the virtual address. The principles of page table hits or misses are the same and will not be repeated here.
[0040] Due to the slow speed of accessing memory, in order to improve device performance, when a page table entry cached in the TLB misses and memory access is required, the prefetch device in the system can perform a prefetch operation based on a prefetch strategy to reduce the number of memory accesses. For example, the prefetch device predicts the next virtual address that may be accessed based on a preset prefetch strategy and caches the page table entry corresponding to the VPN of the next virtual address that may be accessed into the TLB. The prefetch strategy is used to indicate the method or algorithm used by the prefetch device to predict the next virtual address that may be accessed based on the memory access mode of the memory access subject.
[0041] The prefetch device is usually integrated into the MMU (Memory Management Unit) in the system for processing the above-mentioned memory access process, for example, it is integrated into the TLB of the MMU. In the related art, the prefetch strategy of the prefetch device usually adopts a single prefetch strategy, or selects from multiple prefetch strategies based on preset rules. Both of them have the technical problem of insufficient prefetch accuracy. Figure 1 and Figure 2 Explain this.
[0042] Figure 1 The present invention is a schematic diagram of the architecture of a prefetch device that integrates a prefetch function and adopts a single prefetch strategy.
[0043] like Figure 1 As described above, the TLB includes a level 1 TLB 110 and a level 2 TLB 120. The level 2 TLB 120 includes a page cache 121, a prefetch device 122, and a PTW 123 (page table walker).
[0044] When a program running in the system needs to access memory 130, the system can query the page table entries cached in the first-level TLB110 based on the VPN of the virtual address currently accessed by the program and when the page table entries cached in the first-level TLB110 are not hit, the system can query the page table entries cached in the second-level TLB120 in turn.
[0045] If the page table entry cached in the page cache 121 of the L2 TLB 120 also misses, it is necessary to access the memory 130 through the PTW 123 to query the page table in the memory 130. In this case, the prefetch device 122 can predict the VPN of the virtual address that the program may access next based on the preset single prefetch strategy and the VPN of the virtual address currently accessed by the program. Therefore, when accessing the memory 130 through the PTW 123 and querying the page table in the memory 130, the page table entry corresponding to the VPN of the virtual address currently accessed by the program and the page table entry corresponding to the VPN of the virtual address that the program may access next can be simultaneously queried, and the page table entry corresponding to the VPN of the virtual address currently accessed by the program and the page table entry corresponding to the VPN of the virtual address that the program may access next can be cached in the L1 TLB 110 or the L2 TLB 120. The single prefetch strategy preset in the prefetch device 122 is, for example, a next-line prefetch strategy, which may determine the page table entry of the memory unit next to the page table entry corresponding to the VPN of the virtual address currently accessed by the program as the page table entry corresponding to the VPN of the next virtual address that the program may access, and prefetch the page table entry based on this. A memory unit is the smallest storage unit of the memory 130, or the smallest unit for reading data from the memory 130.
[0046] However, when the program's memory access pattern changes, the prefetching accuracy of the prefetching device 122 using a single prefetching strategy may be insufficient, resulting in a decrease in the TLB hit rate. For example, the virtual address that the prefetching device 122 predicts the program's next possible access may be different from the virtual address that the program actually accesses.
[0047] Figure 2 This is a schematic diagram of the architecture of a prefetching device that integrates a prefetching function and selects from multiple prefetching strategies based on preset rules. Figure 2 As described above, the TLB includes a first-level TLB 210 and a second-level TLB 220 . The second-level TLB 220 includes a page cache 221 , a prefetch device 222 , and a PTW 223 .
[0048] When a program running in the system needs to access memory 230, the system can query the page table entries cached in the first-level TLB210 based on the VPN of the virtual address currently accessed by the program and when the page table entries cached in the first-level TLB210 are not hit, the page table entries cached in the second-level TLB220 can be queried in turn.
[0049] If a page table entry cached in the page cache 221 of the L2 TLB 220 also misses, it is necessary to access the memory 230 through the PTW 223 to query the page table in the memory 230. In this case, the prefetch device 222 can select one of its multiple prefetch strategies according to a preset rule, and predict the VPN of the next virtual address that the program may access based on the selected prefetch strategy and the VPN of the virtual address currently accessed by the program. This allows the PTW 223 to simultaneously query the page table entry corresponding to the VPN of the virtual address currently accessed by the program and the VPN of the next virtual address that the program may access when accessing the memory and querying the page table in the memory 230. The page table entry corresponding to the VPN of the virtual address currently accessed by the program and the VPN of the next virtual address that the program may access are then cached in the L1 TLB 210 or the L2 TLB 220. The preset rule may be, for example, a manually set rule, or priorities may be set for multiple prefetch strategies based on different memory access patterns.
[0050] However, Figure 2 The method shown in
[15] relies on the accuracy and comprehensiveness of preset rules. If a program's actual memory access pattern exhibits variations not defined by the preset rules, or if the program's actual memory access pattern is inconsistent with variations defined by the preset rules, the prefetching accuracy of prefetch device 222, selected from among multiple prefetching strategies based on the preset rules, may be insufficient, resulting in a reduced TLB hit rate. For example, the virtual address that prefetch device 222 predicts the program's next likely access may differ from the virtual address that the program actually accesses.
[0051] In view of this, the present application provides a virtual address prefetch device, which can perform prefetch operations based on N prefetch strategies, and can compare the prefetch results of the prefetch operations performed by the prefetch device based on the N prefetch strategies with the actual results, so that the prefetch device can adaptively adjust the N prefetch strategies, thereby improving the flexibility and reliability of the prefetch device.
[0052] Figure 3 This is a structural diagram of the virtual address prefetch device provided in an embodiment of the present application. The prefetch device provided in an embodiment of the present application can be integrated into the MMU or exist independently. This application does not impose any restrictions in this regard.
[0053] Optionally, when the prefetch device provided in the embodiment of the present application is integrated into the MMU, the present application does not impose any restrictions on the architecture of the MMU. For example, the MMU can adopt a two-level TLB architecture, or an architecture that supports Miss Queue, or an architecture that supports PMP (physical memory protection), or an architecture that supports PMA (physical memory attributes), etc. The present application does not impose any restrictions in this regard.
[0054] refer to Figure 3 The structural diagram of the virtual address prefetching device provided in the embodiment of the present application includes a cache module 310, a query module 320 and a decision module 330.
[0055] The cache module 310 is configured to cache prefetch virtual page numbers VPN in N prediction queues, where the prefetch VPNs in the N prediction queues correspond to virtual addresses of page table entries cached in the TLB module that are not hit in the memory access instruction stream.
[0056] Exemplarily, a prefetch VPN can be used, but is not limited to, to indicate the prefetch results of a prefetching device after executing a prefetch operation based on N prefetch strategies. The N prediction queues can be used, but are not limited to, to indicate a sequence of prefetch results of the N prefetch strategies, i.e., a sequence of prefetch VPNs for the N prefetch strategies. N is an integer greater than or equal to 2, such as 2, 3, 4, etc., and this application imposes no restrictions on this. The N prefetch strategies correspond one-to-one to the N prediction queues.
[0057] When a page table entry cached in the TLB module is queried based on the VPN of the virtual address in the memory access instruction stream, and a page table entry cached in the TLB module misses, the prefetch device performs a prefetch operation based on the prefetch policy, prefetching the VPN of the next virtual address that may be accessed. In other words, the virtual address of the page table entry cached in the TLB module that misses triggers the prefetch operation of the prefetch device, resulting in the acquisition of the prefetch VPN. Therefore, there is a one-to-one correspondence between the virtual address of the page table entry cached in the TLB module that misses and the prefetch VPN.
[0058] Taking into account that in actual application scenarios, the capacity of the cache module 320 may be limited, in order to ensure the timeliness of the pre-fetch results, the N prediction queues manage the pre-fetch VPNs based on the first-in-first-out principle, that is, when the number of pre-fetch VPNs in the N prediction queues reaches the upper limit of the N prediction queues, the pre-fetch VPNs that entered the N prediction queues first are cleared first.
[0059] In some embodiments, the N prediction queues include, for example, N FIFO (First-In-First-Out) queues, and the lengths of the N FIFO queues are equal. The upper limit of the number of pre-fetched VPNs in each FIFO queue can be adjusted according to actual application conditions. This application does not impose any restrictions in this regard.
[0060] The query module 320 is configured to query the prefetch VPNs in the N prediction queues according to the VPN of the next virtual address of the first virtual address in the memory access instruction stream, and obtain the query results of the N prediction queues, where the first virtual address is the virtual address of the page table entry cached in the TLB module that did not hit the memory access instruction stream.
[0061] Optionally, the next virtual address of the first virtual address in the memory access instruction stream can be used to indicate the next virtual address to be accessed by the memory access subject after accessing the first virtual address, that is, the virtual address that the memory access subject actually wants to access after accessing the first virtual address.
[0062] The query result can be used, but is not limited to, to indicate the accuracy of the prefetch result after executing a prefetch operation based on N prefetch strategies. As previously described, the next virtual address of the first virtual address in the memory access instruction stream can indicate the virtual address that the memory access subject actually wants to access after accessing the first virtual address, and the prefetch VPN can indicate the prefetch result after the prefetch device executes the prefetch operation based on N prefetch strategies. In view of this, the query result of querying the prefetch VPN based on the VPN of the next virtual address of the first virtual address in the memory access instruction stream can be used to indicate the accuracy of the prefetch result after executing the prefetch operation based on N prefetch strategies.
[0063] For example, the query results may include hits and misses. When querying prefetch VPNs in N prediction queues based on the VPN of the next virtual address of the first virtual address in the memory access instruction stream, if the prefetch VPN in a prediction queue among the N prediction queues hits, then it indicates that among the N prefetch strategies, the accuracy of the prefetch result after executing the prefetch operation based on the prefetch strategy corresponding to the hit prediction queue is higher. If the prefetch VPN in a prediction queue among the N prediction queues misses, then it indicates that among the N prefetch strategies, the accuracy of the prefetch result after executing the prefetch operation based on the prefetch strategy corresponding to the miss prediction queue is lower.
[0064] Among them, the method for determining whether N prediction queues hit includes, for example: when a certain prediction queue among the N prediction queues has a pre-fetch VPN corresponding to the VPN of the next virtual address of the first virtual address, the query result of the prediction queue is a hit; when a certain prediction queue among the N prediction queues does not have a pre-fetch VPN corresponding to the VPN of the next virtual address of the first virtual address, the query result of the prediction queue is a miss.
[0065] The decision module 330 is configured to update the trust of the N prefetch strategies in the decision module according to the query result; determine the prefetch VPN of the second virtual address according to the updated trust and the trust status of the first prefetch strategy, the first prefetch strategy is the prefetch strategy corresponding to the first virtual address in the N prefetch strategies, and the second virtual address is the virtual address of the next page table entry cached in the TLB module that misses the first virtual address in the memory access instruction stream, and the trust status of the N prefetch strategies indicates the reliability of the N prefetch strategies.
[0066] Exemplarily, the trustworthiness of the N prefetch strategies is positively correlated with the accuracy of the prefetch results corresponding to the N prefetch strategies. For example, when the accuracy of the prefetch results corresponding to a prefetch strategy among the N prefetch strategies is higher, the trustworthiness of the prefetch strategy is higher; and when the accuracy of the prefetch results corresponding to a prefetch strategy among the N prefetch strategies is lower, the trustworthiness of the prefetch strategy is lower.
[0067] The method for selecting N prefetch strategies can refer to the following standards, for example: determine the prefetch strategy based on the memory access pattern that may appear in the system. In some embodiments, the N prefetch strategies include but are not limited to Markov prefetch strategy, ASP (Adaptive Stride Prefetcher) prefetch strategy; Delta-Correlated Lookup prefetch strategy. Among them, the Markov prefetch strategy is applicable to memory access patterns with temporal locality and sequential access, such as memory access patterns in scenarios such as loop structures, array traversal, and matrix operations. The ASP prefetch strategy is applicable to access patterns with fixed step sizes and clear rules; the Delta-Correlated Lookup prefetch strategy is applicable to data with spatial locality, and can be learned by tracking the offsets of adjacent addresses.
[0068] As described above, the query result can be used to indicate the accuracy of the prefetch result after the prefetch operation is performed based on N prefetch strategies, and the trust of the N prefetch strategies is positively correlated with the accuracy of the prefetch results corresponding to the N prefetch strategies. In view of this, when the query result includes hits and misses, the decision module 330 is configured to update the trust of the N prefetch strategies in the decision module 330 according to the query result, for example: when the query results of the N prediction queues are different, the trust of the prefetch strategy corresponding to the prediction queue with a hit query result in the N prediction queues is increased; and the trust of the prefetch strategy corresponding to the prediction queue with a miss query result in the N prediction queues is reduced.
[0069] In some embodiments, the confidence levels of the N prefetch strategies are indicated by the values of N counters corresponding to the N prefetch strategies, wherein the N counters are, for example, saturation counters, so that the prefetch device can balance the accuracy of the prefetch strategies with the resource overhead of the system.
[0070] The following will take N=3, the number of counters is 3, the counters are saturated counters with a value range of [0,7], and the initial values of the three saturated counters are all 3 as an example to further explain the process of the decision module 330 updating the trust of N prefetch strategies in the decision module 330 according to the query results.
[0071] When N=3, the N prefetch strategies include, for example, prefetch strategy A, prefetch strategy B, and prefetch strategy C. The N prediction queues include, for example, a first prediction queue, a second prediction queue, and a third prediction queue, and the three different prefetch strategies correspond one-to-one to the three prediction queues. The confidence levels of prefetch strategy A, prefetch strategy B, and prefetch strategy C are recorded by the first saturation counter, the second saturation counter, and the third saturation counter, respectively.
[0072] The first prefetch VPN obtained by the prefetch device after performing the prefetch operation based on prefetch strategy A enters the first prediction queue, the second prefetch VPN obtained by the prefetch device after performing the prefetch operation based on prefetch strategy B enters the second prediction queue, and the third prefetch VPN obtained by the prefetch device after performing the prefetch operation based on prefetch strategy C enters the third prediction queue.
[0073] After querying the first prediction queue, the second prediction queue and the third prediction queue respectively according to the next virtual address of the first virtual address in the memory access instruction stream, the query results of the three prediction queues are different, including: case (1), the first prediction queue hits, the second prediction queue hits, and the third prediction queue misses; case (2) the first prediction queue hits, the second prediction queue misses, and the third prediction queue hits; case (3) the first prediction queue misses, the second prediction queue hits, and the third prediction queue hits; case (4) the first prediction queue hits, the second prediction queue misses, and the third prediction queue misses; case (5) the first prediction queue misses, the second prediction queue hits, and the third prediction queue misses; case (6) the first prediction queue misses, the second prediction queue misses, and the third prediction queue hits, a total of six cases.
[0074] Among the above six cases, for case (1), the trust of prefetch policy A corresponding to the first prediction queue and prefetch policy B corresponding to the second prediction queue is increased, and the trust of prefetch policy C corresponding to the third prediction queue is reduced. The values of the three saturation counters are divided into 4, 4, and 2. For case (2), the trust of prefetch policy A corresponding to the first prediction queue and prefetch policy C corresponding to the third prediction queue is increased, and the trust of prefetch policy B corresponding to the second prediction queue is reduced. The values of the three saturation counters are divided into 4, 2, and 4. For case (3), the trust of prefetch policy C corresponding to the third prediction queue and prefetch policy B corresponding to the second prediction queue is increased, and the trust of prefetch policy A corresponding to the first prediction queue is reduced. The values of the three saturation counters are divided into 2, 4, and 4. For case (4), the trust of prefetch policy C corresponding to the third prediction queue and prefetch policy B corresponding to the second prediction queue is reduced, and the trust of prefetch policy A corresponding to the first prediction queue is increased. The values of the three saturation counters are divided into 4, 2, and 2. For situation (5), the trust levels of prefetch strategy C corresponding to the third prediction queue and prefetch strategy A corresponding to the first prediction queue are lowered, and the trust level of prefetch strategy B corresponding to the second prediction queue is increased. The values of the three saturation counters are divided into 2, 4, and 2. For situation (6), the trust levels of prefetch strategy A corresponding to the first prediction queue and prefetch strategy B corresponding to the second prediction queue are lowered, and the trust level of prefetch strategy B corresponding to the second prediction queue is increased. The values of the three saturation counters are divided into 2, 2, and 4.
[0075] Through the above method, the embodiment of the present application can timely update the trust of N prefetch strategies according to the query results of N prediction queues, and then perform prefetch operations based on the updated trust of the N prefetch strategies, so that the method provided by the embodiment of the present application has higher flexibility and can be adaptively adjusted according to actual conditions, such as switching the prefetch strategy so that the prefetch device performs the prefetch operation according to the switched prefetch strategy.
[0076] Considering that in actual application scenarios, the memory access patterns of programs running in the system may change sporadically, the trustworthiness of the N prefetch strategies updated based on the query results of the N prediction queues is also sporadic. In view of this, the method provided in the embodiment of the present application can also examine the reliability of the N prefetch strategies and then determine whether it is necessary to switch the prefetch strategy to avoid the unexpected switching of the prefetch strategy in the prefetch device when the memory access pattern changes sporadically.
[0077] For example, N prefetch strategies include a second prefetch strategy corresponding to the second virtual address. When the decision module 330 determines the prefetch VPN of the second virtual address based on the updated trust level and the trust status of the first prefetch strategy, it is configured to: determine the second prefetch strategy based on the updated trust level and the trust status of the first prefetch strategy; determine the prefetch VPN of the second virtual address based on the VPN of the second virtual address and the second prefetch strategy.
[0078] The trust states of the N prefetch strategies are used to indicate the reliability of the N prefetch strategies. For example, the trust states of the N prefetch strategies include a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state. When the first prefetch strategy is in the first trust state, if the updated trust fluctuates, for example, the trust of the first prefetch strategy is not the highest among the updated N prefetch strategies, then the fluctuation in the updated trust may be caused by occasional changes in the memory access pattern. In this case, the prefetch strategy can be switched based on the updated trust and the first prefetch strategy can be continued to be trusted, thereby avoiding performance degradation caused by unexpected prefetch strategy switching operations in the prefetch device. When the first prefetch strategy is in the second trust state, if the updated trust fluctuates, for example, the trust of the first prefetch strategy is not the highest among the updated N prefetch strategies, then the fluctuation in the updated trust may be caused by changes in the memory access pattern. In this case, the prefetch strategy can be switched based on the updated trust and the prefetch strategy with the highest trust among the updated trust can be determined as the currently trusted prefetch strategy.
[0079] In some embodiments, the prefetch operation performed by the prefetch device includes multiple times, and the method for determining the trust status of N prefetch strategies includes: determining the number of times the N prefetch strategies are trusted continuously in multiple prefetch operations. For example, when the prefetch operation performed by the prefetch device includes multiple times, if the number of times the first prefetch strategy is trusted continuously is greater than or equal to the number threshold, the trust status of the first prefetch strategy is determined to be the first trust state, otherwise, the trust state of the first prefetch strategy is determined to be the second trust state. Among them, the first prefetch strategy is trusted to indicate that the first prefetch strategy is adopted in the prefetch operation, and the first prefetch strategy is continuously trusted to indicate that the first prefetch strategy is continuously adopted in multiple prefetch operations. The first prefetch strategy can be any one of the N prefetch strategies. The value of the number threshold can be adjusted according to the actual application situation, and the present application does not impose any restrictions in this regard.
[0080] The following will take the case where the first virtual address misses the page table entry cached in the TLB module and the prefetching strategy currently adopted by the prefetching device is the first prefetching strategy corresponding to the first virtual address as an example to illustrate the scenario of whether the prefetching device switches the prefetching strategy.
[0081] When the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; when the decision module 330 determines the second prefetch strategy based on the updated trust level and the trust state of the first prefetch strategy, it is configured as follows: if the trust state of the first prefetch strategy is the first trust state, and the first trust level of the first prefetch strategy is the highest among the updated N prefetch strategies, the first prefetch strategy is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the first trust state.
[0082] In the above method, when the trust state of the first prefetch strategy is the first trust state, it means that in multiple prefetch operations except the currently executed prefetch operation (hereinafter referred to as the previous prefetch operation), the first prefetch strategy is continuously trusted, and the reliability of the first prefetch strategy is relatively high. At this time, if the first trust degree of the first prefetch strategy in the updated trust degree is also the highest, the prefetch strategy can be switched without switching, and the trust state of the first prefetch strategy can be maintained.
[0083] When the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; when the decision module 330 determines the second prefetch strategy based on the updated trust level and the trust state of the first prefetch strategy, it is configured as follows: if the trust state of the first prefetch strategy is the first trust state, and the first trust level of the first prefetch strategy is not the highest among the updated N prefetch strategies, the first prefetch strategy is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the second trust state.
[0084] In the above method, when the trust state of the first prefetch strategy is the first trust state, it means that in the previous prefetch operation, the first prefetch strategy has been continuously trusted and the reliability of the first prefetch strategy is relatively high. At this time, if the first trust degree of the first prefetch strategy in the updated trust degree is not the highest, the fluctuation of the updated trust degree is affected by the occasional change of the memory access pattern. The first prefetch strategy can continue to be trusted and the prefetch strategy will not be switched, but the trust state of the first prefetch strategy will be adjusted to the second trust state.
[0085] In the case where the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; when the decision module 330 determines the second prefetch strategy based on the updated trust level and the trust state of the first prefetch strategy, it is configured as follows: if the trust state of the first prefetch strategy is the second trust state, and the first trust level of the first prefetch strategy is not the highest among the updated N prefetch strategies, the prefetch strategy corresponding to the highest trust level among the multiple trust levels among the N prefetch strategies is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the second trust state.
[0086] In the above method, when the trust state of the first prefetch strategy is the second trust state, it means that in the previous prefetch operation, the first prefetch strategy was not continuously trusted, and the reliability of the first prefetch strategy is low. At this time, if the first trust of the first prefetch strategy in the updated trust is not the highest, the fluctuation of the updated trust may be caused by the change of the memory access pattern. The prefetch strategy can be switched, and since the second prefetch strategy after switching is not continuously trusted, the trust state of the second prefetch strategy can be adjusted to the second trust state.
[0087] When the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; when the decision module 330 determines the second prefetch strategy based on the updated trust level and the trust state of the first prefetch strategy, it is configured as follows: if the trust state of the first prefetch strategy is the second trust state, and the first trust level of the first prefetch strategy is the highest among the updated N prefetch strategies, the first prefetch strategy is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the first trust state.
[0088] In the above method, when the trust state of the first prefetch strategy is the second trust state, it means that in the previous prefetch operation, the first prefetch strategy has not been continuously trusted, and the reliability of the first prefetch strategy is low. At this time, if the first trust degree of the first prefetch strategy is the highest in the updated trust degree, it means that the updated trust degree has not fluctuated, and the prefetch strategy does not need to be switched. Since the prefetch strategy is continuously trusted, the trust state of the second prefetch strategy can be adjusted to the first trust state.
[0089] When the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state, the decision module is configured to determine the second prefetch strategy based on the updated trust and the trust state of the first prefetch strategy: if the trust state of the first prefetch strategy is the second trust state, and the trust levels of the updated N prefetch strategies are the same, determine the N prefetch strategies as the second prefetch strategies.
[0090] In the above method, when the trust status of the first prefetch strategy is the second trust status, it means that in the previous prefetch operation, the first prefetch strategy has not been continuously trusted, and the reliability of the first prefetch strategy is low. If the trust levels of the N updated prefetch strategies are the same, at this time, if the prefetch strategy is switched, the switched prefetch strategy is also in the second trust state. In other words, at this time, the trust levels and trust status of the N prefetch strategies are the same, and it is impossible to select a trusted prefetch strategy based on the trust levels and trust status of the N prefetch strategies. The prefetch operation can be performed based on the N prefetch strategies.
[0091] During the switching process of the above-mentioned prefetch strategies, the first prefetch strategy is the prefetch strategy corresponding to the first virtual address among the N prefetch strategies, and the correspondence between the first prefetch strategy and the first virtual address is used to indicate the prefetch strategy adopted by the prefetch device when performing the prefetch operation when the first virtual address does not hit the page table entry cached in the TLB module. In different application scenarios, the first prefetch strategy corresponding to the first virtual address can be any one of the N prefetch strategies, and the correspondence between the second virtual address and the second prefetch strategy is the same as the correspondence between the first virtual address and the first prefetch strategy, which will not be repeated. For example, when the prefetch device does not switch the prefetch strategy, the first prefetch strategy corresponding to the first virtual address and the second prefetch strategy corresponding to the second virtual address are the same; when the prefetch device switches the prefetch strategy, the first prefetch strategy corresponding to the first virtual address and the second prefetch strategy corresponding to the second virtual address are different.
[0092] Figure 4 This is a schematic diagram of the architecture of the pre-fetching device provided in an embodiment of the present application.
[0093] The following will be combined Figure 4 The prefetching process of the prefetching device provided in the embodiment of the present application is further explained.
[0094] like Figure 4 The TLB module with integrated prefetch device provided in the embodiment of the present application includes a first-level TLB 410 and a second-level TLB 420. The second-level TLB 420 includes a page cache 421, a prefetch device 422 and a PTW 423. The prefetch device 422 includes a query module 4221, a cache module 4222 and a decision module 4223. It should be noted that the prefetch device 422 and the query module 4221, cache module 4222 and decision module 4223 included therein are the same as those in the first and second levels. Figure 3 The principles of the pre-fetch device, cache module 310, query module 320 and decision module 330 shown in FIG are the same and will not be repeated here.
[0095] When a program running in the system needs to access memory 430, the system can query the page table entries cached in the first-level TLB410 based on the VPN of the virtual address currently accessed by the program and when the page table entries cached in the first-level TLB410 are not hit, the page table entries cached in the second-level TLB420 can be queried in turn.
[0096] If the page table entry cached in the page cache 421 of the L2 TLB 420 also misses, it is necessary to access the memory 430 through the PTW 423 to query the page table in the memory 430. In this case, the prefetch device 422 can predict the VPN of the virtual address that the program may next access based on the trust status of the currently executed prefetch strategy (one of the N prefetch strategies), the updated trust level of the N prefetch strategies, and the VPN of the virtual address. When accessing the memory through the PTW 423 and querying the page table in the memory 430, the page table entry corresponding to the VPN of the virtual address currently accessed by the program and the page table entry corresponding to the VPN of the virtual address that the program may next access can be queried simultaneously. The prefetch strategy that matches the current memory access pattern is adaptively selected. After the page table entry corresponding to the VPN of the virtual address currently accessed by the program and the prefetched page table entry corresponding to the VPN of the virtual address that the program may next access are cached in the L1 TLB 410 or L2 TLB 420, the hit rate and usage rate of the L1 TLB 410 or L2 TLB 420 can be improved.
[0097] The technical solution provided by the present application can save all the prefetch VPNs corresponding to the memory access instructions that do not hit the page table entries cached in the TLB module in the memory access instruction stream into the cache module, so that the accuracy of the prefetch strategy corresponding to the first memory access instruction can be verified based on the VPN carried by the next memory access instruction of the first memory access instruction that indicates the VPN that the program actually wants to access next, and the prefetch VPN predicted by the prefetch device, and the trust of the N prefetch strategies can be updated, so that when determining the prefetch VPN corresponding to the second memory access instruction, adaptive adjustments can be made. In addition, in order to avoid the fluctuation of the trust of the N prefetch strategies when the memory access mode of the program changes occasionally, which may lead to unexpected adjustments in the prefetch device, after the trust of the N prefetch strategies is updated, the prefetch device will further consider the reliability of the prefetch strategy, which is conducive to improving the flexibility and reliability of the prefetch device.
[0098] In another possible implementation, the present application provides a virtual address prefetching method. Figure 5 This is a flowchart of a virtual address prefetching method provided by an embodiment of the present application. Figure 5 The virtual address prefetching method provided in the embodiment of the present application includes the following steps.
[0099] Step S510 , querying the prefetch VPNs in N prediction queues respectively according to the VPN of the next virtual address of the first virtual address in the memory access instruction stream, and obtaining query results of the N prediction queues.
[0100] Step S520: updating the confidence levels of the N prefetching strategies in the decision module of the prefetching device according to the query result.
[0101] Step S530: Determine a prefetch VPN for the second virtual address according to the updated trust level and the trust state of the first prefetch strategy.
[0102] Among them, the first virtual address is the virtual address of the page table entry cached in the TLB module that is not hit in the memory access instruction stream, the prefetch VPN corresponds to the virtual address of the page table entry cached in the TLB module that is not hit in the memory access instruction stream, the first prefetch strategy is the prefetch strategy corresponding to the first virtual address among the N prefetch strategies, the second virtual address is the virtual address of the next page table entry cached in the TLB module that is not hit by the first virtual address in the memory access instruction stream, the trust status indicates the reliability of the N prefetch strategies, N is an integer greater than or equal to 2, and the N prefetch strategies and N prediction queues correspond one to one.
[0103] In some embodiments, the query result includes a hit or a miss, and updating the trust of the N prefetch strategies in the decision module based on the query result includes: when the query results of the N prediction queues are different, increasing the trust of the prefetch strategy corresponding to the prediction queue whose query result is a hit among the N prediction queues; reducing the trust of the prefetch strategy corresponding to the prediction queue whose query result is a miss among the N prediction queues.
[0104] In some embodiments, the N prefetch strategies include a second prefetch strategy corresponding to the second virtual address, and the prefetch VPN of the second virtual address is determined based on the updated trust level and the trust status of the first prefetch strategy, including: determining the second prefetch strategy based on the updated trust level and the trust status of the first prefetch strategy; determining the prefetch VPN of the second virtual address based on the VPN of the second virtual address and the second prefetch strategy.
[0105] In some embodiments, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; determining the second prefetch strategy based on the updated trust and the trust state of the first prefetch strategy includes: if the trust state of the first prefetch strategy is the first trust state, and the first trust of the updated first prefetch strategy is the highest among the trusts of the N updated prefetch strategies, determining the first prefetch strategy as the second prefetch strategy, and determining the trust state of the second prefetch strategy as the first trust state.
[0106] In some embodiments, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; determining the second prefetch strategy based on the updated trust and the trust state of the first prefetch strategy includes: if the trust state of the first prefetch strategy is the first trust state, and the first trust of the first prefetch strategy is not the highest among the trusts of the N updated prefetch strategies, determining the first prefetch strategy as the second prefetch strategy, and determining the trust state of the second prefetch strategy as the second trust state.
[0107] In some embodiments, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; determining the second prefetch strategy based on the updated trust level and the trust state of the first prefetch strategy includes: if the trust state of the first prefetch strategy is the second trust state, and the first trust level of the first prefetch strategy is not the highest among the updated N prefetch strategies, determining the prefetch strategy corresponding to the highest trust level among the multiple trust levels among the N prefetch strategies as the second prefetch strategy, and determining the trust state of the second prefetch strategy as the second trust state.
[0108] In some embodiments, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; determining the second prefetch strategy based on the updated trust and the trust state of the first prefetch strategy includes: if the trust state of the first prefetch strategy is the second trust state, and the first trust of the first prefetch strategy is the highest among the updated N prefetch strategies, determining the first prefetch strategy as the second prefetch strategy, and determining the trust state of the second prefetch strategy as the first trust state.
[0109] In some embodiments, the trust state includes a first trust state and a second trust state, and the reliability indicated by the first trust state is higher than the reliability indicated by the second trust state; determining the second prefetch strategy based on the updated trust and the trust state of the first prefetch strategy includes: if the trust state of the first prefetch strategy is the second trust state, and the trust levels of the updated N prefetch strategies are the same, determining the N prefetch strategies as the second prefetch strategies.
[0110] In some embodiments, the N prediction queues manage pre-fetch VPNs based on a first-in-first-out principle.
[0111] above Figure 5 The principle of the virtual address prefetching method shown above can be referred to. Figure 3The virtual address prefetching method embodiment and the virtual address prefetching device embodiment provided in the above embodiment belong to the same concept, and their specific implementation process can be found in the virtual address prefetching device embodiment.
[0112] In some other possible implementations, the present application also provides a processor. Figure 6 Schematic diagram of the structure of the processor provided in the embodiment of the present application. Figure 6 The processor provided in the embodiment of the present application includes a prefetch device 610 and an execution unit 620. The execution unit 620 is used to receive the prefetch VPN of the prefetch device 610 and perform a prefetch operation according to the prefetch VPN. The prefetch device 610 can be the above-mentioned Figure 3 Of course, the processor may also have components such as a wired or wireless network interface, a keyboard, and an input / output interface for input and output, and the processor may also include other components for implementing device functions, which will not be described in detail here.
[0113] In some other possible implementations, the present application further provides a computer-readable storage medium having stored thereon program instructions for prefetching virtual addresses, which, when executed by one or more processors, enable the processors to implement the above combination. Figure 5 The described method and steps of multiple embodiments thereof. The computer-readable storage medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0114] The present application also provides a computer program product comprising a computer program, which is executed by a processor to enable the computer to combine Figure 5 The method and steps of various embodiments thereof are described.
[0115] It should also be noted that the terms "first," "second," etc. (if any) in the specification and claims of the present application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the numbers used in this way are interchangeable where appropriate so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0116] The term "and / or" in the embodiments of the present application is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent three situations: A exists alone, A and B currently exist, and B exists alone.
[0117] The above description is only for the purpose of facilitating the understanding of the technical solution of this application by those skilled in the art and is not intended to limit this application. Any modification, equivalent replacement, improvement, etc. made within the principles of this application shall be included in the scope of protection of this application.
Claims
1. A virtual address prefetching device, characterized in that: The pre-fetching device comprises: a cache module configured to cache prefetch virtual page numbers VPN in N prediction queues, wherein the prefetch VPNs in the N prediction queues correspond to virtual addresses of page table entries cached in a translation lookaside buffer (TLB) module that misses in a memory access instruction stream; a query module configured to query the prefetch VPNs in the N prediction queues respectively according to the VPN of the next virtual address of the first virtual address in the memory access instruction stream, to obtain query results of the N prediction queues, wherein the first virtual address is a virtual address of a page table entry in the memory access instruction stream that does not hit the cache in the TLB module; A decision module is configured to update the trust levels of the N prefetch strategies in the decision module according to the query result; determine a prefetch VPN for a second virtual address according to the updated trust levels and a trust state of a first prefetch strategy, wherein the first prefetch strategy is a prefetch strategy corresponding to the first virtual address in the N prefetch strategies, and the second virtual address is a virtual address of a page table entry cached in the TLB module that misses the next hit of the first virtual address in the memory access instruction stream, and the trust states of the N prefetch strategies indicate the reliability of the N prefetch strategies; Wherein, N is an integer greater than or equal to 2, and the N prefetch strategies correspond one-to-one to the N prediction queues.
2. The prefetch device according to claim 1, wherein: The query result includes a hit or a miss, and when the decision module updates the confidence levels of the N prefetch strategies in the decision module according to the query result, the decision module is configured to: When the query results of the N prediction queues are different, the trust of the prefetch strategy corresponding to the prediction queue with a hit query result among the N prediction queues is increased; The trust level of the prefetch strategy corresponding to the prediction queue whose query result is miss among the N prediction queues is reduced.
3. The prefetch device according to claim 1, wherein: The N prefetch strategies include a second prefetch strategy corresponding to the second virtual address, and the decision module is configured to: determining the second prefetching strategy according to the updated trust degree and the trust state of the first prefetching strategy; A prefetch VPN for the second virtual address is determined according to the VPN for the second virtual address and the second prefetch policy.
4. The prefetch device according to claim 3, wherein: The trust status includes a first trust status and a second trust status, wherein the reliability level indicated by the first trust status is higher than the reliability level indicated by the second trust status; When determining the second prefetching strategy according to the updated trust level and the trust status of the first prefetching strategy, the decision module is configured to: If the trust state of the first prefetch strategy is the first trust state, and the first trust degree of the updated first prefetch strategy is the highest among the trust degrees of the N updated prefetch strategies, the first prefetch strategy is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the first trust state.
5. The prefetch device according to claim 3, wherein: The trust status includes a first trust status and a second trust status, wherein the first trust status indicates a higher reliability than the second trust status indicates; When determining the second prefetching strategy according to the updated trust level and the trust status of the first prefetching strategy, the decision module is configured to: If the trust state of the first prefetch strategy is the first trust state, and the first trust degree of the first prefetch strategy is not the highest among the trust degrees of the N prefetch strategies after update, the first prefetch strategy is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the second trust state.
6. The prefetch device according to claim 3, wherein: The trust status includes a first trust status and a second trust status, wherein the reliability level indicated by the first trust status is higher than the reliability level indicated by the second trust status; When determining the second prefetching strategy according to the updated trust level and the trust status of the first prefetching strategy, the decision module is configured to: If the trust state of the first prefetch strategy is the second trust state, and the first trust degree of the first prefetch strategy is not the highest among the updated trust degrees of the N prefetch strategies, the prefetch strategy among the N prefetch strategies corresponding to the highest trust degree among the multiple trust degrees is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the second trust state.
7. The prefetch device according to claim 3, wherein: The trust status includes a first trust status and a second trust status, wherein the reliability level indicated by the first trust status is higher than the reliability level indicated by the second trust status; When determining the second prefetching strategy according to the updated trust level and the trust status of the first prefetching strategy, the decision module is configured to: If the trust state of the first prefetch strategy is the second trust state, and the first trust degree of the first prefetch strategy is the highest among the updated trust degrees of the N prefetch strategies, the first prefetch strategy is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the first trust state.
8. The prefetch device according to claim 3, characterized in that The trust status includes a first trust status and a second trust status, wherein the reliability level indicated by the first trust status is higher than the reliability level indicated by the second trust status; When determining the second prefetching strategy according to the updated trust level and the trust status of the first prefetching strategy, the decision module is configured to: If the trust state of the first prefetch strategy is the second trust state, and the updated trust levels of the N prefetch strategies are all the same, the N prefetch strategies are determined to be the second prefetch strategies.
9. The prefetch device according to any one of claims 1 to 8, characterized in that: The N prediction queues manage the pre-fetch VPNs based on a first-in-first-out principle.
10. A processor, characterized in that: The processor includes a prefetch device and an execution unit, wherein the execution unit is configured to receive a prefetch VPN from the prefetch device and perform a prefetch operation according to the prefetch VPN. The prefetch device is the prefetch device according to any one of claims 1 to 9.
11. A virtual address prefetching method, characterized in that: The method comprises: querying prefetch VPNs in the N prediction queues according to VPNs of a next virtual address of a first virtual address in a memory access instruction stream, respectively, to obtain query results of the N prediction queues, wherein the first virtual address is a virtual address of a page table entry in the memory access instruction stream that does not hit the cache of the TLB module, and the prefetch VPNs correspond to virtual addresses of page table entries in the memory access instruction stream that do not hit the cache of the TLB module; Updating the confidence levels of N prefetching strategies in the decision module of the prefetching device according to the query result; Determining a prefetch VPN for a second virtual address based on the updated trust level and a trust state of a first prefetch strategy, where the first prefetch strategy is a prefetch strategy corresponding to the first virtual address among the N prefetch strategies, the second virtual address is a virtual address of a next page table entry cached in the TLB module that misses the first virtual address in the memory access instruction stream, and the trust states of the N prefetch strategies indicate reliability of the N prefetch strategies; Wherein, N is an integer greater than or equal to 2, and the N prefetch strategies correspond one-to-one to the N prediction queues.
12. The method according to claim 11, characterized in that The query result includes a hit or a miss, and updating the trust levels of the N prefetch strategies in the decision module according to the query result includes: When the query results of the N prediction queues are different, the trust of the prefetch strategy corresponding to the prediction queue with a hit query result among the N prediction queues is increased; The trust level of the prefetch strategy corresponding to the prediction queue whose query result is miss among the N prediction queues is reduced.
13. The method according to claim 11, characterized in that The N prefetch strategies include a second prefetch strategy corresponding to the second virtual address, and determining the prefetch VPN for the second virtual address according to the updated trust level and the trust state of the first prefetch strategy includes: determining the second prefetching strategy according to the updated trust degree and the trust state of the first prefetching strategy; A prefetch VPN for the second virtual address is determined according to the VPN for the second virtual address and the second prefetch policy.
14. The method according to claim 13, characterized in that The trust status includes a first trust status and a second trust status, wherein the reliability level indicated by the first trust status is higher than the reliability level indicated by the second trust status; The determining the second prefetching strategy according to the updated trust level and the trust status of the first prefetching strategy includes: If the trust state of the first prefetch strategy is the first trust state, and the first trust degree of the updated first prefetch strategy is the highest among the trust degrees of the N updated prefetch strategies, the first prefetch strategy is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the first trust state.
15. The method according to claim 13, characterized in that The trust status includes a first trust status and a second trust status, wherein the first trust status indicates a higher reliability than the second trust status indicates; The determining the second prefetching strategy according to the updated trust level and the trust status of the first prefetching strategy includes: If the trust state of the first prefetch strategy is the first trust state, and the first trust degree of the first prefetch strategy is not the highest among the trust degrees of the N prefetch strategies after update, the first prefetch strategy is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the second trust state.
16. The method according to claim 13, characterized in that The trust status includes a first trust status and a second trust status, wherein the reliability level indicated by the first trust status is higher than the reliability level indicated by the second trust status; The determining the second prefetching strategy according to the updated trust level and the trust status of the first prefetching strategy includes: If the trust state of the first prefetch strategy is the second trust state, and the first trust degree of the first prefetch strategy is not the highest among the updated trust degrees of the N prefetch strategies, the prefetch strategy among the N prefetch strategies corresponding to the highest trust degree among the multiple trust degrees is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the second trust state.
17. The method according to claim 13, characterized in that The trust status includes a first trust status and a second trust status, wherein the reliability level indicated by the first trust status is higher than the reliability level indicated by the second trust status; The determining the second prefetching strategy according to the updated trust level and the trust status of the first prefetching strategy includes: If the trust state of the first prefetch strategy is the second trust state, and the first trust degree of the first prefetch strategy is the highest among the updated trust degrees of the N prefetch strategies, the first prefetch strategy is determined as the second prefetch strategy, and the trust state of the second prefetch strategy is determined as the first trust state.
18. The method according to claim 13, characterized in that The trust status includes a first trust status and a second trust status, wherein the reliability level indicated by the first trust status is higher than the reliability level indicated by the second trust status; The determining the second prefetching strategy according to the updated trust level and the trust status of the first prefetching strategy includes: If the trust state of the first prefetch strategy is the second trust state, and the updated trust levels of the N prefetch strategies are all the same, the N prefetch strategies are determined to be the second prefetch strategies.
19. The method according to any one of claims 11 to 18, wherein: The N prediction queues manage the pre-fetch VPNs based on a first-in-first-out principle.