Exemple #1
0
void *power_set_measurement(void *arg)
{
    unsigned long poll_num = 0;
    struct mstimer timer;
    set_rapl_power(watt_cap, watt_cap);
    double watts = watt_cap;
    // According to the Intel docs, the counter wraps a most once per second.
    // 100 ms should be short enough to always get good information.
    init_msTimer(&timer, 1500);
    init_data();
    start = now_ms();

    poll_num++;
    timer_sleep(&timer);
    while (running)
    {
        take_measurement();
        if (poll_num%5 == 0)
        {
            if (watts >= watt_cap)
            {
                poll_dir = -5;
            }
            if (watts <= 30)
            {
                poll_dir = 5;
            }
            watts += poll_dir;
            set_rapl_power(watts, watts);
        }
        poll_num++;
        timer_sleep(&timer);
    }
}
Exemple #2
0
void* power_measurement(void* arg) {
    struct mstimer timer;
    // according to the Intel docs, the counter wraps a most once per second
    // 100 ms should be short enough to always get good information
    init_msTimer(&timer, 100);
    init_data();
    read_rapl_init();
    start = now_ms();

    timer_sleep(&timer);
    while(running) {
        take_measurement();
        timer_sleep(&timer);
    }
}