Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Mincheol_S_
Beginner
121 Views

RAPL of Intel Atom C2758

Hi,

I am trying to measure power of Intel Atom processor. My target processor is Intel Atom C2758 and it turns out even latest Linux doesn't support it.(intel_rapl module).

So, I tried to read MSR directly with this simple C program(http://web.eece.maine.edu/~vweaver/projects/rapl/) and I can read the values.

However, the values were strange. Even though I put a lot of load on the CPU with sending requests via apache2 benchmark, the power consumption measured by RAPL did not change while with an Intel i7 Haswell core it did change.

Below is what I port the RAPL to Intel Atom.

static long long read_msr(int fd, int which) {

        uint64_t data;

        if (pread(fd, &data, sizeof data, which) != sizeof data ) {
                perror("rdmsr:pread");
                exit(127);
        }

        return (long long)data;
}


/*******************************/
/* MSR code                    */
/*******************************/
static int rapl_msr(int core, int cpu_model) {

        int fd;
        long long result;
        double power_units,time_units;
        double cpu_energy_units[MAX_PACKAGES];
        double package_before[MAX_PACKAGES],package_after[MAX_PACKAGES];
        double thermal_spec_power,minimum_power,maximum_power,time_window;
        int j;

        printf("\nTrying /dev/msr interface to gather results\n\n");

        if (cpu_model<0) {
                printf("\tUnsupported CPU model %d\n",cpu_model);
                return -1;
        }

        for(j=0;j<total_packages;j++) {
                printf("\tListing paramaters for package #%d\n",j);

                fd=open_msr(package_map);

                result=read_msr(fd,MSR_RAPL_POWER_UNIT);

                power_units=pow(0.5,(double)(result&0xf));
                cpu_energy_units=pow(0.5,(double)((result>>8)&0x1f));
                time_units=pow(0.5,(double)((result>>16)&0xf));


                printf("\t\tPower units = %.3fW\n",power_units);
                printf("\t\tCPU Energy units = %.8fJ\n",cpu_energy_units);
                printf("\t\tTime units = %.8fs\n",time_units);
                printf("\n");

                /* Show package power info */
                result=read_msr(fd,MSR_PKG_POWER_INFO);

                thermal_spec_power=power_units*(double)(result&0x7fff);
                printf("\t\tPackage thermal spec: %.3fW\n",thermal_spec_power);
                minimum_power=power_units*(double)((result>>16)&0x7fff);
                printf("\t\tPackage minimum power: %.3fW\n",minimum_power);
                maximum_power=power_units*(double)((result>>32)&0x7fff);
                printf("\t\tPackage maximum power: %.3fW\n",maximum_power);
                time_window=time_units*(double)((result>>48)&0x7fff);
                printf("\t\tPackage maximum time window: %.6fs\n",time_window);

                /* Show package power limit */
                result=read_msr(fd,MSR_PKG_RAPL_POWER_LIMIT);
                printf("\t\tPackage power limits are %s\n", (result >> 63) ? "locked" : "unlocked");
                double pkg_power_limit_1 = power_units*(double)((result>>0)&0x7FFF);
                double pkg_time_window_1 = time_units*(double)((result>>17)&0x007F);
                printf("\t\tPackage power limit #1: %.3fW for %.6fs (%s, %s)\n",
                        pkg_power_limit_1, pkg_time_window_1,
                        (result & (1LL<<15)) ? "enabled" : "disabled",
                        (result & (1LL<<16)) ? "clamped" : "not_clamped");
                double pkg_power_limit_2 = power_units*(double)((result>>32)&0x7FFF);
                double pkg_time_window_2 = time_units*(double)((result>>49)&0x007F);
                printf("\t\tPackage power limit #2: %.3fW for %.6fs (%s, %s)\n",
                        pkg_power_limit_2, pkg_time_window_2,
                        (result & (1LL<<47)) ? "enabled" : "disabled",
                        (result & (1LL<<48)) ? "clamped" : "not_clamped");

                close(fd);

        }
        printf("\n");

        for(j=0;j<total_packages;j++) {

                fd=open_msr(package_map);

                /* Package Energy */
                result=read_msr(fd,MSR_PKG_ENERGY_STATUS);

                package_before=(double)result*cpu_energy_units;

                close(fd);
        }

        printf("\n\tSleeping 5 second\n\n");
        sleep(5);

        for(j=0;j<total_packages;j++) {

                fd=open_msr(package_map);

                printf("\tPackage %d:\n",j);

                /* Package Energy */
                result=read_msr(fd,MSR_PKG_ENERGY_STATUS);

                package_after=(double)result*cpu_energy_units;

                printf("\t\tPackage energy: %.6fJ\n",
                        package_after-package_before);

                close(fd);
        }
        printf("\n");
        printf("Note: the energy measurements can overflow in 60s or so\n");
        printf("      so try to sample the counters more often than that.\n\n");

        return 0;
}

 

0 Kudos
3 Replies
McCalpinJohn
Black Belt
121 Views

I had no trouble getting reasonable RAPL numbers on a C2750, but that was a while ago...

When you say "the power consumption measured by RAPL did not change", do you mean that the "Package energy" printed out by the code listed above showed approximately the same number of Joules used over the 1 second sleep period for multiple runs?

What sort of "Package energy" values are being produced by this code?   Since the values are for a 1 second sampling period, the number of Joules will equal the average power consumption in Watts.  The Atom C2758 is a 20 Watt part (as is the C2750 that I tested), but I was never able to drive it to use more than about 12 Watts with all 8 cores pinned to the nominal 2.4 GHz or just under 15 Watts with all 8 cores at their maximum Turbo frequency.   I did not pay that much attention to the power use under lower loads, so it might not have been varying a lot....

Mincheol_S_
Beginner
121 Views

Mccalpin, John wrote:

I had no trouble getting reasonable RAPL numbers on a C2750, but that was a while ago...

When you say "the power consumption measured by RAPL did not change", do you mean that the "Package energy" printed out by the code listed above showed approximately the same number of Joules used over the 1 second sleep period for multiple runs?

What sort of "Package energy" values are being produced by this code?   Since the values are for a 1 second sampling period, the number of Joules will equal the average power consumption in Watts.  The Atom C2758 is a 20 Watt part (as is the C2750 that I tested), but I was never able to drive it to use more than about 12 Watts with all 8 cores pinned to the nominal 2.4 GHz or just under 15 Watts with all 8 cores at their maximum Turbo frequency.   I did not pay that much attention to the power use under lower loads, so it might not have been varying a lot....

Hi John,

I ran the program, it printed

    Listing paramaters for package #0
        Power units = 0.125W
        CPU Energy units = 0.00001526J
        Time units = 0.00097656s

        Package thermal spec: 312.500W
        Package minimum power: 0.000W
        Package maximum power: 0.000W
        Package maximum time window: 0.000000s
        Package power limits are unlocked
        Package power limit #1: 312.500W for 0.043945s (enabled, clamped)
        Package power limit #2: 375.000W for 0.034180s (enabled, not_clamped)


    Sleeping 5 second

    Package 0:
        Package energy: 39.070312J

I corrected the typo "Sleeping 1 second" to "Sleeping 5 second"

The thing is that even though with high load, the "Package energy" doesn't change.

The "Package energy" shows overall energy change in 5 seconds, so for power measurement, I can divide it by 5.

I am also wondering whether "Package thermal spec: 312.500W" is reasonable.

McCalpinJohn
Black Belt
121 Views

The power units, energy units, and time units look good.

The package thermal spec makes no sense at all, but the code looks identical to the code that I use that gives results that match the specifications on every machine that I have tested -- except for the Atom C2750.  The formulas values for minimum and maximum power look the same as mine.  I have never seen a processor that did not have reasonable numbers in these fields, but I did not look at those fields on the Atom C2750.  It would probably be a good idea to dump the raw value of MSR_PKG_POWER_INFO to provide an independent way of looking at the data.

The "package maximum time window" is computed incorrectly -- I made the same mistake the first time I tried this.  The actual encoding here is a weird floating-point format described in Section 14.9 of Volume 3 of the Intel Architecture SW Developer's Manual.

The Atom C2750 that I tested showed 0.000W for the package thermal spec -- not sure what was going on there -- but gave completely reasonable values for power limit #1 (20 Watts) and power limit #2 (24 Watts).  Unfortunately I don't appear to have saved either the exact source code or the exact binary that I used for those tests.....

Reply