public void QueryDevices(IMessageNotifier messageNotifier) { MessageNotifier = messageNotifier; // #0 get video controllers, used for cross checking QueryVideoControllers(); // Order important CPU Query must be first // #1 CPU QueryCPUs(); // #2 CUDA showMessageAndStep(International.GetText("Compute_Device_Query_Manager_CUDA_Query")); QueryCudaDevices(); // #3 OpenCL showMessageAndStep(International.GetText("Compute_Device_Query_Manager_OpenCL_Query")); QueryOpenCLDevices(); // #4 AMD query AMD from OpenCL devices, get serial and add devices QueryAMD(); // #5 uncheck CPU if GPUs present, call it after we Query all devices UncheckedCPU(); // add numberings to same devices if (ComputeDevice.AllAvaliableDevices.Count != ComputeDevice.UniqueAvaliableDevices.Count) { // name count Dictionary <string, int> namesCount = new Dictionary <string, int>(); // init keys and counters foreach (var uniqueCdev in ComputeDevice.UniqueAvaliableDevices) { namesCount.Add(uniqueCdev.Name, 0); } // count foreach (var cDev in ComputeDevice.AllAvaliableDevices) { namesCount[cDev.Name]++; } foreach (var nameCount in namesCount) { string name = nameCount.Key; int deviceCount = nameCount.Value; if (deviceCount > 1) { int numID = 1; foreach (var cDev in ComputeDevice.AllAvaliableDevices) { if (cDev.Name == name) { cDev.Name = cDev.Name + " #" + numID.ToString(); ++numID; } } } } } // TODO update this to report undetected hardware // #6 check NVIDIA, AMD devices count { int NVIDIA_count = 0; int AMD_count = 0; foreach (var vidCtrl in AvaliableVideoControllers) { NVIDIA_count += (vidCtrl.Name.ToLower().Contains("nvidia")) ? 1 : 0; AMD_count += (vidCtrl.Name.ToLower().Contains("amd")) ? 1 : 0; } if (NVIDIA_count == CudaDevices.Count) { Helpers.ConsolePrint(TAG, "Cuda NVIDIA/CUDA device count GOOD"); } else { Helpers.ConsolePrint(TAG, "Cuda NVIDIA/CUDA device count BAD!!!"); } if (AMD_count == amdGpus.Count) { Helpers.ConsolePrint(TAG, "AMD GPU device count GOOD"); } else { Helpers.ConsolePrint(TAG, "AMD GPU device count BAD!!!"); } } // #7 init ethminer ID mappings offset if (OpenCLJSONData != null) { // helper vars Dictionary <ComputePlatformType, int> openCLGpuCount = new Dictionary <ComputePlatformType, int>(); Dictionary <ComputePlatformType, int> openCLPlatformIds = new Dictionary <ComputePlatformType, int>(); foreach (var oclPlatform in OpenCLJSONData.OCLPlatforms) { ComputePlatformType current = GetPlatformType(oclPlatform.Key); if (current != ComputePlatformType.NONE) { openCLPlatformIds[current] = oclPlatform.Value; } else { Helpers.ConsolePrint(TAG, "ethminer platforms mapping NONE"); } } foreach (var oclDevs in OpenCLJSONData.OCLPlatformDevices) { ComputePlatformType current = GetPlatformType(oclDevs.Key); if (current != ComputePlatformType.NONE) { foreach (var oclDev in oclDevs.Value) { if (oclDev._CL_DEVICE_TYPE.Contains("GPU")) { if (openCLGpuCount.ContainsKey(current)) { openCLGpuCount[current]++; } else { openCLGpuCount[current] = 1; } } } } else { Helpers.ConsolePrint(TAG, "ethminer platforms mapping NONE"); } } // sort platforms by platform values Dictionary <int, ComputePlatformType> openCLPlatformIdsRev = new Dictionary <int, ComputePlatformType>(); List <int> platformIds = new List <int>(); foreach (var platId in openCLPlatformIds) { openCLPlatformIdsRev[platId.Value] = platId.Key; platformIds.Add(platId.Value); } platformIds.Sort(); // set mappings int cumulativeCount = 0; foreach (var curId in platformIds) { var key = openCLPlatformIdsRev[curId]; if (openCLGpuCount.ContainsKey(key)) { _ethminerIdsOffet[key] = cumulativeCount; cumulativeCount += openCLGpuCount[key]; } } } // allerts _currentNvidiaOpenCLDriver = GetNvidiaOpenCLDriver(); // if we have nvidia cards but no CUDA devices tell the user to upgrade driver bool isNvidiaErrorShown = false; // to prevent showing twice if (ConfigManager.Instance.GeneralConfig.ShowDriverVersionWarning && HasNvidiaVideoController() && CudaDevices.Count == 0) { isNvidiaErrorShown = true; var minDriver = NVIDIA_MIN_DETECTION_DRIVER.ToString(); var recomendDrvier = NVIDIA_RECOMENDED_DRIVER.ToString(); MessageBox.Show(String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Detection"), minDriver, recomendDrvier), International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"), MessageBoxButtons.OK, MessageBoxIcon.Error); } // recomended driver if (ConfigManager.Instance.GeneralConfig.ShowDriverVersionWarning && HasNvidiaVideoController() && _currentNvidiaOpenCLDriver < NVIDIA_RECOMENDED_DRIVER && !isNvidiaErrorShown && _currentNvidiaOpenCLDriver > -1) { var recomendDrvier = NVIDIA_RECOMENDED_DRIVER.ToString(); var nvdriverString = _currentNvidiaOpenCLDriver > -1 ? String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended_PART"), _currentNvidiaOpenCLDriver.ToString()) : ""; MessageBox.Show(String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended"), recomendDrvier, nvdriverString, recomendDrvier), International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } // #x remove reference MessageNotifier = null; }
public int GetEthminerOpenCLID(ComputePlatformType platformType, int id) { return(_ethminerIdsOffet[platformType] + id); }