From 0da7bc7ed28c6d24217029c8c730e382382d88e6 Mon Sep 17 00:00:00 2001 From: phooton Date: Fri, 11 Jan 2019 17:09:28 +0100 Subject: [PATCH 1/2] Added fast CUDA mode, console improvement --- src/CudaSolver/Comms.cs | 2 ++ src/CudaSolver/Program.cs | 18 +++++++++++++++++- src/GrinGoldMinerCLI/Program.cs | 24 +++++++++++++++++++++--- src/Master/Logging.cs | 4 ++++ src/Master/Worker.cs | 6 +++--- src/SharedSerialization/Comm.cs | 3 ++- 6 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/CudaSolver/Comms.cs b/src/CudaSolver/Comms.cs index f4b10df..99646d3 100644 --- a/src/CudaSolver/Comms.cs +++ b/src/CudaSolver/Comms.cs @@ -28,6 +28,7 @@ public class Comms public static volatile bool IsTerminated = false; public static volatile int cycleFinderTargetOverride = 0; + public static volatile int numberOfGPUs = 0; static int errorCounter = 0; @@ -97,6 +98,7 @@ private static void Listen() break; case GpuSettings settings: cycleFinderTargetOverride = settings.targetGraphTimeOverride; + numberOfGPUs = settings.numberOfGPUs; break; } } diff --git a/src/CudaSolver/Program.cs b/src/CudaSolver/Program.cs index 006ae08..933b55e 100644 --- a/src/CudaSolver/Program.cs +++ b/src/CudaSolver/Program.cs @@ -62,6 +62,8 @@ class Program public static ConcurrentQueue graphSolutions = new ConcurrentQueue(); + private static int gpuCount = 0; + private static bool fastCuda = false; private static volatile int trimRounds = 80; const string TestPrePow = "0001000000000000202e000000005c2e43ce014ca55dc4e0dffe987ee3eef9ca78e517f5ae7383c40797a4e8a9dd75ddf57eafac5471135202aa6054a2cc66aa5510ebdd58edcda0662a9e02d8232a4c90e90b7bddec1f32031d2894d76e3c390fc12b2dcc7a6f12b52be1d7aea70eac7b8ae0dc3f0ffb267e39b95a77e44e66d523399312a812d538afd00c7fd87275f4be7ef2f447ca918435d537c3db3c1d3e5d4f3b830432e5a283fab48917a5695324a319860a329cb1f6d1520ad0078c0f1dd9147f347f4c34e26d3063f117858d75000000000000babd0000000000007f23000000001ac67b3b00000155"; @@ -96,6 +98,20 @@ static void Main(string[] args) Logger.Log(LogLevel.Error, "Master connection error"); } + try + { + if (args.Length > 3) + { + gpuCount = int.Parse(args[3]); + fastCuda = gpuCount <= (Environment.ProcessorCount / 2); + Logger.Log(LogLevel.Info, "Using single GPU blocking mode"); + } + } + catch + { + + } + if (TEST) { currentJob = nextJob = new Job() @@ -156,7 +172,7 @@ static void Main(string[] args) var assembly = Assembly.GetEntryAssembly(); var resourceStream = assembly.GetManifestResourceStream("CudaSolver.kernel_x64.ptx"); - ctx = new CudaContext(deviceID, CUCtxFlags.BlockingSync | CUCtxFlags.MapHost); + ctx = new CudaContext(deviceID, gpuCount != 1 ? (CUCtxFlags.BlockingSync | CUCtxFlags.MapHost) : CUCtxFlags.MapHost ); meanSeedA = ctx.LoadKernelPTX(resourceStream, "FluffySeed2A"); meanSeedA.BlockDimensions = 128; meanSeedA.GridDimensions = 2048; diff --git a/src/GrinGoldMinerCLI/Program.cs b/src/GrinGoldMinerCLI/Program.cs index afd3c5f..0e995e8 100644 --- a/src/GrinGoldMinerCLI/Program.cs +++ b/src/GrinGoldMinerCLI/Program.cs @@ -223,6 +223,9 @@ static void Main(string[] args) case ConsoleKey.Q: checkKey = false; break; + case ConsoleKey.Enter: + Logger.criticalErrors.TryDequeue(out string msg); + break; default: break; } @@ -277,7 +280,7 @@ private static void WriteGUI() } who = ConnectionManager.IsInFee() ? "FEE" : "USER"; - Console.WriteLine("Grin Gold Miner 2.1"); + Console.WriteLine("Grin Gold Miner 2.2 - BETA 3"); Console.WriteLine("------------------------------------------------------------------------------------------"); WipeLine(); Console.Write("Mining for: "); @@ -312,6 +315,8 @@ private static void WriteGUI() Console.WriteLine($"Last share: {(DateTime.Now - conn.lastShare).TotalSeconds:F0} seconds"); WipeLine(); } + else + Console.WriteLine(); if (who == "FEE") { Console.ForegroundColor = ConsoleColor.DarkMagenta; @@ -328,6 +333,19 @@ private static void WriteGUI() w.PrintStatusLinesToConsole(); } Console.WriteLine("------------------------------------------------------------------------------------------"); + WipeLines(9); + if (Logger.criticalErrors.TryPeek(out string msg)) + { + if (msg.Contains("GPU") || (msg.ToLower().Contains("login") && !msg.ToLower().Contains("mimwim.eu"))) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine($"ERROR [hit Enter to hide]: {msg}"); + Console.ResetColor(); + Console.WriteLine("------------------------------------------------------------------------------------------"); + } + else + Logger.criticalErrors.TryDequeue(out string msgout); + } //Console.ForegroundColor = ConsoleColor.Yellow; //Console.WriteLine("Last log messages:"); Console.ResetColor(); WipeLines(5); @@ -343,14 +361,14 @@ private static void WriteGUI() private static void WipeLine() { - Console.Write(" "); + Console.Write(" "); Console.CursorLeft = 0; } private static void WipeLines(int cnt) { for (int i = 0; i < cnt; i++) { - Console.WriteLine(" "); + Console.WriteLine(" "); Console.CursorLeft = 0; } Console.CursorTop -= cnt; diff --git a/src/Master/Logging.cs b/src/Master/Logging.cs index 8db1470..b285166 100644 --- a/src/Master/Logging.cs +++ b/src/Master/Logging.cs @@ -141,6 +141,7 @@ public static void Log(Exception ex, [CallerFilePath]string callerFilePath = nul Log(LogLevel.ERROR, msg); } private static object lock1 = ""; + public static ConcurrentQueue criticalErrors = new ConcurrentQueue(); public static void Log(LogLevel level, string msg) { try @@ -154,6 +155,9 @@ public static void Log(LogLevel level, string msg) #endif } + if (level == LogLevel.ERROR && criticalErrors.Count < 1000) + criticalErrors.Enqueue(msg); + if (logOptions.DisableLogging == true) return; diff --git a/src/Master/Worker.cs b/src/Master/Worker.cs index f1e739d..3853321 100644 --- a/src/Master/Worker.cs +++ b/src/Master/Worker.cs @@ -134,7 +134,7 @@ public void PrintStatusLinesToConsole() private static void WipeLine() { - Console.Write(" "); + Console.Write(" "); Console.CursorLeft = 0; } @@ -253,7 +253,7 @@ public bool Start(Config config) FileName = (IsLinux ? ((type == WorkerType.NVIDIA) ? "CudaSolver" : "OclSolver") : (type == WorkerType.NVIDIA) ? Path.Combine("solvers", "CudaSolver.exe") : Path.Combine("solvers", "OclSolver.exe")), - Arguments = string.Format("{0} {1} {2}", workerDeviceID, workerCommPort, workerPlatformID), + Arguments = string.Format("{0} {1} {2} {3}", workerDeviceID, workerCommPort, workerPlatformID, config.GPUOptions.Count), CreateNoWindow = true, UseShellExecute = false //, RedirectStandardOutput =true @@ -265,7 +265,7 @@ public bool Start(Config config) stream = client.GetStream(); try { - SendSettings(new GpuSettings() { targetGraphTimeOverride = config.CPUOffloadValue }); + SendSettings(new GpuSettings() { targetGraphTimeOverride = config.CPUOffloadValue, numberOfGPUs = config.GPUOptions.Count }); } catch(Exception ex) { diff --git a/src/SharedSerialization/Comm.cs b/src/SharedSerialization/Comm.cs index 7102eb5..1f48508 100644 --- a/src/SharedSerialization/Comm.cs +++ b/src/SharedSerialization/Comm.cs @@ -192,7 +192,7 @@ public string ToShortString() } [SerializableAttribute] - public enum LogLevel:int + public enum LogLevel :int { Debug, Info, @@ -220,6 +220,7 @@ public enum Episode public class GpuSettings { public int targetGraphTimeOverride; + public int numberOfGPUs; } //public class GPUOptions From e8f7db5e3a83ec2ba1d10a6237a7b48a8e40b024 Mon Sep 17 00:00:00 2001 From: phooton Date: Fri, 11 Jan 2019 17:19:04 +0100 Subject: [PATCH 2/2] Fix error CLI msgbox --- src/GrinGoldMinerCLI/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GrinGoldMinerCLI/Program.cs b/src/GrinGoldMinerCLI/Program.cs index 0e995e8..ba8a9fc 100644 --- a/src/GrinGoldMinerCLI/Program.cs +++ b/src/GrinGoldMinerCLI/Program.cs @@ -336,7 +336,7 @@ private static void WriteGUI() WipeLines(9); if (Logger.criticalErrors.TryPeek(out string msg)) { - if (msg.Contains("GPU") || (msg.ToLower().Contains("login") && !msg.ToLower().Contains("mimwim.eu"))) + if (msg.Contains("GPU") || msg.ToLower().Contains("login")) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"ERROR [hit Enter to hide]: {msg}");