Ejemplo n.º 1
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.CreateForDeviceList(this);
     DriverDisableAlgos = amdDevice.DriverDisableAlgos;
     GpuRam             = amdDevice.DeviceGlobalMemory;
 }
        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;

            // plugin device
            var bd = new BaseDevice(DeviceType.AMD, Uuid, Name, ID);

            PluginDevice = new AMDDevice(bd, amdDevice.BusID, amdDevice.DeviceGlobalMemory, Codename, InfSection);
        }
Ejemplo n.º 3
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)
 {
     if (isDetectionFallback)
     {
         UUID = GetUUID(ID, GroupNames.GetGroupName(DeviceGroupType, ID), Name, DeviceGroupType);
     }
     else
     {
         UUID = 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;
 }
Ejemplo n.º 4
0
 // GPU AMD
 public ComputeDevice(AmdGpuDevice amdDevice, int GPUCount)
 {
     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);
     UUID            = amdDevice.UUID;
     // sgminer extra
     IsOptimizedVersion = amdDevice.UseOptimizedVersion;
     Codename           = amdDevice.Codename;
     AlgorithmSettings  = GroupAlgorithms.CreateForDevice(this);
 }
Ejemplo n.º 5
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;
 }
        public AmdComputeDevice(AmdGpuDevice amdDevice, int gpuCount, bool isDetectionFallback, int adl2Index)
            : base(amdDevice.DeviceID,
                   amdDevice.DeviceName,
                   true,
                   DeviceGroupType.AMD_OpenCL,
                   amdDevice.IsEtherumCapable(),
                   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  = GroupAlgorithms.CreateForDeviceList(this);
            DriverDisableAlgos = amdDevice.DriverDisableAlgos;
            Index              = ID + ComputeDeviceManager.Available.AvailCpus + ComputeDeviceManager.Available.AvailNVGpus;
            _adapterIndex      = amdDevice.AdapterIndex;

            ADL.ADL2_Main_Control_Create?.Invoke(ADL.ADL_Main_Memory_Alloc, 0, ref _adlContext);
            _adapterIndex2 = adl2Index;
        }
Ejemplo n.º 7
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);
 }
        private void QueryAMD()
        {
            //showMessageAndStep(International.GetText("Form_Main_loadtext_AMD"));
            //var dump = new sgminer(true);

            if (ConfigManager.Instance.GeneralConfig.DeviceDetection.DisableDetectionAMD)
            {
                Helpers.ConsolePrint(TAG, "Skipping AMD device detection, settings set to disabled");
                showMessageAndStep(International.GetText("Compute_Device_Query_Manager_AMD_Query_Skip"));
                return;
            }

            #region AMD driver check, ADL returns 0
            // check the driver version bool EnableOptimizedVersion = true;
            Dictionary <string, bool> deviceDriverOld = new Dictionary <string, bool>();
            string minerPath         = MinerPaths.sgminer_5_5_0_general;
            bool   ShowWarningDialog = false;

            foreach (var vidContrllr in AvaliableVideoControllers)
            {
                Helpers.ConsolePrint(TAG, String.Format("Checking AMD device (driver): {0} ({1})", vidContrllr.Name, vidContrllr.DriverVersion));

                deviceDriverOld[vidContrllr.Name] = false;
                // TODO checking radeon drivers only?
                if ((vidContrllr.Name.Contains("AMD") || vidContrllr.Name.Contains("Radeon")) && ShowWarningDialog == false)
                {
                    Version AMDDriverVersion = new Version(vidContrllr.DriverVersion);

                    if (AMDDriverVersion.Major < 15)
                    {
                        ShowWarningDialog = true;
                        deviceDriverOld[vidContrllr.Name] = true;
                        Helpers.ConsolePrint(TAG, "WARNING!!! Old AMD GPU driver detected! All optimized versions disabled, mining " +
                                             "speed will not be optimal. Consider upgrading AMD GPU driver. Recommended AMD GPU driver version is 15.7.1.");
                    }
                    else if (AMDDriverVersion.Major == 16 && AMDDriverVersion.Minor >= 150)
                    {
                        if (MinersDownloadManager.Instance.IsMinerBinFolder())
                        {
                            // TODO why this copy?
                            string src = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\" +
                                         minerPath.Split('\\')[0] + "\\" + minerPath.Split('\\')[1] + "\\kernel";

                            foreach (var file in Directory.GetFiles(src))
                            {
                                string dest = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Temp\\" + System.IO.Path.GetFileName(file);
                                if (!File.Exists(dest))
                                {
                                    File.Copy(file, dest, false);
                                }
                            }
                        }
                    }
                }
            }
            if (ConfigManager.Instance.GeneralConfig.ShowDriverVersionWarning && ShowWarningDialog == true)
            {
                Form WarningDialog = new DriverVersionConfirmationDialog();
                WarningDialog.ShowDialog();
                WarningDialog = null;
            }
            #endregion // AMD driver check

            // get platform version
            showMessageAndStep(International.GetText("Compute_Device_Query_Manager_AMD_Query"));
            if (IsOpenCLQuerrySuccess)
            {
                bool amdPlatformNumFound = false;
                foreach (var kvp in OpenCLJSONData.OCLPlatforms)
                {
                    if (kvp.Key.Contains("AMD") || kvp.Key.Contains("amd"))
                    {
                        amdPlatformNumFound        = true;
                        AMDOpenCLPlatformStringKey = kvp.Key;
                        AMDOpenCLPlatformNum       = kvp.Value;
                        Helpers.ConsolePrint(TAG, String.Format("AMD platform found: Key: {0}, Num: {1}",
                                                                AMDOpenCLPlatformStringKey,
                                                                AMDOpenCLPlatformNum.ToString()));
                        break;
                    }
                }
                if (amdPlatformNumFound)
                {
                    // get only AMD gpus
                    {
                        var amdOCLDevices = OpenCLJSONData.OCLPlatformDevices[AMDOpenCLPlatformStringKey];
                        foreach (var oclDev in amdOCLDevices)
                        {
                            if (oclDev._CL_DEVICE_TYPE.Contains("GPU"))
                            {
                                amdGpus.Add(oclDev);
                            }
                        }
                    }
                    if (amdGpus.Count == 0)
                    {
                        Helpers.ConsolePrint(TAG, "AMD GPUs count is 0");
                    }
                    else
                    {
                        Helpers.ConsolePrint(TAG, "AMD GPUs count : " + amdGpus.Count.ToString());
                        Helpers.ConsolePrint(TAG, "AMD Getting device name and serial from ADL");
                        // ADL
                        bool isAdlInit = true;
                        // ADL does not get devices in order map devices by bus number
                        // bus id, <name, uuid>
                        Dictionary <int, Tuple <string, string> > _busIdsInfo = new Dictionary <int, Tuple <string, string> >();
                        List <string> _amdDeviceName = new List <string>();
                        List <string> _amdDeviceUUID = new List <string>();
                        try {
                            int ADLRet           = -1;
                            int NumberOfAdapters = 0;
                            if (null != ADL.ADL_Main_Control_Create)
                            {
                                // Second parameter is 1: Get only the present adapters
                                ADLRet = ADL.ADL_Main_Control_Create(ADL.ADL_Main_Memory_Alloc, 1);
                            }
                            if (ADL.ADL_SUCCESS == ADLRet)
                            {
                                if (null != ADL.ADL_Adapter_NumberOfAdapters_Get)
                                {
                                    ADL.ADL_Adapter_NumberOfAdapters_Get(ref NumberOfAdapters);
                                }
                                Helpers.ConsolePrint(TAG, "Number Of Adapters: " + NumberOfAdapters.ToString());

                                if (0 < NumberOfAdapters)
                                {
                                    // Get OS adpater info from ADL
                                    ADLAdapterInfoArray OSAdapterInfoData;
                                    OSAdapterInfoData = new ADLAdapterInfoArray();

                                    if (null != ADL.ADL_Adapter_AdapterInfo_Get)
                                    {
                                        IntPtr AdapterBuffer = IntPtr.Zero;
                                        int    size          = Marshal.SizeOf(OSAdapterInfoData);
                                        AdapterBuffer = Marshal.AllocCoTaskMem((int)size);
                                        Marshal.StructureToPtr(OSAdapterInfoData, AdapterBuffer, false);

                                        if (null != ADL.ADL_Adapter_AdapterInfo_Get)
                                        {
                                            ADLRet = ADL.ADL_Adapter_AdapterInfo_Get(AdapterBuffer, size);
                                            if (ADL.ADL_SUCCESS == ADLRet)
                                            {
                                                OSAdapterInfoData = (ADLAdapterInfoArray)Marshal.PtrToStructure(AdapterBuffer, OSAdapterInfoData.GetType());
                                                int IsActive = 0;

                                                for (int i = 0; i < NumberOfAdapters; i++)
                                                {
                                                    // Check if the adapter is active
                                                    if (null != ADL.ADL_Adapter_Active_Get)
                                                    {
                                                        ADLRet = ADL.ADL_Adapter_Active_Get(OSAdapterInfoData.ADLAdapterInfo[i].AdapterIndex, ref IsActive);
                                                    }

                                                    if (ADL.ADL_SUCCESS == ADLRet)
                                                    {
                                                        // we are looking for amd
                                                        // TODO check discrete and integrated GPU separation
                                                        var vendorID = OSAdapterInfoData.ADLAdapterInfo[i].VendorID;
                                                        var devName  = OSAdapterInfoData.ADLAdapterInfo[i].AdapterName;
                                                        if (vendorID == AMD_VENDOR_ID ||
                                                            devName.ToLower().Contains("amd") ||
                                                            devName.ToLower().Contains("radeon") ||
                                                            devName.ToLower().Contains("firepro"))
                                                        {
                                                            string PNPStr        = OSAdapterInfoData.ADLAdapterInfo[i].PNPString;
                                                            var    backSlashLast = PNPStr.LastIndexOf('\\');
                                                            var    serial        = PNPStr.Substring(backSlashLast, PNPStr.Length - backSlashLast);
                                                            var    end_0         = serial.IndexOf('&');
                                                            var    end_1         = serial.IndexOf('&', end_0 + 1);
                                                            // get serial
                                                            serial = serial.Substring(end_0 + 1, (end_1 - end_0) - 1);

                                                            var udid = OSAdapterInfoData.ADLAdapterInfo[i].UDID;
                                                            var pciVen_id_strSize = 21; // PCI_VEN_XXXX&DEV_XXXX
                                                            var uuid  = udid.Substring(0, pciVen_id_strSize) + "_" + serial;
                                                            int budId = OSAdapterInfoData.ADLAdapterInfo[i].BusNumber;
                                                            if (!_amdDeviceUUID.Contains(uuid))
                                                            {
                                                                try {
                                                                    Helpers.ConsolePrint(TAG, String.Format("ADL device added BusNumber:{0}  NAME:{1}  UUID:{2}"),
                                                                                         budId,
                                                                                         devName,
                                                                                         uuid);
                                                                } catch { }

                                                                _amdDeviceUUID.Add(uuid);
                                                                //_busIds.Add(OSAdapterInfoData.ADLAdapterInfo[i].BusNumber);
                                                                _amdDeviceName.Add(devName);
                                                                if (!_busIdsInfo.ContainsKey(budId))
                                                                {
                                                                    var nameUuid = new Tuple <string, string>(devName, uuid);
                                                                    _busIdsInfo.Add(budId, nameUuid);
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                Helpers.ConsolePrint(TAG, "ADL_Adapter_AdapterInfo_Get() returned error code " + ADLRet.ToString());
                                            }
                                        }
                                        // Release the memory for the AdapterInfo structure
                                        if (IntPtr.Zero != AdapterBuffer)
                                        {
                                            Marshal.FreeCoTaskMem(AdapterBuffer);
                                        }
                                    }
                                }
                                if (null != ADL.ADL_Main_Control_Destroy)
                                {
                                    ADL.ADL_Main_Control_Destroy();
                                }
                            }
                            else
                            {
                                // TODO
                                Helpers.ConsolePrint(TAG, "ADL_Main_Control_Create() returned error code " + ADLRet.ToString());
                                Helpers.ConsolePrint(TAG, "Check if ADL is properly installed!");
                            }
                        } catch (Exception ex) {
                            Helpers.ConsolePrint(TAG, "AMD ADL exception: " + ex.Message);
                            isAdlInit = false;
                        }
                        if (isAdlInit)
                        {
                            if (amdGpus.Count == _amdDeviceUUID.Count)
                            {
                                Helpers.ConsolePrint(TAG, "AMD OpenCL and ADL AMD query COUNTS GOOD/SAME");
                            }
                            else
                            {
                                Helpers.ConsolePrint(TAG, "AMD OpenCL and ADL AMD query COUNTS DIFFERENT/BAD");
                            }
                            StringBuilder stringBuilder = new StringBuilder();
                            stringBuilder.AppendLine("");
                            stringBuilder.AppendLine("QueryAMD devices: ");
                            for (int i_id = 0; i_id < amdGpus.Count; ++i_id)
                            {
                                HasAMD = true;

                                int busID = amdGpus[i_id].AMD_BUS_ID;
                                if (busID != -1 && _busIdsInfo.ContainsKey(busID))
                                {
                                    var deviceName = _busIdsInfo[busID].Item1;
                                    var newAmdDev  = new AmdGpuDevice(amdGpus[i_id], deviceDriverOld[deviceName]);
                                    newAmdDev.DeviceName = deviceName;
                                    newAmdDev.UUID       = _busIdsInfo[busID].Item2;
                                    bool   isDisabledGroup    = ConfigManager.Instance.GeneralConfig.DeviceDetection.DisableDetectionAMD;
                                    string skipOrAdd          = isDisabledGroup ? "SKIPED" : "ADDED";
                                    string isDisabledGroupStr = isDisabledGroup ? " (AMD group disabled)" : "";
                                    string etherumCapableStr  = newAmdDev.IsEtherumCapable() ? "YES" : "NO";

                                    new ComputeDevice(newAmdDev, true, true);
                                    // just in case
                                    try {
                                        stringBuilder.AppendLine(String.Format("\t{0} device{1}:", skipOrAdd, isDisabledGroupStr));
                                        stringBuilder.AppendLine(String.Format("\t\tID: {0}", newAmdDev.DeviceID.ToString()));
                                        stringBuilder.AppendLine(String.Format("\t\tNAME: {0}", newAmdDev.DeviceName));
                                        stringBuilder.AppendLine(String.Format("\t\tCODE_NAME: {0}", newAmdDev.Codename));
                                        stringBuilder.AppendLine(String.Format("\t\tUUID: {0}", newAmdDev.UUID));
                                        stringBuilder.AppendLine(String.Format("\t\tMEMORY: {0}", newAmdDev.DeviceGlobalMemory.ToString()));
                                        stringBuilder.AppendLine(String.Format("\t\tETHEREUM: {0}", etherumCapableStr));
                                    } catch { }
                                }
                                else
                                {
                                    stringBuilder.AppendLine(String.Format("\tDevice not added, Bus No. {0} not found:", busID));
                                }
                            }
                            Helpers.ConsolePrint(TAG, stringBuilder.ToString());
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
 // GPU AMD
 public ComputeDevice(AmdGpuDevice amdDevice, bool addToGlobalList = false, bool enabled = true)
 {
     _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 = enabled;
     IsEtherumCapale = amdDevice.IsEtherumCapable();
     DeviceType = DeviceType.AMD;
     InitGlobalsList(addToGlobalList);
     NameCount = String.Format(International.GetText("ComputeDevice_Short_Name_AMD_GPU"), ++GPUCount);
     UUID = amdDevice.UUID;
     // sgminer extra
     IsOptimizedVersion = amdDevice.UseOptimizedVersion;
     Codename = amdDevice.Codename;
 }
Ejemplo n.º 10
0
                public static void QueryAMD()
                {
                    const int AMD_VENDOR_ID = 1002;
                    Helpers.ConsolePrint(TAG, "QueryAMD START");

                    #region AMD driver check, ADL returns 0
                    // check the driver version bool EnableOptimizedVersion = true;
                    Dictionary<string, bool> deviceDriverOld = new Dictionary<string, bool>();
                    string minerPath = MinerPaths.sgminer_5_5_0_general;
                    bool ShowWarningDialog = false;

                    foreach (var vidContrllr in AvaliableVideoControllers) {
                        Helpers.ConsolePrint(TAG, String.Format("Checking AMD device (driver): {0} ({1})", vidContrllr.Name, vidContrllr.DriverVersion));

                        deviceDriverOld[vidContrllr.Name] = false;
                        // TODO checking radeon drivers only?
                        if ((vidContrllr.Name.Contains("AMD") || vidContrllr.Name.Contains("Radeon")) && ShowWarningDialog == false) {
                            Version AMDDriverVersion = new Version(vidContrllr.DriverVersion);

                            if (AMDDriverVersion.Major < 15) {
                                ShowWarningDialog = true;
                                deviceDriverOld[vidContrllr.Name] = true;
                                Helpers.ConsolePrint(TAG, "WARNING!!! Old AMD GPU driver detected! All optimized versions disabled, mining " +
                                    "speed will not be optimal. Consider upgrading AMD GPU driver. Recommended AMD GPU driver version is 15.7.1.");
                            } else if (AMDDriverVersion.Major == 16 && AMDDriverVersion.Minor >= 150) {
                                if (MinersDownloadManager.IsMinerBinFolder()) {
                                    // TODO why this copy?
                                    string src = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\" +
                                                 minerPath.Split('\\')[0] + "\\" + minerPath.Split('\\')[1] + "\\kernel";

                                    foreach (var file in Directory.GetFiles(src)) {
                                        string dest = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Temp\\" + System.IO.Path.GetFileName(file);
                                        if (!File.Exists(dest)) File.Copy(file, dest, false);
                                    }
                                }
                            }
                        }
                    }
                    if (ConfigManager.GeneralConfig.ShowDriverVersionWarning && ShowWarningDialog == true) {
                        Form WarningDialog = new DriverVersionConfirmationDialog();
                        WarningDialog.ShowDialog();
                        WarningDialog = null;
                    }
                    #endregion // AMD driver check

                    // get platform version
                    showMessageAndStep(International.GetText("Compute_Device_Query_Manager_AMD_Query"));
                    List<OpenCLDevice> amdOCLDevices = new List<OpenCLDevice>();
                    string AMDOpenCLPlatformStringKey = "";
                    if (IsOpenCLQuerrySuccess) {
                        bool amdPlatformNumFound = false;
                        foreach (var oclEl in OpenCLJSONData) {
                            if (oclEl.PlatformName.Contains("AMD") || oclEl.PlatformName.Contains("amd")) {
                                amdPlatformNumFound = true;
                                AMDOpenCLPlatformStringKey = oclEl.PlatformName;
                                Avaliable.AMDOpenCLPlatformNum = oclEl.PlatformNum;
                                amdOCLDevices = oclEl.Devices;
                                Helpers.ConsolePrint(TAG, String.Format("AMD platform found: Key: {0}, Num: {1}",
                                    AMDOpenCLPlatformStringKey,
                                    Avaliable.AMDOpenCLPlatformNum.ToString()));
                                break;
                            }
                        }
                        if (amdPlatformNumFound) {
                            // get only AMD gpus
                            {
                                foreach (var oclDev in amdOCLDevices) {
                                    if (oclDev._CL_DEVICE_TYPE.Contains("GPU")) {
                                        amdGpus.Add(oclDev);
                                    }
                                }
                            }
                            bool isBusID_OK = true;
                            // check if buss ids are unuque and different from -1
                            {
                                HashSet<int> bus_ids = new HashSet<int>();
                                foreach (var amdOclDev in amdGpus) {
                                    if (amdOclDev.AMD_BUS_ID < 0) {
                                        isBusID_OK = false;
                                        break;
                                    }
                                    bus_ids.Add(amdOclDev.AMD_BUS_ID);
                                }
                                // check if unique
                                isBusID_OK = isBusID_OK && bus_ids.Count == amdGpus.Count;
                            }

                            if (amdGpus.Count == 0) {
                                Helpers.ConsolePrint(TAG, "AMD GPUs count is 0");
                            } else {
                                // print BUS id status
                                if (isBusID_OK) {
                                    Helpers.ConsolePrint(TAG, "AMD Bus IDs are unique and valid. OK");
                                } else {
                                    Helpers.ConsolePrint(TAG, "AMD Bus IDs IS INVALID. Using fallback AMD detection mode");
                                }

                                Helpers.ConsolePrint(TAG, "AMD GPUs count : " + amdGpus.Count.ToString());
                                Helpers.ConsolePrint(TAG, "AMD Getting device name and serial from ADL");
                                // ADL
                                bool isAdlInit = true;
                                // ADL does not get devices in order map devices by bus number
                                // bus id, <name, uuid>
                                Dictionary<int, Tuple3<string, string, string>> _busIdsInfo = new Dictionary<int, Tuple3<string, string, string>>();
                                List<string> _amdDeviceName = new List<string>();
                                List<string> _amdDeviceUUID = new List<string>();
                                try {
                                    int ADLRet = -1;
                                    int NumberOfAdapters = 0;
                                    if (null != ADL.ADL_Main_Control_Create)
                                        // Second parameter is 1: Get only the present adapters
                                        ADLRet = ADL.ADL_Main_Control_Create(ADL.ADL_Main_Memory_Alloc, 1);
                                    if (ADL.ADL_SUCCESS == ADLRet) {
                                        if (null != ADL.ADL_Adapter_NumberOfAdapters_Get) {
                                            ADL.ADL_Adapter_NumberOfAdapters_Get(ref NumberOfAdapters);
                                        }
                                        Helpers.ConsolePrint(TAG, "Number Of Adapters: " + NumberOfAdapters.ToString());

                                        if (0 < NumberOfAdapters) {
                                            // Get OS adpater info from ADL
                                            ADLAdapterInfoArray OSAdapterInfoData;
                                            OSAdapterInfoData = new ADLAdapterInfoArray();

                                            if (null != ADL.ADL_Adapter_AdapterInfo_Get) {
                                                IntPtr AdapterBuffer = IntPtr.Zero;
                                                int size = Marshal.SizeOf(OSAdapterInfoData);
                                                AdapterBuffer = Marshal.AllocCoTaskMem((int)size);
                                                Marshal.StructureToPtr(OSAdapterInfoData, AdapterBuffer, false);

                                                if (null != ADL.ADL_Adapter_AdapterInfo_Get) {
                                                    ADLRet = ADL.ADL_Adapter_AdapterInfo_Get(AdapterBuffer, size);
                                                    if (ADL.ADL_SUCCESS == ADLRet) {
                                                        OSAdapterInfoData = (ADLAdapterInfoArray)Marshal.PtrToStructure(AdapterBuffer, OSAdapterInfoData.GetType());
                                                        int IsActive = 0;

                                                        for (int i = 0; i < NumberOfAdapters; i++) {
                                                            // Check if the adapter is active
                                                            if (null != ADL.ADL_Adapter_Active_Get)
                                                                ADLRet = ADL.ADL_Adapter_Active_Get(OSAdapterInfoData.ADLAdapterInfo[i].AdapterIndex, ref IsActive);

                                                            if (ADL.ADL_SUCCESS == ADLRet) {
                                                                // we are looking for amd
                                                                // TODO check discrete and integrated GPU separation
                                                                var vendorID = OSAdapterInfoData.ADLAdapterInfo[i].VendorID;
                                                                var devName = OSAdapterInfoData.ADLAdapterInfo[i].AdapterName;
                                                                if (vendorID == AMD_VENDOR_ID
                                                                    || devName.ToLower().Contains("amd")
                                                                    || devName.ToLower().Contains("radeon")
                                                                    || devName.ToLower().Contains("firepro")) {

                                                                    string PNPStr = OSAdapterInfoData.ADLAdapterInfo[i].PNPString;
                                                                    // find vi controller pnp
                                                                    string infSection = "";
                                                                    foreach (var v_ctrl in AvaliableVideoControllers) {
                                                                        if(v_ctrl.PNPDeviceID == PNPStr) {
                                                                            infSection = v_ctrl.InfSection;
                                                                        }
                                                                    }

                                                                    var backSlashLast = PNPStr.LastIndexOf('\\');
                                                                    var serial = PNPStr.Substring(backSlashLast, PNPStr.Length - backSlashLast);
                                                                    var end_0 = serial.IndexOf('&');
                                                                    var end_1 = serial.IndexOf('&', end_0 + 1);
                                                                    // get serial
                                                                    serial = serial.Substring(end_0 + 1, (end_1 - end_0) - 1);

                                                                    var udid = OSAdapterInfoData.ADLAdapterInfo[i].UDID;
                                                                    var pciVen_id_strSize = 21; // PCI_VEN_XXXX&DEV_XXXX
                                                                    var uuid = udid.Substring(0, pciVen_id_strSize) + "_" + serial;
                                                                    int budId = OSAdapterInfoData.ADLAdapterInfo[i].BusNumber;
                                                                    if (!_amdDeviceUUID.Contains(uuid)) {
                                                                        try {
                                                                            Helpers.ConsolePrint(TAG, String.Format("ADL device added BusNumber:{0}  NAME:{1}  UUID:{2}"),
                                                                                budId,
                                                                                devName,
                                                                                uuid);
                                                                        } catch { }

                                                                        _amdDeviceUUID.Add(uuid);
                                                                        //_busIds.Add(OSAdapterInfoData.ADLAdapterInfo[i].BusNumber);
                                                                        _amdDeviceName.Add(devName);
                                                                        if (!_busIdsInfo.ContainsKey(budId)) {
                                                                            var nameUuid = new Tuple3<string, string, string>(devName, uuid, infSection);
                                                                            _busIdsInfo.Add(budId, nameUuid);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    } else {
                                                        Helpers.ConsolePrint(TAG, "ADL_Adapter_AdapterInfo_Get() returned error code " + ADLRet.ToString());
                                                        isAdlInit = false;
                                                    }
                                                }
                                                // Release the memory for the AdapterInfo structure
                                                if (IntPtr.Zero != AdapterBuffer)
                                                    Marshal.FreeCoTaskMem(AdapterBuffer);
                                            }
                                        }
                                        if (null != ADL.ADL_Main_Control_Destroy)
                                            ADL.ADL_Main_Control_Destroy();
                                    } else {
                                        // TODO
                                        Helpers.ConsolePrint(TAG, "ADL_Main_Control_Create() returned error code " + ADLRet.ToString());
                                        Helpers.ConsolePrint(TAG, "Check if ADL is properly installed!");
                                        isAdlInit = false;
                                    }
                                } catch (Exception ex) {
                                    Helpers.ConsolePrint(TAG, "AMD ADL exception: " + ex.Message);
                                    isAdlInit = false;
                                }

                                ///////
                                // AMD device creation (in NHM context)
                                if (isAdlInit && isBusID_OK) {
                                    Helpers.ConsolePrint(TAG, "Using AMD device creation DEFAULT Reliable mappings");
                                    if (amdGpus.Count == _amdDeviceUUID.Count) {
                                        Helpers.ConsolePrint(TAG, "AMD OpenCL and ADL AMD query COUNTS GOOD/SAME");
                                    } else {
                                        Helpers.ConsolePrint(TAG, "AMD OpenCL and ADL AMD query COUNTS DIFFERENT/BAD");
                                    }
                                    StringBuilder stringBuilder = new StringBuilder();
                                    stringBuilder.AppendLine("");
                                    stringBuilder.AppendLine("QueryAMD [DEFAULT query] devices: ");
                                    for (int i_id = 0; i_id < amdGpus.Count; ++i_id) {
                                        Avaliable.HasAMD = true;

                                        int busID = amdGpus[i_id].AMD_BUS_ID;
                                        if (busID != -1 && _busIdsInfo.ContainsKey(busID)) {
                                            var deviceName = _busIdsInfo[busID].Item1;
                                            var newAmdDev = new AmdGpuDevice(amdGpus[i_id], deviceDriverOld[deviceName], _busIdsInfo[busID].Item3);
                                            newAmdDev.DeviceName = deviceName;
                                            newAmdDev.UUID = _busIdsInfo[busID].Item2;
                                            bool isDisabledGroup = ConfigManager.GeneralConfig.DeviceDetection.DisableDetectionAMD;
                                            string skipOrAdd = isDisabledGroup ? "SKIPED" : "ADDED";
                                            string isDisabledGroupStr = isDisabledGroup ? " (AMD group disabled)" : "";
                                            string etherumCapableStr = newAmdDev.IsEtherumCapable() ? "YES" : "NO";

                                            Avaliable.AllAvaliableDevices.Add(
                                                new ComputeDevice(newAmdDev, ++GPUCount, false));
                                            // just in case
                                            try {
                                                stringBuilder.AppendLine(String.Format("\t{0} device{1}:", skipOrAdd, isDisabledGroupStr));
                                                stringBuilder.AppendLine(String.Format("\t\tID: {0}", newAmdDev.DeviceID.ToString()));
                                                stringBuilder.AppendLine(String.Format("\t\tNAME: {0}", newAmdDev.DeviceName));
                                                stringBuilder.AppendLine(String.Format("\t\tCODE_NAME: {0}", newAmdDev.Codename));
                                                stringBuilder.AppendLine(String.Format("\t\tUUID: {0}", newAmdDev.UUID));
                                                stringBuilder.AppendLine(String.Format("\t\tMEMORY: {0}", newAmdDev.DeviceGlobalMemory.ToString()));
                                                stringBuilder.AppendLine(String.Format("\t\tETHEREUM: {0}", etherumCapableStr));
                                            } catch { }
                                        } else {
                                            stringBuilder.AppendLine(String.Format("\tDevice not added, Bus No. {0} not found:", busID));
                                        }
                                    }
                                    Helpers.ConsolePrint(TAG, stringBuilder.ToString());
                                } else {
                                    Helpers.ConsolePrint(TAG, "Using AMD device creation FALLBACK UnReliable mappings");
                                    StringBuilder stringBuilder = new StringBuilder();
                                    stringBuilder.AppendLine("");
                                    stringBuilder.AppendLine("QueryAMD [FALLBACK query] devices: ");

                                    // get video AMD controllers and sort them by RAM
                                    // (find a way to get PCI BUS Numbers from PNPDeviceID)
                                    List<VideoControllerData> AMDVideoControllers = new List<VideoControllerData>();
                                    foreach (var vcd in AvaliableVideoControllers) {
                                        if (vcd.Name.ToLower().Contains("amd")
                                            || vcd.Name.ToLower().Contains("radeon")
                                            || vcd.Name.ToLower().Contains("firepro")) {
                                                AMDVideoControllers.Add(vcd);
                                        }
                                    }
                                    // sort by ram not ideal
                                    AMDVideoControllers.Sort((a, b) => (int)(a.AdapterRAM - b.AdapterRAM));
                                    amdGpus.Sort((a, b) => (int)(a._CL_DEVICE_GLOBAL_MEM_SIZE - b._CL_DEVICE_GLOBAL_MEM_SIZE));
                                    int minCount = Math.Min(AMDVideoControllers.Count, amdGpus.Count);

                                    for (int i = 0; i < minCount; ++i) {
                                        Avaliable.HasAMD = true;

                                        var deviceName = AMDVideoControllers[i].Name;
                                        if(AMDVideoControllers[i].InfSection == null) AMDVideoControllers[i].InfSection = "";
                                        var newAmdDev = new AmdGpuDevice(amdGpus[i], deviceDriverOld[deviceName], AMDVideoControllers[i].InfSection);
                                        newAmdDev.DeviceName = deviceName;
                                        newAmdDev.UUID = "UNUSED";
                                        bool isDisabledGroup = ConfigManager.GeneralConfig.DeviceDetection.DisableDetectionAMD;
                                        string skipOrAdd = isDisabledGroup ? "SKIPED" : "ADDED";
                                        string isDisabledGroupStr = isDisabledGroup ? " (AMD group disabled)" : "";
                                        string etherumCapableStr = newAmdDev.IsEtherumCapable() ? "YES" : "NO";

                                        Avaliable.AllAvaliableDevices.Add(
                                            new ComputeDevice(newAmdDev, ++GPUCount, true));
                                        // just in case
                                        try {
                                            stringBuilder.AppendLine(String.Format("\t{0} device{1}:", skipOrAdd, isDisabledGroupStr));
                                            stringBuilder.AppendLine(String.Format("\t\tID: {0}", newAmdDev.DeviceID.ToString()));
                                            stringBuilder.AppendLine(String.Format("\t\tNAME: {0}", newAmdDev.DeviceName));
                                            stringBuilder.AppendLine(String.Format("\t\tCODE_NAME: {0}", newAmdDev.Codename));
                                            stringBuilder.AppendLine(String.Format("\t\tUUID: {0}", newAmdDev.UUID));
                                            stringBuilder.AppendLine(String.Format("\t\tMEMORY: {0}", newAmdDev.DeviceGlobalMemory.ToString()));
                                            stringBuilder.AppendLine(String.Format("\t\tETHEREUM: {0}", etherumCapableStr));
                                        } catch { }
                                    }
                                    Helpers.ConsolePrint(TAG, stringBuilder.ToString());
                                }
                            }
                        } // end is amdPlatformNumFound
                    } // end is OpenCLSuccess
                    Helpers.ConsolePrint(TAG, "QueryAMD END");
                }