Skip to content

Commit c9aedc1

Browse files
committed
Merge branch 'reflect' of https://github.com/UniStuttgart-VISUS/power-overwhelming into reflect
2 parents cdf9d6c + 7ae7d52 commit c9aedc1

File tree

108 files changed

+1769
-614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1769
-614
lines changed

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ project(power-overwhelming)
99
# User-configurable options.
1010
option(PWROWG_BuildDemo "Build demo programme" OFF)
1111

12+
option(PWROWG_BuildDumpSensors "Build dump_sensors utility" ON)
13+
1214
if (WIN32)
1315
option(PWROWG_BuildStablePower "Build setstablepowerstate tool" OFF)
1416
else (WIN32)
@@ -41,7 +43,14 @@ if (PWROWG_BuildTests)
4143
endif (PWROWG_BuildTests)
4244

4345
# Demo programme
44-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/podump)
46+
if (PWROWG_BuildDemo)
47+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/podump)
48+
endif (PWROWG_BuildDemo)
49+
50+
# dump_sensors utility
51+
if (PWROWG_BuildDumpSensors)
52+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dump_sensors)
53+
endif (PWROWG_BuildDumpSensors)
4554

4655
# Browser
4756
if (PWROWG_BuildWeb)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This project provides a library for measuring the power consumption of GPUs (and
99
The library is self-contained and most optional external dependencies are in the third_party folder. External dependencies from GitHub are fetched by CMake. Once built, the external dependencies are invisible to the user of the library. However, the required DLLs must be present on the target machine. Configure the project using [CMake](https://cmake.org/) and build with Visual Studio or alike.
1010

1111
### Sensors included in the repository
12-
SDKs included in the repository are the [AMD Display Library (ADL)](https://github.com/GPUOpen-LibrariesAndSDKs/display-library), the [NVIDIA Management Library (NVML)](https://developer.nvidia.com/nvidia-management-library-nvml) and support for [Tinkerforge](https://github.com/Tinkerforge) bricks and bricklets. On Windows 11, the [Energy Meter Interface](https://learn.microsoft.com/en-us/windows-hardware/drivers/powermeter/energy-meter-interface) can be used to query the RAPL (Running Average Power Limit Energy Reporting) registers of the system.
12+
SDKs included in the repository are the [AMD Display Library (ADL)](https://github.com/GPUOpen-LibrariesAndSDKs/display-library), the [NVIDIA Management Library (NVML)](https://developer.nvidia.com/nvidia-management-library-nvml) and support for [Tinkerforge](https://github.com/Tinkerforge) bricks and bricklets. On Windows 11, the [Energy Meter Interface](https://learn.microsoft.com/en-us/windows-hardware/drivers/powermeter/energy-meter-interface) can be used to query the RAPL (Running Average Power Limit Energy Reporting) registers of the system. This sensor might be available on certain Windows 10 installations, but according to a [presentation by the Firefox team](https://fosdem.org/2023/schedule/event/energy_power_profiling_firefox/attachments/slides/5537/export/events/attachments/energy_power_profiling_firefox/slides/5537/FOSDEM_2023_Power_profiling_with_the_Firefox_Profiler.pdf), specialised hardware is supported for that.
1313

1414
### Support for Rohde & Schwarz instruments
1515
The library supports reading Rohde & Schwarz oscilloscopes of the RTB 2000 family and HMC8015 power analysers. In order for this to work, VISA must be installed on the development machine. You can download the drivers from https://www.rohde-schwarz.com/de/driver-pages/fernsteuerung/3-visa-and-tools_231388.html. The VISA installation is automatically detected by CMAKE. If VISA was found `POWER_OVERWHELMING_WITH_VISA` will be defined. Otherwise, VISA will not be supported and using it will fail at runtime.

dump_sensors/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# CMakeLists.txt
2+
# Copyright © 2023 Visualisierungsinstitut der Universität Stuttgart. Alle Rechte vorbehalten.
3+
4+
5+
project(dump_sensors)
6+
7+
# Collect source files.
8+
file(GLOB_RECURSE HeaderFiles RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.h" "*.inl")
9+
file(GLOB_RECURSE SourceFiles RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.cpp")
10+
11+
# Define the output.
12+
add_executable(${PROJECT_NAME} ${HeaderFiles} ${SourceFiles})
13+
14+
# Configure the linker.
15+
target_link_libraries(${PROJECT_NAME} power_overwhelming)
16+
17+
# Deploy DLLs with the executable.
18+
if (WIN32)
19+
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
20+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:${PROJECT_NAME}> $<TARGET_FILE_DIR:${PROJECT_NAME}>
21+
COMMAND_EXPAND_LISTS)
22+
endif (WIN32)

dump_sensors/dump_sensors.cpp

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// <copyright file="dump_sensors.cpp" company="Visualisierungsinstitut der Universität Stuttgart">
2+
// Copyright © 2023 Visualisierungsinstitut der Universität Stuttgart. Alle Rechte vorbehalten.
3+
// </copyright>
4+
// <author>Christoph Müller</author>
5+
6+
#include "power_overwhelming/collector.h"
7+
#include "power_overwhelming/dump_sensors.h"
8+
9+
#include <algorithm>
10+
#include <iostream>
11+
#include <vector>
12+
13+
#if defined(_WIN32)
14+
#include <Windows.h>
15+
#include <tchar.h>
16+
#endif /* defined(_WIN32) */
17+
18+
#if !defined(_tmain)
19+
#define _tmain main
20+
#define TCHAR char
21+
#define _T(x) (x)
22+
#endif /* !defined(_tmain) */
23+
24+
25+
/// <summary>
26+
/// Entry point of the dump_sensors application, which dumps the definitions of
27+
/// all sensors into the user-provided file.
28+
/// </summary>
29+
/// <param name="argc"></param>
30+
/// <param name="argv"></param>
31+
/// <returns></returns>
32+
int _tmain(const int argc, const TCHAR **argv) {
33+
using namespace visus::power_overwhelming;
34+
35+
std::wcout << L"dump_sensors" << std::endl;
36+
std::wcout << L"© 2023 Visualisierungsinstitut der Universität Stuttgart."
37+
<< std::endl << L"All rights reserved."
38+
<< std::endl << std::endl;
39+
40+
const std::vector<std::basic_string<TCHAR>> cmd_line(argv, argv + argc);
41+
auto show_help = (argc < 2);
42+
43+
const auto collector = std::find(cmd_line.begin(), cmd_line.end(),
44+
_T("--collector"));
45+
if (collector != cmd_line.end()) {
46+
// If the --collector option is specified, the file must be after it.
47+
show_help = ((collector + 1) == cmd_line.end());
48+
}
49+
50+
if (show_help) {
51+
// Input is wrong, so show the help.
52+
std::wcout << L"Dumps the definition of all sensors that are currently "
53+
<< L"available on this machine " << std::endl
54+
<< L"into a JSON file." << std::endl << std::endl;
55+
std::wcout << "Usage: dump_sensors [--collector] <output path>"
56+
<< std::endl;
57+
return -2;
58+
}
59+
60+
// Can go on with the real thing, which is just calling into the library to
61+
// save the sensor definitions.
62+
try {
63+
if (collector != cmd_line.end()) {
64+
const auto path0 = *(collector + 1);
65+
const auto path = convert_string<wchar_t>(path0);
66+
collector::make_configuration_template(path.c_str());
67+
std::wcout << L"Collector configuration template dumped to \""
68+
<< path << L"\"." << std::endl;
69+
70+
} else {
71+
const auto path = cmd_line[1];
72+
const auto cnt = dump_sensors(path);
73+
std::wcout << cnt << ((cnt == 1) ? L" sensor" : L" sensors")
74+
<< L" dumped to \"" << path.c_str() << L"\"." << std::endl;
75+
}
76+
77+
return 0;
78+
} catch (std::exception& ex) {
79+
std::cout << ex.what() << std::endl;
80+
return -1;
81+
}
82+
}

podump/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ add_executable(${PROJECT_NAME} ${HeaderFiles} ${SourceFiles})
1717
target_link_libraries(${PROJECT_NAME} power_overwhelming)
1818

1919
# Deploy DLLs with the executable.
20-
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
21-
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:${PROJECT_NAME}> $<TARGET_FILE_DIR:${PROJECT_NAME}>
22-
COMMAND_EXPAND_LISTS)
20+
if (WIN32)
21+
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
22+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:${PROJECT_NAME}> $<TARGET_FILE_DIR:${PROJECT_NAME}>
23+
COMMAND_EXPAND_LISTS)
24+
endif (WIN32)

podump/adl_sensor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// <copyright file="adl_sensor.cpp" company="Visualisierungsinstitut der Universität Stuttgart">
2-
// Copyright © 2023 Visualisierungsinstitut der Universität Stuttgart. Alle Rechte vorbehalten.
1+
// <copyright file="adl_sensor.cpp" company="Visualisierungsinstitut der Universität Stuttgart">
2+
// Copyright © 2023 Visualisierungsinstitut der Universität Stuttgart. Alle Rechte vorbehalten.
33
// </copyright>
4-
// <author>Christoph Müller</author>
4+
// <author>Christoph Müller</author>
55

66
#include "pch.h"
77
#include "adl_sensor.h"

podump/adl_sensor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// <copyright file="adl_sensor.h" company="Visualisierungsinstitut der Universität Stuttgart">
2-
// Copyright © 2023 Visualisierungsinstitut der Universität Stuttgart. Alle Rechte vorbehalten.
1+
// <copyright file="adl_sensor.h" company="Visualisierungsinstitut der Universität Stuttgart">
2+
// Copyright © 2023 Visualisierungsinstitut der Universität Stuttgart. Alle Rechte vorbehalten.
33
// </copyright>
4-
// <author>Christoph Müller</author>
4+
// <author>Christoph Müller</author>
55

66
#pragma once
77

podump/collector.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// <copyright file="collector.cpp" company="Visualisierungsinstitut der Universität Stuttgart">
2-
// Copyright © 2023 Visualisierungsinstitut der Universität Stuttgart. Alle Rechte vorbehalten.
1+
// <copyright file="collector.cpp" company="Visualisierungsinstitut der Universität Stuttgart">
2+
// Copyright © 2023 Visualisierungsinstitut der Universität Stuttgart. Alle Rechte vorbehalten.
33
// </copyright>
4-
// <author>Christoph Müller</author>
4+
// <author>Christoph Müller</author>
55

66
#include "pch.h"
77
#include "collector.h"

podump/collector.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// <copyright file="collector.h" company="Visualisierungsinstitut der Universität Stuttgart">
2-
// Copyright © 2023 Visualisierungsinstitut der Universität Stuttgart. Alle Rechte vorbehalten.
1+
// <copyright file="collector.h" company="Visualisierungsinstitut der Universität Stuttgart">
2+
// Copyright © 2023 Visualisierungsinstitut der Universität Stuttgart. Alle Rechte vorbehalten.
33
// </copyright>
4-
// <author>Christoph Müller</author>
4+
// <author>Christoph Müller</author>
55

66
#pragma once
77

podump/emi_sensor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// <copyright file="emi_sensor.cpp" company="Visualisierungsinstitut der Universität Stuttgart">
2-
// Copyright © 2023 Visualisierungsinstitut der Universität Stuttgart. Alle Rechte vorbehalten.
1+
// <copyright file="emi_sensor.cpp" company="Visualisierungsinstitut der Universität Stuttgart">
2+
// Copyright © 2023 Visualisierungsinstitut der Universität Stuttgart. Alle Rechte vorbehalten.
33
// </copyright>
4-
// <author>Christoph Müller</author>
4+
// <author>Christoph Müller</author>
55

66
#include "pch.h"
77
#include "emi_sensor.h"

0 commit comments

Comments
 (0)