예제 #1
0
        public static string GetVBiosVersion(IntPtr deviceHandle)
        {
            var stringBuffer = new StringBuilder(NVMLFunctions.VBiosVersionBufferSize);

            ThrowIfReturnIsError(NVMLFunctions.GetVBiosVersion(deviceHandle, stringBuffer, stringBuffer.Capacity));
            return(stringBuffer.ToString());
        }
예제 #2
0
        public static int GetDeviceCount()
        {
            var deviceCount = 0;

            ThrowIfReturnIsError(NVMLFunctions.GetDeviceCount(ref deviceCount));
            return(deviceCount);
        }
예제 #3
0
        private static void ThrowIfReturnIsError(NVMLReturnCodes returnCode)
        {
            if (returnCode == NVMLReturnCodes.Success)
            {
                return;
            }

            // https://stackoverflow.com/a/370093/528131
            var errorMessagePtr = NVMLFunctions.GetErrorString(returnCode);
            var errorMessage    = Marshal.PtrToStringAuto(errorMessagePtr);

            throw new Exception(string.Format("NVML Failure: {0} - {1}", returnCode, errorMessage));
        }
예제 #4
0
 public static uint GetTemperature(IntPtr deviceHandle)
 {
     ThrowIfReturnIsError(NVMLFunctions.GetTemperature(deviceHandle, TemperatureSensors.GPUSensor, out var temperature));
     return(temperature);
 }
예제 #5
0
 public static (ulong Free, ulong Total, ulong Used) GetMemoryInfo(IntPtr deviceHandle)
 {
     ThrowIfReturnIsError(NVMLFunctions.GetMemoryInfo(deviceHandle, out var memoryInfo));
     return(memoryInfo.Free, memoryInfo.Total, memoryInfo.Used);
 }
예제 #6
0
 public static Architectures GetArchitecture(IntPtr deviceHandle)
 {
     ThrowIfReturnIsError(NVMLFunctions.GetArchitecture(deviceHandle, out var architecture));
     return(architecture);
 }
예제 #7
0
 public static IntPtr GetDeviceHandleByIndex(int deviceIndex)
 {
     ThrowIfReturnIsError(NVMLFunctions.GetDeviceHandleByIndex(deviceIndex, out var deviceHandle));
     return(deviceHandle);
 }
예제 #8
0
 static NVML()
 {
     ThrowIfReturnIsError(NVMLFunctions.Initialize());
 }