private static string GetDeviceAlgorithmVersionKey(AlgorithmContainer algorithmContainer) { var deviceUUID = algorithmContainer.ComputeDevice.Uuid; var algoStrId = algorithmContainer.AlgorithmStringID; var version = $"{algorithmContainer.PluginVersion.Major}.{algorithmContainer.PluginVersion.Minor}"; return $"{deviceUUID}-{algoStrId}-{version}"; }
internal void AddAlgorithmContainer(AlgorithmContainer algorithmContainer) { lock (_lock) { algorithmContainer.PropertyChanged += AlgorithmContainerOnPropertyChanged; SetStatus(algorithmContainer); } }
private async Task BenchmarkAlgorithm(AlgorithmContainer algo, CancellationToken stop) { var miningLocation = StratumService.Instance.SelectedOrFallbackServiceLocationCode().miningLocationCode; // TODO hidden issue here if our market is not available we will not be able to execute benchmarks // unable to benchmark service locations are not operational if (miningLocation == null) { return; } using (var powerHelper = new PowerHelper(algo.ComputeDevice)) { var plugin = algo.PluginContainer; var miner = plugin.CreateMiner(); var miningPair = new NHM.MinerPlugin.MiningPair { Device = algo.ComputeDevice.BaseDevice, Algorithm = algo.Algorithm }; // check ethlargement var miningPairs = new List <NHM.MinerPlugin.MiningPair> { miningPair }; EthlargementIntegratedPlugin.Instance.Start(miningPairs); miner.InitMiningPairs(miningPairs); // fill service since the benchmark might be online. DemoUser.BTC must be used miner.InitMiningLocationAndUsername(miningLocation, DemoUser.BTC); powerHelper.Start(); algo.ComputeDevice.State = DeviceState.Benchmarking; var result = await miner.StartBenchmark(stop, PerformanceType); if (stop.IsCancellationRequested) { return; } algo.IsReBenchmark = false; //EthlargementIntegratedPlugin.Instance.Stop(miningPairs); // TODO check stopping var power = powerHelper.Stop(); if (result.Success || result.AlgorithmTypeSpeeds?.Count > 0) { var ids = result.AlgorithmTypeSpeeds.Select(ats => ats.type).ToList(); var speeds = result.AlgorithmTypeSpeeds.Select(ats => ats.speed).ToList(); algo.Speeds = speeds; algo.PowerUsage = power; ConfigManager.CommitBenchmarksForDevice(algo.ComputeDevice); } else { // mark it as failed algo.LastBenchmarkingFailed = true; // add new failed list _benchmarkFailedAlgo.Add(algo.AlgorithmName); algo.SetBenchmarkError(result.ErrorMessage); } } }
private async Task BenchmarkAlgorithm(AlgorithmContainer algo, CancellationToken stop) { using (var powerHelper = new PowerHelper(algo.ComputeDevice)) { var plugin = algo.PluginContainer; var miner = plugin.CreateMiner(); var miningPair = new NHM.MinerPlugin.MiningPair { Device = algo.ComputeDevice.BaseDevice, Algorithm = algo.Algorithm }; // check ethlargement var miningPairs = new List <NHM.MinerPlugin.MiningPair> { miningPair }; EthlargementIntegratedPlugin.Instance.Start(miningPairs); miner.InitMiningPairs(miningPairs); // fill service since the benchmark might be online. DemoUser.BTC must be used miner.InitMiningLocationAndUsername(StratumService.Instance.SelectedServiceLocation, DemoUser.BTC); powerHelper.Start(); algo.ComputeDevice.State = DeviceState.Benchmarking; var result = await miner.StartBenchmark(stop, PerformanceType); if (stop.IsCancellationRequested) { return; } algo.IsReBenchmark = false; //EthlargementIntegratedPlugin.Instance.Stop(miningPairs); // TODO check stopping var power = powerHelper.Stop(); if (result.Success || result.AlgorithmTypeSpeeds?.Count > 0) { var ids = result.AlgorithmTypeSpeeds.Select(ats => ats.type).ToList(); var speeds = result.AlgorithmTypeSpeeds.Select(ats => ats.speed).ToList(); algo.Speeds = speeds; algo.PowerUsage = power; // set status to empty string it will return speed BenchmarkManager.SetCurrentStatus(algo.ComputeDevice, algo, ""); ConfigManager.CommitBenchmarksForDevice(algo.ComputeDevice); } else { // mark it as failed algo.LastBenchmarkingFailed = true; // add new failed list _benchmarkFailedAlgo.Add(algo.AlgorithmName); algo.SetBenchmarkError(result.ErrorMessage); BenchmarkManager.SetCurrentStatus(algo.ComputeDevice, algo, result.ErrorMessage); } } }
private void AlgorithmItem_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if (e.NewValue is AlgorithmContainer algorithmContainer) { _algorithmContainer = algorithmContainer; AlgorithmSettingsContextMenu.DataContext = e.NewValue; #if USE_MODAL _algorithmSettings.DataContext = e.NewValue; #endif return; } throw new Exception("unsupported datacontext type"); }
private static bool CanGroupAlgorithmContainer(AlgorithmContainer a, AlgorithmContainer b) { // must be from the same plugin container instance (same miner binary) if (a.PluginContainer != b.PluginContainer) { return(false); } // never group same devices if (a.ComputeDevice.Uuid == b.ComputeDevice.Uuid) { return(false); } return(a.PluginContainer.CanGroupAlgorithmContainer(a, b)); }
private static bool ShouldBenchmark(AlgorithmContainer algo, BenchmarkOption benchmarkOption) { switch (benchmarkOption) { case BenchmarkOption.ZeroOnly: return(algo.BenchmarkNeeded); case BenchmarkOption.ReBecnhOnly: return(algo.IsReBenchmark); case BenchmarkOption.ZeroOrReBenchOnly: return(algo.BenchmarkNeeded || algo.IsReBenchmark); } return(true); }
public AlgorithmSettings() { InitializeComponent(); DataContextChanged += (s, e) => { if (e.NewValue is AlgorithmContainer algorithmContainer) { _algorithmContainer = algorithmContainer; secondarySpeedPanel.Visibility = _algorithmContainer.IsDual ? Visibility.Visible : Visibility.Collapsed; ToggleButtonHidden.Visibility = _algorithmContainer.HasBenchmark ? Visibility.Visible : Visibility.Collapsed; _algorithmContainer.PropertyChanged += _algorithmContainer_PropertyChanged; return; } throw new Exception("unsupported datacontext type"); }; }
public void SetCurrentlySelected(ListViewItem lvi, ComputeDevice computeDevice) { // should not happen ever if (lvi == null) { return; } _computeDevice = computeDevice; if (lvi.Tag is AlgorithmContainer algorithm) { _selected = true; _currentlySelectedAlgorithm = algorithm; _currentlySelectedLvi = lvi; Enabled = lvi.Checked && !IsInBenchmark; var selectedAlgoName = $"{algorithm.AlgorithmName} ({algorithm.MinerBaseTypeName})"; groupBoxSelectedAlgorithmSettings.Text = string.Format( Translations.Tr("Selected Algorithm: {0}"), ""); // keep the translation labelSelectedAlgorithm.Text = selectedAlgoName; field_PowerUsage.EntryText = ParseDoubleDefault(algorithm.PowerUsage); var unit = algorithm.IDs[0].GetUnitPerSecond(); fieldBoxBenchmarkSpeed.LabelText = Translations.Tr("Benchmark Speed") + $" ({unit}):"; fieldBoxBenchmarkSpeed.EntryText = ParseDoubleDefault(algorithm.BenchmarkSpeed); richTextBoxExtraLaunchParameters.Text = ParseStringDefault(algorithm.ExtraLaunchParameters); if (algorithm.IsDual) { var secondaryUnit = algorithm.IDs[1].GetUnitPerSecond(); secondaryFieldBoxBenchmarkSpeed.LabelText = Translations.Tr("Secondary Benchmark Speed") + $" ({secondaryUnit}):"; secondaryFieldBoxBenchmarkSpeed.EntryText = ParseDoubleDefault(algorithm.SecondaryBenchmarkSpeed); secondaryFieldBoxBenchmarkSpeed.Enabled = true; } else { secondaryFieldBoxBenchmarkSpeed.LabelText = Translations.Tr("Secondary Benchmark Speed") + ":"; secondaryFieldBoxBenchmarkSpeed.EntryText = ""; secondaryFieldBoxBenchmarkSpeed.Enabled = false; } Update(); } else { // TODO this should not be null } }
private void SetStatus(AlgorithmContainer algorithmContainer) { lock (_lock) { var key = GetDeviceAlgorithmVersionKey(algorithmContainer); _algorithmsBenchmarksStates[key] = _benchmarkStatuses.Contains(algorithmContainer.Status) && algorithmContainer.ComputeDevice.Enabled; _algorithmsCanStartStates[key] = _startStatuses.Contains(algorithmContainer.Status) && algorithmContainer.ComputeDevice.Enabled; _benchmarksPending = _algorithmsBenchmarksStates.Values.Where(benchStatus => benchStatus).Count(); _canStartCount = _algorithmsCanStartStates.Values.Where(canStartStatus => canStartStatus).Count(); OnPropertyChanged(nameof(BenchmarksPending)); OnPropertyChanged(nameof(HasBenchmarkWork)); OnPropertyChanged(nameof(CanStart)); var anyToBench = _algorithmsBenchmarksStates.Where(benchStatus => benchStatus.Key.Contains(algorithmContainer.ComputeDevice.Uuid)).Where(pair => pair.Value).Count(); _deviceCanStartBenchmarkingStates[algorithmContainer.ComputeDevice.Uuid] = algorithmContainer.ComputeDevice.State == DeviceState.Stopped && anyToBench > 0; OnPropertyChanged(nameof(CanStartBenchmarking)); } }
public override void PrintView() { var metricsPath = Path.Combine(Path.Combine(Simulation.Params.CurrentSimulationLoggerPath, @"algorithmMetrics.csv")); var algorithmsLogger = new Logger.Logger(new FileRecorder(Path.Combine(Path.Combine(Simulation.Params.CurrentSimulationLoggerPath, @"algorithms.csv")))); var dataSetLogger = new Logger.Logger(new FileRecorder(Path.Combine(Simulation.Params.CurrentSimulationLoggerPath, @"algorithmsDataset.csv"), "DataModelId,CustomersNumber,VehicleNumber,MaxRideTimeDurationInMinutes,MaxAllowedUpperBoundLimitInMinutes,Seed")); var vehicleNumber = 20; var count = 0; //var algorithmsMetrics = new AlgorithmMetrics(); Simulation.Params.VehicleNumber = vehicleNumber; for (int customersNumber = 25; customersNumber <= 100; customersNumber = customersNumber + 25) { Simulation.Params.NumberInitialRequests = customersNumber; for (int i = 0; i < 10; i++) // tests 10 different data models { bool allowDropNodes = false; RandomNumberGenerator.GenerateNewRandomSeed(); var dataModel = DataModelFactory.Instance().CreateInitialSimulationDataModel(allowDropNodes, Simulation); var printableList = dataModel.GetSettingsPrintableList(); ConsoleLogger.Log(printableList); dataSetLogger.Log(dataModel.GetCSVSettingsMessage()); for (int searchTime = 5; searchTime <= 90; searchTime = searchTime + 5) //test different same datamodel with different search times { AlgorithmContainer algorithmContainer = new AlgorithmContainer(); foreach (var searchAlgorithm in algorithmContainer.SearchAlgorithms) { var algorithm = new SearchAlgorithm(searchAlgorithm, searchTime); algorithm.Test(dataModel, allowDropNodes); ConsoleLogger.Log(algorithm.GetResultPrintableList()); if (count == 0) { //logs base message type style algorithmsLogger.Log(algorithm.GetCSVMessageStyle()); } algorithmsLogger.Log(algorithm.GetCSVResultsMessage()); count++; } } } } //algorithmsMetrics.SaveMetrics(metricsPath); }
internal void RemoveAlgorithmContainer(AlgorithmContainer algorithmContainer) { lock (_lock) { algorithmContainer.PropertyChanged -= AlgorithmContainerOnPropertyChanged; var key = GetDeviceAlgorithmVersionKey(algorithmContainer); _algorithmsBenchmarksStates.Remove(key); _algorithmsCanStartStates.Remove(key); _benchmarksPending = _algorithmsBenchmarksStates.Values.Where(benchStatus => benchStatus).Count(); _canStartCount = _algorithmsCanStartStates.Values.Where(canStartStatus => canStartStatus).Count(); OnPropertyChanged(nameof(BenchmarksPending)); OnPropertyChanged(nameof(HasBenchmarkWork)); OnPropertyChanged(nameof(CanStart)); var anyToBench = _algorithmsBenchmarksStates.Where(benchStatus => benchStatus.Key.Contains(algorithmContainer.ComputeDevice.Uuid)).Where(pair => pair.Value).Count(); _deviceCanStartBenchmarkingStates[algorithmContainer.ComputeDevice.Uuid] = algorithmContainer.ComputeDevice.State == DeviceState.Stopped && anyToBench > 0; OnPropertyChanged(nameof(CanStartBenchmarking)); } }
private async Task BenchmarkAlgorithm(AlgorithmContainer algo) { BenchmarkManager.AddToStatusCheck(Device, algo); var plugin = algo.PluginContainer; var miner = plugin.CreateMiner(); var miningPair = new MinerPlugin.MiningPair { Device = Device.BaseDevice, Algorithm = algo.Algorithm }; // check ethlargement var miningPairs = new List <MinerPlugin.MiningPair> { miningPair }; EthlargementIntegratedPlugin.Instance.Start(miningPairs); miner.InitMiningPairs(miningPairs); // fill service since the benchmark might be online. DemoUser.BTC must be used miner.InitMiningLocationAndUsername(StratumService.SelectedServiceLocation, DemoUser.BTC); _powerHelper.Start(); var result = await miner.StartBenchmark(_stopBenchmark.Token, _performanceType); //EthlargementIntegratedPlugin.Instance.Stop(miningPairs); // TODO check stopping var power = _powerHelper.Stop(); if (result.Success || result.AlgorithmTypeSpeeds?.Count > 0) { var ids = result.AlgorithmTypeSpeeds.Select(ats => ats.AlgorithmType).ToList(); var speeds = result.AlgorithmTypeSpeeds.Select(ats => ats.Speed).ToList(); algo.Speeds = speeds; algo.PowerUsage = power; // set status to empty string it will return speed algo.ClearBenchmarkPending(); BenchmarkManager.SetCurrentStatus(Device, algo, ""); } else { // add new failed list _benchmarkFailedAlgo.Add(algo.AlgorithmName); algo.SetError(result.ErrorMessage); algo.ClearBenchmarkPending(); BenchmarkManager.SetCurrentStatus(Device, algo, result.ErrorMessage); } }
private async Task Benchmark() { AlgorithmContainer currentAlgorithm = null; while (_benchmarkAlgorithmQueue.Count > 0) { try { if (_stopBenchmark.IsCancellationRequested) { break; } currentAlgorithm = _benchmarkAlgorithmQueue.Dequeue(); BenchmarkManager.AddToStatusCheck(Device, currentAlgorithm); currentAlgorithm.InBenchmark = true; await BenchmarkAlgorithm(currentAlgorithm); currentAlgorithm.InBenchmark = false; await Task.Delay(ConfigManager.GeneralConfig.MinerRestartDelayMS); if (_stopBenchmark.IsCancellationRequested) { break; } currentAlgorithm.IsReBenchmark = false; BenchmarkManager.StepUpBenchmarkStepProgress(); ConfigManager.CommitBenchmarksForDevice(Device); } catch (Exception e) { Logger.Error("BenchmarkHandler", $"Exception occurred in benchmark task: {e.Message}"); } } currentAlgorithm?.ClearBenchmarkPending(); var cancel = _stopBenchmark.IsCancellationRequested; // don't show unbenchmarked algos if user canceled var showFailed = _benchmarkFailedAlgo.Count > 0 && !cancel; var startMining = _startMiningAfterBenchmark && !cancel; BenchmarkManager.EndBenchmarkForDevice(Device, showFailed, startMining); }
public static object[] GetAlgorithmRowData(AlgorithmContainer a) { object[] rowData = { a.Enabled, a.AlgorithmName, a.MinerBaseTypeName }; return(rowData); }
public static bool IsAlgoMiningCapable(AlgorithmContainer algo) { return(algo != null && algo.Enabled && algo.BenchmarkSpeed > 0); }
private static bool IsCurrentWithinGroup(AlgorithmContainer current, List <AlgorithmContainer> group) => group.Any(p => p.ComputeDevice.Uuid == current.ComputeDevice.Uuid);
public BenchAlgo(AlgorithmContainer algo) { Algo = algo; Algo.PropertyChanged += AlgoOnPropertyChanged; }
} = BenchmarkPerformanceType.Standard; // TODO TEMP private async Task <object> BenchmarkAlgorithm(AlgorithmContainer algo, CancellationToken stop) { if (algo == null) { Logger.Error("BenchmarkingComputeDeviceHandler.BenchmarkNextAlgorithm", $"TakeNextAlgorithm returned null"); return(false); } bool ret = false; var miningPairs = new List <MiningPair> { algo.ToMiningPair() }; try { algo.IsBenchmarking = true; using (var powerHelper = new PowerHelper(algo.ComputeDevice)) { var plugin = algo.PluginContainer; var miner = plugin.CreateMiner(); GPUProfileManager.Instance.Start(miningPairs); miner.InitMiningPairs(miningPairs); // fill service since the benchmark might be online. DemoUser.BTC must be used miner.InitMiningLocationAndUsername("auto", DemoUser.BTC); powerHelper.Start(); algo.ComputeDevice.State = DeviceState.Benchmarking; var result = await miner.StartBenchmark(stop, BenchmarkManagerState.Instance.SelectedBenchmarkType); GPUProfileManager.Instance.Stop(miningPairs); if (stop.IsCancellationRequested) { return(false); } algo.IsReBenchmark = false; var power = powerHelper.Stop(); ret = result.Success || result.AlgorithmTypeSpeeds?.Count > 0; if (ret) { algo.Speeds = result.AlgorithmTypeSpeeds.Select(ats => ats.speed).ToList(); algo.PowerUsage = power; ConfigManager.CommitBenchmarksForDevice(algo.ComputeDevice); } else { // mark it as failed algo.LastBenchmarkingFailed = true; algo.SetBenchmarkError(result.ErrorMessage); } } } finally { GPUProfileManager.Instance.Stop(miningPairs); algo.ClearBenchmarkPending(); algo.IsBenchmarking = false; } return(ret); }
} = BenchmarkPerformanceType.Standard; // TODO TEMP private async Task <object> BenchmarkAlgorithm(AlgorithmContainer algo, CancellationToken stop) { if (algo == null) { Logger.Error("BenchmarkingComputeDeviceHandler.BenchmarkNextAlgorithm", $"TakeNextAlgorithm returned null"); return(false); } // TODO here you got shity state var miningLocation = StratumService.Instance.SelectedOrFallbackServiceLocationCode().miningLocationCode; // TODO hidden issue here if our market is not available we will not be able to execute benchmarks // unable to benchmark service locations are not operational if (miningLocation == null) { return(false); } bool ret = false; var miningPairs = new List <MiningPair> { algo.ToMiningPair() }; try { algo.IsBenchmarking = true; using (var powerHelper = new PowerHelper(algo.ComputeDevice)) { var plugin = algo.PluginContainer; var miner = plugin.CreateMiner(); // check ethlargement EthlargementIntegratedPlugin.Instance.Start(miningPairs); miner.InitMiningPairs(miningPairs); // fill service since the benchmark might be online. DemoUser.BTC must be used miner.InitMiningLocationAndUsername(miningLocation, DemoUser.BTC); powerHelper.Start(); algo.ComputeDevice.State = DeviceState.Benchmarking; var result = await miner.StartBenchmark(stop, PerformanceType); EthlargementIntegratedPlugin.Instance.Stop(miningPairs); if (stop.IsCancellationRequested) { return(false); } algo.IsReBenchmark = false; var power = powerHelper.Stop(); ret = result.Success || result.AlgorithmTypeSpeeds?.Count > 0; if (ret) { algo.Speeds = result.AlgorithmTypeSpeeds.Select(ats => ats.speed).ToList(); algo.PowerUsage = power; ConfigManager.CommitBenchmarksForDevice(algo.ComputeDevice); } else { // mark it as failed algo.LastBenchmarkingFailed = true; algo.SetBenchmarkError(result.ErrorMessage); } } } finally { EthlargementIntegratedPlugin.Instance.Stop(miningPairs); algo.ClearBenchmarkPending(); algo.IsBenchmarking = false; } return(ret); }
public bool CanGroupAlgorithmContainer(AlgorithmContainer a, AlgorithmContainer b) { return(CanGroup(a.ToMiningPair(), b.ToMiningPair())); }
internal static void SetCurrentStatus(ComputeDevice dev, AlgorithmContainer algo, string status) { //var args = new AlgoStatusEventArgs(dev, algo, status); // TODO append to NotificationInfo instance //OnAlgoStatusUpdate?.Invoke(null, args); }