Skip to content

Commit f4bbe11

Browse files
authored
Report Energy Measurements to YAML (#90)
* report joules to yaml * report GPU energy
1 parent 192086f commit f4bbe11

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

c/extensions/irtracker.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ static void writeResources(const ResultMap& results, std::ostream& stream) {
214214
stream << " used process: " << it->second << '\n';
215215
if (ResultMap::const_iterator it; (it = results.find(TIREX_CPU_USED_SYSTEM_PERCENT)) != results.end())
216216
stream << " used system: " << it->second << '\n';
217+
if (ResultMap::const_iterator it; (it = results.find(TIREX_CPU_ENERGY_SYSTEM_JOULES)) != results.end())
218+
stream << " energy used system: " << it->second << " J\n";
217219
//// GPU DATA
218220
stream << " gpu:\n";
219221
if (ResultMap::const_iterator it; (it = results.find(TIREX_GPU_USED_PROCESS_PERCENT)) != results.end())
@@ -224,12 +226,16 @@ static void writeResources(const ResultMap& results, std::ostream& stream) {
224226
stream << " vram used process: " << it->second << '\n';
225227
if (ResultMap::const_iterator it; (it = results.find(TIREX_GPU_VRAM_USED_SYSTEM_MB)) != results.end())
226228
stream << " vram used system: " << it->second << '\n';
229+
if (ResultMap::const_iterator it; (it = results.find(TIREX_GPU_ENERGY_SYSTEM_JOULES)) != results.end())
230+
stream << " energy used system: " << it->second << " J\n";
227231
//// RAM DATA
228232
stream << " ram:\n";
229233
if (ResultMap::const_iterator it; (it = results.find(TIREX_RAM_USED_PROCESS_KB)) != results.end())
230234
stream << " used process: " << it->second << '\n';
231235
if (ResultMap::const_iterator it; (it = results.find(TIREX_RAM_USED_SYSTEM_MB)) != results.end())
232236
stream << " used system: " << it->second << '\n';
237+
if (ResultMap::const_iterator it; (it = results.find(TIREX_RAM_ENERGY_SYSTEM_JOULES)) != results.end())
238+
stream << " energy used system: " << it->second << " J\n";
233239
}
234240

235241
// Not static because internally the measurecommand calls this. Not pretty :(

c/src/measure/stats/energystats.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ Stats EnergyStats::getStats() {
4141
auto results = tracker.calculate_energy().energy;
4242
for (auto& [device, result] : results)
4343
tirex::log::debug("cppjoules", "[{}] {}", device, result);
44+
// Divide by 1000'000 since CPPJoules reports micro Joule (uJ)
4445
return makeFilteredStats(
45-
enabled, std::pair{TIREX_CPU_ENERGY_SYSTEM_JOULES, std::to_string(getOrDefault(results, "core-0", 0))},
46-
std::pair{TIREX_RAM_ENERGY_SYSTEM_JOULES, std::to_string(getOrDefault(results, "dram-0", 0))},
46+
enabled,
47+
std::pair{TIREX_CPU_ENERGY_SYSTEM_JOULES, std::to_string(getOrDefault(results, "core-0", 0) / 1000'000)},
48+
std::pair{TIREX_RAM_ENERGY_SYSTEM_JOULES, std::to_string(getOrDefault(results, "dram-0", 0) / 1000'000)},
4749
std::pair{TIREX_GPU_ENERGY_SYSTEM_JOULES, std::to_string(getOrDefault(results, "nvidia_gpu_0", 0))}
4850
);
4951
}

0 commit comments

Comments
 (0)