Exemplo n.º 1
0
 public GpuViewModel(IGpu data)
 {
     _gpuType             = data.GpuType;
     _index               = data.Index;
     _busId               = data.BusId;
     _name                = data.Name;
     _totalMemory         = data.TotalMemory;
     _temperature         = data.Temperature;
     _fanSpeed            = data.FanSpeed;
     _powerUsage          = data.PowerUsage;
     _coreClockDelta      = data.CoreClockDelta;
     _memoryClockDelta    = data.MemoryClockDelta;
     _coreClockDeltaMin   = data.CoreClockDeltaMin;
     _coreClockDeltaMax   = data.CoreClockDeltaMax;
     _memoryClockDeltaMin = data.MemoryClockDeltaMin;
     _memoryClockDeltaMax = data.MemoryClockDeltaMax;
     _cool                = data.Cool;
     _coolMin             = data.CoolMin;
     _coolMax             = data.CoolMax;
     _powerCapacity       = data.PowerCapacity;
     _powerMin            = data.PowerMin;
     _powerMax            = data.PowerMax;
     _powerDefault        = data.PowerDefault;
     _tempLimit           = data.TempLimit;
     _tempLimitDefault    = data.TempLimitDefault;
     _tempLimitMax        = data.TempLimitMax;
     _tempLimitMin        = data.TempLimitMin;
     _coreVoltage         = data.CoreVoltage;
     _memoryVoltage       = data.MemoryVoltage;
     _voltMin             = data.VoltMin;
     _voltMax             = data.VoltMax;
     _voltDefault         = data.VoltDefault;
 }
Exemplo n.º 2
0
 public static Guid GetKernelBrandId(this ICoin coin, GpuType targetGpuType)
 {
     if (coin == null || string.IsNullOrEmpty(coin.KernelBrand))
     {
         return(Guid.Empty);
     }
     if (NTMinerRoot.IsKernelBrand)
     {
         return(NTMinerRoot.KernelBrandId);
     }
     string[] items = coin.KernelBrand.Split(';');
     foreach (var item in items)
     {
         string[] kv = item.Split(':');
         if (kv.Length == 2)
         {
             if (kv[0].TryParse(out GpuType gpuType) && gpuType == targetGpuType)
             {
                 if (Guid.TryParse(kv[1], out Guid kernelBrandId))
                 {
                     return(kernelBrandId);
                 }
             }
         }
     }
     return(Guid.Empty);
 }
Exemplo n.º 3
0
        public static uint GpuTypeSize(GpuType type)
        {
            uint s = BrowserInterop.vtsGpuTypeSize((uint)type);

            CheckInterop();
            return(s);
        }
Exemplo n.º 4
0
 public GpuNameCountViewModel(IGpuNameCount data)
 {
     _gpuType     = data.GpuType;
     _name        = data.Name;
     _totalMemory = data.TotalMemory;
     _count       = data.Count;
 }
Exemplo n.º 5
0
        public static string Format(GpuType gpuType, string gpuName, ulong totalMemory)
        {
            int totalMemoryGb = ConvertToGb(totalMemory);

            // 通常显卡的名称上会带显存大小,比如1060分3G版和6G版所以NVIDIA命名显卡的时候
            // 已经带上了显存信息,但不能假定带了显存信息所以这里拼接上显存信息。
            return($"{gpuType.GetName()}///{gpuName}///{totalMemoryGb.ToString()}");
        }
Exemplo n.º 6
0
 public static Gpu Create(GpuType gpuType, int index, string busId, string name)
 {
     return(new Gpu {
         GpuType = gpuType,
         Index = index,
         BusId = busId,
         Name = name
                // 因为其余字段全部是数值类型,留空默认值即可
     });
 }
 public OverClockDataViewModel(IOverClockData data) : this(data.GetId())
 {
     _coinId           = data.CoinId;
     _name             = data.Name;
     _gpuType          = data.GpuType;
     _coreClockDelta   = data.CoreClockDelta;
     _memoryClockDelta = data.MemoryClockDelta;
     _powerCapacity    = data.PowerCapacity;
     _tempLimit        = data.TempLimit;
     _cool             = data.Cool;
 }
Exemplo n.º 8
0
        public void Load(IntPtr handle)
        {
            BrowserInterop.vtsGetTextureResolution(handle, out width, out height, out components);
            Util.CheckError();
            type = (GpuType)BrowserInterop.vtsGetTextureType(handle);
            Util.CheckError();
            IntPtr bufPtr;
            uint   bufSize;

            BrowserInterop.vtsGetTextureBuffer(handle, out bufPtr, out bufSize);
            Util.CheckError();
            data = new byte[bufSize];
            Marshal.Copy(bufPtr, data, 0, (int)bufSize);
        }
    private static float ExtractFloat(vts.Mesh m, int byteOffset, GpuType type, bool normalized)
    {
        switch (type)
        {
        case GpuType.Float:
            Debug.Assert(!normalized);
            return(BitConverter.ToSingle(m.vertices, byteOffset));

        case GpuType.UnsignedShort:
            Debug.Assert(normalized);
            return(BitConverter.ToUInt16(m.vertices, byteOffset) / 65535.0f);

        default:
            throw new VtsException(-17, "Unsupported gpu type");
        }
    }
Exemplo n.º 10
0
        public void Generate(ComputersEntitiesDb db, IRandomGenerator random)
        {
            if (db.Gpus.Count() >= this.Count)
            {
                return;
            }

            var possibleMemories = new[] { 1, 2, 3, 4, 8, 12, 24 };
            var gpusToAdd        = new HashSet <Gpu>();

            var gpuTypes = db.GpuTypes.ToList();
            var vendors  = db.Vendors.ToList();

            while (gpusToAdd.Count < this.Count)
            {
                var     randomNumber = random.GetRandomNumber(0, 100);
                GpuType gpuType      = null;

                if (randomNumber < 33)
                {
                    gpuType = gpuTypes[0];
                }
                else
                {
                    gpuType = gpuTypes[1];
                }
                var nameLength   = random.GetRandomNumber(3, 50);
                var randomString = random.GetRandomString(nameLength);

                var gpu = new Gpu()
                {
                    Vendor  = vendors[random.GetRandomNumber(0, vendors.Count - 1)],
                    Model   = randomString,
                    GpuType = gpuType,
                    Memory  = possibleMemories[random.GetRandomNumber(0, possibleMemories.Length - 1)],
                };

                gpusToAdd.Add(gpu);
            }

            foreach (var gpu in gpusToAdd)
            {
                db.Gpus.AddOrUpdate(gpu);
            }

            db.SaveChanges();
        }
Exemplo n.º 11
0
        public static bool IsSupportedGpu(this SupportedGpu supportedGpu, GpuType gpuType)
        {
            switch (supportedGpu)
            {
            case SupportedGpu.NVIDIA:
                return(gpuType == GpuType.NVIDIA || gpuType == GpuType.Empty);

            case SupportedGpu.AMD:
                return(gpuType == GpuType.AMD || gpuType == GpuType.Empty);

            case SupportedGpu.Both:
                return(true);

            default:
                return(false);
            }
        }
Exemplo n.º 12
0
 public GpuViewModel(IGpuStaticData data, IGpuStaticData[] gpuDatas)
 {
     if (data == null)
     {
         throw new ArgumentNullException(nameof(data));
     }
     if (gpuDatas == null)
     {
         throw new ArgumentNullException(nameof(gpuDatas));
     }
     _isGpuData                = true;
     _gpuDatas                 = gpuDatas.Where(a => a.Index != NTMinerContext.GpuAllId).ToArray();
     _gpuType                  = data.GpuType;
     _index                    = data.Index;
     _busId                    = data.BusId;
     _name                     = data.Name;
     _totalMemory              = data.TotalMemory;
     _temperature              = 0;
     _memoryTemperature        = 0;
     _fanSpeed                 = 0;
     _powerUsage               = 0;
     _coreClockDelta           = 0;
     _memoryClockDelta         = 0;
     _coreClockDeltaMin        = data.CoreClockDeltaMin;
     _coreClockDeltaMax        = data.CoreClockDeltaMax;
     _memoryClockDeltaMin      = data.MemoryClockDeltaMin;
     _memoryClockDeltaMax      = data.MemoryClockDeltaMax;
     _cool                     = 0;
     _coolMin                  = data.CoolMin;
     _coolMax                  = data.CoolMax;
     _powerCapacity            = 0;
     _powerMin                 = data.PowerMin;
     _powerMax                 = data.PowerMax;
     _powerDefault             = data.PowerDefault;
     _tempLimitMin             = data.TempLimitMin;
     _tempLimitMax             = data.TempLimitMax;
     _tempLimitDefault         = data.TempLimitDefault;
     _coreVoltage              = 0;
     _memoryVoltage            = 0;
     _voltMin                  = data.VoltMin;
     _voltMax                  = data.VoltMax;
     _voltDefault              = data.VoltDefault;
     _memoryTimingLevels       = data.MemoryTimingLevels;
     _currentMemoryTimingLevel = -1;
 }
Exemplo n.º 13
0
        public void Load(IntPtr handle)
        {
            BrowserInterop.vtsTextureGetResolution(handle, ref width, ref height, ref components);
            Util.CheckInterop();
            type = (GpuType)BrowserInterop.vtsTextureGetType(handle);
            Util.CheckInterop();
            filterMode = (FilterMode)BrowserInterop.vtsTextureGetFilterMode(handle);
            Util.CheckInterop();
            wrapMode = (WrapMode)BrowserInterop.vtsTextureGetWrapMode(handle);
            Util.CheckInterop();
            IntPtr bufPtr  = IntPtr.Zero;
            uint   bufSize = 0;

            BrowserInterop.vtsTextureGetBuffer(handle, ref bufPtr, ref bufSize);
            Util.CheckInterop();
            data = new byte[bufSize];
            Marshal.Copy(bufPtr, data, 0, (int)bufSize);
        }
Exemplo n.º 14
0
        public void AddCount(GpuType gpuType, string gpuName, ulong gpuTotalMemory)
        {
            if (gpuType == GpuType.Empty || string.IsNullOrEmpty(gpuName) || !GpuName.IsValidTotalMemory(gpuTotalMemory))
            {
                return;
            }
            GpuName key = new GpuName {
                TotalMemory = gpuTotalMemory,
                Name        = gpuName,
                GpuType     = gpuType
            };

            if (_gpuNameCountDic.TryGetValue(key, out int count))
            {
                _gpuNameCountDic[key] = count + 1;
            }
            else
            {
                _gpuNameCountDic.Add(key, 1);
            }
        }
Exemplo n.º 15
0
 public GpuNameViewModel(IGpuName data)
 {
     _gpuType     = data.GpuType;
     _name        = data.Name;
     _totalMemory = data.TotalMemory;
     this.Save    = new DelegateCommand(() => {
         if (this.GpuType == GpuType.Empty)
         {
             VirtualRoot.Out.ShowError("未指定显卡类型");
             return;
         }
         if (string.IsNullOrEmpty(this.Name))
         {
             VirtualRoot.Out.ShowError("名称是必须的");
             return;
         }
         if (this.TotalMemoryGb <= 0)
         {
             VirtualRoot.Out.ShowError("显存不正确");
             return;
         }
         RpcRoot.OfficialServer.GpuNameService.SetGpuNameAsync(new GpuName {
             GpuType     = this.GpuType,
             Name        = this.Name,
             TotalMemory = this.TotalMemory
         }, (response, e) => {
             if (response.IsSuccess())
             {
                 VirtualRoot.RaiseEvent(new GpuNameAddedEvent());
                 VirtualRoot.Execute(new CloseWindowCommand(this.Id));
             }
             else
             {
                 VirtualRoot.Out.ShowError(response.ReadMessage(e), autoHideSeconds: 4);
             }
         });
     });
 }
Exemplo n.º 16
0
 public static bool IsNvidia(this GpuType gpuType)
 {
     return(gpuType == GpuType.NVIDIA);
 }
Exemplo n.º 17
0
 public static bool IsEmpty(this GpuType gpuType)
 {
     return(gpuType == GpuType.Empty);
 }
Exemplo n.º 18
0
 public static bool IsValid(GpuType gpuType, string name, ulong totalMemory)
 {
     return(gpuType != GpuType.Empty && !string.IsNullOrEmpty(name) && IsValidTotalMemory(totalMemory));
 }
Exemplo n.º 19
0
        public void SetData(GpuProfilesJsonDb data)
        {
            _data = data;
            if (data != null)
            {
                string  iconName;
                GpuType gpuType = _minerClientVm.GpuType;
                if (gpuType == GpuType.Empty)
                {
                    gpuType = data.GpuType;
                }
                IsEnabled = data.Gpus != null && data.Gpus.Length != 0;
                RedText   = "超频有风险,操作需谨慎";
                switch (_minerClientVm.GpuType)
                {
                case GpuType.NVIDIA:
                    iconName    = "Icon_Nvidia";
                    GpuIconFill = "Red";
                    break;

                case GpuType.AMD:
                    iconName    = "Icon_Amd";
                    GpuIconFill = "Green";
                    break;

                case GpuType.Empty:
                default:
                    iconName    = "Icon_GpuEmpty";
                    GpuIconFill = "Gray";
                    break;
                }
                GpuIcon = AppUtil.GetResource <Geometry>(iconName);
                foreach (var coinVm in AppRoot.CoinVms.MainCoins)
                {
                    var coinOverClock = data.CoinOverClocks.FirstOrDefault(a => a.CoinId == coinVm.Id);
                    var gpuProfiles   = data.GpuProfiles.Where(a => a.CoinId == coinVm.Id).ToArray();
                    if (coinOverClock == null)
                    {
                        coinOverClock = new CoinOverClockData()
                        {
                            CoinId             = coinVm.Id,
                            IsOverClockEnabled = false,
                            IsOverClockGpuAll  = true
                        };
                    }
                    coinVm.IsOverClockEnabled = coinOverClock.IsOverClockEnabled;
                    coinVm.IsOverClockGpuAll  = coinOverClock.IsOverClockGpuAll;
                    List <GpuProfileViewModel> gpuProfileVms   = new List <GpuProfileViewModel>();
                    GpuProfileViewModel        gpuAllProfileVm = null;
                    #region
                    foreach (var gpu in data.Gpus.OrderBy(a => a.Index))
                    {
                        var gpuProfile = gpuProfiles.FirstOrDefault(a => a.Index == gpu.Index);
                        if (gpuProfile == null)
                        {
                            gpuProfile = new GpuProfileData(coinVm.Id, gpu.Index);
                        }
                        var gpuVm = new GpuViewModel(gpu, data.Gpus);
                        if (gpu.Index == NTMinerContext.GpuAllId)
                        {
                            gpuAllProfileVm = new GpuProfileViewModel(gpuProfile, gpuVm);
                        }
                        else
                        {
                            gpuProfileVms.Add(new GpuProfileViewModel(gpuProfile, gpuVm));
                        }
                    }
                    if (gpuAllProfileVm == null)
                    {
                        gpuAllProfileVm = new GpuProfileViewModel(
                            new GpuProfileData(coinVm.Id, NTMinerContext.GpuAllId), new GpuViewModel(new GpuData {
                            GpuType = gpuType,
                            Index   = NTMinerContext.GpuAllId,
                            Name    = "All"
                        }, data.Gpus));
                    }
                    #endregion
                    coinVm.GpuAllProfileVm = gpuAllProfileVm;
                    coinVm.GpuProfileVms   = gpuProfileVms;
                }
            }
        }
Exemplo n.º 20
0
 public static bool IsAmd(this GpuType gpuType)
 {
     return(gpuType == GpuType.AMD);
 }