Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
urza committed Jan 11, 2019
2 parents 7f95dda + e8f7db5 commit d1f8def
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/CudaSolver/Comms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -97,6 +98,7 @@ private static void Listen()
break;
case GpuSettings settings:
cycleFinderTargetOverride = settings.targetGraphTimeOverride;
numberOfGPUs = settings.numberOfGPUs;
break;
}
}
Expand Down
18 changes: 17 additions & 1 deletion src/CudaSolver/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class Program

public static ConcurrentQueue<Solution> graphSolutions = new ConcurrentQueue<Solution>();

private static int gpuCount = 0;
private static bool fastCuda = false;
private static volatile int trimRounds = 80;
const string TestPrePow = "0001000000000000202e000000005c2e43ce014ca55dc4e0dffe987ee3eef9ca78e517f5ae7383c40797a4e8a9dd75ddf57eafac5471135202aa6054a2cc66aa5510ebdd58edcda0662a9e02d8232a4c90e90b7bddec1f32031d2894d76e3c390fc12b2dcc7a6f12b52be1d7aea70eac7b8ae0dc3f0ffb267e39b95a77e44e66d523399312a812d538afd00c7fd87275f4be7ef2f447ca918435d537c3db3c1d3e5d4f3b830432e5a283fab48917a5695324a319860a329cb1f6d1520ad0078c0f1dd9147f347f4c34e26d3063f117858d75000000000000babd0000000000007f23000000001ac67b3b00000155";

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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;
Expand Down
24 changes: 21 additions & 3 deletions src/GrinGoldMinerCLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -278,7 +281,7 @@ private static void WriteGUI()
string who = ConnectionManager.IsInFee() ? "FEE" : (conn?.login ?? "USER");
who = who.Length > 10 ? who.Substring(0, 10)+".." : who;

Console.WriteLine("Grin Gold Miner 2.1");
Console.WriteLine("Grin Gold Miner 2.2 - BETA 3");
Console.WriteLine("------------------------------------------------------------------------------------------");
WipeLine();
Console.Write("Mining for: ");
Expand Down Expand Up @@ -313,6 +316,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;
Expand All @@ -329,6 +334,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"))
{
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);
Expand All @@ -344,14 +362,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;
Expand Down
4 changes: 4 additions & 0 deletions src/Master/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> criticalErrors = new ConcurrentQueue<string>();
public static void Log(LogLevel level, string msg)
{
try
Expand All @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions src/Master/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void PrintStatusLinesToConsole()

private static void WipeLine()
{
Console.Write(" ");
Console.Write(" ");
Console.CursorLeft = 0;
}

Expand Down Expand Up @@ -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
Expand All @@ -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)
{
Expand Down
3 changes: 2 additions & 1 deletion src/SharedSerialization/Comm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public string ToShortString()
}

[SerializableAttribute]
public enum LogLevel:int
public enum LogLevel :int
{
Debug,
Info,
Expand Down Expand Up @@ -220,6 +220,7 @@ public enum Episode
public class GpuSettings
{
public int targetGraphTimeOverride;
public int numberOfGPUs;
}

//public class GPUOptions
Expand Down

0 comments on commit d1f8def

Please sign in to comment.