libdvfs  2.0
A light library to set CPU governor and freqency
dvfs_unit.h
Go to the documentation of this file.
1 /*
2  * libdvfs - A light library to set CPU governor and frequency
3  * Copyright (C) 2013-2014 Universite de Versailles
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include "dvfs_core.h"
22 
40 typedef struct {
41  unsigned int id;
42  unsigned int nb_cores;
44 } dvfs_unit;
45 
63 int dvfs_unit_open(dvfs_unit** ppUnit, unsigned int nb_cores, dvfs_core **cores, unsigned int unit_id);
64 
77 int dvfs_unit_close(dvfs_unit *unit);
78 
89 int dvfs_unit_set_gov(const dvfs_unit *unit, const char *gov);
90 
101 int dvfs_unit_set_freq(const dvfs_unit *unit, unsigned int freq);
102 
112 int dvfs_unit_get_nb_cores(const dvfs_unit* unit, unsigned int* pNbCores);
113 
126 int dvfs_unit_get_core(const dvfs_unit *unit, dvfs_core** ppCore, unsigned int id);
127 
137 int dvfs_unit_get_freq(const dvfs_unit *unit, unsigned int* pFreq);
138 
149 int dvfs_unit_get_id(const dvfs_unit *unit, unsigned int *pID);
int dvfs_unit_set_freq(const dvfs_unit *unit, unsigned int freq)
Sets the given frequency on all the unit cores.
Definition: dvfs_unit.c:89
int dvfs_unit_close(dvfs_unit *unit)
Frees the memory associated to a DVFS unit and restore their DVFS state.
Definition: dvfs_unit.c:47
int dvfs_unit_get_freq(const dvfs_unit *unit, unsigned int *pFreq)
Gets the frequency currently set for the current DVFS unit.
Definition: dvfs_unit.c:143
dvfs_core ** cores
Cores in the unit.
Definition: dvfs_unit.h:43
int dvfs_unit_get_id(const dvfs_unit *unit, unsigned int *pID)
Returns the index of the considered DVFS unit as stored in the corresponding DVFS context structure a...
Definition: dvfs_unit.c:167
int dvfs_unit_set_gov(const dvfs_unit *unit, const char *gov)
Sets a governor on all the cores we are in charge of.
Definition: dvfs_unit.c:66
A DVFS unit.
Definition: dvfs_unit.h:40
int dvfs_unit_get_core(const dvfs_unit *unit, dvfs_core **ppCore, unsigned int id)
Gets the core with the given id if it is part of this DVFS unit, or NULL otherwise.
Definition: dvfs_unit.c:123
Structures and functions to change frequency at the scale of a CPU core.
unsigned int id
Unit id as described in the dvfs_context structure.
Definition: dvfs_unit.h:41
int dvfs_unit_get_nb_cores(const dvfs_unit *unit, unsigned int *pNbCores)
Gets te number of cores available in this DVFS unit.
Definition: dvfs_unit.c:110
Represents on core.
Definition: dvfs_core.h:36
unsigned int nb_cores
Number of cores in the unit.
Definition: dvfs_unit.h:42
int dvfs_unit_open(dvfs_unit **ppUnit, unsigned int nb_cores, dvfs_core **cores, unsigned int unit_id)
Creates a new DVFS unit in charge of the provided cores.
Definition: dvfs_unit.c:26