From 51e9b65213aac17d25c7924f537a912541c715da Mon Sep 17 00:00:00 2001 From: robbr48 Date: Tue, 14 May 2024 10:37:40 +0200 Subject: [PATCH] Correct names of parallel algorithms --- HopsanCore/include/ComponentSystem.h | 2 +- .../include/CoreUtilities/SimulationHandler.h | 10 +++++----- HopsanCore/src/ComponentSystem.cpp | 14 +++++++------- HopsanGUI/HcomHandler.cpp | 9 ++++++--- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/HopsanCore/include/ComponentSystem.h b/HopsanCore/include/ComponentSystem.h index d2f67f0c0..3ded173f6 100644 --- a/HopsanCore/include/ComponentSystem.h +++ b/HopsanCore/include/ComponentSystem.h @@ -131,7 +131,7 @@ namespace hopsan { bool initialize(const double startT, const double stopT); void simulate(const double stopT); bool startRealtimeSimulation(double realTimeFactor=1); - virtual void simulateMultiThreaded(const double startT, const double stopT, const size_t nDesiredThreads = 0, const bool noChanges=false, ParallelAlgorithmT algorithm=OfflineSchedulingAlgorithm); + virtual void simulateMultiThreaded(const double startT, const double stopT, const size_t nDesiredThreads = 0, const bool noChanges=false, ParallelAlgorithmT algorithm=APrioriScheduling); void finalize(); bool simulateAndMeasureTime(const size_t nSteps); diff --git a/HopsanCore/include/CoreUtilities/SimulationHandler.h b/HopsanCore/include/CoreUtilities/SimulationHandler.h index 77125a7c2..816b03794 100644 --- a/HopsanCore/include/CoreUtilities/SimulationHandler.h +++ b/HopsanCore/include/CoreUtilities/SimulationHandler.h @@ -40,11 +40,11 @@ namespace hopsan { -enum ParallelAlgorithmT {OfflineSchedulingAlgorithm, +enum ParallelAlgorithmT {APrioriScheduling, TaskPoolAlgorithm, TaskStealingAlgorithm, - ParallelForAlgorithm, - GroupedParallelForAlgorithm}; + ForkJoinAlgorithm, + ClusteredForkJoinAlgorithm}; // Forward declaration class ComponentSystem; @@ -59,8 +59,8 @@ class HOPSANCORE_DLLAPI SimulationHandler bool initializeSystem(const double startT, const double stopT, ComponentSystem* pSystem); bool initializeSystem(const double startT, const double stopT, std::vector &rSystemVector); - bool simulateSystem(const double startT, const double stopT, const int nDesiredThreads, ComponentSystem* pSystem, bool noChanges=false, ParallelAlgorithmT algorithm=OfflineSchedulingAlgorithm); - bool simulateSystem(const double startT, const double stopT, const int nDesiredThreads, std::vector &rSystemVector, bool noChanges=false, ParallelAlgorithmT algorithm=OfflineSchedulingAlgorithm); + bool simulateSystem(const double startT, const double stopT, const int nDesiredThreads, ComponentSystem* pSystem, bool noChanges=false, ParallelAlgorithmT algorithm=APrioriScheduling); + bool simulateSystem(const double startT, const double stopT, const int nDesiredThreads, std::vector &rSystemVector, bool noChanges=false, ParallelAlgorithmT algorithm=APrioriScheduling); bool startRealtimeSimulation(ComponentSystem *pSystem, double realtimeFactor=1); void stopRealtimeSimulation(ComponentSystem *pSystem); diff --git a/HopsanCore/src/ComponentSystem.cpp b/HopsanCore/src/ComponentSystem.cpp index 3f2d3432f..fad46be49 100644 --- a/HopsanCore/src/ComponentSystem.cpp +++ b/HopsanCore/src/ComponentSystem.cpp @@ -2470,9 +2470,9 @@ void ComponentSystem::simulateMultiThreaded(const double startT, const double st size_t nSteps = calcNumSimSteps(startT, stopT); //Execute simulation - if(algorithm == OfflineSchedulingAlgorithm) + if(algorithm == APrioriScheduling) { - addInfoMessage("Using offline scheduling algorithm with "+threadStr+" threads."); + addInfoMessage("Using a priori scheduling algorithm with "+threadStr+" threads."); mpMultiThreadPrivates->mvTimePtrs.push_back(&mTime); BarrierLock *pBarrierLock_S = new BarrierLock(nThreads); //Create synchronization barriers @@ -2611,7 +2611,7 @@ void ComponentSystem::simulateMultiThreaded(const double startT, const double st } else if(algorithm == TaskStealingAlgorithm) { - addInfoMessage("Using task stealing algorithm with "+threadStr+" threads."); + addInfoMessage("Using task-stealing algorithm with "+threadStr+" threads."); mpMultiThreadPrivates->mvTimePtrs.push_back(&mTime); BarrierLock *pBarrierLock_S = new BarrierLock(nThreads); //Create synchronization barriers @@ -2684,9 +2684,9 @@ void ComponentSystem::simulateMultiThreaded(const double startT, const double st delete(pVectorsC); delete(pVectorsQ); } - else if(algorithm == ParallelForAlgorithm) + else if(algorithm == ForkJoinAlgorithm) { - addInfoMessage("Using parallel for-loop algorithm 1 with unlimited number of threads."); + addInfoMessage("Using fork-join algorithm with unlimited number of threads."); // Round to nearest, we may not get exactly the stop time that we want size_t numSimulationSteps = calcNumSimSteps(mTime, stopT); //Here mTime is the last time step since it is not updated yet @@ -2743,9 +2743,9 @@ void ComponentSystem::simulateMultiThreaded(const double startT, const double st logTimeAndNodes(mTotalTakenSimulationSteps); } } - else if(algorithm == GroupedParallelForAlgorithm) + else if(algorithm == ClusteredForkJoinAlgorithm) { - addInfoMessage("Using grouped parallel for loop algorithm with unlimited number of threads."); + addInfoMessage("Using clustered fork-join algorithm with unlimited number of threads."); // Round to nearest, we may not get exactly the stop time that we want size_t numSimulationSteps = calcNumSimSteps(mTime, stopT); //Here mTime is the last time step since it is not updated yet diff --git a/HopsanGUI/HcomHandler.cpp b/HopsanGUI/HcomHandler.cpp index bc66022df..33b18804a 100644 --- a/HopsanGUI/HcomHandler.cpp +++ b/HopsanGUI/HcomHandler.cpp @@ -4179,8 +4179,8 @@ void HcomHandler::executeGetCommand(const QString cmd) switch (getConfigPtr()->getParallelAlgorithm()) { - case hopsan::OfflineSchedulingAlgorithm : - output.append("pre-simulation scheduling"); + case hopsan::APrioriScheduling : + output.append("a priori scheduling"); break; case hopsan::TaskPoolAlgorithm : output.append("task pool scheduling"); @@ -4188,9 +4188,12 @@ void HcomHandler::executeGetCommand(const QString cmd) case hopsan::TaskStealingAlgorithm : output.append("task-stealing"); break; - case hopsan::ParallelForAlgorithm : + case hopsan::ForkJoinAlgorithm : output.append("fork-join scheduling"); break; + case hopsan::ClusteredForkJoinAlgorithm : + output.append("clustered fork-join scheduling"); + break; default : output.append("unknown ("+QString::number(getConfigPtr()->getParallelAlgorithm())+")"); break;