public SubJob(Job parentJob, KPoint position) { ParentJob = parentJob ?? throw new ArgumentNullException(nameof(parentJob)); Position = position; SubJobResult = null; OperationType = SubJobOperationType.Unknown; }
public List <KPoint> GetRepoKeysForJob() { IEnumerable <KPoint> keys = GetAllRepoKeys(); if (keys == null) { return(null); } int sx = FJobRequest.Area.Point.X; int sy = FJobRequest.Area.Point.Y; int ex = sx + FJobRequest.Area.Size.W; int ey = sy + FJobRequest.Area.Size.H; List <KPoint> result = new List <KPoint>(); foreach (KPoint pos in keys) { if (pos.X >= sx && pos.X < ex && pos.Y >= sy && pos.Y < ey) { KPoint localKey = pos.FromGlobal(_position); result.Add(localKey); } } return(result); }
public Job(FJobRequest fJobRequest, string requestMsgId) { FJobRequest = fJobRequest; RequestMsgId = requestMsgId; FGenJob fGenJob = BuildFGenJob(fJobRequest); FGenerator = new FGenerator(fGenJob); //_position = new KPoint(fJobRequest.Area.Point.X * FGenerator.BLOCK_WIDTH, fJobRequest.Area.Point.Y * FGenerator.BLOCK_HEIGHT); _position = new KPoint(fJobRequest.Area.Point.X, fJobRequest.Area.Point.Y); _subJobIterator = new SubJobIterator(this); ResetSubJobsRemainingToBeSent(); _closed = false; Debug.WriteLine($"Creating new Repo. Name: {Name}, JobId: {JobId}."); _countsRepo = new ValueRecords <KPoint, SubJobResult>(Name); ReportRepoContents(); //Debug.WriteLine($"Starting to get histogram for {Name} at {DateTime.Now.ToString(DiagTimeFormat)}."); //Dictionary<int, int> h = GetHistogram(); //Debug.WriteLine($"Histogram complete for {Name} at {DateTime.Now.ToString(DiagTimeFormat)}."); }
public void WriteWorkResult(SubJob subJob, bool overwriteResults) { KPoint key = subJob.Position; SubJobResult val = subJob.SubJobResult; // When writing, include the Area's offset. KPoint transKey = key.ToGlobal(_position); try { lock (_repoLock) { if (Closed) { return; } if (overwriteResults) { _countsRepo.Change(transKey, val); } else { _countsRepo.Add(transKey, val, saveOnWrite: true); } } } catch { Debug.WriteLine($"Could not write data for x: {key.X} and y: {key.Y}."); } }
private SubJobResult GetEmptySubJobResult(KPoint dummy) { if (_emptySubJobResult == null) { int size = FGenerator.BLOCK_WIDTH * FGenerator.BLOCK_HEIGHT; string instanceName = "MainJob"; _emptySubJobResult = SubJobResult.GetEmptySubJobResult(size, instanceName, includeZValuesOnRead: false); } SubJobResult.ClearSubJobResult(_emptySubJobResult); return(_emptySubJobResult); }
public bool RetrieveWorkResultFromRepo(KPoint riKey, SubJobResult workResult) { // When writing include the Area's offset. KPoint transKey = riKey.ToGlobal(_position); lock (_repoLock) { if (Closed) { return(false); } bool result = _countsRepo.ReadParts(transKey, workResult); return(result); } }