Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Luke_L_
Beginner
84 Views

TECHNOLOGY INTEL RAPL HELP


Hello, I need help in understanding part of code technology intel rapl msr, I would like to know what its for and how it works

 

void Rapl::sample() {
	uint32_t max_int = ~((uint32_t) 0);

	next_state->pkg = read_msr(MSR_PKG_ENERGY_STATUS) & max_int;
	next_state->pp0 = read_msr(MSR_PP0_ENERGY_STATUS) & max_int;

	if (pp1_supported) {
		next_state->pp1 = read_msr(MSR_PP1_ENERGY_STATUS) & max_int;
		next_state->dram = 0;
	} else {
		next_state->pp1 = 0;
		next_state->dram = read_msr(MSR_DRAM_ENERGY_STATUS) & max_int;
	}

	gettimeofday(&(next_state->tsc), NULL);

	running_total.pkg += energy_delta(current_state->pkg, next_state->pkg);
	running_total.pp0 += energy_delta(current_state->pp0, next_state->pp0);
	running_total.pp1 += energy_delta(current_state->pp0, next_state->pp0);
	running_total.dram += energy_delta(current_state->dram, next_state->dram);

	rapl_state_t *pprev_state = prev_state;
	prev_state = current_state;
	current_state = next_state;
	next_state = pprev_state;
}

 

#include <sys/time.h>
double Rapl::time_delta(struct timeval *begin, struct timeval *end) {
        return (end->tv_sec - begin->tv_sec)
                + ((end->tv_usec - begin->tv_usec)/1000000.0);
}

 

thanks for help in advance ! :)

0 Kudos
1 Reply
McCalpinJohn
Black Belt
84 Views

Have you read Section 14.9 of Volume 3 of the Intel Architectures Software Developer's Manual (document 325384, revision 060, September 2016)?  (The manual is currently available at http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-software-d...

Reply