Skip to content

Commit

Permalink
Add compiler flag to skip tearing for specified components
Browse files Browse the repository at this point in the history
- --noTearingForComponent=<value>
- value is list<Integer> with strong component indexes
- to find out relevant indexes use +d=tearingdump
  • Loading branch information
ptaeuber committed Apr 8, 2016
1 parent 0d11bbe commit 027b44e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 26 deletions.
39 changes: 16 additions & 23 deletions Compiler/BackEnd/Tearing.mo
Expand Up @@ -106,7 +106,6 @@ algorithm

// get method function and traverse systems
case(_) equation

methodString = Config.getTearingMethod();
BackendDAE.SHARED(backendDAEType=DAEtype) = inDAE.shared;
false = stringEqual(methodString, "shuffleTearing") and stringEq("simulation",BackendDump.printBackendDAEType2String(DAEtype));
Expand Down Expand Up @@ -269,7 +268,14 @@ algorithm
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)});
Error.addMessage(Error.MAX_TEARING_SIZE, {intString(strongComponentIndexOut), intString(listLength(vindx)),"linear",intString(maxSize)});
fail();
end if;
if listMember(strongComponentIndexOut,Flags.getConfigIntList(Flags.NO_TEARING_FOR_COMPONENT)) then
if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
print("\nTearing deactivated by user.\n");
end if;
Error.addMessage(Error.NO_TEARING_FOR_COMPONENT, {intString(strongComponentIndexOut)});
fail();
end if;
if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
Expand All @@ -293,7 +299,14 @@ algorithm
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)});
Error.addMessage(Error.MAX_TEARING_SIZE, {intString(strongComponentIndexOut), intString(listLength(vindx)),"nonlinear",intString(maxSize)});
fail();
end if;
if listMember(strongComponentIndexOut,Flags.getConfigIntList(Flags.NO_TEARING_FOR_COMPONENT)) then
if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
print("\nTearing deactivated by user.\n");
end if;
Error.addMessage(Error.NO_TEARING_FOR_COMPONENT, {intString(strongComponentIndexOut)});
fail();
end if;
if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
Expand Down Expand Up @@ -4429,26 +4442,6 @@ algorithm
print("order: " + stringDelimitList(List.map(order,intString),",") + "\n\n");
end for;
end dumpMatchingList;





















annotation(__OpenModelica_Interface="backend");
end Tearing;
4 changes: 3 additions & 1 deletion Compiler/Util/Error.mo
Expand Up @@ -837,7 +837,9 @@ public constant Message EXEC_STAT = MESSAGE(572, TRANSLATION(), NOTIFICATION(),
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 --maxSizeLinearTearing=<size> and --maxSizeNonlinearTearing=<size>\n"));
Util.gettext("Tearing is skipped for strong component %s because system size of %s exceeds maximum system size for tearing of %s systems (%s).\nTo adjust the maximum system size for tearing use --maxSizeLinearTearing=<size> and --maxSizeNonlinearTearing=<size>.\n"));
public constant Message NO_TEARING_FOR_COMPONENT = MESSAGE(575, SYMBOLIC(), NOTIFICATION(),
Util.gettext("Tearing is skipped for strong component %s because of activated compiler flag 'noTearingForComponent=%1'.\n"));

public constant Message MATCH_SHADOWING = MESSAGE(5001, TRANSLATION(), ERROR(),
Util.gettext("Local variable '%s' shadows another variable."));
Expand Down
29 changes: 27 additions & 2 deletions Compiler/Util/Flags.mo
Expand Up @@ -104,6 +104,11 @@ public uniontype FlagData
Integer data;
end INT_FLAG;

record INT_LIST_FLAG
"Value of an integer flag that can have multiple values."
list<Integer> data;
end INT_LIST_FLAG;

record REAL_FLAG
"Value of a real flag."
Real data;
Expand Down Expand Up @@ -1250,6 +1255,9 @@ constant ConfigFlag MAX_SIZE_LINEAR_TEARING = CONFIG_FLAG(91, "maxSizeLinearTear
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)."));
constant ConfigFlag NO_TEARING_FOR_COMPONENT = CONFIG_FLAG(93, "noTearingForComponent",
NONE(), EXTERNAL(), INT_LIST_FLAG({}), NONE(),
Util.gettext("Deactivates tearing for the specified components.\nUse '+d=tearingdump' to find out the relevant indexes."));

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

public function new
Expand Down Expand Up @@ -1916,9 +1925,10 @@ algorithm
local
Boolean b;
Integer i;
list<Integer> ilst;
String s, et, at;
list<tuple<String, Integer>> enums;
list<String> flags;
list<String> flags, slst;
ValidOptions options;

// A boolean value.
Expand All @@ -1939,6 +1949,13 @@ algorithm
then
INT_FLAG(i);

// integer list.
case (slst, INT_LIST_FLAG(), _, _)
equation
ilst = List.map(slst,stringInt);
then
INT_LIST_FLAG(ilst);

// A real value.
case ({s}, REAL_FLAG(), _, _)
then REAL_FLAG(System.stringReal(s));
Expand Down Expand Up @@ -2187,6 +2204,14 @@ algorithm
INT_FLAG(data = outValue) := getConfigValue(inFlag);
end getConfigInt;

public function getConfigIntList
"Returns the value of an integer configuration flag."
input ConfigFlag inFlag;
output list<Integer> outValue;
algorithm
INT_LIST_FLAG(data = outValue) := getConfigValue(inFlag);
end getConfigIntList;

public function getConfigReal
"Returns the value of a real configuration flag."
input ConfigFlag inFlag;
Expand Down

0 comments on commit 027b44e

Please sign in to comment.