Ejemplo n.º 1
0
        public static List <CpuComputeDevice> QueryCpus(out bool failed64Bit, out bool failedCpuCount)
        {
            Helpers.ConsolePrint(Tag, "QueryCpus START");
            // get all CPUs
            var cpuCount = CpuID.GetPhysicalProcessorCount();

            Helpers.ConsolePrint(Tag,
                                 CpuID.IsHypeThreadingEnabled()
                    ? "HyperThreadingEnabled = TRUE"
                    : "HyperThreadingEnabled = FALSE");

            // get all cores (including virtual - HT can benefit mining)
            var threadsPerCpu = CpuID.GetVirtualCoresCount() / cpuCount;

            failed64Bit    = !Helpers.Is64BitOperatingSystem;
            failedCpuCount = threadsPerCpu * cpuCount > 64;

            // TODO important move this to settings
            var threadsPerCpuMask = threadsPerCpu;

            Globals.ThreadsPerCpu = threadsPerCpu;

            var cpus = new List <CpuComputeDevice>();

            if (CpuUtils.IsCpuMiningCapable() && !failed64Bit && !failedCpuCount)
            {
                if (cpuCount == 1)
                {
                    cpus.Add(new CpuComputeDevice(0, "CPU0", CpuID.GetCpuName().Trim(), threadsPerCpu, 0, 1));
                }
                else if (cpuCount > 1)
                {
                    for (var i = 0; i < cpuCount; i++)
                    {
                        cpus.Add(
                            new CpuComputeDevice(i, "CPU" + i, CpuID.GetCpuName().Trim(), threadsPerCpu,
                                                 CpuID.CreateAffinityMask(i, threadsPerCpuMask), i + 1)
                            );
                    }
                }
            }

            Helpers.ConsolePrint(Tag, "QueryCpus END");

            return(cpus);
        }
Ejemplo n.º 2
0
                public static void QueryCpus()
                {
                    Helpers.ConsolePrint(Tag, "QueryCpus START");
                    // get all CPUs
                    Available.CpusCount = CpuID.GetPhysicalProcessorCount();
                    Available.IsHyperThreadingEnabled = CpuID.IsHypeThreadingEnabled();

                    Helpers.ConsolePrint(Tag,
                                         Available.IsHyperThreadingEnabled
                            ? "HyperThreadingEnabled = TRUE"
                            : "HyperThreadingEnabled = FALSE");

                    // get all cores (including virtual - HT can benefit mining)
                    var threadsPerCpu = CpuID.GetVirtualCoresCount() / Available.CpusCount;

                    if (!Helpers.Is64BitOperatingSystem)
                    {
                        if (ConfigManager.GeneralConfig.ShowDriverVersionWarning)
                        {
                            MessageBox.Show(International.GetText("Form_Main_msgbox_CPUMining64bitMsg"),
                                            International.GetText("Warning_with_Exclamation"),
                                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }

                        Available.CpusCount = 0;
                    }

                    if (threadsPerCpu * Available.CpusCount > 64)
                    {
                        if (ConfigManager.GeneralConfig.ShowDriverVersionWarning)
                        {
                            MessageBox.Show(International.GetText("Form_Main_msgbox_CPUMining64CoresMsg"),
                                            International.GetText("Warning_with_Exclamation"),
                                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }

                        Available.CpusCount = 0;
                    }

                    // TODO important move this to settings
                    var threadsPerCpuMask = threadsPerCpu;

                    Globals.ThreadsPerCpu = threadsPerCpu;

                    if (CpuUtils.IsCpuMiningCapable())
                    {
                        if (Available.CpusCount == 1)
                        {
                            Available.Devices.Add(
                                new CpuComputeDevice(0, "CPU0", CpuID.GetCpuName().Trim(), threadsPerCpu, 0,
                                                     ++CpuCount)
                                );
                        }
                        else if (Available.CpusCount > 1)
                        {
                            for (var i = 0; i < Available.CpusCount; i++)
                            {
                                Available.Devices.Add(
                                    new CpuComputeDevice(i, "CPU" + i, CpuID.GetCpuName().Trim(), threadsPerCpu,
                                                         CpuID.CreateAffinityMask(i, threadsPerCpuMask), ++CpuCount)
                                    );
                            }
                        }
                    }

                    Helpers.ConsolePrint(Tag, "QueryCpus END");
                }
Ejemplo n.º 3
0
                public static void QueryCpus()
                {
                    Helpers.ConsolePrint(Tag, "QueryCpus START");
                    // get all CPUs
                    Available.CpusCount = CpuID.GetPhysicalProcessorCount();
                    Available.IsHyperThreadingEnabled = CpuID.IsHypeThreadingEnabled();

                    Helpers.ConsolePrint(Tag,
                                         Available.IsHyperThreadingEnabled
                            ? "HyperThreadingEnabled = TRUE"
                            : "HyperThreadingEnabled = FALSE");

                    // get all cores (including virtual - HT can benefit mining)
                    var threadsPerCpu = CpuID.GetVirtualCoresCount() / Available.CpusCount;

                    if (!Helpers.Is64BitOperatingSystem)
                    {
                        if (ConfigManager.GeneralConfig.ShowDriverVersionWarning)
                        {
                            MessageBox.Show(Tr("NiceHash Miner Legacy works only on 64-bit version of OS for CPU mining. CPU mining will be disabled."),
                                            Tr("Warning!"),
                                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }

                        Available.CpusCount = 0;
                    }

                    if (threadsPerCpu * Available.CpusCount > 64)
                    {
                        if (ConfigManager.GeneralConfig.ShowDriverVersionWarning)
                        {
                            MessageBox.Show(Tr("NiceHash Miner Legacy does not support more than 64 virtual cores. CPU mining will be disabled."),
                                            Tr("Warning!"),
                                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }

                        Available.CpusCount = 0;
                    }

                    // TODO important move this to settings
                    var threadsPerCpuMask = threadsPerCpu;

                    Globals.ThreadsPerCpu = threadsPerCpu;

                    if (CpuUtils.IsCpuMiningCapable())
                    {
                        if (Available.CpusCount == 1)
                        {
                            Available.Devices.Add(
                                new CpuComputeDevice(0, "CPU0", CpuID.GetCpuName().Trim(), threadsPerCpu, 0,
                                                     ++CpuCount)
                                );
                        }
                        else if (Available.CpusCount > 1)
                        {
                            for (var i = 0; i < Available.CpusCount; i++)
                            {
                                Available.Devices.Add(
                                    new CpuComputeDevice(i, "CPU" + i, CpuID.GetCpuName().Trim(), threadsPerCpu,
                                                         CpuID.CreateAffinityMask(i, threadsPerCpuMask), ++CpuCount)
                                    );
                            }
                        }
                    }

                    Helpers.ConsolePrint(Tag, "QueryCpus END");
                }