// CPU
 public ComputeDevice(int id, string group, string name, int threads, ulong affinityMask, int CPUCount)
 {
     ID                = id;
     Name              = name;
     Threads           = threads;
     AffinityMask      = affinityMask;
     Enabled           = true;
     DeviceGroupType   = DeviceGroupType.CPU;
     DeviceType        = DeviceType.CPU;
     NameCount         = String.Format(International.GetText("ComputeDevice_Short_Name_CPU"), CPUCount);
     UUID              = GetUUID(ID, GroupNames.GetGroupName(DeviceGroupType, ID), Name, DeviceGroupType);
     AlgorithmSettings = GroupAlgorithms.CreateForDeviceList(this);
     IsEtherumCapale   = false;
     GpuRam            = 0;
 }
Exemplo n.º 2
0
 // GPU NVIDIA
 public ComputeDevice(CudaDevice cudaDevice, string group, int GPUCount)
 {
     _cudaDevice       = cudaDevice;
     ID                = (int)cudaDevice.DeviceID;
     Group             = group;
     Name              = cudaDevice.GetName();
     _nameNoNums       = cudaDevice.GetName();
     Enabled           = true;
     DeviceGroupType   = GroupNames.GetType(Group);
     DeviceGroupString = GroupNames.GetNameGeneral(DeviceGroupType);
     IsEtherumCapale   = cudaDevice.IsEtherumCapable();
     DeviceType        = DeviceType.NVIDIA;
     NameCount         = String.Format(International.GetText("ComputeDevice_Short_Name_NVIDIA_GPU"), GPUCount);
     UUID              = cudaDevice.UUID;
 }
Exemplo n.º 3
0
 // CPU
 public ComputeDevice(int id, string group, string name, int threads, bool addToGlobalList = false, bool enabled = true)
 {
     ID                = id;
     Group             = group;
     Name              = name;
     Threads           = threads;
     _nameNoNums       = name;
     Enabled           = enabled;
     DeviceGroupType   = GroupNames.GetType(Group);
     DeviceGroupString = GroupNames.GetNameGeneral(DeviceGroupType);
     DeviceType        = DeviceType.CPU;
     InitGlobalsList(addToGlobalList);
     NameCount = String.Format(International.GetText("ComputeDevice_Short_Name_CPU"), ++CPUCount);
     UUID      = GetUUID(ID, Group, Name, DeviceGroupType);
 }
Exemplo n.º 4
0
 // CPU
 public ComputeDevice(int id, string group, string name, int threads, ulong affinityMask, int CPUCount)
 {
     ID                = id;
     Group             = group;
     Name              = name;
     Threads           = threads;
     AffinityMask      = affinityMask;
     _nameNoNums       = name;
     Enabled           = true;
     DeviceGroupType   = GroupNames.GetType(Group);
     DeviceGroupString = GroupNames.GetNameGeneral(DeviceGroupType);
     DeviceType        = DeviceType.CPU;
     NameCount         = String.Format(International.GetText("ComputeDevice_Short_Name_CPU"), CPUCount);
     UUID              = GetUUID(ID, Group, Name, DeviceGroupType);
 }
Exemplo n.º 5
0
 // GPU NVIDIA
 public ComputeDevice(CudaDevice cudaDevice, string group, bool addToGlobalList = false, bool enabled = true)
 {
     _cudaDevice       = cudaDevice;
     ID                = (int)cudaDevice.DeviceID;
     Group             = group;
     Name              = cudaDevice.GetName();
     _nameNoNums       = cudaDevice.GetName();
     Enabled           = enabled;
     DeviceGroupType   = GroupNames.GetType(Group);
     DeviceGroupString = GroupNames.GetNameGeneral(DeviceGroupType);
     IsEtherumCapale   = cudaDevice.IsEtherumCapable();
     DeviceType        = DeviceType.NVIDIA;
     InitGlobalsList(addToGlobalList);
     NameCount = String.Format(International.GetText("ComputeDevice_Short_Name_NVIDIA_GPU"), ++GPUCount);
     UUID      = cudaDevice.UUID;
 }
Exemplo n.º 6
0
 // GPU AMD
 public ComputeDevice(AmdGpuDevice amdDevice, int GPUCount)
 {
     _amdDevice        = amdDevice;
     ID                = amdDevice.DeviceID;
     DeviceGroupType   = DeviceGroupType.AMD_OpenCL;
     Group             = GroupNames.GetName(DeviceGroupType.AMD_OpenCL);
     DeviceGroupString = GroupNames.GetNameGeneral(DeviceGroupType);
     Name              = amdDevice.DeviceName;
     _nameNoNums       = amdDevice.DeviceName;
     Enabled           = true;
     IsEtherumCapale   = amdDevice.IsEtherumCapable();
     DeviceType        = DeviceType.AMD;
     NameCount         = String.Format(International.GetText("ComputeDevice_Short_Name_AMD_GPU"), GPUCount);
     UUID              = amdDevice.UUID;
     // sgminer extra
     IsOptimizedVersion = amdDevice.UseOptimizedVersion;
     Codename           = amdDevice.Codename;
 }
Exemplo n.º 7
0
        public CPUComputeDevice(int id, string group, string name, int threads, ulong affinityMask, int CPUCount)
            : base(id,
                   name,
                   true,
                   DeviceGroupType.CPU,
                   false,
                   DeviceType.CPU,
                   String.Format(International.GetText("ComputeDevice_Short_Name_CPU"), CPUCount),
                   0)
        {
            Threads           = threads;
            AffinityMask      = affinityMask;
            UUID              = GetUUID(ID, GroupNames.GetGroupName(DeviceGroupType, ID), Name, DeviceGroupType);
            AlgorithmSettings = GroupAlgorithms.CreateForDeviceList(this);
            Index             = ID; // Don't increment for CPU

            cpuCounter = new PerformanceCounter();
            cpuCounter.CategoryName = "Processor";
            cpuCounter.CounterName  = "% Processor Time";
            cpuCounter.InstanceName = "_Total";
        }
Exemplo n.º 8
0
 // GPU AMD
 public ComputeDevice(AmdGpuDevice amdDevice, int gpuCount, bool isDetectionFallback)
 {
     ID              = amdDevice.DeviceID;
     BusID           = amdDevice.BusID;
     DeviceGroupType = DeviceGroupType.AMD_OpenCL;
     Name            = amdDevice.DeviceName;
     Enabled         = true;
     IsEtherumCapale = amdDevice.IsEtherumCapable();
     DeviceType      = DeviceType.AMD;
     NameCount       = string.Format(International.GetText("ComputeDevice_Short_Name_AMD_GPU"), gpuCount);
     Uuid            = isDetectionFallback
         ? GetUuid(ID, GroupNames.GetGroupName(DeviceGroupType, ID), Name, DeviceGroupType)
         : amdDevice.UUID;
     // sgminer extra
     //IsOptimizedVersion = amdDevice.UseOptimizedVersion;
     Codename           = amdDevice.Codename;
     InfSection         = amdDevice.InfSection;
     AlgorithmSettings  = GroupAlgorithms.CreateForDeviceList(this);
     DriverDisableAlgos = amdDevice.DriverDisableAlgos;
     GpuRam             = amdDevice.DeviceGlobalMemory;
 }
Exemplo n.º 9
0
 public AmdComputeDevice(AmdGpuDevice amdDevice, int gpuCount, bool isDetectionFallback)
     : base(amdDevice.DeviceID,
            amdDevice.DeviceName,
            true,
            DeviceGroupType.AMD_OpenCL,
            amdDevice.IsEtherumCapable(),
            DeviceType.AMD,
            string.Format(International.GetText("ComputeDevice_Short_Name_AMD_GPU"), gpuCount),
            amdDevice.DeviceGlobalMemory)
 {
     Uuid = isDetectionFallback
         ? GetUuid(ID, GroupNames.GetGroupName(DeviceGroupType, ID), Name, DeviceGroupType)
         : amdDevice.UUID;
     BusID              = amdDevice.BusID;
     Codename           = amdDevice.Codename;
     InfSection         = amdDevice.InfSection;
     AlgorithmSettings  = GroupAlgorithms.CreateForDeviceList(this);
     DriverDisableAlgos = amdDevice.DriverDisableAlgos;
     Index              = ID + ComputeDeviceManager.Avaliable.AvailCpus + ComputeDeviceManager.Avaliable.AvailNVGpus;
     _adapterIndex      = amdDevice.AdapterIndex;
 }
Exemplo n.º 10
0
        public CpuComputeDevice(int id, string group, string name, int threads, ulong affinityMask, int cpuCount)
            : base(id,
                   name,
                   true,
                   DeviceGroupType.CPU,
                   DeviceType.CPU,
                   string.Format(Translations.Tr("CPU#{0}"), cpuCount),
                   0)
        {
            Threads           = threads;
            AffinityMask      = affinityMask;
            Uuid              = GetUuid(ID, GroupNames.GetGroupName(DeviceGroupType, ID), Name, DeviceGroupType);
            AlgorithmSettings = DefaultAlgorithms.GetAlgorithmsForDevice(this);
            Index             = ID; // Don't increment for CPU

            _cpuCounter = new PerformanceCounter
            {
                CategoryName = "Processor",
                CounterName  = "% Processor Time",
                InstanceName = "_Total"
            };
        }
Exemplo n.º 11
0
 // GPU AMD
 public ComputeDevice(AmdGpuDevice amdDevice, int GPUCount, bool isDetectionFallback)
 {
     ID = amdDevice.DeviceID;
     DeviceGroupType = DeviceGroupType.AMD_OpenCL;
     Name            = amdDevice.DeviceName;
     Enabled         = true;
     IsEtherumCapale = amdDevice.IsEtherumCapable();
     DeviceType      = DeviceType.AMD;
     NameCount       = String.Format(International.GetText("ComputeDevice_Short_Name_AMD_GPU"), GPUCount);
     if (isDetectionFallback)
     {
         UUID = GetUUID(ID, GroupNames.GetGroupName(DeviceGroupType, ID), Name, DeviceGroupType);
     }
     else
     {
         UUID = amdDevice.UUID;
     }
     // sgminer extra
     IsOptimizedVersion = amdDevice.UseOptimizedVersion;
     Codename           = amdDevice.Codename;
     InfSection         = amdDevice.InfSection;
     AlgorithmSettings  = GroupAlgorithms.CreateForDevice(this);
 }
        public AmdComputeDevice(AmdGpuDevice amdDevice, int gpuCount, bool isDetectionFallback, int adl2Index)
            : base(amdDevice.DeviceID,
                   amdDevice.DeviceName,
                   true,
                   DeviceGroupType.AMD_OpenCL,
                   DeviceType.AMD,
                   string.Format(Translations.Tr("GPU#{0}"), gpuCount),
                   amdDevice.DeviceGlobalMemory)
        {
            Uuid = isDetectionFallback
                ? GetUuid(ID, GroupNames.GetGroupName(DeviceGroupType, ID), Name, DeviceGroupType)
                : amdDevice.Uuid;
            BusID              = amdDevice.BusID;
            Codename           = amdDevice.Codename;
            InfSection         = amdDevice.InfSection;
            AlgorithmSettings  = DefaultAlgorithms.GetAlgorithmsForDevice(this);
            DriverDisableAlgos = amdDevice.DriverDisableAlgos;
            Index              = ID + AvailableDevices.AvailCpus + AvailableDevices.AvailNVGpus;
            _adapterIndex      = amdDevice.Adl1Index;

            ADL.ADL2_Main_Control_Create?.Invoke(ADL.ADL_Main_Memory_Alloc, 0, ref _adlContext);
            _adapterIndex2 = adl2Index;
        }
        private void QueryCudaDevices()
        {
            Process CudaDevicesDetection = new Process();

            CudaDevicesDetection.StartInfo.FileName               = "CudaDeviceDetection.exe";
            CudaDevicesDetection.StartInfo.UseShellExecute        = false;
            CudaDevicesDetection.StartInfo.RedirectStandardError  = true;
            CudaDevicesDetection.StartInfo.RedirectStandardOutput = true;
            CudaDevicesDetection.StartInfo.CreateNoWindow         = true;
            CudaDevicesDetection.OutputDataReceived              += QueryCudaDevicesOutputErrorDataReceived;
            CudaDevicesDetection.ErrorDataReceived += QueryCudaDevicesOutputErrorDataReceived;

            const int waitTime = 5 * 1000; // 5seconds

            try {
                if (!CudaDevicesDetection.Start())
                {
                    Helpers.ConsolePrint(TAG, "CudaDevicesDetection process could not start");
                }
                else
                {
                    CudaDevicesDetection.BeginErrorReadLine();
                    CudaDevicesDetection.BeginOutputReadLine();
                    if (CudaDevicesDetection.WaitForExit(waitTime))
                    {
                        CudaDevicesDetection.Close();
                    }
                }
            } catch (Exception ex) {
                // TODO
                Helpers.ConsolePrint(TAG, "CudaDevicesDetection threw Exception: " + ex.Message);
            } finally {
                if (QueryCudaDevicesString != "")
                {
                    try {
                        CudaDevices = JsonConvert.DeserializeObject <List <CudaDevice> >(QueryCudaDevicesString, Globals.JsonSettings);
                    } catch { }
                }
            }
            if (CudaDevices != null && CudaDevices.Count != 0)
            {
                HasNVIDIA = true;
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendLine("");
                stringBuilder.AppendLine("CudaDevicesDetection:");
                foreach (var cudaDev in CudaDevices)
                {
                    // check sm vesrions
                    bool isUnderSM21;
                    {
                        bool isUnderSM2_major = cudaDev.SM_major < 2;
                        bool isUnderSM1_minor = cudaDev.SM_minor < 1;
                        isUnderSM21 = isUnderSM2_major && isUnderSM1_minor;
                    }
                    //bool isOverSM6 = cudaDev.SM_major > 6;
                    bool   isDisabledGroup    = IsSMGroupSkip(cudaDev.SM_major);
                    bool   skip               = isUnderSM21 || isDisabledGroup;
                    string skipOrAdd          = skip ? "SKIPED" : "ADDED";
                    string isDisabledGroupStr = isDisabledGroup ? " (SM group disabled)" : "";
                    string etherumCapableStr  = cudaDev.IsEtherumCapable() ? "YES" : "NO";
                    stringBuilder.AppendLine(String.Format("\t{0} device{1}:", skipOrAdd, isDisabledGroupStr));
                    stringBuilder.AppendLine(String.Format("\t\tID: {0}", cudaDev.DeviceID.ToString()));
                    stringBuilder.AppendLine(String.Format("\t\tNAME: {0}", cudaDev.GetName()));
                    stringBuilder.AppendLine(String.Format("\t\tVENDOR: {0}", cudaDev.VendorName));
                    stringBuilder.AppendLine(String.Format("\t\tUUID: {0}", cudaDev.UUID));
                    stringBuilder.AppendLine(String.Format("\t\tSM: {0}", cudaDev.SMVersionString));
                    stringBuilder.AppendLine(String.Format("\t\tMEMORY: {0}", cudaDev.DeviceGlobalMemory.ToString()));
                    stringBuilder.AppendLine(String.Format("\t\tETHEREUM: {0}", etherumCapableStr));

                    if (!skip)
                    {
                        string group;
                        switch (cudaDev.SM_major)
                        {
                        case 2:
                            group = GroupNames.GetName(DeviceGroupType.NVIDIA_2_1);
                            break;

                        case 3:
                            group = GroupNames.GetName(DeviceGroupType.NVIDIA_3_x);
                            break;

                        case 5:
                            group = GroupNames.GetName(DeviceGroupType.NVIDIA_5_x);
                            break;

                        case 6:
                            group = GroupNames.GetName(DeviceGroupType.NVIDIA_6_x);
                            break;

                        default:
                            group = GroupNames.GetName(DeviceGroupType.NVIDIA_6_x);
                            break;
                        }
                        new ComputeDevice(cudaDev, group, true);
                    }
                }
                Helpers.ConsolePrint(TAG, stringBuilder.ToString());
            }
            else
            {
                Helpers.ConsolePrint(TAG, "CudaDevicesDetection found no devices. CudaDevicesDetection returned: " + QueryCudaDevicesString);
            }
        }