WO2015154562A1 - 降低中央处理器能耗的方法、装置、终端及计算机存储介质 - Google Patents

降低中央处理器能耗的方法、装置、终端及计算机存储介质 Download PDF

Info

Publication number
WO2015154562A1
WO2015154562A1 PCT/CN2015/070936 CN2015070936W WO2015154562A1 WO 2015154562 A1 WO2015154562 A1 WO 2015154562A1 CN 2015070936 W CN2015070936 W CN 2015070936W WO 2015154562 A1 WO2015154562 A1 WO 2015154562A1
Authority
WO
WIPO (PCT)
Prior art keywords
cpu
frequency
memory access
main memory
access rate
Prior art date
Application number
PCT/CN2015/070936
Other languages
English (en)
French (fr)
Inventor
郑鹏飞
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2015154562A1 publication Critical patent/WO2015154562A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/26Power supply means, e.g. regulation thereof
    • G06F1/32Means for saving power

Definitions

  • the present invention relates to the field of computers, and in particular, to a method, an apparatus, a terminal, and a computer storage medium for reducing power consumption of a central processing unit.
  • Mobile Internet Since the third generation of mobile communications (3G), the mobile Internet has developed rapidly. Based on the outlook for the future, people have proposed pervasive computing, that is, ubiquitous computing. At present, the fourth generation of mobile communication technology (4G) has begun construction and use in many countries. Therefore, it is foreseeable that the mobile Internet will continue to develop rapidly over time.
  • Mobile Internet has a large number of terminal devices, but the operating system used is based on Google's Android system, Apple's IOS system and Microsoft's Windows Phone system. Among them, the Android system occupies the vast majority of market share.
  • Google's Android system is based on the Linux kernel 2.6.33 and has been modified to accommodate mobile devices for power management and memory management and runtime management.
  • the reason for the improvement of Linux kernel power management is that the mobile device running Android system has limited battery capacity and the energy saving features are different from those of personal computers.
  • Google has developed a power driver for peripheral power management that controls screen display and backlighting, keyboard backlighting, and button backlighting. The basic principle is to switch the state of the system through locks and timers to minimize system power consumption.
  • the power control of peripheral devices is mainly achieved by "WakeLocks".
  • the application applies for a "wake-up lock” through a Power Management API (Application Programming Interface) in the application framework, and displays the screen normally through the "wake-up lock” and makes the CPU (Central Processing Unit)
  • the central processing unit (hereinafter referred to as the processor) is in the AWAKE state to quickly handle the interrupt event.
  • the specific process is shown in Figure 1.
  • the CPU In mobile devices, the CPU is one of the main energy consuming devices.
  • the power management of the CPU in the power management of Android is implemented by Governor.
  • Android-supported Governor mainly includes Performance Governor, Powersave Governor and OnDemand Governor. Among them, Performance Governor always keeps the CPU at the highest frequency; Powersave Governor keeps the CPU at the lowest frequency; OnDemand Governor sets the CPU frequency according to the CPU usage, specifically, sets the two thresholds up_ultilization and down_ultilization. When the CPU usage is greater than up_ultilization, it will be directly The CPU frequency is set to the maximum value, and when the CPU usage is less than down_ultilization, the CPU frequency is reduced by 20%. Users can choose the appropriate Governor as needed.
  • Android provides a Userspace governor that provides users with available frequency information, allowing users to control the CPU frequency based on this information through the Linux sysfs interface to implement user-level managers.
  • Android provides a relatively simple power management framework that provides a set of power management interfaces to application developers through the PowerManager class. Android power management is mainly used to reduce the energy consumption when certain components in the system are idle or not used.
  • Android's Android system saves power by dynamically adjusting the voltage and CPU frequency (Dynamic Voltage and Frequency Scaling, DVFS) to extend battery life. This method is inherited from Linux power management.
  • the energy-saving management method for the CPU For example, when the CPU and peripheral devices (such as a display screen) are in an idle state, the CPU or peripheral device is switched to the idle mode or the power saving mode.
  • the PowerSave governor is usually chosen to set the CPU clock and voltage to a minimum.
  • the lowest CPU frequency and voltage are not necessarily the best way to reduce energy consumption. Because during the actual program execution, the CPU may need to stop and wait for the peripheral to perform I/O processing.
  • OnDemand governor because OnDemand governor uses two thresholds to adjust the CPU frequency, the advantage of this method is simple and easy to implement, but the setting is not accurate enough, the task is likely to reach the set threshold and directly set the CPU frequency to the maximum. And the task may not need to set the CPU frequency to the maximum, thus failing to achieve the task with the lowest energy consumption that the user envisions.
  • the prior art cannot optimize the CPU frequency for different situations to save energy as much as possible.
  • the embodiments of the present invention provide a method, an apparatus, a terminal, and a computer storage medium for reducing power consumption of a central processing unit, so as to at least solve the problem that the CPU needs to reduce energy consumption as much as possible in the related art.
  • an embodiment of the present invention provides a method for reducing power consumption of a central processing unit, including:
  • adjusting the main frequency of the CPU according to the main memory access rate specifically includes:
  • main memory access rate is calculated according to formula (1):
  • M access_rate is the main memory access rate
  • N access_miss is the number of times the CPU access cache cache fails
  • N instruction is the number of instructions executed by the CPU.
  • the adjusted CPU frequency is determined according to formula (2):
  • f opt is the target frequency, that is, the adjusted CPU frequency
  • f min is the minimum frequency supported by the CPU
  • f max is the maximum frequency supported by the CPU
  • M max is the maximum memory access rate supported by the main memory.
  • the main frequency of the CPU is adjusted to be the lowest frequency.
  • an embodiment of the present invention provides an apparatus for reducing power consumption of a central processing unit, including:
  • the main memory access rate obtaining unit is configured to obtain a main memory access rate of the CPU of the central processing unit
  • the CPU main frequency adjustment unit is configured to adjust the main frequency of the CPU according to the main memory access rate.
  • the CPU frequency adjustment unit is set to:
  • the main frequency of the CPU is lowered; when the currently obtained main memory access rate is lower than the last obtained main memory access rate, the improvement is performed.
  • the main frequency of the CPU is lowered
  • main memory access rate obtaining unit calculates the main memory access rate according to the formula (1):
  • M access_rate is the main memory access rate
  • N access_miss is the number of times the CPU access cache cache fails
  • N instruction is the number of instructions executed by the CPU
  • the CPU main frequency adjustment unit determines the adjusted CPU frequency according to formula (2):
  • f opt is the target frequency, that is, the adjusted CPU frequency
  • f min is the minimum frequency supported by the CPU
  • f max is the maximum frequency supported by the CPU
  • M max is the maximum memory access rate supported by the main memory.
  • CPU frequency adjustment unit is further configured to:
  • the main frequency of the CPU is adjusted to be the lowest frequency.
  • the present invention also provides a terminal that uses the above-described means for reducing the power consumption of the central processing unit to adjust the primary frequency of the central processing unit.
  • an embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores computer executable instructions, and the computer executable instructions are used in the foregoing method for reducing power consumption of a central processing unit.
  • the invention dynamically adjusts the main frequency of the CPU according to the main memory access rate by acquiring the main memory access rate of the CPU, and adjusts the main frequency of the CPU to a reasonable main frequency as much as possible under the premise of ensuring performance, thereby ensuring the CPU.
  • FIG. 1 is a schematic diagram of a power management framework in an existing Android system
  • FIG. 2 is a flow chart of a method for reducing power consumption of a central processing unit in an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of an apparatus for reducing power consumption of a central processing unit according to an embodiment of the present invention
  • FIG. 4 is a schematic diagram of a CPU frequency and power management framework based on a CPU freq system in an embodiment of the present invention
  • FIG. 6 is a schematic diagram of a frame for implementing voltage management of a CPU power supply box according to an embodiment of the present invention.
  • the invention proposes a method for achieving the optimal energy saving goal as much as possible while maintaining the performance of the terminal.
  • the method determines the CPU frequency and voltage settings by judging the type of task, that is, whether the task is a CPU-intensive task or a memory-intensive task.
  • the CPU's main frequency and voltage are dynamically set according to the frequency of the CPU accessing the main memory; that is, the higher the frequency of accessing the main memory, that is, the more the task is more memory-intensive, so the lower the CPU main can be set.
  • the method can determine the CPU frequency and voltage suitable for the task, thereby achieving the purpose of energy saving; in short, It is to select the CPU frequency and voltage of the most suitable task to achieve the best possible energy saving goal.
  • the CPU main frequency and voltage are related, that is, the fixed main frequency corresponds to a fixed voltage. When the main frequency is selected, the pressure is also selected.
  • an embodiment of the present invention relates to a method for reducing power consumption of a central processing unit, including:
  • Step S101 acquiring a main memory access rate of the CPU of the central processing unit
  • the frequency of the main memory is accessed by the task, and the CPU main frequency and voltage suitable for the task are determined according to the frequency of the main memory. Therefore, it is necessary to calculate the frequency at which the CPU accesses the main memory. This can be solved by the CPU's failure to access the cache.
  • the cache access failure rate that is, the number of cache failures divided by the number of instructions of the CPU, can be obtained by the CPU. Equation (1) is a formula for calculating memory failure rate.
  • M access_rate is the main memory access rate
  • N access_miss is the number of times the CPU access cache cache fails
  • N instruction is the number of instructions executed by the CPU.
  • Step S102 adjusting a frequency of the CPU according to the main memory access rate.
  • the main memory access rate the more the task is biased toward the memory-intensive task, so the lower CPU frequency should be set; otherwise, if the main memory access rate is lower, the relatively higher CPU should be set. frequency. Therefore, it can be seen that the CPU frequency and voltage of the minimum energy consumption are inversely proportional to the memory access rate.
  • the main frequency of the CPU is lowered; the currently obtained main memory access rate is lower than the last obtained main memory access rate. At the same time, the main frequency of the CPU is increased.
  • the optimal CPU target frequency can be calculated by formula (2).
  • f opt is the target frequency, that is, the adjusted CPU frequency
  • f min is the minimum frequency supported by the CPU
  • f max is the maximum frequency supported by the CPU
  • M max is the maximum memory access rate supported by the main memory.
  • the calculated CPU frequency is the minimum frequency supported by the CPU; when the memory access rate decreases, the obtained CPU target is obtained. The frequency increases accordingly. It should be noted that if there is no task execution, the CPU will enter sleep mode.
  • the present invention also relates to an apparatus for reducing power consumption of a central processing unit that implements the above method, including:
  • the main memory access rate obtaining unit 201 is configured to acquire a main memory access rate of the CPU of the central processing unit;
  • the CPU main frequency adjustment unit 202 is configured to adjust the main frequency of the CPU according to the main memory access rate.
  • the CPU frequency adjustment unit 202 is configured to:
  • the CPU frequency is lowered; when the currently obtained main memory access rate is lower than the last obtained main memory access rate, the CPU main is raised. frequency.
  • the main memory access rate obtaining unit 201 calculates the main memory access rate according to the formula (1):
  • M access_rate is the main memory access rate
  • N access_miss is the number of times the CPU access cache cache fails
  • N instruction is the number of instructions executed by the CPU
  • the CPU frequency adjustment unit 202 determines the adjusted CPU frequency according to formula (2):
  • f opt is the target frequency, that is, the adjusted CPU frequency
  • f min is the minimum frequency supported by the CPU
  • f max is the maximum frequency supported by the CPU
  • M max is the maximum memory access rate supported by the main memory.
  • the CPU frequency adjustment unit 202 is also configured to:
  • an embodiment of the present invention further relates to a terminal that uses the apparatus for reducing power consumption of a central processing unit of the above embodiment to adjust a primary frequency of a central processing unit.
  • the terminal can be a mobile terminal, such as a mobile phone, a tablet, or other terminal that involves processor and power consumption control.
  • the basic idea of the invention is to extend the original framework of the Android system Power Manager, and implement a new power management method using the power management interface provided by the Android system, that is, the Userspace governor. Since this method takes some underlying parameters, it will involve the Android JNI library and the Linux kernel. These parameters mainly include the number of cache failures, the number of machine instructions executed by the CPU, and the frequency supported by the CPU. These parameters are used to dynamically calculate and set the CPU frequency and voltage that are the most suitable for the task to reduce power consumption.
  • the basic principle is to dynamically set the CPU's main frequency and voltage according to the frequency of the CPU accessing the main memory: the higher the frequency of accessing the main memory, the more the task is more memory-intensive, so the lower the CPU main frequency and voltage can be set.
  • the voltage in order to achieve energy-saving purposes; in short, is to choose the CPU frequency and voltage of the most suitable task to achieve the best possible energy-saving goals.
  • the implementation of the present invention is divided into three parts, which respectively relate to the application layer of the Android system, the Android framework library layer, and the Linux kernel layer.
  • the memory access rate calculation is implemented in an Android Service, which relies on the power management Power Manager class and PMU (Performance Monitor Unit) provided by Android.
  • PMU Personal Monitor Unit
  • the invention provides a CPU-based energy saving method and system based on the Android system, and FIG. 4 shows an optimization scheme optimization framework based on the CPU freq system.
  • the application layer CPU frequency and voltage decision management module is a module added by the invention, which is essentially an application layer power management governor, named User PM governor for convenience of description.
  • User PM governor adopts the new method proposed by the present invention to dynamically set the CPU's main frequency and voltage according to the main memory access rate of the task to achieve the optimal energy saving goal.
  • the implementation of User PM governor depends on the Userspace governor provided by Android, the Java Native Interface provided by Java Native Library, and the Power Management Unit (PMU) provided by the Linux kernel through the sysfs interface.
  • the implementation of User PM governor is divided into three parts, as shown in Figure 6:
  • the module starts a Service running in the background at the Android application layer.
  • the Service controls the CPU frequency according to the available CPU frequency information provided by the Userspace governor (via sysfs). All user-level power management governors must pass their Userspace governor as their agent.
  • This module is mainly used to calculate the main memory access rate and the target CPU frequency, which involves some native functions.
  • the main reason for putting the parameters used by the application layer into this layer is to increase the calculation speed. Because Android's application layer is implemented in Java, and Java's operation depends on Java Virtual Machine's compilation, the calculation speed is slow. This is especially important for embedded systems that require minimal computing resources and minimal additional power consumption. In order to reduce the calculation time and reduce the additional energy consumption, the calculation of these parameters is put into the JNI Native Library layer, which is implemented in C language, which can improve the calculation speed and save extra battery energy consumption. For example, you need to call the PMU_Start() function and the PMU_Stop function provided in the JNI library to start and shut down the PMU; you need to call the SetFrequecy interface to set the CPU frequency.
  • the bottom layer is the Linux kernel module. This module mainly involves the need to write some functions to control the related hardware to achieve support for the JNI Native Library layer module.
  • step 301 the startService is invoked at the application layer to start the User PM governor service.
  • Step 302 calling onCreate in the application layer, creating a service thread, and starting the detection thread;
  • Step 303 calling onStart in the application layer, accessing the user PM governor service thread
  • Step 304 the PMU stop interface is called at the JNI library layer to stop the PMU;
  • Step 305 in the JNI library layer, call the PMU read interface to calculate the CPU target frequency
  • Step 306 in the Linux kernel layer calculate a memory access rate according to formula (1);
  • Step 307 calculating the CPU target frequency and voltage of the optimal energy consumption according to formula (2) in the JNI library layer;
  • Step 308 in the JNI library layer, according to the CPU supporting the main frequency in the current system, selecting the CPU frequency of the CPU target frequency which is closest to the optimal power consumption as the optimal energy consumption frequency and voltage;
  • Step 309 in the JNI library layer, call the PMU set interface to set the current CPU frequency to the optimal power consumption frequency and voltage;
  • step 310 the PMU set interface calls the sysfs interface of the linux kernel layer, selects a CPU-related driver, and sets a CPU frequency.
  • step 312 a timer is started at the JNI library layer, and the time interval for detecting the CPU usage is the same in a fixed time interval and Android OnDemand governor, that is, after 1 ms, and then proceeds to step 304.
  • the embodiment of the present invention achieves the goal of saving energy as much as possible by selecting the CPU frequency and voltage of the most suitable task, and the CPU has better energy saving and consumption reduction effect than the prior art.
  • the embodiment of the invention further describes a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are configured to perform the method for reducing power consumption of the central processor shown in FIG. 2 .
  • the disclosed apparatus and method may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner such as: multiple units or components may be combined, or Can be integrated into another system, or some features can be ignored or not executed.
  • the coupling, or direct coupling, or communication connection of the components shown or discussed may be indirect coupling or communication connection through some interfaces, devices or units, and may be electrical, mechanical or other forms. of.
  • the units described above as separate components may or may not be physically separated, and the components displayed as the unit may or may not be physical units, that is, may be located in one place or distributed to multiple network units; Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may be separately used as one unit, or two or more units may be integrated into one unit;
  • the unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
  • the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed.
  • the foregoing storage medium includes: a mobile storage device, a random access memory (RAM), a read-only memory (ROM), a magnetic disk, or an optical disk.
  • RAM random access memory
  • ROM read-only memory
  • magnetic disk or an optical disk.
  • optical disk A medium that can store program code.
  • the above-described integrated unit of the present invention may be stored in a computer readable storage medium if it is implemented in the form of a software function module and sold or used as a standalone product.
  • the technical solution of the embodiments of the present invention may be embodied in the form of a software product in essence or in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for making
  • a computer device which may be a personal computer, server, or network device, etc.
  • the foregoing storage medium includes various media that can store program codes, such as a mobile storage device, a RAM, a ROM, a magnetic disk, or an optical disk.
  • a method, apparatus, terminal, and computer storage medium for reducing power consumption of a central processing unit provided by an embodiment of the present invention have the following beneficial effects: the CPU frequency and voltage of the most suitable task can be selected as much as possible. Compared with the prior art, the energy consumption of the CPU is better.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Power Sources (AREA)

Abstract

一种降低中央处理器能耗的方法、装置、终端及计算机存储介质,方法,包括:获取中央处理器CPU的主存访问率(S101);根据所述主存访问率,调整所述CPU的主频(S102)。通过获取CPU的主存访问率,根据主存访问率动态调整CPU的主频,在保证性能的前提下,尽可能的将CPU的主频调整为一个合理的主频,进而保证CPU的能耗最低,尽可能的降低CPU的能耗。

Description

降低中央处理器能耗的方法、装置、终端及计算机存储介质 技术领域
本发明涉及计算机领域,特别是涉及一种降低中央处理器能耗的方法、装置、终端及计算机存储介质。
背景技术
自从第三代移动通信(3G)以来,移动互联网得到了迅猛的发展。基于对未来的展望,人们提出了普适计算,即无处不在的计算。目前,第四代移动通信技术(4G)已经开始多个国家建设并使用。所以,可以预见随着时间的推移,移动互联网将持续高速发展。移动互联网的终端设备繁多,但是使用的操作系统还是以谷歌(Google)公司的安卓(Android)系统,苹果公司的IOS系统以及微软的Windows Phone系统为主。其中,Android系统占据了绝大部分市场份额。
由于移动设备的电源(即电池)能量非常有限,且耗能越大发热越严重,所以电源管理对移动设备就显得十分关键,也成为当前工作努力的方向之一。Google的Android系统基于Linux内核2.6.33,并对其电源管理和内存管理以及运行时管理进行了修改以适应移动设备。对Linux内核电源管理进行改进的原因是:运行Android系统的移动设备电池容量有限,且节能特征与个人电脑不同。谷歌公司专门开发了针对外围设备电源管理的电源驱动,这个驱动可以控制屏幕显示和背光,键盘背光以及按钮背光。基本的原理是:通过锁和定时器来切换系统的状态,使系统的功耗降至最低。外围设备的电源控制主要是通过“唤醒锁”(WakeLocks)来实现的。应用程序通过应用框架中的一个电源管理(Power Management)API(Application Programming Interface,应用程序编程接口)来申请“唤醒锁”,并通过“唤醒锁”使屏幕正常显示,并使CPU(Central Processing Unit,中央处理器,以下简称处理器)处于AWAKE状态以快速的处理中断事件。具体过程如图1所示。
在移动设备中,CPU是主要的耗能设备之一。Android的电源管理中对CPU的能耗管理通过Governor来实现。目前,Android支持的Governor主要有Performance Governor、Powersave Governor和OnDemand Governor。其中,Performance Governor始终将CPU保持在最高频率;Powersave Governor一直将CPU保持在最低频率;OnDemand Governor根据CPU的使用率来设置CPU频率,具体来说就是设定两个的阀值up_ultilization和down_ultilization,当CPU使用率大于up_ultilization时,直接将 CPU频率设置为最大值,当CPU使用率小于down_ultilization时,则将CPU频率减少20%。用户可以根据需要选择合适的Governor。另外,Android提供了一个Userspace governor,它可以向用户提供可用的频率信息,允许用户根据这些信息通过Linux sysfs接口实现用户级的governor来控制CPU频率。
Android提供了一个比较简单的电源管理框架,该框架通过PowerManager类向应用程序开发者提供了一组电源管理接口。Android的电源管理主要用来解决当系统中的某些组件空闲或者没有被使用时来减少能耗。另外,对于CPU,Google的Android系统是通过动态调整电压和CPU主频(Dynamic Voltage and Frequency Scaling,动态电压频率调整,简写DVFS)来节省电能,以延长电池的寿命,该方法继承自Linux电源管理中对CPU的节能管理方法。例如,当CPU和外围设备(比如显示屏)处于空闲状态时,则将CPU或者外围设备切换到空闲模式或者省电模式。另外,如果一个应用不需要一直运行在最高性能时,可以通过降低主频和电压以减少能耗。通常,DVFS一边试着保持系统性能,一边试图去降低能耗。这种电源管理方法的初衷是针对台式电脑或者笔记本电脑,它以性能为导向即在保证不影响系统性能的情况下节省电能。
然而,对于移动终端用户,在某些情况下,用户可能更注重最大限度地节省电能。例如当用户使用智能手机以进行视频格式转换并上传到网上与朋友分享时,由于这通常需要较长的时间而不会立即完成,所以用户可能需要以最低的能耗来完成该任务。为了达到这个目的通常会选择PowerSave governor将CPU主频和电压设置到最低。但是,最低CPU主频和电压并不一定是最优的降低能耗方法。因为在真实的程序执行过程中,CPU可能需要停下来等待外围进行I/O处理。
另外,对于一个偏计算密集型的任务,由于Android系统选择了最低的CPU主频和电压,所以计算时间就加长,能耗反而可能相对于选择适中的CPU主频和电压有所增加,采用最低主频和电压也可能造成终端反应比较慢。Android在对于CPU频率和电压的管理实际上是依赖于Linux内核,然而其默认的Ondemand governor的实现不适合这种情况,即用户想要在任务正在运行时最大限度的节省能耗。因为在这种情况下OnDemand这种以性能为导向的节能方法可能会不适合。若选择OnDemand governor,由于OnDemand governor采用两个阀值来调节CPU频率,该方法的优点是简单,容易实现,但是设置不够精确,该任务很可能达到设定阀值而直接把CPU频率设置成最大,而该任务可能并不需要把CPU频率设置成最大,从而没有达到用户设想的以最低能耗完成该任务。现有技术不能针对不同的情况对CPU频率进行优化调整,以尽可能的节省能耗。
发明内容
本发明实施例提供了一种降低中央处理器能耗的方法、装置、终端及计算机存储介质,以至少解决相关技术中CPU需要尽可能降低能耗的问题。
为解决上述技术问题,一方面,本发明实施例提供一种降低中央处理器能耗的方法,包括:
获取中央处理器CPU的主存访问率;
根据所述主存访问率,调整所述CPU的主频。
进一步,根据所述主存访问率,调整所述CPU的主频,具体包括:
在当前获得的主存访问率高于上次获得的主存访问率时,降低所述CPU的主频;
在当前获得的主存访问率低于上次获得的主存访问率时,提高所述CPU的主频。
进一步,根据公式(1)计算所述主存访问率:
Figure PCTCN2015070936-appb-000001
其中,Maccess_rate是主存访问率,Naccess_miss是CPU访问缓存cache失效的次数,Ninstruction是CPU执行的指令条数。
进一步,根据公式(2)确定调整后的CPU主频:
Figure PCTCN2015070936-appb-000002
其中,fopt是目标主频,即调整后的CPU主频;fmin是CPU支持的最小主频;fmax是CPU支持的最大主频,Mmax是主存支持的最大主存访问率。
进一步包括,当CPU没有任务执行时,则调整CPU的主频为最低主频。
另一方面,本发明实施例还提供一种降低中央处理器能耗的装置,包括:
主存访问率获取单元,设置为获取中央处理器CPU的主存访问率;
CPU主频调整单元,设置为根据所述主存访问率,调整所述CPU的主频。
进一步,所述CPU主频调整单元设置为:
在当前获得的主存访问率高于上次获得的主存访问率时,降低所述CPU的主频;在当前获得的主存访问率低于上次获得的主存访问率时,提高所述CPU的主频。
进一步,主存访问率获取单元根据公式(1)计算得到主存访问率:
Figure PCTCN2015070936-appb-000003
其中,Maccess_rate是主存访问率,Naccess_miss是CPU访问缓存cache失效的次数,Ninstruction是CPU执行的指令条数;
CPU主频调整单元根据公式(2)确定调整后的CPU主频:
Figure PCTCN2015070936-appb-000004
其中,fopt是目标主频,即调整后的CPU主频;fmin是CPU支持的最小主频;fmax是CPU支持的最大主频,Mmax是主存支持的最大主存访问率。
进一步,所述CPU主频调整单元还设置为:
当所述CPU没有任务执行时,则调整所述CPU的主频为最低主频。
再一方面,本发明还提供一种终端,该终端采用上述的降低中央处理器能耗的装置来调整中央处理器的主频。
再一方面,本发明实施例还提供一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于上述的降低中央处理器能耗的方法。
本发明有益效果如下:
本发明通过获取CPU的主存访问率,根据主存访问率动态调整CPU的主频,在保证性能的前提下,尽可能的将CPU的主频调整为一个合理的主频,进而保证CPU的能耗最低,尽可能的降低CPU的能耗。
附图说明
图1是现有Android系统中电源管理框架示意图;
图2是本发明实施例中一种降低中央处理器能耗的方法的流程图;
图3是本发明实施例中一种降低中央处理器能耗的装置的结构示意图;
图4是本发明实施例中基于CPU freq系统的CPU频率和电源管理框架示意图;
图5是本发明实施例中CPU电源和电压管理流程图;
图6是本发明实施例中CPU电源盒电压管理实现框架示意图。
具体实施方式
以下结合附图以及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不限定本发明。
本发明提出一种可以在保持终端性能的同时,尽可能的达到最优节能目标的方法。该方法通过判断任务的类型,即根据任务是偏CPU密集型任务还是偏内存密集型任务来决定CPU主频和电压的设置。具体来说就是,根据CPU访问主存的频率来动态设置CPU的主频和电压;即:访问主存的频率越高,即该任务越偏内存密集型任务,所以可以设置越低的CPU主频和电压,以减少能耗;访问主存的频率越低,则该任务越偏CPU密集型,所以应该设置较高的CPU主频和电压(相对于最低的CPU主频),即通过本方法可以确定适合该任务的CPU主频和电压,从而达到节能的目的;总之, 就是选择最合适任务的CPU主频和电压以达到尽可能最优的节能目标。需要注意的是,CPU主频和电压是相关的,即固定的主频对应固定的电压。当主频选定时,也压也随之选定。
如图2所示,本发明实施例涉及一种降低中央处理器能耗的方法,包括:
步骤S101,获取中央处理器CPU的主存访问率;
本步骤中,通过任务访问主存的频率,从而根据主存的频率判断适合该任务的CPU主频和电压,所以需要计算CPU访问主存的频率。这可以通过CPU访问cache(缓存)的失效率来解决。当CPU访问cache失效时,就会访问主存;所以可以通过CPU访问cache失效次数,即cache失效的次数除以CPU的指令条数,来得到主存访问率。公式(1)是内存失效率的计算公式。
Figure PCTCN2015070936-appb-000005
其中,Maccess_rate是主存访问率,Naccess_miss是CPU访问缓存cache失效的次数,Ninstruction是CPU执行的指令条数。
步骤S102,根据所述主存访问率,调整所述CPU的主频。
本步骤中,主存访问率越高,则该任务就越偏向内存密集型任务,所以应该设置较低的CPU主频;反之,若主存访问率比较低,则应该设置相对较高的CPU频率。所以可以看出,最小能耗的CPU主频和电压是和内存访问率成反比的。具体调整时,在当前获得的主存访问率高于上次获得的主存访问率时,降低所述CPU的主频;在当前获得的主存访问率低于上次获得的主存访问率时,提高所述CPU的主频。为了获取与任务对应的最佳主频,可以通过公式(2)计算最优CPU目标主频。
Figure PCTCN2015070936-appb-000006
其中,fopt是目标主频,即调整后的CPU主频;fmin是CPU支持的最小主频;fmax是CPU支持的最大主频,Mmax是主存支持的最大主存访问率。
从公式(2)可以看出,当内存访问率达到内存支持的最大访问率时,计算出的CPU主频为其支持的最小主频;当内存访问率下降时,所得到的的CPU目标主频则相应的增大。需要注意的是,若没有任务执行,则CPU会进入睡眠模式(sleep mode)。
另外,如图3所示,本发明还涉及一种实现上述方法的降低中央处理器能耗的装置,包括:
主存访问率获取单元201,设置为获取中央处理器CPU的主存访问率;
CPU主频调整单元202,设置为根据主存访问率,调整CPU的主频。
其中,CPU主频调整单元202设置为:
在当前获得的主存访问率高于上次获得的主存访问率时,降低CPU的主频;在当前获得的主存访问率低于上次获得的主存访问率时,提高CPU的主频。
主存访问率获取单元201根据公式(1)计算得到主存访问率:
Figure PCTCN2015070936-appb-000007
其中,Maccess_rate是主存访问率,Naccess_miss是CPU访问缓存cache失效的次数,Ninstruction是CPU执行的指令条数;
CPU主频调整单元202根据公式(2)确定调整后的CPU主频:
Figure PCTCN2015070936-appb-000008
其中,fopt是目标主频,即调整后的CPU主频;fmin是CPU支持的最小主频;fmax是CPU支持的最大主频,Mmax是主存支持的最大主存访问率。
CPU主频调整单元202还设置为:
当CPU没有任务执行时,则调整CPU的主频为最低主频。
另外,本发明实施例还涉及一种终端,该终端采用上述实施例的降低中央处理器能耗的装置来调整中央处理器的主频。该终端可以为移动终端,例如手机、平板电脑,或者其它涉及处理器及电源能耗控制的终端。
下面,以Android系统为例,详细说明本发明实施例。
本发明的基本思想是:扩展Android系统Power Manager的原有框架,使用Android系统提供的电源管理接口,即Userspace governor实现一个新的电源管理方法。由于该方法要获得一些底层的参数,所以会涉及到Android JNI库和Linux内核。这些参数主要包括cache失效次数,CPU执行的机器指令条数,CPU支持的频率等。通过这些参数动态的计算并设置减小功耗最适合任务的CPU频率和电压。基本原理是根据CPU访问主存的频率来动态设置CPU的主频和电压:访问主存的频率越高,即该任务越偏内存密集型任务,所以可以设置越低的CPU主频和电压,以减少能耗;访问主存的频率越低,则该任务越偏CPU密集型,所以应该设置较高的CPU主频(相对于最低的CPU主频),即适合该任务的CPU主频和电压,从而达到节能的目的;总之,就是选择最合适任务的CPU主频和电压以达到尽可能最优的节能目标。
在Android的Linux内核中,有一个CPUfreq子系统,通过该系统提供的接口可以管理CPU的主频;本发明的实现正式基于该系统。
本发明的实现分为三个部分,分别涉及到了Android系统的应用层,Android框架库层,以及Linux内核层。内存访问率计算在一个Android Service内实现,它依赖于Android提供的电源管理Power Manager类和PMU(Performance Monitor Unit)。然后在Power Manager中计算出相应的可以达到最小功耗的CPU频率和电压。一旦计算出最小功耗的频率和电压就应该应用到处理器作为目标主频。由于CPU支持的主频不是连续的,所以需要进一步选取离目标主频最近的频率作为当前最优CPU主频。最后,将获得的最优CPU主频设置为CPU频率。
下面通过一个优选实施例来对本发明进一步详细说明,如图4所示:
本发明提供了一种基于Android系统上通用的CPU节能方法及系统,图4示出了基于CPU freq系统的优化方案优化框架。其中应用层CPU主频和电压决策管理模块是本发明加入的一个模块,其在本质上是一个应用层的电源管理governor,为方便描述,命名为User PM governor。User PM governor采用了本发明提出的新方法来根据任务的主存访问率动态设置CPU的主频和电压,以达到最优的节能目标。User PM governor的实现依赖于Android提供的Userspace governor、Java Native Library提供的Java Native Interface,以及Linux内核通过sysfs接口提供的电源管理单元PMU(Power Management Unit)。User PM governor的实现分为三个部分,具体如图6所示:
(1)、首先是应用层模块。该模块在Android应用层启动一个运行在后台的Service,该Service根据Userspace governor(通过sysfs)提供的可用CPU频率信息来控制CPU主频。所有用户级的电源管理governor都必须通过Userspace governor作为他们的代理。
(2)、其次是JNI Native Library层模块。该模块主要是用来计算主存访问率和目标CPU主频,这涉及到一些native函数。将应用层用到的参数放到该层来计算的主要原因是为了提高计算速度。因为Android的应用层是用Java实现的,而Java的运行依赖于Java Virtual Machine的编译,所以计算速度比较慢。这对于要求使用尽量少的计算资源和最小的额外能耗的嵌入式系统来说是特别重要的。为了缩短计算时间以及减少额外能耗,将这些参数的计算放到JNI Native Library层,使用C语言实现,可以提高计算速度、节省额外的电池能量消耗。比如,需要调用JNI库中提供的PMU_Start()函数和PMU_Stop函数启动和关闭PMU;需要调用SetFrequecy接口去设置CPU主频。
(3)最底层的是Linux内核模块。该模块主要涉及到需要编写一些函数对相关硬件进行控制,从而实现对JNI Native Library层模块的支持。
本发明的电源管理User PM governor的工作流程如图5所示,下面结合该图对User PM governor的具体流程进行分析:
步骤301,在应用层调用startService,启动User PM governor服务。
步骤302,在应用层调用onCreate,创建服务线程,同时启动检测线程;
步骤303,在应用层调用onStart,访问启动User PM governor服务线程;
步骤304,在JNI库层调用PMU stop接口停止PMU;
步骤305,在JNI库层调用PMU read接口计算CPU目标主频电压;
步骤306,在Linux内核层,根据公式(1)计算内存访问率;
步骤307,在JNI库层根据公式(2)计算出最优能耗的CPU目标主频和电压;
步骤308,在JNI库层,根据当前系统中CPU支持主频,选择最接近最优能耗的CPU目标主频的CPU频率作为最优能耗主频和电压;
步骤309,在JNI库层,调用PMU set接口设置当前的CPU主频为最优能耗主频和电压;
步骤310,PMU set接口调用linux内核层的sysfs接口,选择CPU相关驱动,设置CPU频率。
步骤311,在JNI库层,调用PMU start接口重新启动PMU;
步骤312,在JNI库层启动计时器,在固定的时间间隔和Android的OnDemand governor中检测CPU使用率的时间间隔相同,即1ms后,然后转入步骤304。
由上述实施例可以看出,本发明实施例通过选择最合适任务的CPU主频和电压,实现尽可能节能的目的,相比现有技术,CPU的节能降耗效果更好。
本发明实施例还记载一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令配置为执行图2所示的降低中央处理器能耗方法。
在本发明所提供的几个实施例中,应该理解到,所揭露的设备和方法,可以通过其它的方式实现。以上所描述的设备实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,如:多个单元或组件可以结合,或可以集成到另一个系统,或一些特征可以忽略,或不执行。另外,所显示或讨论的各组成部分相互之间的耦合、或直接耦合、或通信连接可以是通过一些接口,设备或单元的间接耦合或通信连接,可以是电性的、机械的或其它形式的。
上述作为分离部件说明的单元可以是、或也可以不是物理上分开的,作为单元显示的部件可以是、或也可以不是物理单元,即可以位于一个地方,也可以分布到多个网络单元上;可以根据实际的需要选择其中的部分或全部单元来实现本实施例方案的目的。
另外,在本发明各实施例中的各功能单元可以全部集成在一个处理单元中,也可以是各单元分别单独作为一个单元,也可以两个或两个以上单元集成在一个单元中;上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:移动存储设备、随机存取存储器(RAM,Random Access Memory)、只读存储器(ROM,Read-Only Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
或者,本发明上述集成的单元如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明实施例的技术方案本质上或者说对相关技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机、服务器、或者网络设备等)执行本发明各个实施例所述方法的全部或部分。而前述的存储介质包括:移动存储设备、RAM、ROM、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。
尽管为示例目的,已经公开了本发明的优选实施例,本领域的技术人员将意识到各种改进、增加和取代也是可能的,因此,本发明的范围应当不限于上述实施例。
工业实用性
如上所述,本发明实施例提供的一种降低中央处理器能耗的方法、装置、终端及计算机存储介质具有以下有益效果:可以通过选择最合适任务的CPU主频和电压,尽可能地降低能源消耗,相比现有技术,CPU的节能降耗效果更佳。

Claims (11)

  1. 一种降低中央处理器能耗的方法,包括:
    获取中央处理器CPU的主存访问率;
    根据所述主存访问率,调整所述CPU的主频。
  2. 如权利要求1所述的降低中央处理器能耗的方法,其中,根据所述主存访问率,调整所述CPU的主频,具体包括:
    在当前获得的主存访问率高于上次获得的主存访问率时,降低所述CPU的主频;
    在当前获得的主存访问率低于上次获得的主存访问率时,提高所述CPU的主频。
  3. 如权利要求1或2所述的降低中央处理器能耗的方法,其中,根据公式(1)计算所述主存访问率:
    Figure PCTCN2015070936-appb-100001
    其中,Maccess_rats是主存访问率,Naccess_miss是CPU访问缓存cache失效的次数,Ninstruction是CPU执行的指令条数。
  4. 如权利要求3所述的降低中央处理器能耗的方法,其中,根据公式(2)确定调整后的CPU主频:
    Figure PCTCN2015070936-appb-100002
    其中,fopt是目标主频,即调整后的CPU主频;fmin是CPU支持的最小主频;fmax是CPU支持的最大主频,Mmax是主存支持的最大主存访问率。
  5. 如权利要求1所述的降低中央处理器能耗的方法,其中,还包括:
    当所述CPU没有任务执行时,则调整所述CPU的主频为最低主频。
  6. 一种降低中央处理器能耗的装置,包括:
    主存访问率获取单元,设置为获取中央处理器CPU的主存访问率;
    CPU主频调整单元,设置为根据所述主存访问率,调整所述CPU的主频。
  7. 如权利要求6所述的降低中央处理器能耗的装置,其中,所述CPU主频调整单元设置为:
    在当前获得的主存访问率高于上次获得的主存访问率时,降低所述CPU的主频;在当前获得的主存访问率低于上次获得的主存访问率时,提高所述CPU的主频。
  8. 如权利要求7或6所述的降低中央处理器能耗的装置,其中,主存访问率获取单元根据公式(1)计算得到主存访问率:
    Figure PCTCN2015070936-appb-100003
    其中,Maccess_rate是主存访问率,Naccess_miss是CPU访问缓存cache失效的次数,Ninstruction是CPU执行的指令条数;
    CPU主频调整单元根据公式(2)确定调整后的CPU主频:
    Figure PCTCN2015070936-appb-100004
    其中,fopt是目标主频,即调整后的CPU主频;fmin是CPU支持的最小主频;fmax是CPU支持的最大主频,Mmax是主存支持的最大主存访问率。
  9. 如权利要求6所述的降低中央处理器能耗的装置,其中,所述CPU主频调整单元还设置为:
    当所述CPU没有任务执行时,则调整所述CPU的主频为最低主频。
  10. 一种终端,所述终端采用权利要求6至9中任一项所述的降低中央处理器能耗的装置来调整中央处理器的主频。
  11. 一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于权利要求1至5任一项所述的降低中央处理器能耗的方法。
PCT/CN2015/070936 2014-10-20 2015-01-16 降低中央处理器能耗的方法、装置、终端及计算机存储介质 WO2015154562A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410559805.X 2014-10-20
CN201410559805.XA CN105589544A (zh) 2014-10-20 2014-10-20 降低中央处理器能耗的方法、装置及终端

Publications (1)

Publication Number Publication Date
WO2015154562A1 true WO2015154562A1 (zh) 2015-10-15

Family

ID=54287276

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/070936 WO2015154562A1 (zh) 2014-10-20 2015-01-16 降低中央处理器能耗的方法、装置、终端及计算机存储介质

Country Status (2)

Country Link
CN (1) CN105589544A (zh)
WO (1) WO2015154562A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108345513A (zh) * 2018-03-20 2018-07-31 北京小米移动软件有限公司 终端运行方法及装置

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106527666A (zh) * 2016-11-18 2017-03-22 宇龙计算机通信科技(深圳)有限公司 一种中央处理器的控制方法、及终端设备
CN110427085B (zh) * 2019-07-29 2021-01-12 Oppo(重庆)智能科技有限公司 电子设备供电的方法和装置、电子设备

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101067758A (zh) * 2007-06-14 2007-11-07 华南理工大学 一种嵌入式系统的能耗管理方法
CN101266576A (zh) * 2008-05-15 2008-09-17 中国人民解放军国防科学技术大学 一种面向数据流的Cache管理方法
CN103037109A (zh) * 2012-12-12 2013-04-10 中国联合网络通信集团有限公司 多核设备能耗管理方法及装置
US20140089695A1 (en) * 2012-09-25 2014-03-27 Msi Computer(Shenzhen)Co., Ltd. Energy-saving device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4837456B2 (ja) * 2006-06-28 2011-12-14 パナソニック株式会社 情報処理装置
CN103246340A (zh) * 2012-02-06 2013-08-14 索尼公司 动态调整中央处理单元的频率的装置和方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101067758A (zh) * 2007-06-14 2007-11-07 华南理工大学 一种嵌入式系统的能耗管理方法
CN101266576A (zh) * 2008-05-15 2008-09-17 中国人民解放军国防科学技术大学 一种面向数据流的Cache管理方法
US20140089695A1 (en) * 2012-09-25 2014-03-27 Msi Computer(Shenzhen)Co., Ltd. Energy-saving device
CN103037109A (zh) * 2012-12-12 2013-04-10 中国联合网络通信集团有限公司 多核设备能耗管理方法及装置

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108345513A (zh) * 2018-03-20 2018-07-31 北京小米移动软件有限公司 终端运行方法及装置

Also Published As

Publication number Publication date
CN105589544A (zh) 2016-05-18

Similar Documents

Publication Publication Date Title
US11768533B2 (en) Platform power consumption reduction via power state switching
EP4280061A1 (en) Resource scheduling method and electronic device
JP6509895B2 (ja) デバイス固有又はユーザー固有のリソース使用プロファイルに基づくリソース管理
US8112647B2 (en) Protocol for power state determination and demotion
US9361150B2 (en) Resuming applications and/or exempting applications from suspension
KR101943134B1 (ko) 중단 상태 및 실행 상태에 있는 프로세스의 관리 기법
US8286169B2 (en) Dynamic scheduling an interval for polling devices based on a current operational power mode in an extensible firmware interface architecture
US20140208145A1 (en) Methods and apparatus for saving power
WO2012031540A1 (zh) 一种调节内存运行频率的方法及电子设备
JP2012123824A (ja) コンテキストベース電力管理
US9448840B2 (en) Controlling runtime execution from a host to conserve resources
US20060242651A1 (en) Activity-based PC adaptability
WO2014012517A1 (en) Method and device for controlling terminal and terminal thereof
WO2017101362A1 (zh) 一种智能终端的功耗管控方法及系统
US9395785B2 (en) Method and device for controlling terminal and terminal thereof
US20180167878A1 (en) Core frequency/count decision-based thermal mitigation optimization for a multi-core integrated circuit
US9110723B2 (en) Multi-core binary translation task processing
WO2015154562A1 (zh) 降低中央处理器能耗的方法、装置、终端及计算机存储介质
Sahin et al. MAESTRO: Autonomous QoS management for mobile applications under thermal constraints
JP2000039937A (ja) コンピュータシステムおよびそのパワーセーブ制御方法
CN106603526B (zh) WiFi/热点的开启方法及装置
US8243079B2 (en) Aligning animation state update and frame composition
EP3586225B1 (en) Apparatus and method for reducing energy consumption of hardware based on application state
US11592890B2 (en) System and method for Information Handling System (IHS) optimization using core stall management technology
CN111897581B (zh) 息屏唤醒方法、装置、存储介质及一体机设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15776125

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15776125

Country of ref document: EP

Kind code of ref document: A1