A pre-fetching method, device, electronic device and readable storage medium

By using the global history register and throttling control mode in the prefetcher, the problem of excessive prefetching damaging cache performance is solved, precise control of prefetching requests is achieved, and the performance of the processor system is improved.

CN118409981BActive Publication Date: 2024-09-13BEIJING INSTITUTE OF OPEN SOURCE CHIP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410867267.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2024-09-13
Estimated Expiration
2044-06-28

AI Technical Summary

Technical Problem

Excessive prefetching in the prior art may damage cache performance, lead to a decrease in processor execution efficiency, and make it difficult to effectively control the number of prefetch requests.

Method used

By setting the global history register in the prefetcher, obtain the position vector of the target physical page, activate the target prefetch algorithm, determine the performance evaluation index based on the current cache environment information and historical prefetch information, select the appropriate throttling control mode, and update Prefetch queue to control the number of prefetch requests.

Benefits of technology

It effectively avoids the damage to the cache system caused by excessive prefetching, improves the overall performance of the processor system, and ensures that the number of prefetch requests matches the cache system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118409981B
    Figure CN118409981B
Patent Text Reader

Abstract

The embodiment of the present invention provides a prefetch method, device, electronic device and readable storage medium, the method comprising: obtaining the position vector of the target physical page; activating the target prefetch algorithm in the prefetcher according to the position vector; determining the performance evaluation index of the target prefetch algorithm based on the current cache environment information recorded in the global history register and the historical prefetch information corresponding to the target prefetch algorithm; determining the target throttling control mode according to the performance evaluation index; updating the prefetch requests to be sent in the prefetch queue according to the target throttling control mode, and prefetching based on the updated prefetch queue. The embodiment of the present invention can timely control the number of prefetch requests sent by the prefetcher to the outside, avoid excessive prefetching to damage the cache system performance, and is conducive to improving the overall performance of the processor system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a pre-fetching method, device, electronic device and readable storage medium. Background Art

[0002] The memory wall problem of modern on-chip hierarchical storage structures will make it difficult to achieve breakthroughs in physical devices for a long time in the future, and it is difficult to make breakthroughs in hierarchical storage structures. When the processor needs to obtain data from the memory, it needs to wait for the memory access delay, which will cause the execution efficiency of the processor to decrease.

[0003] Data prefetching loads data into cache or registers before it is processed, thereby reducing access latency (hiding access latency), increasing cache hit rate, and optimizing instruction execution speed to improve system performance. In the best case, memory access does not incur any additional overhead, and the performance of memory is close to that of processor registers. In the worst case, excessive prefetching may damage cache performance, pollute cache, and increase power consumption. Summary of the invention

[0004] The embodiments of the present invention provide a pre-fetching method, device, electronic device and readable storage medium, which can solve the problem in the related art that excessive pre-fetching may damage cache performance.

[0005] In order to solve the above problem, an embodiment of the present invention discloses a prefetching method, which is applied to a prefetcher, wherein a global history register is provided in the prefetcher; the method comprises:

[0006] Acquire a position vector of a target physical page; the position vector is used to reflect historical prefetch information of each prefetch algorithm in the prefetcher for each data block in the target physical page;

[0007] activating a target prefetch algorithm in the prefetcher according to the position vector;

[0008] Determine a performance evaluation index of the target prefetch algorithm based on the current cache environment information recorded in the global history register and the historical prefetch information corresponding to the target prefetch algorithm; the performance evaluation index is used to indicate the prefetch performance of the target prefetch algorithm;

[0009] Determining a target throttling control mode according to the performance evaluation index;

[0010] The prefetch requests to be sent in the prefetch queue are updated according to the target throttling control mode, and prefetching is performed based on the updated prefetch queue.

[0011] Optionally, activating a target prefetch algorithm in the prefetcher according to the position vector comprises:

[0012] The position vectors are bit-wise merged according to a preset aggregation granularity to obtain at least two first vectors; one bit of the position vector corresponds to a pre-fetch algorithm, and each first vector corresponds to the same bit of the position vector;

[0013] A target prefetch algorithm in the prefetcher is activated according to the value of the first vector; the value of the first vector corresponding to the target prefetch algorithm is not zero.

[0014] Optionally, the global history register includes a prefetch request counter, a prefetch access hit counter and a prefetch backfill counter corresponding to each prefetch algorithm; the prefetch request counter is used to record the number of prefetch requests triggered by the prefetch algorithm; the prefetch access hit counter is used to record the number of times the cache block prefetched by the prefetch algorithm is hit; the prefetch backfill counter is used to record the number of backfills corresponding to the prefetch algorithm;

[0015] The determining of the performance evaluation index of the target prefetch algorithm based on the current cache environment information recorded in the global history register and the historical prefetch information corresponding to the target prefetch algorithm includes:

[0016] Obtaining a first count value of a prefetch request counter, a second count value of a prefetch access hit counter, and a third count value of a prefetch backfill counter corresponding to the target prefetch algorithm;

[0017] Determining a prefetch accuracy quantization value of the target prefetch algorithm according to the first count value and the second count value;

[0018] Determine a prefetch coverage quantization value of the target prefetch algorithm according to the first count value and the third count value;

[0019] A cache congestion quantization value is determined according to first count values ​​corresponding to each prefetch algorithm in the prefetcher.

[0020] Optionally, the target prefetch algorithm includes at least two prefetch algorithms; and determining the performance evaluation index of the target prefetch algorithm based on the current cache environment information recorded in the global history register and the historical prefetch information corresponding to the target prefetch algorithm includes:

[0021] Obtaining a prediction sequence corresponding to each target prefetch algorithm; the prediction sequence includes a prediction node, the prediction node corresponds to a prefetch address predicted by the target prefetch algorithm, and each prediction node includes an algorithm identifier, the algorithm identifier is used to indicate the prefetch algorithm corresponding to the prediction node;

[0022] Merging prediction nodes with the same prefetch address in the prediction sequence corresponding to the target prefetch algorithm to obtain a first prediction sequence;

[0023] According to the algorithm identifiers of the prediction nodes in the first prediction sequence, the first prediction sequence is split into at least two prediction subsequences; the at least two prediction subsequences include a first subsequence and a second subsequence, the algorithm identifiers of the prediction nodes in each first subsequence indicate the same pre-fetching algorithm, and the algorithm identifiers of the prediction nodes in each second subsequence are the same and indicate at least two pre-fetching algorithms;

[0024] For the first subsequence, obtaining first historical prefetch information of a first prefetch algorithm corresponding to the first subsequence from the global history register according to the algorithm identifier, and determining a performance evaluation indicator corresponding to the first subsequence according to the first historical prefetch information;

[0025] For the second subsequence, a second prefetch algorithm is determined from at least two prefetch algorithms indicated by the algorithm identifier; the prefetch confidence of the second prefetch algorithm is greater than the prefetch confidence of other prefetch algorithms indicated by the algorithm identifier;

[0026] Based on the second history prefetch information corresponding to the second prefetch algorithm recorded in the global history register, a performance evaluation index corresponding to the second subsequence is determined.

[0027] Optionally, determining a target throttling control mode according to the performance evaluation index includes:

[0028] Determining a target throttling control mode corresponding to each predicted subsequence according to a performance evaluation index corresponding to the predicted subsequence;

[0029] The updating of the prefetch request to be sent in the prefetch queue according to the target throttling control mode, and prefetching based on the updated prefetch queue, includes:

[0030] For each prediction subsequence, updating the prediction nodes in the prediction subsequence according to the target throttling control mode;

[0031] According to the prediction nodes included in each updated prediction subsequence, a prefetch request is generated and sent.

[0032] Optionally, the prefetcher further comprises a decision lookup table, the decision lookup table being used to record a mapping relationship between an input vector and a decision value, each decision value corresponding to a throttling control mode;

[0033] Determining the target throttling control mode according to the performance evaluation index includes:

[0034] Constructing a first input vector according to the performance evaluation index;

[0035] Inputting the first input vector into a decision lookup table for query to obtain a target decision value;

[0036] A target throttling control mode is determined according to the target decision value.

[0037] On the other hand, an embodiment of the present invention discloses a prefetch device, which is applied to a prefetcher, wherein a global history register is provided in the prefetcher; the device comprises:

[0038] An acquisition module, used for acquiring a position vector of a target physical page; the position vector is used for reflecting historical prefetching information of each prefetching algorithm in the prefetcher for each data block in the target physical page;

[0039] an activation module, configured to activate a target prefetching algorithm in the prefetcher according to the position vector;

[0040] A performance determination module, configured to determine a performance evaluation index of the target prefetch algorithm based on the current cache environment information recorded in the global history register and the historical prefetch information corresponding to the target prefetch algorithm; the performance evaluation index is used to indicate the prefetch performance of the target prefetch algorithm;

[0041] A mode determination module, used to determine a target throttling control mode according to the performance evaluation index;

[0042] The updating module is used to update the prefetch requests to be sent in the prefetch queue according to the target throttling control mode, and perform prefetching based on the updated prefetch queue.

[0043] Optionally, the activation module includes:

[0044] A merging submodule, configured to merge the position vectors bit by bit according to a preset aggregation granularity to obtain at least two first vectors; one bit of the position vector corresponds to a pre-fetch algorithm, and each first vector corresponds to the same bit of the position vector;

[0045] An activation submodule is used to activate a target prefetch algorithm in the prefetcher according to the value of the first vector; the value of the first vector corresponding to the target prefetch algorithm is not zero.

[0046] On the other hand, an embodiment of the present invention further discloses an electronic device, which includes a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store executable instructions, and the executable instructions enable the processor to execute the aforementioned prefetching method.

[0047] The embodiment of the present invention further discloses a readable storage medium. When instructions in the readable storage medium are executed by a processor of an electronic device, the electronic device can execute the aforementioned pre-fetching method.

[0048] The embodiments of the present invention include the following advantages:

[0049] The embodiment of the present invention provides a prefetch method, which can selectively activate the target prefetch algorithm in the prefetcher according to the position vector of the target physical page, and determine the quantitative performance evaluation index based on the current cache environment information captured by the global history register and the historical prefetch information corresponding to the target prefetch algorithm, and determine the corresponding target throttling control mode according to the value of the performance evaluation index, and perform throttling control on the prefetch requests in the prefetch queue. The embodiment of the present invention can control the number of prefetch requests issued by the prefetcher in combination with the current cache scene information and the historical prefetch information of the prefetch algorithm, and can timely control the number of prefetch requests issued by the prefetcher to avoid excessive prefetching that damages the cache system performance, which is beneficial to improving the overall performance of the processor system. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0051] Figure 1 is a flowchart of a pre-fetching method embodiment of the present invention;

[0052] Figure 2 is a schematic diagram of the architecture of a prefetcher of the present invention;

[0053] Figure 3 It is a schematic flow chart of a pre-fetching method of the present invention;

[0054] Figure 4 is a structural block diagram of an embodiment of a pre-fetching device of the present invention;

[0055] Figure 5 It is a structural block diagram of an electronic device provided by an example of the present invention. DETAILED DESCRIPTION

[0056] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0057] The terms "first", "second", etc. in the specification and claims of the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable when appropriate, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, the term "and / or" in the specification and claims is used to describe the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. In the embodiments of the present invention, the term "multiple" refers to two or more, and other quantifiers are similar.

[0058] Method Embodiment

[0059] Reference Figure 1 , shows a flowchart of a pre-fetching method embodiment of the present invention, the method may specifically include the following steps:

[0060] Step 101, obtaining a position vector of a target physical page; the position vector is used to reflect the historical prefetch information of each prefetch algorithm in the prefetcher for each data block in the target physical page;

[0061] Step 102: activating a target prefetching algorithm in the prefetcher according to the position vector;

[0062] Step 103: determining a performance evaluation index of the target prefetch algorithm based on the current cache environment information recorded in the global history register and the historical prefetch information corresponding to the target prefetch algorithm; the performance evaluation index is used to indicate the prefetch performance of the target prefetch algorithm;

[0063] Step 104: determining a target throttling control mode according to the performance evaluation index;

[0064] Step 105: Update the prefetch requests to be sent in the prefetch queue according to the target throttling control mode, and perform prefetching based on the updated prefetch queue.

[0065] The prefetching method provided in the embodiment of the present invention is applied to a prefetcher. It should be noted that the present invention adds a global history register (GHR) structure in the prefetcher to capture the external cache environment information of the prefetcher and the historical prefetching information of various prefetching algorithms in the prefetcher. Figure 2 , shows a schematic diagram of the architecture of a prefetcher provided by an embodiment of the present invention. Figure 2 As shown, the global history register includes at least two recording modules, each of which is connected to a pre-fetching submodule, and a pre-fetching submodule is used to implement a pre-fetching algorithm. Accordingly, each recording module is used to record historical pre-fetching information corresponding to a pre-fetching algorithm.

[0066] In the embodiment of the present invention, the prefetcher may control the number of prefetch requests issued by the prefetcher in combination with the current cache scene change information and the historical prefetch information of the prefetch algorithm.

[0067] Specifically, after triggering the prefetch, the position vector of the target physical page can be obtained first. The target physical page can be a physical page hit by the access address or prefetch training address that triggers the prefetch. The position vector is used to reflect the historical prefetch information of each prefetch algorithm in the prefetcher for each data block in the target physical page. Exemplarily, in the position vector of the target physical page, each element corresponds to a data block. Assuming that the position vector is [0, 1, 2, 2], indicating 4 data blocks, the prefetcher contains 3 prefetch algorithms. The position vector can be represented as [000, 001, 010, 010] with a 3-bit binary number, and each bit corresponds to a prefetch algorithm. For example, the low bit corresponds to prefetch algorithm A, the middle bit corresponds to prefetch algorithm B, and the high bit corresponds to prefetch algorithm C. It can be seen from the position vector that for data block 0, no prefetch algorithm has issued a prefetch for the data block; for data block 1, prefetch algorithm A has issued a prefetch; for data 2 and data block 3, prefetch algorithm B has issued a prefetch.

[0068] According to the position vector, the target prefetch algorithm in the prefetcher can be selected for activation. It is understandable that the target prefetch algorithm can be an algorithm that issues prefetches in the past period of time as indicated by the position vector, or a prefetch algorithm in which the number of data blocks prefetched in the target physical page in the past period of time is greater than or equal to a preset threshold. For example, in the above example, only prefetch algorithm C has not issued a prefetch, so prefetch algorithms A and B can be determined as target prefetch algorithms and activated. Activating the target prefetch algorithm means activating the prefetch submodule corresponding to the target prefetch algorithm in the prefetcher, so that the prefetcher can perform prefetch operations based on the target prefetch algorithm.

[0069] For the activated target prefetch algorithm, throttling control is required to avoid excessive prefetching.

[0070] Specifically, the current cache environment information and the historical prefetch information corresponding to the target prefetch algorithm are obtained from the global history register, and the performance evaluation index of the target prefetch algorithm is determined based on these two types of information. Among them, the current cache environment information is used to reflect the congestion situation in the current cache system, or to reflect the additional cache bandwidth occupied by prefetching. Exemplarily, the current cache environment information may include the ratio of the number of prefetch requests actually issued by the prefetcher to the number of prefetch requests that successfully trigger prefetching (prefetching is successful, that is, prefetching the data block and backfilling it into the cache); or, the current cache environment information may also include the number of prefetch requests issued by each prefetch submodule in the prefetcher and the number of prefetch requests successfully sent by the prefetcher to the prefetch queue, etc. The historical prefetch information of the target prefetch algorithm can reflect the number of expected requests issued by the target prefetch algorithm, the prefetch access hit situation, the prefetch backfill situation, etc.

[0071] In an embodiment of the present invention, the performance evaluation index of the target prefetch algorithm can be determined according to the current cache environment information and the historical prefetch information corresponding to the target prefetch algorithm. Exemplarily, the current cache environment information and the historical prefetch information can be quantified, and the quantified value can be used as a performance evaluation index. For example, the ratio of the number of prefetch requests actually issued by the prefetcher to the number of prefetch requests that successfully trigger prefetching (prefetching success, that is, prefetching data blocks and backfilling them into the cache) can be used as the quantified value corresponding to the current cache environment information, and the quantified value can be used as a performance evaluation index; or, through a quantization function, the number of prefetch requests issued by each prefetch submodule in the prefetcher and the number of prefetch requests successfully sent by the prefetcher to the prefetch queue can be converted into a quantified value, and the quantified value can be used as a performance evaluation index. For another example, the prefetch accuracy quantization value can be determined according to the number of prefetch requests and the number of prefetch access hits in the historical prefetch information, and the prefetch coverage quantization value can be determined according to the number of prefetch requests and the number of prefetch backfills, and these quantized values ​​can be used as performance evaluation indicators. Among them, the number of prefetch requests refers to the number of prefetch requests issued by the prefetcher to the cache system, the number of prefetch access hits refers to the number of data blocks prefetched and backfilled by the prefetcher that are hit in subsequent accesses, and the number of prefetch backfills refers to the number of prefetch requests issued by the prefetcher that prefetch data blocks from the next level cache or memory and backfill them into the current level cache.

[0072] Based on these performance evaluation indicators, the congestion of the current cache system and information such as the prefetching accuracy and prefetching coverage of the prefetching algorithm can be determined, thereby predicting the impact of prefetching behavior on the cache system.

[0073] For example, a processor that includes an L1 cache prefetcher and an L2 cache prefetcher, the request sent by the L1 cache prefetcher will be merged with the L2 prefetch request, but there is still a priority, and the L1 prefetch request takes precedence over the L2 response. In the L2-level prefetcher, it cannot perceive the impact of its own working status over a period of time on the cache system. When the access pattern of the memory access system becomes complex, or the MSHR resources are insufficient due to excessive cache system load and the prefetch response is blocked, prefetching without a throttling control strategy can easily lead to excessive prefetching and deterioration of prefetching accuracy.

[0074] Specifically, the L2-level prefetcher cannot effectively perceive its own working status in this case, and therefore may continue to perform prefetch operations under high load, regardless of the current system's processing power. This may lead to further blocking of the cache system, resulting in more regular cache misses. In addition, due to the continuous prediction of the prefetcher, excessive prefetching may occur, which has a negative impact on the entire memory access system. In particular, when the prefetcher mechanism carries a prefetch algorithm with a high prefetch coverage rate, the current architectural scheme of sending prefetch requests based on priority is prone to excessive prefetching behavior that is harmful to the cache system.

[0075] Therefore, in an embodiment of the present invention, after determining the performance evaluation index, the corresponding target throttling control mode can be determined according to the performance evaluation index, and the prefetch requests to be sent in the prefetch pair can be updated to control the number of prefetch requests sent by the prefetcher to the cache system, thereby achieving the purpose of throttling control.

[0076] For example, if the current cache system load is too high, resulting in insufficient Miss Status Handling Register (MSHR) resources, it will be unable to respond to prefetch requests in a timely manner, which may easily lead to excessive prefetching and deterioration of prefetching accuracy. In this case, the prefetcher can be throttled to reduce the issuance of prefetch requests. If the prefetching accuracy of the prefetching algorithm is low, the prefetched backfill block will replace the original data block in the cache, which will pollute the cache and cause more regular cache misses. In this case, the issuance of prefetch requests generated by the prefetching algorithm can be reduced. If the prefetching coverage of the prefetching algorithm is high, it is easy to cause excessive prefetching. In this case, the issuance of prefetching requests generated by the prefetching algorithm can also be reduced.

[0077] As an example, the throttling control modes in the embodiments of the present invention may include four types: mode 1, no throttling control is performed, and the prefetch request enters the prefetch queue normally; mode 2, half of the existing prefetch requests in the prefetch queue are flushed, and then the new prefetch request is queued; mode 3, all the prefetch requests that have not been issued in the queue are cleared. The situation that triggers this control mode is largely because the cache system is blocked by insufficient resources, resulting in the prefetch request sent by the prefetcher to the outside unable to complete normal processing, and the prefetch request is stuck in the prefetch queue for too long, which blocks the subsequent updated prefetch request to load data in advance; mode 4, the prefetch is cleared, and the prefetch request is cleared. All pending prefetch request items in the fetch queue are taken, and the current new prefetch requests are blocked. This situation is triggered by insufficient cache system bandwidth and poor quantization of the prefetcher performance counter. The prefetch accuracy is low but the prefetch coverage is high (corresponding to a cache state data distribution, where the number of prefetched data in the cache is greater than the number of data normally loaded or maintained for consistency. The data storage of this cache is almost all occupied by prefetched data, but later memory accesses often do not access these pre-loaded data). In this case, in addition to flushing all old prefetch requests, new prefetch requests within the current observation window must be blocked.

[0078] The prefetch method provided by the embodiment of the present invention can selectively activate the target prefetch algorithm in the prefetcher according to the position vector of the target physical page, and determine the quantitative performance evaluation index based on the current cache environment information captured by the global history register and the historical prefetch information corresponding to the target prefetch algorithm, determine the corresponding target throttling control mode according to the value of the performance evaluation index, and perform throttling control on the prefetch requests in the prefetch queue. The embodiment of the present invention can control the number of prefetch requests issued by the prefetcher in combination with the current cache scene information and the historical prefetch information of the prefetch algorithm, and can timely control the number of prefetch requests issued by the prefetcher to avoid excessive prefetching that damages the cache system performance, which is beneficial to improving the overall performance of the processor system.

[0079] Optionally, the step 102 of activating a target prefetching algorithm in the prefetcher according to the position vector includes:

[0080] Step S11: merging the position vectors bit by bit according to a preset aggregation granularity to obtain at least two first vectors; one bit of the position vector corresponds to a pre-fetch algorithm, and each first vector corresponds to the same bit of the position vector;

[0081] Step S12: activating a target prefetch algorithm in the prefetcher according to the value of the first vector; the value of the first vector corresponding to the target prefetch algorithm is not zero.

[0082] In an embodiment of the present invention, the position vectors may be bitwise merged according to a preset aggregation granularity. Among them, one bit of the position vector corresponds to a prefetch algorithm, and each first vector corresponds to the same bit of the position vector. Exemplarily, assuming that the preset aggregation granularity is 4, and the prefetcher includes 3 prefetch algorithms, the 4 position vectors may be expressed as [000, 001, 010, 010], and each bit corresponds to a prefetch algorithm, for example, the low bit corresponds to prefetch algorithm A, the middle bit corresponds to prefetch algorithm B, and the high bit corresponds to prefetch algorithm C. After the position vectors are bitwise merged, the first vector corresponding to prefetch algorithm A is "1", the first vector corresponding to prefetch algorithm B is "2", and the first vector corresponding to prefetch algorithm C is "0".

[0083] The prefetch algorithm whose value of the first vector is not 0 is determined as the target prefetch algorithm and activated. In the above example, prefetch algorithms A and B can be determined as the target prefetch algorithms and activated. Activating the target prefetch algorithm means activating the prefetch submodule corresponding to the target prefetch algorithm in the prefetcher, so that the prefetcher can perform prefetch operations based on the target prefetch algorithm.

[0084] Optionally, the global history register includes a prefetch request counter, a prefetch access hit counter and a prefetch backfill counter corresponding to each prefetch algorithm; the prefetch request counter is used to record the number of prefetch requests triggered by the prefetch algorithm; the prefetch access hit counter is used to record the number of times the cache blocks prefetched by the prefetch algorithm are hit; the prefetch backfill counter is used to record the number of backfills corresponding to the prefetch algorithm.

[0085] The step 103 of determining the performance evaluation index of the target prefetch algorithm based on the historical prefetch information corresponding to the target prefetch algorithm recorded in the global history register includes:

[0086] Step S21, obtaining a first count value of a prefetch request counter, a second count value of a prefetch access hit counter, and a third count value of a prefetch backfill counter corresponding to the target prefetch algorithm;

[0087] Step S22, determining a prefetching precision quantization value of the target prefetching algorithm according to the first count value and the second count value;

[0088] Step S23, determining a prefetch coverage quantization value of the target prefetch algorithm according to the first count value and the third count value;

[0089] Step S24: determining a cache congestion quantization value according to first count values ​​corresponding to each prefetch algorithm in the prefetcher.

[0090] In an embodiment of the present invention, the performance evaluation metrics corresponding to the current cache environment information may include a cache congestion quantization value; the performance evaluation metrics corresponding to the historical prefetch information of the target prefetch algorithm may include a prefetch accuracy quantization value and a prefetch coverage quantization value.

[0091] Exemplarily, assume that the first count value of the prefetch request counter is ISSUSE, the second count value of the prefetch access hit counter is HIT, and the third count value of the prefetch backfill counter is COVER. The first count value and the second count value can be converted into a prefetch accuracy quantization value through the quantization function F(ISSUSE, HIT), the first count value and the third count value can be converted into a prefetch coverage quantization value through the quantization function F(ISSUSE, COVER), and the first count value corresponding to each prefetch algorithm can be converted into a cache congestion quantization value through the quantization function F(ΣISSUSE, ACCUMU), where ACCUMU is the number of prefetch requests issued by all prefetch sub-modules in the prefetch unit (not the number of prefetch requests issued by the prefetch unit to the cache system), and "ΣISSUSE" is the number of prefetch requests successfully sent to the cache system by each prefetch sub-module in the prefetch unit, that is, the sum of the first count values of the prefetch request counters corresponding to each prefetch algorithm in the prefetch unit.

[0092] In an alternative embodiment of the present invention, the quantization function F(X, Y) can be used to calculate the ratio of X and Y, that is, F(X, Y) = X / Y. For example, the prefetch accuracy quantization value of the prefetch algorithm x = the first count value ISSUSE_x / the second count value HIT_x; the prefetch coverage quantization value of the prefetch algorithm x = the first count value ISSUSE_x / the third count value COVER_x; the cache congestion quantization value = (ΣISSUSE) / ACCUMU.

[0093] In another alternative embodiment of the present invention, the above quantization values can also be represented by "0" or "1". For example, when 4 × HIT > (ISSUE), the prefetch accuracy quantization value H is 1, otherwise H is 0. It can be understood that when the number of prefetch hits of the target prefetch algorithm is 25% of the number of successfully sent prefetches, it is considered that the prefetch accuracy of the target prefetch algorithm is relatively high. When 4 × COVER > (ISSUE + ISSUE), the prefetch coverage quantization value C is 1, otherwise C is 0. When 2 × (ΣISSUSE) < ACCUMU, the cache congestion quantization value B is 1, otherwise B is 0.

[0094] Optionally, the prefetch unit further includes a decision lookup table for recording the mapping relationship between the input vector and the decision value, and each decision value corresponds to a throttling control mode.

[0095] Step 104 of determining the target throttling control mode according to the performance evaluation metrics includes:

[0096] Step S31, constructing a first input vector according to the performance evaluation index;

[0097] Step S32: input the first input vector into a decision lookup table for query to obtain a target decision value;

[0098] Step S33: determine the target throttling control mode according to the target decision value.

[0099] In an embodiment of the present invention, a mapping relationship between an input vector and a decision value can be recorded through a decision lookup table, and each decision value corresponds to a throttling control mode. The mapping relationship between the decision value and the throttling control mode can be determined according to actual throttling control requirements and experimental analysis data.

[0100] After determining the performance evaluation index corresponding to the target prefetch algorithm, a first input vector can be constructed according to each performance evaluation index, and the decision lookup table can be queried using the first input vector to find the corresponding target decision value, thereby determining the target throttling control mode.

[0101] As an example, the first input vector may be (H, C, B), where H is a prefetch accuracy quantization value, C is a prefetch coverage quantization value, and B is a cache congestion quantization value.

[0102] The decision value output by the decision lookup table can be any of 0, 1, 2, and 3. Among them, 0 means allowing prefetch requests to enter the prefetch cache queue; 1 means flushing half of the existing prefetch requests in the prefetch queue, and then entering the new prefetch request; 2 means clearing all the prefetch requests that have not been issued in the queue. The situation that triggers this control mode is largely because the cache system is blocked by insufficient resources, resulting in the inability to complete normal processing of the prefetch request sent by the prefetcher. The prefetch request is stuck in the prefetch queue for too long and blocks the subsequent updated prefetch request to load data in advance; 3 means clearing all suspended prefetch request items in the prefetch queue, and blocking the current new prefetch request. , triggering this situation is more stringent than the decision value equal to 2. Triggering this situation means that the cache system bandwidth is insufficient and the quantized state of the prefetcher performance counter is poor, the prefetch accuracy is low but the prefetch coverage is very high (corresponding to a cache state data distribution, the number of prefetched data in the cache is more than the number of data normally loaded or maintained for consistency, the data storage of this cache is almost all occupied by the prefetched data, but the subsequent memory access often does not access these pre-loaded data). At this time, in addition to flushing all old prefetch requests, new prefetch requests within the current observation window period must be blocked.

[0103] In an optional embodiment of the present invention, the target prefetch algorithm includes at least two prefetch algorithms; the determining the performance evaluation index of the target prefetch algorithm based on the historical prefetch information corresponding to the target prefetch algorithm recorded in the global history register includes:

[0104] Step S41, obtaining a prediction sequence corresponding to each target prefetch algorithm; the prediction sequence includes a prediction node, the prediction node corresponds to a prefetch address predicted by the target prefetch algorithm, and each prediction node includes an algorithm identifier, the algorithm identifier is used to indicate the prefetch algorithm corresponding to the prediction node;

[0105] Step S42, merging prediction nodes with the same prefetch address in the prediction sequence corresponding to the target prefetch algorithm to obtain a first prediction sequence;

[0106] Step S43: split the first prediction sequence into at least two prediction subsequences according to the algorithm identifiers of the prediction nodes in the first prediction sequence; the at least two prediction subsequences include a first subsequence and a second subsequence, the algorithm identifiers of the prediction nodes in each first subsequence indicate the same pre-fetching algorithm, and the algorithm identifiers of the prediction nodes in each second subsequence are the same and indicate at least two pre-fetching algorithms;

[0107] Step S44: for the first subsequence, obtaining first historical prefetch information of a first prefetch algorithm corresponding to the first subsequence from the global history register according to the algorithm identifier, and determining a performance evaluation index corresponding to the first subsequence according to the first historical prefetch information;

[0108] Step S45: for the second subsequence, determine a second prefetch algorithm from the at least two prefetch algorithms indicated by the algorithm identifier; the prefetch confidence of the second prefetch algorithm is greater than the prefetch confidence of other prefetch algorithms indicated by the algorithm identifier;

[0109] Step S46: Determine a performance evaluation index corresponding to the second subsequence based on the second history prefetch information corresponding to the second prefetch algorithm recorded in the global history register.

[0110] In an embodiment of the present invention, if there are multiple target prediction algorithms, the prediction sequences generated by the various pre-fetching algorithms may be aggregated first to remove redundant prediction nodes. Then, the prediction sequence is divided into multiple prediction sub-sequences according to the algorithm identifiers corresponding to the various prediction nodes, and the algorithm identifiers corresponding to the various prediction nodes in each prediction sub-sequence are the same. Among them, the algorithm identifiers of the various prediction nodes in the first sub-sequence indicate the same pre-fetching algorithm, and the algorithm identifiers of the various prediction nodes in the second sub-sequence are the same and indicate at least two pre-fetching algorithms.

[0111] For the first subsequence, the corresponding performance evaluation index can be directly determined according to the first historical prefetch information of the prefetch algorithm corresponding to the sequence. For the second subsequence, in order to ensure the accuracy of throttling control, the second historical prefetch information of the prefetch algorithm with the highest prefetch confidence can be selected to determine the performance evaluation index.

[0112] Optionally, the step 104 of determining a target throttling control mode according to the performance evaluation index includes:

[0113] Step S51, determining a target throttling control mode corresponding to each prediction subsequence according to a performance evaluation index corresponding to the prediction subsequence;

[0114] Step 105, in accordance with the target throttling control mode, updates the prefetch requests to be sent in the prefetch queue, and performs prefetching based on the updated prefetch queue, including:

[0115] Step S52: for each prediction subsequence, updating the prediction nodes in the prediction subsequence according to the target throttling control mode;

[0116] Step S53: Generate and send a pre-fetch request according to the prediction nodes included in each updated prediction sub-sequence.

[0117] In the embodiment of the present invention, for each subsequence, a target throttling control mode exclusive to the subsequence can be determined based on its corresponding performance evaluation index. When performing throttling control, the prediction nodes in the subsequence are updated respectively according to the respective throttling control modes of each subsequence, and a pre-fetch request is generated and sent according to the prediction nodes included in each updated prediction subsequence.

[0118] Exemplarily, assuming that for subsequence 1, its corresponding decision value is 1, then according to the generation time of each prediction node, half of the earliest generated prediction nodes are flushed, and then prefetch requests are generated according to the remaining half of the prediction nodes; for subsequence 2, its corresponding decision value is 2, then all prediction nodes in the subsequence are cleared; for subsequence 3, its corresponding decision value is 3, then all prediction nodes in the subsequence are cleared, and new prediction nodes generated by the prediction algorithm corresponding to the subsequence within the current observation window period are shielded.

[0119] The embodiment of the present invention can perform throttling control on each prefetching algorithm individually when multiple prefetching algorithms are working simultaneously, thereby improving the throttling control accuracy and facilitating improving the prefetching accuracy of the prefetcher.

[0120] Reference Figure 3 , shows a schematic flow chart of a pre-fetching method provided by an embodiment of the present invention. Figure 3As shown, the embodiment of the present invention implements throttling control in the prefetching process through the following five steps:

[0121] Step 1: Pre-fetch the training input and send it to the filter table FT to query whether it hits the corresponding page address. Figure 3 The situation of hitting physical page A is shown in Figure 1. At this time, the position vector of physical page A is split and merged into sub-vector A (VecA), sub-vector B (VecB) and sub-vector C (VecC) according to the number of current prefetch algorithms. Among them, VecA is the lowest bit of each counter in the position vector, VecB is the middle bit of each counter, and VecC is the highest bit of each counter. The sub-vector split in the current step is formed by adding the corresponding bits of every 4 position vectors.

[0122] Step 2: According to the aggregated independent sub-vectors VecA, VecB, and VecC, the corresponding prefetch sub-modules in the activation prefetcher are selected for training. Figure 3 In the region of the block offset aggregation triggered by training, only the values ​​of VecA and VecB are greater than 0, and the value of VecC is 0, so only the prefetch submodules A and B are activated.

[0123] Step 3: The filter table FT receives the prediction sequences from the pre-fetch submodules A and B. The gray rectangles mark the overlapping contents in the pre-fetch sequences. Then, the pre-fetch patterns are filtered to obtain the filtered pre-fetch patterns as shown in Figure 3 shown.

[0124] Step 4: FT sends the filtered prediction sequence to the global history register GHR module. GHR queries the decision lookup table LUT component based on the state vector (H, C, B) obtained by global history information quantization to obtain the decision value Action. The decision value corresponds to four different throttling control modes.

[0125] The embodiment of the present invention designs a table structure FT for vector bit storage from the input end of the prefetch training signal, and the entire cache system additionally designs the data flow logic of the pfVec field (the AcquireBlock request type adds the pfVec field record to the directory). Therefore, the CoupledL2 cache system modified externally by the prefetcher adds the pfVec field in addition to the prefetch flag isPrefetch field, and supports the tracking of the source ID of the data algorithm for prefetching backfill, that is, when the prefetched data is hit, it can be known by which prefetch algorithms the data block is loaded in advance.

[0126] Steps 1 and 2 can activate the prefetch submodules that need to be triggered for training and prefetching according to the source ID of pfVec. For example, as shown in the gray box in the figure, when the block offset corresponding to pageA is in the alignment block interval (the current design is to use 4 block numbers as an interval, which is exactly the maximum range that can be represented by 2 bits of the pfVec field), according to the position vector aggregation operation, each element of the aggregation vector (0, 1, 2, 3) of the 4 adjacent positions is divided into three independent sub-vectors (1, 3, ...), (2, 0, ...), (0, 4, ...) according to the number of bits where the cumulative position is 1. According to the value of PageA index interval 0 (that is, the value of the element at position 0 after the split), only VecA and VecB (shown in the gray box below the arrow in step 1 in the figure) are activated and selected, and the training of algorithms A and B is activated in step 2.

[0127] Steps 1 and 2 can filter out algorithms such as C that have not participated in prefetching the hit data in advance, and then correctly avoid participating in mispredictions. Due to the record tracking and data flow of the pfVec field, the prefetcher can distinguish the algorithm source ID of the sub-algorithm module that truly contributes to memory access acceleration and then start effective training prediction, which can solve the training interference problem of prefetching again after the prefetch hit.

[0128] Step 3 of the throttling control algorithm is to filter the prefetch request. Step 3 can effectively filter the overlapping parts of the memory access addresses output by the sub-algorithms activated and participating in the prediction in the same memory access mode. For different types of algorithms such as BOP and improved SPP, the time required from receiving training data to outputting the address to be predicted is different (that is, the time spent on prediction varies with the algorithm architecture design). FT records the algorithm source ID number corresponding to the first predicted block to detect whether the subsequent output address is repeated with the prediction in the adjacent time. If it is repeated, the subsequent predicted address will be blocked. Figure 3 For example, for the original prediction sequence under page A, the three block addresses 29, 30, and 31 marked with gray boxes in the figure are predicted by algorithms A and B, and there is some overlap. After passing through the filter table, the prediction sequence is converted to filter mode, and the three originally overlapping memory access addresses 29, 30, and 31 will only send a prefetch request output once.

[0129] Steps 4 and 5 of the throttling control algorithm are the process of global throttling control. In essence, if the cache bandwidth resources are insufficient, the prediction sequence after FT filtering will be filtered by GHR and decision lookup table LUT again, and converted into a smaller number of requests and finally sent to the MSHR pre-fetch request. Steps 4 and 5 are an adaptive process, and different throttling schemes are given as the value of the cache system performance register changes. The basis of the entire adaptive control is mainly provided by the decision lookup table set in advance.

[0130] by Figure 3 For example, when (H, C, B) in step 4 is (1, 0, 1), the value of the LUT query output is 0. For the square marked in gray in the LUT dotted box in the figure, when Action is 0, the corresponding policy is to allow the request to enter the prefetch queue.

[0131] There are four control modes corresponding to the decision value. 0 means allowing prefetch requests to enter the prefetch cache queue; 1 means flushing half of the existing prefetch requests in the prefetch queue, and then entering the new prefetch request; 2 means clearing all the prefetch requests that have not been issued in the queue. The situation that triggers this control mode is largely because the cache system is blocked by insufficient resources, resulting in the inability to complete normal processing of the prefetch requests sent by the prefetcher. The prefetch request is stuck in the prefetch queue for too long and blocks the subsequent updated prefetch requests to load data in advance; 3 means clearing all suspended prefetch request items in the prefetch queue, and shielding the current new Prefetch request. Triggering this situation is more stringent than Action equals 2. Triggering this situation means that the cache system bandwidth is insufficient and the quantized state of the prefetcher performance counter is poor. The prefetch accuracy is low but the prefetch coverage is very high (corresponding to a cache state data distribution, the number of prefetched data in the cache is greater than the number of data normally loaded or maintained for consistency. The data storage of this cache is almost all occupied by prefetched data, but later memory accesses often do not access these pre-loaded data). In this case, in addition to flushing all old prefetch requests, new prefetch requests within the current observation window period must be blocked.

[0132] exist Figure 3 In the prefetch method shown, the list of signals that the prefetcher interacts with the outside world is as follows:

[0133]

[0134] Among them, pfVec and goWhereVec are both position vectors, and each bit represents the identifier of a type of prefetcher, as shown in Table 2:

[0135]

[0136] When the X prefetch submodule sends a prefetch request to the cache system, the count value of the prefetch request counter corresponding to X is incremented. When the global reset flag register is reset (the performance statistics cycle number is saturated, the default setting is 102400 clock cycles), the prefetch request counter corresponding to X is reset to 0.

[0137] When the state of the prefetcher train port is prefetch hit and pfVec is X, the X prefetch access hit counter increments. When the global reset flag register is reset (the performance statistics cycle number is saturated, the default setting is 102400 clock cycles), the X prefetch access hit counter is reset to 0.

[0138] When the pfVec of the prefetcher resp port is X, the X prefetch backfill counter increments. When the global reset flag register is reset (the performance statistics cycle number is saturated, the default setting is 102400 clock cycles), the X prefetch backfill counter is reset to 0.

[0139] It should be noted that the above three counters can all be implemented in the top-level module design of the prefetcher.

[0140] In summary, the embodiment of the present invention provides a prefetch method, which can selectively activate the target prefetch algorithm in the prefetcher according to the position vector of the target physical page, and determine the quantitative performance evaluation index based on the current cache environment information captured by the global history register and the historical prefetch information corresponding to the target prefetch algorithm, and determine the corresponding target throttling control mode according to the value of the performance evaluation index, and perform throttling control on the prefetch requests in the prefetch queue. The embodiment of the present invention can control the number of prefetch requests issued by the prefetcher in combination with the current cache scene information and the historical prefetch information of the prefetch algorithm, and can timely control the number of prefetch requests issued by the prefetcher to avoid excessive prefetching that damages the cache system performance, which is beneficial to improving the overall performance of the processor system.

[0141] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0142] Device Embodiment

[0143] Reference Figure 4 , shows a structural block diagram of a prefetch device of the present invention, the device is applied to a prefetcher, and a global history register is provided in the prefetcher; the device may specifically include:

[0144] An acquisition module 401 is used to acquire a position vector of a target physical page; the position vector is used to reflect the historical prefetch information of each prefetch algorithm in the prefetcher for each data block in the target physical page;

[0145] An activation module 402, configured to activate a target prefetching algorithm in the prefetcher according to the position vector;

[0146] A performance determination module 403, configured to determine a performance evaluation index of the target prefetch algorithm based on the current cache environment information recorded in the global history register and the historical prefetch information corresponding to the target prefetch algorithm; the performance evaluation index is used to indicate the prefetch performance of the target prefetch algorithm;

[0147] A mode determination module 404, configured to determine a target throttling control mode according to the performance evaluation index;

[0148] The updating module 405 is used to update the prefetch requests to be sent in the prefetch queue according to the target throttling control mode, and perform prefetching based on the updated prefetch queue.

[0149] Optionally, the activation module includes:

[0150] A merging submodule, used to merge the position vectors bit by bit according to a preset aggregation granularity to obtain at least two first vectors; one bit of the position vector corresponds to a pre-fetch algorithm, and each first vector corresponds to the same bit of the position vector;

[0151] An activation submodule is used to activate a target prefetch algorithm in the prefetcher according to the value of the first vector; the value of the first vector corresponding to the target prefetch algorithm is not zero.

[0152] Optionally, the global history register includes a prefetch request counter, a prefetch access hit counter and a prefetch backfill counter corresponding to each prefetch algorithm; the prefetch request counter is used to record the number of prefetch requests triggered by the prefetch algorithm; the prefetch access hit counter is used to record the number of times the cache block prefetched by the prefetch algorithm is hit; the prefetch backfill counter is used to record the number of backfills corresponding to the prefetch algorithm;

[0153] The performance determination module comprises:

[0154] A count value acquisition submodule, used to acquire a first count value of a prefetch request counter, a second count value of a prefetch access hit counter, and a third count value of a prefetch backfill counter corresponding to the target prefetch algorithm;

[0155] A first determining submodule, configured to determine a prefetching precision quantization value of the target prefetching algorithm according to the first count value and the second count value;

[0156] A second determining submodule, configured to determine a quantized value of a prefetch coverage rate of the target prefetch algorithm according to the first count value and the third count value;

[0157] The third determining submodule is used to determine the cache congestion quantization value according to the first counting value corresponding to each prefetching algorithm in the prefetcher.

[0158] Optionally, the target prefetching algorithm includes at least two prefetching algorithms; and the performance determination module includes:

[0159] A prediction sequence acquisition submodule, used to acquire a prediction sequence corresponding to each target prefetch algorithm; the prediction sequence includes a prediction node, the prediction node corresponds to the prefetch address predicted by the target prefetch algorithm, and each prediction node includes an algorithm identifier, the algorithm identifier is used to indicate the prefetch algorithm corresponding to the prediction node;

[0160] A node merging submodule, used for merging prediction nodes with the same prefetch address in the prediction sequence corresponding to the target prefetch algorithm to obtain a first prediction sequence;

[0161] a splitting submodule, configured to split the first prediction sequence into at least two prediction subsequences according to the algorithm identifiers of the respective prediction nodes in the first prediction sequence; the at least two prediction subsequences include a first subsequence and a second subsequence, the algorithm identifiers of the prediction nodes in each first subsequence indicate the same pre-fetching algorithm, and the algorithm identifiers of the prediction nodes in each second subsequence are the same and indicate at least two pre-fetching algorithms;

[0162] a fourth determination submodule, configured to obtain, for the first subsequence, first historical prefetch information of a first prefetch algorithm corresponding to the first subsequence from the global history register according to the algorithm identifier, and determine a performance evaluation indicator corresponding to the first subsequence according to the first historical prefetch information;

[0163] an algorithm selection submodule, configured to determine, for the second subsequence, a second prefetch algorithm from at least two prefetch algorithms indicated by the algorithm identifier; the prefetch confidence of the second prefetch algorithm being greater than the prefetch confidence of other prefetch algorithms indicated by the algorithm identifier;

[0164] The fifth determination submodule is used to determine the performance evaluation index corresponding to the second subsequence based on the second history prefetch information corresponding to the second prefetch algorithm recorded in the global history register.

[0165] Optionally, the mode determination module includes:

[0166] A first mode determination submodule, configured to determine a target throttling control mode corresponding to each prediction subsequence according to a performance evaluation index corresponding to the prediction subsequence;

[0167] The update module comprises:

[0168] An updating submodule, for updating the prediction nodes in each prediction subsequence according to the target throttling control mode;

[0169] The request submodule is used to generate and send a pre-fetch request according to the prediction nodes included in each updated prediction sub-sequence.

[0170] Optionally, the prefetcher further comprises a decision lookup table, the decision lookup table being used to record a mapping relationship between an input vector and a decision value, each decision value corresponding to a throttling control mode;

[0171] The mode determination module comprises:

[0172] A construction submodule, used to construct a first input vector according to the performance evaluation index;

[0173] A query submodule, used for inputting the first input vector into a decision lookup table for query to obtain a target decision value;

[0174] The second mode determination submodule is used to determine a target throttling control mode according to the target decision value.

[0175] In summary, an embodiment of the present invention provides a prefetch device that can selectively activate a target prefetch algorithm in a prefetcher according to a position vector of a target physical page, and determine a quantitative performance evaluation index based on the current cache environment information captured by a global history register and the historical prefetch information corresponding to the target prefetch algorithm, determine a corresponding target throttling control mode according to the value of the performance evaluation index, and perform throttling control on prefetch requests in a prefetch queue. An embodiment of the present invention can control the number of prefetch requests issued by a prefetcher in combination with the current cache scenario information and the historical prefetch information of the prefetch algorithm, and can timely control the number of prefetch requests issued by the prefetcher to avoid excessive prefetching that damages cache system performance, which is beneficial to improving the overall performance of the processor system.

[0176] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0177] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0178] Regarding the processor in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0179] Reference Figure 5 , is a structural block diagram of an electronic device for pre-fetching provided by an embodiment of the present invention. Figure 5 As shown, the electronic device includes: a processor, a memory, a communication interface and a communication bus, and the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store executable instructions, and the executable instructions enable the processor to execute the pre-fetch method of the aforementioned embodiment.

[0180] The processor may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other editable devices, transistor logic devices, hardware components or any combination thereof. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0181] The communication bus may include a path for transmitting information between the memory and the communication interface. The communication bus may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 The fact that only one line is used in the diagram does not mean that there is only one bus or only one type of bus.

[0182] The memory may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory), a magnetic tape, a floppy disk, an optical data storage device, etc.

[0183] The embodiment of the present invention also provides a non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device (server or terminal), the processor can execute Figure 1 The prefetch method shown.

[0184] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0185] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, devices or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0186] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems) and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0187] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a predictable manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0188] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0189] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0190] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0191] The above is a detailed introduction to a pre-fetching method, device, electronic device and readable storage medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for a person skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A pre-fetching method, characterized in that: Applied to a prefetcher, wherein a global history register is provided in the prefetcher; the method comprises: Acquire a position vector of a target physical page; the position vector is used to reflect historical prefetch information of each prefetch algorithm in the prefetcher for each data block in the target physical page; activating a target prefetch algorithm in the prefetcher according to the position vector; Determine a performance evaluation index of the target prefetch algorithm based on the current cache environment information recorded in the global history register and the historical prefetch information corresponding to the target prefetch algorithm; the performance evaluation index is used to indicate the prefetch performance of the target prefetch algorithm; Determining a target throttling control mode according to the performance evaluation index; updating the prefetch requests to be sent in the prefetch queue according to the target throttling control mode, and performing prefetching based on the updated prefetch queue; The target prefetch algorithm includes an algorithm for issuing prefetches in the past period of time indicated by the position vector, or a prefetch algorithm in which the number of data blocks prefetched in the target physical page in the past period of time is greater than or equal to a preset threshold; The activating the target prefetching algorithm in the prefetcher according to the position vector comprises: A target prefetch algorithm is determined according to the position vector, and a prefetch submodule corresponding to the target prefetch algorithm in the prefetcher is activated so that the prefetcher performs a prefetch operation based on the target prefetch algorithm.

2. The method according to claim 1, characterized in that The activating the target prefetching algorithm in the prefetcher according to the position vector comprises: The position vectors are bit-wise merged according to a preset aggregation granularity to obtain at least two first vectors; one bit of the position vector corresponds to a pre-fetch algorithm, and each first vector corresponds to the same bit of the position vector; A target prefetch algorithm in the prefetcher is activated according to the value of the first vector; the value of the first vector corresponding to the target prefetch algorithm is not zero.

3. The method according to claim 1, characterized in that The global history register includes a prefetch request counter, a prefetch access hit counter and a prefetch backfill counter corresponding to each prefetch algorithm; the prefetch request counter is used to record the number of prefetch requests triggered by the prefetch algorithm; the prefetch access hit counter is used to record the number of times the cache block prefetched by the prefetch algorithm is hit; the prefetch backfill counter is used to record the number of backfills corresponding to the prefetch algorithm; The determining of the performance evaluation index of the target prefetch algorithm based on the current cache environment information recorded in the global history register and the historical prefetch information corresponding to the target prefetch algorithm includes: Obtaining a first count value of a prefetch request counter, a second count value of a prefetch access hit counter, and a third count value of a prefetch backfill counter corresponding to the target prefetch algorithm; Determining a prefetch accuracy quantization value of the target prefetch algorithm according to the first count value and the second count value; Determine a prefetch coverage quantization value of the target prefetch algorithm according to the first count value and the third count value; A cache congestion quantization value is determined according to first count values ​​corresponding to each prefetch algorithm in the prefetcher.

4. The method according to claim 1, characterized in that: The target prefetch algorithm includes at least two prefetch algorithms; the performance evaluation index of the target prefetch algorithm is determined based on the current cache environment information recorded in the global history register and the historical prefetch information corresponding to the target prefetch algorithm, including: Obtaining a prediction sequence corresponding to each target prefetch algorithm; the prediction sequence includes a prediction node, the prediction node corresponds to a prefetch address predicted by the target prefetch algorithm, and each prediction node includes an algorithm identifier, the algorithm identifier is used to indicate the prefetch algorithm corresponding to the prediction node; Merging prediction nodes with the same prefetch address in the prediction sequence corresponding to the target prefetch algorithm to obtain a first prediction sequence; According to the algorithm identifiers of the prediction nodes in the first prediction sequence, the first prediction sequence is split into at least two prediction subsequences; the at least two prediction subsequences include a first subsequence and a second subsequence, the algorithm identifiers of the prediction nodes in each first subsequence indicate the same pre-fetching algorithm, and the algorithm identifiers of the prediction nodes in each second subsequence are the same and indicate at least two pre-fetching algorithms; For the first subsequence, obtaining first historical prefetch information of a first prefetch algorithm corresponding to the first subsequence from the global history register according to the algorithm identifier, and determining a performance evaluation indicator corresponding to the first subsequence according to the first historical prefetch information; For the second subsequence, a second prefetch algorithm is determined from at least two prefetch algorithms indicated by the algorithm identifier; the prefetch confidence of the second prefetch algorithm is greater than the prefetch confidence of other prefetch algorithms indicated by the algorithm identifier; Based on the second history prefetch information corresponding to the second prefetch algorithm recorded in the global history register, a performance evaluation index corresponding to the second subsequence is determined.

5. The method according to claim 4, characterized in that Determining the target throttling control mode according to the performance evaluation index includes: Determining a target throttling control mode corresponding to each predicted subsequence according to a performance evaluation index corresponding to the predicted subsequence; The updating of the prefetch request to be sent in the prefetch queue according to the target throttling control mode, and prefetching based on the updated prefetch queue, includes: For each prediction subsequence, updating the prediction nodes in the prediction subsequence according to the target throttling control mode; According to the prediction nodes included in each updated prediction subsequence, a prefetch request is generated and sent.

6. The method according to claim 1, characterized in that The prefetcher further includes a decision lookup table, the decision lookup table being used to record a mapping relationship between an input vector and a decision value, each decision value corresponding to a throttling control mode; Determining the target throttling control mode according to the performance evaluation index includes: Constructing a first input vector according to the performance evaluation index; Inputting the first input vector into a decision lookup table for query to obtain a target decision value; A target throttling control mode is determined according to the target decision value.

7. A pre-fetching device, characterized in that: Applied to a prefetcher, the prefetcher is provided with a global history register; the device comprises: An acquisition module, used for acquiring a position vector of a target physical page; the position vector is used for reflecting historical prefetching information of each prefetching algorithm in the prefetcher for each data block in the target physical page; an activation module, configured to activate a target prefetching algorithm in the prefetcher according to the position vector; A performance determination module, configured to determine a performance evaluation index of the target prefetch algorithm based on the current cache environment information recorded in the global history register and the historical prefetch information corresponding to the target prefetch algorithm; the performance evaluation index is used to indicate the prefetch performance of the target prefetch algorithm; A mode determination module, used to determine a target throttling control mode according to the performance evaluation index; An updating module, used for updating the prefetch requests to be sent in the prefetch queue according to the target throttling control mode, and performing prefetching based on the updated prefetch queue; The target prefetch algorithm includes an algorithm for issuing prefetches in the past period of time indicated by the position vector, or a prefetch algorithm in which the number of data blocks prefetched in the target physical page in the past period of time is greater than or equal to a preset threshold; The activation module is specifically used for: A target prefetch algorithm is determined according to the position vector, and a prefetch submodule corresponding to the target prefetch algorithm in the prefetcher is activated so that the prefetcher performs a prefetch operation based on the target prefetch algorithm.

8. The device according to claim 7, characterized in that The activation module comprises: A merging submodule, configured to merge the position vectors bit by bit according to a preset aggregation granularity to obtain at least two first vectors; one bit of the position vector corresponds to a pre-fetch algorithm, and each first vector corresponds to the same bit of the position vector; An activation submodule is used to activate a target prefetch algorithm in the prefetcher according to the value of the first vector; the value of the first vector corresponding to the target prefetch algorithm is not zero.

9. An electronic device, characterized in that: The electronic device comprises a processor, a memory, a communication interface and a communication bus, and the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store executable instructions, and the executable instructions enable the processor to execute the prefetching method according to any one of claims 1 to 6.

10. A readable storage medium, characterized in that: When the instructions in the readable storage medium are executed by a processor of an electronic device, the processor is enabled to execute the pre-fetching method as claimed in any one of claims 1 to 6.