Пример #1
0
        static NVML()
        {
            // Indicate to search libraries in
            // - application directory
            // - paths set using AddDllDirectory or SetDllDirectory
            // - %windows%\system32
            SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);

            // Add the directory of the native dll
            AddDllDirectory(@"C:\Program Files\NVIDIA Corporation\NVSMI");

            nvmlInit =
                CreateDelegate <nvmlInitDelegate>(
                    "nvmlInit");
            nvmlInit_v2 =
                CreateDelegate <nvmlInit_v2Delegate>(
                    "nvmlInit_v2");
            NvmlShutdown =
                CreateDelegate <nvmlShutdownDelegate>(
                    "nvmlShutdown");
            NvmlDeviceGetHandleByPciBusId =
                CreateDelegate <nvmlDeviceGetHandleByPciBusIdDelegate>(
                    "nvmlDeviceGetHandleByPciBusId_v2");
            NvmlDeviceGetPowerUsage =
                CreateDelegate <nvmlDeviceGetPowerUsageDelegate>(
                    "nvmlDeviceGetPowerUsage");
            NvmlDeviceGetPcieThroughput =
                CreateDelegate <nvmlDeviceGetPcieThroughputDelegate>(
                    "nvmlDeviceGetPcieThroughput");
        }
Пример #2
0
 static NVML()
 {
     nvmlInit =
         CreateDelegate <nvmlInitDelegate>(
             "nvmlInit");
     nvmlInit_v2 =
         CreateDelegate <nvmlInit_v2Delegate>(
             "nvmlInit_v2");
     NvmlShutdown =
         CreateDelegate <nvmlShutdownDelegate>(
             "nvmlShutdown");
     NvmlDeviceGetHandleByPciBusId =
         CreateDelegate <nvmlDeviceGetHandleByPciBusIdDelegate>(
             "nvmlDeviceGetHandleByPciBusId_v2");
     NvmlDeviceGetPowerUsage =
         CreateDelegate <nvmlDeviceGetPowerUsageDelegate>(
             "nvmlDeviceGetPowerUsage");
     NvmlDeviceGetPcieThroughput =
         CreateDelegate <nvmlDeviceGetPcieThroughputDelegate>(
             "nvmlDeviceGetPcieThroughput");
 }
Пример #3
0
        private NVMLService()
        {
            nvmlInit     = CreateDelegate <nvmlInitDelegate>("nvmlInit");
            nvmlInit_v2  = CreateDelegate <nvmlInit_v2Delegate>("nvmlInit_v2");
            NvmlShutdown = CreateDelegate <nvmlShutdownDelegate>("nvmlShutdown");
            NvmlDeviceGetHandleByPciBusId = CreateDelegate <nvmlDeviceGetHandleByPciBusIdDelegate>("nvmlDeviceGetHandleByPciBusId_v2");
            NvmlDeviceGetHandleByIndex    = CreateDelegate <nvmlDeviceGetHandleByIndexDelegate>("nvmlDeviceGetHandleByIndex_v2");
            NvmlDeviceGetPowerUsage       = CreateDelegate <nvmlDeviceGetPowerUsageDelegate>("nvmlDeviceGetPowerUsage");

            Initialized =
                nvmlInit_v2() == 0 ? true :
                nvmlInit() == 0 ? true : false;

            if (Initialized && NvmlDeviceGetHandleByPciBusId != null)
            {
                for (int deviceIndex = 0; NvmlDeviceGetHandleByPciBusId(NVAPIService.Instance.GetPciBusId(deviceIndex), out NvmlDevice device) == 0; ++deviceIndex)
                {
                    nvmlDevices.Add(device);
                }
            }
        }