aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2013-04-15 09:09:29 -0700
committerKristen Carlson Accardi <kristen@linux.intel.com>2013-04-19 13:07:33 -0700
commitb8b76b0405faccec0aee6471374ffa002c82a085 (patch)
tree4434efee1ff3dfa90fe18bfa9e179c2e03d245cf
parentd96318374803743fabc10c4166519bac5d811bee (diff)
downloadpowertop-2.0-v2-b8b76b0405faccec0aee6471374ffa002c82a085.tar.gz
Add RAPL PP1 domain for GPU
Added RAPL PP1 domain as GPU core power. This will show "GPU misc" and "GPU core" in device stats, if PP1 domain is present. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-rw-r--r--src/Makefile.am2
-rw-r--r--src/devices/gpu_rapl_device.cpp70
-rw-r--r--src/devices/gpu_rapl_device.h57
-rw-r--r--src/devices/i915-gpu.cpp21
-rw-r--r--src/devices/i915-gpu.h6
5 files changed, 154 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index cc4b6d7..7c37356 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,7 +33,7 @@ powertop_SOURCES = parameters/persistent.cpp parameters/learn.cpp parameters/par
report/report-formatter-html.cpp report/report-formatter-html.h \
main.cpp css.h powertop.css cpu/intel_gpu.cpp \
cpu/rapl/rapl_interface.cpp cpu/cpu_rapl_device.cpp \
- cpu/dram_rapl_device.cpp
+ cpu/dram_rapl_device.cpp devices/gpu_rapl_device.cpp
powertop_CXXFLAGS = -fno-omit-frame-pointer -fstack-protector -Wall -Wshadow -Wformat $(NCURSES_CFLAGS) $(PCIUTILS_CFLAGS) $(LIBNL_CFLAGS) $(GLIB2_CFLAGS)
diff --git a/src/devices/gpu_rapl_device.cpp b/src/devices/gpu_rapl_device.cpp
new file mode 100644
index 0000000..71d71a0
--- /dev/null
+++ b/src/devices/gpu_rapl_device.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2010, Intel Corporation
+ *
+ * This file is part of PowerTOP
+ *
+ * This program file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program in a file named COPYING; if not, write to the
+ * Free Software Foundation, Inc,
+ * 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ * or just google for it.
+ *
+ * Authors:
+ * Srinivas Pandruvada<Srinivas.Pandruvada@linux.intel.com>
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "../parameters/parameters.h"
+#include "gpu_rapl_device.h"
+
+gpu_rapl_device::gpu_rapl_device(i915gpu *parent)
+ : i915gpu(),
+ device_valid(false)
+{
+ last_time = time(NULL);
+ if (rapl.pp1_domain_present()) {
+ device_valid = true;
+ parent->add_child(this);
+ rapl.get_pp1_energy_status(&last_energy);
+ }
+}
+
+void gpu_rapl_device::start_measurement(void)
+{
+ last_time = time(NULL);
+
+ rapl.get_pp1_energy_status(&last_energy);
+}
+
+void gpu_rapl_device::end_measurement(void)
+{
+ time_t curr_time = time(NULL);
+ double energy;
+
+ consumed_power = 0.0;
+ if ((curr_time - last_time) > 0) {
+ rapl.get_pp1_energy_status(&energy);
+ consumed_power = (energy-last_energy)/(curr_time-last_time);
+ last_energy = energy;
+ last_time = curr_time;
+ }
+}
+
+double gpu_rapl_device::power_usage(struct result_bundle *result, struct parameter_bundle *bundle)
+{
+ if (rapl.pp1_domain_present())
+ return consumed_power;
+ else
+ return 0.0;
+}
diff --git a/src/devices/gpu_rapl_device.h b/src/devices/gpu_rapl_device.h
new file mode 100644
index 0000000..fbde246
--- /dev/null
+++ b/src/devices/gpu_rapl_device.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2010, Intel Corporation
+ *
+ * This file is part of PowerTOP
+ *
+ * This program file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program in a file named COPYING; if not, write to the
+ * Free Software Foundation, Inc,
+ * 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ * or just google for it.
+ *
+ * Authors:
+ * Srinivas Pandruvada <Srinivas.Pandruvada@linux.intel.com>
+ */
+#ifndef _INCLUDE_GUARD_GPU_RAPL_DEVICE_H
+#define _INCLUDE_GUARD_GPU_RAPL_DEVICE_H
+
+#include <vector>
+#include <string>
+
+using namespace std;
+
+#include <sys/time.h>
+#include "i915-gpu.h"
+#include "cpu/rapl/rapl_interface.h"
+
+class gpu_rapl_device: public i915gpu {
+
+ c_rapl_interface rapl;
+ time_t last_time;
+ double last_energy;
+ double consumed_power;
+ bool device_valid;
+
+public:
+ gpu_rapl_device(i915gpu *parent);
+ virtual const char * class_name(void) { return "GPU core";};
+ virtual const char * device_name(void) { return "GPU core";};
+ bool device_present() { return device_valid;}
+ virtual double power_usage(struct result_bundle *result, struct parameter_bundle *bundle);
+ virtual void start_measurement(void);
+ virtual void end_measurement(void);
+
+};
+
+
+#endif
diff --git a/src/devices/i915-gpu.cpp b/src/devices/i915-gpu.cpp
index bcc07cc..a2cfaa5 100644
--- a/src/devices/i915-gpu.cpp
+++ b/src/devices/i915-gpu.cpp
@@ -37,6 +37,7 @@ using namespace std;
#include "i915-gpu.h"
#include "../parameters/parameters.h"
#include "../process/powerconsumer.h"
+#include "gpu_rapl_device.h"
#include <string.h>
#include <unistd.h>
@@ -47,6 +48,14 @@ i915gpu::i915gpu(): device()
rindex = get_result_index("gpu-operations");
}
+const char * i915gpu::device_name(void)
+{
+ if (child_devices.size())
+ return "GPU misc";
+ else
+ return "GPU";
+}
+
void i915gpu::start_measurement(void)
{
}
@@ -66,6 +75,7 @@ void create_i915_gpu(void)
{
char filename[4096];
class i915gpu *gpu;
+ gpu_rapl_device *rapl_dev;
strcpy(filename, "/sys/kernel/debug/tracing/events/i915/i915_gem_ring_dispatch/format");
@@ -80,6 +90,10 @@ void create_i915_gpu(void)
gpu = new class i915gpu();
all_devices.push_back(gpu);
+
+ rapl_dev = new class gpu_rapl_device(gpu);
+ if (rapl_dev->device_present())
+ all_devices.push_back(rapl_dev);
}
@@ -89,11 +103,18 @@ double i915gpu::power_usage(struct result_bundle *result, struct parameter_bundl
double power;
double factor;
double util;
+ double child_power;
power = 0;
factor = get_parameter_value(index, bundle);
util = get_result_value(rindex, result);
power += util * factor / 100.0;
+ for (unsigned int i = 0; i < child_devices.size(); ++i) {
+ child_power = child_devices[i]->power_usage(result, bundle);
+ if ((power - child_power) > 0.0)
+ power -= child_power;
+ }
+
return power;
}
diff --git a/src/devices/i915-gpu.h b/src/devices/i915-gpu.h
index 25cf748..7653b94 100644
--- a/src/devices/i915-gpu.h
+++ b/src/devices/i915-gpu.h
@@ -31,6 +31,8 @@
class i915gpu: public device {
int index;
int rindex;
+ vector<device *>child_devices;
+
public:
i915gpu();
@@ -42,10 +44,12 @@ public:
virtual const char * class_name(void) { return "GPU";};
- virtual const char * device_name(void) { return "GPU";};
+ virtual const char * device_name(void);
virtual double power_usage(struct result_bundle *result, struct parameter_bundle *bundle);
virtual bool show_in_list(void) {return false;};
virtual const char * util_units(void) { return " ops/s"; };
+
+ virtual void add_child(device *dev_ptr) { child_devices.push_back(dev_ptr);}
};
extern void create_i915_gpu(void);