Using the Intel® Power Gadget 2.7 API on Windows*

Contributors: Seung-Woo Kim, Vardhan Dugar, Jun De Vega

1. Introduction

1.1 About Intel® Power Gadget for Windows

Intel® Power Gadgetfor Windows is an application which presents real-time data about a 2nd generation or later Intel® Core processor regarding current estimated processor power, thermal design power (TDP), current processor frequency, base frequency, current temperature, maximum temperature, timestamps and elapsed time. The data is obtained from the Model Specific Registers (MSRs) that are available only in 2nd Generation Intel® Core™ or later processors.  The supported MSRs are correlated with three MSR functions as described in Table 1. This data can be viewed on a Graphical User Interface (GUI) and/or logged for a required duration of time.

Table 1: MSR functions

MSR Function





Frequency of sample (in MHz)



Average Power (in Watts),
Cumulative Energy (in Joules),
Cumulative Energy (in milliWatt-Hours)



Temperature (in Deg. Celsius)

 Developers may use this data to create their own application by exploiting the Dynamic-Link Library (DLL) used by the Intel® Power Gadget. The DLL serves as a C++ Application Programming Interface (API). For more details on the API, please refer to subsequent sections.

1.2 Setup

1.     Download the appropriate Intel® Power Gadget installation package on your system.

2.     Run setup.exe as an administrator. Accept the UAC, if one appears.

3.     Follow the installer prompt instructions to complete installation. Microsoft* .Net Framework 4 will automatically be downloaded from the Microsoft website if not yet installed in your system. Microsoft Visual C++ 2010 SP1 Redistributable Package will also automatically get installed if not yet installed.

 For more information on system requirements and installation, please visit Intel® Power Gadget page


2. Developers’ Tools

The installer sets two environment variables on installation:


a.     IPG_Ver: Contains version of Intel® Power Gadget being installed.


b.    IPG_Dir: Contains directory in whichthe DLLs (EnergyLib64.dll used for 64-bit applications and EnergyLib32.dll used for 32-bit applications) were installed. 

           Developers may utilize the DLL for their 32-bit or 64-bit applications. Sample code called “” to use Intel®     Power Gadget’s DLL is available for download at the bottom of this page 

3. API of Intel® Power Gadget

3.1 Concept of Sampling

For a good understanding of the API, it is essential to be familiar with the concept of sampling. Data is acquired from specific MSRs at a fixed sampling frequency. Higher the frequency, greater will be the accuracy of the data but poorer will be the performance of the system. Although the Intel® Power Gadget API can be used with a sampling frequency ranging from 20 to 1000 milliseconds, the optimal sampling frequency of 50 milliseconds is the default selection on the GUI and is recommended for application developers.

3.2 Overview

As the primary API, developers may use Intel® Power Gadget’s EnergyLib32.dll for 32-bit applications or EnergyLib64.dll for 64-bit applications. This library must be initialized at the start of the program by calling IntelEnergyLibInitialize(). Here, the loading of the driver takes place.

The ReadSample()function is used to read samples. ReadSample() obtains the number of sampled MSRs from GetNumMsrs(). MSRs are given an ID from 0 to n-1, where n is the number returned by GetNumMsrs(). The MSR ID is used to acquire data for a specific MSR using GetMsrName(),GetMsrFunc() and GetPowerData() functions. GetPowerData() is called for each sampled MSR and provides the relevant data from that MSR. An MSR’s function, which the API obtains from GetMsrFunc(), determines the amount and meaning of data returned from GetPowerData() as described in Table 1.  

ReadSample() also reads the system time via GetSysTime() and Time Stamp Counter (TSC) via GetRDTSC()at the time the sample is read. The time interval (in seconds) between samples is available via GetTimeInterval().

Further, the API supports reading from common individual MSRs without having to specify the MSR address or read an entire sample via GetIAFrequency(), GetMaxTemperature(), GetTemperature() and GetTDP().

The sample data from ReadSample() can be logged to a file. Logging can be started at any time by calling StartLog(), and subsequently ended by calling StopLog().

For more information on the API, refer to the Function Reference and Notes of Caution in Section 4 and 4.1 respectively

4. Function Reference

Table 2: Function Lookup






Initializes the library and connects to the driver.



Reads sample data from the driver for all the supported MSRs.



Returns the number of CPU packages on the system.



Returns the number of supported MSRs for bulk reading and logging.


boolGetMsrName(intiMsr, wchar_t *szName);

Returns in szName the name of the MSR specified by iMsr.


boolGetMsrFunc(intiMsr, int*pFuncID);

Returns in pFuncID the function of the MSR specified by MSR ID in iMsr. Refer Table 1: MSR Functions.


boolGetPowerData(intiNode, intiMSR, double*pResult, int*nResult);

Returns the data collected by the most recent call to ReadSample(). The returned data is for the data on the package specified by iNode, from the MSR specified by iMSR. The data is returned in pResult, and the number of double results returned in pResult is returned in nResult. Refer Table 1: MSR Functions.



Returns the system time as of the last call to ReadSample(). The data returned in pSysTime is structured as follows: pSysTime[63:32] = time in seconds ; pSysTime[31:0] = time in nanoseconds


boolGetRDTSC(unsigned __int64 *pTSC);

Returns in pTSC the processors time stamp counter as of the last call to ReadSample().



Returns in pOffset the time (in seconds) that has elapsed between the two most recent calls to ReadSample().


boolGetIAFrequency(intiNode, int*freqInMHz);

Reads the processor frequency MSR on the package specified by iNode, and returns the frequency (in MHz) in freqInMHz.


boolGetTDP(intiNode, double*TDP);

Reads the package power info MSR on the package specified by iNode, and returns the TDP (in Watts) in TDP.


boolGetMaxTemperature(intiNode, int*degreeC);

Reads the temperature target MSR on the package specified by iNode, and returns the maximum temperature (in degrees Celsius) in degreeC.


boolGetTemperature(intiNode, int*degreeC);

Reads the temperature MSR on the package specified by iNode, and returns the current temperature (in degrees) Celsius in degreeC.


boolGetBaseFrequency(intiNode, double*pBaseFrequency);

Returns in pBaseFrequency the advertised processor frequency for the package specified by iNode.



Starts saving the data collected by ReadSample() until StopLog() is called. Data will be written to the file specified by szFileName.



Stops saving data and writes all saved data to the file specified by the call to StartLog().


4. 1 Notes of Caution

1.     The functions described in Table 2 return either true on success or false on failure.

2.     Prior to calling GetPowerData(), GetRDTSC(), and GetTimeInterval(), ReadSample() must be called twice as the functions perform computations using the difference between the last two samples.   

3.     When logging data, the data isn’t written into the log until StopLog() function is called. StartLog() will cause an initial call to ReadSample() and StopLog() causes the final call.




For more complete information about compiler optimizations, see our Optimization Notice.

1 comment



  Is it possible to determine how much power individual processes consume? If not directly then perhaps there is some possible way to correlate, maybe using CPU usage stats etc.?



Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.