Processor frequency modulation method, device, equipment, medium and program product
By dividing the processor core into multiple core groups and dynamically adjusting the frequency and power consumption, the problem of stability during full load operation in the existing technology is solved, and reasonable resource allocation and stability of the processor under full load are achieved. Running in a stateful state improves system performance.
Patent Information
- Application Number
- CN202410834409.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-06-26
AI Technical Summary
Existing processor frequency regulation solutions are difficult to ensure stability when running at full load, and power consumption adjustment is inconsistent with full load, resulting in unreasonable resource allocation.
Divide the processor core into multiple core groups, set the frequency range and group priority according to task priority, and iteratively adjust the frequency and power consumption average of the core group to ensure reasonable resource allocation and steady-state operation under full load. .
Through the dynamic adjustment of core group frequency and power consumption, the steady-state operation of the processor under full load is achieved, resources are reasonably allocated, and system performance is improved.
Smart Images

Figure CN118377626B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a processor frequency modulation method, device, equipment, medium and program product. Background Art
[0002] The current processor frequency adjustment scheme is generally designed for the purpose of saving energy consumption, which can make the power consumption distribution of different processor cores more reasonable. However, the purpose of saving energy consumption is contrary to the full load of the processor, and it is not suitable for power consumption adjustment when the processor is fully loaded. Therefore, in the case of high energy consumption when the processor is fully loaded, how to ensure the operation stability of the full load state is a problem that technicians in this field need to solve. Summary of the invention
[0003] In view of this, the purpose of the present invention is to provide a processor frequency modulation method, device, equipment, medium and program product to ensure the operation stability of the full-load state under the high energy consumption condition of the processor running at full load. The specific scheme is as follows:
[0004] In a first aspect, the present invention provides a processor frequency modulation method, comprising:
[0005] Divide multiple processor cores into N core groups, and set the frequency range and group priority corresponding to each core group; wherein the group priority of the core group to which any processor core belongs is consistent with the priority of the task bound to the processor core, and the number of processor cores included in any core group matches the group priority of the corresponding core group;
[0006] Under the constraints of the frequency range corresponding to each core group, the tasks bound to the processor cores in each core group are run, and the average power consumption and frequency of each processor core are determined during the running process;
[0007] If it is the first iteration, the processor cores are regrouped according to the frequency averages of the processor cores to update N core groups;
[0008] After determining the frequency ranges and group priorities corresponding to the updated N core groups, executing the steps of running the tasks bound to the processor cores in each core group under the constraints of the frequency ranges corresponding to each core group, and determining the average power consumption and the average frequency of each processor core during the running process, so as to obtain the current average power consumption and the current average frequency of each processor core;
[0009] If it is not the first iteration, the number of iterations is increased by one. When the current average power consumption does not exceed the power consumption threshold and the previous average power consumption exceeds the power consumption threshold, the steps of running the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group and determining the average power consumption and frequency of each processor core during the running process are executed; when the average power consumption does not exceed the power consumption threshold for two consecutive times, the current round of frequency modulation process is terminated.
[0010] On the other hand, multiple processor cores are divided into N core groups, and the frequency range and group priority corresponding to each core group are set, including:
[0011] Set N group priorities and the number of processor cores that match the corresponding group priorities;
[0012] Divide the plurality of processor cores according to the number of the processor cores to obtain N core groups;
[0013] The upper frequency limit of the N core groups is set to the highest frequency of the processor, and the lower frequency limit is set to the lowest frequency of the processor, so as to obtain the frequency range corresponding to each core group.
[0014] On the other hand, the processor cores are regrouped according to the magnitude of the frequency averages of the processor cores to update the N core groups, and the frequency ranges and group priorities corresponding to the updated N core groups are determined, including:
[0015] Arrange the frequency mean values of each processor core in descending order to obtain a frequency sequence;
[0016] According to the number of processor cores matched by the N group priorities, the frequency sequence is divided into N segments to obtain updated N core groups arranged from high to low group priorities;
[0017] For the core group with the highest group priority among the updated N core groups, the frequency upper limit of the core group is set to the highest frequency of the processor, and the previous average of the minimum frequencies of the processor cores in the core group is used as the frequency lower limit to obtain the frequency range corresponding to the core group;
[0018] For the core group with the lowest group priority among the updated N core groups, the frequency lower limit of the core group is set to the lowest frequency of the processor, and the average of the previous maximum frequencies of the processor cores in the core group is used as the frequency upper limit to obtain the frequency range corresponding to the core group;
[0019] For the core groups of other group priorities in the updated N core groups, the average of the previous maximum frequencies of each processor core in the corresponding core group is used as the frequency upper limit, and the average of the previous minimum frequencies of each processor core in the corresponding core group is used as the frequency lower limit to obtain the frequency range corresponding to the corresponding core group.
[0020] On the other hand, it also includes:
[0021] When the current average power consumption exceeds the power consumption threshold, determining whether there is at least one processor core in the updated core group with the highest group priority whose average frequency exceeds the highest frequency of the processor;
[0022] If so, the next iteration is entered, and the steps of running the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group and determining the average power consumption and frequency of each processor core during the running process are executed.
[0023] On the other hand, it also includes:
[0024] When the current average power consumption exceeds the power consumption threshold, determining whether the updated average frequencies of the processor cores in the core group with the highest group priority all exceed the highest frequency of the processor;
[0025] If yes, then determine an updated second core group; the group priority of the second core group is one level lower than the highest group priority;
[0026] After increasing the frequency upper limit of the second core group, enter the next iteration and execute the steps of running the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determining the average power consumption and frequency of each processor core during the running process.
[0027] On the other hand, increasing the upper frequency limit of the second core group includes:
[0028] Increase the upper frequency limit of the second core group according to the first formula; the first formula is: FD new-max-2 =F old-max-2 +a×(F old-max-2 -F old-min-2 );
[0029] Among them, FD new-max-2 is the increased upper frequency limit of the second core group, F old-max-2 To increase the upper frequency limit of the second core group, F old-min-2 To increase the previous lower limit of the frequency of the second core group, a is a preset first coefficient.
[0030] On the other hand, it also includes:
[0031] If the frequency average of each processor core in the core group with the highest group priority does not exceed the highest frequency of the processor, the frequency upper limit of the second core group is reduced, and the next iteration is entered, and the tasks bound to the processor cores in each core group are run under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and frequency of each processor core during the running process are executed.
[0032] On the other hand, reducing the upper frequency limit of the second core group includes:
[0033] The frequency upper limit of the second core group is reduced according to a second formula; the second formula is: FX new-max-2 =F old-max-2 -b×(F old-max-2 -F old-min-2 );
[0034] Among them, FX new-max-2 is the upper frequency limit of the second core group after reduction, F old-max-2 To reduce the upper frequency limit of the second core group, F old-min-2 In order to reduce the previous lower limit of the frequency of the second core group, b is a preset second coefficient.
[0035] On the other hand, it also includes:
[0036] When two consecutive average power consumption values exceed the power consumption threshold, if the difference between the two consecutive average power consumption values and the difference between the two consecutive average frequencies meet the preset first condition, the current round of frequency modulation process is terminated.
[0037] On the other hand, the calculation process of the difference between two consecutive power consumption averages and the difference between two consecutive frequency averages includes:
[0038] The previous power consumption average and the previous frequency average are constructed as a first vector;
[0039] constructing the current power consumption mean and the current frequency mean into a second vector;
[0040] Subtracting the first vector from the second vector to obtain a vector difference;
[0041] Take the modulus of the vector difference.
[0042] On the other hand, the difference between two consecutive power consumption averages and the difference between two consecutive frequency averages meet the preset first condition, including: the modulus result of the vector difference is less than the first target value.
[0043] On the other hand, it also includes:
[0044] If the difference between the two consecutive average power consumption values and the difference between the two consecutive average frequency values do not meet the preset first condition, the next iteration is entered, and the tasks bound to the processor cores in each core group are run under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and frequency of each processor core during the running process are executed.
[0045] On the other hand, it also includes:
[0046] After the current round of frequency modulation process is completed, the current power consumption average and the current frequency average are stored;
[0047] After waiting for a preset time, determine the target power consumption average and target frequency average of each processor core;
[0048] If the difference between the current average power consumption and the target average power consumption, and the difference between the current average frequency and the target average frequency meet the preset second condition, the next round of frequency modulation process is activated, and the tasks bound to the processor cores in each core group are run under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and average frequency of each processor core during the running process are executed.
[0049] On the other hand, the target power consumption mean and the target frequency mean are constructed as a third vector;
[0050] constructing the current power consumption mean and the current frequency mean into a fourth vector;
[0051] Subtracting the third vector from the fourth vector to obtain a vector difference;
[0052] If the modulus result of the vector difference is greater than the second target value, the preset second condition is met; otherwise, the preset second condition is not met.
[0053] On the other hand, it also includes:
[0054] If the difference between the current average power consumption and the target average power consumption, and the difference between the current average frequency and the target average frequency do not meet the preset second condition, then the step of determining the target average power consumption and target average frequency of each processor core after waiting for a preset period of time is executed.
[0055] On the other hand, the average frequency of any processor core is calculated as:
[0056] ;
[0057] in, f corei For the processor core i The frequency mean of f 1 is the frequency value collected for the first time, fx For the x The frequency value of the acquisition, f nt For the nt The frequency value of the acquisition.
[0058] In another aspect, the present invention provides a processor frequency modulation device, comprising:
[0059] A partitioning module is used to partition multiple processor cores into N core groups, and set the frequency range and group priority corresponding to each core group; wherein the group priority of the core group to which any processor core belongs is consistent with the priority of the task bound to the processor core, and the number of processor cores included in any core group matches the group priority of the corresponding core group;
[0060] An operation module, used to run the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determine the average power consumption and frequency of each processor core during the operation process;
[0061] A grouping module, for regrouping the processor cores according to the frequency averages of the processor cores to update N core groups if it is the first iteration;
[0062] An execution module, configured to, after determining the frequency ranges and group priorities corresponding to the updated N core groups, execute the steps of running the tasks bound to the processor cores in each core group under the constraints of the frequency ranges corresponding to each core group, and determining the average power consumption and the average frequency of each processor core during the running process, so as to obtain the current average power consumption and the current average frequency of each processor core;
[0063] The iteration module is used to increase the number of iterations by one if it is not the first iteration, and to execute the steps of running the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determining the power consumption average and frequency average of each processor core during the running process, if the current power consumption average does not exceed the power consumption threshold and the previous power consumption average exceeds the power consumption threshold if the current power consumption average does not exceed the power consumption threshold and the previous power consumption average exceeds the power consumption threshold if the current power consumption average does not exceed the power consumption threshold if the previous power consumption average exceeds the power consumption threshold if the current frequency modulation process ends.
[0064] In another aspect, the present invention provides an electronic device, comprising:
[0065] Memory for storing computer programs;
[0066] The processor is used to execute the computer program to implement the processor frequency modulation method disclosed above.
[0067] In a fourth aspect, the present invention provides a non-volatile storage medium for storing a computer program, wherein the computer program implements the aforementioned processor frequency modulation method when executed by a processor.
[0068] On the other hand, the present invention provides a computer program product, comprising a computer program / instruction, which implements the steps of the processor frequency modulation method disclosed above when executed by a processor.
[0069] The beneficial effects of the present invention are as follows: after dividing multiple processor cores into N core groups and setting the frequency range and group priority corresponding to each core group, the core group and its frequency constraint range are iteratively adjusted according to the running conditions of the tasks on each processor core, so that each processor core can reasonably implement resource allocation under full load and ensure the operational stability under full load.
[0070] Correspondingly, a processor frequency modulation device, equipment, medium and program product provided by the present invention also have the above-mentioned technical effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0072] Figure 1 A flow chart of a processor frequency modulation method disclosed in the present invention;
[0073] Figure 2 This is an architecture diagram of a processor frequency modulation solution disclosed in the present invention;
[0074] Figure 3 It is a flow chart of another processor frequency modulation method disclosed in the present invention;
[0075] Figure 4 A schematic diagram of a processor frequency modulation device disclosed in the present invention;
[0076] Figure 5 A schematic diagram of an electronic device disclosed in the present invention;
[0077] Figure 6 A server structure diagram provided by the present invention;
[0078] Figure 7 A terminal structure diagram provided by the present invention. DETAILED DESCRIPTION
[0079] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other examples obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0080] At present, processor frequency modulation schemes are generally designed for the purpose of saving energy consumption, which can make the power consumption distribution of different processor cores more reasonable. However, the purpose of saving energy consumption is contrary to the full load of the processor, and it is not suitable for power consumption adjustment under the full load operation of the processor. To this end, the present invention provides a processor frequency modulation scheme, which can ensure the operation stability of the full load state under the high energy consumption condition of the processor running at full load.
[0081] See also Figure 1 As shown, an embodiment of the present invention discloses a processor frequency modulation method, including:
[0082] S101. Divide multiple processor cores into N core groups, and set a frequency range and a group priority corresponding to each core group.
[0083] For example, 10 processor cores are divided into 3 core groups: core group 1, core group 2, and core group 3. It is stipulated that core group 1 includes at most 3 processor cores, core group 2 includes at most 5 processor cores, and core group 3 includes at most 6 processor cores. Then, by dividing these 10 processor cores, a division example can be obtained: core group 1 includes 3 processor cores, core group 2 includes 4 processor cores, and core group 3 includes 3 processor cores.
[0084] Among them, the group priority of the core group to which any processor core belongs is consistent with the priority of the task bound to the processor core, and the number of processor cores included in any core group matches the group priority of the corresponding core group. In other words, each processor core is bound to a task, and the priority of the task is consistent with the group priority of the core group to which the current processor core belongs. For example: the task priority of task 1 bound to processor core 1 is the highest level, then processor core 1 should be divided into the core group with the highest group priority. If the task binding operation is completed before the division operation, S101 can be executed according to the priority of the task bound to the processor core; if the division operation is completed before the task binding operation, S101 is executed according to the number of processor cores specified by each group priority.
[0085] In one embodiment, multiple processor cores are divided into N core groups, and the frequency range and group priority corresponding to each core group are set, including: setting N group priorities and the number of processor cores that match the corresponding group priorities; dividing multiple processor cores according to the number of processor cores to obtain N core groups; setting the upper frequency limit of the N core groups to the highest frequency of the processor, and the lower frequency limit to the lowest frequency of the processor, to obtain the frequency range corresponding to each core group.
[0086] S102: Under the constraints of the frequency range corresponding to each core group, run the tasks bound to the processor cores in each core group, and determine the average power consumption and frequency of each processor core during the running process.
[0087] S103: Determine whether the current iteration is the first one; if so, execute S104; if not, execute S106.
[0088] S104 . Regroup the processor cores according to the magnitude of the frequency averages of the processor cores to update N core groups.
[0089] S105 . Determine the frequency ranges and group priorities corresponding to the updated N core groups, and execute S102 , thereby obtaining the current average power consumption and the current average frequency of each processor core.
[0090] It can be seen that after determining the frequency ranges and group priorities corresponding to the updated N core groups, the tasks bound to the processor cores in each core group are executed under the constraints of the frequency ranges corresponding to each core group, and the steps of determining the average power consumption and average frequency of each processor core are performed during the running process to obtain the current average power consumption and current average frequency of each processor core.
[0091] In one implementation, each processor core is regrouped according to the size of the frequency mean of each processor core to update N core groups, and the frequency range and group priority corresponding to the updated N core groups are determined, including: arranging the frequency mean of each processor core in descending order to obtain a frequency sequence; dividing the frequency sequence into N segments according to the number of processor cores matching the N group priorities to obtain updated N core groups whose group priorities are arranged from high to low; for the core group with the highest group priority among the updated N core groups, setting the frequency upper limit of the core group to the highest frequency of the processor, and setting the frequency of each processor core in the core group to the highest frequency. The previous minimum frequency average is used as the frequency lower limit to obtain the frequency range corresponding to the core group; for the core group with the lowest group priority among the updated N core groups, the frequency lower limit of the core group is set to the lowest frequency of the processor, and the previous maximum frequency average of each processor core in the core group is used as the frequency upper limit to obtain the frequency range corresponding to the core group; for the core groups with other group priorities among the updated N core groups, the previous maximum frequency average of each processor core in the corresponding core group is used as the frequency upper limit, and the previous minimum frequency average of each processor core in the corresponding core group is used as the frequency lower limit to obtain the frequency range corresponding to the corresponding core group.
[0092] In the first iteration, the N core groups and their frequency ranges and group priorities are adjusted through S105. In the second and subsequent iterations, S106-S107 are executed to perform an iteration cycle and determine whether to end the current round of frequency adjustment.
[0093] S106. Increase the number of iterations by one.
[0094] S107. When the current average power consumption does not exceed the power consumption threshold and the previous average power consumption exceeds the power consumption threshold, execute S102 and other subsequent steps; when the average power consumption does not exceed the power consumption threshold for two consecutive times, end this round of frequency modulation process.
[0095] It should be noted that if the number of iterations after the increase is greater than the preset value, the preset value is 1, so it can be judged again whether it is not the first iteration. If it is not the first iteration, the following steps can also be performed: when the current average power consumption exceeds the power consumption threshold, determine whether there is at least one processor core in the core group with the highest group priority after the update whose average frequency exceeds the highest frequency of the processor; if so, enter the next iteration (i.e., enter the third iteration), and execute the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determine the steps of the average power consumption and average frequency of each processor core during the operation.
[0096] In one embodiment, if it is not the first iteration, the following steps may also be performed: when the current average power consumption exceeds the power consumption threshold, determine whether the average frequency of each processor core in the core group with the highest group priority after the update exceeds the highest frequency of the processor; if so, determine the updated second core group; the group priority of the second core group is one level lower than the highest group priority; after increasing the upper frequency limit of the second core group, enter the next iteration (i.e., enter the third iteration), and execute the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determine the steps of the average power consumption and the average frequency of each processor core during the operation. If the average frequency of each processor core in the core group with the highest group priority does not exceed the highest frequency of the processor, after reducing the upper frequency limit of the second core group, enter the next iteration (i.e., enter the third iteration), and execute the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determine the steps of the average power consumption and the average frequency of each processor core during the operation.
[0097] Wherein, increasing the upper frequency limit of the second core group includes: increasing the upper frequency limit of the second core group according to a first formula; the first formula is: FD new-max-2 =F old-max-2 +a×(F old-max-2 -F old-min-2 ); where FD new-max-2 is the upper frequency limit of the second core group after the increase, F old-max-2 To increase the frequency limit of the second core group, F old-min-2 To increase the lower frequency limit of the second core group, a is a preset first coefficient, and a takes a value of 0.1.
[0098] The step of reducing the upper frequency limit of the second core group includes: reducing the upper frequency limit of the second core group according to a second formula; the second formula is: FX new-max-2 =F old-max-2 -b×(F old-max-2 -F old-min-2 ); Among them, FX new-max-2 is the lowered upper frequency limit of the second core group, F old-max-2 To reduce the upper frequency limit of the second core group, F old-min-2 In order to reduce the lower limit of the frequency of the second core group, b is a preset second coefficient, and the value of b is 0.05.
[0099] In one embodiment, when two consecutive average power consumption values exceed the power consumption threshold, if the difference between the two consecutive average power consumption values and the difference between the two consecutive average frequencies meet the preset first condition, the current round of frequency modulation process is terminated. If the difference between the two consecutive average power consumption values and the difference between the two consecutive average frequencies do not meet the preset first condition, the next iteration is entered, and the tasks bound to the processor cores in each core group are executed under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and average frequency of each processor core during the operation are executed.
[0100] Among them, the calculation process of the difference between two consecutive power consumption averages and the difference between two consecutive frequency averages includes: constructing the previous power consumption average and the previous frequency average as a first vector; constructing the current power consumption average and the current frequency average as a second vector; subtracting the first vector from the second vector to obtain a vector difference; and taking the modulus of the vector difference. The difference between the two consecutive power consumption averages and the difference between the two consecutive frequency averages meet the preset first condition, including: the modulus result of the vector difference is less than the first target value. Correspondingly, if the modulus result is not less than the first target value, the preset first condition is not met. The preset first condition is expressed by the formula: .in, F tmpi represents the first vector, F tmp(i-1) represents the first vector, T out Indicates the first target value.
[0101] After a round of frequency modulation process ends, how to determine whether to activate the next round of frequency modulation process. A specific judgment scheme is provided below, including: after the end of this round of frequency modulation process, the current power consumption average and the current frequency average are stored, and the corresponding time node is before the preset time length; after waiting for the preset time length, the target power consumption average and the target frequency average of each processor core are determined, and the corresponding time node is after the preset time length; if the difference between the current power consumption average and the target power consumption average, and the difference between the current frequency average and the target frequency average meet the preset second condition, then the next round of frequency modulation process is activated, and the tasks bound to the processor cores in each core group are executed under the constraints of the frequency range corresponding to each core group, and the steps of determining the power consumption average and frequency average of each processor core during the operation are determined. If the difference between the current power consumption average and the target power consumption average, and the difference between the current frequency average and the target frequency average do not meet the preset second condition, then the step of determining the target power consumption average and the target frequency average of each processor core is executed after waiting for the preset time length.
[0102] The target power consumption mean and the target frequency mean are constructed as a third vector; the current power consumption mean and the current frequency mean are constructed as a fourth vector; the third vector and the fourth vector are subtracted from each other to obtain a vector difference; if the modulus result of the vector difference is greater than the second target value, the preset second condition is met, otherwise, the preset second condition is not met. The preset second condition is expressed by the formula: .in, F last represents the fourth vector, F new represents the third vector, T up Indicates the second target value.
[0103] In one implementation, the calculation formula for the frequency mean of any processor core is:
[0104] ;
[0105] in, f corei For the processor core i The frequency mean of f 1 is the frequency value collected for the first time, f x For the x The frequency value of the acquisition, f nt For the nt It can be seen that one processor core corresponds to one frequency average value, and all processor cores correspond to one power consumption average value. Therefore, the power consumption average value and frequency average value determined for each processor core each time include: one power consumption average value and multiple frequency average values.
[0106] It can be seen that this embodiment divides multiple processor cores into N core groups, and after setting the frequency range and group priority corresponding to each core group, iteratively adjusts the core group and its frequency constraint range according to the running status of the task on each processor core, so that each processor core can reasonably realize resource allocation under full load and ensure the operating stability under full load.
[0107] If the present invention is used to allocate frequency to the processor of the hyper-converged node, the power consumption allocation of different cores can be made more reasonable by finely adjusting the frequency constraint range of different processor cores, which can maximize the use of processor resources and improve the performance of the hyper-converged server. Hyper-convergence is an infrastructure solution that integrates computing, storage and network functions, and can integrate computing, storage and network devices into a unified software-defined platform, achieving flexibility, scalability and simplicity through software management and automation.
[0108] See also Figure 2 The specific solution architecture includes: binding multiple processes PID1~PIDn to the corresponding processor cores, and grouping the processor cores CPU1~CPUn to obtain three priority core groups, then monitoring the frequency average of CPU1~CPUn, and then adjusting the upper and lower limits of the frequency of the core group according to this frequency average.
[0109] See also Figure 3 , the specific implementation process includes:
[0110] 1) Obtaining host resource parameters.
[0111] Get the number of physical cores of the host n core , the base frequency of the processor F base , the lowest frequency F idle , highest turbo frequency F turbo , pressurize all cores of the processor to make the full core load at the highest state, and obtain the power consumption of the processor at this time P max .
[0112] 2) Initialize the allocation rules.
[0113] By analyzing the upper-layer business, the processes that consume processor resources are divided into more than 2 priorities, each process is bound to the corresponding processor core to run fixedly on a certain processor core, and the processor core is allocated to the core group with the corresponding priority. The priority classification level can be appropriately increased or decreased, such as classified into 2 or 4 levels.
[0114] Specifically, the processor cores are divided into three groups, corresponding to high, medium, and low priorities, wherein the number of processor cores included in the high priority core group is n1, the number of processor cores included in the medium priority core group is n2, and the number of processor cores included in the low priority core group is n3. n core =n1+n2+n3.
[0115] At the same time, the frequency of the processor cores in each priority core group is limited. The processor frequency ranges corresponding to the three priorities of high, medium and low are: F max1 ,F min1 ],[ F max2 ,F min2 ],[ F max3 ,Fmin3 ],and, F max1 =F max2 =F max3 =F turbo , F min1 = F min2 = F min3 =F idle .
[0116] When binding processes and processor cores, you can bind cores according to the upper-layer business type. Assuming that the upper-layer business is mainly distributed storage and virtual machine operation, then bind the distributed storage threads and virtual machine processes to fixed processor cores, and divide the above cores into different groups.
[0117] 3) Run upper-layer services.
[0118] Start the upper-layer business. After the upper-layer business is started, it will continue to run and consume processor resources. After the business runs stably for a period of time, collect the real-time frequency of each processor core n times at the same interval, and fit the frequency change in a linear manner to calculate the average frequency during this period. One processor core corresponds to one average frequency.
[0119] After the service is started, the frequency of each processor core is sampled once every t1 time until nt data are recorded.
[0120] Taking a single processor core as an example, a total of 10 data are recorded, and the data obtained are: f 1 , f 2 ,…, f nt}, reflects the change of processor core frequency over a period of time, performs linear fitting on adjacent data, and calculates the average frequency during this period as: ;in, f corei For the processor core i The frequency mean of f 1 is the frequency value collected for the first time, f x For the x The frequency value of the acquisition, f nt For the nt The frequency value of the acquisition.
[0121] Use the same method to sample the power consumption of the processor cores to obtain the average power consumption of all processor cores P avg .
[0122] Finally, a set of sampling data is obtained for all processor cores: F tmpi = { f core1 , f core2 ,…, f core n core , P avg}. f core1 for core1 The frequency mean of f core2 for core2 The frequency mean of f core n core for n core The frequency mean of .
[0123] 4) Regroup the processor cores by the average frequency obtained.
[0124] In the first iteration, all processor cores are regrouped according to the frequency averages collected above. That is, they are sorted by frequency and then divided into three priority core groups: low, medium, and high. The frequency upper and lower limits of these three new core groups are adjusted as follows:
[0125] .
[0126] in, G h , G m , G l is the set of average frequencies of each processor core in the three new core groups, G h , G m , G l Arrange them in high, medium, and low priority. Repeat step 3 and run the upper layer service again to collect new data for the second time. When the average power consumption value collected for the second time does not reach P max , then proceed to the next iteration; if the average power consumption for two consecutive times does not reach Pmax , then exit this round of iteration.
[0127] 5) Adjust the frequency constraints of the core group and repeat the above 3); if the exit iteration conditions are met, the system is considered to have reached a steady state.
[0128] Not the first iteration, that is, in the second iteration, when the average power consumption of the second collection reaches P max , then proceed as follows:
[0129] If the frequency average of at least one processor core in the high-priority core group reaches F turbo , then proceed to the next iteration.
[0130] If the average frequency of all processor cores in the high-priority core group reaches F turbo , then the frequency cap of the core group with medium priority is raised according to the rules. That is: FD new-max-2 =F old-max-2 +a×(F old-max-2 -F old-min-2 ), and then proceed to the next iteration.
[0131] If the average frequency of all processor cores in the high-priority core group does not reach F turbo , then the frequency cap of the core group with medium priority is reduced according to the rules. That is: FX new-max-2 =F old-max-2 -b×(F old-max-2 -F old-min-2 ), and then proceed to the next iteration.
[0132] Step 5: Determine whether to exit iteration.
[0133] When the average power consumption for two consecutive times reaches P max , take the modulus of the difference between two consecutive sampling data, and when the modulus result is within a certain threshold range, it is considered that the system has reached a steady state and the iteration is exited. That is, the iteration exit condition is: .
[0134] 6) After the iteration exits, wait for a while and collect the average frequency again to determine whether to activate the next iteration. If activated, repeat steps 3)-5) again until a steady state is reached again.
[0135] Keep the sampling data at the end of the previous iteration, recorded as F last , and then sample again after a period of time (such as 30 minutes) to obtain the average frequency of each processor core, recorded asF new When the difference between the new sampling result and the sampling result of the last round of termination iteration exceeds the threshold, the iteration is activated again and steps 4)-5) are executed. Otherwise, wait for a period of time and then sample again to determine whether to activate. Among them: the iteration activation condition is: . This can achieve the following: after the system reaches a certain stable state, the number of times and time intervals for monitoring the processor are reduced. If the frequency fluctuation of each core does not exceed the threshold, no adjustment is made. On the contrary, when the upper-layer business changes and the load of each process changes greatly, the frequency of each core changes twice before and after exceeding the threshold, then reactivate the iteration until a new steady state is reached.
[0136] It can be seen that this embodiment fixes the relevant business processes to different processor cores by binding cores, and allocates resources to different processor cores according to actual frequencies through upper-layer business drivers. After that, by long-term monitoring of the processor core frequency and real-time adjustment of the allocation rules, the processor resources can be adaptively planned, which has strong adaptability to high-load and flexible upper-layer businesses, thereby improving system efficiency.
[0137] A processor frequency modulation device provided by an embodiment of the present invention is introduced below. The processor frequency modulation device described below can be referenced to other embodiments described in this document.
[0138] See also Figure 4 As shown, an embodiment of the present invention discloses a processor frequency modulation device, comprising:
[0139] A partitioning module is used to partition multiple processor cores into N core groups, and set the frequency range and group priority corresponding to each core group; wherein the group priority of the core group to which any processor core belongs is consistent with the priority of the task bound to the processor core, and the number of processor cores included in any core group matches the group priority of the corresponding core group;
[0140] An operation module, used to run the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determine the average power consumption and frequency of each processor core during the operation process;
[0141] A grouping module, for regrouping the processor cores according to the frequency averages of the processor cores to update N core groups if it is the first iteration;
[0142] An execution module, configured to, after determining the frequency ranges and group priorities corresponding to the updated N core groups, execute the tasks bound to the processor cores in each core group under the constraints of the frequency ranges corresponding to each core group, and determine the average power consumption and the average frequency of each processor core during the running process, so as to obtain the current average power consumption and the current average frequency of each processor core;
[0143] The iteration module is used to increase the number of iterations by one if it is not the first iteration. If the number of iterations after the increase is greater than the preset value, then when the current average power consumption does not exceed the power consumption threshold and the previous average power consumption exceeds the power consumption threshold, execute the task bound to the processor cores in each core group under the constraint of the frequency range corresponding to each core group, and determine the average power consumption and frequency of each processor core during the running process; when the average power consumption does not exceed the power consumption threshold for two consecutive times, end the current round of frequency modulation process.
[0144] In one implementation, the partitioning module is specifically used to:
[0145] Set N group priorities and the number of processor cores that match the corresponding group priorities;
[0146] Divide the multiple processor cores according to the number of processor cores to obtain N core groups;
[0147] The upper frequency limit of the N core groups is set to the highest frequency of the processor, and the lower frequency limit is set to the lowest frequency of the processor, so as to obtain the frequency range corresponding to each core group.
[0148] In one implementation, the grouping module is specifically used to:
[0149] Arrange the frequency mean values of each processor core in descending order to obtain a frequency sequence;
[0150] According to the number of processor cores matched by the N group priorities, the frequency sequence is divided into N segments, and the updated N core groups are obtained with the group priorities arranged from high to low;
[0151] For the core group with the highest group priority among the updated N core groups, the frequency upper limit of the core group is set to the highest frequency of the processor, and the previous average of the minimum frequencies of the processor cores in the core group is used as the frequency lower limit to obtain the frequency range corresponding to the core group;
[0152] For the core group with the lowest group priority among the updated N core groups, the frequency lower limit of the core group is set to the lowest frequency of the processor, and the average of the previous maximum frequencies of the processor cores in the core group is used as the frequency upper limit to obtain the frequency range corresponding to the core group;
[0153] For the core groups of other group priorities in the updated N core groups, the average of the previous maximum frequencies of each processor core in the corresponding core group is used as the frequency upper limit, and the average of the previous minimum frequencies of each processor core in the corresponding core group is used as the frequency lower limit to obtain the frequency range corresponding to the corresponding core group.
[0154] In one embodiment, the iteration module is further configured to:
[0155] When the current average power consumption exceeds the power consumption threshold, determining whether there is at least one processor core in the updated core group with the highest group priority whose average frequency exceeds the highest frequency of the processor;
[0156] If so, the next iteration is entered, and the tasks bound to the processor cores in each core group are executed under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and frequency of each processor core during the running process are executed.
[0157] In one embodiment, the iteration module is further configured to:
[0158] When the current average power consumption exceeds the power consumption threshold, determining whether the updated average frequencies of the processor cores in the core group with the highest group priority all exceed the highest frequency of the processor;
[0159] If yes, then determine the updated second core group; the group priority of the second core group is one level lower than the highest group priority;
[0160] After increasing the frequency upper limit of the second core group, enter the next iteration, and execute the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determine the average power consumption and frequency of each processor core during the running process.
[0161] In one implementation, increasing the upper frequency limit of the second core group includes:
[0162] Increase the upper frequency limit of the second core group according to the first formula; the first formula is: FD new-max-2 =F old-max-2 +a×(F old-max-2 -F old-min-2 );
[0163] Among them, FD new-max-2 is the upper frequency limit of the second core group after the increase, F old-max-2 To increase the frequency limit of the second core group, F old-min-2 To increase the lower frequency limit of the previous second core group, a is a preset first coefficient.
[0164] In one embodiment, the iteration module is further configured to:
[0165] If the frequency averages of the processor cores in the core group with the highest group priority do not exceed the highest frequency of the processor, the frequency upper limit of the second core group is reduced, and the next iteration is entered. The tasks bound to the processor cores in each core group are run under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and frequency of each processor core during the running process are performed.
[0166] In one embodiment, reducing the upper frequency limit of the second core group includes:
[0167] Reduce the upper frequency limit of the second core group according to the second formula; the second formula is: FX new-max-2 =F old-max-2 -b×(F old-max-2 -F old-min-2 );
[0168] Among them, FX new-max-2 is the lowered upper frequency limit of the second core group, F old-max-2 To reduce the upper frequency limit of the second core group, F old-min-2 To reduce the previous lower frequency limit of the second core group, b is a preset second coefficient.
[0169] In one embodiment, the iteration module is further configured to:
[0170] When two consecutive average power consumption values exceed the power consumption threshold, if the difference between the two consecutive average power consumption values and the difference between the two consecutive average frequencies meet the preset first condition, the current round of frequency modulation process is terminated.
[0171] In one implementation, the calculation process of the difference between two consecutive power consumption averages and the difference between two consecutive frequency averages includes:
[0172] The previous power consumption average and the previous frequency average are constructed as a first vector;
[0173] constructing the current power consumption mean and the current frequency mean into a second vector;
[0174] Subtract the first vector from the second vector to obtain a vector difference;
[0175] Modulo the difference of vectors.
[0176] In one implementation, the difference between two consecutive power consumption averages and the difference between two consecutive frequency averages satisfying a preset first condition include: a modulus result of a vector difference being smaller than a first target value.
[0177] In one embodiment, the iteration module is further configured to:
[0178] If the difference between two consecutive average power consumption values and the difference between two consecutive average frequency values do not meet the preset first condition, the next iteration is entered, and the tasks bound to the processor cores in each core group are executed under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and frequency of each processor core are determined during the running process.
[0179] In one embodiment, the iteration module is further configured to:
[0180] After the current round of frequency modulation process is completed, the current power consumption average and the current frequency average are stored;
[0181] After waiting for a preset time, determine the target power consumption average and target frequency average of each processor core;
[0182] If the difference between the current average power consumption and the target average power consumption, as well as the difference between the current average frequency and the target average frequency meet the preset second condition, the next round of frequency modulation process is activated, and the tasks bound to the processor cores in each core group are executed under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and average frequency of each processor core are determined during the running process.
[0183] In one implementation, the target power consumption mean and the target frequency mean are constructed as a third vector;
[0184] constructing the current power consumption mean and the current frequency mean into a fourth vector;
[0185] Subtract the third vector from the fourth vector to obtain a vector difference;
[0186] If the modulus result of the vector difference is greater than the second target value, the preset second condition is met; otherwise, the preset second condition is not met.
[0187] In one embodiment, the iteration module is further configured to:
[0188] If the difference between the current average power consumption and the target average power consumption, and the difference between the current average frequency and the target average frequency do not meet the preset second condition, then the step of determining the target average power consumption and target average frequency of each processor core after waiting for a preset period of time is executed.
[0189] In one implementation, the calculation formula for the frequency mean of any processor core is:
[0190] ;
[0191] in, f corei For the processor core i The frequency mean of f1 is the frequency value collected for the first time, f x For the x The frequency value of the acquisition, f nt For the nt The frequency value of the acquisition.
[0192] Among them, for more specific working processes of each module and unit in this embodiment, reference can be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.
[0193] It can be seen that this embodiment divides multiple processor cores into N core groups, and after setting the frequency range and group priority corresponding to each core group, iteratively adjusts the core group and its frequency constraint range according to the running status of the task on each processor core, so that each processor core can reasonably realize resource allocation under full load and ensure the operating stability under full load.
[0194] An electronic device provided by an embodiment of the present invention is introduced below. The electronic device described below can be referenced to other embodiments described in this document.
[0195] See also Figure 5 As shown, an embodiment of the present invention discloses an electronic device, including:
[0196] Memory 501, used for storing computer programs;
[0197] The processor 502 is used to execute the computer program to implement the method disclosed in any of the above embodiments.
[0198] In this embodiment, when the processor executes the computer program stored in the memory, the following steps may be specifically implemented: multiple processor cores are divided into N core groups, and a frequency range and a group priority corresponding to each core group are set; under the constraint of the frequency range corresponding to each core group, tasks bound to the processor cores in each core group are run, and the average power consumption and the average frequency of each processor core are determined during the running process; if it is the first iteration, the processor cores are regrouped according to the size of the average frequency of each processor core to update the N core groups; after determining the frequency range and the group priority corresponding to the updated N core groups, the tasks bound to the processor cores in each core group are run under the constraint of the frequency range corresponding to each core group, and the average power consumption and the average frequency of each processor core are determined during the running process; if it is the first iteration, the processor cores are regrouped according to the size of the average frequency of each processor core to update the N core groups; after determining the frequency range and the group priority corresponding to the updated N core groups, the tasks bound to the processor cores in each core group are run under the constraint of the frequency range corresponding to each core group. The tasks bound to the processor cores in the core group are executed, and the steps of determining the average power consumption and the average frequency of each processor core during the running process are performed to obtain the current average power consumption and the current average frequency of each processor core; if it is not the first iteration, the number of iterations is incremented by one. If the number of iterations after the increase is greater than the preset value, then when the current average power consumption does not exceed the power consumption threshold and the previous average power consumption exceeds the power consumption threshold, the tasks bound to the processor cores in each core group are executed under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and the average frequency of each processor core during the running process are performed; when the average power consumption does not exceed the power consumption threshold for two consecutive times, the current round of frequency modulation process is terminated.
[0199] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: setting N group priorities and the number of processor cores that match the corresponding group priorities; dividing multiple processor cores according to the number of processor cores to obtain N core groups; setting the upper frequency limit of the N core groups to the highest frequency of the processor, and the lower frequency limit to the lowest frequency of the processor, to obtain the frequency range corresponding to each core group.
[0200] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: arranging the frequency mean values of each processor core in descending order to obtain a frequency sequence; dividing the frequency sequence into N segments according to the number of processor cores matched by the N group priorities to obtain updated N core groups whose group priorities are arranged from high to low; for the core group with the highest group priority among the updated N core groups, setting the frequency upper limit of the core group to the highest frequency of the processor, and taking the previous minimum frequency mean value of each processor core in the core group as the frequency lower limit to obtain the frequency range corresponding to the core group; for the core group with the lowest group priority among the updated N core groups, setting the frequency lower limit of the core group to the lowest frequency of the processor, and taking the previous maximum frequency mean value of each processor core in the core group as the frequency upper limit to obtain the frequency range corresponding to the core group; for the core groups with other group priorities among the updated N core groups, taking the previous maximum frequency mean value of each processor core in the corresponding core group as the frequency upper limit, and taking the previous minimum frequency mean value of each processor core in the corresponding core group as the frequency lower limit to obtain the frequency range corresponding to the corresponding core group.
[0201] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: when the current average power consumption exceeds the power consumption threshold, determine whether there is at least one processor core in the updated core group with the highest group priority whose average frequency exceeds the highest frequency of the processor; if so, enter the next iteration, and execute the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determine the average power consumption and frequency of each processor core during the running process.
[0202] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: when the current average power consumption exceeds the power consumption threshold, determine whether the frequency averages of each processor core in the updated core group with the highest group priority all exceed the highest frequency of the processor; if so, determine the updated second core group; the group priority of the second core group is one level lower than the highest group priority; after increasing the frequency upper limit of the second core group, enter the next iteration, and execute the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determine the power consumption average and frequency average of each processor core during the running process.
[0203] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: if the frequency average of each processor core in the core group with the highest group priority does not exceed the highest frequency of the processor, the frequency upper limit of the second core group is reduced, and the next iteration is entered, and the tasks bound to the processor cores in each core group are executed under the constraints of the frequency range corresponding to each core group, and the steps of determining the power consumption average and frequency average of each processor core during the running process are performed.
[0204] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: when two consecutive power consumption averages exceed the power consumption threshold, if the difference between the two consecutive power consumption averages and the difference between the two consecutive frequency averages meet the preset first condition, then the current round of frequency modulation process is terminated.
[0205] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: constructing the previous power consumption average and the previous frequency average as a first vector; constructing the current power consumption average and the current frequency average as a second vector; subtracting the first vector from the second vector to obtain a vector difference; and taking the modulus of the vector difference.
[0206] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: if the difference between two consecutive power consumption averages and the difference between two consecutive frequency averages do not meet the preset first condition, then enter the next iteration, and execute the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determine the power consumption average and frequency average of each processor core during the running process.
[0207] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: after ending the current round of frequency modulation process, the current average power consumption and the current average frequency are stored; after waiting for a preset period of time, the target average power consumption and the target average frequency of each processor core are determined; if the difference between the current average power consumption and the target average power consumption, and the difference between the current average frequency and the target average frequency meet the preset second condition, the next round of frequency modulation process is activated, and the tasks bound to the processor cores in each core group are executed under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and the average frequency of each processor core during the running process are performed.
[0208] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: if the difference between the current average power consumption and the target average power consumption, and the difference between the current average frequency and the target average frequency do not meet the preset second condition, then wait for a preset period of time and then determine the target average power consumption and target average frequency of each processor core.
[0209] Furthermore, an embodiment of the present invention also provides an electronic device. The electronic device can be Figure 6 The server shown can also be Figure 7 Terminal shown. Figure 6 and Figure 7 All of them are structural diagrams of electronic devices according to an exemplary embodiment, and the contents in the diagrams cannot be regarded as any limitation on the scope of application of the present invention.
[0210] Figure 6 A schematic diagram of the structure of a server provided in an embodiment of the present invention. The server may specifically include: at least one processor, at least one memory, a power supply, a communication interface, an input / output interface, and a communication bus. The memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the relevant steps in the processor frequency modulation disclosed in any of the aforementioned embodiments.
[0211] In this embodiment, the power supply is used to provide working voltage for each hardware device on the server; the communication interface can create a data transmission channel between the server and external devices, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present invention, and is not specifically limited here; the input and output interface is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0212] In addition, the memory as a carrier for resource storage can be a read-only memory, random access memory, disk or CD, etc. The resources stored thereon include operating system, computer programs and data, etc. The storage method can be temporary storage or permanent storage.
[0213] The operating system is used to manage and control the hardware devices and computer programs on the server to realize the operation and processing of the data in the memory by the processor, and it can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the processor frequency modulation method disclosed in any of the aforementioned embodiments, the computer program can further include computer programs that can be used to complete other specific tasks. In addition to data such as application update information, the data can also include data such as application developer information.
[0214] Figure 7 A schematic diagram of the structure of a terminal provided in an embodiment of the present invention, wherein the terminal may specifically include but is not limited to a smart phone, a tablet computer, a laptop computer or a desktop computer.
[0215] Generally, the terminal in this embodiment includes: a processor and a memory.
[0216] Among them, the processor may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0217] The memory may include one or more computer non-volatile storage media, which may be non-transitory. The memory may also include high-speed random access memory, and non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory is used to store at least the following computer program, wherein, after the computer program is loaded and executed by the processor, it can implement the relevant steps in the processor frequency modulation method performed by the terminal side disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory may also include an operating system and data, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system may include Windows, Unix, Linux, etc. The data may include, but is not limited to, update information of the application.
[0218] In some embodiments, the terminal may also include a display screen, an input and output interface, a communication interface, a sensor, a power supply, and a communication bus.
[0219] Those skilled in the art will understand that Figure 7 The structure shown in the figure does not constitute a limitation on the terminal, and may include more or fewer components than those shown in the figure.
[0220] A nonvolatile storage medium provided in an embodiment of the present invention is introduced below. The nonvolatile storage medium described below and other embodiments described herein may be cross-referenced.
[0221] A non-volatile storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the processor frequency modulation method disclosed in the above embodiment. The non-volatile storage medium is a computer-readable non-volatile storage medium, which, as a carrier for resource storage, may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system, a computer program and data, etc., and the storage method may be temporary storage or permanent storage.
[0222] In this embodiment, when the processor executes the computer program, the following steps can be specifically implemented: multiple processor cores are divided into N core groups, and the frequency range and group priority corresponding to each core group are set; under the constraint of the frequency range corresponding to each core group, the tasks bound to the processor cores in each core group are run, and the average power consumption and the average frequency of each processor core are determined during the running process; if it is the first iteration, the processor cores are regrouped according to the size of the average frequency of each processor core to update the N core groups; after determining the frequency range and group priority corresponding to the updated N core groups, the processor cores in each core group are run under the constraint of the frequency range corresponding to each core group. The steps of performing the tasks bound to the processor cores, and determining the average power consumption and the average frequency of each processor core during the running process to obtain the current average power consumption and the current average frequency of each processor core; if it is not the first iteration, the number of iterations is incremented by one, and if the number of iterations after the increase is greater than the preset value, then when the current average power consumption does not exceed the power consumption threshold and the previous average power consumption exceeds the power consumption threshold, executing the tasks bound to the processor cores in each core group under the constraint of the frequency range corresponding to each core group, and determining the average power consumption and the average frequency of each processor core during the running process; when the average power consumption does not exceed the power consumption threshold for two consecutive times, ending this round of frequency modulation process.
[0223] In this embodiment, when the processor executes a computer program, the following steps can be specifically implemented: setting N group priorities and the number of processor cores that match the corresponding group priorities; dividing multiple processor cores according to the number of processor cores to obtain N core groups; setting the upper frequency limit of the N core groups to the highest frequency of the processor, and the lower frequency limit to the lowest frequency of the processor, to obtain the frequency range corresponding to each core group.
[0224] In this embodiment, when the processor executes the computer program, the following steps can be specifically implemented: the frequency mean values of each processor core are arranged in descending order to obtain a frequency sequence; according to the number of processor cores matched by the N group priorities, the frequency sequence is divided into N segments to obtain updated N core groups whose group priorities are arranged from high to low; for the core group with the highest group priority among the updated N core groups, the frequency upper limit of the core group is set to the highest frequency of the processor, and the previous minimum frequency mean value of each processor core in the core group is used as the frequency lower limit to obtain the frequency range corresponding to the core group; for the core group with the lowest group priority among the updated N core groups, the frequency lower limit of the core group is set to the lowest frequency of the processor, and the previous maximum frequency mean value of each processor core in the core group is used as the frequency upper limit to obtain the frequency range corresponding to the core group; for the core groups with other group priorities among the updated N core groups, the previous maximum frequency mean value of each processor core in the corresponding core group is used as the frequency upper limit, and the previous minimum frequency mean value of each processor core in the corresponding core group is used as the frequency lower limit to obtain the frequency range corresponding to the corresponding core group.
[0225] In this embodiment, when the processor executes a computer program, the following steps can be specifically implemented: when the current average power consumption exceeds the power consumption threshold, determine whether there is at least one processor core in the updated core group with the highest group priority whose average frequency exceeds the highest frequency of the processor; if so, enter the next iteration, and execute the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determine the average power consumption and frequency of each processor core during the running process.
[0226] In this embodiment, when the processor executes a computer program, the following steps can be specifically implemented: when the current average power consumption exceeds the power consumption threshold, determine whether the frequency averages of each processor core in the updated core group with the highest group priority all exceed the highest frequency of the processor; if so, determine the updated second core group; the group priority of the second core group is one level lower than the highest group priority; after increasing the frequency upper limit of the second core group, enter the next iteration, and execute the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determine the steps of the average power consumption and frequency average of each processor core during the running process.
[0227] In this embodiment, when the processor executes a computer program, the following steps can be specifically implemented: if the frequency average of each processor core in the core group with the highest group priority does not exceed the highest frequency of the processor, the frequency upper limit of the second core group is reduced, and the next iteration is entered, and the tasks bound to the processor cores in each core group are executed under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and frequency of each processor core during the running process are performed.
[0228] In this embodiment, when the processor executes the computer program, the following steps can be specifically implemented: when two consecutive power consumption averages exceed the power consumption threshold, if the difference between the two consecutive power consumption averages and the difference between the two consecutive frequency averages meet the preset first condition, then the current round of frequency modulation process is terminated.
[0229] In this embodiment, when the processor executes the computer program, the following steps can be specifically implemented: constructing the previous power consumption average and the previous frequency average as a first vector; constructing the current power consumption average and the current frequency average as a second vector; subtracting the first vector from the second vector to obtain a vector difference; and taking the modulus of the vector difference.
[0230] In this embodiment, when the processor executes a computer program, the following steps can be specifically implemented: if the difference between two consecutive power consumption averages and the difference between two consecutive frequency averages do not meet the preset first condition, then enter the next iteration, and execute the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determine the power consumption average and frequency average of each processor core during the running process.
[0231] In this embodiment, when the processor executes the computer program, the following steps can be specifically implemented: after ending the current round of frequency modulation process, the current average power consumption and the current average frequency are stored; after waiting for a preset period of time, the target average power consumption and the target average frequency of each processor core are determined; if the difference between the current average power consumption and the target average power consumption, and the difference between the current average frequency and the target average frequency meet the preset second condition, the next round of frequency modulation process is activated, and the tasks bound to the processor cores in each core group are executed under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and the average frequency of each processor core during the running process are performed.
[0232] In this embodiment, when the processor executes a computer program, the following steps can be specifically implemented: if the difference between the current average power consumption and the target average power consumption, and the difference between the current average frequency and the target average frequency do not meet the preset second condition, then wait for a preset period of time and then determine the target average power consumption and target average frequency of each processor core.
[0233] A computer program product provided by an embodiment of the present invention is introduced below. The computer program product described below can be referenced to other embodiments described in this document.
[0234] A computer program product includes a computer program / instruction, which implements the steps of the processor frequency modulation method disclosed above when the computer program / instruction is executed by a processor.
[0235] The embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referenced to each other.
[0236] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of non-volatile storage medium known in the art.
[0237] Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A processor frequency modulation method, characterized in that: include: Divide multiple processor cores into N core groups, and set the frequency range and group priority corresponding to each core group; wherein the group priority of the core group to which any processor core belongs is consistent with the priority of the task bound to the processor core, and the number of processor cores included in any core group matches the group priority of the corresponding core group; Under the constraints of the frequency range corresponding to each core group, the tasks bound to the processor cores in each core group are run, and the average power consumption and frequency of each processor core are determined during the running process; If it is the first iteration, the processor cores are regrouped according to the frequency averages of the processor cores to update N core groups; After determining the frequency ranges and group priorities corresponding to the updated N core groups, executing the steps of running the tasks bound to the processor cores in each core group under the constraints of the frequency ranges corresponding to each core group, and determining the average power consumption and the average frequency of each processor core during the running process, so as to obtain the current average frequency of each processor core and the current average power consumption of all processor cores; If it is not the first iteration, the number of iterations is incremented by one. When the current average power consumption does not exceed the power consumption threshold and the previous average power consumption exceeds the power consumption threshold, the steps of running the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group and determining the average power consumption and the average frequency of each processor core during the running process are performed; when the average power consumption does not exceed the power consumption threshold for two consecutive times, the current round of frequency modulation process is terminated; The processor cores are regrouped according to the frequency averages of the processor cores to update the N core groups, and the frequency ranges and group priorities corresponding to the updated N core groups are determined, including: Arrange the frequency mean values of each processor core in descending order to obtain a frequency sequence; According to the number of processor cores matched by the N group priorities, the frequency sequence is divided into N segments to obtain updated N core groups arranged in descending order of group priority; For the core group with the highest group priority among the updated N core groups, the frequency upper limit of the core group is set to the highest frequency of the processor, and the previous average of the minimum frequencies of the processor cores in the core group is used as the frequency lower limit to obtain the frequency range corresponding to the core group; For the core group with the lowest group priority among the updated N core groups, the frequency lower limit of the core group is set to the lowest frequency of the processor, and the average of the previous maximum frequencies of the processor cores in the core group is used as the frequency upper limit to obtain the frequency range corresponding to the core group; For the core groups of other group priorities in the updated N core groups, the average of the previous maximum frequencies of each processor core in the corresponding core group is used as the frequency upper limit, and the average of the previous minimum frequencies of each processor core in the corresponding core group is used as the frequency lower limit to obtain the frequency range corresponding to the corresponding core group.
2. The method according to claim 1, characterized in that Divide multiple processor cores into N core groups, and set the frequency range and group priority corresponding to each core group, including: Set N group priorities and the number of processor cores that match the corresponding group priorities; Divide the plurality of processor cores according to the number of the processor cores to obtain N core groups; The upper frequency limit of the N core groups is set to the highest frequency of the processor, and the lower frequency limit is set to the lowest frequency of the processor, so as to obtain the frequency range corresponding to each core group.
3. The method according to claim 1, characterized in that Also includes: When the current average power consumption exceeds the power consumption threshold, determining whether there is at least one processor core in the updated core group with the highest group priority whose average frequency exceeds the highest frequency of the processor; If so, the next iteration is entered, and the steps of running the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group and determining the average power consumption and frequency of each processor core during the running process are executed.
4. The method according to claim 1, characterized in that: Also includes: When the current average power consumption exceeds the power consumption threshold, determining whether the updated average frequencies of the processor cores in the core group with the highest group priority all exceed the highest frequency of the processor; If yes, then determine the updated second core group; The group priority of the second core group is one level lower than the highest group priority; After increasing the frequency upper limit of the second core group, enter the next iteration and execute the steps of running the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determining the average power consumption and frequency of each processor core during the running process.
5. The method according to claim 4, characterized in that Increasing the upper frequency limit of the second core group, including: Increase the upper frequency limit of the second core group according to the first formula; the first formula is: FD new-max-2 =F old-max-2 +a×(F old-max-2 -F old-min-2 ); Among them, FD new-max-2 is the increased upper frequency limit of the second core group, F old-max-2 To increase the upper frequency limit of the second core group, F old-min-2 To increase the previous lower limit of the frequency of the second core group, a is a preset first coefficient.
6. The method according to claim 4, characterized in that Also includes: If the frequency average of each processor core in the core group with the highest group priority does not exceed the highest frequency of the processor, the frequency upper limit of the second core group is reduced, and the next iteration is entered, and the tasks bound to the processor cores in each core group are run under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and frequency of each processor core during the running process are executed.
7. The method according to claim 6, characterized in that Reducing the upper frequency limit of the second core group includes: The frequency upper limit of the second core group is reduced according to a second formula; the second formula is: FX new-max-2 =F old-max-2 -b×(F old-max-2 -F old-min-2 ); Among them, FX new-max-2 is the upper frequency limit of the second core group after reduction, F old-max-2 To reduce the upper frequency limit of the second core group, F old-min-2 In order to reduce the previous lower limit of the frequency of the second core group, b is a preset second coefficient.
8. The method according to any one of claims 1 to 7, characterized in that: Also includes: When two consecutive average power consumption values exceed the power consumption threshold, if the difference between the two consecutive average power consumption values and the difference between the two consecutive average frequencies meet the preset first condition, the current round of frequency modulation process is terminated.
9. The method according to claim 8, characterized in that The calculation process of the difference between two consecutive power consumption average values and the difference between two consecutive frequency average values includes: The previous power consumption average and the previous frequency average are constructed as a first vector; constructing the current power consumption mean and the current frequency mean into a second vector; Subtracting the first vector from the second vector to obtain a vector difference; Take the modulus of the vector difference.
10. The method according to claim 9, characterized in that The difference between two consecutive power consumption averages and the difference between two consecutive frequency averages satisfying a preset first condition include: a modulus result of the vector difference is less than a first target value.
11. The method according to claim 8, characterized in that Also includes: If the difference between the two consecutive average power consumption values and the difference between the two consecutive average frequency values do not meet the preset first condition, the next iteration is entered, and the tasks bound to the processor cores in each core group are run under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and frequency of each processor core during the running process are executed.
12. The method according to any one of claims 1 to 7, characterized in that: Also includes: After the current round of frequency modulation process is completed, the current power consumption average and the current frequency average are stored; After waiting for a preset time, determine the target power consumption average and target frequency average of each processor core; If the difference between the current average power consumption and the target average power consumption, and the difference between the current average frequency and the target average frequency meet the preset second condition, the next round of frequency modulation process is activated, and the tasks bound to the processor cores in each core group are run under the constraints of the frequency range corresponding to each core group, and the steps of determining the average power consumption and average frequency of each processor core during the running process are executed.
13. The method according to claim 12, characterized in that constructing a target power consumption mean and a target frequency mean as a third vector; constructing the current power consumption mean and the current frequency mean into a fourth vector; Subtracting the third vector from the fourth vector to obtain a vector difference; If the modulus result of the vector difference is greater than the second target value, the preset second condition is met; otherwise, the preset second condition is not met.
14. The method according to claim 12, characterized in that Also includes: If the difference between the current average power consumption and the target average power consumption, and the difference between the current average frequency and the target average frequency do not meet the preset second condition, then the step of determining the target average power consumption and target average frequency of each processor core after waiting for a preset period of time is executed.
15. The method according to any one of claims 1 to 7, characterized in that: The formula for calculating the average frequency of any processor core is: ; in, f corei For the processor core i The frequency mean of f 1 is the frequency value collected for the first time, f x For the x The frequency value of the acquisition, f nt For the nt The frequency value of the acquisition.
16. A processor frequency modulation device, characterized in that: include: A partitioning module is used to partition multiple processor cores into N core groups, and set the frequency range and group priority corresponding to each core group; wherein the group priority of the core group to which any processor core belongs is consistent with the priority of the task bound to the processor core, and the number of processor cores included in any core group matches the group priority of the corresponding core group; An operation module, used to run the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determine the average power consumption and frequency of each processor core during the operation process; A grouping module, for regrouping the processor cores according to the frequency averages of the processor cores to update N core groups if it is the first iteration; An execution module, configured to, after determining the frequency ranges and group priorities corresponding to the updated N core groups, execute the steps of running the tasks bound to the processor cores in each core group under the constraints of the frequency ranges corresponding to each core group, and determining the average power consumption and the average frequency of each processor core during the running process, so as to obtain the current average frequency of each processor core and the current average power consumption of all processor cores; An iteration module, for increasing the number of iterations by one if it is not the first iteration, and executing the steps of running the tasks bound to the processor cores in each core group under the constraints of the frequency range corresponding to each core group, and determining the power consumption average and frequency average of each processor core during the running process, if the current power consumption average does not exceed the power consumption threshold and the previous power consumption average exceeds the power consumption threshold if the current power consumption average does not exceed the power consumption threshold and the previous power consumption average exceeds the power consumption threshold if the current power consumption average does not exceed the power consumption threshold for two consecutive times; terminating the current round of frequency modulation process; The grouping module is specifically used for: Arrange the frequency mean values of each processor core in descending order to obtain a frequency sequence; According to the number of processor cores matched by the N group priorities, the frequency sequence is divided into N segments to obtain updated N core groups arranged in descending order of group priority; For the core group with the highest group priority among the updated N core groups, the frequency upper limit of the core group is set to the highest frequency of the processor, and the previous average of the minimum frequencies of the processor cores in the core group is used as the frequency lower limit to obtain the frequency range corresponding to the core group; For the core group with the lowest group priority among the updated N core groups, the frequency lower limit of the core group is set to the lowest frequency of the processor, and the average of the previous maximum frequencies of the processor cores in the core group is used as the frequency upper limit to obtain the frequency range corresponding to the core group; For the core groups of other group priorities in the updated N core groups, the average of the previous maximum frequencies of each processor core in the corresponding core group is used as the frequency upper limit, and the average of the previous minimum frequencies of each processor core in the corresponding core group is used as the frequency lower limit to obtain the frequency range corresponding to the corresponding core group.
17. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the method according to any one of claims 1 to 15.
18. A non-volatile storage medium, characterized in that: Used to store a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 15 is implemented.
19. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 15 is implemented.
Citation Information
Patent Citations
Processor frequency modulation method and device
CN112068690A
Frequency modulation method and device, electronic equipment and readable storage medium
CN115718536A
Frequency control method, device and system and readable storage medium
CN116414211A
