Frequency modulation method and electronic equipment
Adjusting the CPU frequency through the frequency modulation relationship table solves the problem of temperature rise caused by high power consumption of the device in complex games, achieves a balance between game performance and power consumption, and improves the user experience of the device.
Patent Information
- Application Number
- CN202310216083.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-25
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2043-02-25
AI Technical Summary
When using mobile phones, tablets and other devices to play complex games, the high power consumption of the device causes the temperature to rise, limiting the working frequency of the CPU and GPU and the game frame rate, resulting in unsmooth game graphics and poor experience.
Provide a frequency modulation method that uses the frequency modulation relationship table to adjust the CPU frequency based on CPU load and application operation information, and monitor the frame length. If the effect is good, continue to use the frequency modulation relationship table. Otherwise, switch to a backup plan to reduce the amount of calculation and avoid excessive device temperature.
Effectively adjust CPU frequency, balance game performance and power consumption, reduce device temperature, and improve gaming experience.
Smart Images

Figure CN117130770B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a frequency modulation method and electronic equipment. Background Art
[0002] When playing games on mobile phones, tablets and other devices, especially playing King of Glory TM , Genshin Impact TM When playing games with a lot of fighting and complex scenes, the power consumption of the device will be relatively high, which will cause the temperature of the device to rise.
[0003] At the same time, in mobile phones, tablets and other devices, if the temperature of the device is too high, the device will limit the operating frequency of the central processing unit (CPU), graphics processing unit (GPU) and other hardware and / or limit the frame rate of the game. This will cause the game screen to be choppy and the gaming experience to be poor. Summary of the invention
[0004] The present application provides a frequency modulation method and electronic device, which can continue to use the frequency modulation relationship table to adjust the frequency of the CPU when the use effect of the frequency modulation relationship table is good, thereby improving the rationality of the frequency modulation.
[0005] In a first aspect, the present application provides a frequency modulation method, which is applied to a first device that needs to frequency modulate the CPU. The first device includes a first application and a frequency modulation relationship table. The first application is an application that needs to refresh images frequently, such as a game application, a video playback application, etc. And, the frequency modulation relationship table includes multiple groups of discrete state combinations and corresponding multiple target frequencies, each group of discrete state combinations includes a discrete load value of the CPU load and a discrete operating value of the operating information of the first application, and the operating information includes at least one of the load of the application thread and the information of the application screen. That is, when a discrete state combination is given, the corresponding target frequency can be obtained by querying the frequency modulation relationship table.
[0006] Among them, the first application is started. In response to the end of displaying the k-th frame image of the first application, if the display frame length (i.e., frame length) of the first image is lower than the first frame length threshold, the first discrete load and the first discrete operating value corresponding to the first frequency are queried in the frequency modulation relationship table, the first discrete load is the discrete value of the current CPU load of the first device, the first discrete operating value is the discrete value of the current operating information of the first application in the first device, the first image includes the k-th frame image, k≥2, and k is an integer. The frequency of the CPU is adjusted to the first frequency.
[0007] In summary, after starting the first application, for the second frame and each frame thereafter, if it is detected that the effect of using the frequency modulation relationship table is good, such as a shorter frame length, the first device can continue to use the frequency modulation relationship table to determine a target frequency corresponding to the current state (such as the current CPU load, application information of the first application, etc.), such as the first frequency. In this way, the rationality of the frequency modulation can be guaranteed.
[0008] In a possible design of the first aspect, if the display frame length of the first image is higher than the first frame length threshold, the frequency modulation relationship table is not used to query the frequency. In other words, if the effect of using the frequency modulation relationship table is not good, the frequency modulation relationship table will not be used to query the frequency.
[0009] In a possible design manner of the first aspect, the first device includes a working state of the frequency modulation relationship table, and when the first application is started, the working state is a first state. The above-mentioned querying the first frequency corresponding to the first discrete load and the first discrete operating value in the frequency modulation relationship table includes: if the working state is the first state, querying the first frequency corresponding to the first discrete load and the first discrete operating value in the frequency modulation relationship table.
[0010] In a possible design of the first aspect, the method further includes: if the display frame length of the first image is higher than the first frame length threshold, updating the working state to the second state. In response to the display of the k+1th frame image of the first application being completed, the frequency modulation relationship table is not used to query the frequency.
[0011] In this way, when the working state of the frequency modulation relationship table is invalid, the mobile phone does not need to continue to monitor whether the frequency modulation relationship table is valid, but can directly use the backup frequency modulation scheme, thereby reducing the amount of calculation.
[0012] In a possible design manner of the first aspect, the method further includes: if the display frame length of the kth frame image is lower than the second frame length threshold, detecting whether the display frame length of the first image is lower than the first frame length threshold.
[0013] In a possible design of the first aspect, the method further includes: if the display frame length of the kth frame image is higher than the second frame length threshold, querying the first frequency corresponding to the first discrete load and the first discrete operating value in the frequency modulation relationship table. The first device does not detect whether the display frame length of the first image is lower than the first frame length threshold. The frequency of the CPU is adjusted to the first frequency.
[0014] Among them, if the kth frame is an abnormal frame caused by high temperature frame limit, DDR abnormality or slow IO loading, then the frame length of the kth frame image will be very long. Therefore, in actual implementation, the first device can compare the frame length of the kth frame image with a larger frame length threshold (i.e., the second frame length threshold). If the frame length of the kth frame image is higher than the frame length threshold, the kth frame is determined to be an abnormal frame, that is, there is an abnormal factor. In this case, the first device does not need to perform validity monitoring, but can directly use the frequency modulation relationship table to query the frequency. If the frame length of the kth frame image is lower than or equal to the frame length threshold, it is determined that the kth frame is not an abnormal frame, that is, there is no abnormal factor. In this case, the first device needs to perform validity monitoring and select a strategy to determine the frequency based on the monitoring results. In this way, validity monitoring can be performed even when the kth frame is an abnormal frame.
[0015] In a possible design of the first aspect, the first device includes a cumulative frame number, and when the first application is started, the cumulative frame number is 0. Before querying the first frequency corresponding to the first discrete load and the first discrete operating value in the frequency modulation relationship table, the method further includes: adding one to the cumulative frame number. If the cumulative frame number is equal to the preset frame number, it is detected whether the display frame length of the first image is lower than the first frame length threshold. That is to say, each time the preset frame number is accumulated, the first device will perform a validity monitoring, that is, detecting whether the display frame length of the first image is lower than the first frame length threshold.
[0016] In a possible design of the first aspect, after detecting whether the display frame length of the first image is lower than the first frame length threshold, the method further includes: clearing the accumulated frame number to zero. In this way, after the preset frame number is accumulated, a new round of counting can be performed.
[0017] In a possible design of the first aspect, the method further includes: if the accumulated number of frames is less than the preset number of frames, querying the first frequency corresponding to the first discrete load and the first discrete operating value in the frequency modulation relationship table. The first device does not detect whether the display frame length of the first image is less than the first frame length threshold. The frequency of the CPU is adjusted to the first frequency.
[0018] That is to say, if the accumulated number of frames is small, the frequency modulation relationship table is still used to query the frequency.
[0019] In a possible design of the first aspect, the accumulated number of frames is increased by one, including: if the working state of the frequency modulation relationship table is a valid state and / or the display frame length of the kth frame image is lower than the second frame length threshold, the accumulated number of frames is increased by one.
[0020] That is to say, the count is accumulated only when the k-th frame image is not an abnormal frame, so that the abnormal frame can be avoided from being included in the statistics.
[0021] In a possible design manner of the first aspect, the first image includes an image corresponding to a cumulative number of frames.
[0022] In a possible design of the first aspect, the method further includes: in response to the first frame image display of the first application ending, querying a second frequency corresponding to a second discrete load and a second discrete operating value in a frequency modulation relationship table, wherein the second discrete load is a discrete value of a current CPU load of the first device, and the second discrete operating value is a discrete value of current operating information of the first application in the first device. Adjusting the CPU frequency to the second frequency.
[0023] In a possible design of the first aspect, the first device includes multiple value intervals of CPU load and multiple discrete load values corresponding to each other, as well as multiple value intervals of operation information and multiple discrete operation values corresponding to each other. The first discrete load is a discrete load value corresponding to the value interval to which the current CPU load of the first device belongs, and the first discrete operation value is a discrete operation value corresponding to the value interval to which the current operation information of the first application belongs.
[0024] In a possible design of the first aspect, the first application is a game application, and the information of the application screen includes at least one of the following: the complexity of the game screen and indication information of whether the game screen includes team battle content.
[0025] In the second aspect, the present application also provides a method for generating a frequency modulation relationship table, which is applied to a second device. Among them, the values of the CPU load and the values of the running information of the first application are discretized to obtain multiple value intervals of the CPU load and multiple discrete load values corresponding to each other, as well as multiple value intervals of the running information and multiple corresponding discrete running values, and the running information includes at least one of the load of the application thread and the information of the application screen. At preset time intervals, the second load of the CPU in the test device and the second running information of the first application in the test device are obtained. The third discrete load value corresponding to the second load and the third discrete running value corresponding to the second running information are mapped to obtain the discrete load value corresponding to the value interval to which the second load belongs, and the third discrete running value is the discrete running value corresponding to the value interval to which the second running information belongs. The third discrete load value and the third discrete running value are used as the state in reinforcement learning, the CPU frequency is used as the action in reinforcement learning, and the application frame rate and CPU power consumption of the first application are used as the reward of reinforcement learning to train a preset reinforcement learning network (such as a DQN network) to obtain a regulation model. Arrange and combine multiple discrete load values and multiple discrete running values to obtain multiple groups of discrete state combinations. Input multiple discrete state combinations into the regulation model respectively, run the regulation model, and obtain multiple target frequencies corresponding to the multiple discrete state combinations. The frequency regulation relationship table includes the multiple discrete state combinations and the corresponding multiple target frequencies.
[0026] In summary, after the second device obtains the regulation model through training, it further converts the regulation model into a frequency modulation relationship table. Subsequently, the frequency modulation relationship table is transplanted to the device in need, and the optimal frequency corresponding to the discrete state value (such as the first discrete load value, the first operating load value) of the real-time state can be obtained by querying the frequency modulation relationship table. In this way, the calculation in the process of determining the frequency can be simplified.
[0027] In a possible design of the first aspect, training a preset reinforcement learning network to obtain a regulation model includes: inputting a third discrete load value and a third discrete operating value into the preset reinforcement learning network, and outputting a third frequency. Sending a frequency modulation instruction to a test device, the frequency modulation instruction is used to instruct to adjust the frequency of the CPU to a first frequency. Obtaining a first frame rate of a first application in the test device, and obtaining a first power consumption of the CPU corresponding to the third frequency. Adjusting the preset reinforcement learning network based on the first frame rate and the first power consumption.
[0028] In a possible design of the second aspect, the obtaining of the first frame rate of the first application in the test device includes: obtaining the first frame rate of the first application in the test device at a first time interval after sending a frequency modulation instruction to the test device. In this way, it can be ensured that the obtained frame rate is feedback from the test machine after adjusting the CPU frequency to the first frequency.
[0029] In a possible design manner of the second aspect, the second load is an average load of the test device within a preset time period, and the second operation information is average operation information of the first application in the test device within a preset time period.
[0030] In a possible design manner of the second aspect, after obtaining multiple target frequencies corresponding one-to-one to multiple groups of discrete state combinations, the method further includes: sending a frequency modulation relationship table to a first device, wherein the first device includes a first application.
[0031] In a possible design of the second aspect, the first application is a game application, and the information of the application screen includes at least one of the following: the complexity of the game screen and indication information of whether the game screen includes team battle content.
[0032] In a third aspect, the present application also provides an electronic device, which may be the first device or the second device mentioned above, and the electronic device includes: a memory and one or more processors, and the memory is coupled to the processor; wherein computer program code is stored in the memory, and the computer program code includes computer instructions, and when the computer instructions are executed by the processor, the electronic device executes the method in the first aspect, the second aspect and any possible design thereof.
[0033] In a fourth aspect, the present application also provides a chip system, which is applied to an electronic device including a processor and a memory. The chip system includes one or more interface circuits and one or more processors. The interface circuit and the processor are interconnected through lines. The interface circuit is used to receive signals from the memory of the electronic device and send signals to the processor. The signals include computer instructions stored in the memory. When the processor executes the computer instructions, the electronic device executes the methods in the above-mentioned first aspect, second aspect and any possible design method thereof.
[0034] In a fifth aspect, the present application also provides a computer-readable storage medium, comprising computer instructions, which, when executed on a server, enable the server to execute the method in the first aspect and any possible design thereof; or, when executed on an electronic device, enable the electronic device to execute the method in the first aspect, the second aspect and any possible design thereof.
[0035] In a sixth aspect, the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the method described in the first aspect, the second aspect, and any possible design thereof.
[0036] It can be understood that the beneficial effects that can be achieved by the electronic device, chip system, computer storage medium, and computer program product provided above can refer to the beneficial effects in the first aspect, the second aspect and any possible design method thereof, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A schematic diagram of the principle of reinforcement learning;
[0038] Figure 2 A schematic diagram of the composition of a communication system provided in an embodiment of the present application;
[0039] Figure 3 An interactive schematic diagram of generating and using a frequency modulation relationship table provided in an embodiment of the present application;
[0040] Figure 4 A schematic diagram of the principle of discretization processing provided in an embodiment of the present application;
[0041] Figure 5 A schematic diagram of the use of a regulation model provided in an embodiment of the present application;
[0042] Figure 6 A software architecture diagram of a mobile phone provided in an embodiment of the present application;
[0043] Figure 7 An interactive schematic diagram of a frequency modulation method provided in an embodiment of the present application;
[0044] Figure 8 One of the flow charts of the frequency modulation method provided in the embodiment of the present application;
[0045] Fig. 9 The second flowchart of the frequency modulation method provided in the embodiment of the present application;
[0046] Fig.10 The third flowchart of the frequency modulation method provided in the embodiment of the present application;
[0047] Fig.11 A fourth flowchart of the frequency modulation method provided in an embodiment of the present application;
[0048] Fig.12 One of the schematic diagrams of a training process provided in an embodiment of the present application;
[0049] Fig.13 A schematic diagram of the composition of a network structure provided in an embodiment of the present application;
[0050] Fig.14 A second schematic diagram of a training process provided in an embodiment of the present application;
[0051] Fig.15 A structural diagram of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] The technical solutions in the embodiments of the present application are described below in conjunction with the drawings in the embodiments of the present application. Among them, in the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "a", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear indication to the contrary in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one or more (including two). The term "and / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist; for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in a "or" relationship.
[0053] References to "one embodiment" or "some embodiments" etc. described in this specification mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Thus, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways. The term "connection" includes direct connection and indirect connection, unless otherwise specified. "First" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
[0054] In the embodiments of the present application, the words "exemplarily" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a specific way.
[0055] The frequency modulation method provided in the embodiment of the present application can be applied to scenarios where the CPU frequency needs to be adjusted, such as gaming scenarios, drama watching scenarios, video call scenarios, etc. It should be understood that the higher the frequency of the CPU in the device, the more powerful the CPU can provide, thereby improving the performance of the device; the lower the frequency of the CPU, the more limited the CPU can provide, thereby reducing the power consumption of the device and avoiding excessive temperature of the device.
[0056] Taking the game scenario as an example, the device can meet the high frame rate requirements of the game by increasing the CPU frequency; and the device can reduce power consumption and avoid excessive temperature of the device by lowering the CPU frequency. That is, in the game scenario, the game frame rate and device power consumption can be balanced by adjusting the CPU frequency.
[0057] In some embodiments, in the above-mentioned CPU adjustment scenario, the device scheduler, such as Energy Aware Scheduling (EAS), Completely Fair Scheduler (CFS), power governor, etc., selects the corresponding CPU frequency based on the CPU load (utilization) measured in the historical window. As the load increases, a higher frequency is selected to meet the computing power requirements.
[0058] In this embodiment, the basis for selecting the frequency is the CPU load, which reflects the resource utilization of the entire device and has a very coarse granularity. In addition, in this embodiment, the goal of selecting the frequency is only to meet the computing power requirements and complete the task as soon as possible, but it is impossible to achieve a balance between computing power and power consumption.
[0059] Based on this, in other embodiments, a reinforcement learning method may be used to train and obtain an adjustment model. Then, the device uses the adjustment model to adjust the frequency of the CPU.
[0060] In order to facilitate the understanding of the embodiments of the present application, a brief introduction to reinforcement learning is given below:
[0061] Reinforcement learning is a process in which an agent learns by trial and error and guides its behavior through rewards obtained through interaction with the environment. The goal is to maximize the reward for the agent.
[0062] Reinforcement learning consists of three main components: state, action, and reward. The state is a description of the environment, and the state will change after the agent takes an action. The action is a description of the agent's behavior and is the result of the agent's decision. In other words, the action has the effect of changing the state. And the reward (positive or negative) is calculated by the agent based on the feedback from the environment after it takes an action. The agent can adjust the decision-making strategy based on the reward for subsequent decision-making actions. The principle of decision-making is to increase the probability of positive rewards.
[0063] For example, see Figure 1 , at time t, the state of the environment is st, and the agent can decide on action at based on state st. At time t+1, the agent performs action at on the environment, and the state of the environment changes from st to st+1, and the reward fed back by the environment to the agent is Rt+1. Then, the agent can update the decision strategy based on the reward Rt+1. Then, the agent uses the updated decision strategy to decide on the action corresponding to state st+1, and performs the action on the environment at the next moment... and so on.
[0064] Corresponding to this embodiment, the intelligent agent may be a device for performing reinforcement learning, such as a personal computer (PC). The environment may be a device that needs to determine the frequency of the CPU, such as a test machine.
[0065] The state includes at least two of the following: CPU load, application thread load, and application screen content (such as the complexity of the screen content, etc.). Taking a game application as an example, the state may include information such as CPU load, game thread load, game frame rate, the intensity of the fight in the screen, whether the screen includes group battle content, etc. In a game application, the load of a game thread refers to the time taken by one or more game threads to run within a frame length (such as 11.11ms, 16.67ms, 20ms, etc.) when a specific core (such as the core with the largest computing power) runs at a specific frequency (such as the highest frequency). In other words, if it is not running at a specific frequency on a specific core, then a conversion is required to convert the load of the game thread to the result of running at a specific frequency on a specific core. In this way, the measurement standard of the load of the game thread can be unified and the consistency of the training samples can be improved. For the sake of convenience, the above-mentioned states other than the CPU load, such as the load of the application thread and the content of the application screen, can be referred to as the running information of the application.
[0066] Action refers to the frequency of the CPU. It should be understood that the CPU can support a variety of frequencies, such as 800MHz, 1GHz, 1.2GHz, etc. Correspondingly, there should be multiple corresponding actions in the action set. The agent can decide the CPU frequency corresponding to the current state st from the frequencies of multiple CPUs, so as to increase the probability of the agent obtaining a positive reward.
[0067] And, the reward is a function of the application performance parameters and the CPU power consumption parameters. That is, the reward parameters used to calculate the reward include the application performance parameters and the CPU power consumption parameters. In this way, the application performance (such as game frame rate, picture clarity, etc.) and the CPU power consumption can be balanced in the reward. It should be understood that the essence of the environment's feedback reward to the agent is: the environment feeds back the reward parameters to the agent. Subsequently, the agent needs to calculate the reward based on the reward parameters and update the decision-making strategy accordingly.
[0068] After the adjustment model is obtained through the above training, the adjustment model is transplanted into the device. When the device runs the application, it can collect the state s and input it into the adjustment model. After running the adjustment model, the CPU frequency can be output. Taking the game application as an example, the device inputs the CPU load in the current frame, the load of the game thread, the game frame rate, the intensity of the fight in the picture, whether the picture includes team battle content, and other state information into the adjustment model, and the adjustment model can output the CPU frequency in the next frame.
[0069] In this embodiment, on the one hand, the adjustment model is trained for the application and used to determine the CPU frequency when the application is running. In this way, the frequency of the CPU adjusted is more in line with the application requirements, with the application as the granularity. On the other hand, the reward in the reinforcement learning process balances the application performance and the CPU power consumption, rather than just considering the CPU power consumption. In this way, the CPU frequency determined by the adjustment model is more reasonable.
[0070] However, in this embodiment, after the device inputs the state s into the adjustment model, it needs to run the adjustment model, that is, complete the inference operation of the adjustment model, in order to infer the CPU frequency. The inference operation of the adjustment model has a considerable amount of calculation, and the inference operation by the CPU, GPU or digital signal processor (DSP) requires considerable power consumption, resulting in an increase in the device temperature.
[0071] Furthermore, a large number of continuous state values can be discretized to obtain finite discrete state values. During the training process, the state value of the acquired state can be mapped to the corresponding discrete state value, and then input into the network model for training to obtain the adjustment model. Then, the adjustment model is converted into a mapping relationship table of discrete state values and CPU frequencies. When frequency modulation is required, the current state can be collected and discretized to obtain the current discrete state value, and the optimal frequency corresponding to the real-time discrete state value can be obtained by querying the mapping relationship table (also called the frequency modulation relationship table). In this way, the device can determine the frequency of the CPU by simply looking up the table, thereby simplifying the calculation and reducing the power consumption caused by determining the frequency of the CPU. Finally, the device adjusts the frequency of the CPU to the optimal frequency, so that at the optimal frequency, the device can balance the application performance and the power consumption of the CPU.
[0072] In some scenarios, the application may be upgraded and revised. At the same time, the above mapping table cannot be automatically updated. Therefore, after the mobile phone obtains the mapping table, as the application is upgraded and revised, the mapping table may no longer be applicable and the appropriate frequency cannot be obtained.
[0073] Based on this, an embodiment of the present application provides a frequency modulation method, which can be applied to scenarios where the frequency of the CPU needs to be adjusted, such as gaming scenarios, drama watching scenarios, video call scenarios, etc. After the device obtains the mapping relationship table, it can monitor whether the mapping relationship table is valid during the process of running the target application (such as a gaming application). If it is monitored that the mapping relationship table is valid, it indicates that the mapping relationship table can be used to obtain the appropriate CPU frequency. In this case, the device can continue to use the mapping relationship table to determine the CPU frequency. If it is monitored that the mapping relationship table is invalid, it indicates that the mapping relationship table can no longer be used to obtain the appropriate CPU frequency. In this case, the device no longer uses the mapping relationship table to determine the CPU frequency. In this way, the mapping relationship table can be used only when the mapping relationship table can be well applied, so that the mapping relationship table can be used to obtain the appropriate CPU frequency.
[0074] The above frequency modulation method can be applied to the communication system provided in the embodiment of the present application. Figure 2 , the communication system includes one or more first devices (such as Figure 2 The mobile phone 210, tablet computer 220) and the second device (such as Figure 2 PC230 in the figure). The second device is used to train the adjustment model, convert the adjustment model into a mapping relationship table of discrete state values and CPU frequencies, and send it to the first device. The first device is a device that needs to be frequency modulated, and is used to determine the CPU frequency that matches the current state based on the mapping relationship table, thereby achieving frequency modulation. Exemplarily, the first device can be a mobile phone, tablet computer, PC, or other device that has frequency modulation requirements, such as a device with a game application installed. The second device can be a server, server cluster, PC, or other device with strong computing power.
[0075] In some embodiments, the communication system further includes a third device (such as Figure 2 The third device is the source device of the training samples (including the state samples and the reward samples). That is, the second device obtains the state st, the reward Rt+1 and st+1 from the third device during the training of the adjustment model.
[0076] It should be understood that the process of training the adjustment model and converting the adjustment model into a mapping relationship table of discrete state values and CPU frequencies can also be completed in different devices. Exemplarily, the communication system also includes a fourth device ( Figure 2 The fourth device is used to train the adjustment model and send it to the second device, and the second device is used to convert the adjustment model into a mapping relationship table between discrete state values and CPU frequencies and send it to the first device. Figure 2 The communication system shown is taken as an example to illustrate the frequency modulation method provided in the embodiment of the present application.
[0077] The frequency modulation method of the embodiment of the present application can be implemented in the above communication system. The following further combines the drawings to illustrate the embodiment of the present application by taking the first device as a mobile phone, the second device as a PC, and the target application as a game application as an example.
[0078] The present application embodiment first illustrates the specific process of obtaining the mapping relationship table and adjusting the CPU frequency using the mapping relationship table by the mobile phone. Figure 3 , the process includes:
[0079] S301. PC maps a state value of a continuous state into multiple discrete state values.
[0080] The continuous state refers to a state including a large number (i.e., exceeding a preset number) of continuous state values. Any state other than the continuous state is a discrete state.
[0081] Taking a game application as an example, the state includes at least two of the following: CPU load, game thread load, game frame rate, the intensity of the fight in the picture, and whether the picture includes group battle content. Among them, the CPU load and the game thread load usually include a large number of continuous state values, so the CPU load and the game thread load are continuous states. For example, the game thread load is measured in microseconds (us), and its value can be 0us, 1us, 2us, 3us...10000us, 10001us, 10002us..., obviously, its value is continuous and very many. Therefore, the CPU load and the game thread load are continuous states. In addition to the CPU load and the game thread load, the game frame rate, the intensity of the fight in the picture, and whether the picture includes group battle content usually only include a small number of limited state values, so the game frame rate, the intensity of the fight in the picture, and whether the picture includes group battle content are all discrete states. For example, whether the picture includes group battle content only includes two state values of "yes" and "no".
[0082] PC can divide the state value of each continuous state into multiple state intervals, and then map the multiple state intervals one by one to the corresponding multiple discrete state values, thereby mapping the state value of the continuous state to a small number of discrete state values.
[0083] For example, see Figure 4, the state value of a continuous state includes a natural number from 0 to a very large value MAX. The PC can divide the state value into 8 state intervals, namely 0-50, 51-140, 141-200, 201-250, 251-300, 301-360, 361-450, 451-Max, and map the value of the state interval 0-50 to discrete state value 1, the value of the state interval 51-140 to discrete state value 2...map the state interval 361-450 to discrete state value 7, and map the state interval 451-Max to discrete state value 8. Thus, the continuous state including a large number of state values is mapped to 8 offline states.
[0084] It should be noted that for each continuous state, the state intervals obtained by division may be different, and the number of state intervals may also be different. For example, the state value of continuous state a can be divided into 10 state intervals, and the state value of continuous state b can be divided into 8 state intervals.
[0085] S302, the PC collects training samples, maps the state values of the continuous states in the training samples to discrete state values, and then performs training.
[0086] The training samples include state samples and reward samples. The state samples refer to the states obtained from the test machine, and the reward samples refer to the reward parameters obtained from the test machine.
[0087] Specifically, PC determines the target state interval to which the state value of the continuous state in the training sample belongs, and the target state interval is one of the multiple state intervals. Then, the discrete state value corresponding to the target state interval is determined as the discrete state value mapped to the state value of the continuous state in the training sample. For example, multiple state intervals corresponding to a continuous state and their discrete state values are as follows: Figure 4 It shows that if the state value of the continuous state in the training sample is 150, which belongs to the state interval 141-200, then the target state interval is 141-200, and the mapped discrete state value is 3.
[0088] It should be understood that the state st may include one or more continuous states. If it includes multiple continuous states, the PC needs to discretize the state value of each continuous state.
[0089] After the PC discretizes the state value of the continuous state in the state sample, the discretized state sample can be obtained for training the adjustment model. It should be understood that during the training process, the input is a discrete state sample, so the adjustment model obtained by training can output the corresponding CPU frequency based on the input discrete state.
[0090] S303, the PC arranges and combines the discrete state values of the multiple states to obtain multiple discrete combinations.
[0091] The multiple states include continuous states and discrete states. Moreover, in any two discrete combinations, there is at least one state with a different discrete state value.
[0092] It should be noted that when performing permutations and combinations, all possibilities need to be traversed, so that the corresponding relationship between all discrete combinations and CPU frequencies can be obtained.
[0093] See also Figure 5 , with multiple states including state Sx and state Sy, the discrete state values of state Sx include x1, x2, x3, x4, and the discrete state values of state Sy include y1 and y2, then multiple (4*3) discrete combinations are shown in Table 1 below:
[0094] Table 1
[0095] y1 y2 x1 (x1,y1) (x1,y2) x2 (x2,y1) (x2,y2) x3 (x3,y1) (x3,y2) x4 (x4,y1) (x4,y2)
[0096] As shown in Table 1 above, there are 8 discrete combinations, including (x1,y1), (x1,y2), (x2,y1), (x2,y2), (x3,y1), (x3,y2), (x4,y1) and (x4,y2), which traverse all possible combinations.
[0097] S304, the PC inputs the plurality of discrete state combinations into the adjustment model respectively, obtains information of a plurality of optimal frequencies corresponding to the plurality of discrete state combinations one by one, and generates a mapping relationship table of the discrete state combinations and the information of the optimal frequencies.
[0098] See also Figure 5 , PC inputs the discrete state combination obtained after discretization (such as (Sx', Sy')) into the regulation model, and the regulation model can output a set of probabilities, such as {Qa, Qb, Qc, Qd}. Each probability in this set of probabilities corresponds to a CPU frequency. And, the higher the probability, the higher the value of selecting the corresponding CPU frequency. For example, Qa corresponds to the probability of frequency f1, Qb corresponds to the probability of frequency f2, Qc corresponds to the probability of frequency f3, Qd corresponds to the probability of frequency f4, and Qa>Qb>Qc>Qd, which means that the values of f1, f2, f3 and f4 decrease in turn.
[0099] After the adjustment model outputs a set of probabilities, the PC can determine the maximum probability, and the frequency corresponding to the maximum probability is the optimal frequency (also called the target frequency). That is, the frequency with the greatest value is selected as the optimal frequency. Figure 5 Taking {Qa, Qb, Qc, Qd} as an example, Qa>Qb>Qc>Qd, then the maximum probability is Qa, and the optimal frequency is the frequency corresponding to the maximum probability. For example, if Qa corresponds to the probability of frequency f1, then the optimal frequency is f1.
[0100] Among them, the information of the optimal frequency can be the frequency value of the optimal frequency. For example, the information of the target probability is f1. Alternatively, the information of the optimal frequency can also be the sequence number of the maximum probability in a group of probabilities. For example, a group of probabilities output by the adjustment model is {Qa, Qb, Qc, Qd}. If Qa is the largest, then, since the sequence number of Qa in {Qa, Qb, Qc, Qd} is 1, the information of the target probability can be 1; if Qb is the largest, then, since the sequence number of Qb in {Qa, Qb, Qc, Qd} is 2, the information of the target probability can be 2; if Qc is the largest, then, since the sequence number of Qc in {Qa, Qb, Qc, Qd} is 3, the information of the target probability can be 3; if Qd is the largest, then, since the sequence number of Qd in {Qa, Qb, Qc, Qd} is 4, the information of the target probability can be 4.
[0101] Taking the example that the information of the optimal frequency is the sequence number with the maximum probability, the 8 discrete state combinations in Table 1 above are respectively input into the adjustment model, and the information of the optimal frequency can be obtained as shown in Table 2 below.
[0102] Table 2
[0103] y1 y2 x1 No.{argmax[Q(x1,y1)]} No.{argmax[Q(x1,y2)]} x2 No.{argmax[Q(x2,y1)]} No.{argmax[Q(x2,y2)]} x3 Number {argmax[Q(x3,y1)]} No.{argmax[Q(x3,y2)]} x4 Number {argmax[Q(x4,y1)]} Number {argmax[Q(x4,y2)]}
[0104] In Table 2 above, (xi, yj) represents a discrete state combination. Q(xi, yj) represents a set of probabilities output by the adjustment model after the discrete state combination is input into the adjustment model. argmax[Q(x1, y2)] represents the maximum value in a set of probabilities, that is, the maximum probability. The serial number {argmax[Q(x2, y2)]} represents the serial number of the maximum probability in a set of probabilities.
[0105] Table 2 above is a mapping relationship table of discrete state combinations and optimal frequency information.
[0106] S305. The PC sends a mapping relationship table, multiple state intervals of continuous states and their corresponding discrete state values to the mobile phone.
[0107] Among them, multiple state intervals of the continuous state and their corresponding discrete state values can be used by the mobile phone to convert the state value of the continuous state into a discrete state value.
[0108] And, the mapping relationship table can be used by the mobile phone to determine the optimal frequency corresponding to the current state.
[0109] It should be understood that the PC can send the information directly to the mobile phone, or the PC can send the information to the mobile phone through the cloud / server, and the embodiments of the present application do not specifically limit this.
[0110] After the mapping relationship table is sent to the mobile phone, the mobile phone can use the mapping relationship table to adjust the CPU frequency when processing each frame of the image during the application running process. It should be noted that when the application is just started, in addition to the CPU load, there is no status information such as the application frame rate, the application thread load, and the content of the application screen (such as the complexity of the screen content, etc.). Therefore, in some embodiments, when the application is just started, the mobile phone can set the frequency of a specific CPU, or use EAS, CFS, power scheduler, etc. to set the CPU frequency. Subsequently, starting from the end of the kth frame, the mobile phone uses the mapping relationship table to determine the optimal frequency, where k takes values from {1,2,3,4...} in sequence.
[0111] S306 . In response to the end of the kth frame, the mobile phone collects current state values of multiple states, maps the current state values of the continuous states into discrete state values, and obtains a current discrete state combination.
[0112] The k-th end refers to the end of displaying the k-th frame image. After the k-th frame image is finished displaying, the k+1-th frame image will start to be displayed. That is, the end of the k-th frame is also the start of the k+1-th frame.
[0113] For the specific implementation of the discretization process, please refer to the relevant description in S302 above, which will not be repeated here.
[0114] It should be noted that the state value of a discrete state is a discrete state value and does not need to be further discretized. For example, multiple states include the load of the game thread and whether the screen includes team battle content. Whether the screen includes team battle content is a discrete state, and its possible state values are "yes" or "no", which is a discrete state value. Therefore, it does not need to be discretized in S306.
[0115] If multiple states are continuous states, the current discrete state combination includes the discrete state values corresponding to the current state values of the multiple continuous states. If multiple states include at least one continuous state and at least one discrete state, the current discrete state combination includes the discrete state value corresponding to the current state value of at least one continuous state and the current state value of at least one discrete state.
[0116] For example, multiple states include the load of the game thread (continuous state) and whether the screen includes group battle content (discrete state). The current state value of the load of the game thread collected by the mobile phone is 10000us, which is mapped to the discrete state value x2, and the current state value of whether the screen includes group battle content is "yes" (represented by y1). Then, the current discrete state combination is [x2, y1].
[0117] S307. The mobile phone searches the mapping relationship table for the current discrete state combination to determine the optimal frequency.
[0118] For example, the current discrete state combination is [x2, y1], and the mapping relationship table is Table 2 in the previous text. The mobile phone searches [x2, y1] in Table 2 and can obtain the target probability information: serial number {argmax[Q(x2, y1)]}. Then, the PC can determine the frequency corresponding to "serial number {argmax[Q(x2, y1)]}", such as f2, as the optimal frequency.
[0119] S308. The mobile phone adjusts the CPU frequency to the optimal frequency.
[0120] In this way, the CPU can operate at the optimal frequency to ensure a balance between gaming performance and CPU power consumption.
[0121] It should be noted that before the image is displayed, the image rendering process is also included, and image rendering occupies CPU resources. Moreover, when the kth frame ends, the k+1th frame image is about to be displayed, which means that the k+1th frame image has been rendered and does not need to occupy CPU resources. Therefore, at the end of the kth frame, the optimal frequency determined by the mobile phone is mainly used by the CPU to render the k+2th frame image while displaying the k+1th frame image.
[0122] It should be understood that the above S306-S308 can be executed continuously. For example, at the end of each frame of the game, such as the end of the 1st frame, the 2nd frame, the 3rd frame, etc., the above S306-S308 can be used to make the CPU work at the optimal frequency during the next frame, thereby ensuring the balance between the game frame rate and the CPU power consumption.
[0123] At this point, it should be noted that in many cases, the CPU includes multiple cores, such as dual-core, quad-core, octa-core, etc. Different cores can run independently to process different tasks. In these cases, it is necessary to train a single core, and the adjustment model obtained by training can be used to determine the frequency of the corresponding core in the CPU. Moreover, during the training process, the load of the CPU in the state sample refers to the load of the corresponding core in the CPU, and the load of the game thread refers to the load of the thread running in the core. Subsequently, when the mobile phone uses the mapping relationship table to determine the load of the CPU, in the collected current state value, the load of the CPU also refers to the load of the corresponding core in the CPU, and the load of the game thread also refers to the load of the thread running in the core.
[0124] Furthermore, the software and hardware architecture of the mobile phone can adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. In this article, the Android system with a layered architecture is taken as an example to illustrate the software and hardware structure of the mobile phone.
[0125] See also Figure 6 , is a diagram of the software and hardware architecture of a mobile phone provided in an embodiment of the present application. Figure 6 As shown, the layered architecture divides the software and hardware into several layers, and each layer has a clear role and division of labor. Data transmission and communication are carried out between layers through software or hardware interfaces. In some embodiments, the Android system is divided from top to bottom into an application layer, an application framework layer, an Android runtime (Android runtime) and a system library (Native), a hardware abstract layer (HAL), a kernel layer, and a hardware layer.
[0126] The application layer can include a series of application packages. Figure 6 As shown, the application package may include applications such as memo, calculator, call, browser, video, game, etc. For ease of explanation, an application that needs to refresh images frequently during operation may be referred to as a first application, such as a game application, a video player, etc.
[0127] In an embodiment of the present application, a regulation model can be trained for a single application and used to determine the frequency of the CPU during the operation of the application.
[0128] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0129] The application framework layer may include a notification manager, a window manager, a resource manager, a content provider, and a view system, etc.
[0130] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, prompting text information in the status bar, issuing a prompt sound, terminal device vibration, indicator light flashing, etc. The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, touch the screen, drag the screen, capture the screen, etc. The resource manager provides various resources for applications, such as localized strings, icons, pictures, layout files, video files, etc. The content provider is used to implement data sharing between different applications, allowing one program to access data in another program while ensuring the security of the accessed data. The view system can be responsible for the interface drawing and event processing of the application.
[0131] Android runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0132] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0133] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0134] The system library can include multiple functional modules. For example: Media Libraries, Function Libraries, etc. The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The function library provides developers with a variety of service API interfaces, which facilitates developers to quickly integrate and implement various functions.
[0135] In some embodiments, the system library also includes a graphics processing library (e.g., OpenGL ES), which is used to implement graphics drawing, image rendering, synthesis, and layer processing. In the process of image rendering, the graphics processing library can be used to convert drawing commands into graphics commands. In a specific implementation, the scheduling service can determine the content of the application screen (such as the complexity of the screen content, etc.) based on the graphics commands converted by the graphics processing library.
[0136] In some embodiments, the system library also includes a window system (SurfaceFlinger). The window system can send each rendered frame of the image to the display screen for display. Among them, when the window system sends the k+1th frame of the image to the display screen for display, it means that the kth frame ends and the k+1th frame begins. That is, the window system can determine the start time point and the end time point of displaying each frame of the image. In a specific implementation method, the scheduling service can determine the application frame rate (such as the game frame rate) based on the time point recorded in the window system. For example, the window system records the time information t1 of sending the kth frame of the image and the time information t2 of sending the k+1th frame of the image, then t2-t1 is the frame length of the kth frame, which is equivalent to indirectly obtaining the frame rate.
[0137] In some embodiments, the system library also includes a scheduling service, such as a gamesScheduler, which is used to determine the optimal frequency based on the mapping relationship table. In addition, the scheduling service can store the mapping relationship table for determining the optimal frequency.
[0138] The kernel layer is the layer between hardware and software. The kernel layer can include display drivers, camera drivers, audio drivers, Bluetooth drivers, WiFi drivers, CPU drivers, etc.
[0139] In some embodiments, the kernel layer also includes a frequency modulation module, a scheduler, and a game feature collector.
[0140] The frequency regulation module (governor) is used to control the frequency of the CPU, for example, to adjust the frequency of the CPU to an optimal frequency.
[0141] The scheduler is the EAS, CFS or power scheduler mentioned above. It selects the frequency of the corresponding CPU based on the CPU load. For details, please refer to the description of EAS, CFS or power scheduler mentioned above, which will not be repeated here.
[0142] The feature collector (task load scheduler) is used to obtain the CPU load from the scheduler.
[0143] The hardware layer includes processors such as CPU, GPU, DSP, etc. In the embodiment of the present application, the frequency of the CPU can be adjusted to the optimal frequency, thereby achieving a balance between application performance and CPU power consumption.
[0144] The present application embodiment will be combined with Figure 6 The software and hardware architecture of the present invention also takes the game application as an example to further illustrate the process of adjusting the CPU frequency of the mobile phone based on the mapping relationship table (ie, the process of S306-S308).
[0145] See also Figure 7 , taking the state including the CPU load and the complexity of the screen as an example, S306 includes:
[0146] S701. When the window system sends an image to be displayed to a display screen, the window system records current time information.
[0147] After rendering and synthesis, each frame of the application (i.e., the image to be displayed) needs to be sent to the display screen through the window system, and then the display screen displays the image to be displayed. At this time, the application screen is refreshed from the current frame to the next frame. Then, the time when the window system sends the image to be displayed to the display screen can be roughly considered as the time when the application screen is refreshed. For example, if the window system sends the image to be displayed to the display screen at time a, it is roughly considered that the application screen is refreshed at time a.
[0148] It should be understood that the application frame rate is the number of application image frames refreshed per second. For example, if the application frame rate is 60 frames, it means that the application screen is refreshed 60 frames per second. The reciprocal of the application frame rate is the time interval between refreshing two frames of the application image, that is, the frame length. One time information recorded by the window system can reflect the time of one refresh, and multiple time information can reflect the time interval between multiple refreshes, which can be used to calculate the frame length.
[0149] S702: The window system sends time information to the scheduling service.
[0150] After receiving the time information, the scheduling service will calculate the application frame rate, as shown in S703 below, and obtain the CPU load, as shown in S704-S706 below. In this way, the state for determining the optimal frequency is obtained.
[0151] S703 . In response to receiving the time information (ie, the end of the kth frame), the scheduling service determines the application frame rate based on the time information.
[0152] In some embodiments, the scheduling service may determine the time difference between the two most recently received time information as the frame length, and determine the reciprocal of the frame length as the application frame rate. For example, the time information received the last two times is 8:20 and 8:20:020 milliseconds (ms), respectively, and the time difference is 20ms, that is, the frame length is 20ms, then the application frame rate is 1 / 20ms=50 frames.
[0153] In other embodiments, the scheduling service may determine the average time difference of the time information received for the most recent n times as the frame length, and determine the reciprocal of the frame length as the application frame rate. Where n is a natural number greater than 0, such as 3, 4, 5, 10, 20, etc. Taking n=3 as an example, the time information received for the most recent three times is 8:20, 8:20:020 milliseconds, and 8:20:036 milliseconds, respectively. The average time difference is 36ms / 2=18ms, that is, the frame length is 18ms, and the application frame rate is 1 / 18ms≈55 frames.
[0154] S704: In response to receiving the time information, the scheduling service sends an acquisition request to the feature collector.
[0155] The acquisition request is used to request the CPU load.
[0156] S705 . In response to receiving the acquisition request, the feature collector acquires the CPU load from the scheduler.
[0157] S706: The feature collector returns the CPU load to the scheduling service.
[0158] S707: The scheduling service maps the CPU load to a discrete state value to obtain a current discrete state combination, wherein the current discrete state combination includes the discrete state value of the CPU load and the application frame rate.
[0159] In the acquired state, the application frame rate is a discrete state, and the CPU load is a continuous state. Therefore, the scheduling service needs to discretize the CPU load to obtain a discrete state value. Then the discrete state value of the CPU load and the application frame rate are combined into a discrete state combination.
[0160] S307 further includes:
[0161] S708. The scheduling service queries the current discrete state combination in the mapping relationship table to determine the optimal frequency.
[0162] S308 further includes:
[0163] S709. The dispatch service sends the optimal frequency to the frequency modulation module.
[0164] S710: The frequency adjustment module adjusts the frequency of the CPU to an optimal frequency.
[0165] It should be understood that in the test machine, the above Figure 7 The similar process of S701-S706 in the above process is used to collect state samples, and the above process is used to collect state samples. Figure 7 The S707-S710 uses a similar process to tune the frequency.
[0166] In some scenarios, the application may be upgraded and revised. At the same time, the above mapping relationship table cannot be automatically updated. Therefore, after the mobile phone obtains the mapping relationship table, as the application is upgraded and revised, the mapping relationship table may no longer be applicable.
[0167] Based on this, in some embodiments, after the mobile phone obtains the mapping relationship table, the mobile phone can monitor whether the mapping relationship table is valid. If it is monitored that the mapping relationship table is invalid, it means that the use of the mapping relationship table can no longer obtain the appropriate CPU frequency. For this situation, the mobile phone can use a backup frequency modulation scheme to determine the CPU frequency. If it is monitored that the mapping relationship table is valid, it means that the use of the mapping relationship table can obtain the appropriate CPU frequency. For this situation, the mobile phone can continue to use the mapping relationship table to determine the CPU frequency. In this way, the mapping relationship table can be used only when the mapping relationship table can be well applied, so that the use of the mapping relationship table can obtain the appropriate CPU frequency.
[0168] The optimal frequency set at the end of the kth frame is used to render the k+2th frame image during the display of the k+1th frame image. Then, the effect feedback of the optimal frequency set at the end of the kth frame can only be obtained at the end of the k+1th frame, and is used to monitor whether the mapping relationship table is valid. For example, the effect feedback of the optimal frequency set at the end of the 1st frame can only be obtained at the end of the 2nd frame. Among them, the monitoring results can also be used to guide whether to continue to use the mapping relationship table to determine the optimal frequency at the end of the k+1th frame. That is to say, at the end of the 2nd frame and each frame thereafter (i.e., k≥2), on the one hand, the mobile phone needs to monitor whether the mapping relationship table is valid; on the other hand, the mobile phone needs to choose to use the mapping relationship table or the backup frequency modulation scheme based on the monitoring results to determine the optimal frequency.
[0169] It should be understood that at the end of the first frame, the mobile phone can directly use the mapping table to determine the optimal frequency without monitoring whether the mapping table is valid. That is, in response to the end of the first frame, the mobile phone can directly execute S606-S607 to determine the optimal frequency corresponding to the current state.
[0170] Then, for the second frame and each frame thereafter, it is necessary to monitor whether the mapping table is valid, and based on the monitoring result, select to use the mapping table or the backup frequency modulation scheme to determine the optimal frequency. Figure 8,Take a game application as an example, during the process from starting to closing (the game process is cleared), at the end of the kth frame, before using the mapping relationship table to determine the optimal frequency, it is also necessary to monitor whether the mapping relationship table is valid.
[0171] S801, in response to the end of the kth frame, the mobile phone monitors whether the mapping relationship table is valid based on the frame length, k≥2. If yes, execute S306-S307. If no, execute S802.
[0172] The moment when the kth frame ends can be understood as the moment when the window system sends the k+1th frame of the image to be displayed to the display screen.
[0173] The game frame rate is an important indicator for measuring game performance. It refers to the number of frames of the game screen that can be displayed per second. For example, a game frame rate of 60 frames means that the game screen is refreshed 60 frames per second. The higher the game frame rate, the better the game performance can be guaranteed by the optimal frequency determined based on the mapping relationship table.
[0174] Frame length refers to the time interval between two screen refreshes, that is, the display duration of each frame. It should be understood that the higher the game frame rate, the shorter the frame length is. For example, if the game frame rate is 60 frames, the frame length should be 16.67ms; if the game frame rate is 90 frames, the frame length should be 11.11ms.
[0175] Based on this, the mobile phone can monitor whether the mapping relationship is valid based on the game frame length. Among them, the mobile phone determines the frame length by obtaining the time point of the screen refresh (such as the time information recorded by the window system). Exemplarily, as long as the mobile phone obtains the time point of the two adjacent frames of the screen refresh, it can determine a frame length. For example, by obtaining the time point t1 when the kth frame ends and the time point t2 when the k-1th frame ends, it can be determined that the frame length of the kth frame is t2-t1.
[0176] In practice, the frame length of a certain frame may be subject to accidental factors, which cannot accurately reflect the effect of using the mapping relationship table. Based on this, in some embodiments, the mobile phone can calculate the average frame length of multiple frames, and monitor whether the mapping relationship table is valid based on the average frame length. Exemplarily, at the end of the kth frame, the mobile phone can calculate the average frame length dn from the knth frame to the kth frame, and monitor whether the mapping relationship table is valid based on dn. For example, the mobile phone can find the difference between the time point at which the kth frame ends and the time point at which the knth frame ends, and then divide it by the number of frames n to obtain dn.
[0177] For the sake of convenience, the image used to calculate the frame length in S801 may be referred to as a first image, such as a k-th frame image or a kn-th frame image to a k-th frame image.
[0178] Specifically, if the frame length is higher than the preset frame length (also referred to as the first frame length threshold), it indicates that the optimal frequency determined using the mapping relationship table cannot guarantee the game frame rate, so it can be determined that the mapping relationship table is invalid. If the frame length is lower than or equal to the preset frame length, it indicates that the optimal frequency determined using the mapping relationship table can guarantee the game frame rate, so it can be determined that the mapping relationship table is valid.
[0179] Taking the preset frame length as 18ms as an example, if the calculated frame length (or average frame length) is 20ms when the kth frame ends, which is higher than the preset frame length, the mobile phone can determine that the mapping relationship table is invalid.
[0180] If it is detected that the mapping relationship table is valid, the mobile phone may continue to use the mapping relationship table to determine the optimal frequency and adjust the frequency, such as executing S306-S308.
[0181] If it is detected that the mapping relationship table is invalid, the mobile phone needs to avoid using the mapping relationship table. For example, the mobile phone may execute the following S802.
[0182] S802. The mobile phone uses the backup frequency modulation scheme to determine the optimal frequency.
[0183] In a specific implementation (which may be referred to as backup plan 1), the backup frequency modulation plan may be to obtain the CPU load through EAS, CFS or a power scheduler, and then select the corresponding CPU frequency based on the CPU load to meet the computing power requirements.
[0184] In another specific implementation (which may be referred to as Alternative Plan 2), the alternative frequency modulation plan may obtain the functional relationship between the load of a single game thread (such as rendering thread UnityGfx or main thread UnityMain), the game frame rate, and the CPU frequency through linear fitting. Then, the load of a single game thread and the game frame rate collected in real time are used to determine the optimal frequency based on the functional relationship.
[0185] In practice, the above two alternative solutions can also be combined. For example, for some cores in the CPU, the above alternative solution 1 can be used to determine the optimal frequency, and for other cores of the CPU, the above alternative solution 2 can be used to determine the optimal frequency. For example, for medium cores, solution 2 is used, and for large cores, solution 1 is used.
[0186] By adopting this embodiment, when the mapping relationship table is valid, the mapping relationship table can be used to obtain the optimal frequency. In this way, it can be ensured that a reasonable frequency is obtained by using the mapping relationship table.
[0187] In the process of running a game application from startup to shutdown (the game process is cleared), if the mapping table has expired, the mapping table will not be restored to validity in a short period of time. In other words, during a run, if the mapping table is detected to be invalid, the mapping table will usually not be used during the run, but the backup frequency modulation scheme will be used all the time. After using the backup frequency modulation scheme, the game frame rate is no longer caused by the invalid mapping table.
[0188] Based on this, further, after the mobile phone detects that the mapping relationship table is invalid, it can record the working state of the mapping relationship table as an invalid state. Correspondingly, at the end of each frame, the mobile phone will first query the working state of the mapping relationship table. If the working state is a valid state (also called the first state), the mobile phone directly uses the backup frequency modulation scheme to determine the optimal frequency without continuing to monitor whether the mapping relationship table is valid. If the working state is a failed state (also called the second state), the mobile phone directly uses the backup frequency modulation scheme to determine the optimal frequency without continuing to monitor whether the mapping relationship table is valid.
[0189] For details, see Fig. 9 , before S801, also includes:
[0190] S901. In response to the end of the kth frame, the mobile phone queries the mapping relationship table to see whether the working state is a valid state. The initial value of the working state is a valid state, and k≥2.
[0191] It should be noted that each time the game application starts running, the mapping relationship table is used by default to determine the optimal frequency, and the default mapping relationship table is valid at this time. Based on this, the initial value of the working state can be set to a valid state.
[0192] In a specific implementation, the mobile phone may use a first tag (such as true) to indicate a valid state, and use a second tag (such as false) to indicate an invalid state. Accordingly, in S901, if the mobile phone queries the first tag, it determines that the working state of the mapping relationship table is a valid state; if the mobile phone queries the second tag, it determines that the working state of the mapping relationship table is an invalid state.
[0193] If the query shows that the working status is valid, it means that the k-th frame still uses the mapping relationship table to determine the optimal frequency. Then, the mobile phone needs to continue to monitor whether the mapping relationship table is valid, such as executing S801. If the query shows that the working status is invalid, it means that the backup frequency modulation scheme is used to determine the optimal frequency in the k-th frame. Then, the mobile phone does not need to continue to monitor whether the mapping relationship table is valid, but continues to use the backup frequency modulation scheme to determine the optimal frequency, such as executing S802. In this way, only when the mapping relationship table is valid, it is necessary to further monitor whether the mapping relationship table is valid, and reduce the amount of calculation by reducing the number of monitoring times.
[0194] Correspondingly, after executing S801, if it is monitored that the mapping relationship table is valid, it indicates that the mapping relationship table is still valid. In this case, the mobile phone uses the mapping relationship table to determine the optimal frequency and adjust the frequency, such as executing S306 and subsequent steps.
[0195] On the contrary, after executing S801, if it is detected that the mapping relationship table is invalid, it means that the mapping relationship table has changed from a valid state to an invalid state. In view of this situation, on the one hand, the mobile phone needs to use a backup frequency modulation scheme to determine the optimal frequency, such as executing S802. In other words, if the working state is found to be invalid, or the mapping relationship table is detected to be invalid, S802 needs to be executed. On the other hand, the mobile phone needs to update the working state of the mapping relationship table so that the updated working state can be queried later.
[0196] S902: The working state of the mobile phone updating mapping relationship table is invalid.
[0197] After the working status of the mapping relationship table is updated to an invalid state, subsequent queries on the working status will determine the use of the backup frequency modulation scheme.
[0198] In this way, when the working state of the mapping relationship table is an invalid state, the mobile phone does not need to continue to monitor whether the mapping relationship table is valid, but directly uses the backup frequency modulation scheme.
[0199] It should be noted that during the running of a game application, its frame rate may be affected by many factors, not just the failure of the mapping relationship table.
[0200] Based on this, the mobile phone needs to eliminate the influence of abnormal factors before monitoring whether the mapping relationship table is valid. In this way, it can avoid the problem of abnormal factors causing the game frame rate to decrease, and mistakenly attribute it to the invalidity of the mapping relationship table.
[0201] For details, see Fig.10 , before S801, the frequency modulation method also includes:
[0202] S1001, in response to the end of the kth frame, the mobile phone detects whether there are abnormal factors other than the mapping relationship table that affect the frame rate. If not, execute S801; if yes, execute S306.
[0203] Among them, the mobile phone may include a high temperature frame limit strategy, that is, when the temperature of the mobile phone is higher than a preset temperature, the mobile phone will limit the game frame rate to below the preset frame rate. Under normal circumstances, the game frame rate will not be lower than the preset frame rate.
[0204] Therefore, in a specific implementation, in S1001, the mobile phone can detect whether the game frame rate is lower than the preset frame rate. If it is lower than the preset frame rate, it indicates that there may be a high temperature abnormality, and the mobile phone can determine that there is an abnormal factor.
[0205] Taking the preset frame rate of 48 frames as an example, the time point at which the kth frame ends is t1, and the time point at which the k-1th frame ends is t2. The mobile phone can determine that the frame length of the kth frame is t2-t1, such as t2-t1=22ms. Then, the mobile phone converts the frame length 22ms into the game frame rate, and the game frame rate can be obtained as 1s / 22ms=45 frames, which is obviously less than the preset frame rate of 48 frames. It is very likely caused by high temperature frame limit.
[0206] During the game, due to abnormalities in the Double Data Rate (DDR) (Synchronous Dynamic Random Access Memory, SDRAM) or slow loading of the input output (IO), the frame length of a certain frame may be particularly long. For example, a certain frame needs to load a map, and the map is stored in the DDR. If the DDR is abnormal or the IO loading is slow, the map will load slowly, the screen will refresh slowly, and the frame length will be very long.
[0207] Therefore, in another specific implementation, in S1002, the mobile phone can also detect whether the frame length is higher than the upper limit of the frame length, such as the upper limit of the frame length is twice the target frame length, and the target frame length corresponds to the target frame rate (such as 60 frames, 90 frames, etc.). If it is higher than the upper limit of the frame length, it indicates that the kth frame is an abnormal frame caused by DDR abnormality or slow IO loading, and the mobile phone can determine that there is an abnormal factor.
[0208] That is to say, if the kth frame is an abnormal frame due to high temperature frame limit, DDR abnormality or slow IO loading, then the frame length of the kth frame image will be very long. Therefore, in actual implementation, the mobile phone can compare the frame length of the kth frame image with a larger frame length threshold (also called the second frame length threshold). If the frame length of the kth frame image is higher than the frame length threshold, the kth frame is determined to be an abnormal frame, that is, there is an abnormal factor; if the frame length of the kth frame image is lower than or equal to the frame length threshold, the kth frame is determined not to be an abnormal frame, that is, there is no abnormal factor.
[0209] If there are no abnormal factors, it indicates that the frame rate is most likely caused by the mapping relationship table. In this case, the mobile phone needs to monitor whether the mapping relationship table is valid, such as executing S801. If there are abnormal factors, it indicates that the kth frame is an abnormal frame. Even if the frame rate is low, it cannot be determined that it is caused by the failure of the mapping relationship table. In this case, the mobile phone can assume that the mapping relationship table is valid and use the mapping relationship table to determine the optimal frequency, such as executing S306 and S307.
[0210] In order to facilitate Figure 8-Figure 10 The understanding of the scheme shown below is combined with Fig.11 A specific implementation method shown further details the frequency modulation scheme of each frame during the running of the game application.
[0211] See also Fig.11 , frequency modulation methods include:
[0212] S1101, in response to the end of the kth frame, the mobile phone queries the mapping table to see whether the working state is valid, and the initial value of the working state is valid. If yes, execute S1102; if not, execute S1107.
[0213] For details about S1101, please refer to the description of S901 above.
[0214] S1102, the mobile phone detects whether there are abnormal factors other than the mapping relationship table that affect the frame rate. If not, execute S1103; if yes, execute S306.
[0215] Among them, abnormal factors include high temperature frame limit abnormality, DDR abnormality, slow IO loading, etc. For details, please refer to the description of S1001 above.
[0216] In this implementation, the mapping table is monitored for validity every m frames. For example, m=3600, 5400, etc. Moreover, the frame length of the abnormal factor in the aforementioned S1102 is abnormal and has no reference value. Therefore, in this implementation, S1103 is executed after the abnormal factor is eliminated to update the cumulative number of frames and the average frame length. In other words, the cumulative number of frames and the average frame length only count the frames other than the abnormal factor.
[0217] S1103. The mobile phone updates the cumulative number of frames and the average frame length. The initial value of the cumulative number of frames is 0.
[0218] The accumulated frame number is used to determine the timing of effectiveness monitoring. When the accumulated frame number reaches the preset frame number m, that is, the interval is m frames, the timing of monitoring effectiveness is determined. In addition, the initial value of the accumulated frame number is the value of the accumulated frame number when the game application is started.
[0219] Specifically, when the mobile phone updates the cumulative frame number, it can add 1 to the cumulative frame number to obtain the updated cumulative frame number. For example, if the existing cumulative frame number is 8, the cumulative frame number can be updated to 9 when executing S1103.
[0220] The average frame length refers to the average frame length corresponding to the cumulative number of frames. For example, the cumulative frames are 3601, 3602, 3603 (3604 is a frame with abnormal factors and is not counted) and 3605, a total of 4 frames, then the cumulative number of frames is 4, and the average frame length refers to the average frame length of 3601, 3602, 3603 and 3605. That is, the average frame length is irrelevant to the frames with abnormal factors.
[0221] Specifically, when the mobile phone updates the average frame length, it sums the frame lengths of the accumulated frames and then divides it by the accumulated number of frames to obtain the average frame length. Furthermore, in order to reduce data storage, the mobile phone can calculate the average frame length y by the following rolling averaging method: y = (x*y0+y1) / (x+1). Among them, x is the accumulated number of frames before the update, y0 is the average frame length before the update, and y1 is the frame length of the kth frame. That is, when updating the average frame length, it is only necessary to multiply the average frame length obtained by historical statistics by the accumulated number of frames, and then add the frame length of the kth frame to obtain the sum of the frame lengths corresponding to the updated accumulated number of frames. In this way, the mobile phone only needs to obtain the sum of the frame lengths of the accumulated frames based on the accumulated number of frames before the update, the average frame length, and the frame length of the kth frame, without having to store the frame lengths of each accumulated frame, which can save storage resources.
[0222] S1104, the mobile phone detects whether the accumulated frame number reaches the preset frame number m. If yes, execute S1105; if no, execute S306.
[0223] If the accumulated number of frames reaches the preset number of frames m, it means that m normal frames have been separated and it is time to monitor the validity. In this case, the mobile phone needs to monitor the validity of the mapping relationship table, such as executing S1105.
[0224] If the accumulated number of frames does not reach the preset number of frames m, it means that n normal frames have not been spaced and the time for effectiveness monitoring has not been reached. In this case, and because the working state is found to be effective in S1101, the mobile phone continues to use the mapping table to determine the optimal frequency, such as executing S306.
[0225] S1105, the mobile phone monitors whether the mapping relationship table is valid based on the average frame length, and clears the accumulated number of frames and the average frame length. If yes, execute S306; if no, execute S1106.
[0226] For the specific implementation of monitoring whether the mapping relationship table is valid, please refer to the description of S801 above, which will not be repeated here.
[0227] If the mapping table is valid, the working state is kept valid and S306 is executed to use the mapping table for frequency modulation. If the mapping table is invalid, on the one hand, the mobile phone needs to execute S1106 so as to switch to the backup frequency modulation scheme for frequency modulation. On the other hand, the mobile phone needs to execute S1107 to determine the frequency of the kth frame.
[0228] After the mobile phone detects whether the mapping table is valid or not, it clears the accumulated number of frames and the average frame length to zero, thus starting a new round of statistics.
[0229] S1106: The working state of the mobile phone updating mapping relationship table is invalid.
[0230] After the working status of the mapping relationship table is updated to an invalid state, subsequent queries on the working status will determine the use of the backup frequency modulation scheme.
[0231] S1107. The mobile phone uses the backup frequency modulation scheme to determine the optimal frequency.
[0232] For details about S1107, please refer to the description of S802 above.
[0233] That is to say, when the working status is found to be a failure state, or when the mapping relationship table is detected to be failure, the mobile phone will use the backup frequency modulation scheme to determine the optimal frequency.
[0234] Here are some typical examples to illustrate Fig.11 The effect of the implementation shown.
[0235] Example 1: There are x1 abnormal frames in the frames 1 to m, and the average frame length of the frames 1 to m+x1 except the abnormal frames is greater than the preset frame length. Then, use Fig.11 The effect is as follows:
[0236] When all frames except frame x1 in frames 1 to m+x1-1 are finished, the mobile phone will execute S1101-S1104 and S306-S308 in sequence.
[0237] After the x1th frame ends, the mobile phone will execute S1101-S1102, S306-S308 in sequence.
[0238] After the m+x1th frame ends, the mobile phone will execute S1101-S1107 and S308 in sequence.
[0239] After the m+x1+1th frame and subsequent frames are completed, the mobile phone will execute S1101, S1107, and S308 in sequence.
[0240] It can be seen from this that if the mapping relationship table becomes invalid when the game application is opened, the mobile phone will detect it when the normal frames accumulate to m frames, and there is no need to monitor each subsequent frame again.
[0241] Example 2: There are no abnormal frames. The average frame length of the 1st to mth frames is less than the preset frame length, the average frame length of the m+1st to 2mth frames is less than the preset frame length, and the average frame length of the 2m+1st to 3mth frames is less than the preset frame length. Then, use Fig.11 The effect is as follows:
[0242] From frame 1 to frame m-1, the mobile phone will execute S1101-S1104, S306-S308 in sequence.
[0243] In the mth frame, the mobile phone will execute S1101-S1104, S306-S308 in sequence.
[0244] From frame m+1 to frame 2m-1, the mobile phone will execute S1101-S1104, S306-S308 in sequence.
[0245] In the 2mth frame, the mobile phone will execute S1101-S1104, S306-S308 in sequence.
[0246] From frames 2m+1 to 3m-1, the mobile phone will execute S1101-S1104 and S306-S308 in sequence.
[0247] In the 3mth frame, the mobile phone will execute S1101-S1104, S306-S308...
[0248] It can be seen that if the mapping relationship table has not been invalidated, the mapping relationship table will be used for frequency modulation in each frame.
[0249] After the mapping relationship table becomes invalid, on the one hand (as mentioned above Figure 8-Figure 11As shown), the mobile phone needs to adopt an alternative frequency modulation scheme to determine the optimal frequency to ensure that the CPU frequency is adjusted to an appropriate value; on the other hand, the mapping relationship table needs to be updated to obtain a mapping relationship table that can match the revised and upgraded game application to determine the appropriate optimal frequency.
[0250] For this aspect, the mobile phone can report relevant detection data to the server for the server to analyze whether the mapping relationship table needs to be updated. For example, the server finds through big data analysis that a large number of mobile phones switch to the backup frequency modulation scheme to determine the optimal frequency when the CPU temperature is not high. Therefore, the server can determine that the mapping relationship table needs to be updated.
[0251] After the server determines that the mapping relationship table needs to be updated, the PC can update the mapping relationship table. For example, the embodiment of the present application will illustrate the specific implementation of updating the mapping relationship table:
[0252] See also Fig.12 In this embodiment, the process of collecting training samples and training to obtain the adjustment model by the PC includes:
[0253] S1, build a reinforcement learning network model in the PC, such as building the model architecture, setting the initial network parameters, setting the reward function, loss function, etc.
[0254] Among them, the network model can be a model architecture suitable for reinforcement learning, such as Q-learning, sarsa, DQN (Deep Q Network), etc., and the embodiment of the present application does not make specific limitations on this.
[0255] Take the DQN network as an example, see Fig.13, the model architecture includes an input layer, a hidden layer, an output layer, a normalization module, and a value function module. Among them, the input layer, the hidden layer, and the output layer are the layers of the neural network. The input layer is used to input the state, and the number of items in the input layer is equal to the number of items in the state. Each item is used to input a state. For example, the state includes two items, the CPU load and the game thread load, then the input layer includes two items, Sa and Sb, Sa is used to input the CPU load, and Sb is used to input the game thread load. The number of items in the output layer is equal to the number of actions in the action set. For example, there are 4 frequencies supported by the CPU, then the output layer includes 4 items, Aa, Ab, Ac, and Ad. The normalization module is used to normalize the values of the output layer to obtain the probabilities corresponding to each action, and the sum of the probabilities of multiple actions is 1. The value function module is used to output multiple probability values, and the number of items in the value function module is equal to the number of actions in the action set. Each item corresponds to the probability of an action, that is, the probability of a CPU frequency. For example, the frequencies supported by the CPU are f1, f2, f3 and f4, then the output layer includes 4 items, Qa, Qb, Qc and Qd, and Qa corresponds to the probability of frequency f1, Qb corresponds to the probability of frequency f2, Qc corresponds to the probability of frequency f3, and Qd corresponds to the probability of frequency f4.
[0256] Furthermore, the parameters of the reward function (i.e., reward parameters) include game performance and CPU power consumption. In this way, the reward used to guide the adjustment of network parameters can balance game performance and CPU power consumption, thereby improving the rationality of the adjustment model obtained through training.
[0257] After S1, the PC can obtain training samples from the test machine, and then the PC runs the network model (such as the DQN network) based on the training samples to train and obtain the adjustment model.
[0258] See also Fig.14 , the test machine can build an Android Debug Bridge (adeb) environment and run the acquisition service in the adeb environment. The acquisition service can serve as a transfer station for training samples. When running the game application, the test machine can transmit the training samples to the acquisition service frame by frame. Among them, the training samples include status (such as CPU load, game thread load, etc.) and rewards (such as game frame rate). For example, the test machine can transmit the status of each frame (such as CPU load, game thread load) and game frame rate to the acquisition service through a socket.
[0259] In some embodiments, the acquisition service receives training samples frame by frame and calculates the average value for each item in the training samples, for example, the average value of the CPU load, the average value of the game thread load, the average value of the game frame rate, etc. In this way, even if the PC fails to obtain the training samples from the test machine in time due to communication delay, the acquisition service in the test machine can always store the average value of a group of training samples by averaging, so that the PC can obtain it.
[0260] Specifically, the PC obtains a state sample through the following S2.
[0261] S2, at time t, the PC obtains the CPU load, game thread load, game screen content and other status st from the test machine.
[0262] Exemplarily, the PC can obtain the status from the collection service in the adeb environment of the test machine. Fig.14 The "data capture" in the PC shown can obtain the status from the acquisition service using a socket.
[0263] It should be noted that each time the PC obtains a training sample from the collection service, the training sample in the collection service will be cleared and the PC will start to receive a new training sample.
[0264] S30. PC maps the state value of the continuous state in the state st to a discrete state value to obtain a state st'.
[0265] In this embodiment, after obtaining the state st, the PC does not directly input the state st into the network model, but first discretizes the state value of the continuous state. For example, Fig.14 The "discretization processing" in the PC shown can discretize the state st obtained by "data capture" to obtain the state st'.
[0266] For example, the mapping relationship between multiple state intervals of a continuous state and multiple discrete state values is as follows: Figure 4 As shown, the state value of the continuous state in state st can be Figure 4 The mapping relationship is mapped to a discrete state value. For example, if the state value of the continuous state in st is 150, which belongs to the state interval 141-200, it can be mapped to a discrete state value 3. For another example, if the state value of the continuous state in st is 350, which belongs to the state interval 300-360, it can be mapped to a discrete state value 6.
[0267] In some embodiments, in addition to the above discretization process, the PC can also perform smoothing on the state, for example, using an attenuation method or a weighted method within a window to perform smoothing, which is beneficial to the convergence of the network model.
[0268] S31. The PC inputs the state st' into the network model, and the network model decides the frequency of the CPU from the action set, that is, decides the action at.
[0269] S4, the PC sends an action at to the test machine, and the test machine adjusts the CPU frequency to the frequency indicated by the action at.
[0270] S5, at time t+1, the PC obtains game performance, such as game frame rate, from the test machine.
[0271] For example, the PC can also obtain the game frame rate from the acquisition service in the adeb environment of the test machine.
[0272] It should be noted that after the PC sends the action at to the test machine, it can wait for a preset period of time and then obtain the game frame rate from the test machine to ensure that the obtained game frame rate is the game performance obtained after the test machine adjusts the CPU frequency.
[0273] S6, PC calculates the reward Rt+1. PC inputs the reward Rt+1 into the network model, and the network model updates the decision strategy based on the reward Rt+1, that is, updates the model parameters of the network model. In addition, at time t+1, PC can also obtain the CPU load, game thread load, and game screen content status from the test machine st+1.
[0274] Among them, the reward is a function of game performance and CPU power consumption to ensure that the reward can balance game performance and CPU functionality. Exemplarily, the PC can calculate the reward based on the game frame rate and power consumption. Of course, the PC can also adjust the weights of game performance and CPU power consumption in the reward. For example, increase the weight of game performance so that the trained adjustment model focuses on game performance. For another example, increase the weight of CPU power consumption so that the trained adjustment model focuses on functionality.
[0275] The power consumption of the CPU is related to the frequency of the CPU. The PC may store a fitting curve of the power consumption and frequency of the CPU. Moreover, after each action at is determined, the PC determines the power consumption corresponding to the action at based on the fitting curve.
[0276] Accordingly, PC uses the loss function to evaluate whether the network model converges. If converged, the training ends. If not, S30 and its subsequent steps (i.e., the iteration process) continue to be executed. It should be understood that in the iteration process, t=t+1. Then, the state st+1 obtained in this round can be used as the state st of the next iteration.
[0277] Through training, the network parameters of the network model can be obtained, that is, an updated adjustment model can be obtained. Then, by adopting the steps S303 and S304 above, a mapping relationship table of discrete state combinations and optimal frequency information can be generated, that is, an updated mapping relationship table can be obtained.
[0278] After obtaining the updated mapping relationship table, the PC can send the updated mapping relationship table to the mobile phone. In this way, the mobile phone can use the updated mapping relationship table to determine the optimal frequency. Further, the PC can send the difference table before and after the update to the mobile phone to reduce the amount of data sent.
[0279] The embodiment of the present application also provides an electronic device, which may include: a memory and one or more processors. The memory and the processor are coupled. The memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the electronic device can execute various functions or steps of the mobile phone in the above method embodiment.
[0280] The present application also provides a chip system, such as Fig.15 As shown, the chip system 1500 includes at least one processor 1501 and at least one interface circuit 1502. The processor 1501 and the interface circuit 1502 can be interconnected via lines. For example, the interface circuit 1502 can be used to receive signals from other devices (such as a memory of an electronic device). For another example, the interface circuit 1502 can be used to send signals to other devices (such as processor 1501). Exemplarily, the interface circuit 1502 can read instructions stored in the memory and send the instructions to the processor 1501. When the instructions are executed by the processor 1501, the electronic device can execute the various steps in the above embodiments. Of course, the chip system can also include other discrete devices, which are not specifically limited in the embodiments of the present application.
[0281] This embodiment also provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed on an electronic device, the electronic device executes each function or step in the above method embodiment.
[0282] This embodiment also provides a computer program product. When the computer program product is run on a computer, it enables the computer to execute each function or step in the above method embodiment.
[0283] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor can execute the computer-executable instructions stored in the memory so that the chip performs the various functions or steps in the above-mentioned method embodiments.
[0284] Among them, the electronic device, communication system, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above and will not be repeated here.
[0285] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0286] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0287] The unit described as a separate component may or may not be physically separated, and the component shown as a unit may be one physical unit or multiple physical units, that is, it may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiment.
[0288] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0289] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program code.
[0290] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.
Claims
1. A frequency modulation method, characterized in that: Applied to a first device, the first device includes a first application and a frequency modulation relationship table, the frequency modulation relationship table includes multiple groups of discrete state combinations and corresponding multiple target frequencies, each group of discrete state combinations includes a discrete load value of a CPU load and a discrete running value of running information of the first application, the running information includes at least one of a load of an application thread and information of an application screen, the method includes: Starting the first application; In response to the k-th frame image of the first application being displayed, if the display frame length of the first image is lower than the first frame length threshold, querying the first frequency corresponding to the first discrete load and the first discrete running value in the frequency modulation relationship table, where the first discrete load is a discrete value of the current CPU load of the first device, the first discrete running value is a discrete value of the current running information of the first application in the first device, and the first image includes the k-th frame image, k=2, 3, 4, 5, ..., k is an integer; The frequency of the CPU is adjusted to the first frequency.
2. The method according to claim 1, characterized in that If the display frame length of the first image is higher than the first frame length threshold, the frequency modulation relationship table is not used to query the frequency.
3. The method according to claim 1, characterized in that: The first device includes a working state of the frequency modulation relationship table, and when the first application is started, the working state is a first state, and the method further includes: The querying the first frequency corresponding to the first discrete load and the first discrete operating value in the frequency modulation relationship table includes: If the working state is the first state, a first frequency corresponding to a first discrete load and a first discrete operating value is searched in the frequency modulation relationship table.
4. The method according to claim 3, characterized in that The method further comprises: If the display frame length of the first image is higher than the first frame length threshold, updating the working state to the second state; In which, in response to the completion of display of the (k+1)th frame image of the first application, the frequency modulation relationship table is not used to query the frequency.
5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: If the display frame length of the k-th image frame is lower than the second frame length threshold, it is detected whether the display frame length of the first image is lower than the first frame length threshold.
6. The method according to claim 5, characterized in that The method further comprises: If the display frame length of the k-th image frame is higher than the second frame length threshold, query the first frequency corresponding to the first discrete load and the first discrete operating value in the frequency modulation relationship table; wherein the first device does not detect whether the display frame length of the first image is lower than the first frame length threshold; The frequency of the CPU is adjusted to the first frequency.
7. The method according to any one of claims 1 to 4, characterized in that The first device includes a cumulative frame number, and when the first application is started, the cumulative frame number is 0; Before searching the frequency modulation relationship table for a first frequency corresponding to a first discrete load and a first discrete operating value, the method further includes: Increasing the accumulated number of frames by one; If the accumulated number of frames is equal to the preset number of frames, it is detected whether the display frame length of the first image is lower than a first frame length threshold.
8. The method according to claim 7, characterized in that After detecting whether the display frame length of the first image is lower than a first frame length threshold, the method further includes: The accumulated number of frames is cleared.
9. The method according to claim 7, characterized in that: The method further comprises: If the accumulated number of frames is less than the preset number of frames, querying the first frequency corresponding to the first discrete load and the first discrete operating value in the frequency modulation relationship table; wherein the first device does not detect whether the display frame length of the first image is less than the first frame length threshold; The frequency of the CPU is adjusted to the first frequency.
10. The method according to claim 7, characterized in that The step of increasing the accumulated number of frames by one comprises: If the display frame length of the k-th image frame is lower than the second frame length threshold, the accumulated frame number is increased by one.
11. The method according to claim 7, characterized in that The first image includes an image corresponding to the accumulated number of frames.
12. The method according to any one of claims 1 to 4, characterized in that The method further comprises: In response to the first frame image of the first application being displayed, querying the frequency modulation relationship table for a second frequency corresponding to a second discrete load and a second discrete operating value, where the second discrete load is a discrete value of a current CPU load of the first device, and the second discrete operating value is a discrete value of current operating information of the first application in the first device; The frequency of the CPU is adjusted to the second frequency.
13. The method according to any one of claims 1 to 4, characterized in that The first device includes multiple value intervals of the CPU load and multiple discrete load values corresponding to each other, and multiple value intervals of the operation information and multiple discrete operation values corresponding to each other; The first discrete load is a discrete load value corresponding to a value interval to which a current CPU load of the first device belongs, and the first discrete operation value is a discrete operation value corresponding to a value interval to which current operation information of the first application belongs.
14. The method according to any one of claims 1 to 4, characterized in that The first application is a game application, and the information of the application screen includes at least one of the following: the complexity of the game screen and indication information of whether the game screen includes team battle content.
15. An electronic device, characterized in that: The electronic device is the first device in any one of claims 1-14, and the electronic device comprises: a memory and one or more processors, wherein the memory is coupled to the processor; wherein computer program code is stored in the memory, and the computer program code comprises computer instructions, and when the computer instructions are executed by the processor, the electronic device executes the method in any one of claims 1-14.
16. A computer-readable storage medium, characterized in that: The method comprises computer instructions, which, when executed on a first device, cause the first device to execute the method according to any one of claims 1 to 14.
17. A chip system, characterized in that: The chip system is applied to an electronic device including a processor and a memory. The chip system includes one or more interface circuits and one or more processors. The interface circuit and the processor are interconnected via lines. The interface circuit is used to receive a signal from the memory of the electronic device and send the signal to the processor. The signal includes a computer instruction stored in the memory. When the processor executes the computer instruction, the electronic device executes the method as described in any one of claims 1 to 14.
