Skip to content

Commit

Permalink
Correct names of parallel algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
robbr48 committed May 15, 2024
1 parent eb90f09 commit 51e9b65
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion HopsanCore/include/ComponentSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions HopsanCore/include/CoreUtilities/SimulationHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@

namespace hopsan {

enum ParallelAlgorithmT {OfflineSchedulingAlgorithm,
enum ParallelAlgorithmT {APrioriScheduling,
TaskPoolAlgorithm,
TaskStealingAlgorithm,
ParallelForAlgorithm,
GroupedParallelForAlgorithm};
ForkJoinAlgorithm,
ClusteredForkJoinAlgorithm};

// Forward declaration
class ComponentSystem;
Expand All @@ -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<ComponentSystem*> &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<ComponentSystem*> &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<ComponentSystem*> &rSystemVector, bool noChanges=false, ParallelAlgorithmT algorithm=APrioriScheduling);

bool startRealtimeSimulation(ComponentSystem *pSystem, double realtimeFactor=1);
void stopRealtimeSimulation(ComponentSystem *pSystem);
Expand Down
14 changes: 7 additions & 7 deletions HopsanCore/src/ComponentSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions HopsanGUI/HcomHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4179,18 +4179,21 @@ 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");
break;
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;
Expand Down

0 comments on commit 51e9b65

Please sign in to comment.