Skip to content

Commit

Permalink
Never select CSE var as iteration var (#8049)
Browse files Browse the repository at this point in the history
Addresses issue #7800
TODO do this also for arrays, currently some tests would fail
TODO even tear them with minimalTearing
  • Loading branch information
phannebohm committed Oct 30, 2021
1 parent 611faf9 commit 4ef7b21
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions OMCompiler/Compiler/BackEnd/BackendVariable.mo
Expand Up @@ -1770,12 +1770,12 @@ algorithm
DAE.T_COMPLEX(complexClassType=ClassInf.RECORD(path)) = inType;
source = DAE.SOURCE(AbsynUtil.dummyInfo, {}, DAE.NOCOMPPRE(), {}, {path}, {}, {});
varKind = if Types.isDiscreteType(inType) then BackendDAE.DISCRETE() else BackendDAE.VARIABLE();
outVar = BackendDAE.VAR(inCref, varKind, DAE.BIDIR(), DAE.NON_PARALLEL(), inType, NONE(), NONE(), {}, source, DAEUtil.setProtectedAttr(NONE(), true), NONE(), SOME(DAE.BCONST(true)), NONE(), DAE.NON_CONNECTOR(), DAE.NOT_INNER_OUTER(), true);
outVar = BackendDAE.VAR(inCref, varKind, DAE.BIDIR(), DAE.NON_PARALLEL(), inType, NONE(), NONE(), {}, source, DAEUtil.setProtectedAttr(NONE(), true), SOME(BackendDAE.NEVER()), SOME(DAE.BCONST(true)), NONE(), DAE.NON_CONNECTOR(), DAE.NOT_INNER_OUTER(), true);
then outVar;

else equation
varKind = if Types.isDiscreteType(inType) then BackendDAE.DISCRETE() else BackendDAE.VARIABLE();
outVar = BackendDAE.VAR(inCref, varKind, DAE.BIDIR(), DAE.NON_PARALLEL(), inType, NONE(), NONE(), {}, DAE.emptyElementSource, DAEUtil.setProtectedAttr(NONE(), true), NONE(), SOME(DAE.BCONST(true)), NONE(), DAE.NON_CONNECTOR(), DAE.NOT_INNER_OUTER(), true);
outVar = BackendDAE.VAR(inCref, varKind, DAE.BIDIR(), DAE.NON_PARALLEL(), inType, NONE(), NONE(), {}, DAE.emptyElementSource, DAEUtil.setProtectedAttr(NONE(), true), SOME(BackendDAE.NEVER()), SOME(DAE.BCONST(true)), NONE(), DAE.NON_CONNECTOR(), DAE.NOT_INNER_OUTER(), true);
then outVar;
end match;
end createCSEVar;
Expand Down
23 changes: 11 additions & 12 deletions OMCompiler/Compiler/BackEnd/Tearing.mo
@@ -1,7 +1,7 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2014, Open Source Modelica Consortium (OSMC),
* Copyright (c) 1998-2021, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
Expand Down Expand Up @@ -109,11 +109,20 @@ algorithm
return;
end if;

// Check if maxSizeLinearTearing maxSizeNonlinearTearing flag is illegal
if (Flags.getConfigInt(Flags.MAX_SIZE_LINEAR_TEARING) < 0) then
Error.addMessage(Error.INVALID_FLAG_TYPE, {"maxSizeLinearTearing", "non-negative integer", intString(Flags.getConfigInt(Flags.MAX_SIZE_LINEAR_TEARING))});
fail();
elseif (Flags.getConfigInt(Flags.MAX_SIZE_NONLINEAR_TEARING) < 0) then
Error.addMessage(Error.INVALID_FLAG_TYPE, {"maxSizeNonlinearTearing", "non-negative integer", intString(Flags.getConfigInt(Flags.MAX_SIZE_NONLINEAR_TEARING))});
fail();
end if;

// get method function and traverse systems
try
method := getTearingMethod(methodString);
BackendDAE.SHARED(backendDAEType=DAEtype) := inDAE.shared;
if Flags.isSet(Flags.TEARING_DUMP) or Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
BackendDAE.SHARED(backendDAEType=DAEtype) := inDAE.shared;
print("\n\n\n\n" + UNDERLINE + UNDERLINE + "\nCalling Tearing for " +
BackendDump.printBackendDAEType2String(DAEtype) +
"!\n" + UNDERLINE + UNDERLINE + "\n");
Expand Down Expand Up @@ -251,16 +260,6 @@ algorithm
print("\n" + BORDER + "\nBEGINNING of traverseComponents\n\n");
end if;

// Check if maxSizeLinearTearing maxSizeNonlinearTearing flag is illegal
// phi: TODO move this to flag handling at the beginning
if (Flags.getConfigInt(Flags.MAX_SIZE_LINEAR_TEARING) < 0) then
Error.addMessage(Error.INVALID_FLAG_TYPE, {"maxSizeLinearTearing", "non-negative integer", intString(Flags.getConfigInt(Flags.MAX_SIZE_LINEAR_TEARING))});
fail();
elseif (Flags.getConfigInt(Flags.MAX_SIZE_NONLINEAR_TEARING) < 0) then
Error.addMessage(Error.INVALID_FLAG_TYPE, {"maxSizeNonlinearTearing", "non-negative integer", intString(Flags.getConfigInt(Flags.MAX_SIZE_NONLINEAR_TEARING))});
fail();
end if;

(comps, runMatching, outStrongComponentIndex) := traverseComponents(comps, isyst, inShared, tearingMethod, inStrongComponentIndex);
if Flags.isSet(Flags.TEARING_DUMPVERBOSE) then
print("\nEND of traverseComponents\n" + BORDER + "\n\n");
Expand Down

0 comments on commit 4ef7b21

Please sign in to comment.