Skip to content

Commit

Permalink
Bumped ADL to 17.1.
Browse files Browse the repository at this point in the history
Added support for new sensor IDs on 7000 series.
  • Loading branch information
crowbar27 committed Jul 26, 2023
1 parent cf2452b commit 1a722e5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,30 @@ namespace power_overwhelming {
enum class adl_sensor_source : std::uint32_t {

/// <summary>
///
/// <c>ADL_PMLOG_SOC_POWER</c>.
/// </summary>
soc = 0x0001,

/// <summary>
///
/// <c>ADL_PMLOG_GFX_POWER</c>.
/// </summary>
graphics = 0x0002,

/// <summary>
///
/// <c>ADL_PMLOG_ASIC_POWER</c> or <c>ADL_PMLOG_SSPAIRED_ASICPOWER</c>.
/// </summary>
asic = 0x0004,

/// <summary>
///
/// <c>ADL_PMLOG_CPU_POWER</c>.
/// </summary>
cpu = 0x0008,

/// <summary>
/// Total board power (<c>ADL_PMLOG_BOARD_POWER</c>).
/// </summary>
board = 0x0010,

/// <summary>
/// Represents all possible sensor sources.
/// </summary>
Expand Down
29 changes: 22 additions & 7 deletions power_overwhelming/src/adl_sensor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <copyright file="adl_sensor.cpp" company="Visualisierungsinstitut der Universität Stuttgart">
// Copyright © 2021 Visualisierungsinstitut der Universität Stuttgart. Alle Rechte vorbehalten.
// Copyright © 2021 - 2023 Visualisierungsinstitut der Universität Stuttgart. Alle Rechte vorbehalten.
// </copyright>
// <author>Christoph Müller</author>

Expand Down Expand Up @@ -35,6 +35,8 @@ namespace detail {
template<class TIterator>
std::size_t for_adapter(TIterator oit, adl_scope& scope,
const AdapterInfo& adapter, const adl_sensor_source source) {
#define _PWROWG_ENABLED(haystack, needle) ((haystack & needle) == needle)

int isActive = 0;
std::size_t retval = 0;
ADLPMLogSupportInfo supportInfo;
Expand All @@ -60,7 +62,7 @@ namespace detail {
}

// Now, check all of the supported sensor sources.
if ((source & adl_sensor_source::asic) == adl_sensor_source::asic) {
if (_PWROWG_ENABLED(source, adl_sensor_source::asic)) {
auto source = adl_sensor_source::asic;
auto ids = detail::adl_sensor_impl::get_sensor_ids(source,
supportInfo);
Expand All @@ -73,7 +75,7 @@ namespace detail {
}
}

if ((source & adl_sensor_source::cpu) == adl_sensor_source::cpu) {
if (_PWROWG_ENABLED(source, adl_sensor_source::cpu)) {
auto source = adl_sensor_source::cpu;
auto ids = detail::adl_sensor_impl::get_sensor_ids(source,
supportInfo);
Expand All @@ -86,8 +88,7 @@ namespace detail {
}
}

if ((source & adl_sensor_source::graphics)
== adl_sensor_source::graphics) {
if (_PWROWG_ENABLED(source, adl_sensor_source::graphics)) {
auto source = adl_sensor_source::graphics;
auto ids = detail::adl_sensor_impl::get_sensor_ids(source,
supportInfo);
Expand All @@ -100,7 +101,7 @@ namespace detail {
}
}

if ((source & adl_sensor_source::soc) == adl_sensor_source::soc) {
if (_PWROWG_ENABLED(source, adl_sensor_source::soc)) {
auto source = adl_sensor_source::soc;
auto ids = detail::adl_sensor_impl::get_sensor_ids(source,
supportInfo);
Expand All @@ -113,7 +114,21 @@ namespace detail {
}
}

if (_PWROWG_ENABLED(source, adl_sensor_source::board)) {
auto source = adl_sensor_source::board;
auto ids = detail::adl_sensor_impl::get_sensor_ids(source,
supportInfo);

if (!ids.empty()) {
auto impl = new detail::adl_sensor_impl(adapter);
impl->configure_source(source, std::move(ids));
*oit++ = adl_sensor(std::move(impl));
++retval;
}
}

return retval;
#undef _PWROWG_ENABLED
}

/// <summary>
Expand Down Expand Up @@ -236,7 +251,7 @@ visus::power_overwhelming::adl_sensor::from_index(_In_ const int index,
throw adl_exception(status);
}

throw "TODO";
throw "TODO: Implement retrieval from index.";

return retval;
}
Expand Down
15 changes: 14 additions & 1 deletion power_overwhelming/src/adl_sensor_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,17 @@ visus::power_overwhelming::detail::adl_sensor_impl::get_sensor_ids(
const adl_sensor_source source) {
switch (source) {
case adl_sensor_source::asic:
return std::vector<ADL_PMLOG_SENSORS> { ADL_PMLOG_ASIC_POWER };
// HAZARD: We assume that only one of these can be set at the
// same time, but we cannot prove this from the docs.
return std::vector<ADL_PMLOG_SENSORS> { ADL_PMLOG_ASIC_POWER,
ADL_PMLOG_SSPAIRED_ASICPOWER };

case adl_sensor_source::cpu:
return std::vector<ADL_PMLOG_SENSORS> { ADL_PMLOG_CPU_POWER };

case adl_sensor_source::board:
return std::vector<ADL_PMLOG_SENSORS> { ADL_PMLOG_BOARD_POWER };

case adl_sensor_source::graphics:
return std::vector<ADL_PMLOG_SENSORS> { ADL_PMLOG_GFX_VOLTAGE,
ADL_PMLOG_GFX_CURRENT, ADL_PMLOG_GFX_POWER };
Expand Down Expand Up @@ -180,9 +186,11 @@ bool visus::power_overwhelming::detail::adl_sensor_impl::is_power(
const ADL_PMLOG_SENSORS id) {
switch (id) {
case ADL_PMLOG_ASIC_POWER:
case ADL_PMLOG_BOARD_POWER:
case ADL_PMLOG_CPU_POWER:
case ADL_PMLOG_GFX_POWER:
case ADL_PMLOG_SOC_POWER:
case ADL_PMLOG_SSPAIRED_ASICPOWER:
return true;

default:
Expand Down Expand Up @@ -285,6 +293,11 @@ void visus::power_overwhelming::detail::adl_sensor_impl::configure_source(
+ L"/" + std::to_wstring(this->adapter_index);
break;

case adl_sensor_source::board:
this->sensor_name = L"ADL/BOARD/" + this->device_name
+ L"/" + std::to_wstring(this->adapter_index);
break;

case adl_sensor_source::cpu:
this->sensor_name = L"ADL/CPU/" + this->device_name
+ L"/" + std::to_wstring(this->adapter_index);
Expand Down
2 changes: 1 addition & 1 deletion third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mark_as_advanced(FORCE

# AMD Display Library (this is a bit hacky ...)
FetchContent_Declare(adl
URL "https://github.com/GPUOpen-LibrariesAndSDKs/display-library/archive/17.0.tar.gz"
URL "https://github.com/GPUOpen-LibrariesAndSDKs/display-library/archive/17.1.tar.gz"
)
FetchContent_MakeAvailable(adl)
add_library(adl INTERFACE IMPORTED GLOBAL)
Expand Down

0 comments on commit 1a722e5

Please sign in to comment.