Skip to content

Commit

Permalink
- Added +scalarizeBindings flag, to enable scalarization of array bin…
Browse files Browse the repository at this point in the history
…dings.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15996 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed May 7, 2013
1 parent 94a355e commit 3df253e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Compiler/FrontEnd/Inst.mo
Expand Up @@ -8566,6 +8566,14 @@ algorithm
DAE.Dimensions dims;
DAE.ComponentRef cr;
DAE.Type ty;

// Don't add array equations if +scalarizeBindings is set.
case (_, _, _, _, _, _, _, _, _, _, _)
equation
true = Config.scalarizeBindings();
then
(inCache, inDae);

case (_,_,_,_,DAE.DAE(dae),_,_,DAE.C_VAR(),_,_,_)
equation
false = ClassInf.isFunctionOrRecord(inState);
Expand Down Expand Up @@ -8978,7 +8986,7 @@ algorithm
PrefixUtil.prefixToCrefOpt(inPrefix), NONE(), NONE());

// Instantiate the components binding.
mod = Util.if_(listLength(inSubscripts) > 0 and not SCode.isParameterOrConst(vt) and not ClassInf.isFunctionOrRecord(inState) and not Types.isComplexType(Types.arrayElementType(ty)) and not Types.isExternalObject(Types.arrayElementType(ty)),DAE.NOMOD(),inMod);
mod = Util.if_(listLength(inSubscripts) > 0 and not SCode.isParameterOrConst(vt) and not ClassInf.isFunctionOrRecord(inState) and not Types.isComplexType(Types.arrayElementType(ty)) and not Types.isExternalObject(Types.arrayElementType(ty)) and not Config.scalarizeBindings(),DAE.NOMOD(),inMod);
opt_binding = makeVariableBinding(ty, mod, NFInstUtil.toConst(vt), inPrefix, inName, source);
start = instStartBindingExp(inMod /* Yup, let's keep the start-binding. It seems sane. */, ty, vt);

Expand Down
6 changes: 6 additions & 0 deletions Compiler/Util/Config.mo
Expand Up @@ -541,5 +541,11 @@ algorithm
outScalarizeMinMax := Flags.getConfigBool(Flags.SCALARIZE_MINMAX);
end scalarizeMinMax;

public function scalarizeBindings
output Boolean outScalarizeBindings;
algorithm
outScalarizeBindings := Flags.getConfigBool(Flags.SCALARIZE_BINDINGS);
end scalarizeBindings;

end Config;

6 changes: 5 additions & 1 deletion Compiler/Util/Flags.mo
Expand Up @@ -765,6 +765,9 @@ constant ConfigFlag RUNNING_WSM_TESTSUITE = CONFIG_FLAG(48, "wsm-testsuite",
constant ConfigFlag CORRECT_CREF_TYPES = CONFIG_FLAG(49, "correctCrefTypes",
NONE(), INTERNAL(), BOOL_FLAG(false), NONE(),
Util.gettext("Set to true to set correct types in component references. Doesn't work for OpenModelica backend."));
constant ConfigFlag SCALARIZE_BINDINGS = CONFIG_FLAG(50, "scalarizeBindings",
NONE(), EXTERNAL(), BOOL_FLAG(false), NONE(),
Util.gettext("Always scalarizes bindings if set."));

// This is a list of all configuration flags. A flag can not be used unless it's
// in this list, and the list is checked at initialization so that all flags are
Expand Down Expand Up @@ -818,7 +821,8 @@ constant list<ConfigFlag> allConfigFlags = {
TEARING_METHOD,
SCALARIZE_MINMAX,
RUNNING_WSM_TESTSUITE,
CORRECT_CREF_TYPES
CORRECT_CREF_TYPES,
SCALARIZE_BINDINGS
};

public function new
Expand Down

0 comments on commit 3df253e

Please sign in to comment.