Example #1
0
        public AMDGpuSet(INTMinerRoot root)
        {
            _root           = root;
            this.Properties = new List <GpuSetProperty>();
            if (NTMinerRoot.IsInDesignMode)
            {
                return;
            }
            adlHelper.Init();
            int deviceCount = 0;

            deviceCount = adlHelper.GpuCount;
            for (int i = 0; i < deviceCount; i++)
            {
                _gpus.Add(i, new Gpu {
                    Index = i,
                    Name  = adlHelper.GetGpuName(i)
                });
            }
            string driverVersion = adlHelper.GetDriverVersion();

            this.Properties.Add(new GpuSetProperty("DriverVersion", "驱动版本", driverVersion));
            Global.Access <Per5SecondEvent>(Guid.Parse("7C379223-D494-4213-9659-A086FFDE36DF"), "周期刷新显卡状态", LogEnum.None, action: message => {
                LoadGpuState();
            });
        }
Example #2
0
        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
        }
Example #3
0
        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
        }
Example #4
0
        public AMDGpuSet()
        {
#if DEBUG
            NTStopwatch.Start();
#endif
            adlHelper.Init();
            this.Properties = new List <GpuSetProperty>();
            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
            var elapsedMilliseconds = NTStopwatch.Stop();
            if (elapsedMilliseconds.ElapsedMilliseconds > NTStopwatch.ElapsedMilliseconds)
            {
                Write.DevTimeSpan($"耗时{elapsedMilliseconds} {this.GetType().Name}.ctor");
            }
#endif
        }