private void DistributedSchedule(int processCount, int threadCount) { int nodeCount = 100; IReadOnlyList <Gaussian> xExpected; Gaussian shiftExpected; IReadOnlyList <int[]> variablesUsedByNode; var schedulePerThread = parallelScheduleTest(processCount, nodeCount, out xExpected, out shiftExpected, out variablesUsedByNode); int[][][] schedulePerProcess = ParallelScheduler.ConvertToSchedulePerProcess(schedulePerThread); Dictionary <int, int>[] processLocalIndexOfArrayIndexPerProcess; IReadOnlyList <Compiler.Graphs.DistributedCommunicationInfo> distributedCommunicationInfos = ParallelScheduler.GetDistributedCommunicationInfos(schedulePerThread, variablesUsedByNode, out processLocalIndexOfArrayIndexPerProcess); Console.WriteLine("communication cost = {0}", TotalCommunicationCost(distributedCommunicationInfos)); int[][][][][] schedulePerThreadPerProcess; if (threadCount > 1) { schedulePerThreadPerProcess = Util.ArrayInit(processCount, process => ParallelScheduler.GetSchedulePerThreadInProcess(schedulePerProcess[process], distributedCommunicationInfos[process].indices, threadCount) ); } else { schedulePerThreadPerProcess = Util.ArrayInit(processCount, process => default(int[][][][])); } IList <Gaussian>[] xResultPerProcess = new IList <Gaussian> [processCount]; Gaussian[] shiftResultPerProcess = new Gaussian[processCount]; bool debug = false; if (debug) { Assert.Equal(1, processCount); SequentialCommunicator comm = new SequentialCommunicator(); DistributedScheduleTestProcess(comm, xResultPerProcess, shiftResultPerProcess, distributedCommunicationInfos[comm.Rank], schedulePerProcess[comm.Rank], schedulePerThreadPerProcess[comm.Rank]); } else { ThreadCommunicator.Run(processCount, comm => DistributedScheduleTestProcess(comm, xResultPerProcess, shiftResultPerProcess, distributedCommunicationInfos[comm.Rank], schedulePerProcess[comm.Rank], schedulePerThreadPerProcess[comm.Rank]) ); } Gaussian[] arrayMarginal = new Gaussian[nodeCount]; for (int process = 0; process < processCount; process++) { ////Console.WriteLine($"shift {shiftExpected} {shiftResultPerProcess[process]}"); Assert.Equal(shiftExpected, shiftResultPerProcess[process]); foreach (var entry in processLocalIndexOfArrayIndexPerProcess[process]) { int arrayIndex = entry.Key; int localIndex = entry.Value; arrayMarginal[arrayIndex] = xResultPerProcess[process][localIndex]; } } var arrayActual = new DistributionStructArray <Gaussian, double>(arrayMarginal); ////Console.WriteLine(arrayActual); double error = arrayActual.MaxDiff(xExpected); Assert.True(error < 1e-10); }
public override void Execute() { Destroy(modalwindow); Debug.Log("check"); thread.AbortThread(); OnThreadAborted(); ModalWindowManager.instance.CreateModalWindow("Communication Cancelled"); thread = null; modalwindow = null; this.gameObject.SetActive(false); }