libmsr
0.3.0
A friendlier interface to accessing MSRs on Intel platforms
|
#include <math.h>
#include <omp.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <tgmath.h>
#include "msr_core.h"
#include "memhdlr.h"
#include "cpuid.h"
#include "msr_rapl.h"
#include "msr_turbo.h"
#include "libmsr_error.h"
#include "libmsr_debug.h"
Functions | |
int | rapl_storage (struct rapl_data **data, uint64_t **flags) |
Store the RAPL data and flags on the heap. | |
int | print_available_rapl (void) |
Print available RAPL registers based on platform-dependent flags. | |
int | rapl_init (struct rapl_data **rapl, uint64_t **rapl_flags) |
Initialize storage for Running Average Power Limit (RAPL) data and flags. | |
int | set_pkg_rapl_limit (const unsigned socket, struct rapl_limit *limit1, struct rapl_limit *limit2) |
Determine the steps necessary to set the user-supplied package-level power limit(s). | |
int | set_dram_rapl_limit (const unsigned socket, struct rapl_limit *limit) |
Determine the steps necessary to set the user-supplied DRAM limit. | |
int | set_pp_rapl_limit (const unsigned socket, struct rapl_limit *limit0, struct rapl_limit *limit1) |
Determine the steps necessary to set the user-supplied power plane limit. | |
int | get_rapl_power_info (const unsigned socket, struct rapl_power_info *info) |
Get power info data for all RAPL power domains. | |
int | set_pp_rapl_policies (const unsigned socket, uint64_t *pp0, uint64_t *pp1) |
Determine the steps necessary to set the user-supplied power plane policy. | |
int | get_pp_rapl_policies (const unsigned socket, uint64_t *pp0, uint64_t *pp1) |
Get RAPL policies for the power plane domains. | |
int | get_pkg_rapl_limit (const unsigned socket, struct rapl_limit *limit1, struct rapl_limit *limit2) |
Get RAPL power limit for the package domain. | |
int | get_dram_rapl_limit (const unsigned socket, struct rapl_limit *limit) |
Get RAPL power limit for the DRAM domain. | |
int | get_pp_rapl_limit (const unsigned socket, struct rapl_limit *limit0, struct rapl_limit *limit1) |
Get RAPL power limit for the power plane domains. | |
void | dump_rapl_limit (struct rapl_limit *L, FILE *writedest) |
Print out RAPL power limit. | |
int | dump_rapl_data_terse_label (FILE *writedest) |
Print the label for the abbreviated RAPL data print out. | |
int | dump_rapl_data_terse (FILE *writedest) |
Print abbreviated RAPL data. | |
int | dump_rapl_data (FILE *writedest) |
Print out a specified RAPL data item. | |
int | dump_rapl_power_info (FILE *writedest) |
Print out only RAPL power data. | |
void | get_rapl_power_unit (struct rapl_units *ru) |
Get units for RAPL power data. | |
void | dump_rapl_power_unit (FILE *writedest) |
Print out RAPL power units (power, energy, time). | |
int | poll_rapl_data (void) |
Read the current RAPL data and calculate the deltas from the previous call to this function. | |
int | delta_rapl_data (void) |
Check how much the RAPL data has changed overtime to derive time-based values, such as power. | |
int | read_rapl_data (void) |
Read all available RAPL data for a given socket. | |
int delta_rapl_data | ( | void | ) |
Check how much the RAPL data has changed overtime to derive time-based values, such as power.
int dump_rapl_data | ( | FILE * | writedest | ) |
Print out a specified RAPL data item.
[in] | writedest | File stream where output will be written to. |
int dump_rapl_data_terse | ( | FILE * | writedest | ) |
Print abbreviated RAPL data.
[in] | writedest | File stream where output will be written to. |
int dump_rapl_data_terse_label | ( | FILE * | writedest | ) |
Print the label for the abbreviated RAPL data print out.
[in] | writedest | File stream where output will be written to. |
void dump_rapl_limit | ( | struct rapl_limit * | L, |
FILE * | writedest | ||
) |
Print out RAPL power limit.
[in] | L | RAPL power limit for a given domain. |
[in] | writedest | File stream where output will be written to. |
int dump_rapl_power_info | ( | FILE * | writedest | ) |
Print out only RAPL power data.
[in] | writedest | File stream where output will be written to. |
void dump_rapl_power_unit | ( | FILE * | writedest | ) |
Print out RAPL power units (power, energy, time).
[in] | writedest | File stream where output will be written to. |
int get_dram_rapl_limit | ( | const unsigned | socket, |
struct rapl_limit * | limit | ||
) |
Get RAPL power limit for the DRAM domain.
If a pointer is null, do nothing. If the bit vector is nonzero, translate the bit vector to watts and seconds. If the bit vector is zero, read the msr value into the bit vector and translate into watts and seconds.
[in] | socket | Identifier of socket to read |
[out] | limit | Data for DRAM domain RAPL power limit. |
int get_pkg_rapl_limit | ( | const unsigned | socket, |
struct rapl_limit * | limit1, | ||
struct rapl_limit * | limit2 | ||
) |
Get RAPL power limit for the package domain.
If a pointer is null, do nothing. If the bit vector is nonzero, translate the bit vector to watts and seconds. If the bit vector is zero, read the msr value into the bit vector and translate into watts and seconds.
[in] | socket | Identifier of socket to read |
[out] | limit1 | Data for package domain RAPL power limit 1 (lower). |
[out] | limit2 | Data for package domain RAPL power limit 2 (upper). |
int get_pp_rapl_limit | ( | const unsigned | socket, |
struct rapl_limit * | limit0, | ||
struct rapl_limit * | limit1 | ||
) |
Get RAPL power limit for the power plane domains.
If a pointer is null, do nothing. If the bit vector is nonzero, translate the bit vector to watts and seconds. If the bit vector is zero, read the msr value into the bit vector and translate into watts and seconds.
[in] | socket | Identifier of socket to read |
[out] | limit0 | Data for PP0 domain RAPL power limit. |
[out] | limit1 | Data for PP1 domain RAPL power limit. |
int get_pp_rapl_policies | ( | const unsigned | socket, |
uint64_t * | pp0, | ||
uint64_t * | pp1 | ||
) |
Get RAPL policies for the power plane domains.
[in] | socket | Unique socket/package identifier. |
[out] | pp0 | Raw 64-bit value stored in MSR_PP0_POLICY. |
[out] | pp1 | Raw 64-bit value stored in MSR_PP1_POLICY. |
int get_rapl_power_info | ( | const unsigned | socket, |
struct rapl_power_info * | info | ||
) |
Get power info data for all RAPL power domains.
If a pointer is null, do nothing. If the bit vector is nonzero, translate the bit vector to watts and seconds. If the bit vector is zero, read the msr value into the bit vector and translate into watts and seconds.
[in] | socket | Unique socket/package identifier. |
[out] | info | Data for domain-specific power range info for RAPL usage. |
void get_rapl_power_unit | ( | struct rapl_units * | ru | ) |
Get units for RAPL power data.
[out] | ru | Data for RAPL power units. |
int poll_rapl_data | ( | void | ) |
Read the current RAPL data and calculate the deltas from the previous call to this function.
If this function has not been called at least once, then the data will be initialized to zeros. NOTE: This is now what you use instead of read_rapl_data().
int print_available_rapl | ( | void | ) |
Print available RAPL registers based on platform-dependent flags.
int rapl_init | ( | struct rapl_data ** | rapl, |
uint64_t ** | rapl_flags | ||
) |
Initialize storage for Running Average Power Limit (RAPL) data and flags.
Be sure to put this function before any other RAPL functions.
[out] | rapl | Pointer to storage for energy, time, and power data measurements from a given RAPL power domain. |
[out] | rapl_flags | Pointer to storage for flags indicating available on registers on platform. |
int rapl_storage | ( | struct rapl_data ** | data, |
uint64_t ** | flags | ||
) |
Store the RAPL data and flags on the heap.
This data will be used by nearly all other RAPL APIs. A user can retrieve only RAPL data or only RAPL flags by passing a NULL argument.
[out] | data | Pointer to measurements of energy, time, and power data from a given RAPL power domain. |
[out] | flags | Pointer to RAPL flags indicating available registers on a given platform. |
int read_rapl_data | ( | void | ) |
Read all available RAPL data for a given socket.
int set_dram_rapl_limit | ( | const unsigned | socket, |
struct rapl_limit * | limit | ||
) |
Determine the steps necessary to set the user-supplied DRAM limit.
If a pointer is null, do nothing. If the bit vector is nonzero, translate the bit vector to watts and seconds and write the bit vector to the msr. If the bit vector is zero, translate the watts and seconds to the appropriate bit vector and write the bit vector to the msr.
[in] | socket | Unique socket/package identifier. |
[out] | limit | RAPL power limit data for DRAM power domain. |
int set_pkg_rapl_limit | ( | const unsigned | socket, |
struct rapl_limit * | limit1, | ||
struct rapl_limit * | limit2 | ||
) |
Determine the steps necessary to set the user-supplied package-level power limit(s).
If a pointer is null, do nothing. If the bit vector is nonzero, translate the bit vector to watts and seconds and write the bit vector to the msr. If the bit vector is zero, translate the watts and seconds to the appropriate bit vector and write the bit vector to the msr.
[in] | socket | Unique socket/package identifier. |
[in] | limit1 | Data for lower power limit 1. |
[in] | limit2 | Data for upper power limit 2. |
int set_pp_rapl_limit | ( | const unsigned | socket, |
struct rapl_limit * | limit0, | ||
struct rapl_limit * | limit1 | ||
) |
Determine the steps necessary to set the user-supplied power plane limit.
If a pointer is null, do nothing. If the bit vector is nonzero, translate the bit vector to watts and seconds and write the bit vector to the msr. If the bit vector is zero, translate the watts and seconds to the appropriate bit vector and write the bit vector to the msr.
[in] | socket | Unique socket/package identifier. |
[in] | limit0 | Data for PP0 power limit. |
[in] | limit1 | Data for PP1 power limit. |
int set_pp_rapl_policies | ( | const unsigned | socket, |
uint64_t * | pp0, | ||
uint64_t * | pp1 | ||
) |
Determine the steps necessary to set the user-supplied power plane policy.
If a pointer is null, do nothing. If the bit vector is nonzero, translate the bit vector to watts and seconds and write the bit vector to the msr. If the bit vector is zero, translate the watts and seconds to the appropriate bit vector and write the bit vector to the msr.
[in] | socket | Unique socket/package identifier. |
[in] | pp0 | Raw 64-bit value specifying desired policy for PP0. |
[in] | pp1 | Raw 64-bit value specifying desired policy for PP1. |