CPU frequency modulation method and device, equipment and medium

By obtaining the performance characteristic values ​​and demand values ​​of the instruction granularity and predicting the CPU frequency range, the problem of inaccurate CPU frequency adjustment in the prior art is solved, and accurate computing power supply and power consumption savings are achieved for various application loads.

CN118915897APending Publication Date: 2024-11-08GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD +1
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410957100.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-16
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

The prior art fails to fully consider the nonlinear relationship between CPU performance and frequency caused by memory access characteristics and load characteristics when adjusting the CPU frequency, resulting in inaccurate frequency adjustment.

Method used

By obtaining the performance characteristic values ​​and performance requirements of the instruction granularity, predict the CPU frequency range, and adjust the CPU frequency based on this range to ensure the accuracy and adaptability of frequency adjustment.

Benefits of technology

Accurate adjustment of CPU frequency based on performance values ​​of smaller granularity is achieved, suitable for various application load types, saving power consumption while meeting performance requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118915897A_ABST
    Figure CN118915897A_ABST
Patent Text Reader

Abstract

The invention discloses a CPU frequency modulation method and device, equipment and a medium, and relates to the technical field of computers. The method comprises the steps of obtaining a performance characteristic value of a previous period, wherein the performance characteristic value is used for representing a performance characteristic of instruction granularity; predicting a performance demand value in a later period, wherein the performance demand value is used for indicating the performance demand of the instruction granularity; determining a predicted frequency range of the later period based on the performance characteristic value of the previous period and the performance demand value of the later period; and based on the predicted frequency range, adjusting the CPU frequency in the later period. According to the method, the CPU frequency range is predicted based on the performance value with the small granularity, and the CPU frequency can be adjusted more accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a CPU frequency modulation method, device, equipment and medium. Background Art

[0002] The clock frequency of the central processing unit (CPU) determines the operating speed of the CPU and is an important indicator that affects the CPU performance. Generally speaking, the higher the CPU clock frequency, the faster the CPU runs and the better the CPU performance.

[0003] In the related art, a mobile device can adjust the CPU operating frequency according to the CPU load so that the adjusted operating frequency can meet the CPU load requirement. The CPU operating frequency is lower than or equal to the CPU clock frequency, hereinafter referred to as CPU frequency.

[0004] However, the above method only considers the linear relationship between CPU performance and CPU frequency, and does not consider the nonlinear relationship between CPU performance and CPU frequency due to memory access characteristics and load characteristics, which may cause the adjusted CPU frequency to be inaccurate. Summary of the invention

[0005] The present application provides a CPU frequency modulation method, device, equipment and medium. The technical solution is as follows:

[0006] According to one aspect of the present application, a CPU frequency modulation method is provided, the method being executed by a computer device, the method comprising:

[0007] Acquire a performance characteristic value of a previous cycle, wherein the performance characteristic value is used to characterize a performance characteristic of an instruction granularity;

[0008] Predicting a performance requirement value in a later cycle, wherein the performance requirement value is used to indicate a performance requirement of an instruction granularity;

[0009] Determining a predicted frequency range of the subsequent cycle based on the performance characteristic value of the previous cycle and the performance requirement value of the subsequent cycle;

[0010] Based on the predicted frequency range, the CPU frequency in the subsequent cycle is adjusted.

[0011] According to another aspect of the present application, a CPU frequency modulation device is provided, the device comprising:

[0012] An acquisition module, used for acquiring a performance characteristic value of a previous cycle, wherein the performance characteristic value is used for characterizing a performance characteristic of an instruction granularity;

[0013] A prediction module, used to predict a performance requirement value in a later cycle, wherein the performance requirement value is used to indicate a performance requirement of an instruction granularity;

[0014] A determination module, configured to determine a predicted frequency range of the subsequent cycle based on the performance characteristic value of the previous cycle and the performance requirement value of the subsequent cycle;

[0015] An adjustment module is used to adjust the CPU frequency in the subsequent cycle based on the predicted frequency range.

[0016] According to another aspect of the present application, a computer device is provided, comprising: a processor and a memory, wherein at least one program is stored in the memory, and the at least one program is loaded and executed by the processor to implement the CPU frequency modulation method as described above.

[0017] According to another aspect of the present application, a computer-readable storage medium is provided, in which at least one program is stored. The at least one program is loaded and executed by a processor to implement the CPU frequency modulation method as described above.

[0018] According to another aspect of the present application, a computer program product is provided, which includes at least one program segment, and the at least one program segment is stored in a computer-readable storage medium; a processor of a computer device reads the at least one program segment from the computer-readable storage medium, and the processor executes the at least one program segment, so that the computer device executes the CPU frequency modulation method described above.

[0019] The beneficial effects of the technical solution provided by this application include at least:

[0020] By obtaining the performance characteristic value of the instruction granularity and predicting the performance requirement value of the instruction granularity, it is possible to predict the CPU frequency range based on the performance value of a smaller granularity, so as to adjust the CPU frequency more accurately based on the CPU frequency range. In addition, since the performance characteristic value and the performance requirement value are both at the instruction granularity, this method can be applied to various application load types, and can provide accurate computing power for various application load types, saving power while meeting performance requirements. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0022] Figure 1 is a schematic diagram of a computer system provided by an exemplary embodiment of the present application;

[0023] Figure 2 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0024] Figure 3 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0025] Figure 4 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0026] Figure 5 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0027] Figure 6 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0028] Figure 7 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0029] Figure 8 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0030] Fig. 9 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0031] Fig.10 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0032] Fig.11 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0033] Fig.12 is a schematic diagram of a hardware register provided by an exemplary embodiment of the present application;

[0034] Fig.13 is a schematic diagram of a hardware register provided by an exemplary embodiment of the present application;

[0035] Fig.14 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0036] Fig.15 is a schematic diagram of a hardware register provided by an exemplary embodiment of the present application;

[0037] Fig.16 is a schematic diagram of a hardware register provided by an exemplary embodiment of the present application;

[0038] Fig.17 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0039] Fig.18 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0040] Fig.19 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0041] Fig. 20 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0042] Fig.21 is a schematic diagram of a three-dimensional mapping table provided by an exemplary embodiment of the present application;

[0043] Fig. 22 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0044] Fig.23 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0045] Fig.24 is a flow chart of a CPU frequency modulation method provided by an exemplary embodiment of the present application;

[0046] Fig.25 is a block diagram of a CPU frequency modulation device provided by an exemplary embodiment of the present application;

[0047] Fig.26 is a block diagram of a computer device provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0048] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0049] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0050] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0051] It should be understood that, although the terms first, second, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first parameter may also be referred to as the second parameter, and similarly, the second parameter may also be referred to as the first parameter. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0052] First, the nouns involved in the embodiments of the present application are briefly introduced:

[0053] CPU: refers to the execution unit that processes information and runs programs.

[0054] CPU frequency: includes clock frequency and operating frequency. The clock frequency of the CPU determines the operating speed of the CPU and is an important indicator that affects the performance of the CPU. Generally speaking, the higher the clock frequency of the CPU, the faster the CPU runs and the better the CPU performance. The operating frequency of the CPU refers to the frequency when information processing and running programs are performed. The operating frequency of the CPU is lower than or equal to the clock frequency of the CPU. The embodiments of the present application specifically focus on the adjustment of the operating frequency of the CPU.

[0055] CPU frequency regulator: also known as CPU frequency regulator. It is a kernel module in the CPU that is used to obtain CPU information and dynamically adjust the CPU frequency according to the CPU load.

[0056] Performance Monitoring Unit (PMU): refers to the unit in the CPU used to count specific hardware events that occur in the system.

[0057] Activity Monitor Unit (AMU): refers to the performance counters in the CPU used for system management.

[0058] In the related art, the CPU frequency regulator (cpufreq governor) of the operating system of the mobile device assumes that the CPU performance and CPU frequency have a simple linear relationship. The performance demand value of the CPU is equal to the product of frequency and time, that is, performance demand value = frequency (cpufreq) * time (time), which can also be called the performance demand value based on cycles (cycles demand).

[0059] In addition, when adjusting the CPU frequency, the CPU frequency regulator tracks each CPU load (util) and gives a corresponding CPU frequency to each CPU load, giving each CPU load enough CPU frequency according to the different situations corresponding to different CPU loads. However, for different application load types, due to the differences in the CPU memory hierarchy and the different memory access characteristics of different loads, the CPU performance will also change with the change of CPU frequency.

[0060] For example, the following Figure 1 As shown in the figure, under the same CPU, the relationship between the number of instructions per second (IPS) and the frequency corresponding to different loads is different. For example, the IPS corresponding to load 1 is proportional to the frequency; while the IPS corresponding to load 3 is nonlinearly related to the frequency, and the effect of frequency increase on IPS is getting smaller and smaller. In other words, in the process of adjusting the CPU frequency, if only the CPU frequency and CPU performance are considered to be linearly related, and other factors (such as memory access characteristics) are ignored, the adjusted CPU frequency may be too high.

[0061] Based on the above considerations, an embodiment of the present application proposes a CPU frequency adjustment method, which adjusts the CPU frequency by using a performance characteristic value and a performance requirement value based on instruction granularity.

[0062] Figure 2 is a schematic diagram of a CPU frequency modulation method provided by an exemplary embodiment of the present application. The method is executed by a computer device, and the method includes:

[0063] Step 220: Obtain the performance characteristic value of the previous cycle, where the performance characteristic value is used to characterize the performance characteristic of the instruction granularity;

[0064] In some embodiments, the performance characteristic value includes a load characteristic value (base_CPI) and / or a memory access characteristic value (stall_SPI). The load characteristic value (base_CPI) is used to indicate the number of cycles consumed by each instruction that is not related to the front-end memory access and the back-end memory access in the CPU pipeline, and the memory access characteristic value (stall_SPI) is used to indicate the access consumption time caused by each instruction accessing the storage. Accessing the storage refers to the CPU accessing external storage such as cache or memory.

[0065] In some embodiments, instruction granularity refers to the degree of refinement of analyzing performance characteristics in units of instructions, such as calculating the number of cycles consumed by each instruction that is not related to front-end memory access and back-end memory access in the CPU pipeline in units of instructions, or calculating the access time consumed by each instruction due to accessing storage in units of instructions.

[0066] In some embodiments, the performance characteristics of instruction granularity can be understood as characteristics that measure CPU performance based on instructions, or characteristics that evaluate CPU performance based on a single instruction or each instruction as a measurement dimension.

[0067] In some embodiments, the performance characteristic value of each period is obtained in units of period.

[0068] In some embodiments, the computer device includes a hardware register for storing performance characteristic values, and the performance characteristic value of each cycle is directly obtained based on the hardware register.

[0069] In some embodiments, if the computer device does not include a hardware register for storing performance characteristic values, the performance characteristic value of each cycle is calculated by acquiring monitoring data of a performance monitoring hardware unit.

[0070] In some embodiments, the performance monitoring hardware unit includes at least one of a PMU and an AMU.

[0071] Step 240: predicting a performance requirement value in a later cycle, where the performance requirement value is used to indicate the performance requirement of the instruction granularity;

[0072] In some embodiments, the performance requirement value in the later cycle is directly equal to the performance requirement value in the previous cycle.

[0073] In some embodiments, considering that the load on the mobile device changes rapidly, the performance requirement value in the subsequent cycle can be predicted using a window sliding method. The performance requirement value in the subsequent cycle is equal to the sliding average of the performance requirement value in the previous cycle and the performance requirement value of at least one historical cycle.

[0074] Step 260: Determine a predicted frequency range in the subsequent cycle based on the performance characteristic value in the previous cycle and the performance requirement value in the subsequent cycle;

[0075] In some embodiments, there is a preset corresponding relationship between the performance characteristic value, the performance requirement value and the CPU frequency. Based on the preset corresponding relationship, as well as the performance characteristic value in the previous cycle and the performance requirement value in the next cycle, the minimum CPU frequency and the maximum CPU frequency are determined. That is, the predicted frequency range determined in the next cycle has both a minimum value restriction and a maximum value restriction. While meeting the minimum CPU performance requirements, CPU power consumption is also saved.

[0076] In some embodiments, the predicted frequency range in the later cycle is the adjustment range of the CPU frequency in the later cycle. That is, the CPU frequency in the later cycle is a target value determined between the above-mentioned minimum CPU frequency and maximum CPU frequency. When the minimum CPU frequency and the maximum CPU frequency are equal, a determined target value is given.

[0077] In some embodiments, the minimum CPU frequency is determined based on a preset correspondence between the performance characteristic value, the performance requirement value, and the CPU frequency. The maximum CPU frequency is not limited. That is, the predicted frequency range determined in the subsequent cycle has only a minimum value limit, but no maximum value limit. While meeting the minimum CPU performance requirements, there is no limit on the CPU power consumption.

[0078] Step 280: Based on the predicted frequency range, adjust the CPU frequency in the subsequent cycle.

[0079] In some embodiments, the CPU frequency in the later cycle is adjusted by the CPU frequency regulator based on the predicted frequency range.

[0080] In some embodiments, the predicted frequency range is used to set the working parameters of the CPU frequency regulator. After the CPU frequency regulator is set, the CPU frequency in the subsequent cycle is adjusted by the set CPU frequency regulator.

[0081] In some embodiments, the CPU frequency governor (cpufreq governor) includes but is not limited to at least one of the following: a high-performance mode frequency governor, a power saving mode frequency governor, a conservative mode frequency governor, an on-demand mode frequency governor, an interactive mode frequency governor, a user mode frequency governor, a default CPU frequency governor based on a physical load tracking algorithm, and a load tracking frequency governor, etc.

[0082] In summary, the method provided in this embodiment can predict the CPU frequency range based on the performance value of a smaller granularity by obtaining the performance characteristic value of the instruction granularity and predicting the performance requirement value of the instruction granularity, so as to adjust the CPU frequency more accurately. In addition, since the performance characteristic value and the performance requirement value are both at the instruction granularity, this method can be applied to various application load types, and can provide accurate computing power for various application load types, thereby saving power while meeting performance requirements.

[0083] It should be understood that this is different from the method in the related art that uses CPU load as a measurement dimension to evaluate CPU performance. Since each CPU load usually involves tens of thousands of instructions, the related art considers a coarser granularity when adjusting the CPU frequency. In the embodiment of the present application, by obtaining the performance characteristics of the instruction granularity, it is possible to consider a finer granularity when adjusting the CPU frequency. Based on this, the method provided in the embodiment of the present application can be referenced and adjusted from a more precise instruction-level quantity unit, and can achieve more accurate adjustment of the CPU frequency compared to the method in the related art that uses CPU load as a measurement dimension to evaluate CPU performance.

[0084] In some embodiments, the above steps 220 to 280 are executed in a loop. Figure 3 As shown, the above method includes the following stages:

[0085] Phase 1: Data sampling phase; including obtaining the performance characteristic values ​​of the current cycle;

[0086] Phase 2: Predicting performance requirement values; specifically, predicting the performance requirement values ​​for the next cycle.

[0087] Stage 3: Determine the predicted frequency range; specifically, the predicted frequency range is the frequency range of the next cycle.

[0088] Phase 4: CPU frequency adjustment phase: Specifically, the frequency of the next cycle is adjusted based on the above predicted frequency range.

[0089] Repeat the above stages 1-4 in cycles.

[0090] In some embodiments, the CPU is frequency-controlled in clusters. Figure 4 As shown, assume that there are 7 CPUs in total, of which CPU0-CPU2 correspond to cluster 0, CPU3-CPU6 correspond to cluster 1, and CPU7 corresponds to cluster 3. Then repeat the above stages 1-4 for cluster 0, cluster 1, and cluster 2 respectively.

[0091] For phase 1, the performance characteristic values ​​in the previous cycle are obtained based on the following two methods:

[0092] Acquisition method 1: Calculated based on monitoring data of performance monitoring hardware unit;

[0093] Acquisition method 2: Acquisition based on monitoring event registers in the CPU pipeline.

[0094] For acquisition method 1:

[0095] In some embodiments, the performance characteristic value of the previous cycle is calculated based on the monitoring data of the performance monitoring hardware unit of the previous cycle. Figure 5 As shown, the above step 220 can also be replaced by the following sub-steps:

[0096] Step 221: Acquire monitoring data of the performance monitoring hardware unit in the previous cycle;

[0097] In some embodiments, the performance monitoring hardware unit includes at least one register for monitoring CPU performance. Optionally, the performance monitoring hardware unit includes a memory access characteristic value (stall_SPI) register and / or a load characteristic value (base_CPI) register. Among them, the memory access characteristic value (stall_SPI) register is used to store the memory access characteristic value (stall_SPI), and the load characteristic value (base_CPI) register is used to store the load characteristic value (base_CPI).

[0098] In some embodiments, the monitoring data of the performance monitoring hardware unit includes at least the number of cycles, the number of instructions executed in the current cycle, the number of refills of caches at all levels in the current cycle, and the CPU running time (cpu_running_time). Among them, the cycles and the number of instructions executed in the current cycle can be obtained from the AMU, and the number of refills of caches at all levels in the current cycle can be obtained from the PMU. Exemplarily, the number of refills of caches at all levels in the current cycle includes at least one of the number of refills of the third-level cache in the current cycle (L3 Cache Refill), the number of refills of the second-level cache in the current cycle (L2 Cache Refill), and the number of refills of the second-level cache in the current cycle (L2d TLBRefill).

[0099] Step 222: Based on the monitoring data, calculate the performance characteristic value of the previous cycle, and the performance characteristic value is used to characterize the factors that affect the number of instructions per second or the time required for each instruction.

[0100] In some embodiments, the performance characteristic value includes a memory access characteristic value (stall_SPI) and / or a load characteristic value (base_CPI). The memory access characteristic value (stall_SPI) is used to indicate the access consumption time caused by each instruction accessing the storage. The load characteristic value (base_CPI) is used to indicate the number of cycles consumed by each instruction that is not related to the front-end memory access and the back-end memory access in the CPU pipeline.

[0101] By acquiring the monitoring data of the performance monitoring hardware unit, the performance characteristic value is calculated so that the performance characteristic value can be used to characterize the real-time performance status of the instruction granularity, so that a more accurate prediction result can be obtained when predicting the frequency range in the subsequent cycle based on the performance characteristic value.

[0102] For the memory access characteristic value (stall_SPI):

[0103] In some embodiments, the manners of calculating the memory access characteristic value based on the monitoring data of the performance monitoring hardware unit include the following two methods:

[0104] Calculation method 1: calculated based on the number of refreshes per instruction of at least two levels of cache in the previous cycle in the monitoring data;

[0105] Calculation method 2: Calculated based on at least two operating frequencies of the CPU in the previous cycle in the monitoring data and the running time and the number of executed instructions at at least two operating frequencies.

[0106] For calculation method 1:

[0107] In some embodiments, the memory access characteristic value (stall_SPI) is equal to the weighted sum of the number of refills per instruction of at least two levels of cache in the previous cycle.

[0108] In some embodiments, the monitoring data includes the number of refreshes of at least two levels of cache per instruction in the previous cycle. The performance characteristic value includes a memory access characteristic value (stall_SPI), which is used to indicate the access consumption time caused by each instruction accessing the storage. Figure 6 As shown, the above step 222 can also be replaced by the following sub-steps:

[0109] Step 2221: Using the fitting parameters corresponding to at least two levels of cache as weights, calculate the weighted sum of the number of refills per instruction of at least two levels of cache in the previous cycle, and use the weighted sum as the memory access feature value.

[0110] Exemplarily, the calculation formula of the memory access characteristic value (stall_SPI) is as follows:

[0111]

[0112] Among them, stall_SPI represents the memory access characteristic value, α i represents the fitting parameters corresponding to the i-th level cache, PMU i It indicates the number of times the i-th level cache is refilled in the current cycle, and Instruction indicates the number of instructions executed in the current cycle.

[0113] Specifically, the number of refills of at least two levels of cache in the current cycle includes the number of refills of the third level cache in the current cycle (L3 Cache Refill), the number of refills of the second level cache in the current cycle (L2 Cache Refill), and the number of refills of the second level cache in the current cycle (L2d TLB Refill). The memory access characteristic value (stall_SPI) can also be calculated according to the following formula:

[0114] stall_SPI=para1*L3_MPI+para2*L2_MPI–para3*L3_MPI*L2_TLB_MPI

[0115] Among them, stall_SPI represents the memory access characteristic value, para1 represents the fitting parameter corresponding to the third-level cache, and L3_MPI represents the number of times the third-level cache is refilled per instruction in the current cycle. para2 represents the fitting parameters corresponding to the L2 cache, L2_MPI represents the number of times the L2 cache is refilled per instruction in the current cycle, para3 indicates the fitting parameters corresponding to the L2 cache, L2_TLB_MPI indicates the number of refills per instruction of the L2 cache in the current cycle,

[0116] In some embodiments, different CPU architectures correspond to different fitting parameters. That is, under different CPU architectures, the above α i Different. Under different CPU architectures, the above para1, para2 and para3 are also different.

[0117] By calculating the weighted sum of the number of refills per instruction in at least two levels of cache in the previous cycle, the consumption caused by refilling per instruction can be characterized by a memory access feature value. That is, the memory access feature value can directly characterize the time consumption caused by accessing storage per instruction.

[0118] For calculation method 2:

[0119] In some embodiments, the monitoring data includes at least two operating frequencies of the CPU in the previous cycle and the running time and number of instructions executed at the at least two operating frequencies. The performance characteristic value includes a memory access characteristic value (stall_SPI), and the memory access characteristic value (stall_SPI) is used to indicate the access consumption time caused by each instruction accessing the storage. Figure 7 As shown, the above step 222 can also be replaced by the following sub-steps:

[0120] Step 2222: Based on the running time and the number of executed instructions at the first operating frequency, calculate a first SPI of the CPU load of the current cycle at the first operating frequency, and calculate a first product of the first SPI and the first operating frequency;

[0121] In some embodiments, a first SPI of the CPU load of the current cycle at the first operating frequency is equal to a first ratio of the running time and the number of executed instructions at the first operating frequency.

[0122] Exemplarily, the calculation formula of the first SPI is as follows:

[0123]

[0124] SPI1 represents the first SPI, cpu_running_time1 represents the running time at the first operating frequency, and Instructions1 represents the number of executed instructions at the first operating frequency.

[0125] Exemplarily, the first product=SPI1*Freq1, wherein SPI1 represents the first SPI, and Freq1 represents the first operating frequency.

[0126] Step 2223: Based on the running time and the number of executed instructions at the second operating frequency, calculate the second SPI of the CPU load of the current cycle at the second operating frequency, and calculate a first product of the second SPI and the second operating frequency;

[0127] In some embodiments, a second SPI of the CPU load of the current cycle at the second operating frequency is equal to a second ratio of the running time and the number of executed instructions at the second operating frequency.

[0128] Exemplarily, the calculation formula of the second SPI is as follows:

[0129]

[0130] SPI2 represents the second SPI, cpu_running_time2 represents the running time at the second operating frequency, and Instructions2 represents the number of executed instructions at the second operating frequency.

[0131] Exemplarily, the second product=SPI2*Freq2, wherein SPI2 represents the second SPI, and Freq2 represents the second operating frequency.

[0132] Step 2224: Calculate a first difference between the first product and the second product, and calculate a second difference between the first operating frequency and the second operating frequency;

[0133] Exemplarily, the first difference=first product-second product=SPI1*Freq1-SPI2*Freq2, wherein SPI1 represents the first SPI, Freq1 represents the first operating frequency, SPI2 represents the second SPI, and Freq2 represents the second operating frequency.

[0134] Exemplarily, the second difference=first operating frequency-second operating frequency=Freq1-Freq2.

[0135] Step 2225: Use the quotient of the first difference and the second difference as the memory access feature value.

[0136] Exemplarily, the calculation formula of the memory access characteristic value (stall_SPI) is as follows:

[0137]

[0138] Wherein, stall_SPI represents a memory access characteristic value, SPI1 represents a first SPI, Freq1 represents a first operating frequency, SPI2 represents a second SPI, and Freq2 represents a second operating frequency.

[0139] By utilizing at least two operating frequencies of the CPU in the previous cycle as well as the running time and number of executed instructions at at least two operating frequencies, the workload of searching data from the performance monitoring hardware unit can be reduced without searching all caches in sequence, which is beneficial to improving the computational efficiency of calculating memory access characteristic values.

[0140] For load characteristic value (base_CPI):

[0141] In some embodiments, the performance characteristic value further includes a load characteristic value (base_CPI). The load characteristic value (base_CPI) is used to indicate the number of cycles consumed by each instruction that is independent of the front-end memory access and the back-end memory access in the CPU pipeline.

[0142] In some embodiments, the monitoring data includes the number of per-instruction refreshes of at least two levels of cache in a previous cycle.

[0143] Exemplarily, the calculation formula of the load characteristic value (base_CPI) is as follows:

[0144] base_CPI=para1*STALL_BACKEND_MPI+para2*L1D_TLB_REFILL_MPI+para3*L1I_TLB_MPI+para4

[0145] *BRANCH_MIS_PREDICTED_MPI

[0146] Among them, base_CPI represents the load characteristic value, para1 represents the fitting parameter corresponding to the number of stall cycles caused by memory access in the back end, STALL_BACKEND_MPI represents the number of stall cycles caused by memory access per instruction in the current cycle, para2 represents the fitting parameter corresponding to the number of refills of the first-level data translation lookaside buffer, L1D_TLB_REFILL_MPI represents the number of refills of the first-level data translation lookaside buffer per instruction in the current cycle, para3 represents the fitting parameter corresponding to the number of accesses to the first-level data translation lookaside buffer, L1I_TLB_MPI represents the number of accesses to the first-level data translation lookaside buffer per instruction in the current cycle, para4 represents the fitting parameter corresponding to the number of branch prediction errors, BRANCH_MIS_PREDICTED_MPI represents the number of branch prediction errors per instruction of the erroneous instruction in the current cycle.

[0147] In some embodiments, there is an equation relationship between the memory access characteristic value (stall_SPI) and the load characteristic value (base_CPI). When the memory access characteristic value (stall_SPI) is known, the load characteristic value (base_CPI) can be obtained based on the equation relationship; when the load characteristic value (base_CPI) is known, the memory access characteristic value (stall_SPI) can be obtained based on the equation relationship.

[0148] Calculate the load characteristic value for a known memory access characteristic value:

[0149] In some embodiments, when the memory access characteristic value (stall_SPI) is known, the monitoring data includes the CPU's running time and the number of executed instructions in the previous cycle. Figure 8 As shown, the above step 222 can also be replaced by the following sub-steps:

[0150] Step 2226: Calculate the quotient of the CPU's running time in the previous cycle and the number of executed instructions to obtain the execution time SPI required for each instruction in the current cycle;

[0151] For example, Among them, SPI represents the execution time required for each instruction in the current cycle, cpu_running_time represents the CPU running time, and Instructions represents the number of instructions executed by the CPU in the previous cycle.

[0152] Step 2227: Based on the memory access characteristic value and the SPI, the load characteristic value is calculated.

[0153] In some embodiments, the difference between the SPI and the memory access characteristic value (stall_SPI) is equal to the quotient of the load characteristic value (base_CPI) and the CPU frequency of the current cycle.

[0154] For example,

[0155] Among them, SPI represents the execution time required for each instruction in the current cycle, base_CPI represents the load characteristic value, cpufreq represents the CPU frequency of the current cycle, and stall_SPI represents the memory access characteristic value.

[0156] The above step 2227 may also be replaced by the following sub-steps:

[0157] Step 2227-1: Calculate the difference between the SPI and the memory access characteristic value;

[0158] Exemplarily, the difference = SPI - stall_SPI.

[0159] Step 2227-2: Calculate the quotient of the CPU operation cycle and the CPU operation time to obtain the CPU frequency of the current cycle;

[0160] In some embodiments, the monitoring data includes the CPU's operating cycles and the CPU's operating time.

[0161] For example,

[0162] Among them, cpufreq represents the CPU frequency of the current cycle, cycles represents the CPU operating cycle, and cpu_running_time represents the CPU running time.

[0163] Step 2227-3: Calculate the product of the difference and the CPU frequency as the load characteristic value.

[0164] Exemplarily, base_CPI=(SPI-stall_SPI)*cpufreq.

[0165] Among them, base_CPI represents the load characteristic value, SPI represents the execution time required for each instruction in the current cycle, stall_SPI represents the memory access characteristic value, and cpufreq represents the CPU frequency of the current cycle.

[0166] When the memory access characteristic value is known, the load characteristic value can be directly calculated through the equation relationship between the memory access characteristic value and the load characteristic value, thereby avoiding repeated acquisition of monitoring data for calculating the load characteristic value, which is conducive to improving calculation efficiency.

[0167] Calculate the memory access characteristic value for a known load characteristic value:

[0168] In some embodiments, when the load characteristic value (base_CPI) is known, the monitoring data includes the CPU's running time and the number of executed instructions in the previous cycle. Fig. 9 As shown, the above step 222 can also be replaced by the following sub-steps:

[0169] Step 2228: Calculate the quotient of the CPU's running time in the previous cycle and the number of executed instructions to obtain the execution time SPI required for each instruction in the current cycle;

[0170] For example, Among them, SPI represents the execution time required for each instruction in the current cycle, cpu_running_time represents the CPU running time, and Instructions represents the number of instructions executed by the CPU in the previous cycle.

[0171] Step 2229: Based on the load characteristic value and SPI, the memory access characteristic value is calculated.

[0172] In some embodiments, the difference between the SPI and the memory access characteristic value (stall_SPI) is equal to the quotient of the load characteristic value (base_CPI) and the CPU frequency of the current cycle.

[0173] For example,

[0174] Among them, SPI represents the execution time required for each instruction in the current cycle, base_CPI represents the load characteristic value, cpufreq represents the CPU frequency of the current cycle, and stall_SPI represents the memory access characteristic value.

[0175] In some embodiments, the above step 2229 may also be replaced by the following sub-steps:

[0176] Step 2229-1: Calculate the quotient of the CPU operation cycle and the CPU operation time to obtain the CPU frequency of the current cycle;

[0177] In some embodiments, the monitoring data includes the CPU's operating cycles and the CPU's operating time.

[0178] For example,

[0179] Among them, cpufreq represents the CPU frequency of the current cycle, cycles represents the CPU operating cycle, and cpu_running_time represents the CPU running time.

[0180] Step 2229-2: Calculate the quotient of the load characteristic value and the CPU frequency;

[0181] For example, the load characteristic value (base_CPI) is Among them, base_CPI represents the load characteristic value, and cpufreq represents the CPU frequency of the current cycle.

[0182] Step 2229-3: Calculate the difference between the SPI and the quotient value as the memory access characteristic value.

[0183] For example,

[0184] Among them, stall_SPI represents the memory access characteristic value, SPI represents the execution time required for each instruction in the current cycle, base_CPI represents the load characteristic value, and cpufreq represents the CPU frequency of the current cycle.

[0185] When the load characteristic value is known, the memory access characteristic value can be directly calculated through the equation relationship between the memory access characteristic value and the load characteristic value, thereby avoiding repeated acquisition of monitoring data for calculating the memory access characteristic value, which is conducive to improving calculation efficiency.

[0186] For acquisition method 2:

[0187] In some embodiments, the performance characteristic value of the previous cycle is obtained based on monitoring the event register in the CPU pipeline. Fig.10 As shown, the above method also includes:

[0188] Step 320: Monitor events in the CPU pipeline.

[0189] In some implementations, the events in the CPU pipeline include events related to front-end memory access and back-end memory access in the CPU pipeline. Optionally, the events in the CPU pipeline include the number of cycles and the first number of instructions that are not related to the front-end memory access and back-end memory access in the CPU pipeline. Optionally, the events in the CPU pipeline include the number of second instructions in the CPU pipeline that trigger the front-end memory access and back-end memory access and the stagnation time caused by the second number of instructions.

[0190] In some embodiments, events in the CPU pipeline are used to calculate performance characteristic values. Optionally, the performance characteristic values ​​are calculated in real time based on real-time monitoring of events in the CPU pipeline. Optionally, the performance characteristic values ​​are obtained from hardware registers. Events in the CPU pipeline and / or performance characteristic values ​​calculated based on events in the CPU pipeline are stored in real time in the hardware registers.

[0191] In some embodiments, the performance characteristic value includes a memory access characteristic value (stall_SPI) and / or a load characteristic value (base_CPI). The memory access characteristic value (stall_SPI) is used to indicate the access consumption time caused by each instruction accessing the storage. The load characteristic value (base_CPI) is used to indicate the number of cycles consumed by each instruction that is not related to the front-end memory access and the back-end memory access in the CPU pipeline.

[0192] For load characteristic value (base_CPI):

[0193] In some embodiments, Fig.11 As shown, the above step 320 can also be replaced by the following sub-steps:

[0194] Step 321: Monitor the number of cycles and the number of first instructions that are not related to the front-end memory access and the back-end memory access in the CPU pipeline, and the number of cycles and the number of first instructions are used to calculate the load characteristic value.

[0195] In some embodiments, the load characteristic value does not need to be stored via a hardware register, but is directly calculated in real time based on monitoring events in the CPU pipeline.

[0196] In some embodiments, the number of cycles and the number of first instructions of the CPU that are not related to front-end memory access and back-end memory access in at least one cycle are monitored, the quotient of the number of cycles and the number of first instructions is directly calculated, and the quotient of the number of cycles and the number of first instructions is used as the load characteristic value.

[0197] In some embodiments, the number of cycles and the first number of instructions of the CPU that are unrelated to front-end memory access and back-end memory access in at least one cycle are monitored; the quotient of the number of cycles and the first number of instructions is used as a load characteristic value and stored in a first hardware register.

[0198] In some embodiments, the performance characteristic value includes a load characteristic value (base_CPI). The load characteristic value (base_CPI) is directly obtained based on the first hardware register. The load characteristic value (base_CPI) is related to the number of cycles of the CPU that are not related to front-end memory access and back-end memory access in at least one cycle and the number of first instructions.

[0199] For example, Fig.12As shown, the number of cycles and the first number of instructions of the CPU that are not related to the front-end memory access and the back-end memory access in at least one cycle are monitored, and the quotient of the number of cycles and the first number of instructions is directly stored as the load characteristic value (base_CPI) in the first hardware register 10. That is,

[0200] In some embodiments, the first hardware memory stores a load characteristic value (base_CPI). In some embodiments, the first hardware memory stores a load characteristic value (base_CPI), a number of CPU cycles that are unrelated to front-end memory access and back-end memory access in at least one cycle, and a first instruction number.

[0201] In some embodiments, the number of cycles and the number of first instructions of the CPU that are independent of front-end memory access and back-end memory access in at least one cycle are monitored; the number of cycles and the number of first instructions are stored in a second hardware register and a third hardware register, respectively, as values ​​for calculating a load characteristic value.

[0202] In some embodiments, the performance characteristic value includes a load characteristic value (base_CPI). The load characteristic value (base_CPI) is directly obtained based on the first hardware register. The load characteristic value (base_CPI) is related to the number of cycles of the CPU that are not related to front-end memory access and back-end memory access in at least one cycle and the number of first instructions.

[0203] For example, Fig.13As shown, the number of cycles and the number of first instructions of the CPU that are not related to the front-end memory access and the back-end memory access in at least one cycle are monitored. The number of cycles that are not related to the front-end memory access and the back-end memory access in at least one cycle of the CPU is stored in the second hardware register 11, and the number of first instructions that are not related to the front-end memory access and the back-end memory access in at least one cycle of the CPU is stored in the third hardware register 12. Or, the number of cycles that are not related to the front-end memory access and the back-end memory access in at least one cycle of the CPU is stored in the third hardware register 12, and the number of first instructions that are not related to the front-end memory access and the back-end memory access in at least one cycle of the CPU is stored in the second hardware register 11.

[0204] The quotient of the above number of cycles (cycles) and the first number of instructions (instructions) is stored in the first hardware register 10 as a load characteristic value (base_CPI).

[0205] At this time, the first hardware register is used to store the load characteristic value (base_CPI), the second hardware register is used to store the number of CPU cycles that are not related to front-end memory access and back-end memory access in at least one cycle, and the third hardware register is used to store the number of first instructions that are not related to front-end memory access and back-end memory access in at least one cycle of the CPU. Or, the first hardware register is used to store the load characteristic value (base_CPI), the second hardware register is used to store the number of first instructions that are not related to front-end memory access and back-end memory access in at least one cycle of the CPU, and the third hardware register is used to store the number of CPU cycles that are not related to front-end memory access and back-end memory access in at least one cycle.

[0206] For the memory access characteristic value (stall_SPI):

[0207] In some embodiments, Fig.14 As shown, the above step 320 can also be replaced by the following sub-steps:

[0208] Step 323: monitor the number of second instructions that trigger front-end memory access and back-end memory access in the CPU pipeline and the stall time caused by the second instruction number, and the second instruction number and the stall time are used to calculate the memory access characteristic value.

[0209] In some embodiments, the memory access characteristic value does not need to be stored through a hardware register, but is directly calculated in real time based on monitoring events in the CPU pipeline.

[0210] In some embodiments, the number of second instructions that trigger front-end memory access and back-end memory access in the CPU pipeline and the stall time caused by the second instruction number are monitored, the quotient of the second instruction number and the stall time caused by the second instruction number is directly calculated, and the quotient of the second instruction number and the stall time caused by the second instruction number is used as the memory access feature value.

[0211] In some embodiments, the number of second instructions that trigger front-end memory access and back-end memory access by the CPU in at least one cycle and the stall time caused by the second instruction number are monitored; the quotient of the stall time and the second instruction number is used as a memory access characteristic value and stored in a fourth hardware register.

[0212] In some embodiments, the performance characteristic value includes a memory access characteristic value (stall_SPI). The memory access characteristic value (stall_SPI) is directly obtained based on the fourth hardware register. The memory access characteristic value (stall_SPI) is related to the number of second instructions that trigger front-end memory access and back-end memory access by the CPU in at least one cycle and the stall time caused by the second instruction number.

[0213] For example, Fig.15 As shown, the monitoring CPU triggers the second instruction number (instructions) of the front-end memory access and the back-end memory access in at least one cycle and the stall time caused by the second instruction number, and directly stores the quotient of the stall time and the second instruction number as the memory access characteristic value (stall_SPI) in the fourth hardware register 20. That is,

[0214] In some embodiments, the fourth hardware memory stores a memory access characteristic value (stall_SPI). In some embodiments, the fourth hardware memory stores a memory access characteristic value (stall_SPI), a second instruction number of the CPU triggering front-end memory access and back-end memory access in at least one cycle, and a stall time caused by the second instruction number.

[0215] In some embodiments, the number of second instructions that trigger front-end memory access and back-end memory access by the CPU in at least one cycle and the stall time caused by the second instruction number are monitored; the stall time and the second instruction number are stored in a fifth hardware register and a sixth hardware register, respectively, as values ​​for calculating a memory access characteristic value.

[0216] In some embodiments, the performance characteristic value includes a memory access characteristic value (stall_SPI). The memory access characteristic value (stall_SPI) is directly obtained based on the fourth hardware register. The memory access characteristic value (stall_SPI) is related to the number of second instructions that trigger front-end memory access and back-end memory access by the CPU in at least one cycle and the stall time caused by the second instruction number.

[0217] For example, Fig.16 As shown, the number of second instructions (instructions) of the CPU triggering the front-end memory access and the back-end memory access in at least one cycle and the stagnation time caused by the second instruction number are monitored. The number of second instructions (instructions) of the CPU triggering the front-end memory access and the back-end memory access in at least one cycle is stored in the fifth hardware memory 21. The stagnation time caused by the second instruction number is stored in the sixth register 22. Or, the number of second instructions (instructions) of the CPU triggering the front-end memory access and the back-end memory access in at least one cycle is stored in the sixth hardware memory 22. The stagnation time caused by the second instruction number is stored in the fifth register 21.

[0218] The quotient of the stall time and the second instruction number is stored in the fourth hardware register 20 as a memory access characteristic value (stall_SPI).

[0219] At this time, the fourth hardware register is used to store the memory access characteristic value (stall_SPI), the fifth hardware register is used to store the second instruction number of the CPU triggering the front-end memory access and the back-end memory access in at least one cycle, and the sixth hardware register is used to store the stall time caused by the second instruction number. Or, the fourth hardware register is used to store the memory access characteristic value (stall_SPI), the fifth hardware register is used to store the stall time caused by the second instruction number, and the sixth hardware register is used to store the second instruction number of the CPU triggering the front-end memory access and the back-end memory access in at least one cycle.

[0220] In some embodiments, where the performance characteristic values ​​are stored in hardware registers, such as Fig.17 As shown, the above step 220 can also be replaced by the following sub-steps:

[0221] Step 223: Obtain the performance characteristic value of the previous cycle based on the hardware register.

[0222] In some embodiments, a load characteristic value (base_CPI) of a previous cycle is obtained based on a first hardware register.

[0223] In some embodiments, the number of CPU cycles that are independent of front-end memory access and back-end memory access in at least one cycle is obtained based on the second hardware register, and the number of first instructions that are independent of front-end memory access and back-end memory access in at least one cycle is obtained based on the third hardware register. Or, the number of first instructions that are independent of front-end memory access and back-end memory access in at least one cycle is obtained based on the second hardware register, and the number of CPU cycles that are independent of front-end memory access and back-end memory access in at least one cycle is obtained based on the third hardware register. The load characteristic value (base_CPI) of the previous cycle is equal to the quotient of the number of cycles and the first number of instructions.

[0224] In some embodiments, a memory access characteristic value (stall_SPI) of a previous cycle is obtained based on a fourth hardware register.

[0225] In some embodiments, the second instruction number that triggers the front-end memory access and the back-end memory access of the CPU in at least one cycle is obtained based on the fifth hardware register, and the stall time caused by the second instruction number is obtained based on the sixth hardware register. Or, the stall time caused by the second instruction number is obtained based on the fifth hardware register, and the second instruction number that triggers the front-end memory access and the back-end memory access of the CPU in at least one cycle is obtained based on the sixth hardware register. The memory access characteristic value (stall_SPI) of the previous cycle is equal to the quotient of the stall time and the second instruction number.

[0226] To sum up, the method provided in this embodiment monitors the performance characteristic values ​​of each cycle in real time and stores the performance characteristic values ​​obtained by monitoring in hardware registers, thereby saving the time for searching monitoring data and calculating the performance characteristic values, which is conducive to improving computing efficiency.

[0227] For phase 2, the performance requirements in the later period are predicted based on the following two methods:

[0228] Prediction method 1: directly use the performance requirement value of the previous cycle as the performance requirement value of the next cycle;

[0229] Forecasting method 2: forecasting based on the performance demand value in the previous cycle and the performance demand value in at least one historical cycle.

[0230] For prediction method 1:

[0231] In some embodiments, the performance requirement value in the later cycle is predicted based on the performance requirement value in the previous cycle. Fig.19 As shown, the above step 240 can also be replaced by the following sub-steps:

[0232] Step 241: The performance requirement value in the previous cycle is used as the performance requirement value in the next cycle.

[0233] In some embodiments, the performance requirement value in the previous cycle is equal to the ratio of the number of instructions executed by the CPU in the previous cycle to the cycle time.

[0234] For example, Among them, demand_ips represents the performance demand value, instructions represents the number of instructions executed by the CPU in the previous cycle, and period_time represents the cycle time.

[0235] Directly using the performance requirement value in the previous cycle as the performance requirement value in the next cycle is helpful in reducing calculations, thereby helping to improve efficiency.

[0236] For prediction method 2:

[0237] In some embodiments, the performance requirement value in the subsequent cycle is determined based on the performance requirement value in the previous cycle and the performance requirement value of at least one historical cycle. Fig.19 As shown, the above step 240 can also be replaced by the following sub-steps:

[0238] Step 242: Based on the sliding average of the performance requirement value in the previous cycle and the performance requirement value in at least one historical cycle, predict the performance requirement value in the next cycle.

[0239] In some embodiments, in order to avoid the negative impact of multiple data on the prediction of the performance requirement value, the performance requirement value in the next cycle is predicted based on the sliding average of the performance requirement value in the previous cycle and the performance requirement value in the most recent historical cycle. Exemplarily, the calculation formula of the performance requirement value in the next cycle is as follows:

[0240] demand_ips[n]=α*ips[n]+(1-α)*ips[n-1]

[0241] Among them, demand_ips[n] represents the predicted performance demand value in the next cycle, α represents the coefficient, ips[n] represents the performance demand value in the previous cycle, and ips[n-1] represents the performance demand value in the most recent historical cycle.

[0242] In some embodiments, when α=1, the performance requirement value in the previous cycle is directly used as the performance requirement value in the next cycle.

[0243] By utilizing the performance requirement value of the previous cycle and the performance requirement value of at least one historical cycle, the performance requirement value of the subsequent cycle can refer to the performance requirement values ​​of multiple previous cycles, thereby making the predicted performance requirement value of the subsequent cycle more accurate.

[0244] For stage 3, after obtaining the performance characteristic value and predicting the performance requirement value, the predicted frequency range in the subsequent cycle can be determined based on the preset correspondence between the performance characteristic value, the performance requirement value and the CPU frequency. Fig. 20 As shown, the above step 260 can also be replaced by the following sub-steps:

[0245] Step 261: Taking the performance characteristic value in the previous cycle and the performance requirement value in the next cycle as input, determine the minimum CPU frequency and the maximum CPU frequency based on a preset corresponding relationship;

[0246] In some embodiments, the preset correspondence relationship is predetermined. Fig.21 As shown, the preset corresponding relationship is represented by a three-dimensional mapping table, wherein the x-axis represents the memory access characteristic value, the y-axis represents the load characteristic value, and the z-axis represents the CPU frequency.

[0247] In some embodiments, the preset correspondence includes a correspondence between a performance characteristic value, a performance requirement value, and a CPU frequency.

[0248] In some embodiments, the preset correspondence is a non-linear correspondence.

[0249] In some embodiments, the performance characteristic value in the previous cycle and the performance requirement value in the next cycle are used as input, and the minimum CPU frequency value is queried in the preset corresponding relationship.

[0250] In some embodiments, the difference between the inverse of the performance requirement value in the later cycle and the memory access characteristic value (stall_SPI) is equal to the quotient of the load characteristic value (base_CPI) and the CPU frequency.

[0251] Among them, SPI represents the execution time required for each instruction in the current cycle, IPS represents the number of instructions executed per unit time, base_CPI represents the load characteristic value, cpufreq represents the CPU frequency, and stall_SPI represents the memory access characteristic value.

[0252] In some embodiments, when the performance characteristic value of the previous cycle and the performance requirement value of the next cycle are known, the minimum CPU frequency value is determined based on a preset corresponding relationship.

[0253] In some embodiments, the preset corresponding relationship is represented by a curve.

[0254] In some embodiments, the maximum value of the CPU frequency is determined based on the acceleration ratio corresponding to the minimum value of the CPU frequency in the preset correspondence. The difference between the first preset performance value corresponding to the maximum value of the CPU frequency and the second preset performance value corresponding to the minimum value of the CPU frequency is positively correlated with the acceleration ratio. Optionally, the acceleration ratio is represented by a slope or a gradient. Wherein, when the preset correspondence is represented by a two-dimensional curve, the maximum value of the CPU frequency is determined based on the slope corresponding to the minimum value of the CPU frequency. When the preset correspondence is represented by a three-dimensional curve, the maximum value of the CPU frequency is determined based on the gradient corresponding to the minimum value of the CPU frequency. Optionally, the acceleration ratio of the minimum value of the CPU frequency at the curve is pre-calculated. Optionally, the acceleration ratio of the minimum value of the CPU frequency at the curve is calculated in real time.

[0255] Step 262: Based on the minimum CPU frequency and the maximum CPU frequency, determine the predicted frequency range in the subsequent cycle.

[0256] In some embodiments, the minimum CPU frequency value determined based on the preset corresponding relationship is used as the minimum value of the predicted frequency range, and the maximum CPU frequency value determined based on the preset corresponding relationship is used as the maximum value of the predicted frequency range.

[0257] In some embodiments, since there are multiple demand ends that need to adjust the CPU frequency, in the process of determining the minimum CPU frequency and the maximum CPU frequency, the priorities corresponding to different demand ends may be determined. Fig. 22 As shown, multiple demand ends are sorted according to priority: temperature control demand corresponds to the first priority, frame stabilizer demand corresponds to the second priority, IPS demand corresponds to the third priority, flash drive demand corresponds to the fourth priority, and user scenario demand corresponds to the fifth priority. Determining the minimum CPU frequency and the maximum CPU frequency according to the priority is conducive to avoiding conflicts between multiple demand ends when determining the minimum CPU frequency and the maximum CPU frequency, and is conducive to ensuring that high-priority demands are met first.

[0258] By determining the minimum CPU frequency, the CPU frequency value within the predicted frequency range can at least meet the performance requirements required in the subsequent cycle. By determining the maximum CPU frequency, it is possible to limit excessive useless requirements, while ensuring performance, and also to minimize power consumption.

[0259] For stage 4, after the predicted frequency range is determined, the CPU frequency in the subsequent cycle can be adjusted based on the predicted frequency range.

[0260] In some embodiments, the CPU frequency is adjusted in two ways:

[0261] Adjustment method 1: first determine the first operating frequency based on the first frequency modulator, and then adjust the first operating frequency based on the predicted frequency range to obtain the second operating frequency;

[0262] Adjustment method 2: firstly adjust the working parameters of the second frequency modulator based on the predicted frequency range, and then determine the third working frequency based on the adjusted second frequency modulator.

[0263] For adjustment method 1:

[0264] In some embodiments, Fig.23 As shown, the above step 280 can also be replaced by the following sub-steps:

[0265] Step 281: Obtain a first operating frequency determined by the first CPU frequency regulator based on the load in the subsequent cycle;

[0266] In some embodiments, the first CPU frequency regulator is used to determine the operating frequency of the CPU based on the load. Optionally, the first CPU frequency regulator is used to determine the first operating frequency based on the load in the subsequent cycle.

[0267] Step 282: Based on the predicted frequency range, the first operating frequency is adjusted to obtain a second operating frequency in a subsequent period.

[0268] In some embodiments, based on the predicted frequency range, it is determined whether the first operating frequency is within the predicted frequency range.

[0269] In some embodiments, if the first operating frequency is within the predicted frequency range, the first operating frequency is directly used as the second operating frequency in the subsequent cycle. That is, the first operating frequency is equal to the second operating frequency. Optionally, when the first operating frequency is greater than or equal to the minimum CPU frequency and less than or equal to the maximum CPU frequency, the first operating frequency is used as the second operating frequency in the subsequent cycle.

[0270] In some embodiments, if the first operating frequency is not within the predicted frequency range, the frequency within the predicted frequency range that is closest to the first operating frequency is used as the second operating frequency in the later cycle. Exemplarily, assuming that the first operating frequency is 1000MHz and the predicted frequency range is 500MHz to 800MHz, since the first operating frequency is greater than the maximum frequency, that is, the first operating frequency is closest to the maximum frequency in the predicted frequency range, 800MHz corresponding to the maximum frequency is used as the second operating frequency. Optionally, when the first operating frequency is greater than the maximum CPU frequency, the maximum CPU frequency is used as the second operating frequency in the later cycle. Optionally, when the first operating frequency is less than the minimum CPU frequency, the minimum CPU frequency is used as the second operating frequency in the later cycle.

[0271] For example, Fig. 22 As shown, first, based on step 7, a first operating frequency determined by the first CPU frequency regulator based on the load in the subsequent cycle is obtained, and the first operating frequency is determined based on the load in the subsequent cycle before the CPU frequency is adjusted. Then, based on step 6, the first operating frequency is adjusted based on the predicted frequency range to obtain a second operating frequency in the subsequent cycle.

[0272] By first determining the first operating frequency corresponding to the load in the subsequent cycle, and then judging whether the first operating frequency needs to be adjusted based on the predicted frequency range, it is helpful to reduce the workload. For example, when the first operating frequency is within the predicted frequency range, there is no need to adjust the first operating frequency; when the first operating frequency is outside the predicted frequency range, the first operating frequency is adjusted to the frequency value closest to the first operating frequency within the predicted frequency range. That is, when the first operating frequency is within the predicted frequency range, there is no need to adjust it again.

[0273] For adjustment method 2:

[0274] In some embodiments, Fig.24 As shown, the above step 280 can also be replaced by the following sub-steps:

[0275] Step 283: Setting the operating parameters of the second CPU frequency regulator based on the predicted frequency range;

[0276] In some embodiments, the predicted frequency range is used to set operating parameters of a second CPU frequency regulator, and the second CPU frequency regulator is used to determine the operating frequency of the CPU based on the load.

[0277] Step 284: Determine the third operating frequency in the subsequent cycle based on the load in the subsequent cycle through the set second CPU frequency regulator.

[0278] For example, Fig. 22 As shown, firstly, based on step 6, the operating parameters of the second frequency modulator are set based on the predicted frequency range. Then, based on step 7, the third operating frequency in the subsequent cycle is determined by the set second CPU frequency modulator.

[0279] By first adjusting the operating parameters of the CPU frequency regulator based on the predicted frequency range, and then determining the third operating frequency corresponding to the load in the subsequent cycle through the set CPU frequency regulator, it is helpful to ensure the accuracy of the third operating frequency.

[0280] Fig.25 A block diagram of a CPU frequency modulation device provided by an exemplary embodiment of the present application is shown. The device includes:

[0281] The acquisition module 110 is used to acquire the performance characteristic value of the previous cycle, and the performance characteristic value is used to characterize the performance characteristic of the instruction granularity.

[0282] In some embodiments, the performance characteristic value includes a load characteristic value (base_CPI) and / or a memory access characteristic value (stall_SPI). The load characteristic value (base_CPI) is used to indicate the number of cycles consumed by each instruction that is not related to the front-end memory access and the back-end memory access in the CPU pipeline, and the memory access characteristic value (stall_SPI) is used to indicate the access consumption time caused by each instruction accessing the storage. Accessing the storage refers to the CPU accessing external storage such as cache or memory.

[0283] In some embodiments, the performance characteristic value of each period is obtained in units of period.

[0284] In some embodiments, the computer device includes a hardware register for storing performance characteristic values, and the performance characteristic value of each cycle is directly obtained based on the hardware register.

[0285] In some embodiments, if the computer device does not include a hardware register for storing performance characteristic values, the performance characteristic value of each cycle is calculated by acquiring monitoring data of a performance monitoring hardware unit.

[0286] In some embodiments, the performance monitoring hardware unit includes at least one of a PMU and an AMU.

[0287] The prediction module 120 is used to predict the performance requirement value in the subsequent cycle, and the performance requirement value is used to indicate the performance requirement of the instruction granularity.

[0288] In some embodiments, the performance requirement value in the later cycle is directly equal to the performance requirement value in the previous cycle.

[0289] In some embodiments, considering that the load on the mobile device changes rapidly, the performance requirement value in the subsequent cycle can be predicted using a window sliding method. The performance requirement value in the subsequent cycle is equal to the sliding average of the performance requirement value in the previous cycle and the performance requirement value of at least one historical cycle.

[0290] The determination module 130 is used to determine the predicted frequency range of the subsequent cycle based on the performance characteristic value of the previous cycle and the performance requirement value of the subsequent cycle.

[0291] In some embodiments, there is a preset corresponding relationship between the performance characteristic value, the performance requirement value and the CPU frequency. Based on the preset corresponding relationship, as well as the performance characteristic value in the previous cycle and the performance requirement value in the next cycle, the minimum CPU frequency and the maximum CPU frequency are determined. That is, the predicted frequency range determined in the next cycle has both a minimum value restriction and a maximum value restriction. While meeting the minimum CPU performance requirements, CPU power consumption is also saved.

[0292] In some embodiments, the predicted frequency range in the later cycle is the adjustment range of the CPU frequency in the later cycle. That is, the CPU frequency in the later cycle is a target value determined between the above-mentioned minimum CPU frequency and maximum CPU frequency. When the minimum CPU frequency and the maximum CPU frequency are equal, a determined target value is given.

[0293] In some embodiments, the minimum CPU frequency is determined based on a preset correspondence between the performance characteristic value, the performance requirement value, and the CPU frequency. The maximum CPU frequency is not limited. That is, the predicted frequency range determined in the subsequent cycle has only a minimum value limit, but no maximum value limit. While meeting the minimum CPU performance requirements, there is no limit on the CPU power consumption.

[0294] The adjustment module 140 is used to adjust the CPU frequency in the subsequent cycle based on the predicted frequency range.

[0295] In some embodiments, the CPU frequency in the later cycle is adjusted by the CPU frequency regulator based on the predicted frequency range.

[0296] In some embodiments, the predicted frequency range is used to set the working parameters of the CPU frequency regulator. After the CPU frequency regulator is set, the CPU frequency in the subsequent cycle is adjusted by the set CPU frequency regulator.

[0297] In some embodiments, the CPU frequency governor (cpufreq governor) includes but is not limited to at least one of the following: a high-performance mode frequency governor, a power saving mode frequency governor, a conservative mode frequency governor, an on-demand mode frequency governor, an interactive mode frequency governor, a user mode frequency governor, a default CPU frequency governor based on a physical load tracking algorithm, and a load tracking frequency governor, etc.

[0298] In some embodiments, the performance characteristic value in the previous cycle is obtained based on the following two methods:

[0299] Acquisition method 1: Calculated based on monitoring data of performance monitoring hardware unit;

[0300] Acquisition method 2: Acquisition based on monitoring event registers in the CPU pipeline.

[0301] For acquisition method 1:

[0302] In some embodiments, the performance characteristic value of the previous cycle is calculated based on monitoring data of the performance monitoring hardware unit of the previous cycle.

[0303] The acquisition module 110 is also used to acquire monitoring data of the performance monitoring hardware unit in the previous cycle.

[0304] In some embodiments, the performance monitoring hardware unit includes at least one register for monitoring CPU performance. Optionally, the performance monitoring hardware unit includes a memory access characteristic value (stall_SPI) register and / or a load characteristic value (base_CPI) register. Among them, the memory access characteristic value (stall_SPI) register is used to store the memory access characteristic value (stall_SPI), and the load characteristic value (base_CPI) register is used to store the load characteristic value (base_CPI).

[0305] In some embodiments, the monitoring data of the performance monitoring hardware unit includes at least the number of cycles, the number of instructions executed in the current cycle, the number of refills of caches at all levels in the current cycle, and the CPU running time (cpu_running_time). Among them, the cycles and the number of instructions executed in the current cycle can be obtained from the AMU, and the number of refills of caches at all levels in the current cycle can be obtained from the PMU. The number of refills of caches at all levels in the current cycle includes at least one of the number of refills of the third-level cache in the current cycle (L3 CacheRefill), the number of refills of the second-level cache in the current cycle (L2 Cache Refill), and the number of refills of the second-level cache in the current cycle (L2dTLB Refill).

[0306] The acquisition module 110 is further used to calculate the performance characteristic value of the previous cycle based on the monitoring data, and the performance characteristic value is used to characterize the factors that affect the number of instructions per second or the time required for each instruction.

[0307] In some embodiments, the performance characteristic value includes a memory access characteristic value (stall_SPI) and / or a load characteristic value (base_CPI). The memory access characteristic value (stall_SPI) is used to indicate the access consumption time caused by each instruction accessing the storage. The load characteristic value (base_CPI) is used to indicate the number of cycles consumed by each instruction that is not related to the front-end memory access and the back-end memory access in the CPU pipeline.

[0308] For the memory access characteristic value (stall_SPI):

[0309] In some embodiments, the manners of calculating the memory access characteristic value based on the monitoring data of the performance monitoring hardware unit include the following two methods:

[0310] Calculation method 1: calculated based on the number of refreshes per instruction of at least two levels of cache in the previous cycle in the monitoring data;

[0311] Calculation method 2: Calculated based on at least two operating frequencies of the CPU in the previous cycle in the monitoring data and the running time and the number of executed instructions at at least two operating frequencies.

[0312] For calculation method 1:

[0313] In some embodiments, the memory access characteristic value (stall_SPI) is equal to the weighted sum of the number of refills per instruction of at least two levels of cache in the previous cycle.

[0314] In some embodiments, the monitoring data includes the number of refreshes of at least two levels of cache per instruction in the previous cycle. The performance characteristic value includes a memory access characteristic value (stall_SPI), which is used to indicate the access consumption time caused by accessing storage per instruction.

[0315] The acquisition module 110 is further used to calculate the weighted sum of the number of refills per instruction of at least two levels of cache in the previous cycle using the fitting parameters corresponding to at least two levels of cache as weights, and use the weighted sum as the memory access characteristic value (stall_SPI).

[0316] Exemplarily, the calculation formula of the memory access characteristic value (stall_SPI) is as follows:

[0317]

[0318] Among them, stall_SPI represents the memory access characteristic value, α i represents the fitting parameters corresponding to the i-th level cache, PMU i It indicates the number of times the i-th level cache is refilled in the current cycle, and Instruction indicates the number of instructions executed in the current cycle.

[0319] Specifically, the number of refills of at least two levels of cache in the current cycle includes the number of refills of the third level cache in the current cycle (L3 Cache Refill), the number of refills of the second level cache in the current cycle (L2 Cache Refill), and the number of refills of the second level cache in the current cycle (L2d TLB Refill). The memory access characteristic value (stall_SPI) can also be calculated according to the following formula:

[0320] stall_SPI=para1*L3_MPI+para2*L2_MPI–para3*L3_MPI*L2_TLB_MPI

[0321] Among them, stall_SPI represents the memory access characteristic value, para1 represents the fitting parameter corresponding to the third-level cache, and L3_MPI represents the number of times the third-level cache is refilled per instruction in the current cycle. para2 represents the fitting parameters corresponding to the L2 cache, L2_MPI represents the number of times the L2 cache is refilled per instruction in the current cycle, para3 indicates the fitting parameters corresponding to the L2 cache, L2_TLB_MPI indicates the number of refills per instruction of the L2 cache in the current cycle,

[0322] In some embodiments, different CPU architectures correspond to different fitting parameters. That is, under different CPU architectures, the above α i Different. Under different CPU architectures, the above para1, para2 and para3 are also different.

[0323] For calculation method 2:

[0324] In some embodiments, the monitoring data includes at least two operating frequencies of the CPU in the previous cycle and the running time and number of instructions executed at at least two operating frequencies. The performance characteristic value includes a memory access characteristic value (stall_SPI), which is used to indicate the access consumption time caused by accessing storage per instruction.

[0325] The acquisition module 110 is further used to calculate the first SPI of the CPU load of the current cycle at the first operating frequency based on the running time and the number of executed instructions at the first operating frequency, and calculate the first product of the first SPI and the first operating frequency.

[0326] In some embodiments, a first SPI of the CPU load of the current cycle at the first operating frequency is equal to a first ratio of the running time and the number of executed instructions at the first operating frequency.

[0327] Exemplarily, the calculation formula of the first SPI is as follows:

[0328]

[0329] SPI1 represents the first SPI, cpu_running_time1 represents the running time at the first operating frequency, and Instructions1 represents the number of executed instructions at the first operating frequency.

[0330] Exemplarily, the first product=SPI1*Freq1, wherein SPI1 represents the first SPI, and Freq1 represents the first operating frequency.

[0331] The acquisition module 110 is further configured to calculate a second SPI of the CPU load of the current cycle at the second operating frequency based on the running time and the number of executed instructions at the second operating frequency, and to calculate a first product of the second SPI and the second operating frequency.

[0332] In some embodiments, a second SPI of the CPU load of the current cycle at the second operating frequency is equal to a second ratio of the running time and the number of executed instructions at the second operating frequency.

[0333] Exemplarily, the calculation formula of the second SPI is as follows:

[0334]

[0335] SPI2 represents the second SPI, cpu_running_time2 represents the running time at the second operating frequency, and Instructions2 represents the number of executed instructions at the second operating frequency.

[0336] Exemplarily, the second product=SPI2*Freq2, wherein SPI2 represents the second SPI, and Freq2 represents the second operating frequency.

[0337] The acquisition module 110 is further configured to calculate a first difference between the first product and the second product, and to calculate a second difference between the first operating frequency and the second operating frequency.

[0338] Exemplarily, the first difference=first product-second product=SPI1*Freq1-SPI2*Freq2, wherein SPI1 represents the first SPI, Freq1 represents the first operating frequency, SPI2 represents the second SPI, and Freq2 represents the second operating frequency.

[0339] Exemplarily, the second difference=first operating frequency-second operating frequency=Freq1-Freq2.

[0340] The acquisition module 110 is further configured to use the quotient of the first difference value and the second difference value as the access feature value.

[0341] Exemplarily, the calculation formula of the memory access characteristic value (stall_SPI) is as follows:

[0342]

[0343] Wherein, stall_SPI represents a memory access characteristic value, SPI1 represents a first SPI, Freq1 represents a first operating frequency, SPI2 represents a second SPI, and Freq2 represents a second operating frequency.

[0344] For load characteristic value (base_CPI):

[0345] In some embodiments, the performance characteristic value further includes a load characteristic value (base_CPI). The load characteristic value (base_CPI) is used to indicate the number of cycles consumed by each instruction that is independent of the front-end memory access and the back-end memory access in the CPU pipeline.

[0346] In some embodiments, the monitoring data includes the number of per-instruction refreshes of at least two levels of cache in a previous cycle.

[0347] Exemplarily, the calculation formula of the load characteristic value (base_CPI) is as follows:

[0348] base_CPI=para1*STALL_BACKEND_MPI+para2*L1D_TLB_REFILL_MPI+para3*L1I_TLB_MPI+para4

[0349] *BRANCH_MIS_PREDICTED_MPI

[0350] Among them, base_CPI represents the load characteristic value, para1 represents the fitting parameter corresponding to the number of stall cycles caused by memory access in the back end, STALL_BACKEND_MPI represents the number of stall cycles caused by memory access per instruction in the current cycle, para2 represents the fitting parameter corresponding to the number of refills of the first-level data translation lookaside buffer, L1D_TLB_REFILL_MPI represents the number of refills of the first-level data translation lookaside buffer per instruction in the current cycle, para3 represents the fitting parameter corresponding to the number of accesses to the first-level data translation lookaside buffer, L1I_TLB_MPI represents the number of accesses to the first-level data translation lookaside buffer per instruction in the current cycle, para4 represents the fitting parameter corresponding to the number of branch prediction errors, BRANCH_MIS_PREDICTED_MPI represents the number of branch prediction errors per instruction of the erroneous instruction in the current cycle.

[0351] In some embodiments, there is an equation relationship between the memory access characteristic value (stall_SPI) and the load characteristic value (base_CPI). When the memory access characteristic value (stall_SPI) is known, the load characteristic value (base_CPI) can be obtained based on the equation relationship; when the load characteristic value (base_CPI) is known, the memory access characteristic value (stall_SPI) can be obtained based on the equation relationship.

[0352] Calculate the load characteristic value for a known memory access characteristic value:

[0353] In some embodiments, when the memory access characteristic value (stall_SPI) is known, the monitoring data includes the CPU's running time and the number of executed instructions in the previous cycle.

[0354] The acquisition module 110 is further used to calculate the quotient of the CPU's running time in the previous cycle and the number of executed instructions to obtain the execution time SPI required for each instruction in the current cycle.

[0355] For example, Among them, SPI represents the execution time required for each instruction in the current cycle, cpu_running_time represents the CPU running time, and Instructions represents the number of instructions executed by the CPU in the previous cycle.

[0356] The acquisition module 110 is further used to calculate the load characteristic value based on the memory access characteristic value and the SPI.

[0357] In some embodiments, the difference between the SPI and the memory access characteristic value (stall_SPI) is equal to the quotient of the load characteristic value (base_CPI) and the CPU frequency of the current cycle.

[0358] For example,

[0359] Among them, SPI represents the execution time required for each instruction in the current cycle, base_CPI represents the load characteristic value, cpufreq represents the CPU frequency of the current cycle, and stall_SPI represents the memory access characteristic value.

[0360] The acquisition module 110 is further used to calculate the difference between the SPI and the memory access characteristic value.

[0361] Exemplarily, the difference = SPI - stall_SPI.

[0362] The acquisition module 110 is further used to calculate the quotient of the CPU operation cycle and the CPU operation time to obtain the CPU frequency of the current cycle.

[0363] In some embodiments, the monitoring data includes the CPU's operating cycles and the CPU's operating time.

[0364] For example,

[0365] Among them, cpufreq represents the CPU frequency of the current cycle, cycles represents the CPU operating cycle, and cpu_running_time represents the CPU running time.

[0366] The acquisition module 110 is further used to calculate the product of the difference and the CPU frequency as the load characteristic value.

[0367] Exemplarily, base_CPI=(SPI-stall_SPI)*cpufreq.

[0368] Among them, base_CPI represents the load characteristic value, SPI represents the execution time required for each instruction in the current cycle, stall_SPI represents the memory access characteristic value, and cpufreq represents the CPU frequency of the current cycle.

[0369] Calculate the memory access characteristic value for a known load characteristic value:

[0370] In some embodiments, when the load characteristic value (base_CPI) is known, the monitoring data includes the CPU's running time and the number of executed instructions in the previous cycle.

[0371] The acquisition module 110 is further used to calculate the quotient of the CPU's running time in the previous cycle and the number of executed instructions to obtain the execution time SPI required for each instruction in the current cycle.

[0372] For example, Among them, SPI represents the execution time required for each instruction in the current cycle, cpu_running_time represents the CPU running time, and Instructions represents the number of instructions executed by the CPU in the previous cycle.

[0373] The acquisition module 110 is further used to calculate the memory access characteristic value based on the load characteristic value and the SPI.

[0374] In some embodiments, the difference between the SPI and the memory access characteristic value (stall_SPI) is equal to the quotient of the load characteristic value (base_CPI) and the CPU frequency of the current cycle.

[0375] For example,

[0376] Among them, SPI represents the execution time required for each instruction in the current cycle, base_CPI represents the load characteristic value, cpufreq represents the CPU frequency of the current cycle, and stall_SPI represents the memory access characteristic value.

[0377] The acquisition module 110 is further used to calculate the quotient of the CPU operation cycle and the CPU operation time to obtain the CPU frequency of the current cycle.

[0378] In some embodiments, the monitoring data includes the CPU's operating cycles and the CPU's operating time.

[0379] For example,

[0380] Among them, cpufreq represents the CPU frequency of the current cycle, cycles represents the CPU operating cycle, and cpu_running_time represents the CPU running time.

[0381] The acquisition module 110 is further used to calculate the quotient of the load characteristic value and the CPU frequency.

[0382] For example, the load characteristic value (base_CPI) and CPU Among them, base_CPI represents the load characteristic value, and cpufreq represents the CPU frequency of the current cycle.

[0383] The acquisition module 110 is further used to calculate the difference between the SPI and the quotient value as the memory access feature value.

[0384] For example,

[0385] Among them, stall_SPI represents the memory access characteristic value, SPI represents the execution time required for each instruction in the current cycle, base_CPI represents the load characteristic value, and cpufreq represents the CPU frequency of the current cycle.

[0386] For acquisition method 2:

[0387] In some embodiments, the performance characteristic value of the previous cycle is obtained based on monitoring event registers in the CPU pipeline.

[0388] The above device also includes:

[0389] The monitoring module 150 is used to monitor events in the CPU pipeline.

[0390] In some implementations, the events in the CPU pipeline include events related to front-end memory access and back-end memory access in the CPU pipeline. Optionally, the events in the CPU pipeline include the number of cycles and the first number of instructions that are not related to the front-end memory access and back-end memory access in the CPU pipeline. Optionally, the events in the CPU pipeline include the number of second instructions in the CPU pipeline that trigger the front-end memory access and back-end memory access and the stagnation time caused by the second number of instructions.

[0391] In some embodiments, events in the CPU pipeline are used to calculate performance characteristic values. Optionally, the performance characteristic values ​​are calculated in real time based on real-time monitoring of events in the CPU pipeline. Optionally, the performance characteristic values ​​are obtained from hardware registers. Events in the CPU pipeline and / or performance characteristic values ​​calculated based on events in the CPU pipeline are stored in real time in the hardware registers.

[0392] For load characteristic value (base_CPI):

[0393] The monitoring module 150 is also used to monitor the number of cycles and the number of first instructions that are not related to the front-end memory access and the back-end memory access in the CPU pipeline. The number of cycles and the number of first instructions are used to calculate the load characteristic value.

[0394] In some embodiments, the load characteristic value does not need to be stored via a hardware register, but is directly calculated in real time based on monitoring events in the CPU pipeline.

[0395] In some embodiments, the number of cycles and the number of first instructions of the CPU that are not related to front-end memory access and back-end memory access in at least one cycle are monitored, the quotient of the number of cycles and the number of first instructions is directly calculated, and the quotient of the number of cycles and the number of first instructions is used as the load characteristic value.

[0396] In some embodiments, the number of cycles and the first number of instructions of the CPU that are unrelated to front-end memory access and back-end memory access in at least one cycle are monitored; the quotient of the number of cycles and the first number of instructions is used as a load characteristic value and stored in a first hardware register.

[0397] In some embodiments, the performance characteristic value includes a load characteristic value (base_CPI). The load characteristic value (base_CPI) is directly obtained based on the first hardware register. The load characteristic value (base_CPI) is related to the number of cycles of the CPU that are not related to front-end memory access and back-end memory access in at least one cycle and the number of first instructions.

[0398] In some embodiments, the first hardware memory stores a load characteristic value (base_CPI). In some embodiments, the first hardware memory stores a load characteristic value (base_CPI), a number of CPU cycles that are unrelated to front-end memory access and back-end memory access in at least one cycle, and a first instruction number.

[0399] The monitoring module 150 is also used to monitor the number of cycles and the number of first instructions of the CPU that are not related to front-end memory access and back-end memory access in at least one cycle; the number of cycles and the number of first instructions are stored in the second hardware register and the third hardware register respectively as values ​​for calculating the load characteristic value.

[0400] In some embodiments, the performance characteristic value includes a load characteristic value (base_CPI). The load characteristic value (base_CPI) is directly obtained based on the first hardware register. The load characteristic value (base_CPI) is related to the number of cycles of the CPU that are not related to front-end memory access and back-end memory access in at least one cycle and the number of first instructions.

[0401] At this time, the first hardware register is used to store the load characteristic value (base_CPI), the second hardware register is used to store the number of CPU cycles that are not related to front-end memory access and back-end memory access in at least one cycle, and the third hardware register is used to store the number of first instructions that are not related to front-end memory access and back-end memory access in at least one cycle of the CPU. Or, the first hardware register is used to store the load characteristic value (base_CPI), the second hardware register is used to store the number of first instructions that are not related to front-end memory access and back-end memory access in at least one cycle of the CPU, and the third hardware register is used to store the number of CPU cycles that are not related to front-end memory access and back-end memory access in at least one cycle.

[0402] For the memory access characteristic value (stall_SPI):

[0403] The monitoring module 150 is also used to monitor the number of second instructions that trigger front-end memory access and back-end memory access in the CPU pipeline and the stall time caused by the second instruction number. The second instruction number and the stall time are used to calculate the memory access characteristic value.

[0404] In some embodiments, the memory access characteristic value does not need to be stored through a hardware register, but is directly calculated in real time based on monitoring events in the CPU pipeline.

[0405] In some embodiments, the number of second instructions that trigger front-end memory access and back-end memory access in the CPU pipeline and the stall time caused by the second instruction number are monitored, the quotient of the second instruction number and the stall time caused by the second instruction number is directly calculated, and the quotient of the second instruction number and the stall time caused by the second instruction number is used as the memory access feature value.

[0406] In some embodiments, the number of second instructions that trigger front-end memory access and back-end memory access by the CPU in at least one cycle and the stall time caused by the second instruction number are monitored; the quotient of the stall time and the second instruction number is used as a memory access characteristic value and stored in a fourth hardware register.

[0407] In some embodiments, the performance characteristic value includes a memory access characteristic value (stall_SPI). The memory access characteristic value (stall_SPI) is directly obtained based on the fourth hardware register. The memory access characteristic value (stall_SPI) is related to the number of second instructions that trigger front-end memory access and back-end memory access by the CPU in at least one cycle and the stall time caused by the second instruction number.

[0408] In some embodiments, the fourth hardware memory stores a memory access characteristic value (stall_SPI). In some embodiments, the fourth hardware memory stores a memory access characteristic value (stall_SPI), a second instruction number of the CPU triggering front-end memory access and back-end memory access in at least one cycle, and a stall time caused by the second instruction number.

[0409] The monitoring module 150 is also used to monitor the number of second instructions that trigger front-end memory access and back-end memory access of the CPU in at least one cycle and the stagnation time caused by the second instruction number; the stagnation time and the second instruction number are stored in the fifth hardware register and the sixth hardware register respectively as values ​​for calculating the memory access characteristic value.

[0410] In some embodiments, the performance characteristic value includes a memory access characteristic value (stall_SPI). The memory access characteristic value (stall_SPI) is directly obtained based on the fourth hardware register. The memory access characteristic value (stall_SPI) is related to the number of second instructions that trigger front-end memory access and back-end memory access by the CPU in at least one cycle and the stall time caused by the second instruction number.

[0411] In some embodiments, when the performance characteristic value is stored in a hardware register, the acquisition module 110 is further configured to acquire the performance characteristic value of the previous cycle based on the hardware register.

[0412] In some embodiments, a load characteristic value (base_CPI) of a previous cycle is obtained based on a first hardware register.

[0413] In some embodiments, the number of CPU cycles that are independent of front-end memory access and back-end memory access in at least one cycle is obtained based on the second hardware register, and the number of first instructions that are independent of front-end memory access and back-end memory access in at least one cycle is obtained based on the third hardware register. Or, the number of first instructions that are independent of front-end memory access and back-end memory access in at least one cycle is obtained based on the second hardware register, and the number of CPU cycles that are independent of front-end memory access and back-end memory access in at least one cycle is obtained based on the third hardware register. The load characteristic value (base_CPI) of the previous cycle is equal to the quotient of the number of cycles and the first number of instructions.

[0414] In some embodiments, a memory access characteristic value (stall_SPI) of a previous cycle is obtained based on a fourth hardware register.

[0415] In some embodiments, the second instruction number that triggers the front-end memory access and the back-end memory access of the CPU in at least one cycle is obtained based on the fifth hardware register, and the stall time caused by the second instruction number is obtained based on the sixth hardware register. Or, the stall time caused by the second instruction number is obtained based on the fifth hardware register, and the second instruction number that triggers the front-end memory access and the back-end memory access of the CPU in at least one cycle is obtained based on the sixth hardware register. The memory access characteristic value (stall_SPI) of the previous cycle is equal to the quotient of the stall time and the second instruction number.

[0416] In some embodiments, the performance requirement value in the later period is predicted based on the following two methods:

[0417] Prediction method 1: directly use the performance requirement value of the previous cycle as the performance requirement value of the next cycle;

[0418] Forecasting method 2: forecasting based on the performance demand value in the previous cycle and the performance demand value in at least one historical cycle.

[0419] For prediction method 1:

[0420] In some embodiments, the performance requirement value in the later cycle is predicted based on the performance requirement value in the previous cycle.

[0421] In some embodiments, the performance requirement value in the previous cycle is directly used as the performance requirement value in the next cycle.

[0422] The prediction module 120 is further configured to use the performance requirement value in the previous cycle as the performance requirement value in the next cycle.

[0423] In some embodiments, the performance requirement value in the previous cycle is equal to the ratio of the number of instructions executed by the CPU in the previous cycle to the cycle time.

[0424] For example, Among them, demand_ips represents the performance demand value, instructions represents the number of instructions executed by the CPU in the previous cycle, and period_time represents the cycle time.

[0425] In some embodiments, the performance requirement value in the subsequent cycle is determined based on the performance requirement value in the previous cycle and the performance requirement value of at least one historical cycle.

[0426] For prediction method 2:

[0427] The prediction module 120 is further configured to predict a performance requirement value in a subsequent cycle based on a sliding average of a performance requirement value in a previous cycle and a performance requirement value in at least one historical cycle.

[0428] In some embodiments, in order to avoid the negative impact of multiple data on the prediction of the performance requirement value, the performance requirement value in the next cycle is predicted based on the sliding average of the performance requirement value in the previous cycle and the performance requirement value in the most recent historical cycle. Exemplarily, the calculation formula of the performance requirement value in the next cycle is as follows:

[0429] demand_ips[n]=α*ips[n]+(1-α)*ips[n-1]

[0430] Among them, demand_ips[n] represents the predicted performance demand value in the next cycle, α represents the coefficient, ips[n] represents the performance demand value in the previous cycle, and ips[n-1] represents the performance demand value in the most recent historical cycle.

[0431] In some embodiments, when α=1, the performance requirement value in the previous cycle is directly used as the performance requirement value in the next cycle.

[0432] In some embodiments, after the performance characteristic value is obtained and the performance requirement value is predicted, the predicted frequency range in the subsequent cycle is determined based on a preset correspondence between the performance characteristic value, the performance requirement value and the CPU frequency.

[0433] The determination module 130 is further configured to take the performance characteristic value in the previous cycle and the performance requirement value in the next cycle as input, and determine the minimum CPU frequency value and the maximum CPU frequency value based on a preset corresponding relationship.

[0434] In some embodiments, the preset correspondence relationship is predetermined. Fig.21 As shown, the preset corresponding relationship is represented by a three-dimensional mapping table, wherein the x-axis represents the memory access characteristic value, the y-axis represents the load characteristic value, and the z-axis represents the CPU frequency.

[0435] In some embodiments, the preset correspondence includes a correspondence between a performance characteristic value, a performance requirement value, and a CPU frequency.

[0436] In some embodiments, the preset correspondence is a non-linear correspondence.

[0437] In some embodiments, the performance characteristic value in the previous cycle and the performance requirement value in the next cycle are used as input, and the minimum CPU frequency value is queried in the preset corresponding relationship.

[0438] In some embodiments, the difference between the inverse of the performance requirement value in the later cycle and the memory access characteristic value (stall_SPI) is equal to the quotient of the load characteristic value (base_CPI) and the CPU frequency.

[0439] Among them, SPI represents the execution time required for each instruction in the current cycle, IPS represents the number of instructions executed per unit time, base_CPI represents the load characteristic value, cpufreq represents the CPU frequency, and stall_SPI represents the memory access characteristic value.

[0440] In some embodiments, when the performance characteristic value of the previous cycle and the performance requirement value of the next cycle are known, the minimum CPU frequency value is determined based on a preset corresponding relationship.

[0441] In some embodiments, the preset corresponding relationship is represented by a curve.

[0442] In some embodiments, the maximum value of the CPU frequency is determined based on the acceleration ratio corresponding to the minimum value of the CPU frequency in the preset correspondence. The difference between the first preset performance value corresponding to the maximum value of the CPU frequency and the second preset performance value corresponding to the minimum value of the CPU frequency is positively correlated with the acceleration ratio. Optionally, the acceleration ratio is represented by a slope or a gradient. Wherein, when the preset correspondence is represented by a two-dimensional curve, the maximum value of the CPU frequency is determined based on the slope corresponding to the minimum value of the CPU frequency. When the preset correspondence is represented by a three-dimensional curve, the maximum value of the CPU frequency is determined based on the gradient corresponding to the minimum value of the CPU frequency. Optionally, the acceleration ratio of the minimum value of the CPU frequency at the curve is pre-calculated. Optionally, the acceleration ratio of the minimum value of the CPU frequency at the curve is calculated in real time.

[0443] The determination module 130 is further configured to determine a predicted frequency range in a subsequent cycle based on the minimum CPU frequency and the maximum CPU frequency.

[0444] In some embodiments, the minimum CPU frequency value determined based on the preset corresponding relationship is used as the minimum value of the predicted frequency range, and the maximum CPU frequency value determined based on the preset corresponding relationship is used as the maximum value of the predicted frequency range.

[0445] In some embodiments, since there are multiple demand ends that need to adjust the CPU frequency, in the process of determining the minimum CPU frequency and the maximum CPU frequency, the priorities corresponding to different demand ends may be determined. Fig. 22As shown, multiple demand ends are sorted according to priority: temperature control demand corresponds to the first priority, frame stabilizer demand corresponds to the second priority, IPS demand corresponds to the third priority, flash drive demand corresponds to the fourth priority, and user scenario demand corresponds to the fifth priority. Determining the minimum CPU frequency and the maximum CPU frequency according to the priority is conducive to avoiding conflicts between multiple demand ends when determining the minimum CPU frequency and the maximum CPU frequency, and is conducive to ensuring that high-priority demands are met first.

[0446] In some embodiments, after the predicted frequency range is determined, the CPU frequency in the subsequent cycle can be adjusted based on the predicted frequency range.

[0447] In some embodiments, the CPU frequency is adjusted in two ways:

[0448] Adjustment method 1: first determine the first operating frequency based on the first frequency modulator, and then adjust the first operating frequency based on the predicted frequency range to obtain the second operating frequency;

[0449] Adjustment method 2: firstly adjust the working parameters of the second frequency modulator based on the predicted frequency range, and then determine the third working frequency based on the adjusted second frequency modulator.

[0450] For adjustment method 1:

[0451] The adjustment module 140 is further configured to obtain a first operating frequency determined by the first CPU frequency regulator based on the load in the subsequent cycle.

[0452] In some embodiments, the first CPU frequency regulator is used to determine the operating frequency of the CPU based on the load. Optionally, the first CPU frequency regulator is used to determine the first operating frequency based on the load in the subsequent cycle.

[0453] The adjustment module 140 is further configured to adjust the first operating frequency based on the predicted frequency range to obtain a second operating frequency in a subsequent period.

[0454] In some embodiments, based on the predicted frequency range, it is determined whether the first operating frequency is within the predicted frequency range.

[0455] In some embodiments, if the first operating frequency is within the predicted frequency range, the first operating frequency is directly used as the second operating frequency in the subsequent cycle. That is, the first operating frequency is equal to the second operating frequency. Optionally, when the first operating frequency is greater than or equal to the minimum CPU frequency and less than or equal to the maximum CPU frequency, the first operating frequency is used as the second operating frequency in the subsequent cycle.

[0456] In some embodiments, if the first operating frequency is not within the predicted frequency range, the frequency within the predicted frequency range that is closest to the first operating frequency is used as the second operating frequency in the later cycle. Exemplarily, assuming that the first operating frequency is 1000MHz and the predicted frequency range is 500MHz to 800MHz, since the first operating frequency is greater than the maximum frequency, that is, the first operating frequency is closest to the maximum frequency in the predicted frequency range, 800MHz corresponding to the maximum frequency is used as the second operating frequency. Optionally, when the first operating frequency is greater than the maximum CPU frequency, the maximum CPU frequency is used as the second operating frequency in the later cycle. Optionally, when the first operating frequency is less than the minimum CPU frequency, the minimum CPU frequency is used as the second operating frequency in the later cycle.

[0457] For adjustment method 2:

[0458] The adjustment module 140 is further configured to set working parameters of the second CPU frequency regulator based on the predicted frequency range.

[0459] In some embodiments, the predicted frequency range is used to set operating parameters of a second CPU frequency regulator, and the second CPU frequency regulator is used to determine the operating frequency of the CPU based on the load.

[0460] The adjustment module 140 is further configured to determine a third operating frequency in the subsequent cycle based on the load in the subsequent cycle through the configured second CPU frequency regulator.

[0461] Fig.26 The schematic diagram of the structure of a computer device provided by an exemplary embodiment of the present application is shown. Schematically, the computer device 1100 includes a central processing unit (CPU) 1101, a system memory 1104 including a random access memory (RAM) 1102 and a read-only memory (ROM) 1103, and a system bus 1105 connecting the system memory 1104 and the central processing unit 1101. The computer device 1100 also includes a basic input / output system 1106 that helps transmit information between various devices in the computer, and a large-capacity storage device 1107 for storing an operating system 1113, application programs 1114 and other program modules 1115.

[0462] The basic input / output system 1106 includes a display 1108 for displaying information and an input device 1109 such as a mouse, keyboard or touch screen for user input information. The display 1108 and the input device 1109 are connected to the central processing unit 1101 through an input / output controller 1110 connected to the system bus 1105. The basic input / output system 1106 may also include an input / output controller 1110 for receiving and processing inputs from multiple other devices such as a keyboard, a mouse, or a touch screen. Similarly, the input / output controller 1110 also provides output to a display screen, a printer or other types of output devices.

[0463] The mass storage device 1107 is connected to the central processing unit 1101 through a mass storage controller (not shown) connected to the system bus 1105. The mass storage device 1107 and its associated computer readable media provide non-volatile storage for the computer device 1100. That is, the mass storage device 1107 may include a computer readable medium (not shown) such as a hard disk or a Compact Disc Read-Only Memory (CD-ROM) drive.

[0464] Computer readable media may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), flash memory or other solid-state storage technology, CD-ROM, Digital Versatile Disc (DVD) or other optical storage, cassettes, tapes, disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that computer storage media are not limited to the above. The above-mentioned system memory 1104 and mass storage device 1107 can be collectively referred to as memory.

[0465] According to various embodiments of the present application, the computer device 1100 can also be connected to a remote computer on the network through a network such as the Internet. That is, the computer device 1100 can be connected to the network 1112 through the network interface unit 1111 connected to the system bus 1105, or the network interface unit 1111 can be used to connect to other types of networks or remote computer systems (not shown).

[0466] An exemplary embodiment of the present application further provides a computer-readable storage medium, in which at least one program is stored. The at least one program is loaded and executed by a processor to implement the CPU frequency modulation method provided by each of the above method embodiments.

[0467] An exemplary embodiment of the present application also provides a computer program product, which includes at least one program, and the at least one program is stored in a readable storage medium; the processor of the communication device reads the signaling from the readable storage medium, and the processor executes the signaling, so that the communication device executes to implement the CPU frequency modulation method provided by the above-mentioned various method embodiments.

[0468] It should be understood that the "plurality" mentioned in this article refers to two or more. Those skilled in the art will easily think of other embodiments of the present application after considering the specification and practicing the invention disclosed here. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary technical means in the art that are not disclosed in the present application. The description and examples are only regarded as exemplary, and the true scope and spirit of the present application are indicated by the following claims.

[0469] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0470] The above are only optional embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent switches, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A method for frequency modulation of a central processing unit (CPU), characterized in that: The method is performed by a computer device, and the method comprises: Acquire a performance characteristic value of a previous cycle, wherein the performance characteristic value is used to characterize a performance characteristic of an instruction granularity; Predicting a performance requirement value in a later cycle, wherein the performance requirement value is used to indicate a performance requirement of an instruction granularity; Determining a predicted frequency range of the subsequent cycle based on the performance characteristic value of the previous cycle and the performance requirement value of the subsequent cycle; Based on the predicted frequency range, the CPU frequency in the subsequent cycle is adjusted.

2. The method according to claim 1, characterized in that The determining, based on the performance characteristic value of the previous cycle and the performance requirement value of the subsequent cycle, a predicted frequency range of the subsequent cycle includes: Taking the performance characteristic value of the previous cycle and the performance requirement value of the subsequent cycle as input, determining a minimum CPU frequency value and a maximum CPU frequency value based on a preset corresponding relationship; Determining the predicted frequency range of the subsequent cycle based on the CPU minimum value and the CPU frequency maximum value; The preset corresponding relationship includes the corresponding relationship between the performance characteristic value, the performance requirement value and the CPU frequency.

3. The method according to claim 2, characterized in that The step of taking the performance characteristic value of the previous cycle and the performance requirement value of the subsequent cycle as input and determining the minimum CPU frequency value and the maximum CPU frequency value based on a preset corresponding relationship includes: Taking the performance characteristic value of the previous cycle and the performance requirement value of the subsequent cycle as input, querying the minimum CPU frequency value in the preset corresponding relationship; Determine the maximum value of the CPU frequency based on the acceleration ratio corresponding to the minimum value of the CPU frequency in the preset corresponding relationship; The preset corresponding relationship is represented by a curve, and the difference between the first preset performance value corresponding to the maximum value of the CPU frequency and the second preset performance value corresponding to the minimum value of the CPU frequency is positively correlated with the acceleration ratio.

4. The method according to any one of claims 1 to 3, characterized in that: The obtaining of the performance characteristic value in the previous cycle includes: Acquire monitoring data of the performance monitoring hardware unit in the previous cycle, wherein the performance monitoring hardware unit includes at least one register for monitoring CPU performance; Based on the monitoring data, the performance characteristic value of the previous cycle is calculated, and the performance characteristic value is used to characterize the factors that affect the number of instructions per second or the time required for each instruction.

5. The method according to claim 4, characterized in that The monitoring data includes the number of times each instruction of at least two levels of cache is refilled in the previous cycle, and the performance characteristic value includes a memory access characteristic value, and the memory access characteristic value is used to indicate the access consumption time caused by each instruction accessing storage; The calculating, based on the monitoring data, the performance characteristic value of the previous cycle includes: The fitting parameters respectively corresponding to the at least two levels of cache are used as weights, and the weight sum of the number of refills per instruction of the at least two levels of cache in the previous cycle is calculated, and the weight sum is used as the access characteristic value.

6. The method according to claim 5, characterized in that Different CPU architectures correspond to different fitting parameters.

7. The method according to any one of claims 1 to 3, characterized in that: The monitoring data includes at least two operating frequencies of the CPU in the previous cycle and the running time and number of executed instructions at the at least two operating frequencies; the performance characteristic value includes a memory access characteristic value, and the memory access characteristic value is used to indicate the access consumption time caused by accessing storage for each instruction; The calculating, based on the monitoring data, the performance characteristic value of the previous cycle includes: Based on the running time and the number of executed instructions at the first operating frequency, a first SPI of the CPU load of the current cycle at the first operating frequency is calculated, and a first product of the first SPI and the first operating frequency is calculated; Based on the running time and the number of executed instructions at the second operating frequency, a second SPI of the CPU load of the current cycle at the second operating frequency is calculated, and a first product of the second SPI and the second operating frequency is calculated; Calculating a first difference between the first product and the second product; calculating a second difference between the first operating frequency and the second operating frequency; The quotient of the first difference value and the second difference value is used as the memory access feature value.

8. The method according to any one of claims 4 to 7, characterized in that: The performance characteristic value also includes a load characteristic value, which is used to indicate the number of cycles consumed by each instruction that is unrelated to the front-end memory access and the back-end memory access in the CPU pipeline; the monitoring data includes the running time and the number of instructions executed by the CPU in the previous cycle; The calculating, based on the monitoring data, the performance characteristic value of the previous cycle includes: Calculate the quotient of the CPU's running time in the previous cycle and the number of executed instructions to obtain the execution time SPI required for each instruction in the current cycle; The load characteristic value is calculated based on the memory access characteristic value and the SPI.

9. The method according to claim 8, characterized in that The calculating the load characteristic value based on the memory access characteristic value and the SPI includes: Calculating a difference between the SPI and the memory access characteristic value; Calculate the quotient of the CPU operation cycle and the CPU operation time to obtain the CPU frequency of the current cycle; The product of the difference and the CPU frequency is calculated as the load characteristic value.

10. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Monitor events in the CPU pipeline; The obtaining of the performance characteristic value in the previous cycle includes: A performance characteristic value of the previous cycle is obtained based on an event in the CPU pipeline.

11. The method according to claim 10, characterized in that The performance characteristic value includes a load characteristic value, and the monitoring of events in the CPU pipeline includes: The number of cycles and the first number of instructions that are unrelated to the front-end memory access and the back-end memory access in the CPU pipeline are monitored, and the number of cycles and the first number of instructions are used to calculate the load characteristic value.

12. The method according to claim 10, characterized in that The performance monitoring value includes a memory access characteristic value, and the monitoring of events in the CPU pipeline includes: The number of second instructions triggering front-end memory access and back-end memory access in the CPU pipeline and the stall time caused by the second number of instructions are monitored, and the second number of instructions and the stall time are used to calculate the memory access characteristic value.

13. The method according to any one of claims 1 to 3, characterized in that: The predicted performance requirement value in the later period includes: Using the performance requirement value of the previous cycle as the performance requirement value of the subsequent cycle; or, Predicting the performance requirement value of the subsequent period based on the performance requirement value of the previous period and a sliding average of the performance requirement value of at least one historical period; The performance requirement value of the previous cycle is equal to the ratio of the number of instructions executed by the CPU in the previous cycle to the cycle time.

14. The method according to any one of claims 1 to 3, characterized in that: Adjusting the CPU frequency in the subsequent cycle based on the predicted frequency range includes: Acquire a first operating frequency determined by the first CPU frequency regulator based on the load in the latter cycle; Based on the predicted frequency range, the first operating frequency is adjusted to obtain the second operating frequency in the subsequent period; or, Setting operating parameters of a second CPU frequency regulator based on the predicted frequency range; The third operating frequency in the subsequent cycle is determined based on the load in the subsequent cycle by the configured second CPU frequency regulator.

15. A CPU frequency modulation device, characterized in that: The device comprises: An acquisition module, used for acquiring a performance characteristic value of a previous cycle, wherein the performance characteristic value is used for characterizing a performance characteristic of an instruction granularity; A prediction module, used to predict a performance requirement value in a later cycle, wherein the performance requirement value is used to indicate a performance requirement of an instruction granularity; A determination module, configured to determine a predicted frequency range of the subsequent cycle based on the performance characteristic value of the previous cycle and the performance requirement value of the subsequent cycle; An adjustment module is used to adjust the CPU frequency in the subsequent cycle based on the predicted frequency range.

16. A computer device, characterized in that: The computer device comprises: a processor and a memory, wherein at least one program is stored in the memory, and the at least one program is loaded and executed by the processor to implement the CPU frequency modulation method according to any one of claims 1 to 14.

17. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one program, and the at least one program is loaded and executed by a processor to implement the CPU frequency modulation method according to any one of claims 1 to 14.

18. A computer program product, characterized in that The computer program product includes at least one program segment, and the at least one program segment is stored in a computer-readable storage medium; the processor of the computer device reads the at least one program segment from the computer-readable storage medium, and the processor executes the at least one program segment, so that the computer device executes the CPU frequency modulation method as described in any one of claims 1 to 14.

Citation Information

Cited By

  • Intelligent control method and system for frequency modulation of CPU based on big data

    CN121349590A

  • An intelligent control method and system for CPU frequency adjustment based on big data

    CN121349590B