Skip to content

Commit

Permalink
[testsuite] add ScalableTestsuite new backend tests (#11658)
Browse files Browse the repository at this point in the history
* [testsuite] add new backend scalable testsuite tests

* [testsuite] add scalable testsuite new backend to makefile

 [NB] remove warnings for unparsed annotations
  • Loading branch information
kabdelhak committed Dec 12, 2023
1 parent 357024f commit cd71567
Show file tree
Hide file tree
Showing 51 changed files with 703 additions and 45 deletions.
9 changes: 6 additions & 3 deletions OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBEvents.mo
Expand Up @@ -73,6 +73,7 @@ protected
// SimCode
import NSimGenericCall.SimIterator;
import OldSimIterator = BackendDAE.SimIterator;
import Block = NSimStrongComponent.Block;

// Util
import BackendUtil = NBBackendUtil;
Expand Down Expand Up @@ -264,14 +265,15 @@ public
output list<OldBackendDAE.ZeroCrossing> zeroCrossings;
output list<OldBackendDAE.ZeroCrossing> relations "== zeroCrossings for the most part (only eq pointer different?)";
output list<OldBackendDAE.TimeEvent> timeEvents;
input UnorderedMap<ComponentRef, Block> equation_map;
protected
list<TimeEvent> tev_lst;
list<tuple<Condition, CompositeEvent>> cev_lst;
list<tuple<Condition, StateEvent>> sev_lst;
algorithm
// add composite at some point?
(tev_lst, cev_lst, sev_lst) := toLists(eventInfo);
zeroCrossings := list(StateEvent.convert(sev_tpl) for sev_tpl in sev_lst);
zeroCrossings := list(StateEvent.convert(sev_tpl, equation_map) for sev_tpl in sev_lst);
relations := zeroCrossings;
timeEvents := list(TimeEvent.convert(tev) for tev in tev_lst);
end convert;
Expand Down Expand Up @@ -668,6 +670,7 @@ public

function convert
input tuple<Condition, StateEvent> sev_tpl;
input UnorderedMap<ComponentRef, Block> equation_map;
output OldBackendDAE.ZeroCrossing oldZc;
protected
Condition cond;
Expand All @@ -679,7 +682,7 @@ public
oldZc := OldBackendDAE.ZERO_CROSSING(
index = sev.index,
relation_ = Expression.toDAE(cond.exp),
occurEquLst = {}, //ToDo: low priority - only for debugging
occurEquLst = list(Block.getIndex(UnorderedMap.getSafe(Equation.getEqnName(eqn), equation_map, sourceInfo())) for eqn in sev.eqns), //ToDo: low priority - only for debugging
iter = iter
);
end convert;
Expand Down Expand Up @@ -855,7 +858,7 @@ public
algorithm
str := Expression.toString(cond.exp);
if not Iterator.isEmpty(cond.iter) then
str := str + " " + Iterator.toString(cond.iter);
str := str + " for {" + Iterator.toString(cond.iter) + "}";
end if;
end toString;

Expand Down
9 changes: 1 addition & 8 deletions OMCompiler/Compiler/NFFrontEnd/NFBackendExtension.mo
Expand Up @@ -1330,14 +1330,7 @@ public
case SCode.NAMEMOD(ident = "HideResult", mod = SCode.MOD(binding = SOME(Absyn.BOOL(true)))) algorithm
annotations.hideResult := true;
then ();
// do not create a notification for TearingSelect since its parsed in attributes
case SCode.NAMEMOD(ident = "TearingSelect") then ();
// do not create a notification for the following since they are handled in the frontend
case SCode.NAMEMOD(ident = "Placement") then ();
case SCode.NAMEMOD(ident = "Dialog") then ();
else algorithm
Error.addCompilerNotification("Could not parse annotation \"" + submod.ident + "\" in the backend.");
then ();
else ();
end match;
end for;
then ();
Expand Down
29 changes: 18 additions & 11 deletions OMCompiler/Compiler/NSimCode/NSimCode.mo
Expand Up @@ -203,6 +203,7 @@ public
//*** a protected section *** not exported to SimCodeTV
//HashTableCrILst.HashTable varToIndexMapping;
UnorderedMap<ComponentRef, SimVar> simcode_map;
UnorderedMap<ComponentRef, SimStrongComponent.Block> equation_map;
//HashTable.HashTable crefToClockIndexHT "map variables to clock indices";
//Option<BackendMapping> backendMapping;
//FMI 2.0 data for model structure
Expand Down Expand Up @@ -256,7 +257,7 @@ public
algorithm
simCode := match bdae
local
BackendDAE qual;
// auxillaries
VarData varData;
EqData eqData;
FunctionTree funcTree;
Expand Down Expand Up @@ -284,6 +285,7 @@ public
list<ComponentRef> discreteVars;
list<SimJacobian> jacobians;
UnorderedMap<ComponentRef, SimVar> simcode_map;
UnorderedMap<ComponentRef, SimStrongComponent.Block> equation_map;
Option<DaeModeData> daeModeData;
SimJacobian jacA, jacB, jacC, jacD, jacF, jacH;
list<SimStrongComponent.Block> inlineEquations; // ToDo: what exactly is this?
Expand All @@ -299,6 +301,9 @@ public
(vars, simCodeIndices) := SimVars.create(varData, residual_vars, simCodeIndices);
simcode_map := SimCodeUtil.createSimCodeMap(vars);

// create empty equation map and fill while creating the blocks
equation_map := UnorderedMap.new<SimStrongComponent.Block>(ComponentRef.hash, ComponentRef.isEqual);

literals := {};
externalFunctionIncludes := {};

Expand All @@ -312,15 +317,15 @@ public
algorithms := {};

// init before everything else!
(init, simCodeIndices) := SimStrongComponent.Block.createInitialBlocks(bdae.init, simCodeIndices, simcode_map);
(init, simCodeIndices) := SimStrongComponent.Block.createInitialBlocks(bdae.init, simCodeIndices, simcode_map, equation_map);
if isSome(bdae.init_0) then
init_0 := SimStrongComponent.Block.createInitialBlocks(Util.getOption(bdae.init_0), simCodeIndices, simcode_map);
init_0 := SimStrongComponent.Block.createInitialBlocks(Util.getOption(bdae.init_0), simCodeIndices, simcode_map, equation_map);
else
init_0 := {};
end if;

// start allSim with no return equations
(no_ret, simCodeIndices) := SimStrongComponent.Block.createNoReturnBlocks(eqData.removed, simCodeIndices, NBSystem.SystemType.ODE, simcode_map);
(no_ret, simCodeIndices) := SimStrongComponent.Block.createNoReturnBlocks(eqData.removed, simCodeIndices, NBSystem.SystemType.ODE, simcode_map, equation_map);
init_no_ret := {};
start := {};
discreteVars := {};
Expand All @@ -333,14 +338,14 @@ public
else
algebraic := {};
end if;
(daeModeData, simCodeIndices) := DaeModeData.create(Util.getOption(bdae.dae), simCodeIndices, simcode_map);
(daeModeData, simCodeIndices) := DaeModeData.create(Util.getOption(bdae.dae), simCodeIndices, simcode_map, equation_map);
else
// Normal Simulation
daeModeData := NONE();
(ode, allSim, simCodeIndices) := SimStrongComponent.Block.createBlocks(bdae.ode, allSim, simCodeIndices, simcode_map);
(algebraic, allSim, simCodeIndices) := SimStrongComponent.Block.createBlocks(bdae.algebraic, allSim, simCodeIndices, simcode_map);
(ode, allSim, event_blocks, simCodeIndices) := SimStrongComponent.Block.createDiscreteBlocks(bdae.ode_event, ode, allSim, event_blocks, simCodeIndices, simcode_map);
(algebraic, allSim, event_blocks, simCodeIndices) := SimStrongComponent.Block.createDiscreteBlocks(bdae.alg_event, algebraic, allSim, event_blocks, simCodeIndices, simcode_map);
(ode, allSim, simCodeIndices) := SimStrongComponent.Block.createBlocks(bdae.ode, allSim, simCodeIndices, simcode_map, equation_map);
(algebraic, allSim, simCodeIndices) := SimStrongComponent.Block.createBlocks(bdae.algebraic, allSim, simCodeIndices, simcode_map, equation_map);
(ode, allSim, event_blocks, simCodeIndices) := SimStrongComponent.Block.createDiscreteBlocks(bdae.ode_event, ode, allSim, event_blocks, simCodeIndices, simcode_map, equation_map);
(algebraic, allSim, event_blocks, simCodeIndices) := SimStrongComponent.Block.createDiscreteBlocks(bdae.alg_event, algebraic, allSim, event_blocks, simCodeIndices, simcode_map, equation_map);
if not listEmpty(no_ret) then
algebraic := no_ret :: algebraic;
allSim := listAppend(no_ret, allSim);
Expand Down Expand Up @@ -416,6 +421,7 @@ public
simulationSettingsOpt = simSettingsOpt,
fileNamePrefix = fileNamePrefix,
simcode_map = simcode_map,
equation_map = equation_map,
eventInfo = bdae.eventInfo,
daeModeData = daeModeData,
inlineEquations = inlineEquations
Expand Down Expand Up @@ -444,7 +450,7 @@ public
list<SimVar> residualVars;
algorithm
modelInfo := ModelInfo.convert(simCode.modelInfo);
(zeroCrossings, relations, timeEvents) := EventInfo.convert(simCode.eventInfo);
(zeroCrossings, relations, timeEvents) := EventInfo.convert(simCode.eventInfo, simCode.equation_map);

(varToArrayIndexMapping, varToIndexMapping) := OldSimCodeUtil.createVarToArrayIndexMapping(modelInfo);
crefToSimVarHT := SimCodeUtil.convertSimCodeMap(simCode.simcode_map);
Expand Down Expand Up @@ -799,12 +805,13 @@ public
output Option<DaeModeData> data;
input output SimCodeIndices simCodeIndices;
input UnorderedMap<ComponentRef, SimVar> simcode_map;
input UnorderedMap<ComponentRef, SimStrongComponent.Block> equation_map;
protected
list<list<SimStrongComponent.Block>> blcks;
list<SimVar> residualVars, algebraicVars;
Option<SimJacobian> daeModeJac;
algorithm
(blcks, residualVars, simCodeIndices) := SimStrongComponent.Block.createDAEModeBlocks(systems, simCodeIndices, simcode_map);
(blcks, residualVars, simCodeIndices) := SimStrongComponent.Block.createDAEModeBlocks(systems, simCodeIndices, simcode_map, equation_map);
//(daeModeJac, simCodeIndices) := SimJacobian.fromSystems(systems, simCodeIndices);
//data := SOME(DAE_MODE_DATA(blcks, daeModeJac, residualVars, {}, {}, DaeModeConfig.ALL));
data := NONE();
Expand Down
5 changes: 3 additions & 2 deletions OMCompiler/Compiler/NSimCode/NSimJacobian.mo
Expand Up @@ -209,7 +209,8 @@ public
simJacobian := match jacobian
local
// dummy map for strong component creation (no alias possible here)
UnorderedMap<ComponentRef, SimVar> dummy_map = UnorderedMap.new<SimVar>(ComponentRef.hash, ComponentRef.isEqual);
UnorderedMap<ComponentRef, SimVar> dummy_sim_map = UnorderedMap.new<SimVar>(ComponentRef.hash, ComponentRef.isEqual);
UnorderedMap<ComponentRef, SimStrongComponent.Block> dummy_eqn_map = UnorderedMap.new<SimStrongComponent.Block>(ComponentRef.hash, ComponentRef.isEqual);
SimStrongComponent.Block columnEqn;
VarData varData;
VariablePointers seed_scalar, res_scalar, tmp_scalar;
Expand All @@ -232,7 +233,7 @@ public
sim_map := indices.generic_call_map;
indices.generic_call_map := UnorderedMap.new<Integer>(Identifier.hash, Identifier.isEqual);
for i in arrayLength(jacobian.comps):-1:1 loop
(columnEqn, indices, _) := SimStrongComponent.Block.fromStrongComponent(jacobian.comps[i], indices, NBSystem.SystemType.JAC, dummy_map);
(columnEqn, indices, _) := SimStrongComponent.Block.fromStrongComponent(jacobian.comps[i], indices, NBSystem.SystemType.JAC, dummy_sim_map, dummy_eqn_map);
columnEqns := columnEqn :: columnEqns;
end for;

Expand Down

0 comments on commit cd71567

Please sign in to comment.