public AMDGpuSet(INTMinerRoot root) : this() { #if DEBUG VirtualRoot.Stopwatch.Restart(); #endif _root = root; adlHelper.Init(); this.OverClock = new AMDOverClock(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.GetTotalMemoryByIndex(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; if (_gpus.Any(a => a.Key != NTMinerRoot.GpuAllId && a.Value.TotalMemory < minG)) { 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(() => { OverClock.RefreshGpuState(NTMinerRoot.GpuAllId); foreach (var kv in kvs) { Environment.SetEnvironmentVariable(kv.Key, kv.Value); } }); } } #if DEBUG Write.DevWarn($"耗时{VirtualRoot.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor"); #endif }