Methods, apparatus, electronic devices and storage media for constructing power consumption prediction models
By constructing a power consumption prediction model, using a training program to record performance events and iteratively calculating to select target performance events, the problem of inaccurate processor power consumption acquisition in existing technologies is solved, and processor power consumption can be accurately reduced without adding hardware.
Patent Information
- Application Number
- CN202210111757.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-29
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2042-01-29
AI Technical Summary
In existing technologies, methods to reduce processor power consumption, such as reducing the clock frequency, can lead to an increase in the time it takes for the system to process tasks, which in turn increases the overall power consumption. How to obtain the processor's power consumption value in a timely and accurate manner has become an urgent problem to be solved.
By running the training program set, the count values and power consumption values of performance events are recorded. Target performance events and model parameters are selected through iterative calculations, and a power consumption prediction model is constructed. This model is then used to obtain power consumption values during processor operation.
It enables accurate and timely calculation of processor power consumption without adding hardware units, supports dynamic voltage and frequency adjustment, and reduces processor power consumption.
Smart Images

Figure CN114417733B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and in particular to a method for constructing a power consumption prediction model, an apparatus for constructing a power consumption prediction model, an electronic device, and a storage medium. Background Technology
[0002] Power consumption is one of the most important factors to consider in processor design today. While reducing clock frequency can lower processor power consumption, simply lowering the clock frequency does not truly reduce power consumption. This is because operating at low frequencies may increase the time the system spends processing tasks, thus increasing overall power consumption.
[0003] Dynamic Voltage and Frequency Scaling (DVFS) is a low-power technology that sets the operating voltage and clock frequency according to the actual power consumption of the chip. This ensures that the power provided meets the requirements without causing performance overkill, thereby reducing power consumption.
[0004] In order to reduce processor power consumption using DVFS technology, how to obtain the processor's power consumption value in a timely and accurate manner has become an urgent problem to be solved. Summary of the Invention
[0005] In view of the above problems, embodiments of the present invention are proposed to provide a method, electronic device, apparatus and storage medium for constructing a power consumption prediction model to overcome or at least partially solve the above problems, thereby reducing processor power consumption.
[0006] Accordingly, embodiments of the present invention also provide an apparatus for constructing a power consumption prediction model and a storage medium to ensure the implementation and application of the above method.
[0007] To address the above problems, this invention discloses a method for constructing a power consumption prediction model, the method comprising:
[0008] Run each training program in the training program set and record the running data of each training program. The running data includes the count value of each preset performance event when running each training program, the power consumption value of the processor when running each training program, and the running time of each training program.
[0009] Based on the running data of each training program and the preset model size n, iterative calculations are performed. When the iteration termination condition is reached, n target performance events selected from the preset performance events and the model parameters corresponding to the n target performance events are obtained.
[0010] A power consumption prediction model is constructed based on the n target performance events and the model parameters corresponding to the n target performance events.
[0011] This invention also discloses a method for predicting processor power consumption, the method comprising:
[0012] During processor operation, acquire the count value of each of the n target performance events;
[0013] The count value of each target performance event is input into the power consumption prediction model, and the power consumption value of the processor is output through the power consumption prediction model.
[0014] This invention also discloses an apparatus for constructing a power consumption prediction model, the apparatus comprising:
[0015] The running record module is used to run each training program in the training program set and record the running data of each training program. The running data includes the count value of each preset performance event when running each training program, the power consumption value of the processor when running each training program, and the running time of each training program.
[0016] The iterative calculation module is used to perform iterative calculations based on the running data of each training program and the preset model size n. When the iteration termination condition is reached, it obtains n target performance events selected from the preset performance events and the model parameters corresponding to the n target performance events.
[0017] The model building module is used to build a power consumption prediction model based on the n target performance events and the model parameters corresponding to the n target performance events.
[0018] This invention also discloses an apparatus for predicting processor power consumption, the apparatus comprising:
[0019] The counting acquisition module is used to acquire the count value of each of the n target performance events during processor operation.
[0020] The power consumption calculation module is used to input the count value of each target performance event into the power consumption prediction model, and output the power consumption value of the processor through the power consumption prediction model. The power consumption prediction model is pre-built according to any of the aforementioned methods for constructing a power consumption prediction model.
[0021] This invention also discloses a computing device, including: 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;
[0022] The memory is used to store at least one executable instruction that causes the processor to perform the steps of the method for constructing a power prediction model as described in any of the foregoing descriptions.
[0023] This invention also discloses a readable storage medium storing a program or instructions, which, when executed by a processor, can implement one or more of the methods for constructing power consumption prediction models described in this invention.
[0024] The method, apparatus, device, and storage medium for predicting processor power consumption provided in this invention have the following advantages:
[0025] This invention provides a method for constructing a power consumption prediction model. The power consumption prediction model estimates the processor's power consumption based on the count values of various target performance events during processor operation. The model parameters are obtained through offline training of the processor using a large number of training programs. The trained power consumption prediction model can calculate the processor's power consumption accurately and promptly without adding additional hardware units, thus reducing hardware costs. For any processor architecture, the power consumption prediction model provided by this invention can be constructed. After the model is built, during processor operation, the constructed power consumption prediction model can accurately and promptly calculate the processor's power consumption. Furthermore, DVFS processing can be performed based on the processor's calculated power consumption value to reduce processor power consumption. Attached Figure Description
[0026] Figure 1 This is a flowchart illustrating the steps of an embodiment of the method for constructing a power consumption prediction model according to the present invention;
[0027] Figure 2 This is a flowchart illustrating the steps of an embodiment of the method for predicting processor power consumption according to the present invention.
[0028] Figure 3 This is a structural block diagram of an embodiment of a device for constructing a power consumption prediction model according to the present invention;
[0029] Figure 4 This is a structural block diagram of an embodiment of a device for predicting processor power consumption according to the present invention;
[0030] Figure 5 This is a schematic diagram of the structure of the computing device provided by the present invention. Detailed Implementation
[0031] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0032] The terms "first," "second," etc., used in the specification and claims of this invention are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, the term "and / or" in the specification and claims is used to describe the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. In embodiments of this invention, the term "multiple" refers to two or more, and other quantifiers are similar.
[0033] Method Implementation Examples
[0034] Reference Figure 1 The diagram illustrates a flowchart of an embodiment of a method for constructing a power consumption prediction model according to the present invention. The method may specifically include the following steps:
[0035] Step 101: Run each training program in the training program set and record the running data of each training program. The running data includes the count value of each preset performance event when running each training program, the power consumption value of the processor when running each training program, and the running time of each training program.
[0036] Step 102: Perform iterative calculations based on the running data of each training program and the preset model size n. When the iteration termination condition is reached, obtain n target performance events selected from the preset performance events and the model parameters corresponding to the n target performance events.
[0037] Step 103: Construct a power consumption prediction model based on the n target performance events and the model parameters corresponding to the n target performance events.
[0038] This invention provides a method for constructing a power consumption prediction model. The power consumption prediction model can estimate the processor's power consumption based on the count values of various target performance events during processor operation. The model parameters of the power consumption prediction model are obtained through offline training of the processor using a large number of training programs. The trained power consumption prediction model can calculate the processor's power consumption accurately and promptly without adding additional hardware units, thus reducing hardware costs.
[0039] The performance event count refers to the number of times performance-related events occur, such as the number of operations and memory accesses. Predefined performance events refer to all performance-related events observable during processor operation. Most processors currently have performance event counting capabilities; therefore, this invention is applicable to any processor architecture. For any processor, a power prediction model can be constructed using the method provided by this invention. After the model is built, during processor operation, the counts of n target performance events are acquired. These counts are then input into the constructed power prediction model to output the processor's power consumption value. This value can then be used for Direct Value Filtering (DVFS) processing to reduce processor power consumption.
[0040] The target performance event is a performance event pre-selected from a preset performance event set through training. This target performance event can be used to predict the processor's power consumption. During processor operation, there is no need to deploy hardware units to read processor power consumption; simply obtaining the count value of the target performance event is sufficient to accurately predict the processor's power consumption, thus reducing hardware costs.
[0041] The training program set includes at least one training program. In this embodiment of the invention, by running the training program in the training program set, the model parameters of the target performance event and the power consumption prediction model are obtained, thereby constructing a power consumption prediction model. During processor operation, the count value of the target performance event is obtained and substituted into the constructed power consumption prediction model to calculate the predicted power consumption value of the processor.
[0042] The embodiments of the present invention do not limit the type of training program in the training program set. The training program may include a performance test benchmark program, or a user-developed test program for the processor module, such as a test program for the floating-point operation module.
[0043] Furthermore, to ensure the accuracy of the training results, the training programs in the training program set should utilize all components of the processor during operation.
[0044] Model size refers to the number of target performance events selected to construct the power consumption prediction model. In practice, the model size can be determined by considering both the ease of sampling and the accuracy of the model. For example, selecting a model size of 8 (8 target performance events) achieves a balance between the ease of sampling and the accuracy of the model. It is understood that this invention does not limit the specific value of the model size.
[0045] In this embodiment of the invention, each training program in the training program set is run sequentially, and the running data of each training program is read and recorded. The running data includes the count value of each preset performance event when running each training program, the power consumption value of the processor when running each training program, and the running time of each training program.
[0046] It should be noted that during the training phase, the count value of each preset performance event when running each training program can be obtained using pre-developed software for reading performance event counts. Similarly, the processor power consumption value when running each training program can be obtained using pre-developed software for reading processor power consumption. After the model parameters are trained and the power prediction model is obtained, the processor power consumption value can be predicted using this trained model, eliminating the need to deploy hardware units for reading processor power consumption. Accurate prediction of processor power consumption can be achieved solely through the count values of the target performance events, thus reducing hardware and software costs.
[0047] Based on the running data of each training program and the preset model size n, iterative calculations are performed. When the iteration termination condition is reached, n target performance events selected from the preset performance events and the model parameters corresponding to the n target performance events are obtained.
[0048] In an optional embodiment of the present invention, the model parameters may include: the weight corresponding to each of the selected n target performance events and the static power consumption weight per unit voltage; the step of constructing a power consumption prediction model based on the n target performance events and the model parameters corresponding to the n target performance events may include:
[0049] A power consumption prediction model is constructed based on the weight of each target performance event among the n target performance events, the static power consumption weight per unit voltage, the preset model size, the count value of each target performance event among the n target performance events, the power supply voltage of the processor, and the runtime of the processor.
[0050] The weights corresponding to each of the n target performance events and the static power consumption weight per unit voltage are model parameters of the power consumption prediction model, obtained by training the model using the training program in the training program set. The weights corresponding to each target performance event reflect the different degrees of influence of different target performance events on the processor's power consumption. The static power consumption weight per unit voltage represents the increment in static power consumption caused by each unit increase in voltage.
[0051] The preset model size is a preset value and can be set according to actual needs. The count value of each target performance event, the processor's power supply voltage, and the processor's runtime in the n target performance events are specific values read when predicting the processor's power consumption in actual applications.
[0052] Through the embodiments of the present invention, after training the model parameters of the power consumption prediction model, when predicting the power consumption value of the processor in practical applications, it is only necessary to obtain the count value of each target performance event in n target performance events during the processor's operation, the processor's power supply voltage, and the processor's runtime. The power consumption prediction model can be constructed based on the trained model parameters to calculate the processor's power consumption value without using additional hardware to read the processor's power consumption value. This can accurately predict the processor's power consumption value while reducing hardware costs and hardware size.
[0053] In an optional embodiment of the present invention, the power consumption prediction model can be expressed by the following formula:
[0054] (1)
[0055] Where E represents the processor's power consumption value output by the power prediction model, n represents the model size, V represents the processor's supply voltage, t represents the processor's runtime, and pmc i w represents the count value of the i-th target performance event among the n target performance events selected through training. i β and w are the model parameters obtained through training. i β represents the weight of the i-th target performance event, and β represents the static power consumption weight per unit voltage.
[0056] It should be noted that E represents the processor's power consumption value predicted by the power consumption prediction model. This predicted power consumption value represents the processor's total power consumption within a time window t. The time window t is also the processor's runtime. If t is sufficiently small, such as t being less than a preset threshold, the average power consumption within the time window t can be used as the predicted real-time power consumption of the processor.
[0057] In an optional embodiment of the present invention, the training program set includes m training programs, and the iterative calculation based on the running data of each training program and a preset model size n includes:
[0058] Step S11: Select n candidate performance events for this round;
[0059] Step S12: Generate training data, which includes a first vector and a second vector. The first vector includes the count values of the n candidate performance events corresponding to the m training programs and the runtime of each training program. The second vector includes the power consumption value of the processor during the runtime of each of the m training programs.
[0060] Step S13: Calculate the model evaluation score and model parameters corresponding to the n candidate performance events based on the training data;
[0061] Step S14: Compare the model evaluation score calculated in this round with that in the previous round, and keep the larger one.
[0062] The candidate performance event can be any performance event among the preset performance events. In this embodiment of the invention, the target performance event is determined from the candidate performance events. For example, assuming there are 20 preset performance events, each time 8 non-repeating candidate performance events are randomly selected from these 20 performance events for calculation. After multiple rounds of iterative calculation, the 8 candidate performance events selected in a certain round are determined as the target performance event.
[0063] The model evaluation score is used to evaluate the accuracy of the power prediction model, constructed using the model parameters corresponding to the selected n candidate performance events, in predicting the processor's power consumption. In one example, the n candidate performance events with the highest model evaluation scores can be identified as the target performance events.
[0064] In the process of iterative calculation based on the running data of each training program and the preset model size n, the embodiments of the present invention mainly use the following two algorithms: Algorithm 1 and Algorithm 2.
[0065] The input to Algorithm 1 includes the running data of all training programs and the required model size n. Algorithm 1 performs iterative calculations based on the received running data and the model size n. When the iteration termination condition is reached, it obtains n target performance events selected from the preset performance events and the model parameters corresponding to the n target performance events. The output of Algorithm 1 includes the identifiers of the n target performance events and the model parameters corresponding to the n target performance events.
[0066] Assuming there are N preset performance events, this embodiment of the invention uses Algorithm 1 to perform multiple rounds of iterative operations to select n target performance events from the N preset performance events and obtain the model parameters corresponding to these n target performance events, where N > n.
[0067] Algorithm 1 selects n candidate performance events for the current round based on the running data of all received training programs, generates training data, calculates the model evaluation score and model parameters corresponding to the n candidate performance events based on the training data, and compares the model evaluation score calculated in the current round with that in the previous round, retaining the larger one. Assume that after 100 rounds of iterative operations, n target performance events and their corresponding model parameters are calculated. The first iteration is called the current round of calculation. Similarly, the 50th iteration is called the current round of calculation, and the 49th iteration is called the previous round of calculation.
[0068] In this round, a pre-selected candidate performance event that has never been selected is randomly chosen to replace one of the n candidate performance events from the previous round, resulting in n candidate performance events for this round. This iterative process is repeated until the iteration termination condition is met, yielding n target performance events selected from the pre-selected performance events and the corresponding model parameters for these n target performance events. Based on these n target performance events and their corresponding model parameters, a power consumption prediction model can be constructed.
[0069] Optionally, Algorithm 1 can execute the steps of calculating the model evaluation scores and model parameters corresponding to the n candidate performance events by calling Algorithm 2.
[0070] The input to Algorithm 2 is the first vector and the second vector generated by Algorithm 1. The output of Algorithm 2 is the model evaluation score and model parameters corresponding to the n candidate performance events in this round, calculated based on the first vector and the second vector.
[0071] The first vector includes the count values of the m training programs corresponding to the n candidate performance events and the runtime of each training program. In this embodiment of the invention, the first vector can be an m*(n+1) two-dimensional vector, representing the count values of the m programs corresponding to the n performance events.
[0072] For example, let the first vector be denoted as result, which is represented as follows:
[0073]
[0074] The first vector, `result`, is an m*(n+1) two-dimensional vector. The first n columns represent the count values of the n performance events corresponding to the m training programs, and the (n+1)th column represents the runtime of the m training programs.
[0075] First row element: a 11 a 12 ... a 1nThese represent the counts of n performance events during the execution of the first training program, a and n respectively. 1,n+1 This indicates the runtime of the first training program.
[0076] Second row element: a 21 a 22 ... a 2n These represent the counts of n performance events during the execution of the second training program, a and n respectively. 2,n+1 This indicates the runtime of the second training program.
[0077] And so on, the element in the m-th row: a m1 a m2 ... a mn These represent the counts of n performance events during the execution of the m-th training program, a and n respectively. m,n+1 This represents the runtime of the m-th training program.
[0078] The second vector can be a 1*m one-dimensional vector, including the power consumption value of the processor when each of the m training programs is running.
[0079] For example, the second vector is denoted as energy, and this second vector energy is represented as follows:
[0080] [ ]
[0081] Among them, elements This represents the processor power consumption value during the first training program's runtime, element This represents the processor power consumption value during the execution of the second training program, and so on, element... This represents the processor power consumption value during the execution of the m-th training program.
[0082] In an optional embodiment of the present invention, the iteration termination condition may include:
[0083] The highest model evaluation score is obtained, or the number of iterations reaches the preset number.
[0084] In this embodiment of the invention, the model evaluation score and model parameters corresponding to the n candidate performance events selected in each round are calculated according to the above iterative calculation method.
[0085] In one example, assume n=8, and the initial model evaluation score is coef. In each round, select 8 candidate performance events and calculate the model evaluation score and model parameters corresponding to each of the 8 candidate performance events. Select the largest model evaluation score (e.g., coef_temp) from the model evaluation scores calculated in each round and compare it with coef. If coef_temp is greater than coef, then change coef to the value of coef_temp, and retain the n candidate performance events and corresponding model parameters corresponding to coef_temp. Repeat the above process until the calculated model evaluation score reaches a stable value, which can be considered as obtaining the highest calculated model evaluation score. At this point, the iteration termination condition can be considered reached, and the model evaluation scores and model parameters corresponding to the n target performance events are obtained. Here, model evaluation score stabilization means that the coef value calculated in s consecutive iterations remains unchanged, where s is a preset value.
[0086] Alternatively, when the number of iterations reaches the preset number, the iteration termination condition can be considered to have been met. The n candidate performance events selected in this round are taken as the target performance events, and the model parameters calculated in this round are taken as the final model parameters.
[0087] In an optional embodiment of the present invention, after recording the running data of each training program, the method may further include:
[0088] Filter out preset performance events with count values less than a first preset value; and / or
[0089] For each preset performance event, calculate the correlation coefficient between the count value of each training program corresponding to the preset performance event and the power consumption value of the processor when running each training program, and filter out preset performance events with a correlation coefficient less than the second preset value.
[0090] To improve the versatility and accuracy of the constructed power consumption prediction model, this embodiment of the invention filters all preset performance events in the processor before selecting candidate performance events, so as to obtain more effective candidate performance events.
[0091] This invention provides two methods for filtering preset performance events. Method one filters out preset performance events with count values less than a first preset value. To ensure the universality of the constructed power prediction model, candidate performance events participating in the construction of the power prediction model should not include random events. Preset performance events with count values less than the first preset value can be considered random events and filtered out. The first preset value can be set according to actual needs. Optionally, the first preset value can be set based on the number of clock cycles. For any preset performance event, multiply the count value of the preset performance event by 100,000 and then divide by the number of clock cycles. If the resulting value is greater than 1, the preset performance event is retained; otherwise, it is filtered out. For example, Method one can filter out preset performance events that occur at least once every 100,000 clock cycles on average.
[0092] Since processor power consumption originates from circuit activity, and circuit activity always results in positive power consumption overhead, the increase in performance event counts must contribute positively to processor power consumption. Therefore, to ensure the accuracy of the constructed power consumption prediction model, this embodiment of the invention uses Method Two to filter out preset performance events that are positively correlated with power consumption. Method Two involves calculating the correlation coefficient between the count value of each training program corresponding to the preset performance event and the processor power consumption value when running each training program, and filtering out preset performance counts with correlation coefficients less than a second preset value.
[0093] Optionally, the correlation coefficient can be the Pearson correlation coefficient. In statistics, the Pearson correlation coefficient, also known as the Pearson product-moment correlation coefficient (PPMCC or PCCs), is used to measure the correlation (linear correlation) between two variables X and Y, and its value is between -1 and 1.
[0094] The second preset value can be set according to actual needs. For example, if the second preset value can be set to 0.1, then preset performance events with a Pearson correlation coefficient less than 0.1 (including negative numbers) will be filtered out.
[0095] In one example, suppose there are 3 training programs. For a preset performance event A, the count values corresponding to the preset performance event A for these 3 training programs are [1, 2, 3]. The power consumption of the processor during the runtime of each of these 3 training programs is [2, 4, 6]. Calculate the Pearson correlation coefficient between [1, 2, 3] and [2, 4, 6]. If the Pearson correlation coefficient is 1, then the preset performance event A is retained.
[0096] In another example, suppose there are 4 training programs. For a preset performance event B, the count value corresponding to the preset performance event B for these 4 training programs is [1,2,1,2]. The power consumption of the processor during the runtime of each of these 4 training programs is [1,1,2,2]. Calculate the Pearson correlation coefficient between [1,2,1,2] and [1,1,2,2]. If the Pearson correlation coefficient is less than 0.1, then the preset performance event B is filtered out.
[0097] In an optional embodiment of the present invention, the method may further include:
[0098] Step S21: Calculate the correlation coefficient between the preset performance events;
[0099] Step S22: Cluster the preset performance events according to the correlation coefficient, and divide the preset performance events with a correlation coefficient greater than the third preset value into the same group to obtain at least one group;
[0100] The selection of n candidate performance events in this round includes:
[0101] Select n candidate performance events for this round from the at least one group.
[0102] Multicollinearity refers to the distortion or inaccuracy of model estimation caused by precise or high correlations between explanatory variables in a linear regression model. Furthermore, to eliminate multicollinearity in power consumption prediction models and improve model accuracy and stability, this embodiment of the invention, after filtering preset performance events, can perform hierarchical cluster analysis on the filtered preset performance events to calculate the correlation coefficients between them. Optionally, the correlation coefficient can be the Pearson correlation coefficient. Based on the Pearson correlation coefficient, the preset performance events are clustered, and preset performance events with Pearson correlation coefficients greater than a third preset value are grouped into the same group, resulting in at least one group. Thus, preset performance events with high correlation can be grouped into the same group.
[0103] It should be noted that since the n candidate performance events in each round are randomly selected, some or all of these n candidate performance events may belong to the same group.
[0104] The third preset value can be set according to actual needs. For example, the third preset value can be set to 0.75, that is, preset performance events with a Pearson correlation coefficient greater than 0.75 are clustered into the same group. The grouping information obtained after clustering can participate in the subsequent calculation of the model evaluation score to eliminate multicollinearity of the constructed power prediction model and improve the accuracy and stability of the model.
[0105] In an optional embodiment of the present invention, calculating the model evaluation score and model parameters corresponding to the n candidate performance events based on the training data includes:
[0106] Step S31: Perform linear regression on the training data using the least squares method to obtain the linear equation of the power consumption prediction model. The coefficients of the linear equation are the model parameters corresponding to the n candidate performance events.
[0107] Step S32: Count the number of negative values in the coefficients of the linear equation, and calculate the first reference score based on the number of negative values;
[0108] Step S33: Perform joint hypothesis testing on the training data and calculate the second reference score based on the test results;
[0109] Step S34: Count the number of related events belonging to the same group among the n candidate performance events, and calculate the third reference score based on the number of related events;
[0110] Step S35: Calculate the determination coefficient of the linear equation based on the observed values and predicted values of the linear equation. The observed values include the power consumption value of the processor recorded when running each training program, and the predicted values include the power consumption value of the processor when running each training program as predicted by the linear equation.
[0111] Step S36: Calculate the model evaluation score corresponding to the n candidate performance events based on the determination coefficient of the linear equation, the first reference score, the second reference score, and the third reference score.
[0112] In this embodiment of the invention, the least squares method (leastsq(result, energy)) is used to perform linear regression on the training data to obtain the linear equation of the power consumption prediction model. Here, energy (the second vector) is the dependent variable, and result (the first vector) is the independent variable. The coefficients of the linear equation are the model parameters corresponding to the n candidate performance events.
[0113] In this embodiment of the invention, the linear equation is scored from three aspects by calculating a first reference score, a second reference score, and a third reference score, thereby obtaining a model evaluation score.
[0114] The first aspect involves counting the number of negative values in the coefficients of the linear equation and calculating a first reference score (e.g., para_score) based on this number. The first aspect is scoring the linear equation based on whether its coefficients are negative; the more negative coefficients, the lower the score. This invention requires that all weights obtained by the least squares method be positive. For example, counting the number of negative values in all coefficients of the linear equation, deducting 1 point for each negative value.
[0115] Secondly, an F-test is performed on the training data, and a second reference score (denoted as Stat_score) is calculated based on the test results. The second aspect involves scoring the linear equation based on the results of the joint F-test; the lower the probability of multicollinearity among the n candidate performance events selected in this round, the higher the stat_score.
[0116] The F-test, also known as the joint hypothesis test, is a common method used in stepwise regression to detect multicollinearity. According to statistical experience, the p-value for each variable in the F-test should be less than 0.05, indicating a 95% reliability. The p-value represents the probability of observing at least the same extreme result as the actual observed sample when the null hypothesis is true. A small p-value indicates that the probability of observing extreme results under the null hypothesis is very small. In this embodiment of the invention, F-tests are performed on all training data, and cases where the p-value is less than 0.05 are recorded. For example, if the p-value is less than 0.05, it indicates that there is only a 5% probability of multicollinearity among the n candidate performance events selected in this round.
[0117] Thirdly, the number of related events belonging to the same group among the n candidate performance events is counted, and a third reference score (denoted as hca_score) is calculated based on the number of related events. The third aspect is to evaluate the hierarchical clustering of the n candidate performance events selected in this round. The more instances of selected candidate performance events appearing in the same group, the lower the hca_score. In this embodiment of the invention, during the calculation of the corresponding model evaluation score and model parameters for the n candidate performance events selected in this round, it detects whether there are candidate performance events from the same group among the n candidate performance events in this round. If there are candidate performance events from the same group, the third reference score is calculated based on the number of candidate performance events appearing in the same group. For example, suppose group 1 includes three preset performance events {a, b, c}, and the eight candidate performance events selected in this round include a, b, and c. Since a, b, and c belong to the same group, it means that only one of the three preset performance events a, b, and c is a valid preset performance event, and the model evaluation score for this round needs to be reduced by 2.
[0118] The coefficient of determination is a concept in statistics, expressed as R. 2 The higher the coefficient of determination, the better the linear equation fits the data.
[0119] In this embodiment of the invention, the determination coefficients of the linear equation are calculated based on the observed values and predicted values of the linear equation. The observed values include the power consumption values of the processor recorded when running each training program, and the predicted values include the power consumption values of the processor when running each training program as predicted by the linear equation.
[0120] Assuming the training program set includes m training programs, the observed values include the processor power consumption recorded during the runtime of each of the m training programs, denoted as energy[m]. The predicted values include the processor power consumption predicted by the linear equation for the runtime of each training program, denoted as energy_predict[m].
[0121] For example, the coefficient of determination R can be calculated using the following formula. 2 :
[0122] (2)
[0123] in, For the sum of squared residuals, For the total sum of squares, specifically:
[0124] ;
[0125] ;
[0126] The average() function is used to calculate the average value of an array.
[0127] e[m] is the residual between the observed value and the predicted value, where e[i] = energy[i] - energy_predict[i].
[0128] The model evaluation scores corresponding to the n candidate performance events can be calculated based on the determination coefficient of the linear equation, the first reference score, the second reference score, and the third reference score.
[0129] In an optional embodiment of the present invention, calculating the model evaluation score corresponding to the n candidate performance events based on the determination coefficient of the linear equation, the first reference score, the second reference score, and the third reference score may include:
[0130] The determination coefficients, the first reference score, the second reference score, and the third reference score of the linear equation are summed to obtain the model evaluation scores corresponding to the n candidate performance events.
[0131] In one example, the model evaluation score can be calculated using the following formula:
[0132] score = R 2 + para_score + stat_score + hca_score(3)
[0133] In addition to detecting multicollinearity, the explanatory power of linear regression is also considered when calculating the model evaluation score. Specifically, this embodiment of the invention uses the coefficient of determination R0. 2 The coefficient of determination (R²) is used as a measure of fitting accuracy. 2 In statistics, the coefficient of determination is used to measure the proportion of the variance in the dependent variable that can be explained by the independent variable, thereby judging the explanatory power of the regression model. The closer the value of the coefficient of determination is to 1, the stronger the explanatory power of the parameter for the power consumption result. In formula (3), the final model evaluation score consists of the coefficient of determination and three multicollinearity detection deductions. Since the value of the coefficient of determination is always less than 1, and the multicollinearity deduction is at least 1, there will be no situation where a variable with multicollinearity is incorrectly selected due to stronger explanatory power.
[0134] In this embodiment of the invention, the input to Algorithm 1 includes: the running data of m training programs and the model size n. The running data of the m training programs includes: the count values of all preset performance events recorded when running the m training programs, the processor power consumption value recorded when running each training program, and the runtime of each training program. The output of Algorithm 1 includes: the identifiers of the selected n target performance events and the model parameters (i.e., the coefficients of the linear equations) corresponding to these n target performance events.
[0135] In one example, the process of Algorithm 1 mainly includes the following two stages: the screening and hierarchical clustering analysis stage and the stepwise regression analysis stage.
[0136] The screening and hierarchical clustering analysis stage filters the input runtime data to remove preset performance events with count values less than a first preset value and preset performance counts with correlation coefficients less than a second preset value. Then, hierarchical clustering analysis is performed on the filtered preset performance events to calculate the correlation coefficients between them and record the grouping results.
[0137] The stepwise regression analysis phase is used to obtain the final output value through multiple rounds of iterative calculation. The stepwise regression analysis phase may include the following steps: Step A: Randomly select n candidate performance events from the pre-set performance events and initialize the model evaluation score, such as initializing the model evaluation score coef to -∞. Step B: Each time, randomly select one from the unselected pre-set performance events to replace one of the n candidate performance events, obtaining a new set of n candidate performance events. Calculate the model evaluation score coef_temp and the corresponding model parameters for the new n candidate performance events. Compare the largest coef_temp with coef. If the largest coef_temp is greater than coef, change coef to the value of the largest coef_temp, and retain the n candidate performance events and corresponding model parameters corresponding to the largest coef_temp. Step C: Repeat Step B until the calculated model evaluation score reaches a stable state, at which point the iteration terminates, yielding the n target performance events and model parameters, which is the final output value of Algorithm 1.
[0138] In this embodiment of the invention, the input to Algorithm 2 includes: a first vector and a second vector generated by Algorithm 1, and the grouping results of preset performance events. The first vector includes the count values of m training programs corresponding to n candidate performance events and the runtime of each training program. The second vector includes the power consumption value of the processor during the runtime of each of the m training programs. The output of Algorithm 2 includes: the model evaluation score (score) and model parameters (para) calculated based on the n candidate performance events selected in this round, wherein para includes w i and β.
[0139] In one example, the main steps of Algorithm 2 are as follows: using the first vector as the independent variable and the second vector as the dependent variable, perform least squares analysis to obtain the model parameters (coefficients of the linear equation) and the coefficient of determination R. 2 A linear equation for the power consumption prediction model is constructed. The number of negative values in the coefficients of the linear equation is counted to obtain the first reference score, para_score. Using the first vector as the independent variable and the second vector as the dependent variable, a joint hypothesis test is performed, and the number of occurrences of variables with p-values greater than 0.05 is counted to obtain the second reference score, stat_score. The number of candidate performance events appearing in different groups is counted to calculate the third reference score, hca_score. The model evaluation score for this round, coef=R, is then calculated. 2 +para_score+stat_score+hca_score. Outputs the model evaluation score (coef) and model parameters for this round.
[0140] In the process of executing the training set program, the above-mentioned Algorithm 1 and Algorithm 2 are used to select n target performance events required for the power consumption prediction model from the training set program, obtain the weight wi corresponding to each target performance event and the static power consumption weight β per unit voltage, and then substitute them into the above formula (1) to construct the power consumption prediction model for predicting the processor power consumption value.
[0141] In summary, this invention provides a method for constructing a power consumption prediction model. The power consumption prediction model can estimate the processor's power consumption based on the count values of various target performance events during processor operation. The model parameters of the power consumption prediction model are obtained through offline training of the processor using a large number of training programs. The trained power consumption prediction model can calculate the processor's power consumption accurately and promptly without adding additional hardware units, thus reducing hardware costs. For any processor architecture, a power consumption prediction model can be constructed using the method provided by this invention. After the model is constructed, during processor operation, the constructed power consumption prediction model can accurately and promptly calculate the processor's power consumption. Furthermore, DVFS processing can be performed based on the processor's calculated power consumption value to reduce processor power consumption.
[0142] Reference Figure 2 The diagram illustrates a step flowchart of an embodiment of a method for predicting processor power consumption according to the present invention. The method may specifically include the following steps:
[0143] Step 201: During processor operation, obtain the count value of each of the n target performance events;
[0144] Step 202: Input the count value of each target performance event into the power consumption prediction model, and output the power consumption value of the processor through the power consumption prediction model. The power consumption prediction model is pre-built according to the aforementioned method for constructing the power consumption prediction model.
[0145] The method for predicting processor power consumption provided by this invention is applicable to any processor architecture. For any processor, during the operation of the processor, the count values of n target performance events are obtained, and the count values of the n target performance events are input into the constructed power consumption prediction model to output the power consumption value of the processor.
[0146] The power consumption prediction model's parameters are obtained through offline training of the processor using a large number of training programs. Once trained, the power consumption prediction model can calculate the processor's power consumption in a timely and accurate manner without requiring additional hardware units, thus reducing hardware costs.
[0147] In an optional embodiment of the present invention, the method may further include:
[0148] Based on the power consumption value of the processor output by the power consumption prediction model, the processor's voltage and frequency are dynamically adjusted.
[0149] This allows for DVFS processing based on the processor's power consumption value output by the model, thereby reducing processor power consumption.
[0150] It should be noted that the embodiments of the present invention are applicable to multi-processor computing devices. Each processor has its own voltage domain and its own performance event counter. Therefore, the power consumption prediction model constructed using the present invention can calculate the power consumption value of each processor. By adding the power consumption values of each processor together, the power consumption value of the multiple processors of the computing device can be obtained.
[0151] This invention utilizes a pre-built power consumption prediction model to accurately and promptly calculate the processor's power consumption without requiring additional hardware units to measure it. This saves hardware costs while ensuring accurate power consumption calculation. Furthermore, the processor's power consumption calculated based on the power consumption prediction model can be processed using DVFS (Dynamic Value Filtering) to further reduce processor power consumption.
[0152] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0153] Device Examples
[0154] Reference Figure 3 The diagram illustrates a structural block diagram of an embodiment of a device for constructing a power consumption prediction model according to the present invention. The device may specifically include the following modules:
[0155] The running record module 301 is used to run each training program in the training program set and record the running data of each training program. The running data includes the count value of each preset performance event when running each training program, the power consumption value of the processor when running each training program, and the running time of each training program.
[0156] The iterative calculation module 302 is used to perform iterative calculations based on the running data of each training program and the preset model size n. When the iteration termination condition is reached, it obtains n target performance events selected from the preset performance events and the model parameters corresponding to the n target performance events.
[0157] The model building module 303 is used to build a power consumption prediction model based on the n target performance events and the model parameters corresponding to the n target performance events.
[0158] Optionally, the model parameters include: static power consumption weight per unit voltage and weight corresponding to each of the n target performance events; the model building module is specifically used to build a power consumption prediction model based on the weight corresponding to each of the n target performance events, the static power consumption weight per unit voltage, the preset model size, the count value of each target performance event in the n target performance events, the processor's power supply voltage, and the processor's runtime.
[0159] Optionally, the power consumption prediction model is:
[0160] ;
[0161] Where E represents the predicted processor power consumption, n represents the model size, V represents the processor's supply voltage, t represents the processor's runtime, and pmc i w represents the count value of the i-th target performance event out of n target performance events. i β and w are the model parameters obtained through training. i β represents the weight of the i-th target performance event, and β represents the static power consumption weight per unit voltage.
[0162] Optionally, the training program set includes m training programs, and the iterative calculation module includes:
[0163] The event selection submodule is used to select n candidate performance events for this round;
[0164] The data generation submodule is used to generate training data, which includes a first vector and a second vector. The first vector includes the count values of the n candidate performance events corresponding to the m training programs and the runtime of each training program. The second vector includes the power consumption value of the processor during the runtime of each of the m training programs.
[0165] The scoring calculation submodule is used to calculate the model evaluation score and model parameters corresponding to the n candidate performance events based on the training data.
[0166] The score comparison submodule is used to compare the model evaluation score calculated in this round with that in the previous round, and retain the larger one.
[0167] Optionally, the method further includes:
[0168] A coefficient calculation module is used to calculate the correlation coefficients between the preset performance events;
[0169] The event clustering module is used to cluster the preset performance events according to the correlation coefficient, and to divide the preset performance events with a correlation coefficient greater than a preset value into the same group to obtain at least one group;
[0170] The event selection submodule is specifically used to select n candidate performance events for the current round from the at least one group.
[0171] Optionally, the score calculation submodule includes:
[0172] The linear regression unit is used to perform linear regression on the training data using the least squares method to obtain the linear equation of the power consumption prediction model, wherein the coefficients of the linear equation are the model parameters corresponding to the n candidate performance events.
[0173] The first calculation unit is used to count the number of negative values in the coefficients of the linear equation and calculate a first reference score based on the number of negative values.
[0174] The second calculation unit is used to perform joint hypothesis testing on the training data and calculate a second reference score based on the test results.
[0175] The third calculation unit is used to count the number of related events belonging to the same group among the n candidate performance events, and calculate the third reference score based on the number of related events;
[0176] The fourth calculation unit is used to calculate the determination coefficient of the linear equation based on the observed values and predicted values of the linear equation, wherein the observed values include the power consumption value of the processor recorded when running each training program, and the predicted values include the power consumption value of the processor when running each training program as predicted by the linear equation.
[0177] The scoring unit is used to calculate the model evaluation score corresponding to the n candidate performance events based on the determination coefficient of the linear equation, the first reference score, the second reference score, and the third reference score.
[0178] Optionally, the scoring calculation unit is specifically used to sum the determination coefficient of the linear equation, the first reference score, the second reference score, and the third reference score to obtain the model evaluation score corresponding to the n candidate performance events.
[0179] Optionally, the device further includes:
[0180] The first filtering module is used to filter out preset performance events whose count value is less than the first preset value;
[0181] and / or
[0182] The second filtering module is used to calculate the correlation coefficient between the count value of each training program corresponding to each preset performance event and the power consumption value of the processor when running each training program, and filter out preset performance events with a correlation coefficient less than a second preset value.
[0183] Optionally, the iteration termination condition includes:
[0184] The highest model evaluation score is obtained, or the number of iterations reaches the preset number.
[0185] This invention provides a method for constructing a power consumption prediction model. The power consumption prediction model estimates the processor's power consumption based on the count values of various target performance events during processor operation. The model parameters are obtained through offline training of the processor using a large number of training programs. The trained power consumption prediction model can calculate the processor's power consumption accurately and promptly without adding additional hardware units, thus reducing hardware costs. For any processor architecture, the power consumption prediction model provided by this invention can be used to construct a power consumption prediction model. After the model is constructed, during processor operation, the constructed power consumption prediction model can accurately and promptly calculate the processor's power consumption. Furthermore, DVFS processing can be performed based on the processor's calculated power consumption value to reduce processor power consumption.
[0186] Reference Figure 4 The diagram illustrates a structural block diagram of an embodiment of a device for predicting processor power consumption according to the present invention. The device may specifically include the following modules:
[0187] The counting acquisition module 401 is used to acquire the count value of each of the n target performance events during processor operation.
[0188] The power consumption calculation module 402 is used to input the count value of each target performance event into the power consumption prediction model, and output the power consumption value of the processor through the power consumption prediction model. The power consumption prediction model is pre-built according to the aforementioned method for constructing the power consumption prediction model.
[0189] Optionally, the device may further include:
[0190] The frequency adjustment module is used to dynamically adjust the voltage and frequency of the processor based on the power consumption value of the processor output by the power consumption prediction model.
[0191] This invention utilizes a pre-built power consumption prediction model to accurately and promptly calculate the processor's power consumption without requiring additional hardware units to measure it. This saves hardware costs while ensuring accurate power consumption calculation. Furthermore, the processor's power consumption calculated based on the power consumption prediction model can be processed using DVFS (Dynamic Value Filtering) to further reduce processor power consumption.
[0192] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0193] Reference Figure 5 This is a schematic diagram of the structure of a computing device provided in an embodiment of the present invention. Figure 5 As shown, the computing device includes: a processor, a memory, a communication interface, and a communication bus. The processor, the memory, and the communication interface communicate with each other through the communication bus. The memory is used to store at least one executable instruction, which causes the processor to perform the steps of the memory access control method of the aforementioned embodiment.
[0194] This invention provides a non-transitory computer-readable storage medium. When the instructions in the storage medium are executed by a program or processor of a terminal, the terminal is able to execute a method for constructing a power consumption prediction model. The method includes: running each training program in a training program set and recording the running data of each training program, the running data including the count value of each preset performance event when running each training program, the power consumption value of the processor when running each training program, and the running duration of each training program; performing iterative calculations based on the running data of each training program and a preset model size n; obtaining n target performance events selected from the preset performance events and the model parameters corresponding to the n target performance events when the iteration termination condition is reached; and constructing a power consumption prediction model based on the n target performance events and the model parameters corresponding to the n target performance events.
[0195] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0196] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products 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.
[0197] Embodiments of the present invention are described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0198] These computer program instructions may also be stored in a computer-readable storage medium capable of directing a computer or other programmable data processing terminal device to operate in a predictive manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0199] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0200] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.
[0201] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0202] The present invention has provided a detailed description of a method and apparatus for predicting processor power consumption, a storage medium, and a storage medium. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for constructing a power consumption prediction model, characterized in that, The method includes: Run each training program in the training program set and record the running data of each training program. The running data includes the count value of each preset performance event when running each training program, the power consumption value of the processor when running each training program, and the running time of each training program. Based on the running data of each training program and the preset model size n, iterative calculations are performed. When the iteration termination condition is reached, n target performance events selected from the preset performance events and the model parameters corresponding to the n target performance events are obtained. Based on the n target performance events and the model parameters corresponding to the n target performance events, a power consumption prediction model is constructed; The training program set includes m training programs, and the iterative calculation based on the running data of each training program and the preset model size n includes: Select n candidate performance events for this round; Generate training data, which includes a first vector and a second vector. The first vector includes the count values of the n candidate performance events corresponding to the m training programs and the runtime of each training program. The second vector includes the power consumption value of the processor during the runtime of each of the m training programs. Based on the training data, calculate the model evaluation score and model parameters corresponding to the n candidate performance events; The model evaluation score calculated in this round is compared with that in the previous round, and the larger one is retained.
2. The method according to claim 1, characterized in that, The model parameters include: static power consumption weight per unit voltage and the weight corresponding to each of the n target performance events; the step of constructing a power consumption prediction model based on the n target performance events and the model parameters corresponding to the n target performance events includes: A power consumption prediction model is constructed based on the weight of each target performance event among the n target performance events, the static power consumption weight per unit voltage, the preset model size, the count value of each target performance event among the n target performance events, the power supply voltage of the processor, and the runtime of the processor.
3. The method according to claim 2, characterized in that, The power consumption prediction model is as follows: ; Where E represents the predicted processor power consumption, n represents the model size, V represents the processor's supply voltage, t represents the processor's runtime, and pmc i w represents the count value of the i-th target performance event out of n target performance events. i β and w are the model parameters obtained through training. i β represents the weight of the i-th target performance event, and β represents the static power consumption weight per unit voltage.
4. The method according to claim 1, characterized in that, The method further includes: Calculate the correlation coefficients between the preset performance events; Cluster the preset performance events based on the correlation coefficient, and group the preset performance events with a correlation coefficient greater than a preset value into the same group to obtain at least one group. The selection of n candidate performance events in this round includes: Select n candidate performance events for this round from the at least one group.
5. The method according to claim 4, characterized in that, The step of calculating the model evaluation score and model parameters corresponding to the n candidate performance events based on the training data includes: The training data is linearly regressed using the least squares method to obtain the linear equation of the power consumption prediction model. The coefficients of the linear equation are the model parameters corresponding to the n candidate performance events. Count the number of negative values in the coefficients of the linear equation, and calculate the first reference score based on the number of negative values; Perform joint hypothesis testing on the training data, and calculate the second reference score based on the test results; Count the number of related events belonging to the same group among the n candidate performance events, and calculate the third reference score based on the number of related events; The determination coefficients of the linear equation are calculated based on the observed and predicted values of the linear equation, wherein the observed values include the processor power consumption recorded when running each training program, and the predicted values include the processor power consumption predicted by the linear equation when running each training program. The model evaluation scores corresponding to the n candidate performance events are calculated based on the determination coefficient of the linear equation, the first reference score, the second reference score, and the third reference score.
6. The method according to claim 5, characterized in that, The step of calculating the model evaluation score corresponding to the n candidate performance events based on the determination coefficient of the linear equation, the first reference score, the second reference score, and the third reference score includes: The determination coefficients, the first reference score, the second reference score, and the third reference score of the linear equation are summed to obtain the model evaluation scores corresponding to the n candidate performance events.
7. The method according to any one of claims 1 to 6, characterized in that, After recording the runtime data for each training program, the method further includes: Filter out preset performance events with count values less than a first preset value; and / or For each preset performance event, calculate the correlation coefficient between the count value of each training program corresponding to the preset performance event and the power consumption value of the processor when running each training program, and filter out preset performance events with a correlation coefficient less than the second preset value.
8. The method according to any one of claims 1 to 6, characterized in that, The iteration termination conditions include: The highest model evaluation score is obtained, or the number of iterations reaches the preset number.
9. A method for predicting processor power consumption, characterized in that, The method includes: During processor operation, acquire the count value of each of the n target performance events; The count value of each target performance event is input into the power consumption prediction model, and the power consumption value of the processor is output through the power consumption prediction model. The power consumption prediction model is pre-built according to the method of constructing a power consumption prediction model according to any one of claims 1 to 8.
10. The method according to claim 9, characterized in that, The method further includes: Based on the power consumption value of the processor output by the power consumption prediction model, the processor's voltage and frequency are dynamically adjusted.
11. An apparatus for constructing a power consumption prediction model, characterized in that, The device includes: The running record module is used to run each training program in the training program set and record the running data of each training program. The running data includes the count value of each preset performance event when running each training program, the power consumption value of the processor when running each training program, and the running time of each training program. The iterative calculation module is used to perform iterative calculations based on the running data of each training program and the preset model size n. When the iteration termination condition is reached, it obtains n target performance events selected from the preset performance events and the model parameters corresponding to the n target performance events. The model building module is used to build a power consumption prediction model based on the n target performance events and the model parameters corresponding to the n target performance events; The training program set includes m training programs, and the iterative calculation module includes: The event selection submodule is used to select n candidate performance events for this round; The data generation submodule is used to generate training data, which includes a first vector and a second vector. The first vector includes the count values of the n candidate performance events corresponding to the m training programs and the runtime of each training program. The second vector includes the power consumption value of the processor during the runtime of each of the m training programs. The scoring calculation submodule is used to calculate the model evaluation score and model parameters corresponding to the n candidate performance events based on the training data. The score comparison submodule is used to compare the model evaluation score calculated in this round with that in the previous round, and retain the larger one.
12. The apparatus according to claim 11, characterized in that, The model parameters include: static power consumption weight per unit voltage and weight corresponding to each of the n target performance events; the model construction module is specifically used to construct a power consumption prediction model based on the weight corresponding to each of the n target performance events, the static power consumption weight per unit voltage, the preset model size, the count value of each target performance event in the n target performance events, the processor's power supply voltage, and the processor's runtime.
13. The apparatus according to claim 12, characterized in that, The power consumption prediction model is as follows: ; Where E represents the predicted processor power consumption, n represents the model size, V represents the processor's supply voltage, t represents the processor's runtime, and pmc i w represents the count value of the i-th target performance event out of n target performance events. i β and w are the model parameters obtained through training. i β represents the weight of the i-th target performance event, and β represents the static power consumption weight per unit voltage.
14. The apparatus according to claim 11, characterized in that, The device further includes: A coefficient calculation module is used to calculate the correlation coefficients between the preset performance events; The event clustering module is used to cluster the preset performance events according to the correlation coefficient, and to divide the preset performance events with a correlation coefficient greater than a preset value into the same group to obtain at least one group; The event selection submodule is specifically used to select n candidate performance events for the current round from the at least one group.
15. The apparatus according to claim 14, characterized in that, The score calculation submodule includes: The linear regression unit is used to perform linear regression on the training data using the least squares method to obtain the linear equation of the power consumption prediction model, wherein the coefficients of the linear equation are the model parameters corresponding to the n candidate performance events. The first calculation unit is used to count the number of negative values in the coefficients of the linear equation and calculate a first reference score based on the number of negative values. The second calculation unit is used to perform joint hypothesis testing on the training data and calculate a second reference score based on the test results. The third calculation unit is used to count the number of related events belonging to the same group among the n candidate performance events, and calculate the third reference score based on the number of related events; The fourth calculation unit is used to calculate the determination coefficient of the linear equation based on the observed values and predicted values of the linear equation, wherein the observed values include the power consumption value of the processor recorded when running each training program, and the predicted values include the power consumption value of the processor when running each training program as predicted by the linear equation. The scoring unit is used to calculate the model evaluation score corresponding to the n candidate performance events based on the determination coefficient of the linear equation, the first reference score, the second reference score, and the third reference score.
16. The apparatus according to claim 15, characterized in that, The scoring calculation unit is specifically used to sum the determination coefficient of the linear equation, the first reference score, the second reference score, and the third reference score to obtain the model evaluation score corresponding to the n candidate performance events.
17. The apparatus according to any one of claims 11 to 16, characterized in that, The device further includes: The first filtering module is used to filter out preset performance events whose count value is less than the first preset value; and / or The second filtering module is used to calculate the correlation coefficient between the count value of each training program corresponding to each preset performance event and the power consumption value of the processor when running each training program, and filter out preset performance events with a correlation coefficient less than a second preset value.
18. The apparatus according to any one of claims 11 to 16, characterized in that, The iteration termination conditions include: The highest model evaluation score is obtained, or the number of iterations reaches the preset number.
19. A device for predicting processor power consumption, characterized in that, The device includes: The counting acquisition module is used to acquire the count value of each of the n target performance events during processor operation. A power consumption calculation module is used to input the count value of each target performance event into a power consumption prediction model, and output the power consumption value of the processor through the power consumption prediction model. The power consumption prediction model is pre-built according to the method of constructing a power consumption prediction model according to any one of claims 1 to 8.
20. The apparatus according to claim 19, characterized in that, The device further includes: The frequency adjustment module is used to dynamically adjust the voltage and frequency of the processor based on the power consumption value of the processor output by the power consumption prediction model.
21. A computing device, characterized in that, include: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction that causes the processor to perform the steps of the method for constructing a power prediction model as claimed in any one of claims 1 to 8.
22. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the method for constructing a power consumption prediction model as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Many-core chip power consumption estimation method, device, equipment and readable storage medium
CN111694714A