public AMDGpuSet() { #if DEBUG NTStopwatch.Start(); #endif this.Properties = new List<GpuSetProperty>(); this.OverClock = new GpuOverClock(adlHelper); VirtualRoot.AddEventPath<AppExitEvent>("程序退出时调用adlHelper.Close", LogEnum.None, message => { adlHelper.Close(); }, this.GetType()); int deviceCount = 0; deviceCount = adlHelper.GpuCount; for (int i = 0; i < deviceCount; i++) { var atiGpu = adlHelper.GetAtiGPU(i); string name = atiGpu.AdapterName; // short gpu name if (!string.IsNullOrEmpty(name)) { name = name.Replace("Radeon (TM) RX ", string.Empty); name = name.Replace("Radeon RX ", string.Empty); } var gpu = Gpu.Create(GpuType.AMD, i, atiGpu.BusNumber.ToString(), name); gpu.TotalMemory = adlHelper.GetTotalMemory(i); _gpus.Add(i, gpu); } if (deviceCount > 0) { this._driverVersion = adlHelper.GetDriverVersion(); this.Properties.Add(new GpuSetProperty(GpuSetProperty.DRIVER_VERSION, "驱动版本", DriverVersion)); const ulong minG = 5 * NTKeyword.ULongG; bool has470 = _gpus.Any(a => a.Key != NTMinerContext.GpuAllId && a.Value.TotalMemory < minG); if (has470) { Dictionary<string, string> kvs = new Dictionary<string, string> { ["GPU_MAX_ALLOC_PERCENT"] = "100", ["GPU_MAX_HEAP_SIZE"] = "100", ["GPU_SINGLE_ALLOC_PERCENT"] = "100" }; foreach (var kv in kvs) { var property = new GpuSetProperty(kv.Key, kv.Key, kv.Value); this.Properties.Add(property); } Task.Factory.StartNew(() => { OverClock.RefreshGpuState(NTMinerContext.GpuAllId); foreach (var kv in kvs) { Environment.SetEnvironmentVariable(kv.Key, kv.Value); } }); } else { Task.Factory.StartNew(() => { OverClock.RefreshGpuState(NTMinerContext.GpuAllId); }); } } #if DEBUG var elapsedMilliseconds = NTStopwatch.Stop(); if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds) { NTMinerConsole.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor"); } #endif }
public AMDGpuSet(INTMinerRoot root) : this() { #if DEBUG VirtualRoot.Stopwatch.Restart(); #endif _root = root; if (Design.IsInDesignMode) { return; } adlHelper.Init(); int deviceCount = 0; deviceCount = adlHelper.GpuCount; for (int i = 0; i < deviceCount; i++) { string name = adlHelper.GetGpuName(i); // short gpu name if (!string.IsNullOrEmpty(name)) { name = name.Replace("Radeon (TM) RX ", string.Empty); name = name.Replace("Radeon RX ", string.Empty); } var gpu = Gpu.Create(i, name); gpu.TotalMemory = adlHelper.GetTotalMemory(i); _gpus.Add(i, gpu); } if (deviceCount > 0) { this.Properties.Add(new GpuSetProperty(GpuSetProperty.DRIVER_VERSION, "驱动版本", DriverVersion)); Dictionary <string, string> kvs = new Dictionary <string, string> { { "GPU_FORCE_64BIT_PTR", "0" }, { "GPU_MAX_ALLOC_PERCENT", "100" }, { "GPU_MAX_HEAP_SIZE", "100" }, { "GPU_SINGLE_ALLOC_PERCENT", "100" }, { "GPU_USE_SYNC_OBJECTS", "1" } }; foreach (var kv in kvs) { var property = new GpuSetProperty(kv.Key, kv.Key, kv.Value); this.Properties.Add(property); } Task.Factory.StartNew(() => { foreach (var kv in kvs) { Environment.SetEnvironmentVariable(kv.Key, kv.Value); } }); } #if DEBUG Write.DevWarn($"耗时{VirtualRoot.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor"); #endif }
public AMDGpuSet(INTMinerRoot root) : this() { #if DEBUG Write.Stopwatch.Restart(); #endif _root = root; adlHelper.Init(); this.OverClock = new GpuOverClock(adlHelper); int deviceCount = 0; deviceCount = adlHelper.GpuCount; for (int i = 0; i < deviceCount; i++) { var atiGpu = adlHelper.GetGpuName(i); string name = atiGpu.AdapterName; // short gpu name if (!string.IsNullOrEmpty(name)) { name = name.Replace("Radeon (TM) RX ", string.Empty); name = name.Replace("Radeon RX ", string.Empty); } var gpu = Gpu.Create(i, atiGpu.BusNumber.ToString(), name); gpu.TotalMemory = adlHelper.GetTotalMemory(i); _gpus.Add(i, gpu); } if (deviceCount > 0) { this.DriverVersion = adlHelper.GetDriverVersion(); this.Properties.Add(new GpuSetProperty(GpuSetProperty.DRIVER_VERSION, "驱动版本", DriverVersion)); const ulong minG = (ulong)5 * 1024 * 1024 * 1024; bool has470 = _gpus.Any(a => a.Key != NTMinerRoot.GpuAllId && a.Value.TotalMemory < minG); if (has470) { Dictionary <string, string> kvs = new Dictionary <string, string> { { "GPU_MAX_ALLOC_PERCENT", "100" }, { "GPU_MAX_HEAP_SIZE", "100" }, { "GPU_SINGLE_ALLOC_PERCENT", "100" } }; foreach (var kv in kvs) { var property = new GpuSetProperty(kv.Key, kv.Key, kv.Value); this.Properties.Add(property); } Task.Factory.StartNew(() => { OverClock.RefreshGpuState(NTMinerRoot.GpuAllId); foreach (var kv in kvs) { Environment.SetEnvironmentVariable(kv.Key, kv.Value); } }); } else { Task.Factory.StartNew(() => { OverClock.RefreshGpuState(NTMinerRoot.GpuAllId); }); } } #if DEBUG Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor"); #endif }
public static void getOverclockGPU(ref UIDataGridView GPUOverClockTable) { int GPUCount = 0; try { szzminer_overclock.AMD.NvmlHelper nvmlHelper = new szzminer_overclock.AMD.NvmlHelper(); szzminer_overclock.AMD.NvapiHelper nvapiHelper = new szzminer_overclock.AMD.NvapiHelper(); List <szzminer_overclock.AMD.NvmlHelper.NvGpu> gpus = nvmlHelper.GetGpus(); for (int i = 0; i < gpus.Count; i++) { szzminer_overclock.AMD.OverClockRange overClockRange = nvapiHelper.GetClockRange(gpus[i].BusId); GPUOverClockTable.Rows[GPUCount].Cells[0].Value = gpus[i].BusId; GPUOverClockTable.Rows[GPUCount].Cells[1].Value = "NVIDIA " + gpus[i].Name + " " + gpus[i].TotalMemory / 1024 / 1000 / 1000 + "GB"; GPUOverClockTable.Rows[GPUCount].Cells[5].Value = "N/A"; GPUOverClockTable.Rows[GPUCount].Cells[7].Value = "N/A"; GPUCount++; } } catch { //WriteLog("没有发现N卡"); } try { AdlHelper adl = new AdlHelper(); const ulong a = 1024 * 1024 * 1024; for (int i = 0; i < adl.ATIGpus.Count; i++) { //uint power, fan; //int coreClock, memoryClock; //adl.GetPowerFanTemp(adl.ATIGpus[i].BusNumber, out power, out fan, out _,out _); //adl.GetClockRange(adl.ATIGpus[i].BusNumber, out coreClock, out memoryClock); GPUOverClockTable.Rows[GPUCount].Cells[0].Value = adl.ATIGpus[i].BusNumber; GPUOverClockTable.Rows[GPUCount].Cells[1].Value = adl.ATIGpus[i].AdapterName + " " + ((adl.GetTotalMemory(adl.ATIGpus[i].AdapterIndex) + a - 1) / a).ToString() + "GB";; GPUOverClockTable.Rows[GPUCount].Cells[2].Value = adl.ATIGpus[i].PowerDefault.ToString(); GPUOverClockTable.Rows[GPUCount].Cells[3].Value = adl.ATIGpus[i].TempLimitDefault.ToString(); GPUOverClockTable.Rows[GPUCount].Cells[4].Value = (adl.ATIGpus[i].coreClockSelf).ToString(); GPUOverClockTable.Rows[GPUCount].Cells[5].Value = adl.ATIGpus[i].CoreVolt; GPUOverClockTable.Rows[GPUCount].Cells[6].Value = (adl.ATIGpus[i].memoryClockSelf / 1000).ToString(); GPUOverClockTable.Rows[GPUCount].Cells[7].Value = adl.ATIGpus[i].MemoryVolt; GPUCount++; } } catch { } }
public static void getGPU(ref UIDataGridView GPUStatusTable, ref int totalPower) { int GPUCount = 0; try { szzminer_overclock.AMD.NvmlHelper nvmlHelper = new szzminer_overclock.AMD.NvmlHelper(); szzminer_overclock.AMD.NvapiHelper nvapiHelper = new szzminer_overclock.AMD.NvapiHelper(); List <szzminer_overclock.AMD.NvmlHelper.NvGpu> gpus = nvmlHelper.GetGpus(); uint coretemp = 0; uint memtemp = 0; for (int i = 0; i < gpus.Count; i++) { szzminer_overclock.AMD.OverClockRange overClockRange = nvapiHelper.GetClockRange(gpus[i].BusId); GPUStatusTable.Rows[GPUCount].Cells[0].Value = gpus[i].BusId; GPUStatusTable.Rows[GPUCount].Cells[1].Value = "NVIDIA " + gpus[i].Name + " " + gpus[i].TotalMemory / 1024 / 1000 / 1000 + "GB"; GPUStatusTable.Rows[GPUCount].Cells[5].Value = nvmlHelper.GetPowerUsage(i); nvapiHelper.GetCoreTemperature(gpus[i].BusId, out coretemp); nvapiHelper.GetMemTemperature(gpus[i].BusId, out memtemp); GPUStatusTable.Rows[GPUCount].Cells[6].Value = coretemp.ToString() + "/" + memtemp.ToString(); GPUStatusTable.Rows[GPUCount].Cells[7].Value = nvmlHelper.GetFanSpeed(i); GPUStatusTable.Rows[GPUCount].Cells[8].Value = nvmlHelper.GetCoreClock(i) + "Mhz"; GPUStatusTable.Rows[GPUCount].Cells[9].Value = nvmlHelper.GetMemoryClock(i) + "Mhz"; totalPower += Convert.ToInt32(GPUStatusTable.Rows[GPUCount].Cells[5].Value); GPUCount++; } } catch { //WriteLog("没有发现N卡"); } try { AdlHelper adl = new AdlHelper(); const ulong a = 1024 * 1024 * 1024; uint power = 0, fan = 0; int temp = 0; int memtemp = 0; int coreClock = 0, memoryClock = 0; for (int i = 0; i < adl.ATIGpus.Count; i++) { adl.GetPowerFanTemp(adl.ATIGpus[i].BusNumber, out power, out fan, out temp, out memtemp); adl.GetClockRange(adl.ATIGpus[i].BusNumber, out coreClock, out memoryClock); GPUStatusTable.Rows[GPUCount].Cells[0].Value = adl.ATIGpus[i].BusNumber; GPUStatusTable.Rows[GPUCount].Cells[1].Value = adl.ATIGpus[i].AdapterName + " " + ((adl.GetTotalMemory(adl.ATIGpus[i].AdapterIndex) + a - 1) / a).ToString() + "GB";; GPUStatusTable.Rows[GPUCount].Cells[5].Value = power; GPUStatusTable.Rows[GPUCount].Cells[6].Value = temp; GPUStatusTable.Rows[GPUCount].Cells[7].Value = fan; GPUStatusTable.Rows[GPUCount].Cells[8].Value = coreClock / 1000 + "Mhz"; GPUStatusTable.Rows[GPUCount].Cells[9].Value = memoryClock / 1000 + "Mhz"; totalPower += Convert.ToInt32(GPUStatusTable.Rows[GPUCount].Cells[5].Value); GPUCount++; } } catch { } }