using NvAPIWrapper.Native; using NvAPIWrapper.Native.GPU; namespace NvAPIWrapper.GPU { /// /// Contains information about the ECC memory /// public class ECCMemoryInformation { internal ECCMemoryInformation(PhysicalGPU physicalGPU) { PhysicalGPU = physicalGPU; } /// /// Gets the number of aggregated ECC memory double bit errors /// public ulong AggregatedDoubleBitErrors { get { if (!IsSupported || !IsEnabled) { return 0; } return GPUApi.GetECCErrorInfo(PhysicalGPU.Handle).AggregatedErrors.DoubleBitErrors; } } /// /// Gets the number of aggregated ECC memory single bit errors /// public ulong AggregatedSingleBitErrors { get { if (!IsSupported || !IsEnabled) { return 0; } return GPUApi.GetECCErrorInfo(PhysicalGPU.Handle).AggregatedErrors.SingleBitErrors; } } /// /// Gets the ECC memory configuration in regard to how changes are applied /// public ECCConfiguration Configuration { get { try { return GPUApi.GetECCStatusInfo(PhysicalGPU.Handle).ConfigurationOptions; } catch { return ECCConfiguration.NotSupported; } } } /// /// Gets the number of current ECC memory double bit errors /// public ulong CurrentDoubleBitErrors { get { if (!IsSupported || !IsEnabled) { return 0; } return GPUApi.GetECCErrorInfo(PhysicalGPU.Handle).CurrentErrors.DoubleBitErrors; } } /// /// Gets the number of current ECC memory single bit errors /// public ulong CurrentSingleBitErrors { get { if (!IsSupported || !IsEnabled) { return 0; } return GPUApi.GetECCErrorInfo(PhysicalGPU.Handle).CurrentErrors.SingleBitErrors; } } /// /// Gets a boolean value indicating if ECC memory error correction is enabled /// public bool IsEnabled { get => IsSupported && GPUApi.GetECCStatusInfo(PhysicalGPU.Handle).IsEnabled && GPUApi.GetECCConfigurationInfo(PhysicalGPU.Handle).IsEnabled; } /// /// Gets a boolean value indicating if ECC memory is enabled by default /// public bool IsEnabledByDefault { get => IsSupported && GPUApi.GetECCConfigurationInfo(PhysicalGPU.Handle).IsEnabledByDefault; } /// /// Gets a boolean value indicating if ECC memory is supported and available /// public bool IsSupported { get { try { return GPUApi.GetECCStatusInfo(PhysicalGPU.Handle).IsSupported; } catch { return false; } } } /// /// Gets the physical GPU that this instance describes /// public PhysicalGPU PhysicalGPU { get; } /// public override string ToString() { if (!IsSupported) { return "[Not Supported]"; } if (!IsEnabled) { return "[Disabled]"; } return $"{CurrentSingleBitErrors}, {CurrentDoubleBitErrors} ({AggregatedSingleBitErrors}, {AggregatedDoubleBitErrors})"; } /// /// Clears aggregated error counters. /// public void ClearAggregatedErrors() { GPUApi.ResetECCErrorInfo(PhysicalGPU.Handle, false, true); } /// /// Clears current error counters. /// public void ClearCurrentErrors() { GPUApi.ResetECCErrorInfo(PhysicalGPU.Handle, true, false); } /// /// Clears all error counters. /// public void ClearErrors() { GPUApi.ResetECCErrorInfo(PhysicalGPU.Handle, true, true); } /// /// Disables ECC memory error correction. /// /// A boolean value to indicate if this change should get applied immediately public void Disable(bool immediate) { GPUApi.SetECCConfiguration(PhysicalGPU.Handle, false, immediate); } /// /// Enables ECC memory error correction. /// /// A boolean value to indicate if this change should get applied immediately public void Enable(bool immediate) { GPUApi.SetECCConfiguration(PhysicalGPU.Handle, true, immediate); } } }