Skip to content

Commit

Permalink
new subclock partitioning implementation with new partition adjacency…
Browse files Browse the repository at this point in the history
… matrix
  • Loading branch information
vwaurich authored and OpenModelica-Hudson committed Jun 14, 2017
1 parent 95cea6e commit 7827a66
Show file tree
Hide file tree
Showing 6 changed files with 1,057 additions and 302 deletions.
2 changes: 2 additions & 0 deletions Compiler/BackEnd/BackendDAE.mo
Expand Up @@ -88,6 +88,8 @@ public uniontype SubClock
MMath.Rational shift;
Option<String> solver;
end SUBCLOCK;
record INFERED_SUBCLOCK
end INFERED_SUBCLOCK;
end SubClock;

public constant SubClock DEFAULT_SUBCLOCK = SUBCLOCK(MMath.RAT1, MMath.RAT0, NONE());
Expand Down
12 changes: 7 additions & 5 deletions Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -1626,7 +1626,7 @@ algorithm
(systs,oshared) := matchcontinue (isyst,ishared,numErrorMessages,throwNoError)
local
BackendDAE.IncidenceMatrix m, mT, rm, rmT;
array<Integer> ixs, rixs;
array<Integer> eqPartMap, varPartMap, rixs;
array<Boolean> vars, rvars;
Boolean b;
Integer i;
Expand All @@ -1638,20 +1638,22 @@ algorithm
funcs = BackendDAEUtil.getFunctions(ishared);
(syst, m, mT) = BackendDAEUtil.getIncidenceMatrixfromOption(syst, BackendDAE.NORMAL(), SOME(funcs));
(rm, rmT) = BackendDAEUtil.removedIncidenceMatrix(syst, BackendDAE.NORMAL(), SOME(funcs));
ixs = arrayCreate(arrayLength(m), 0);
eqPartMap = arrayCreate(arrayLength(m), 0);
varPartMap = arrayCreate(arrayLength(mT), 0);
rixs = arrayCreate(arrayLength(rm), 0);
vars = arrayCreate(arrayLength(mT), false);
rvars = arrayCreate(arrayLength(rmT), false);
// ixsT = arrayCreate(arrayLength(mT),0);
i = SynchronousFeatures.partitionIndependentBlocks0(m, mT, rm, rmT, ixs, rixs, vars, rvars);
i = SynchronousFeatures.partitionIndependentBlocks0(m, mT, rm, rmT, eqPartMap, varPartMap, rixs, vars, rvars);
// i2 = SynchronousFeatures.partitionIndependentBlocks0(mT,m,ixsT);
b = i > 1;
// bcall2(b,BackendDump.dumpBackendDAE,BackendDAE.DAE({syst},shared), "partitionIndependentBlocksHelper");
// printPartition(b,ixs);
systs = if b then SynchronousFeatures.partitionIndependentBlocksSplitBlocks(i, syst, ixs, rixs, mT, rmT, throwNoError) else {syst};
systs = if b then SynchronousFeatures.partitionIndependentBlocksSplitBlocks(i, syst, eqPartMap, rixs, mT, rmT, throwNoError) else {syst};
// print("Number of partitioned systems: " + intString(listLength(systs)) + "\n");
// List.map1_0(systs, BackendDump.dumpEqSystem, "System");
GC.free(ixs);
GC.free(eqPartMap);
GC.free(varPartMap);
GC.free(rixs);
then (systs,shared);
else
Expand Down
27 changes: 17 additions & 10 deletions Compiler/BackEnd/BackendDump.mo
Expand Up @@ -313,17 +313,24 @@ end printSubPartitions;
public function subClockString
input BackendDAE.SubClock subClock;
output String subClockString;
protected
String factorStr, shiftStr, solverStr;
algorithm
factorStr := "factor(" + MMath.rationalString(subClock.factor) + ")";
shiftStr := "shift(" + MMath.rationalString(subClock.shift) + ")";
solverStr := "solver(" + optionString(subClock.solver) + ")";
if stringLength(solverStr) > 8 then
subClockString := factorStr + " " + shiftStr + " " + solverStr;
else
subClockString := factorStr + " " + shiftStr + " ";
end if;
subClockString := match(subClock)
local
String factorStr, shiftStr, solverStr;
case(BackendDAE.INFERED_SUBCLOCK())
then "INFERED_SUBCLOCK";
case(BackendDAE.SUBCLOCK(_))
algorithm
factorStr := "factor(" + MMath.rationalString(subClock.factor) + ")";
shiftStr := "shift(" + MMath.rationalString(subClock.shift) + ")";
solverStr := "solver(" + optionString(subClock.solver) + ")";
if stringLength(solverStr) > 8 then
subClockString := factorStr + " " + shiftStr + " " + solverStr;
else
subClockString := factorStr + " " + shiftStr + " ";
end if;
then subClockString;
end match;
end subClockString;

public function optionString
Expand Down

0 comments on commit 7827a66

Please sign in to comment.