Skip to content

Commit 5ade52e

Browse files
authored
Fix/nvml struct (#637)
* fix nvml structure definition * explicit inclusion of headers
1 parent a848d9a commit 5ade52e

5 files changed

Lines changed: 14 additions & 9 deletions

File tree

IntelPresentMon/CommonUtilities/ref/GeneratedReflectionHelpers.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#pragma once
2-
#include <string>
32
#include <concepts>
3+
#include <cstddef>
4+
#include <cstdint>
5+
#include <format>
6+
#include <sstream>
7+
#include <string>
8+
#include <type_traits>
49
#include "GeneratedReflection.h"
510

611
namespace pmon::util::ref::gen

IntelPresentMon/CommonUtilities/ref/gen/GeneratedReflection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ namespace pmon::util::ref::gen
326326
const auto& s = *static_cast<const nvmlMemory_t*>(pStruct);
327327
std::ostringstream oss;
328328
oss << std::boolalpha << "struct nvmlMemory_t {"
329-
<< " .free = " << s.free
330329
<< " .total = " << s.total
330+
<< " .free = " << s.free
331331
<< " .used = " << s.used
332332
<< " }";
333333
return oss.str();

IntelPresentMon/ControlLib/nvml/NvmlTelemetryProvider.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ namespace pmon::tel::nvml
122122
if (pMemoryInfo == nullptr) {
123123
return (uint64_t)0;
124124
}
125-
return GetLegacyTotalMemoryBytes_(*pMemoryInfo);
125+
return GetTotalMemoryBytes_(*pMemoryInfo);
126126
}
127127
case PM_METRIC_GPU_MEM_USED:
128128
{
@@ -141,7 +141,7 @@ namespace pmon::tel::nvml
141141
return 0.0;
142142
}
143143

144-
const auto totalBytes = GetLegacyTotalMemoryBytes_(*pMemoryInfo);
144+
const auto totalBytes = GetTotalMemoryBytes_(*pMemoryInfo);
145145
if (totalBytes == 0) {
146146
return 0.0;
147147
}
@@ -160,9 +160,9 @@ namespace pmon::tel::nvml
160160
(void)metricId;
161161
}
162162

163-
uint64_t NvmlTelemetryProvider::GetLegacyTotalMemoryBytes_(const nvmlMemory_t& memoryInfo) noexcept
163+
uint64_t NvmlTelemetryProvider::GetTotalMemoryBytes_(const nvmlMemory_t& memoryInfo) noexcept
164164
{
165-
return (uint64_t)memoryInfo.free;
165+
return (uint64_t)memoryInfo.total;
166166
}
167167

168168
bool NvmlTelemetryProvider::TryInitializeDevice_(DeviceState_& device, nvmlDevice_t handle) const
@@ -232,7 +232,7 @@ namespace pmon::tel::nvml
232232
}
233233

234234
if (const auto* pMemoryInfo = PollMemoryInfoEndpoint_(device, requestQpc)) {
235-
const auto totalBytes = GetLegacyTotalMemoryBytes_(*pMemoryInfo);
235+
const auto totalBytes = GetTotalMemoryBytes_(*pMemoryInfo);
236236
if (totalBytes != 0) {
237237
caps.Set(PM_METRIC_GPU_MEM_SIZE, 1);
238238
caps.Set(PM_METRIC_GPU_MEM_USED, 1);

IntelPresentMon/ControlLib/nvml/NvmlTelemetryProvider.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace pmon::tel::nvml
3939
};
4040

4141
static void ValidateScalarMetricIndex_(PM_METRIC metricId, uint32_t arrayIndex);
42-
static uint64_t GetLegacyTotalMemoryBytes_(const nvmlMemory_t& memoryInfo) noexcept;
42+
static uint64_t GetTotalMemoryBytes_(const nvmlMemory_t& memoryInfo) noexcept;
4343

4444
bool TryInitializeDevice_(DeviceState_& device, nvmlDevice_t handle) const;
4545
ipc::MetricCapabilities BuildCapsForDevice_(DeviceState_& device) const;

IntelPresentMon/ControlLib/nvml/nvml.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ struct nvmlPciInfo_t {
111111
};
112112

113113
struct nvmlMemory_t {
114-
unsigned long long free;
115114
unsigned long long total;
115+
unsigned long long free;
116116
unsigned long long used;
117117
};
118118

0 commit comments

Comments
 (0)