Skip to content

Commit

Permalink
- fix FMI on windows (both import/export) due to main C file split (a…
Browse files Browse the repository at this point in the history
…lso DllExport was only for MSVC and not for gcc in SimulationRuntime/fmi/export/fmiModelFunctions.h)

- fix +target=msvc due to main C file split (fix makefile, forward equation functions, use extern "C")

- propagate fileNamePrefix in the backend as part of the BackedDAE.SHARED
- split all the duplicate partial function declarations for function pointers into a new file Compiler/BackEnd/BackendDAEFunc.mo


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17700 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Oct 15, 2013
1 parent fd1bbae commit a4e3fe9
Show file tree
Hide file tree
Showing 30 changed files with 627 additions and 394 deletions.
7 changes: 7 additions & 0 deletions Compiler/BackEnd/BackendDAE.mo
Expand Up @@ -102,9 +102,16 @@ uniontype Shared "Data shared for all equation-systems"
ExternalObjectClasses extObjClasses "classes of external objects, contains constructor & destructor";
BackendDAEType backendDAEType "indicate for what the BackendDAE is used";
SymbolicJacobians symjacs "Symbolic Jacobians";
ExtraInfo info "contains extra info that we send around like the model name";
end SHARED;
end Shared;

uniontype ExtraInfo "extra information that we should send arround with the DAE"
record EXTRA_INFO "extra information that we should send arround with the DAE"
String fileNamePrefix "the model name to be used in the dumps";
end EXTRA_INFO;
end ExtraInfo;

public
uniontype BackendDAEType "BackendDAEType to indicate different types of BackendDAEs.
For example for simulation, initialization, jacobian, algebraic loops etc."
Expand Down
24 changes: 17 additions & 7 deletions Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -62,6 +62,7 @@ protected import Expression;
protected import ExpressionSimplify;
protected import ExpressionDump;
protected import Flags;
protected import Global;
protected import GlobalScript;
protected import HashTableExpToExp;
protected import HashTableExpToIndex;
Expand Down Expand Up @@ -89,6 +90,7 @@ public function lower "This function translates a DAE, which is the result from
input DAE.DAElist lst;
input Env.Cache inCache;
input Env.Env inEnv;
input BackendDAE.ExtraInfo inExtraInfo;
output BackendDAE.BackendDAE outBackendDAE;
protected
BackendDAE.Variables vars, knvars, vars_1, extVars, aliasVars;
Expand All @@ -106,6 +108,8 @@ protected
BackendDAE.SampleLookup sampleLookup;
algorithm
System.realtimeTick(GlobalScript.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
// reset dumped file sequence number
System.tmpTickResetIndex(0, Global.backendDAE_fileSequence);
Debug.execStat("Enter Backend", GlobalScript.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
functionTree := Env.getFunctionTree(inCache);
(DAE.DAE(elems), functionTree, sampleLookup) := processBuiltinExpressions(lst, functionTree);
Expand Down Expand Up @@ -143,7 +147,7 @@ algorithm
einfo,
extObjCls,
BackendDAE.SIMULATION(),
symjacs));
symjacs,inExtraInfo));
BackendDAEUtil.checkBackendDAEWithErrorMsg(outBackendDAE);
Debug.fcall(Flags.DUMP_BACKENDDAE_INFO, print, "No. of Equations: " +& intString(BackendDAEUtil.equationSize(eqnarr)) +& "\nNo. of Variables: " +& intString(BackendVariable.varsSize(vars_1)) +& "\n");
Debug.execStat("generate Backend Data Structure", GlobalScript.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
Expand Down Expand Up @@ -3277,12 +3281,13 @@ algorithm
Env.Cache cache;
Env.Env env;
BackendDAE.StateSets stateSets;
case (BackendDAE.EQSYSTEM(vars, eqns, m, mT, matching, stateSets), BackendDAE.SHARED(knvars, exobj, av, inieqns, remeqns, constrs, clsAttrs, cache, env, funcs, einfo, eoc, btp, symjacs))
BackendDAE.ExtraInfo ei;
case (BackendDAE.EQSYSTEM(vars, eqns, m, mT, matching, stateSets), BackendDAE.SHARED(knvars, exobj, av, inieqns, remeqns, constrs, clsAttrs, cache, env, funcs, einfo, eoc, btp, symjacs,ei))
equation
(eqns1, (vars1, _)) = BackendEquation.traverseBackendDAEEqnsWithUpdate(eqns, traverserexpandDerEquation, (vars, shared));
(inieqns1, (vars2, _)) = BackendEquation.traverseBackendDAEEqnsWithUpdate(inieqns, traverserexpandDerEquation, (vars1, shared));
then
(BackendDAE.EQSYSTEM(vars2, eqns1, m, mT, matching, stateSets), BackendDAE.SHARED(knvars, exobj, av, inieqns1, remeqns, constrs, clsAttrs, cache, env, funcs, einfo, eoc, btp, symjacs));
(BackendDAE.EQSYSTEM(vars2, eqns1, m, mT, matching, stateSets), BackendDAE.SHARED(knvars, exobj, av, inieqns1, remeqns, constrs, clsAttrs, cache, env, funcs, einfo, eoc, btp, symjacs,ei));
end match;
end expandDerOperatorWork;

Expand Down Expand Up @@ -3518,10 +3523,12 @@ algorithm
Env.Cache cache;
Env.Env env;
BackendDAE.EqSystems systs;
BackendDAE.ExtraInfo ei;

case (BackendDAE.DAE(systs, (BackendDAE.SHARED(knvars, exobj, av, inieqns, remeqns, constrs, clsAttrs,
cache, env, funcs, einfo as BackendDAE.EVENT_INFO(sampleLookup=sampleLookup, zeroCrossingLst=zero_crossings, relationsLst=relationsLst,
sampleLst=sampleLst, whenClauseLst=whenclauses, relationsNumber=countRelations,
numberMathEvents=countMathFunctions), eoc, btp, symjacs))), _)
numberMathEvents=countMathFunctions), eoc, btp, symjacs, ei))), _)
equation
vars = BackendVariable.listVar1(allvars);
eqs_lst = BackendEquation.equationList(remeqns);
Expand All @@ -3533,7 +3540,7 @@ algorithm
Debug.fcall(Flags.RELIDX, print, "findZeroCrossings1 sample index: " +& intString(listLength(sampleLst)) +& "\n");
einfo1 = BackendDAE.EVENT_INFO(sampleLookup, whenclauses, zero_crossings, sampleLst, relationsLst, countRelations, countMathFunctions);
then
BackendDAE.DAE(systs, BackendDAE.SHARED(knvars, exobj, av, inieqns, remeqns, constrs, clsAttrs, cache, env, funcs, einfo1, eoc, btp, symjacs));
BackendDAE.DAE(systs, BackendDAE.SHARED(knvars, exobj, av, inieqns, remeqns, constrs, clsAttrs, cache, env, funcs, einfo1, eoc, btp, symjacs, ei));
end match;
end findZeroCrossingsShared;

Expand Down Expand Up @@ -3568,12 +3575,14 @@ algorithm
Env.Cache cache;
Env.Env env;
BackendDAE.StateSets stateSets;
BackendDAE.ExtraInfo ei;

case (BackendDAE.EQSYSTEM(vars, eqns, m, mT, matching, stateSets),
(BackendDAE.SHARED(knvars, exobj, av, inieqns, remeqns, constrs, clsAttrs,
cache, env, funcs, einfo as BackendDAE.EVENT_INFO(sampleLookup=sampleLookup, zeroCrossingLst=zero_crossings,
sampleLst=sampleLst, whenClauseLst=whenclauses, relationsLst=relations,
relationsNumber=countRelations, numberMathEvents=countMathFunctions),
eoc, btp, symjacs), allvars))
eoc, btp, symjacs, ei), allvars))
equation
eqs_lst = BackendEquation.equationList(eqns);
(zero_crossings, eqs_lst1, _, countRelations, countMathFunctions, relations, sampleLst) = findZeroCrossings2(vars, knvars, eqs_lst, 0, {}, 0, countRelations, countMathFunctions, zero_crossings, relations, sampleLst);
Expand All @@ -3583,7 +3592,8 @@ algorithm
einfo1 = BackendDAE.EVENT_INFO(sampleLookup, whenclauses, zero_crossings, sampleLst, relations, countRelations, countMathFunctions);
allvars = listAppend(allvars, BackendVariable.varList(vars));
then
(BackendDAE.EQSYSTEM(vars, eqns1, m, mT, matching, stateSets), (BackendDAE.SHARED(knvars, exobj, av, inieqns, remeqns, constrs, clsAttrs, cache, env, funcs, einfo1, eoc, btp, symjacs), allvars));
(BackendDAE.EQSYSTEM(vars, eqns1, m, mT, matching, stateSets), (BackendDAE.SHARED(knvars, exobj, av, inieqns, remeqns, constrs, clsAttrs, cache, env, funcs, einfo1, eoc, btp, symjacs, ei), allvars));

end match;
end findZeroCrossings1;

Expand Down
94 changes: 94 additions & 0 deletions Compiler/BackEnd/BackendDAEFunc.mo
@@ -0,0 +1,94 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Linköping University,
* Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
* AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
* ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from Linköping University, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
* OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/

encapsulated package BackendDAEFunc
" file: BackendDAEFunc.mo
package: BackendDAEFunc
description: BackendDAEFunc defines the partial functions (interfaces) to function pointers that are sent around.

RCS: $Id: BackendDAEFunc.mo 17568 2013-10-07 01:59:38Z adrpo $
"

public import BackendDAE;

/*************************************/
/* Interfaces */
/*************************************/

public
partial function preOptimizationDAEModule "
This is the interface for pre-optimization modules."
input BackendDAE.BackendDAE inDAE;
output BackendDAE.BackendDAE outDAE;
end preOptimizationDAEModule;

partial function postOptimizationDAEModule "
This is the interface for post-optimization modules."
input BackendDAE.BackendDAE inDAE;
output BackendDAE.BackendDAE outDAE;
end postOptimizationDAEModule;

partial function stateDeselectionFunc
input BackendDAE.BackendDAE inDAE;
input list<Option<BackendDAE.StructurallySingularSystemHandlerArg>> inArgs;
output BackendDAE.BackendDAE outDAE;
end stateDeselectionFunc;

partial function StructurallySingularSystemHandlerFunc
input list<list<Integer>> eqns;
input Integer actualEqn;
input BackendDAE.EqSystem isyst;
input BackendDAE.Shared ishared;
input array<Integer> inAssignments1;
input array<Integer> inAssignments2;
input BackendDAE.StructurallySingularSystemHandlerArg inArg;
output list<Integer> changedEqns;
output Integer continueEqn;
output BackendDAE.EqSystem osyst;
output BackendDAE.Shared oshared;
output array<Integer> outAssignments1;
output array<Integer> outAssignments2;
output BackendDAE.StructurallySingularSystemHandlerArg outArg;
end StructurallySingularSystemHandlerFunc;

partial function matchingAlgorithmFunc
input BackendDAE.EqSystem isyst;
input BackendDAE.Shared ishared;
input Boolean clearMatching;
input BackendDAE.MatchingOptions inMatchingOptions;
input StructurallySingularSystemHandlerFunc sssHandler;
input BackendDAE.StructurallySingularSystemHandlerArg inArg;
output BackendDAE.EqSystem osyst;
output BackendDAE.Shared oshared;
output BackendDAE.StructurallySingularSystemHandlerArg outArg;
end matchingAlgorithmFunc;

end BackendDAEFunc;

0 comments on commit a4e3fe9

Please sign in to comment.