Skip to content

Commit de93785

Browse files
author
Volker Waurich
committed
- hpcom outputs theoretical speedup and theoretical max speedup
- updated tests git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18169 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 71985f0 commit de93785

File tree

2 files changed

+56
-29
lines changed

2 files changed

+56
-29
lines changed

Compiler/BackEnd/HpcOmScheduler.mo

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,41 +2014,73 @@ end printSchedule;
20142014

20152015

20162016
public function predictExecutionTime "computes the theoretically execution time for the serial simulation and the parallel. a speedup ratio is determined by su=serTime/parTime.
2017+
the max speedUp is computed via the serTime/criticalPathCosts.
20172018
author:Waurich TUD 2013-11"
20182019
input Schedule scheduleIn;
2020+
input Option<Real> cpCostsOption;
20192021
input Integer numProc;
20202022
input HpcOmTaskGraph.TaskGraph taskGraphIn;
20212023
input HpcOmTaskGraph.TaskGraphMeta taskGraphMetaIn;
20222024
output Real serialTimeOut;
20232025
output Real parallelTimeOut;
2024-
output Real speedupOut;
2025-
protected
2026-
Boolean isODE;
2027-
Real parTime, serTime, speedUp;
2028-
Schedule schedule;
2026+
output Real speedUpOut;
2027+
output Real speedUpMaxOut;
20292028
algorithm
2030-
isODE := intNe(arrayLength(taskGraphIn),0);
2031-
schedule := Util.if_(isODE,scheduleIn,EMPTYSCHEDULE());
2032-
(_,parTime) := getFinishingTimesForSchedule(schedule,numProc,taskGraphIn,taskGraphMetaIn);
2033-
serTime := getSerialExecutionTime(taskGraphMetaIn);
2034-
speedUp := serTime /. parTime;
2035-
serialTimeOut := serTime;
2036-
parallelTimeOut := parTime;
2037-
speedupOut := speedUp;
2038-
end predictExecutionTime;
2029+
(serialTimeOut,parallelTimeOut,speedUpOut,speedUpMaxOut) := matchcontinue(scheduleIn,cpCostsOption,numProc,taskGraphIn,taskGraphMetaIn)
2030+
local
2031+
Boolean isODE;
2032+
Real parTime, serTime, speedUp, speedUpMax, cpCosts;
2033+
String isOkString, isNotOkString;
2034+
Schedule schedule;
2035+
case(_,NONE(),_,_,_)
2036+
equation
2037+
true = intNe(arrayLength(taskGraphIn),0); //is an ODE system
2038+
(_,parTime) = getFinishingTimesForSchedule(scheduleIn,numProc,taskGraphIn,taskGraphMetaIn);
2039+
serTime = getSerialExecutionTime(taskGraphMetaIn);
2040+
speedUp = serTime /. parTime;
2041+
print("The predicted SpeedUp with "+&intString(numProc)+&" processors is "+&realString(speedUp)+&".\n");
2042+
then
2043+
(serTime,parTime,speedUp,-1.0);
2044+
case(_,SOME(cpCosts),_,_,_)
2045+
equation
2046+
true = intNe(arrayLength(taskGraphIn),0); //is an ODE system
2047+
(_,parTime) = getFinishingTimesForSchedule(scheduleIn,numProc,taskGraphIn,taskGraphMetaIn);
2048+
serTime = getSerialExecutionTime(taskGraphMetaIn);
2049+
speedUp = serTime /. parTime;
2050+
speedUpMax = serTime /. cpCosts;
2051+
isOkString = "The predicted SpeedUp with "+&intString(numProc)+&" processors is: "+&realString(speedUp)+&". With a theoretical maxmimum speedUp of: "+&realString(speedUpMax)+&"\n";
2052+
isNotOkString = "Something is weird. The predicted SpeedUp is "+&realString(speedUp)+&" and the theoretical maximum speedUp is "+&realString(speedUpMax)+&"\n";
2053+
Debug.bcall(realGt(speedUp,speedUpMax),print,isNotOkString);
2054+
Debug.bcall(realLe(speedUp,speedUpMax),print,isOkString);
2055+
//print("the serialCosts: "+&realString(serTime)+&"\n");
2056+
//print("the parallelCosts: "+&realString(parTime)+&"\n");
2057+
//print("the cpCosts: "+&realString(cpCosts)+&"\n");
2058+
then
2059+
(serTime,parTime,speedUp,speedUpMax);
2060+
case(_,_,_,_,_)
2061+
equation
2062+
then
2063+
(0.0,0.0,0.0,0.0);
2064+
end matchcontinue;
2065+
end predictExecutionTime;
20392066

20402067

20412068
protected function getSerialExecutionTime "computes thes serial execution time by summing up all exeCosts of all tasks.
20422069
author:Waurich TUD 2013-11"
20432070
input HpcOmTaskGraph.TaskGraphMeta taskGraphMetaIn;
20442071
output Real serialTimeOut;
20452072
protected
2073+
list<Integer> odeComps;
2074+
list<Real> exeCostsReal;
20462075
array<Real> exeCosts1;
2076+
array<list<Integer>> inComps;
20472077
array<tuple<Integer, Real>> exeCosts;
20482078
algorithm
2049-
HpcOmTaskGraph.TASKGRAPHMETA(exeCosts=exeCosts) := taskGraphMetaIn;
2079+
HpcOmTaskGraph.TASKGRAPHMETA(exeCosts=exeCosts, inComps=inComps) := taskGraphMetaIn;
2080+
odeComps := Util.arrayFold(inComps,listAppend,{});
20502081
exeCosts1 := Util.arrayMap(exeCosts,Util.tuple22);
2051-
serialTimeOut := Util.arrayFold(exeCosts1,realAdd,0.0);
2082+
exeCostsReal := List.map1(odeComps,Util.arrayGetIndexFirst,exeCosts1);
2083+
serialTimeOut := List.fold(exeCostsReal,realAdd,0.0);
20522084
end getSerialExecutionTime;
20532085

20542086

Compiler/BackEnd/HpcOmSimCode.mo

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ algorithm
151151
HpcOmTaskGraph.TaskGraphMeta taskGraphData1;
152152
list<list<Integer>> parallelSets;
153153
list<list<Integer>> criticalPaths, criticalPathsWoC;
154-
Real cpCosts, cpCostsWoC, serTime, parTime, speedUp;
154+
Real cpCosts, cpCostsWoC, serTime, parTime, speedUp, speedUpMax;
155155

156156
//Additional informations to append SimCode
157157
list<DAE.Exp> simCodeLiterals;
@@ -237,25 +237,20 @@ algorithm
237237
//Create schedule
238238
//---------------
239239
schedule = createSchedule(taskGraph1,taskGraphData1,sccSimEqMapping,filenamePrefix);
240-
(serTime,parTime,speedUp) = HpcOmScheduler.predictExecutionTime(schedule,numProc,taskGraph1,taskGraphData1);
241-
//print("The predicted SpeedUp with "+&intString(numProc)+&" processors is "+&realString(speedUp)+&".\n");
240+
241+
(serTime,parTime,speedUp,speedUpMax) = HpcOmScheduler.predictExecutionTime(schedule,SOME(cpCostsWoC),numProc,taskGraph1,taskGraphData1);
242+
((criticalPaths,cpCosts),(criticalPathsWoC,cpCostsWoC),parallelSets) = HpcOmTaskGraph.longestPathMethod(taskGraph1,taskGraphData1);
243+
criticalPathInfo = HpcOmTaskGraph.dumpCriticalPathInfo((criticalPaths,cpCosts),(criticalPathsWoC,cpCostsWoC));
244+
242245

243246
taskScheduleSimCode = HpcOmScheduler.convertScheduleToSimCodeSchedule(schedule);
247+
schedulerInfo = HpcOmScheduler.convertScheduleStrucToInfo(schedule,arrayLength(taskGraph));
248+
244249

245250
fileName = ("taskGraph"+&filenamePrefix+&"ODE_schedule.graphml");
246-
schedulerInfo = HpcOmScheduler.convertScheduleStrucToInfo(schedule,arrayLength(taskGraph));
247-
248-
((criticalPaths,cpCosts),(criticalPathsWoC,cpCostsWoC),parallelSets) = HpcOmTaskGraph.longestPathMethod(taskGraph1,taskGraphData1);
249-
criticalPathInfo = HpcOmTaskGraph.dumpCriticalPathInfo((criticalPaths,cpCosts),(criticalPathsWoC,cpCostsWoC));
250-
//criticalPathInfo = "";
251-
//criticalPaths = {{}};
252-
//criticalPathsWoC = {{}};
253251
HpcOmTaskGraph.dumpAsGraphMLSccLevel(taskGraph1, taskGraphData1, fileName, criticalPathInfo, HpcOmTaskGraph.convertNodeListToEdgeTuples(List.first(criticalPaths)), HpcOmTaskGraph.convertNodeListToEdgeTuples(List.first(criticalPathsWoC)), sccSimEqMapping, schedulerInfo);
254252
//HpcOmScheduler.printSchedule(schedule);
255253

256-
//print("Parallel informations:\n");
257-
//printParInformation(hpcOmParInformation);
258-
259254
SimCode.SIMCODE(modelInfo, simCodeLiterals, simCodeRecordDecls, simCodeExternalFunctionIncludes, allEquations, odeEquations, algebraicEquations, residualEquations, useSymbolicInitialization, useHomotopy, initialEquations, startValueEquations,
260255
parameterEquations, inlineEquations, removedEquations, algorithmAndEquationAsserts, stateSets, constraints, classAttributes, zeroCrossings, relations, sampleLookup, whenClauses,
261256
discreteModelVars, extObjInfo, makefileParams, delayedExps, jacobianMatrixes, simulationSettingsOpt, fileNamePrefix, crefToSimVarHT, _) = simCode;

0 commit comments

Comments
 (0)