Skip to content

Commit

Permalink
Clean up in HPCOM module.
Browse files Browse the repository at this point in the history
Redeclared public functions that are not used in other packages to protected with respect to compile efficiently (https://trac.openmodelica.org/OpenModelica/wiki/WritingEfficientMetaModelica).
  • Loading branch information
mflehmig authored and OpenModelica-Hudson committed Jan 11, 2016
1 parent dc2d3ef commit 71918c7
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 60 deletions.
4 changes: 2 additions & 2 deletions Compiler/BackEnd/HpcOmBenchmark.mo
Expand Up @@ -98,7 +98,7 @@ algorithm
end matchcontinue;
end readCalcTimesFromFile;

public function readCalcTimesFromXml "author: marcusw
protected function readCalcTimesFromXml "author: marcusw
Reads the calculation times of the different simCode-equations out of the given xml-file (fileName). Make sure that the file exists before invoking this
method, otherwise it will return an misleading error-message.
Deprecated since commit r20267. Use the generated *.json-file instead."
Expand All @@ -111,7 +111,7 @@ algorithm
calcTimes := expandCalcTimes(tmpResult,{});
end readCalcTimesFromXml;

public function readCalcTimesFromJson "author: marcusw
protected function readCalcTimesFromJson "author: marcusw
Reads the calculation times of the different simCode-equations out of the given json-file (fileName). Make sure that the file exists before invoking this
method, otherwise it will return an misleading error-message."
input String fileName;
Expand Down
16 changes: 8 additions & 8 deletions Compiler/BackEnd/HpcOmEqSystems.mo
Expand Up @@ -84,7 +84,7 @@ end EqSys;
// start functions for handling linearTornSystems from here
//-------------------------------------------------//

public function partitionLinearTornSystem"checks the EqSystem for tornSystems in order to dissassemble them into various SingleEquation and a reduced EquationSystem.
public function partitionLinearTornSystem "checks the EqSystem for tornSystems in order to dissassemble them into various SingleEquation and a reduced EquationSystem.
This is useful in order to reduce the execution costs of the equationsystem and generate a bunch of parallel singleEquations. use +d=doLienarTearing +partlintorn=x to activate it.
Remark: this is still under development

Expand Down Expand Up @@ -112,10 +112,11 @@ algorithm
end matchcontinue;
end partitionLinearTornSystem;

public function reduceLinearTornSystem "author:Waurich TUD 2013-09
checks the EqSystem for tornSystems in order to dissassemble them into various SingleEquation and a reduced EquationSystem.
This is useful in order to reduce the execution costs of the equationsystem and generate a bunch of parallel singleEquations. use +d=doLienarTearing +partlintorn=x to activate it.
Remark: this is still under development"
protected function reduceLinearTornSystem "author: Waurich TUD 2013-09
Checks the EqSystem for tornSystems in order to dissassemble them into various SingleEquation and
a reduced EquationSystem. This is useful in order to reduce the execution costs of the equationsystem
and generate a bunch of parallel singleEquations. use +d=doLienarTearing +partlintorn=x to activate it.
Remark: this is still under development"
input BackendDAE.EqSystem systIn;
input BackendDAE.Shared sharedIn;
input Integer tornSysIdxIn;
Expand Down Expand Up @@ -147,7 +148,6 @@ algorithm
end matchcontinue;
end reduceLinearTornSystem;


protected function reduceLinearTornSystem1 "author: Waurich TUD 2013-09
traverses all StrongComponents for tornSystems, reduces them and rebuilds the BLT, the matching and the info about vars and equations"
input Integer compIdx;
Expand Down Expand Up @@ -1577,8 +1577,8 @@ algorithm
end if;
end containsFunctioncallOfCref;

public function getCallExpLst "author:Waurich TUD 2015-08
returns the list of expressions from a call."
protected function getCallExpLst "author: Waurich TUD 2015-08
Returns the list of expressions from a call."
input DAE.Exp eIn;
input list<DAE.Exp> eLstIn;
output DAE.Exp eOut;
Expand Down
17 changes: 9 additions & 8 deletions Compiler/BackEnd/HpcOmScheduler.mo
Expand Up @@ -1335,7 +1335,8 @@ algorithm
str := s + "---------------------\n";
end dumpTaskDepSchedule;

public function printTaskList
protected function printTaskList "
Printing the given list of tasks using the dumpTaskList function."
input list<HpcOmSimCode.Task> iTaskList;
algorithm
print(dumpTaskList(iTaskList));
Expand Down Expand Up @@ -1902,7 +1903,7 @@ algorithm
sum := List.fold(reals,realAdd,0.0);
end realSum;

public function deleteIntListMembers "author: Waurich TUD 2014-07
protected function deleteIntListMembers "author: Waurich TUD 2014-07
Deletes all entries of lst2 in lst1."
input list<Integer> lst1;
input list<Integer> lst2;
Expand Down Expand Up @@ -1934,7 +1935,7 @@ algorithm
oMeta := iMeta;
end createLevelSchedule;

public function createLevelScheduleForLevel "author: marcusw
protected function createLevelScheduleForLevel "author: marcusw
Handles all tasks of one level."
input list<Integer> iTasksOfLevel;
input HpcOmTaskGraph.TaskGraph iGraph;
Expand Down Expand Up @@ -4912,8 +4913,8 @@ algorithm
end match;
end traverseAndUpdateThreadsInSchedule;

protected function createScheduleFromAssignments "author:Waurich TUD 2013-12
creates the ThreadSchedule from the taskAssignment i.e. which task is computed in which thread."
protected function createScheduleFromAssignments "author: Waurich TUD 2013-12
Creates the ThreadSchedule from the taskAssignment i.e. which task is computed in which thread."
input array<Integer> taskAss;
input array<list<Integer>> procAss;
input Option<list<Integer>> orderOpt;
Expand Down Expand Up @@ -5312,7 +5313,7 @@ algorithm
(outElement,outIdx,found) := getMemberOnTrueWithIdx1(1,inValue,inList,inCompFunc);
end getMemberOnTrueWithIdx;

public function getMemberOnTrueWithIdx1 "author:Waurich TUD 2013-11
protected function getMemberOnTrueWithIdx1 "author:Waurich TUD 2013-11
implementation of getMemberOnTrueWithIdx."
input Integer inIdx;
input Real inValue;
Expand Down Expand Up @@ -5640,7 +5641,7 @@ algorithm
print(dumpSchedule(iSchedule));
end printSchedule;

public function dumpSchedule
protected function dumpSchedule
input HpcOmSimCode.Schedule iSchedule;
output String str;
protected
Expand Down Expand Up @@ -5941,7 +5942,7 @@ algorithm
speedUpMaxOut := speedUpMax;
end predictExecutionTime;

public function printPredictedExeTimeInfo "author:Waurich TUD 2013-11
protected function printPredictedExeTimeInfo "author:Waurich TUD 2013-11
function to print the information about the predicted execution times."
input Real serTime;
input Real parTime;
Expand Down
73 changes: 48 additions & 25 deletions Compiler/BackEnd/HpcOmTaskGraph.mo
Expand Up @@ -247,7 +247,7 @@ algorithm
oMapping := listAppend(iMapping,{(isyst,isystIdx)});
end getSystemComponents1;

public function getNumberOfSystemComponents "author: marcusw
protected function getNumberOfSystemComponents "author: marcusw
Returns the number of components stored in the BackendDAE."
input BackendDAE.BackendDAE iDae;
output Integer oNumOfComps;
Expand All @@ -258,7 +258,7 @@ algorithm
oNumOfComps := List.fold(eqs, getNumberOfEqSystemComponents, 0);
end getNumberOfSystemComponents;

public function getNumberOfEqSystemComponents "author: marcusw
protected function getNumberOfEqSystemComponents "author: marcusw
Adds the number of components in the given eqSystem to the iNumOfComps."
input BackendDAE.EqSystem iEqSystem;
input Integer iNumOfComps;
Expand Down Expand Up @@ -765,7 +765,7 @@ algorithm
end matchcontinue;
end getVarString;

public function shortenVarString "author: Waurich TUD 2013-06
protected function shortenVarString "author: Waurich TUD 2013-06
Terminates var string at :"
input List<String> iString;
output List<String> oString;
Expand Down Expand Up @@ -1248,7 +1248,7 @@ algorithm
end match;
end getVarsBySCC;

public function tupleToString "author: marcusw
protected function tupleToString "author: marcusw
Returns the given tuple as string."
input tuple<Integer,Integer> inTuple;
output String result;
Expand Down Expand Up @@ -1878,7 +1878,7 @@ algorithm
end match;
end getAllSuccessors2;

public function getChildNodes "author: waurich TUD 2013-06
protected function getChildNodes "author: waurich TUD 2013-06
Gets the successor nodes for a list of parent nodes."
input array<list<Integer>> adjacencyLstIn;
input list<Integer> parents;
Expand Down Expand Up @@ -2391,7 +2391,7 @@ algorithm
oTpl := (oLst,map);
end mapIntegers;

public function getEventSystem "author: marcusw
protected function getEventSystem "author: marcusw
Gets the graph and the adjacencyLst only for the EventSystem. This means that all branches which leads to a node solving
a whencondition or another boolean condition will remain."
input TaskGraph iTaskGraph;
Expand Down Expand Up @@ -3018,7 +3018,7 @@ algorithm
print("\n");
end printTaskGraph;

public function dumpAdjacencyLst "author: Waurich TUD 2013-07
protected function dumpAdjacencyLst "author: Waurich TUD 2013-07
Prints the adjacencyLst."
input list<list<Integer>> inIntegerLstLst;
input Integer rowIndex;
Expand All @@ -3038,7 +3038,7 @@ algorithm
end match;
end dumpAdjacencyLst;

public function dumpAdjacencyRow "author: PA
protected function dumpAdjacencyRow "author: PA
Helper function to dumpIncidenceMatrix2."
input list<Integer> inIntegerLst;
algorithm
Expand Down Expand Up @@ -3106,7 +3106,7 @@ algorithm
print("\n");
end printTaskGraphMeta;

public function printInComps "author:Waurich TUD 2013-06
protected function printInComps "author:Waurich TUD 2013-06
Prints the information about the assigned components to a taskgraph node."
input array<list<Integer>> iInComps;
protected
Expand All @@ -3120,7 +3120,7 @@ algorithm
print("--------------------------------\n");
end printInComps;

public function printVarCompMapping "author: Waurich TUD 2013-07 / marcusw
protected function printVarCompMapping "author: Waurich TUD 2013-07 / marcusw
Prints the information about how the vars are assigned to the graph nodes."
input array<tuple<Integer, Integer, Integer>> iVarCompMapping;
protected
Expand All @@ -3134,7 +3134,7 @@ algorithm
print("--------------------------------\n");
end printVarCompMapping;

public function printEqCompMapping "author: Waurich TUD 2013-07 / marcusw
protected function printEqCompMapping "author: Waurich TUD 2013-07 / marcusw
Prints the information about which equations are assigned to the graph nodes."
input array<tuple<Integer,Integer,Integer>> iEqCompMapping;
protected
Expand All @@ -3148,7 +3148,7 @@ algorithm
print("--------------------------------\n");
end printEqCompMapping;

public function printCompParamMapping "author: marcusw
protected function printCompParamMapping "author: marcusw
Prints the information which components contains which parameters."
input array<list<Integer>> iCompParamMapping;
protected
Expand Down Expand Up @@ -3219,7 +3219,7 @@ algorithm
print("--------------------------------\n");
end printCommCosts;

public function printCommCost "author: marcusw
protected function printCommCost "author: marcusw
Prints the information about the the communication costs of one edge."
input Communication iComm;
output String oCommString;
Expand All @@ -3235,7 +3235,7 @@ algorithm
oCommString := "(target node: " + intString(childNode) + " ints: " + intString(numberOfIntegers) + " floats: " + intString(numberOfFloats) + " booleans: " + intString(numberOfBooleans) + " [requiredTime: " + realString(requiredTime) + " for " + intString(numberOfVars) + " variables)";
end printCommCost;

public function printNodeMarks "author: Waurich TUD 2013-07 / marcusw
protected function printNodeMarks "author: Waurich TUD 2013-07 / marcusw
Prints the information about additional NodeMark."
input array<Integer> iNodeMarks;
protected
Expand All @@ -3248,7 +3248,7 @@ algorithm
print("--------------------------------\n");
end printNodeMarks;

public function printComponentInformations "author: marcusw
protected function printComponentInformations "author: marcusw
Function to print the component information of task graph meta."
input array<ComponentInfo> iComponentInformations;
protected
Expand Down Expand Up @@ -3313,7 +3313,7 @@ algorithm
oString := intLstString(listGet(criticalPathsIn,cpIdx))+"";
end dumpCriticalPathInfo1;

public function printCriticalPathInfo "author: Waurich TUD 2013-07
protected function printCriticalPathInfo "author: Waurich TUD 2013-07
Prints the criticalPath and the costs."
input list<list<Integer>> criticalPathsIn;
input Real cpCosts;
Expand Down Expand Up @@ -3348,7 +3348,7 @@ end printCriticalPathInfo1;
// Functions to merge nodes
//--------------------------

public function mergeSingleNodes "
protected function mergeSingleNodes "
Merges all single nodes. The max number of remaining single nodes is numProc."
input TaskGraph iTaskGraph;
input TaskGraphMeta iTaskGraphMeta;
Expand Down Expand Up @@ -3552,7 +3552,7 @@ algorithm
end mergeSimpleNodes;

public function mergeParentNodes "author: marcusw, waurich
Merges parent nodes into child if this produces a shorter execution time."
Merges parent nodes into child if this produces a shorter execution time due to omitted communication costs."
input TaskGraph graphIn;
input TaskGraph graphTIn;
input TaskGraphMeta graphDataIn;
Expand Down Expand Up @@ -3633,6 +3633,29 @@ algorithm
end matchcontinue;
end mergeParentNodes0;

protected function mergeSinkNodes "author: mflehmig
Nodes that have a only one dependency to the very same node are merged with this 'sink' node."
input TaskGraph graphIn;
input TaskGraph graphTIn;
input TaskGraphMeta graphDataIn;
input array<Integer> contractedTasksIn;
output TaskGraph graphOut;
output TaskGraph graphTOut;
output TaskGraphMeta graphDataOut;
output array<Integer> contractedTasksOut;
output Boolean changed;
protected
array<Integer> alreadyMerged;
list<list<Integer>> mergedNodes;
algorithm
alreadyMerged := arrayCreate(arrayLength(graphIn),0);
mergedNodes := mergeParentNodes0(graphIn, graphTIn, graphDataIn, contractedTasksIn, alreadyMerged, 1, {});
//print("mergedNodes "+stringDelimitList(List.map(mergedNodes,intLstString),"\n")+"\n");
(graphOut,graphTOut,graphDataOut,contractedTasksOut) := contractNodesInGraph(mergedNodes,graphIn,graphTIn,graphDataIn,contractedTasksIn);
changed := not listEmpty(mergedNodes);
//print("contractedTasksOut "+stringDelimitList(List.map(arrayList(contractedTasksOut),intString),"\n")+"\n");
end mergeSinkNodes;

public function markSystemComponents "author: marcusw
Mark all components that are part of the given Task Graph in the target task graph meta with (ComponentInfo OR iComponentInfo)."
input TaskGraph iTaskGraph;
Expand Down Expand Up @@ -4150,7 +4173,7 @@ algorithm
graphDataOut := TASKGRAPHMETA(inComps,varCompMapping,eqCompMapping,compParamMapping,compNames,compDescs,exeCosts,commCosts,nodeMark,compInformations);
end getMergedSystemData;

public function updateCompNamesForMerging "author: Waurich TUD 2013-07
protected function updateCompNamesForMerging "author: Waurich TUD 2013-07
Updates the compNames with the merging information."
input Integer compIdx;
input array<list<Integer>> inComps;
Expand Down Expand Up @@ -4532,7 +4555,7 @@ algorithm
end matchcontinue;
end createCosts;

public function estimateCosts "author: Waurich TUD 09-2013
protected function estimateCosts "author: Waurich TUD 09-2013
Estimates the communication and execution costs very roughly so hpcom can work with something when there is no prof_xml file."
input BackendDAE.BackendDAE daeIn;
input TaskGraphMeta taskGraphMetaIn;
Expand Down Expand Up @@ -5733,7 +5756,7 @@ algorithm
end transposeCommCosts1;

//TODO: Can this be merged with getCommCostBetweenNodes?
public function getCommunicationCost "author: waurich TUD 2013-06.
protected function getCommunicationCost "author: waurich TUD 2013-06.
Gets the communication cost for an edge from parent node to child node.
REMARK: use the primal indeces!!!!!!"
input Integer childIdx;
Expand Down Expand Up @@ -5792,7 +5815,7 @@ algorithm
oCommCost := requiredTime;
end getCommCostTimeBetweenNodes;

public function getCommCostBetweenNodes "author: marcusw
protected function getCommCostBetweenNodes "author: marcusw
Get the edge with highest communication costs between the given nodes."
input Integer iParentNodeIdx;
input Integer iChildNodeIdx;
Expand Down Expand Up @@ -6468,7 +6491,7 @@ algorithm
end matchcontinue;
end getSimEqIdxSimEqMapping1;

public function getSimCodeEqByIndexAndMapping "author: marcusw
protected function getSimCodeEqByIndexAndMapping "author: marcusw
Returns the SimEqSystem which has the given Index."
input array<Option<SimCode.SimEqSystem>> iSimEqIdxSimEqMapping; //All SimEqSystems
input Integer iIdx; //The index of the required system
Expand Down Expand Up @@ -6585,7 +6608,7 @@ algorithm
end match;
end getSimCodeEqsByTaskList0;

public function dumpSimEqSCCMapping "author: marcusw
protected function dumpSimEqSCCMapping "author: marcusw
Prints the given mapping out to the console."
input array<Integer> iSccMapping;
protected
Expand All @@ -6611,7 +6634,7 @@ algorithm
oIndexText := (iIndex+1,text);
end dumpSimEqSCCMapping1;

public function dumpSccSimEqMapping "author: marcusw
protected function dumpSccSimEqMapping "author: marcusw
Prints the given mapping out to the console."
input array<list<Integer>> iSccMapping;
protected
Expand Down

0 comments on commit 71918c7

Please sign in to comment.