From 86b9cfb981672bfa09d14240e010ffcc9acbb72f Mon Sep 17 00:00:00 2001 From: F5 Date: Wed, 22 Nov 2023 16:29:41 +0800 Subject: [PATCH] mpi: Keep original event UID after automatic partition --- src/mpi/model/hybrid-simulator-impl.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/mpi/model/hybrid-simulator-impl.cc b/src/mpi/model/hybrid-simulator-impl.cc index f2c4ddf33..6d7d4b48b 100644 --- a/src/mpi/model/hybrid-simulator-impl.cc +++ b/src/mpi/model/hybrid-simulator-impl.cc @@ -471,22 +471,29 @@ HybridSimulatorImpl::Partition() << " threads"); // create new LPs - const Ptr events = MtpInterface::GetSystem()->GetPendingEvents(); - MtpInterface::Disable(); - MtpInterface::Enable(threadCount, systemCount); + MtpInterface::EnableNew(threadCount, systemCount); // set scheduler ObjectFactory schedulerFactory; schedulerFactory.SetTypeId(m_schedulerTypeId); - for (uint32_t i = 0; i <= systemCount; i++) + for (uint32_t i = 1; i <= systemCount; i++) { MtpInterface::GetSystem(i)->SetScheduler(schedulerFactory); } - // transfer events to new LPs - while (!events->IsEmpty()) + // remove old events in public LP + const Ptr oldEvents = MtpInterface::GetSystem()->GetPendingEvents(); + const Ptr eventsToBeTransferred = schedulerFactory.Create(); + while (!oldEvents->IsEmpty()) { - Scheduler::Event ev = events->RemoveNext(); + Scheduler::Event next = oldEvents->RemoveNext(); + eventsToBeTransferred->Insert(next); + } + + // transfer events to new LPs + while (!eventsToBeTransferred->IsEmpty()) + { + Scheduler::Event ev = eventsToBeTransferred->RemoveNext(); // invoke initialization events (at time 0) by their insertion order // since changing the execution order of these events may cause error, // they have to be invoked now rather than parallelly executed