Commit 58de956d authored by Weronika's avatar Weronika

added the temperature sensor

parent 81d7b58c
...@@ -35,6 +35,7 @@ nvmlConfigurator::nvmlConfigurator() { ...@@ -35,6 +35,7 @@ nvmlConfigurator::nvmlConfigurator() {
_gpuFeatureMAP["GPU_ENERGY"] = GPU_ENERGY; _gpuFeatureMAP["GPU_ENERGY"] = GPU_ENERGY;
_gpuFeatureMAP["GPU_POWER"] = GPU_POWER; _gpuFeatureMAP["GPU_POWER"] = GPU_POWER;
_gpuFeatureMAP["GPU_TEMP"] = GPU_TEMP;
_groupName = "group"; _groupName = "group";
_baseName = "sensor"; _baseName = "sensor";
...@@ -44,7 +45,7 @@ nvmlConfigurator::~nvmlConfigurator() {} ...@@ -44,7 +45,7 @@ nvmlConfigurator::~nvmlConfigurator() {}
void nvmlConfigurator::sensorBase(nvmlSensorBase& s, CFG_VAL config) { void nvmlConfigurator::sensorBase(nvmlSensorBase& s, CFG_VAL config) {
//ADD { //ADD {
*/
BOOST_FOREACH (boost::property_tree::iptree::value_type &val, config) { BOOST_FOREACH (boost::property_tree::iptree::value_type &val, config) {
if (boost::iequals(val.first, "feature")) { if (boost::iequals(val.first, "feature")) {
gpuFeatureMap_t::iterator it = _gpuFeatureMAP.find(val.second.data()); gpuFeatureMap_t::iterator it = _gpuFeatureMAP.find(val.second.data());
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
enum GPU_FEATURE { enum GPU_FEATURE {
GPU_ENERGY = 0, GPU_ENERGY = 0,
GPU_POWER = 1, GPU_POWER = 1,
GPU_TEMP = 2,
}; };
/** /**
...@@ -101,6 +102,9 @@ class nvmlSensorBase : public SensorBase { ...@@ -101,6 +102,9 @@ class nvmlSensorBase : public SensorBase {
case GPU_POWER: case GPU_POWER:
feature = "GPU_POWER"; feature = "GPU_POWER";
break; break;
case GPU_TEMP:
feature = "GPU_TEMP";
break;
} }
LOG_VAR(ll) << leading << " Feature type: " << feature; LOG_VAR(ll) << leading << " Feature type: " << feature;
} }
......
...@@ -31,20 +31,13 @@ ...@@ -31,20 +31,13 @@
// Used to ensure we get a sensible value of energy by computing the difference // Used to ensure we get a sensible value of energy by computing the difference
// between calls to the read function // between calls to the read function
static int isfirsttime=0; static int isfirsttime=0;
// We need the energy values to be global too
//unsigned long long energy_initial;
//unsigned long long energy_current;
//unsigned long long energy_previous;
// FR defn of env was global in our test case
struct env_t { struct env_t {
nvmlDevice_t device; nvmlDevice_t device;
} env; } env;
// FR
struct counters_t { struct counters_t {
// unsigned long long energy_start;
// unsigned long long energy_stop;
unsigned long long energy_initial; unsigned long long energy_initial;
unsigned long long energy_current; unsigned long long energy_current;
unsigned long long energy_previous; unsigned long long energy_previous;
...@@ -52,38 +45,25 @@ struct counters_t { ...@@ -52,38 +45,25 @@ struct counters_t {
// unsigned int freq2; // unsigned int freq2;
// unsigned int freq3; // unsigned int freq3;
unsigned int temperature; unsigned int temperature;
unsigned int fanspeed; // unsigned int fanspeed;
// unsigned int clockspeed_graphics; // unsigned int clockspeed_graphics;
// unsigned int clockspeed_sm; // unsigned int clockspeed_sm;
// unsigned int clockspeed_mem; // unsigned int clockspeed_mem;
nvmlMemory_t memory; // nvmlMemory_t memory;
unsigned int power; unsigned int power;
unsigned long long ecc_counts; // unsigned long long ecc_counts;
// nvmlUtilization_t utilization; // nvmlUtilization_t utilization;
} counters; } counters;
nvmlSensorGroup::nvmlSensorGroup(const std::string& name) : nvmlSensorGroup::nvmlSensorGroup(const std::string& name) :
SensorGroupTemplate(name) { SensorGroupTemplate(name) {
/*
* TODO
* Construct attributes
*/
} }
nvmlSensorGroup::nvmlSensorGroup(const nvmlSensorGroup& other) : nvmlSensorGroup::nvmlSensorGroup(const nvmlSensorGroup& other) :
SensorGroupTemplate(other) { SensorGroupTemplate(other) {
/*
* TODO
* Copy construct attributes
*/
} }
nvmlSensorGroup::~nvmlSensorGroup() { nvmlSensorGroup::~nvmlSensorGroup() {}
/*
* TODO
* Tear down attributes
*/
}
nvmlSensorGroup& nvmlSensorGroup::operator=(const nvmlSensorGroup& other) { nvmlSensorGroup& nvmlSensorGroup::operator=(const nvmlSensorGroup& other) {
SensorGroupTemplate::operator=(other); SensorGroupTemplate::operator=(other);
...@@ -166,11 +146,15 @@ void nvmlSensorGroup::read() { ...@@ -166,11 +146,15 @@ void nvmlSensorGroup::read() {
err = nvmlDeviceGetPowerUsage(env.device,&(counters.power)); err = nvmlDeviceGetPowerUsage(env.device,&(counters.power));
reading.value = counters.power; reading.value = counters.power;
break; break;
case(GPU_TEMP):
err = nvmlDeviceGetTemperature(env.device,NVML_TEMPERATURE_GPU,&(counters.temperature));
reading.value = counters.temperature;
break;
} }
s->storeReading(reading); s->storeReading(reading);
#ifdef DEBUG //ifdef DEBUG
LOG(debug) << _groupName << "::" << s->getName() << " raw reading: \"" << reading.value << "\""; LOG(debug) << _groupName << "::" << s->getName() << " raw reading: \"" << reading.value << "\"";
#endif //endif
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
LOG(error) << "Sensorgroup" << _groupName << " could not read value: " << e.what(); LOG(error) << "Sensorgroup" << _groupName << " could not read value: " << e.what();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment