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);
        }
        private IEnumerable <Algorithm> GetSupportedAMDAlgorithms(AMDDevice dev)
        {
            const ulong minBeamMem = 4UL << 30;

            if (dev.GpuRam >= minBeamMem)
            {
                yield return(new Algorithm(PluginUUID, AlgorithmType.Beam));
            }
        }
        private static bool IsAMDDriverVersionValidFormat(AMDDevice amdDev)
        {
            var validCrimson = IsAMDCrimsonVersionValid(amdDev.RawDriverVersion);

            if (validCrimson && (amdDev.ADLReturnCode == 0 || amdDev.ADLReturnCode == 1))
            {
                return(true);
            }
            return(false);
        }
Example #4
0
        IReadOnlyList <Algorithm> GetAMDSupportedAlgorithms(AMDDevice gpu)
        {
            var algorithms = new List <Algorithm>
            {
                new Algorithm(PluginUUID, AlgorithmType.GrinCuckaroo29),
            };
            var filteredAlgorithms = Filters.FilterInsufficientRamAlgorithmsList(gpu.GpuRam, algorithms);

            return(filteredAlgorithms);
        }
        IReadOnlyList <Algorithm> GetSupportedAlgorithms(AMDDevice gpu)
        {
            var algorithms = new List <Algorithm> {
                new Algorithm(PluginUUID, AlgorithmType.CryptoNightR)
            };

            var filteredAlgorithms = Filters.FilterInsufficientRamAlgorithmsList(gpu.GpuRam, algorithms);

            return(filteredAlgorithms);
        }
 private static void AMDNonOKCodeNotification(AMDDevice amd)
 {
     if (amd.ADLReturnCode == 1)
     {
         AvailableNotifications.CreateADLVersionWarning(amd);
     }
     else
     {
         AvailableNotifications.CreateADLVersionError(amd);
     }
 }
        IReadOnlyList <Algorithm> GetSupportedAlgorithms(AMDDevice gpu)
        {
            var algorithms = new List <Algorithm> {
                new Algorithm(PluginUUID, AlgorithmType.CryptoNightR),
                new Algorithm(PluginUUID, AlgorithmType.Lyra2REv3),
                new Algorithm(PluginUUID, AlgorithmType.Lyra2Z),
                new Algorithm(PluginUUID, AlgorithmType.X16R),
            };

            return(algorithms);
        }
Example #8
0
        private List <Algorithm> GetSupportedAlgorithms(AMDDevice gpu)
        {
            var algorithms = PluginSupportedAlgorithms.GetSupportedAlgorithmsAMD(PluginUUID);

            if (PluginSupportedAlgorithms.UnsafeLimits(PluginUUID))
            {
                return(algorithms);
            }
            var filteredAlgorithms = Filters.FilterInsufficientRamAlgorithmsList(gpu.GpuRam, algorithms);

            return(filteredAlgorithms);
        }
Example #9
0
        public static async Task <List <AMDDevice> > TryQueryAMDDevicesAsync(List <VideoControllerData> availableVideoControllers)
        {
            var amdDevices = new List <AMDDevice>();

            Logger.Info(Tag, "TryQueryAMDDevicesAsync START");
            var openCLResult = await OpenCLDetector.TryQueryOpenCLDevicesAsync();

            Logger.Info(Tag, $"TryQueryOpenCLDevicesAsync RAW: '{openCLResult.rawOutput}'");

            var result = openCLResult.parsed;

            if (result?.Platforms?.Count > 0)
            {
                var amdPlatforms = result.Platforms.Where(platform => IsAMDPlatform(platform)).ToList();
                foreach (var platform in amdPlatforms)
                {
                    var platformNum = platform.PlatformNum;
                    if (platform.Devices.Count > 0)
                    {
                        AMDDevice.GlobalOpenCLPlatformID = platformNum;
                    }
                    foreach (var oclDev in platform.Devices)
                    {
                        var infSection   = "";
                        var name         = oclDev._CL_DEVICE_BOARD_NAME_AMD;
                        var codename     = oclDev._CL_DEVICE_NAME;
                        var gpuRAM       = oclDev._CL_DEVICE_GLOBAL_MEM_SIZE;
                        var infoToHashed = $"{oclDev.DeviceID}--{DeviceType.AMD}--{gpuRAM}--{codename}--{name}";
                        // cross ref info from vid controllers with bus id
                        var vidCtrl = availableVideoControllers?.Where(vid => vid.PCI_BUS_ID == oclDev.AMD_BUS_ID).FirstOrDefault() ?? null;
                        if (vidCtrl != null)
                        {
                            infSection    = vidCtrl.InfSection;
                            infoToHashed += vidCtrl.PnpDeviceID;
                        }
                        else
                        {
                            Logger.Info(Tag, $"TryQueryAMDDevicesAsync cannot find VideoControllerData with bus ID {oclDev.AMD_BUS_ID}");
                        }
                        var uuidHEX = UUID.GetHexUUID(infoToHashed);
                        var uuid    = $"AMD-{uuidHEX}";

                        var bd        = new BaseDevice(DeviceType.AMD, uuid, name, (int)oclDev.DeviceID);
                        var amdDevice = new AMDDevice(bd, oclDev.AMD_BUS_ID, gpuRAM, codename, infSection, platformNum);
                        amdDevices.Add(amdDevice);
                    }
                }
            }
            Logger.Info(Tag, "TryQueryAMDDevicesAsync END");

            return(amdDevices);
        }
Example #10
0
        /// <summary>
        /// Get whether AMD device is GCN 2th gen or higher (300/400/500/Vega)
        /// </summary>
        public static bool IsGcn2(AMDDevice dev)
        {
            if (dev.Name.Contains("Vega") || dev.InfSection.ToLower().Contains("r7500") || dev.InfSection.ToLower().Contains("vega"))
            {
                return(true);
            }
            if (!dev.InfSection.ToLower().Contains("pitcairn ") && !dev.InfSection.ToLower().Contains("tahiti") && !dev.InfSection.ToLower().Contains("oland") && !dev.InfSection.ToLower().Contains("cape verde"))
            {
                return(true);
            }

            return(false);
        }
Example #11
0
        private IEnumerable <Algorithm> GetAMDSupportedAlgorithms(AMDDevice gpu)
        {
            var algorithms = new List <Algorithm>
            {
                new Algorithm(PluginUUID, AlgorithmType.Beam)
                {
                    Enabled = false
                },
            };
            var filteredAlgorithms = Filters.FilterInsufficientRamAlgorithmsList(gpu.GpuRam, algorithms);

            return(filteredAlgorithms);
        }
Example #12
0
        /// <summary>
        /// Get whether AMD device is GCN 4th gen or higher (400/500/Vega)
        /// </summary>
        public static bool IsGcn4(AMDDevice dev)
        {
            if (dev.Name.Contains("Vega"))
            {
                return(true);
            }
            if (dev.InfSection.ToLower().Contains("polaris"))
            {
                return(true);
            }

            return(false);
        }
        IReadOnlyList <Algorithm> GetAMDSupportedAlgorithms(AMDDevice gpu)
        {
            var algorithms = new List <Algorithm>
            {
                new Algorithm(PluginUUID, AlgorithmType.CuckooCycle)
                {
                    Enabled = false
                },                                                                       //~5% of invalid nonce shares
                new Algorithm(PluginUUID, AlgorithmType.BeamV2),
            };
            var filteredAlgorithms = Filters.FilterInsufficientRamAlgorithmsList(gpu.GpuRam, algorithms);

            return(filteredAlgorithms);
        }
Example #14
0
        /// <summary>
        /// Get whether AMD device is GCN 4th gen or higher (400/500/Vega)
        /// </summary>
        public static bool IsGcn4(AMDDevice dev)
        {
            var oldCodeNames = new List <string> {
                /*Gen1*/ "oland", "cape verde", "pitcairn", "tahiti",
                /*Gen2*/ "bonaire", "hawaii", "temash", "kabini", "liverpool", "durango", "kaveri", "godavari", "mullins", "beema", "carrizo-L",
                /*Gen3*/ "tonga", "fiji", "carrizo", "bristol ridge", "stoney ridge"
            };

            if (oldCodeNames.Contains(dev.InfSection.ToLower()))
            {
                return(false);
            }

            return(true);
        }
Example #15
0
        IReadOnlyList <Algorithm> GetSupportedAlgorithms(AMDDevice gpu)
        {
            var algorithms = new List <Algorithm> {
                new Algorithm(PluginUUID, AlgorithmType.CryptoNightR),
                new Algorithm(PluginUUID, AlgorithmType.Lyra2REv3),
                new Algorithm(PluginUUID, AlgorithmType.Lyra2Z),
                new Algorithm(PluginUUID, AlgorithmType.X16R),
                new Algorithm(PluginUUID, AlgorithmType.GrinCuckatoo31),
                new Algorithm(PluginUUID, AlgorithmType.MTP)
                {
                    Enabled = false
                }
            };

            var filteredAlgorithms = Filters.FilterInsufficientRamAlgorithmsList(gpu.GpuRam, algorithms);

            return(filteredAlgorithms);
        }
Example #16
0
        public static async Task <List <AMDDevice> > TryQueryAMDDevicesAsync(List <VideoControllerData> availableVideoControllers)
        {
            var amdDevices = new List <AMDDevice>();

            Logger.Info(Tag, "TryQueryAMDDevicesAsync START");
            var openCLResult = await OpenCLDetector.TryQueryOpenCLDevicesAsync();

            Logger.Info(Tag, $"TryQueryOpenCLDevicesAsync RAW: '{openCLResult.rawOutput}'");


            OpenCLDeviceDetectionResult result = null;

            // check if we have duplicated platforms
            Logger.Info(Tag, "Checking duplicate devices...");
            if (DuplicatedDevices(openCLResult.parsed))
            {
                Logger.Info(Tag, "Found duplicate devices. Trying fallback detection");
                var openCLResult2 = await OpenCLDetector.TryQueryOpenCLDevicesAsyncFallback();

                Logger.Info(Tag, $"TryQueryOpenCLDevicesAsyncFallback RAW: '{openCLResult2.rawOutput}'");
                if (DuplicatedDevices(openCLResult2.parsed))
                {
                    Logger.Info(Tag, $"TryQueryOpenCLDevicesAsyncFallback has duplicate files as well... Taking filtering lower platform devices");
                    // #3 try merging both results and take lower platform unique devices
                    result = MergeResults(openCLResult.parsed, openCLResult2.parsed);
                }
                else
                {
                    // #2 try good
                    result = openCLResult2.parsed;
                }
            }
            else
            {
                // #1 try good
                result = openCLResult.parsed;
            }

            if (result?.Platforms?.Count > 0)
            {
                Platforms = result.Platforms;
                var amdPlatforms = result.Platforms.Where(platform => IsAMDPlatform(platform)).ToList();
                foreach (var platform in amdPlatforms)
                {
                    var platformNum = platform.PlatformNum;
                    foreach (var oclDev in platform.Devices)
                    {
                        var infSection   = "";
                        var name         = oclDev._CL_DEVICE_BOARD_NAME_AMD;
                        var codename     = oclDev._CL_DEVICE_NAME;
                        var gpuRAM       = oclDev._CL_DEVICE_GLOBAL_MEM_SIZE;
                        var infoToHashed = $"{oclDev.DeviceID}--{DeviceType.AMD}--{gpuRAM}--{codename}--{name}";
                        // cross ref info from vid controllers with bus id
                        var vidCtrl = availableVideoControllers?.Where(vid => vid.PCI_BUS_ID == oclDev.BUS_ID).FirstOrDefault() ?? null;
                        if (vidCtrl != null)
                        {
                            infSection    = vidCtrl.InfSection;
                            infoToHashed += vidCtrl.PnpDeviceID;
                        }
                        else
                        {
                            Logger.Info(Tag, $"TryQueryAMDDevicesAsync cannot find VideoControllerData with bus ID {oclDev.BUS_ID}");
                        }
                        var uuidHEX = UUID.GetHexUUID(infoToHashed);
                        var uuid    = $"AMD-{uuidHEX}";

                        var bd        = new BaseDevice(DeviceType.AMD, uuid, name, (int)oclDev.DeviceID);
                        var amdDevice = new AMDDevice(bd, oclDev.BUS_ID, gpuRAM, codename, infSection, platformNum);
                        amdDevices.Add(amdDevice);
                    }
                }
            }
            Logger.Info(Tag, "TryQueryAMDDevicesAsync END");

            return(amdDevices);
        }
Example #17
0
        public static async Task <List <AMDDevice> > TryQueryAMDDevicesAsync(List <VideoControllerData> availableVideoControllers)
        {
            var amdDevices = new List <AMDDevice>();

            Logger.Info(Tag, "TryQueryAMDDevicesAsync START");
            var openCLResult = await OpenCLDetector.TryQueryOpenCLDevicesAsync();

            Logger.Info(Tag, $"TryQueryOpenCLDevicesAsync RAW: '{openCLResult.rawOutput}'");


            OpenCLDeviceDetectionResult result = null;

            // check if we have duplicated platforms
            Logger.Info(Tag, "Checking duplicate devices...");
            if (DuplicatedDevices(openCLResult.parsed))
            {
                Logger.Info(Tag, "Found duplicate devices. Trying fallback detection");
                var openCLResult2 = await OpenCLDetector.TryQueryOpenCLDevicesAsyncFallback();

                Logger.Info(Tag, $"TryQueryOpenCLDevicesAsyncFallback RAW: '{openCLResult2.rawOutput}'");
                IsOpenClFallback = true;
                if (DuplicatedDevices(openCLResult2.parsed))
                {
                    Logger.Info(Tag, $"TryQueryOpenCLDevicesAsyncFallback has duplicate files as well... Taking filtering lower platform devices");
                    // #3 try merging both results and take lower platform unique devices
                    result = MergeResults(openCLResult.parsed, openCLResult2.parsed);
                }
                else
                {
                    // #2 try good
                    result = openCLResult2.parsed;
                }
            }
            else
            {
                // #1 try good
                result = openCLResult.parsed;
            }

            if (result?.Platforms?.Count > 0)
            {
                Platforms = result.Platforms;
                var amdPlatforms = result.Platforms.Where(platform => IsAMDPlatform(platform)).ToList();
                foreach (var platform in amdPlatforms)
                {
                    var platformNum = platform.PlatformNum;
                    foreach (var oclDev in platform.Devices)
                    {
                        var infSection      = "";
                        var name            = oclDev._CL_DEVICE_BOARD_NAME_AMD;
                        var codename        = oclDev._CL_DEVICE_NAME;
                        var gpuRAM          = oclDev._CL_DEVICE_GLOBAL_MEM_SIZE;
                        var infoToHashedNew = $"{oclDev.DeviceID}--{oclDev.BUS_ID}--{DeviceType.AMD}--{codename}--{name}";
                        var infoToHashedOld = $"{oclDev.DeviceID}--{DeviceType.AMD}--{gpuRAM}--{codename}--{name}";
                        // cross ref info from vid controllers with bus id
                        var vidCtrl = availableVideoControllers?.Where(vid => vid.PCI_BUS_ID == oclDev.BUS_ID).FirstOrDefault() ?? null;
                        if (vidCtrl != null)
                        {
                            infSection       = vidCtrl.InfSection;
                            infoToHashedOld += vidCtrl.PnpDeviceID;
                            infoToHashedNew += vidCtrl.PnpDeviceID;
                        }
                        else
                        {
                            Logger.Info(Tag, $"TryQueryAMDDevicesAsync cannot find VideoControllerData with bus ID {oclDev.BUS_ID}");
                        }
                        var uuidHEXOld = UUID.GetHexUUID(infoToHashedOld);
                        var uuidHEXNew = UUID.GetHexUUID(infoToHashedNew);
                        var uuidOld    = $"AMD-{uuidHEXOld}";
                        var uuidNew    = $"AMD-{uuidHEXNew}";
                        // append VRAM to distinguish AMD GPUs

                        //transition from old uuid's to new
                        try
                        {
                            var cfgPathOld = Paths.ConfigsPath($"device_settings_{uuidOld}.json");
                            var cfgPathNew = Paths.ConfigsPath($"device_settings_{uuidNew}.json");
                            if (File.Exists(cfgPathOld) && !File.Exists(cfgPathNew))//rename file and rename first line
                            {
                                string configText = File.ReadAllText(cfgPathOld);
                                configText = configText.Replace(uuidOld, uuidNew);
                                File.WriteAllText(cfgPathNew, configText);
                                File.Delete(cfgPathOld);
                            }
                        }
                        catch (Exception e)
                        {
                            Logger.Info(Tag, $"Error when transitioning from old to new AMD GPU config file. " + e.Message);
                        }

                        var vramPart  = convertSize(gpuRAM);
                        var setName   = vramPart != null ? $"{name} {vramPart}" : name;
                        var bd        = new BaseDevice(DeviceType.AMD, uuidNew, setName, (int)oclDev.DeviceID);
                        var amdDevice = new AMDDevice(bd, oclDev.BUS_ID, gpuRAM, codename, infSection, platformNum);
                        var thisDeviceExtraADLResult = result.AMDBusIDVersionPairs.FirstOrDefault(ver => ver.BUS_ID == oclDev.BUS_ID);
                        if (thisDeviceExtraADLResult != null && thisDeviceExtraADLResult.BUS_ID == oclDev.BUS_ID)
                        {
                            amdDevice.ADLFunctionCall  = thisDeviceExtraADLResult.FunctionCall;
                            amdDevice.ADLReturnCode    = thisDeviceExtraADLResult.ADLRetCode;
                            amdDevice.RawDriverVersion = thisDeviceExtraADLResult.AdrenalinVersion;
                            if (Version.TryParse(thisDeviceExtraADLResult.AdrenalinVersion, out var parsedVer))
                            {
                                amdDevice.DEVICE_AMD_DRIVER = parsedVer;
                            }
                        }
                        amdDevices.Add(amdDevice);
                    }
                }
            }
            Logger.Info(Tag, "TryQueryAMDDevicesAsync END");

            return(amdDevices);
        }