示例#1
0
        public static (List <NvmlProcessInfo>, uint) NvmlDeviceGetComputeRunningProcesses(IntPtr device)
        {
            NvmlReturn res;
            int        size = Marshal.SizeOf <NvmlProcessInfo>();
            // IntPtr buffer = Marshal.AllocHGlobal(size * 5);
            uint count = 0;

            res = Api.NvmlDeviceGetComputeRunningProcesses(device, out count, null);
            if (count <= 0)
            {
                return(new List <NvmlProcessInfo>(), count);
            }

            NvmlProcessInfo[] buffer = new NvmlProcessInfo[count];
            res = Api.NvmlDeviceGetComputeRunningProcesses(device, out count, buffer);
            if (NvmlReturn.NVML_SUCCESS != res)
            {
                throw new SystemException(res.ToString());
            }

            return(new List <NvmlProcessInfo>(buffer), count);
        }
示例#2
0
 internal static extern NvmlReturn NvmlDeviceGetComputeRunningProcesses(IntPtr device, out uint infoCount, out NvmlProcessInfo infos);