Home

Awesome

DISCONTINUATION OF PROJECT

This project will no longer be maintained by Intel.

Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.

Intel no longer accepts patches to this project.

If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project.

Contact: webadmin@linux.intel.com Power Governor {#mainpage}

Power Governor is a software utility and library, which allows developers to (a) monitor power and (b) regulate power, at very fine time granularities (few tens of milliseconds). Power monitoring/control is available for the following power domains:

How to use it

Prerequisites: This tool uses the msr and cpuid kernel modules. You may have to do:

modprobe msr

modprobe cpuid

On RedHat, you may have to run:

mk_msr_dev_redhat.sh

To build:

make

To run:

./power_gov

To generate the doxygen documentation:

doxygen doxygen/config/doxy_config

Using the library

Power Governor library allows developers to design dynamic power management solutions, which optimize the power consumption of their machines in accordance with their performance or quality of service needs. To get started using the library, see the short example below.

Below is a simple example, of using the library in order to create a tool 'set_limit', which limits the CPU package (for all packages) power consumption to 70 Watts. To compile, link against the stardard math library and librapl:
gcc set_limit.c -I. -L. -lm -o set_limit ./librapl.a

#include "rapl.h"
#define MY_POWER_LIMIT 70
 
int
main(int argc, char **argv)
{
    int i, num_node;
    pkg_rapl_power_limit_control_t  pkg_plc;
     
    // Always intialize the power_gov library first
    init_rapl();

    num_node = get_num_rapl_nodes_pkg();

    for (i = 0; i < num_node; i++) {

        // Read, modify and write the power limit control structure
        get_pkg_rapl_power_limit_control(i, &pkg_plc);
        pkg_plc.power_limit_watts_1 = MY_POWER_LIMIT;
        set_pkg_rapl_power_limit_control(i, &pkg_plc);
   }

    // Terminate the power_gov library
   return terminate_rapl();
}

Below is another example, of using the library in order to create power meter, which reports the CPU package (for all packages) power consumption every 100ms. To compile, link against the stardard math library and librapl:
gcc power_limit.c -I. -L. -lm -o power_limit ./librapl.a


#include "rapl.h"
#include <stdio.h>
#include <stdlib.h>


unsigned int  delay_us   = 100000.0;
double        delay_unit = 1000000.0;

int
main(int argc, char **argv)
{

    int i, num_node;
    double energy_consumed, delta;
    double *samples;

    // Always intialize the power_gov library first
    init_rapl();

    num_node = get_num_nodes();
    samples = (double*) malloc(num_node * sizeof(double));

    while(1){

        usleep(delay_us);

        for (i = 0; i < num_node; i++) {

            // Sample the total energy consumed, and convert to Watts.  
            get_pkg_total_energy_consumed(i, &energy_consumed);
            delta = energy_consumed - samples[i];
            samples[i] = energy_consumed;
            printf("%.0lf,", delta / ((double) delay_us / delay_unit));
        }
        printf("\n");
    }

    // Terminate the power_gov library
    return terminate_rapl();
}

Known Limitations / Issues / BKMs

Revision History