Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Conflicts:
	SimulationRuntime/cpp/Core/System/AlgLoopSolverFactory.cpp
	SimulationRuntime/cpp/Include/Core/Math/Array.h
	SimulationRuntime/cpp/Include/Solver/Kinsol/Kinsol.h
	SimulationRuntime/cpp/Solver/Kinsol/Kinsol.cpp
  • Loading branch information
niklwors committed Aug 7, 2015
2 parents de80e2b + 9d54400 commit f4ba1f4
Show file tree
Hide file tree
Showing 76 changed files with 2,271 additions and 2,638 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -85,6 +85,7 @@ SimulationRuntime/c/util/java_interface/src/org/openmodelica/corba/parser/OMCorb
SimulationRuntime/c/util/java_interface/src/org/openmodelica/corba/parser/OMCorbaDefinitionsParser.java
SimulationRuntime/c/util/java_interface/src/org/openmodelica/corba/parser/OMCorbaDefinitions.tokens
SimulationRuntime/cpp/Makefile
SimulationRuntime/cpp/Makefile.env
SimulationRuntime/cpp/Build/
SimulationRuntime/cpp/Debug/
SimulationRuntime/cpp/.cproject
Expand Down
466 changes: 251 additions & 215 deletions Compiler/BackEnd/Differentiate.mo

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Compiler/BackEnd/HpcOmScheduler.mo
Expand Up @@ -5704,6 +5704,11 @@ algorithm
printPredictedExeTimeInfo(serTime,parTime,speedUp,speedUpMax,numProcIn);
then
criticalPathInfo;
case(HpcOmSimCode.TASKDEPSCHEDULE(),_,_,_,_)
equation
((criticalPaths,cpCosts),(criticalPathsWoC,cpCostsWoC)) = HpcOmTaskGraph.getCriticalPaths(taskGraphIn,taskGraphMetaIn);
criticalPathInfo = HpcOmTaskGraph.dumpCriticalPathInfo((criticalPaths,cpCosts),(criticalPathsWoC,cpCostsWoC));
then criticalPathInfo;
else
equation
print("HpcOmScheduler.analyseScheduledTaskGraph failed\n");
Expand Down
79 changes: 56 additions & 23 deletions Compiler/BackEnd/HpcOmTaskGraph.mo
Expand Up @@ -222,7 +222,7 @@ algorithm
tmpSystMapping = List.fold2(comps, getSystemComponents1, iSyst, currentIdx, tmpSystMapping);
//print(stringDelimitList(List.map(comps, BackendDump.printComponent),","));
tmpComps = listAppend(tmpComps,comps);
//print("--getSystemComponents0 end (found " + intString(listLength(comps)) + " of " + intString(numberOfElement) + " components)\n");
//print("--getSystemComponents0 end (found " + intString(listLength(comps)) + " components in system " + intString(currentIdx) + ")\n");
then ((tmpComps, tmpSystMapping, currentIdx+1));
else
equation
Expand Down Expand Up @@ -3122,7 +3122,7 @@ algorithm
end printInComps;

public function printVarCompMapping " prints the information about how the vars are assigned to the graph nodes
author: Waurich TUD 2013-07 / mwalther"
author: Waurich TUD 2013-07 / marcusw"
input array<tuple<Integer, Integer, Integer>> iVarCompMapping;
protected
Integer varIdx, comp, eqSysIdx, varOffset;
Expand All @@ -3135,7 +3135,7 @@ algorithm
end printVarCompMapping;

public function printEqCompMapping " prints the information about which equations are assigned to the graph nodes
author: Waurich TUD 2013-07 / mwalther"
author: Waurich TUD 2013-07 / marcusw"
input array<tuple<Integer,Integer,Integer>> iEqCompMapping;
protected
Integer eqIdx, comp, eqSysIdx, eqOffset;
Expand All @@ -3162,7 +3162,7 @@ algorithm
end printCompParamMapping;

protected function printComponentNames "prints the component names of the taskgraph components
author: Waurich TUD 2013-07 / mwalther"
author: Waurich TUD 2013-07 / marcusw"
input array<String> iCompNames;
protected
Integer compIdx;
Expand All @@ -3176,7 +3176,7 @@ algorithm
end printComponentNames;

protected function printCompDescs "prints the information about the description of the taskgraph nodes for the .graphml file.
author: Waurich TUD 2013-07 / mwalther"
author: Waurich TUD 2013-07 / marcusw"
input array<String> iCompDescs;
protected
Integer compIdx;
Expand All @@ -3190,7 +3190,7 @@ algorithm
end printCompDescs;

protected function printExeCosts " prints the information about the execution costs of every component in task graph meta
author: Waurich TUD 2013-07 / mwalther"
author: Waurich TUD 2013-07 / marcusw"
input array<tuple<Integer,Real>> iExeCosts;
protected
Integer compIdx;
Expand All @@ -3205,7 +3205,7 @@ algorithm
end printExeCosts;

protected function printCommCosts " prints the information about the the communication costs of every edge.
author:Waurich TUD 2013-06 / mwalther"
author:Waurich TUD 2013-06 / marcusw"
input array<Communications> iCommCosts;
protected
Integer nodeIdx;
Expand Down Expand Up @@ -3235,7 +3235,7 @@ algorithm
end printCommCost;

public function printNodeMarks " prints the information about additional NodeMark
author: Waurich TUD 2013-07 / mwalther"
author: Waurich TUD 2013-07 / marcusw"
input array<Integer> iNodeMarks;
protected
Integer compIdx, mark;
Expand All @@ -3248,7 +3248,7 @@ algorithm
end printNodeMarks;

public function printComponentInformations "function to print the component informations of task graph meta
author:mwalther"
author:marcusw"
input array<ComponentInfo> iComponentInformations;
protected
Integer compIdx;
Expand Down Expand Up @@ -3334,7 +3334,6 @@ algorithm
end matchcontinue;
end printCriticalPathInfo;


protected function printCriticalPathInfo1"prints one criticalPath.
author: Waurich TUD 2013-07"
input list<list<Integer>> criticalPathsIn;
Expand All @@ -3343,7 +3342,6 @@ algorithm
print(intString(cpIdx)+". path: "+intLstString(listGet(criticalPathsIn,cpIdx))+"\n");
end printCriticalPathInfo1;


//--------------------------
// Functions to merge nodes
//--------------------------
Expand Down Expand Up @@ -4997,6 +4995,8 @@ algorithm
(systComps,systCompEqSysMapping) = getSystemComponents(iDae);
systCompsArray = listArray(systComps);
(graphComps,graphCompEqSysMapping) = getGraphComponents(iMeta,systCompsArray,systCompEqSysMapping);
//print("validateTaskGraphMeta: graph components are " + stringDelimitList(List.map(graphComps, BackendDump.printComponent), ",") + "\n");
//print("validateTaskGraphMeta: system components are " + stringDelimitList(List.map(systComps, BackendDump.printComponent), ",") + "\n");
((_,_,systCompEqSysMappingIdx)) = validateTaskGraphMeta0(systCompEqSysMapping,(1,systComps,{}));
((_,_,graphCompEqSysMappingIdx)) = validateTaskGraphMeta0(graphCompEqSysMapping,(1,graphComps,{}));
true = validateComponents(graphCompEqSysMappingIdx,systCompEqSysMappingIdx);
Expand All @@ -5010,7 +5010,7 @@ algorithm
end matchcontinue;
end validateTaskGraphMeta;

public function validateTaskGraphMeta0 "author: marcusw
protected function validateTaskGraphMeta0 "author: marcusw
Implementation of validateTaskGraphMeta."
input array<tuple<BackendDAE.EqSystem,Integer>> iEqSysMapping;
input tuple<Integer,BackendDAE.StrongComponents,list<tuple<BackendDAE.StrongComponent,Integer>>> iCompsTpl; //<current Index, list of remaining strong components, result>
Expand All @@ -5027,6 +5027,7 @@ algorithm
equation
((_,eqSysIdx)) = arrayGet(iEqSysMapping,currentIdx);
oCompEqSysMapping = (head,eqSysIdx)::iCompEqSysMapping;
//print("validateTaskGraphMeta0: Adding head " + BackendDump.printComponent(head) + " with equation system index " + intString(eqSysIdx) + "\n");
tmpCompsTpl = validateTaskGraphMeta0(iEqSysMapping,(currentIdx+1,rest,oCompEqSysMapping));
then tmpCompsTpl;
else iCompsTpl;
Expand All @@ -5050,18 +5051,21 @@ algorithm
algorithm
sortedGraphComps := List.sort(graphComps,compareComponents);
sortedSystComps := List.sort(systComps,compareComponents);
//true := List.isEqual(sortedGraphComps, sortedSystComps, true);

//print("validateTaskGraphMeta: sorted graph components are \n" + stringDelimitList(List.map(List.map(sortedGraphComps, Util.tuple21), BackendDump.printComponent), ",") + "\n");
//print("validateTaskGraphMeta: sorted system components are \n" + stringDelimitList(List.map(List.map(sortedSystComps, Util.tuple21), BackendDump.printComponent), ",") + "\n");

if intNe(listLength(sortedSystComps),listLength(sortedGraphComps)) then print("the graph and the system have a difference number of components.\n"); end if;
isEqual := true;
while isEqual and not listEmpty(sortedGraphComps) loop
tpl1::sortedGraphComps := sortedGraphComps;
tpl2::sortedSystComps := sortedSystComps;
(comp1,i1) := tpl1;
(comp2,i2) := tpl2;
if BackendDAEUtil.componentsEqual(comp1,comp2) and intEq(i1,i2) then isEqual:= true;
if componentsEqual(tpl1, tpl2) then isEqual:= true;
else
isEqual := false;
print("comp"+intString(i1)+BackendDump.printComponent(comp1)+" is not equal to "+"comp"+intString(i2)+BackendDump.printComponent(comp2)+"\n");
print("comp " + intString(i1) + BackendDump.printComponent(comp1) + " is not equal to " + "comp" + intString(i2) + BackendDump.printComponent(comp2) + "\n");
end if;
end while;
then true;
Expand Down Expand Up @@ -5099,8 +5103,8 @@ algorithm
case(_,(_,NONE())) then ((true,SOME(currentComp_idx)));
case((currentComp,idxCurrent),(_,SOME(lastComp_idx as (lastComp, idxLast))))
equation
false = compareComponents(currentComp_idx,lastComp_idx);
print("Component duplicate detected in eqSystem " + intString(idxCurrent) + ": current: " + BackendDump.printComponent(currentComp) + " last " + BackendDump.printComponent(lastComp) + ".\n");
true = componentsEqual(currentComp_idx,lastComp_idx);
print("Component duplicate detected: current: " + BackendDump.printComponent(currentComp) + " (eqSystem " + intString(idxCurrent) + ") last " + BackendDump.printComponent(lastComp) + " (eqSystem " + intString(idxLast) + ").\n");
then ((false,SOME(currentComp_idx)));
else ((true, SOME(currentComp_idx)));
end matchcontinue;
Expand Down Expand Up @@ -5199,24 +5203,53 @@ algorithm
end matchcontinue;
end getGraphComponents2;

protected function compareComponents "author: marcusw
Compares the given components and returns false if they are equal."
protected function componentsEqual "author: marcusw
Compares the given components and returns true if they are equal."
input tuple<BackendDAE.StrongComponent,Integer> iComp1;
input tuple<BackendDAE.StrongComponent,Integer> iComp2; //<component, eqSystIdx>
output Boolean res;
protected
String comp1Str,comp2Str;
Integer minLength, comp1Idx, comp2Idx;
Integer comp1Idx, comp2Idx;
BackendDAE.StrongComponent comp1, comp2;
algorithm
(comp1, comp1Idx) := iComp1;
(comp2, comp2Idx) := iComp2;
comp1Str := BackendDump.printComponent(comp1) + "_" + intString(comp1Idx);
comp2Str := BackendDump.printComponent(comp2) + "_" + intString(comp2Idx);
minLength := intMin(stringLength(comp1Str),stringLength(comp2Str));
res := intGt(System.strncmp(comp1Str, comp2Str, minLength), 0);
end compareComponents;
if(intNe(stringLength(comp1Str),stringLength(comp2Str))) then
res := false;
else
res := intEq(System.strncmp(comp1Str, comp2Str, stringLength(comp1Str)), 0);
end if;
end componentsEqual;

protected function compareComponents "author: marcusw
Compares the given components and returns true if the name of the first component is lower are equal."
input tuple<BackendDAE.StrongComponent,Integer> iComp1;
input tuple<BackendDAE.StrongComponent,Integer> iComp2; //<component, eqSystIdx>
output Boolean res;
protected
String comp1Str,comp2Str;
Integer minLength, compRes, comp1Idx, comp2Idx;
BackendDAE.StrongComponent comp1, comp2;
algorithm
if(componentsEqual(iComp1, iComp2)) then
res := false;
else
(comp1, comp1Idx) := iComp1;
(comp2, comp2Idx) := iComp2;
comp1Str := BackendDump.printComponent(comp1) + "_" + intString(comp1Idx);
comp2Str := BackendDump.printComponent(comp2) + "_" + intString(comp2Idx);
minLength := intMin(stringLength(comp1Str), stringLength(comp2Str));
compRes := System.strncmp(comp1Str, comp2Str, minLength);
if(intEq(compRes, 0)) then
res := intLt(stringLength(comp1Str), stringLength(comp2Str));
else
res := intLt(compRes, 0);
end if;
end if;
end compareComponents;

//------------------------------------
// Evaluation and analysing functions
Expand Down
6 changes: 1 addition & 5 deletions Compiler/BackEnd/OpenTURNS.mo
Expand Up @@ -77,13 +77,9 @@ constant String cStrWrapperCompileCmd = "wrapper_template.compile.cmd";
constant String cStrInvokeOpenTurnsCmd = "invoke.cmd";

public function generateOpenTURNSInterface "generates the dll and the python script for connections with OpenTURNS"
input FCore.Cache cache;
input FCore.Graph graph;
input BackendDAE.BackendDAE inDaelow;
input DAE.FunctionTree inFunctionTree;
input Absyn.Path inPath;
input Absyn.Program inProgram;
input DAE.DAElist inDAElist;
input String templateFile "the filename to the template file (python script)";
output String scriptFile "the name of the generated file";

Expand Down Expand Up @@ -117,7 +113,7 @@ algorithm
//print("strippedDae :");
//BackendDump.dump(strippedDae);
_ := System.realtimeTock(ClockIndexes.RT_CLOCK_BACKEND); // Is this necessary?
(_,libs,fileDir,_,_) := SimCodeMain.generateModelCode(strippedDae,inProgram,inDAElist,inPath,cname_str,SOME(simSettings),Absyn.FUNCTIONARGS({},{}));
(libs, fileDir, _, _) := SimCodeMain.generateModelCode(strippedDae, inProgram, inPath, cname_str, SOME(simSettings), Absyn.FUNCTIONARGS({}, {}));

//print("..compiling, fileNamePrefix = "+fileNamePrefix+"\n");
CevalScript.compileModel(fileNamePrefix , libs);
Expand Down
12 changes: 10 additions & 2 deletions Compiler/BackEnd/Tearing.mo
Expand Up @@ -1707,11 +1707,16 @@ protected
BackendDAE.AdjacencyMatrixTEnhanced meT;
BackendDAE.BackendDAEType DAEtype;
BackendDAE.TearingSet strictTearingSet;
BackendDAE.StateSets stateSets;
Option<BackendDAE.TearingSet> casualTearingSet;
list<BackendDAE.Equation> eqn_lst;
list<BackendDAE.Var> var_lst;
Boolean linear,simulation,b;
Boolean linear,simulation,b,noDynamicStateSelection;
algorithm

BackendDAE.EQSYSTEM(stateSets = stateSets) := isyst;
noDynamicStateSelection := listEmpty(stateSets);

BackendDAE.SHARED(backendDAEType=DAEtype) := ishared;
simulation := stringEq(BackendDump.printBackendDAEType2String(DAEtype), "simulation");

Expand Down Expand Up @@ -1827,7 +1832,7 @@ algorithm
// Determine casual tearing set if dynamic tearing is enabled
// *****************************************************************

if simulation and Config.dynamicTearing() then
if simulation and noDynamicStateSelection and Config.dynamicTearing() then

if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
print("\n\nDetermine CASUAL TEARING SET\n" + BORDER + BORDER + "\n\n");
Expand Down Expand Up @@ -1927,6 +1932,9 @@ algorithm
end if;

else
if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
print("Note:\n=====\nNo dynamic Tearing for this strong component. Check if\n- flag 'dynamicTearing' is set\n- strong component contains statesets\n- system belongs to simulation\n\n");
end if;
if not b and not Flags.getConfigBool(Flags.FORCE_TEARING) then
if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
print("\nNote:\n=====\nTearing set is discarded because it is not smaller than the original set. Use +forceTearing to prevent this.\n\n");
Expand Down
49 changes: 25 additions & 24 deletions Compiler/FrontEnd/ClassLoader.mo
Expand Up @@ -128,20 +128,6 @@ algorithm
end matchcontinue;
end loadClass;

protected function existRegularFile
"Checks if a file exists"
input String filename;
algorithm
true := System.regularFileExists(filename);
end existRegularFile;

public function existDirectoryFile
"Checks if a directory exist"
input String filename;
algorithm
true := System.directoryExists(filename);
end existDirectoryFile;

protected function loadClassFromMps
"Loads a class or classes from a set of paths in OPENMODELICALIBRARY"
input String id;
Expand Down Expand Up @@ -272,7 +258,10 @@ algorithm
mp_1 = stringAppendList({mp,pd,pack});
packagefile = stringAppendList({mp_1,pd,"package.mo"});
orderfile = stringAppendList({mp_1,pd,"package.order"});
existRegularFile(packagefile);
if not System.regularFileExists(packagefile) then
Error.addInternalError("Expected file " + packagefile + " to exist", sourceInfo());
fail();
end if;
// print("Look for " + packagefile + "\n");
(cl as Absyn.CLASS(name,pp,fp,ep,r,Absyn.PARTS(tv,ca,cp,ann,cmt),info)) = parsePackageFile(packagefile, strategy, true, within_, id);
// print("Got " + packagefile + "\n");
Expand Down Expand Up @@ -347,14 +336,16 @@ algorithm
pd = System.pathDelimiter();
file = mp + pd + id + "/package.mo";
bDirectoryAndFileExists = System.directoryExists(mp + pd + id) and System.regularFileExists(file);
if (bDirectoryAndFileExists)
then
if bDirectoryAndFileExists then
cl = loadCompletePackageFromMp(id,id,mp,strategy,w1,Error.getNumErrorMessages());
ei = Absyn.makeClassElement(cl);
cps = mergeBefore(Absyn.PUBLIC({ei}),acc);
else
file = mp + pd + id + ".mo";
true = System.regularFileExists(file);
if not System.regularFileExists(file) then
Error.addInternalError("Expected file " + file + " to exist", sourceInfo());
fail();
end if;
cl = parsePackageFile(file, strategy, false, w1, id);
ei = Absyn.makeClassElement(cl);
cps = mergeBefore(Absyn.PUBLIC({ei}),acc);
Expand Down Expand Up @@ -383,14 +374,24 @@ algorithm
Absyn.PROGRAM(cs,w2) := getProgramFromStrategy(name, strategy);
classNames := List.map(cs, Absyn.getClassName);
str := stringDelimitList(classNames,", ");
Error.assertionOrAddSourceMessage(listLength(cs)==1, Error.LIBRARY_ONE_PACKAGE_PER_FILE, {str}, SOURCEINFO(name,true,0,0,0,0,0.0));
cl::{} := cs;
Absyn.CLASS(name=cname,body=body,info=info) := cl;
Error.assertionOrAddSourceMessage(stringEqual(cname,pack), Error.LIBRARY_UNEXPECTED_NAME, {pack,cname}, info);
if not listLength(cs)==1 then
Error.addSourceMessage(Error.LIBRARY_ONE_PACKAGE_PER_FILE, {str}, SOURCEINFO(name,true,0,0,0,0,0.0));
fail();
end if;
(cl as Absyn.CLASS(name=cname,body=body,info=info))::{} := cs;
if not stringEqual(cname,pack) then
Error.addSourceMessage(Error.LIBRARY_UNEXPECTED_NAME, {pack,cname}, info);
fail();
end if;
s1 := Absyn.withinString(w1);
s2 := Absyn.withinString(w2);
Error.assertionOrAddSourceMessage(Absyn.withinEqual(w1,w2) or Config.languageStandardAtMost(Config.MODELICA_2_X()), Error.LIBRARY_UNEXPECTED_WITHIN, {s1,s2}, info);
Error.assertionOrAddSourceMessage((not expectPackage) or Absyn.isParts(body), Error.LIBRARY_EXPECTED_PARTS, {pack}, info);
if not (Absyn.withinEqual(w1,w2) or Config.languageStandardAtMost(Config.MODELICA_2_X())) then
Error.addSourceMessage(Error.LIBRARY_UNEXPECTED_WITHIN, {s1,s2}, info);
fail();
elseif expectPackage and not Absyn.isParts(body) then
Error.addSourceMessage(Error.LIBRARY_EXPECTED_PARTS, {pack}, info);
fail();
end if;
end parsePackageFile;

protected function getBothPackageAndFilename
Expand Down
7 changes: 3 additions & 4 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -1850,10 +1850,9 @@ external "builtin";
annotation(preferredView="text");
end mkdir;

function remove "removes a file or directory of given path (which may be either relative or absolute)
returns 0 if path was removed successfully."
input String newDirectory;
output Boolean success;
function remove "removes a file or directory of given path (which may be either relative or absolute)."
input String path;
output Boolean success "Returns true on success.";
external "builtin";
annotation(preferredView="text");
end remove;
Expand Down

0 comments on commit f4ba1f4

Please sign in to comment.