CN-121996576-A - High-precision access prediction and cache prefetching method and system based on machine learning
Abstract
The invention relates to the technical field of cache prefetching optimization, in particular to a high-precision access prediction and cache prefetching method and system based on machine learning. A high-precision access prediction and cache prefetching method based on machine learning comprises the following steps of S1, monitoring and recording an access address of a processor and an identifier sequence corresponding to an access instruction in real time, calculating a difference value of adjacent access addresses to serve as a real access address variation, dynamically identifying and marking obvious unconventional variation points in the address sequence, and extracting a characteristic value reflecting an access behavior hiding rule through online recursive estimation based on the numerical value of the obvious unconventional variation points. According to the invention, by extracting the hidden rule features from the access sequence and adopting the targeted training strategy, the prediction model can accurately learn the irregular access mode, and by combining the self-adaptive selection and adjustment mechanism in operation, the prediction accuracy and the overall robustness of the cache prefetching system in the process of facing complex nonlinear access are improved.
Inventors
- LI YANJIANG
- LI QIANG
- LI YANFENG
- MAO ZHIXIN
- YU WENWU
Assignees
- 华中科技大学
- 芯创(天门)电子科技有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260124
Claims (10)
- 1. The high-precision access prediction and cache prefetching method based on machine learning is characterized by comprising the following steps of: S1, monitoring and recording an access address of a processor and an identifier sequence corresponding to an access instruction in real time, calculating the difference value of adjacent access addresses as real access address variation, dynamically identifying and marking obvious unconventional variation points in the address sequence, and extracting a characteristic value reflecting the access behavior hiding rule through online recursive estimation based on the numerical value of the obvious unconventional variation points; s2, combining the characteristic value reflecting the hiding rule of the memory behavior with an identifier sequence corresponding to the current memory address, the current real memory address variation and the memory instruction to form a combined characteristic sequence which is used as input of a neural network model; S3, training a neural network model by using a training mode focusing on unconventional change point prediction, wherein the neural network model is used for predicting future memory access change trend according to the combined feature sequence and outputting a corresponding memory access prediction result; S4, deploying the trained neural network model in a selective framework comprising a prefetching mechanism, judging a memory access behavior mode by the selective framework according to a combined feature sequence extracted in real time, and selecting to enable the neural network model or a prefetcher based on fixed rules to generate a prefetching address; S5, based on a time sequence formed by the continuously extracted characteristic values reflecting the access behavior hiding rule, when the change of the program execution stage is detected, the trained neural network model deployed in the selective architecture comprising a plurality of prefetching mechanisms is adjusted by using an access address sequence of an initial stage after the change and an identifier sequence corresponding to an access instruction; and S6, monitoring the memory access prediction result and the memory access sequence of the processor in real time in the running process, and optimizing a neural network model deployed in a selective framework comprising a plurality of prefetching mechanisms based on monitoring data.
- 2. The machine learning based high precision memory prediction and cache prefetch method of claim 1 wherein dynamically identifying and marking significant non-routine change points in an address sequence comprises: Calculating a difference sequence of adjacent access addresses, namely the real access address variation sequence; Calculating the statistical distribution characteristic of the difference sequence, and dynamically calculating a numerical limit for distinguishing a conventional difference value from a non-conventional difference value according to the statistical distribution characteristic; Non-zero difference points that fall outside the numerical limits are marked as significant non-regular change points.
- 3. The machine learning-based high-precision access prediction and cache prefetching method according to claim 1, wherein the extracting, by online recursive estimation, the feature value reflecting the access behavior hiding rule based on the numerical value of the change point comprises: Correlating the change point value corresponding to the marked obvious unconventional change point, the set first parameter to be solved, the set second parameter to be solved and the assumed internal variable change quantity to form a state space model, wherein the state space model consists of a state transition equation and an observation equation; The state transition equation is: , wherein, Representation of The state vector of the moment of time, Representation of A state vector of time, including the assumed internal variable variation, the first parameter to be calculated and the second parameter to be calculated; a state transition matrix is a matrix with diagonal elements approaching 1 and non-diagonal elements being 0, and is used for representing a smooth evolution relation of state vectors between continuous time steps; is a process noise vector; the observation equation is: , wherein, Is that The observation value of the moment, namely the numerical value of the change point; Is that An observation matrix of time, the structure of which is determined by the linear observation relation; is observation noise; Based on the state space model, constructing a state vector recurrence estimation problem, adopting an online recurrence estimation algorithm to solve the state vector recurrence estimation problem, and updating the state vector in real time Is a function of the estimated value of (2); And combining the corresponding first parameter value to be solved, the corresponding second parameter value to be solved and the statistical characteristic value of the internal variable variation in a period of time in the state vector obtained by solving at the current moment to form the characteristic value reflecting the hiding rule of the access behavior.
- 4. The machine learning-based high-precision memory prediction and cache prefetching method according to claim 1, wherein the merging the feature value reflecting the memory behavior hiding rule with the identifier sequence corresponding to the current memory address, the current real memory address variation and the memory instruction to form a combined feature sequence includes: splicing the current memory address, the current real memory address variation, and the characteristic value which is formed by the first to-be-solved parameter value, the second to-be-solved parameter value and the internal variable variation statistical characteristic value and reflects the memory behavior hiding rule; and connecting the spliced features with the vector representation of the identifier corresponding to the current access instruction, and carrying out standardization processing on the connected results to form a combined feature sequence which is used as the input of the neural network model.
- 5. The machine learning based high precision memory access prediction and cache prefetch method of claim 1 wherein training the neural network model using a training approach focused on irregular change point prediction comprises: The method comprises the steps of obtaining a training data set, calculating and obtaining a historical real memory access variation serving as a training target based on a historical memory access sequence, identifying the historical real memory access variation, and marking a remarkable unconventional variation point; When the neural network model is trained, a weighted loss function is adopted to evaluate the future memory address change trend predicted by the neural network model and the error between the historical real memory address change quantity, wherein the weighted loss function is as follows: Wherein, the prediction error is the difference between the future memory address variation trend predicted by the neural network model and the historical real memory address variation, the importance coefficient allocated for the training sample is dynamically variable, when the historical real memory address variation corresponding to the training sample is not marked as a significant unconventional variation point, the importance coefficient is a basic value When the historical real memory access variation corresponding to the training sample is marked as a significant irregular variation point, the degree coefficient is valued The calculation formula is as follows: wherein, the method comprises the steps of, For training the historical real memory address variation corresponding to the sample, To train the absolute value of the historical real address change of the sample, Is a positive coefficient.
- 6. The machine learning-based high-precision access prediction and cache prefetching method according to claim 1 is characterized in that the trained neural network model is deployed in a selective framework comprising a plurality of prefetching mechanisms, the selective framework judges an access behavior mode according to a combined feature sequence extracted in real time, and the selective framework selectively enables the neural network model or a prefetcher based on fixed rules to generate a prefetch address, and the machine learning-based high-precision access prediction and cache prefetching method comprises the steps of deploying a selection unit based on judging logic, wherein the input of the selection unit is a feature value extracted in real time and reflecting the access behavior hiding rule, the selection unit evaluates the regularization degree of a current access behavior mode according to an internal variable variation statistical feature value contained in the feature value, enables the prefetcher based on fixed stride rule when the internal variable variation statistical feature value indicates that the access behavior mode is highly regularized, and enables the neural network model to predict when the internal variable variation statistical feature value indicates that the access behavior mode is irregular.
- 7. The machine learning-based high-precision memory access prediction and cache prefetching method according to claim 6, wherein the detecting of the change in the program execution stage based on the time sequence of the continuously extracted feature values reflecting the memory access behavior hiding rule includes maintaining a sliding window containing the feature values at M times in real time, calculating component parts of the feature values in the sliding window and forming a statistical vector, respectively, the component parts including the first to-be-found parameter value, the second to-be-found parameter value and the average value of the internal variable variation statistical feature values, comparing the statistical vector with a reference statistical vector, calculating an euclidean distance as a difference metric, determining that the change in the program execution stage is detected when the difference metric exceeds a dynamic threshold, calculating statistical distribution characteristics of the statistical vector sequence, and calculating statistical distribution characteristics of the statistical vector sequence based on the reference statistical vector and the statistical distribution characteristics of the statistical vector sequence, wherein the reference statistical vector is statistically determined by the feature values corresponding to the program execution stage before the change.
- 8. The machine learning based high precision memory prediction and cache prefetch method according to claim 1, wherein said adjusting the trained neural network model deployed in the selective architecture comprising a plurality of prefetch mechanisms using the memory address sequence and the identifier sequence corresponding to the memory instruction at the initial stage after the change comprises: a temporary storage area with fixed capacity is allocated for the detected changed program execution stage, and is used for storing N initial combined characteristic sequences and corresponding real memory access variation of the changed program execution stage; And freezing network layer parameters of a first preset proportion of the neural network model in a background processing core independent of the processor, and carrying out gradient updating on the rest network layers of the neural network model for a limited number of times by utilizing the data stored in the temporary storage area.
- 9. The machine learning-based high-precision memory prediction and cache prefetching method of claim 1 wherein said real-time monitoring of said memory prediction results and real-time monitored and recorded processor memory sequences during said operation optimizes a neural network model deployed in a selective architecture comprising a plurality of prefetch mechanisms based on monitored data, including continuously calculating differences between said memory prediction results and said real-time monitored and recorded processor memory sequences, storing said difference data in a long-term dataset, and when the amount of data in said long-term dataset reaches a preset threshold, updating parameters of said neural network model using data in said dataset.
- 10. The machine learning-based high-precision memory prediction and cache prefetching system for implementing the machine learning-based high-precision memory prediction and cache prefetching method according to any one of claims 1 to 9, characterized in that the system further comprises: The access monitoring and characteristic extracting module monitors and records an identifier sequence corresponding to an access address and an access instruction of the processor in real time, calculates the difference value of adjacent access addresses as a real access address variation, dynamically identifies and marks a remarkable irregular variation point in the address sequence, and extracts a characteristic value reflecting the access behavior hiding rule through online recursive estimation based on the numerical value of the remarkable irregular variation point; the combined characteristic construction module is used for combining the characteristic value reflecting the hiding rule of the access behavior with the identifier sequence corresponding to the current access address, the current real access address variation and the access instruction to form a combined characteristic sequence which is used as the input of the neural network model; The neural network prediction model module is used for training a neural network model by using a training mode focusing on unconventional change point prediction, and the neural network model is used for predicting future memory access change trend according to the combined feature sequence and outputting a corresponding memory access prediction result; The prefetching decision-making and executing module deploys the trained neural network model in a selective framework comprising a prefetching mechanism, wherein the selective framework judges a memory access behavior mode according to a combined feature sequence extracted in real time, and selects to enable the neural network model or a prefetcher based on fixed rules to generate a prefetching address; The model rapid self-adaptation module is used for adjusting the trained neural network model deployed in the selective framework comprising a plurality of prefetch mechanisms by utilizing the address sequence of the initial stage after the change and the identifier sequence corresponding to the access instruction when the change of the program execution stage is detected based on the time sequence formed by the continuously extracted characteristic values reflecting the access behavior hiding rule; And the model online optimization module is used for monitoring the memory access prediction result and the processor memory access sequence which is monitored and recorded in real time in the running process, and optimizing the neural network model which is deployed in the selective architecture comprising a plurality of prefetch mechanisms based on the monitoring data.
Description
High-precision access prediction and cache prefetching method and system based on machine learning Technical Field The invention relates to the technical field of cache prefetching optimization, in particular to a high-precision access prediction and cache prefetching method and system based on machine learning. Background In the technical field of memory access prediction and cache prefetching, in order to alleviate performance bottlenecks between a processor and a main memory, a prefetcher is generally adopted to predict addresses which a program may access in the future and load related data into a cache in advance, and in recent years, intelligent prediction methods based on machine learning are introduced into the field, aiming at improving the prediction capability of nonlinear and irregular memory access behaviors through learning complex modes in a historical memory access sequence, so as to optimize the cache hit rate. However, when the special and key access mode of irregular stride and complex index is faced, the limitation of the existing machine learning prediction method becomes particularly prominent, under the scene, the offset of the access address presents the characteristics of dynamic, non-fixed and surface unordered, so that the traditional prefetcher based on fixed stride is completely disabled, while the existing data driving learning method can fit the sequence presented by specific training data, but can not fundamentally understand the hidden mapping rule for driving the access mode, so that the model is seriously dependent on the specific circulation structure or data distribution during training, once the data distribution of the target program is finely adjusted or the execution stage is switched, the prediction accuracy of the model is obviously reduced, and the problems of weak generalization capability and lack of robustness become the main obstacle in actual deployment. Therefore, a novel cache prefetching method capable of deeply understanding the inherent mechanism of irregular memory access behaviors and keeping stable predictive performance when the running environment changes is needed in the current memory access prediction field, and the method is needed to be capable of identifying the surface mode and adaptively capturing and tracking the dynamic change rule behind the memory access behaviors so as to realize high-precision and high-reliability prefetching of irregular stride and complex index scenes. Disclosure of Invention In order to overcome the defects of weak generalization capability and insufficient robustness of the prefetcher, the invention provides a high-precision access prediction and cache prefetching method and system based on machine learning. The technical implementation scheme of the invention is that the high-precision access prediction and cache prefetching method based on machine learning comprises the following steps: S1, monitoring and recording an access address of a processor and an identifier sequence corresponding to an access instruction in real time, calculating the difference value of adjacent access addresses as real access address variation, dynamically identifying and marking obvious unconventional variation points in the address sequence, and extracting a characteristic value reflecting the access behavior hiding rule through online recursive estimation based on the numerical value of the obvious unconventional variation points; s2, combining the characteristic value reflecting the hiding rule of the memory behavior with an identifier sequence corresponding to the current memory address, the current real memory address variation and the memory instruction to form a combined characteristic sequence which is used as input of a neural network model; S3, training a neural network model by using a training mode focusing on unconventional change point prediction, wherein the neural network model is used for predicting future memory access change trend according to the combined feature sequence and outputting a corresponding memory access prediction result; S4, deploying the trained neural network model in a selective framework comprising a prefetching mechanism, judging a memory access behavior mode by the selective framework according to a combined feature sequence extracted in real time, and selecting to enable the neural network model or a prefetcher based on fixed rules to generate a prefetching address; S5, based on a time sequence formed by the continuously extracted characteristic values reflecting the access behavior hiding rule, when the change of the program execution stage is detected, the trained neural network model deployed in the selective architecture comprising a plurality of prefetching mechanisms is adjusted by using an access address sequence of an initial stage after the change and an identifier sequence corresponding to an access instruction; and S6, monitoring the memory access prediction result and the memory acces