Skip to content

Commit

Permalink
- round the values for serialTime, parallel Time, critical Path
Browse files Browse the repository at this point in the history
- always use num_threads from the flag +n=.. for level scheduling


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18884 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Volker Waurich committed Jan 31, 2014
1 parent 1ef26bc commit db09538
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Compiler/BackEnd/HpcOmScheduler.mo
Expand Up @@ -2340,6 +2340,9 @@ algorithm
criticalPathInfo = HpcOmTaskGraph.dumpCriticalPathInfo((criticalPaths,cpCosts),(criticalPathsWoC,cpCostsWoC));
//predict speedup etc.
(serTime,parTime,speedUp,speedUpMax) = predictExecutionTime(scheduleIn,SOME(cpCostsWoC),numProcIn,taskGraphIn,taskGraphMetaIn);
serTime = HpcOmTaskGraph.roundReal(serTime,2);
parTime = HpcOmTaskGraph.roundReal(parTime,2);
cpCostsWoC = HpcOmTaskGraph.roundReal(cpCostsWoC,2);
Debug.fcall(Flags.HPCOM_DUMP,print,"the serialCosts: "+&realString(serTime)+&"\n");
Debug.fcall(Flags.HPCOM_DUMP,print,"the parallelCosts: "+&realString(parTime)+&"\n");
Debug.fcall(Flags.HPCOM_DUMP,print,"the cpCosts: "+&realString(cpCostsWoC)+&"\n");
Expand Down
12 changes: 6 additions & 6 deletions Compiler/BackEnd/HpcOmSimCode.mo
Expand Up @@ -223,6 +223,8 @@ algorithm
//Assign levels and get critcal path
//----------------------------------
((criticalPaths,cpCosts),(criticalPathsWoC,cpCostsWoC),parallelSets) = HpcOmTaskGraph.longestPathMethod(taskGraphOde,taskGraphDataOde);
cpCosts = HpcOmTaskGraph.roundReal(cpCosts,2);
cpCostsWoC = HpcOmTaskGraph.roundReal(cpCostsWoC,2);
criticalPathInfo = HpcOmTaskGraph.dumpCriticalPathInfo((criticalPaths,cpCosts),(criticalPathsWoC,cpCostsWoC));
((graphOps,graphCosts)) = HpcOmTaskGraph.sumUpExecCosts(taskGraphDataOde);
criticalPathInfo = criticalPathInfo +& " sum: (" +& realString(graphCosts) +& " ; " +& intString(graphOps) +& ")";
Expand All @@ -246,16 +248,13 @@ algorithm
schedule = createSchedule(taskGraph1,taskGraphData1,sccSimEqMapping,filenamePrefix,numProc);
(schedule,numProc) = repeatScheduleWithOtherNumProc(taskGraph1,taskGraphData1,sccSimEqMapping,filenamePrefix,cpCostsWoC,schedule,numProc,numFixed);
criticalPathInfo = HpcOmScheduler.analyseScheduledTaskGraph(schedule,numProc,taskGraph1,taskGraphData1);

taskScheduleSimCode = HpcOmScheduler.convertScheduleToSimCodeSchedule(schedule);
schedulerInfo = HpcOmScheduler.convertScheduleStrucToInfo(schedule,arrayLength(taskGraph));
Debug.execStat("hpcom create schedule", GlobalScript.RT_CLOCK_EXECSTAT_HPCOM_MODULES);

fileName = ("taskGraph"+&filenamePrefix+&"ODE_schedule.graphml");
HpcOmTaskGraph.dumpAsGraphMLSccLevel(taskGraph1, taskGraphData1, fileName, criticalPathInfo, HpcOmTaskGraph.convertNodeListToEdgeTuples(List.first(criticalPaths)), HpcOmTaskGraph.convertNodeListToEdgeTuples(List.first(criticalPathsWoC)), sccSimEqMapping, schedulerInfo);
//HpcOmScheduler.printSchedule(schedule);
Debug.execStat("hpcom dump schedule TaskGraph", GlobalScript.RT_CLOCK_EXECSTAT_HPCOM_MODULES);

SimCode.SIMCODE(modelInfo, simCodeLiterals, simCodeRecordDecls, simCodeExternalFunctionIncludes, allEquations, odeEquations, algebraicEquations, residualEquations, useSymbolicInitialization, useHomotopy, initialEquations, startValueEquations,
parameterEquations, inlineEquations, removedEquations, algorithmAndEquationAsserts, jacobianEquations, stateSets, constraints, classAttributes, zeroCrossings, relations, sampleLookup, whenClauses,
discreteModelVars, extObjInfo, makefileParams, delayedExps, jacobianMatrixes, simulationSettingsOpt, fileNamePrefix, crefToSimVarHT, _) = simCode;
Expand Down Expand Up @@ -359,7 +358,7 @@ end repeatScheduleWithOtherNumProc1;


protected function setNumProc "sets the number of processors. its upper limit is the number of processsors provided by the system.
if no n-flag is set, a ideal number is chosen
if no n-flag is set, a ideal number is suggested but the simulation fails.
author: Waurich TUD 2013-11"
input Integer numProcFlag;
input Real cpCosts;
Expand All @@ -381,12 +380,13 @@ algorithm
numProcSys = System.numProcessors();
numProc = intMin(numProcSched,numProcSys);
string1 = "Your system provides only "+&intString(numProcSys)+&" processors!\n";
string2 = "The model is simulated using "+&intString(numProcSched)+&" processors, because that might be a reasonable number of threads.\n";
string2 = intString(numProcSched)+&" processors might be a reasonable number of processors.\n";
string1 = Util.if_(intGt(numProcSched,numProcSys),string1,string2);
isFixed = Util.if_(intGt(numProcSched,numProcSys),true,false);
print("Please set the number of processors you want to use!\n");
print(string1);
then
(numProc,isFixed);
fail();
else
equation
numProcSys = System.numProcessors();
Expand Down
14 changes: 14 additions & 0 deletions Compiler/BackEnd/HpcOmTaskGraph.mo
Expand Up @@ -5668,6 +5668,20 @@ algorithm
oCostsOps := (tmpOps,tmpCosts);
end sumUpExecCosts1;

public function roundReal "rounds a real to the nth decimal
author: Waurich TUD 2014-01"
input Real inReal;
input Integer nIn;
output Real outReal;
protected
Integer int;
Real real;
algorithm
real := realMul(inReal,realPow(10.0,intReal(nIn)));
real := realFloor(real);
outReal := realDiv(real,realPow(10.0,intReal(nIn)));
end roundReal;

// public function arrangeGraphInLevels "
// author: Waurich TUD 2013-07"
// input TaskGraph graphIn;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenC.tpl
Expand Up @@ -2175,7 +2175,7 @@ template functionXXX_system0_HPCOM_Level(list<SimEqSystem> derivativEquations, S
//let odeEqs = "#pragma omp parallel sections\n{"
let odeEqs = eqsOfLevel |> eq => equationNamesHPCOM_(eq,derivativEquations,contextSimulationNonDiscrete,modelNamePrefixStr); separator="\n"
<<
#pragma omp parallel sections
#pragma omp parallel sections num_threads(<%getConfigInt(NUM_PROC)%>)
{
<%odeEqs%>
}
Expand Down

0 comments on commit db09538

Please sign in to comment.