private void ResumeThreads() { m_threadPool.ResumeThreads(); if (m_errorOccured) { if (m_lastException != null) { throw m_lastException; } throw new MySimulationException("Unknown simulation exception occured"); } }
/// <summary> /// Performs one step of simulation /// </summary> public override void PerformStep(bool stepByStepRun) { m_debugStepComplete = true; m_errorOccured = false; m_threadPool.ResumeThreads(ExecutionPlan); if (m_errorOccured) { if (m_lastException != null) { throw m_lastException; } else { throw new MySimulationException(-1, "Unknown simulation exception occured"); } } //mainly for observers if (InDebugMode && stepByStepRun) { for (int i = 0; i < NodePartitioning.Length; i++) { List <MyWorkingNode> nodeList = NodePartitioning[i]; MyKernelFactory.Instance.SetCurrent(i); for (int j = 0; j < nodeList.Count; j++) { MyWorkingNode node = nodeList[j]; MyMemoryManager.Instance.SynchronizeSharedBlocks(node, false); } } } if (!InDebugMode || m_debugStepComplete) { bool doAutoSave = SimulationStep > 0 && AutoSaveInterval > 0 && SimulationStep % AutoSaveInterval == 0; if (doAutoSave) { MyLog.INFO.WriteLine("Autosave (" + SimulationStep + " steps)"); } for (int i = 0; i < NodePartitioning.Length; i++) { List <MyWorkingNode> nodeList = NodePartitioning[i]; MyKernelFactory.Instance.SetCurrent(i); if (SimulationStep == 0) { LoadBlocks(nodeList); } if (doAutoSave) { SaveBlocks(nodeList); } for (int j = 0; j < nodeList.Count; j++) { MyWorkingNode node = nodeList[j]; //TODO: fix UI to not flicker and enable this line to clear signals after every simulation step //node.ClearSignals(); MyMemoryManager.Instance.SynchronizeSharedBlocks(node, false); } } SimulationStep++; } }