Skip to content

Commit

Permalink
Introduce flag to skip tearing for huge systems
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaeuber authored and OpenModelica-Hudson committed Apr 6, 2016
1 parent 325d842 commit fda31e0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
13 changes: 12 additions & 1 deletion Compiler/BackEnd/Tearing.mo
Expand Up @@ -102,7 +102,7 @@ algorithm
true = stringEqual(methodString, "noTearing");
then inDAE;

// get method function and traveres systems
// get method function and traverse systems
case(_) equation
methodString = Config.getTearingMethod();
BackendDAE.SHARED(backendDAEType=DAEtype) = inDAE.shared;
Expand Down Expand Up @@ -236,6 +236,7 @@ protected
algorithm
(oComp, outRunMatching) := matchcontinue (inComp, isyst, ishared, inMethod)
local
Integer maxSize;
list<Integer> eindex, vindx;
Boolean b, b1;
BackendDAE.StrongComponents comps, acc;
Expand All @@ -246,6 +247,11 @@ algorithm

case ((BackendDAE.EQUATIONSYSTEM(eqns=eindex, vars=vindx, jac=BackendDAE.FULL_JACOBIAN(ojac), jacType=jacType, mixedSystem=mixedSystem)), _, _, _) equation
equality(jacType = BackendDAE.JAC_LINEAR());
maxSize = Flags.getConfigInt(Flags.MAX_SIZE_LINEAR_TEARING);
if intGt(listLength(vindx),maxSize) then
Error.addMessage(Error.MAX_TEARING_SIZE, {intString(listLength(vindx)),"Linear",intString(maxSize)});
fail();
end if;
if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
print("\nCase linear in traverseComponents\nUse Flag '+d=tearingdumpV' for more details\n\n");
end if;
Expand All @@ -265,6 +271,11 @@ algorithm
// tearing of non-linear systems
case ((BackendDAE.EQUATIONSYSTEM(eqns=eindex, vars=vindx, jac=BackendDAE.FULL_JACOBIAN(ojac), jacType=jacType, mixedSystem=mixedSystem)), _, _, _) equation
failure(equality(jacType = BackendDAE.JAC_LINEAR()));
maxSize = Flags.getConfigInt(Flags.MAX_SIZE_NONLINEAR_TEARING);
if intGt(listLength(vindx),maxSize) then
Error.addMessage(Error.MAX_TEARING_SIZE, {intString(listLength(vindx)),"Nonlinear",intString(maxSize)});
fail();
end if;
if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
print("\nCase non-linear in traverseComponents\nUse Flag '+d=tearingdumpV' for more details\n\n");
end if;
Expand Down
2 changes: 2 additions & 0 deletions Compiler/Util/Error.mo
Expand Up @@ -835,6 +835,8 @@ public constant Message EXEC_STAT = MESSAGE(572, TRANSLATION(), NOTIFICATION(),
Util.gettext("Performance of %s: time %s/%s, memory: %s / %s"));
public constant Message EXEC_STAT_GC = MESSAGE(573, TRANSLATION(), NOTIFICATION(),
Util.gettext("Performance of %s: time %s/%s, GC stats:%s"));
public constant Message MAX_TEARING_SIZE = MESSAGE(574, SYMBOLIC(), NOTIFICATION(),
Util.gettext("Tearing is skipped because system size of %s exceeds maximum system size for tearing of %s Systems (%s)\nTo adjust the maximum system size for tearing use +maxSize%2Tearing=<size>\n"));

public constant Message MATCH_SHADOWING = MESSAGE(5001, TRANSLATION(), ERROR(),
Util.gettext("Local variable '%s' shadows another variable."));
Expand Down
11 changes: 9 additions & 2 deletions Compiler/Util/Flags.mo
Expand Up @@ -1244,7 +1244,12 @@ constant ConfigFlag DEFAULT_CLOCK_PERIOD = CONFIG_FLAG(89, "defaultClockPeriod",
constant ConfigFlag INST_CACHE_SIZE = CONFIG_FLAG(90, "instCacheSize",
NONE(), EXTERNAL(), INT_FLAG(25343), NONE(),
Util.gettext("Sets the size of the internal hash table used for instantiation caching."));

constant ConfigFlag MAX_SIZE_LINEAR_TEARING = CONFIG_FLAG(91, "maxSizeLinearTearing",
NONE(), EXTERNAL(), INT_FLAG(4000), NONE(),
Util.gettext("Sets the maximum system size for tearing of linear systems (default 4000)."));
constant ConfigFlag MAX_SIZE_NONLINEAR_TEARING = CONFIG_FLAG(92, "maxSizeNonlinearTearing",
NONE(), EXTERNAL(), INT_FLAG(10000), NONE(),
Util.gettext("Sets the maximum system size for tearing of nonlinear systems (default 10000)."));

protected
// This is a list of all configuration flags. A flag can not be used unless it's
Expand Down Expand Up @@ -1340,7 +1345,9 @@ constant list<ConfigFlag> allConfigFlags = {
PERMISSIVE,
HETS,
DEFAULT_CLOCK_PERIOD,
INST_CACHE_SIZE
INST_CACHE_SIZE,
MAX_SIZE_LINEAR_TEARING,
MAX_SIZE_NONLINEAR_TEARING
};

public function new
Expand Down

0 comments on commit fda31e0

Please sign in to comment.