Add shared memory free/total for Intel iGPU (#1328)

This commit is contained in:
Emerson Pinter
2024-05-03 10:23:21 +02:00
committed by GitHub
parent 92bfa55f12
commit 418888502a
@@ -11,6 +11,8 @@ internal class IntelIntegratedGpu : GenericGpu
private const uint MSR_RAPL_POWER_UNIT = 0x606;
private readonly Sensor _dedicatedMemoryUsage;
private readonly Sensor _sharedMemoryLimit;
private readonly Sensor _sharedMemoryFree;
private readonly string _deviceId;
private readonly float _energyUnitMultiplier;
private readonly Sensor[] _nodeUsage;
@@ -38,6 +40,12 @@ internal class IntelIntegratedGpu : GenericGpu
_sharedMemoryUsage = new Sensor("D3D Shared Memory Used", memorySensorIndex++, SensorType.SmallData, this, settings);
if (deviceInfo.GpuSharedLimit > 0)
{
_sharedMemoryFree = new Sensor("D3D Shared Memory Free", memorySensorIndex++, SensorType.SmallData, this, settings);
_sharedMemoryLimit = new Sensor("D3D Shared Memory Total", memorySensorIndex++, SensorType.SmallData, this, settings);
}
if (Ring0.ReadMsr(MSR_RAPL_POWER_UNIT, out uint eax, out uint _))
{
_energyUnitMultiplier = intelCpu.EnergyUnitsMultiplier;
@@ -78,6 +86,17 @@ internal class IntelIntegratedGpu : GenericGpu
ActivateSensor(_dedicatedMemoryUsage);
}
if (_sharedMemoryLimit != null)
{
_sharedMemoryLimit.Value = 1f * deviceInfo.GpuSharedLimit / 1024 / 1024;
ActivateSensor(_sharedMemoryLimit);
if (_sharedMemoryUsage != null)
{
_sharedMemoryFree.Value = _sharedMemoryLimit.Value - _sharedMemoryUsage.Value;
ActivateSensor(_sharedMemoryFree);
}
}
_sharedMemoryUsage.Value = 1f * deviceInfo.GpuSharedUsed / 1024 / 1024;
ActivateSensor(_sharedMemoryUsage);