Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 23.6% 635 / 0 / 2688
Functions: -% 0 / 1 / 1
Branches: 18.2% 56 / 0 / 308

build_cmake/OMCompiler/Compiler/generated-mo/Template/CodegenCppHpcom.mo
Line Branch Exec Source
1 encapsulated package CodegenCppHpcom
2 "
3 file: CodegenCppHpcom.mo
4 package: CodegenCppHpcom
5 description: Generated by Susan.
6 "
7
8 public import Tpl;
9
10 public import BackendVariable;
11 public import HpcOmSimCode;
12 public import HpcOmCodegenUtil;
13 public import FMI;
14 public import SimCodeVar;
15 public import HashTableCrefSimVar;
16 public import SimCode;
17 public import SimCodeFunction;
18 public import SimCodeCodegenUtil;
19 public import SimCodeFunctionUtil;
20 public import BackendDAE;
21 public import System;
22 public import Autoconf;
23 protected import Absyn;
24 protected import AbsynUtil;
25 public import MMath;
26 public import DAE;
27 public import ClassInf;
28 public import ClassInfUtil;
29 protected import SCode;
30 protected import SCodeDump;
31 public import StringUtil;
32 public import Util;
33 public import List;
34 public import ComponentReferenceBasics;
35 public import ComponentReference;
36 public import Expression;
37 protected import ExpressionDump;
38 public import ExpressionBasics;
39 public import Config;
40 public import Testsuite;
41 public import Flags;
42 public import FlagsUtil;
43 public import Settings;
44 public import Patternm;
45 public import Error;
46 public import Values;
47 public import ValuesUtil;
48 public import DAEDump;
49 public import Algorithm;
50 protected import ElementSource;
51 public import DAEUtil;
52 public import TypesDump;
53 public import Types;
54 public import HashTableCrIListArray;
55 public import CodegenUtil;
56 public import CodegenCppCommon;
57 public import CodegenCppInit;
58 public import CodegenCpp;
59
60 protected function fun_51
61 input Tpl.Text in_txt;
62 input Boolean in_mArg;
63
64 output Tpl.Text out_txt;
65 algorithm
66 out_txt :=
67 match(in_txt, in_mArg)
68 local
69 Tpl.Text txt;
70
71 case ( txt,
72 false )
73 then txt;
74
75 case ( txt,
76 _ )
77 algorithm
78 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#include <mpi.h>"));
79 then txt;
80 end match;
81 end fun_51;
82
83 protected function fun_52
84 input Tpl.Text in_txt;
85 input Boolean in_mArg;
86
87 output Tpl.Text out_txt;
88 algorithm
89 out_txt :=
90 match(in_txt, in_mArg)
91 local
92 Tpl.Text txt;
93
94 case ( txt,
95 false )
96 then txt;
97
98 case ( txt,
99 _ )
100 algorithm
101 ✗ txt := mpiInit(txt);
102 then txt;
103 end match;
104 end fun_52;
105
106 protected function fun_53
107 input Tpl.Text in_txt;
108 input Boolean in_mArg;
109
110 output Tpl.Text out_txt;
111 algorithm
112 out_txt :=
113 match(in_txt, in_mArg)
114 local
115 Tpl.Text txt;
116
117 case ( txt,
118 false )
119 then txt;
120
121 case ( txt,
122 _ )
123 algorithm
124 ✗ txt := mpiFinalize(txt);
125 then txt;
126 end match;
127 end fun_53;
128
129 protected function fun_54
130 input Tpl.Text in_txt;
131 input Boolean in_mArg;
132 input String in_a_fileNamePrefix;
133 input Tpl.Text in_a_stateDerVectorName;
134 input Tpl.Text in_a_className;
135 input Tpl.Text in_a_extraFuncsDeclInit;
136 input Tpl.Text in_a_extraFuncsInit;
137 input SimCode.SimCode in_a_simCode;
138
139 output Tpl.Text out_txt;
140 output Tpl.Text out_a_stateDerVectorName;
141 output Tpl.Text out_a_extraFuncsDeclInit;
142 output Tpl.Text out_a_extraFuncsInit;
143 algorithm
144 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsDeclInit, out_a_extraFuncsInit) :=
145 match(in_txt, in_mArg, in_a_fileNamePrefix, in_a_stateDerVectorName, in_a_className, in_a_extraFuncsDeclInit, in_a_extraFuncsInit, in_a_simCode)
146 local
147 Tpl.Text txt;
148 String a_fileNamePrefix;
149 Tpl.Text a_stateDerVectorName;
150 Tpl.Text a_className;
151 Tpl.Text a_extraFuncsDeclInit;
152 Tpl.Text a_extraFuncsInit;
153 SimCode.SimCode a_simCode;
154 Tpl.Text txt_5;
155 Tpl.Text txt_4;
156 Tpl.Text txt_3;
157 Tpl.Text txt_2;
158 Tpl.Text txt_1;
159 Tpl.Text txt_0;
160
161 case ( txt,
162 true,
163 a_fileNamePrefix,
164 a_stateDerVectorName,
165 a_className,
166 a_extraFuncsDeclInit,
167 a_extraFuncsInit,
168 a_simCode )
169 algorithm
170 ✗ txt_0 := Tpl.writeText(Tpl.emptyTxt, a_className);
171 ✗ txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("Initialize"));
172 ✗ (txt_1, a_extraFuncsInit, a_extraFuncsDeclInit, txt_0, a_stateDerVectorName) := CodegenCpp.simulationInitParameterCppFile(Tpl.emptyTxt, a_simCode, a_extraFuncsInit, a_extraFuncsDeclInit, txt_0, a_stateDerVectorName, false);
173 ✗ txt_2 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
174 ✗ txt_2 := Tpl.writeStr(txt_2, a_fileNamePrefix);
175 ✗ txt_2 := Tpl.writeTok(txt_2, Tpl.ST_STRING("InitializeParameter.cpp"));
176 ✗ Tpl.textFile(txt_1, Tpl.textString(txt_2));
177 ✗ txt_3 := Tpl.writeText(Tpl.emptyTxt, a_className);
178 ✗ txt_3 := Tpl.writeTok(txt_3, Tpl.ST_STRING("Initialize"));
179 ✗ (txt_4, a_extraFuncsInit, a_extraFuncsDeclInit, txt_3, a_stateDerVectorName) := CodegenCpp.simulationInitAlgVarsCppFile(Tpl.emptyTxt, a_simCode, a_extraFuncsInit, a_extraFuncsDeclInit, txt_3, a_stateDerVectorName, false);
180 ✗ txt_5 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
181 ✗ txt_5 := Tpl.writeStr(txt_5, a_fileNamePrefix);
182 ✗ txt_5 := Tpl.writeTok(txt_5, Tpl.ST_STRING("InitializeAlgVars.cpp"));
183 ✗ Tpl.textFile(txt_4, Tpl.textString(txt_5));
184 ✗ then (txt, a_stateDerVectorName, a_extraFuncsDeclInit, a_extraFuncsInit);
185
186 case ( txt,
187 _,
188 _,
189 a_stateDerVectorName,
190 _,
191 a_extraFuncsDeclInit,
192 a_extraFuncsInit,
193 _ )
194 then (txt, a_stateDerVectorName, a_extraFuncsDeclInit, a_extraFuncsInit);
195 end match;
196 end fun_54;
197
198 protected function lm_55
199 input output Tpl.Text txt;
200 input list<SimCode.JacobianColumn> items;
201 input output Tpl.Text a_stateDerVectorName;
202 input output Tpl.Text a_extraFuncsDecl;
203 input output Tpl.Text a_extraFuncs;
204 input SimCode.SimCode a_simCode;
205 algorithm
206
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 31 times.
56 for lstElt_55 in items loop
207 (txt, a_stateDerVectorName, a_extraFuncsDecl, a_extraFuncs) := match lstElt_55
208 local
209 list<SimCode.SimEqSystem> i_eqs;
210
211 case SimCode.JAC_COLUMN(columnEqns = i_eqs)
212 algorithm
213 25 (txt, a_extraFuncs, a_extraFuncsDecl, _, a_stateDerVectorName) := CodegenCpp.algloopfiles(txt, i_eqs, a_simCode, a_extraFuncs, a_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), SimCodeFunction.contextAlgloopJacobian, 0, a_stateDerVectorName, false);
214 25 txt := Tpl.nextIter(txt);
215 25 then (txt, a_stateDerVectorName, a_extraFuncsDecl, a_extraFuncs);
216
217 case _
218 ✗ then (txt, a_stateDerVectorName, a_extraFuncsDecl, a_extraFuncs);
219 end match;
220 end for;
221 end lm_55;
222
223 protected function lm_56
224 input output Tpl.Text txt;
225 input list<SimCode.JacobianMatrix> items;
226 input output Tpl.Text a_stateDerVectorName;
227 input output Tpl.Text a_extraFuncsDecl;
228 input output Tpl.Text a_extraFuncs;
229 input SimCode.SimCode a_simCode;
230 algorithm
231
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 1 time.
32 for lstElt_56 in items loop
232 (txt, a_stateDerVectorName, a_extraFuncsDecl, a_extraFuncs) := match lstElt_56
233 local
234 list<SimCode.JacobianColumn> i_mat;
235
236 case SimCode.JAC_MATRIX(columns = i_mat)
237 algorithm
238 31 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING("")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
239 31 (txt, a_stateDerVectorName, a_extraFuncsDecl, a_extraFuncs) := lm_55(txt, i_mat, a_stateDerVectorName, a_extraFuncsDecl, a_extraFuncs, a_simCode);
240 31 txt := Tpl.popIter(txt);
241 31 txt := Tpl.nextIter(txt);
242 31 then (txt, a_stateDerVectorName, a_extraFuncsDecl, a_extraFuncs);
243
244 case _
245 ✗ then (txt, a_stateDerVectorName, a_extraFuncsDecl, a_extraFuncs);
246 end match;
247 end for;
248 end lm_56;
249
250 protected function fun_57
251 input Tpl.Text in_txt;
252 input SimCode.SubPartition in_a_subPartition;
253 input Tpl.Text in_a_stateDerVectorName;
254 input Integer in_a_i;
255 input Tpl.Text in_a_extraFuncsDecl;
256 input Tpl.Text in_a_extraFuncs;
257 input SimCode.SimCode in_a_simCode;
258
259 output Tpl.Text out_txt;
260 output Tpl.Text out_a_stateDerVectorName;
261 output Tpl.Text out_a_extraFuncsDecl;
262 output Tpl.Text out_a_extraFuncs;
263 algorithm
264 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsDecl, out_a_extraFuncs) :=
265 match(in_txt, in_a_subPartition, in_a_stateDerVectorName, in_a_i, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode)
266 local
267 Tpl.Text txt;
268 Tpl.Text a_stateDerVectorName;
269 Integer a_i;
270 Tpl.Text a_extraFuncsDecl;
271 Tpl.Text a_extraFuncs;
272 SimCode.SimCode a_simCode;
273 list<SimCode.SimEqSystem> i_removedEquations;
274 list<SimCode.SimEqSystem> i_equations;
275 list<SimCode.SimEqSystem> ret_0;
276
277 case ( txt,
278 SimCode.SUBPARTITION(equations = i_equations, removedEquations = i_removedEquations),
279 a_stateDerVectorName,
280 a_i,
281 a_extraFuncsDecl,
282 a_extraFuncs,
283 a_simCode )
284 algorithm
285 ✗ ret_0 := listAppend(i_equations, i_removedEquations);
286 ✗ (txt, a_extraFuncs, a_extraFuncsDecl, _, a_stateDerVectorName) := CodegenCpp.algloopfiles(txt, ret_0, a_simCode, a_extraFuncs, a_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), SimCodeFunction.contextAlgloop, a_i, a_stateDerVectorName, false);
287 ✗ then (txt, a_stateDerVectorName, a_extraFuncsDecl, a_extraFuncs);
288
289 case ( txt,
290 _,
291 a_stateDerVectorName,
292 _,
293 a_extraFuncsDecl,
294 a_extraFuncs,
295 _ )
296 then (txt, a_stateDerVectorName, a_extraFuncsDecl, a_extraFuncs);
297 end match;
298 end fun_57;
299
300 protected function lm_58
301 input output Tpl.Text txt;
302 input list<SimCode.SubPartition> items;
303 input output Tpl.Text a_stateDerVectorName;
304 input output Tpl.Text a_extraFuncsDecl;
305 input output Tpl.Text a_extraFuncs;
306 input SimCode.SimCode a_simCode;
307 algorithm
308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 for lstElt_58 in items loop
309 (txt, a_stateDerVectorName, a_extraFuncsDecl, a_extraFuncs) := match lstElt_58
310 local
311 Integer x_i;
312 SimCode.SubPartition i_subPartition;
313
314 case i_subPartition
315 algorithm
316 ✗ x_i := Tpl.getIteri_i0(txt);
317 ✗ (txt, a_stateDerVectorName, a_extraFuncsDecl, a_extraFuncs) := fun_57(txt, i_subPartition, a_stateDerVectorName, x_i, a_extraFuncsDecl, a_extraFuncs, a_simCode);
318 ✗ txt := Tpl.nextIter(txt);
319 then (txt, a_stateDerVectorName, a_extraFuncsDecl, a_extraFuncs);
320 end match;
321 end for;
322 end lm_58;
323
324 public function translateModel
325 input Tpl.Text in_txt;
326 input SimCode.SimCode in_a_simCode;
327
328 output Tpl.Text out_txt;
329 algorithm
330 out_txt :=
331 match(in_txt, in_a_simCode)
332 local
333 Tpl.Text txt;
334 list<SimCode.ClockedPartition> i_clockedPartitions;
335 list<SimCode.SimEqSystem> i_initialEquations;
336 list<SimCode.JacobianMatrix> i_jacobianMatrices;
337 list<String> i_externalFunctionIncludes;
338 list<DAE.Exp> i_literals;
339 list<SimCodeFunction.Function> i_modelInfo_functions;
340 HashTableCrIListArray.HashTable i_varToArrayIndexMapping;
341 Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> i_hpcomData_schedules;
342 list<SimCode.SimEqSystem> i_allEquations;
343 String i_fileNamePrefix;
344 SimCode.SimCode i_simCode;
345 Option<HpcOmSimCode.MemoryMap> i_hpcomData_hpcOmMemory;
346 SimCode.ModelInfo i_modelInfo;
347 Absyn.Path i_modelInfo_name;
348 Tpl.Text txt_100;
349 Tpl.Text txt_99;
350 Tpl.Text txt_98;
351 Tpl.Text txt_97;
352 list<SimCode.SubPartition> ret_96;
353 Tpl.Text l_clk;
354 list<SimCode.SimEqSystem> ret_94;
355 Tpl.Text l_alg;
356 Tpl.Text l_jac;
357 Tpl.Text txt_91;
358 Tpl.Text txt_90;
359 Tpl.Text txt_89;
360 Tpl.Text txt_88;
361 Tpl.Text txt_87;
362 Tpl.Text txt_86;
363 Tpl.Text txt_85;
364 Tpl.Text txt_84;
365 Tpl.Text txt_83;
366 Tpl.Text txt_82;
367 Tpl.Text txt_81;
368 Tpl.Text txt_80;
369 Tpl.Text txt_79;
370 Tpl.Text txt_78;
371 Tpl.Text txt_77;
372 Tpl.Text txt_76;
373 Tpl.Text txt_75;
374 Tpl.Text txt_74;
375 Tpl.Text txt_73;
376 Tpl.Text txt_72;
377 Tpl.Text txt_71;
378 Boolean ret_70;
379 Tpl.Text l_jacobianVarsInit;
380 Tpl.Text txt_68;
381 Tpl.Text txt_67;
382 Tpl.Text txt_66;
383 Boolean ret_65;
384 Boolean ret_64;
385 Boolean ret_63;
386 Tpl.Text l_0__;
387 Tpl.Text txt_61;
388 Tpl.Text txt_60;
389 Tpl.Text txt_59;
390 Tpl.Text txt_58;
391 Tpl.Text txt_57;
392 Tpl.Text l_complexStartExpressions;
393 Tpl.Text l_extraFuncsDeclInit;
394 Tpl.Text l_extraFuncsInit;
395 Tpl.Text txt_53;
396 Tpl.Text txt_52;
397 Tpl.Text txt_51;
398 Tpl.Text txt_50;
399 Tpl.Text l_extraFuncsDeclFun;
400 Tpl.Text l_extraFuncsFun;
401 Tpl.Text txt_47;
402 Tpl.Text txt_46;
403 Tpl.Text txt_45;
404 Tpl.Text txt_44;
405 Tpl.Text txt_43;
406 Tpl.Text txt_42;
407 Tpl.Text txt_41;
408 Boolean ret_40;
409 Tpl.Text txt_39;
410 Tpl.Text txt_38;
411 Tpl.Text txt_37;
412 Tpl.Text txt_36;
413 Tpl.Text txt_35;
414 Tpl.Text txt_34;
415 Tpl.Text txt_33;
416 Tpl.Text txt_32;
417 Tpl.Text txt_31;
418 Tpl.Text txt_30;
419 Tpl.Text txt_29;
420 Tpl.Text txt_28;
421 Tpl.Text txt_27;
422 Tpl.Text txt_26;
423 Tpl.Text txt_25;
424 Tpl.Text txt_24;
425 Tpl.Text txt_23;
426 Tpl.Text txt_22;
427 Tpl.Text txt_21;
428 Tpl.Text txt_19;
429 Boolean ret_19;
430 Tpl.Text txt_17;
431 Boolean ret_17;
432 Tpl.Text txt_15;
433 Boolean ret_15;
434 Tpl.Text l_numPreVars;
435 Tpl.Text l_numStringVars;
436 Tpl.Text l_numBoolVars;
437 Tpl.Text l_numIntVars;
438 Tpl.Text l_numRealVars;
439 Tpl.Text l_className;
440 Boolean ret_8;
441 Tpl.Text l_useMemoryOptimization;
442 Tpl.Text l_stateDerVectorName;
443 Tpl.Text l_dummyTypeElemCreation;
444 Tpl.Text l_extraResidualsFuncsDecl;
445 Tpl.Text l_extraFuncsDecl;
446 Tpl.Text l_extraFuncs;
447 String ret_1;
448 Tpl.Text l_target;
449
450 case ( txt,
451 (i_simCode as SimCode.SIMCODE(modelInfo = (i_modelInfo as SimCode.MODELINFO(name = i_modelInfo_name, functions = i_modelInfo_functions)), makefileParams = SimCodeFunction.MAKEFILE_PARAMS(ccompiler = _), hpcomData = HpcOmSimCode.HPCOMDATA(hpcOmMemory = i_hpcomData_hpcOmMemory, schedules = i_hpcomData_schedules), fileNamePrefix = i_fileNamePrefix, allEquations = i_allEquations, varToArrayIndexMapping = i_varToArrayIndexMapping, literals = i_literals, externalFunctionIncludes = i_externalFunctionIncludes, jacobianMatrices = i_jacobianMatrices, initialEquations = i_initialEquations, clockedPartitions = i_clockedPartitions)) )
452 algorithm
453 1 ret_1 := Config.simulationCodeTarget();
454 1 l_target := Tpl.writeStr(Tpl.emptyTxt, ret_1);
455 1 l_extraFuncs := Tpl.emptyTxt;
456 1 l_extraFuncsDecl := Tpl.emptyTxt;
457 1 l_extraResidualsFuncsDecl := Tpl.emptyTxt;
458 1 l_dummyTypeElemCreation := Tpl.emptyTxt;
459 1 l_stateDerVectorName := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("__zDot"));
460 1 ret_8 := Flags.isSet(Flags.HPCOM_MEMORY_OPT);
461 1 l_useMemoryOptimization := Tpl.writeStr(Tpl.emptyTxt, Tpl.booleanString(ret_8));
462 1 l_className := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, i_modelInfo_name);
463 1 l_numRealVars := numRealvarsHpcom(Tpl.emptyTxt, i_modelInfo, i_hpcomData_hpcOmMemory);
464 1 l_numIntVars := numIntvarsHpcom(Tpl.emptyTxt, i_modelInfo, i_hpcomData_hpcOmMemory);
465 1 l_numBoolVars := numBoolvarsHpcom(Tpl.emptyTxt, i_modelInfo, i_hpcomData_hpcOmMemory);
466 1 l_numStringVars := CodegenCpp.numStringvars(Tpl.emptyTxt, i_modelInfo);
467 1 l_numPreVars := numPreVarsHpcom(Tpl.emptyTxt, i_modelInfo, i_hpcomData_hpcOmMemory);
468 1 ret_15 := Flags.isSet(Flags.USEMPI);
469 1 txt_15 := fun_51(Tpl.emptyTxt, ret_15);
470 1 ret_17 := Flags.isSet(Flags.USEMPI);
471 1 txt_17 := fun_52(Tpl.emptyTxt, ret_17);
472 1 ret_19 := Flags.isSet(Flags.USEMPI);
473 1 txt_19 := fun_53(Tpl.emptyTxt, ret_19);
474 1 (txt_21, l_extraFuncs, l_extraFuncsDecl, _) := CodegenCpp.simulationMainFile(Tpl.emptyTxt, Tpl.textString(l_target), i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), Tpl.textString(txt_15), Tpl.textString(txt_17), Tpl.textString(txt_19), Tpl.textString(l_numRealVars), Tpl.textString(l_numIntVars), Tpl.textString(l_numBoolVars), Tpl.textString(l_numStringVars), Tpl.textString(l_numPreVars));
475 1 txt_22 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
476 1 txt_22 := Tpl.writeStr(txt_22, i_fileNamePrefix);
477 1 txt_22 := Tpl.writeTok(txt_22, Tpl.ST_STRING("Main.cpp"));
478 1 Tpl.textFile(txt_21, Tpl.textString(txt_22));
479 1 (txt_23, l_extraFuncs, l_extraFuncsDecl, _, l_stateDerVectorName) := updateHpcom(Tpl.emptyTxt, i_allEquations, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), SimCodeFunction.contextOther, l_stateDerVectorName, false);
480 1 txt_24 := Tpl.writeText(Tpl.emptyTxt, l_numRealVars);
481 1 txt_24 := Tpl.writeTok(txt_24, Tpl.ST_STRING("-1"));
482 1 txt_25 := Tpl.writeText(Tpl.emptyTxt, l_numIntVars);
483 1 txt_25 := Tpl.writeTok(txt_25, Tpl.ST_STRING("-1"));
484 1 txt_26 := Tpl.writeText(Tpl.emptyTxt, l_numBoolVars);
485 1 txt_26 := Tpl.writeTok(txt_26, Tpl.ST_STRING("-1"));
486 1 txt_27 := Tpl.writeText(Tpl.emptyTxt, l_numStringVars);
487 1 txt_27 := Tpl.writeTok(txt_27, Tpl.ST_STRING("-1"));
488 1 txt_28 := additionalHpcomConstructorDefinitions(Tpl.emptyTxt, i_hpcomData_schedules);
489 1 txt_29 := CodegenUtil.dotPath(Tpl.emptyTxt, i_modelInfo_name);
490 1 txt_30 := additionalHpcomConstructorBodyStatements(Tpl.emptyTxt, i_hpcomData_schedules, Tpl.textString(l_className), Tpl.textString(txt_29));
491 1 txt_31 := additionalHpcomDestructorBodyStatements(Tpl.emptyTxt, i_hpcomData_schedules);
492 1 (txt_32, txt_23, txt_24, txt_25, txt_26, txt_27, l_extraFuncs, l_extraFuncsDecl, l_className, txt_28, txt_30, txt_31, l_stateDerVectorName) := CodegenCpp.simulationCppFile(Tpl.emptyTxt, i_simCode, SimCodeFunction.contextOther, txt_23, txt_24, txt_25, txt_26, txt_27, l_extraFuncs, l_extraFuncsDecl, l_className, txt_28, txt_30, txt_31, l_stateDerVectorName, false);
493 1 txt_33 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
494 1 txt_33 := Tpl.writeStr(txt_33, i_fileNamePrefix);
495 1 txt_33 := Tpl.writeTok(txt_33, Tpl.ST_STRING(".cpp"));
496 1 Tpl.textFile(txt_32, Tpl.textString(txt_33));
497 1 (txt_34, l_extraFuncs, l_extraFuncsDecl, l_className) := additionalHpcomIncludes(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, l_className, false);
498 1 (txt_35, l_extraFuncs, l_extraFuncsDecl, _) := additionalHpcomProtectedMemberDeclaration(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), false);
499 1 txt_36 := Tpl.writeText(Tpl.emptyTxt, l_numRealVars);
500 1 txt_36 := Tpl.writeTok(txt_36, Tpl.ST_STRING("-1"));
501 1 txt_37 := Tpl.writeText(Tpl.emptyTxt, l_numIntVars);
502 1 txt_37 := Tpl.writeTok(txt_37, Tpl.ST_STRING("-1"));
503 1 txt_38 := Tpl.writeText(Tpl.emptyTxt, l_numBoolVars);
504 1 txt_38 := Tpl.writeTok(txt_38, Tpl.ST_STRING("-1"));
505 1 txt_39 := Tpl.writeText(Tpl.emptyTxt, l_numStringVars);
506 1 txt_39 := Tpl.writeTok(txt_39, Tpl.ST_STRING("-1"));
507 1 ret_40 := Flags.isSet(Flags.GEN_DEBUG_SYMBOLS);
508 1 (txt_41, txt_36, txt_37, txt_38, txt_39) := CodegenCpp.memberVariableDefine(Tpl.emptyTxt, i_modelInfo, i_varToArrayIndexMapping, txt_36, txt_37, txt_38, txt_39, ret_40, false);
509 1 (txt_42, l_extraFuncs, l_extraFuncsDecl, _) := CodegenCpp.simulationHeaderFile(Tpl.emptyTxt, i_simCode, SimCodeFunction.contextOther, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), Tpl.textString(txt_34), "", Tpl.textString(txt_35), Tpl.textString(txt_41), false);
510 1 txt_43 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
511 1 txt_43 := Tpl.writeStr(txt_43, i_fileNamePrefix);
512 1 txt_43 := Tpl.writeTok(txt_43, Tpl.ST_STRING(".h"));
513 1 Tpl.textFile(txt_42, Tpl.textString(txt_43));
514 1 (txt_44, l_extraFuncs, l_extraFuncsDecl, _, l_dummyTypeElemCreation, l_stateDerVectorName) := CodegenCpp.simulationTypesHeaderFile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), l_dummyTypeElemCreation, i_modelInfo_functions, i_literals, l_stateDerVectorName, false);
515 1 txt_45 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
516 1 txt_45 := Tpl.writeStr(txt_45, i_fileNamePrefix);
517 1 txt_45 := Tpl.writeTok(txt_45, Tpl.ST_STRING("Types.h"));
518 1 Tpl.textFile(txt_44, Tpl.textString(txt_45));
519 1 (txt_46, l_extraFuncs, l_extraFuncsDecl, _) := simulationMakefile(Tpl.emptyTxt, Tpl.textString(l_target), i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")));
520 1 txt_47 := Tpl.writeStr(Tpl.emptyTxt, i_fileNamePrefix);
521 1 txt_47 := Tpl.writeTok(txt_47, Tpl.ST_STRING(".makefile"));
522 1 Tpl.textFile(txt_46, Tpl.textString(txt_47));
523 1 l_extraFuncsFun := Tpl.emptyTxt;
524 1 l_extraFuncsDeclFun := Tpl.emptyTxt;
525 1 (txt_50, l_extraFuncsFun, l_extraFuncsDeclFun, _, l_stateDerVectorName) := CodegenCpp.simulationFunctionsHeaderFile(Tpl.emptyTxt, i_simCode, l_extraFuncsFun, l_extraFuncsDeclFun, Tpl.strTokText(Tpl.ST_STRING("")), i_modelInfo_functions, i_literals, l_stateDerVectorName, false);
526 1 txt_51 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
527 1 txt_51 := Tpl.writeStr(txt_51, i_fileNamePrefix);
528 1 txt_51 := Tpl.writeTok(txt_51, Tpl.ST_STRING("Functions.h"));
529 1 Tpl.textFile(txt_50, Tpl.textString(txt_51));
530 1 (txt_52, l_extraFuncsFun, l_extraFuncsDeclFun, _, l_stateDerVectorName) := CodegenCpp.simulationFunctionsFile(Tpl.emptyTxt, i_simCode, l_extraFuncsFun, l_extraFuncsDeclFun, Tpl.strTokText(Tpl.ST_STRING("")), i_modelInfo_functions, i_literals, i_externalFunctionIncludes, l_stateDerVectorName, false);
531 1 txt_53 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
532 1 txt_53 := Tpl.writeStr(txt_53, i_fileNamePrefix);
533 1 txt_53 := Tpl.writeTok(txt_53, Tpl.ST_STRING("Functions.cpp"));
534 1 Tpl.textFile(txt_52, Tpl.textString(txt_53));
535 1 l_extraFuncsInit := Tpl.emptyTxt;
536 1 l_extraFuncsDeclInit := Tpl.emptyTxt;
537 1 l_complexStartExpressions := Tpl.emptyTxt;
538 1 (txt_57, l_complexStartExpressions, l_stateDerVectorName) := CodegenCppInit.modelInitXMLFile(Tpl.emptyTxt, i_simCode, Tpl.textString(l_numRealVars), Tpl.textString(l_numIntVars), Tpl.textString(l_numBoolVars), Tpl.textString(l_numStringVars), "", "", "", false, "", l_complexStartExpressions, l_stateDerVectorName);
539 1 txt_58 := Tpl.writeStr(Tpl.emptyTxt, i_fileNamePrefix);
540 1 txt_58 := Tpl.writeTok(txt_58, Tpl.ST_STRING("_init.xml"));
541 1 Tpl.textFile(txt_57, Tpl.textString(txt_58));
542 1 txt_59 := Tpl.writeText(Tpl.emptyTxt, l_className);
543 1 txt_59 := Tpl.writeTok(txt_59, Tpl.ST_STRING("Initialize"));
544 1 (txt_60, l_extraFuncsInit, l_extraFuncsDeclInit, txt_59, l_dummyTypeElemCreation, l_stateDerVectorName, l_complexStartExpressions) := CodegenCpp.simulationInitCppFile(Tpl.emptyTxt, i_simCode, l_extraFuncsInit, l_extraFuncsDeclInit, txt_59, l_dummyTypeElemCreation, l_stateDerVectorName, false, l_complexStartExpressions);
545 1 txt_61 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
546 1 txt_61 := Tpl.writeStr(txt_61, i_fileNamePrefix);
547 1 txt_61 := Tpl.writeTok(txt_61, Tpl.ST_STRING("Initialize.cpp"));
548 1 Tpl.textFile(txt_60, Tpl.textString(txt_61));
549 1 ret_63 := Flags.isSet(Flags.HARDCODED_START_VALUES);
550 1 ret_64 := Flags.isSet(Flags.GEN_DEBUG_SYMBOLS);
551 1 ret_65 := boolOr(ret_63, ret_64);
552 1 (l_0__, l_stateDerVectorName, l_extraFuncsDeclInit, l_extraFuncsInit) := fun_54(Tpl.emptyTxt, ret_65, i_fileNamePrefix, l_stateDerVectorName, l_className, l_extraFuncsDeclInit, l_extraFuncsInit, i_simCode);
553 1 txt_66 := Tpl.writeText(Tpl.emptyTxt, l_className);
554 1 txt_66 := Tpl.writeTok(txt_66, Tpl.ST_STRING("Initialize"));
555 1 (txt_67, l_extraFuncsInit, l_extraFuncsDeclInit, txt_66) := CodegenCpp.simulationInitHeaderFile(Tpl.emptyTxt, i_simCode, l_extraFuncsInit, l_extraFuncsDeclInit, txt_66);
556 1 txt_68 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
557 1 txt_68 := Tpl.writeStr(txt_68, i_fileNamePrefix);
558 1 txt_68 := Tpl.writeTok(txt_68, Tpl.ST_STRING("Initialize.h"));
559 1 Tpl.textFile(txt_67, Tpl.textString(txt_68));
560 1 l_jacobianVarsInit := Tpl.emptyTxt;
561 1 ret_70 := Flags.isSet(Flags.GEN_DEBUG_SYMBOLS);
562 1 (txt_71, l_extraFuncs, l_extraFuncsDecl, _, l_jacobianVarsInit) := CodegenCpp.simulationJacobianHeaderFile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), l_jacobianVarsInit, ret_70);
563 1 txt_72 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
564 1 txt_72 := Tpl.writeStr(txt_72, i_fileNamePrefix);
565 1 txt_72 := Tpl.writeTok(txt_72, Tpl.ST_STRING("Jacobian.h"));
566 1 Tpl.textFile(txt_71, Tpl.textString(txt_72));
567 1 (txt_73, l_extraFuncs, l_extraFuncsDecl, _, l_jacobianVarsInit, l_stateDerVectorName) := CodegenCpp.simulationJacobianCppFile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), l_jacobianVarsInit, l_stateDerVectorName, false);
568 1 txt_74 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
569 1 txt_74 := Tpl.writeStr(txt_74, i_fileNamePrefix);
570 1 txt_74 := Tpl.writeTok(txt_74, Tpl.ST_STRING("Jacobian.cpp"));
571 1 Tpl.textFile(txt_73, Tpl.textString(txt_74));
572 1 (txt_75, l_extraFuncs, l_extraFuncsDecl, _, l_stateDerVectorName) := CodegenCpp.simulationStateSelectionCppFile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), l_stateDerVectorName, false);
573 1 txt_76 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
574 1 txt_76 := Tpl.writeStr(txt_76, i_fileNamePrefix);
575 1 txt_76 := Tpl.writeTok(txt_76, Tpl.ST_STRING("StateSelection.cpp"));
576 1 Tpl.textFile(txt_75, Tpl.textString(txt_76));
577 1 (txt_77, l_extraFuncs, l_extraFuncsDecl, _) := CodegenCpp.simulationStateSelectionHeaderFile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")));
578 1 txt_78 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
579 1 txt_78 := Tpl.writeStr(txt_78, i_fileNamePrefix);
580 1 txt_78 := Tpl.writeTok(txt_78, Tpl.ST_STRING("StateSelection.h"));
581 1 Tpl.textFile(txt_77, Tpl.textString(txt_78));
582 1 (txt_79, l_extraResidualsFuncsDecl, l_className, l_stateDerVectorName) := CodegenCpp.updateResiduals(Tpl.emptyTxt, i_simCode, l_extraResidualsFuncsDecl, l_className, l_stateDerVectorName, false);
583 1 (txt_80, txt_79, l_extraFuncs, l_extraFuncsDecl, _, l_stateDerVectorName) := CodegenCpp.simulationMixedSystemCppFile(Tpl.emptyTxt, i_simCode, txt_79, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), l_stateDerVectorName, false);
584 1 txt_81 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
585 1 txt_81 := Tpl.writeStr(txt_81, i_fileNamePrefix);
586 1 txt_81 := Tpl.writeTok(txt_81, Tpl.ST_STRING("Mixed.cpp"));
587 1 Tpl.textFile(txt_80, Tpl.textString(txt_81));
588 1 (txt_82, l_extraResidualsFuncsDecl) := CodegenCpp.simulationMixedSystemHeaderFile(Tpl.emptyTxt, i_simCode, l_extraResidualsFuncsDecl);
589 1 txt_83 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
590 1 txt_83 := Tpl.writeStr(txt_83, i_fileNamePrefix);
591 1 txt_83 := Tpl.writeTok(txt_83, Tpl.ST_STRING("Mixed.h"));
592 1 Tpl.textFile(txt_82, Tpl.textString(txt_83));
593 1 (txt_84, l_extraFuncs, l_extraFuncsDecl, _) := CodegenCpp.simulationWriteOutputHeaderFile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")));
594 1 txt_85 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
595 1 txt_85 := Tpl.writeStr(txt_85, i_fileNamePrefix);
596 1 txt_85 := Tpl.writeTok(txt_85, Tpl.ST_STRING("WriteOutput.h"));
597 1 Tpl.textFile(txt_84, Tpl.textString(txt_85));
598 1 (txt_86, l_extraFuncs, l_extraFuncsDecl, _, l_stateDerVectorName) := CodegenCpp.simulationWriteOutputCppFile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), l_stateDerVectorName, false);
599 1 txt_87 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
600 1 txt_87 := Tpl.writeStr(txt_87, i_fileNamePrefix);
601 1 txt_87 := Tpl.writeTok(txt_87, Tpl.ST_STRING("WriteOutput.cpp"));
602 1 Tpl.textFile(txt_86, Tpl.textString(txt_87));
603 1 (txt_88, l_extraFuncs, l_extraFuncsDecl, _) := CodegenCpp.simulationFactoryFile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")));
604 1 txt_89 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
605 1 txt_89 := Tpl.writeStr(txt_89, i_fileNamePrefix);
606 1 txt_89 := Tpl.writeTok(txt_89, Tpl.ST_STRING("FactoryExport.cpp"));
607 1 Tpl.textFile(txt_88, Tpl.textString(txt_89));
608 1 (txt_90, l_extraFuncs, l_extraFuncsDecl, _) := simulationMainRunScript(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")));
609 1 txt_91 := Tpl.writeStr(Tpl.emptyTxt, i_fileNamePrefix);
610 1 (txt_91, l_extraFuncs, l_extraFuncsDecl, _) := CodegenCpp.simulationMainRunScriptSuffix(txt_91, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")));
611 1 Tpl.textFile(txt_90, Tpl.textString(txt_91));
612 1 l_jac := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING("")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
613 1 (l_jac, l_stateDerVectorName, l_extraFuncsDecl, l_extraFuncs) := lm_56(l_jac, i_jacobianMatrices, l_stateDerVectorName, l_extraFuncsDecl, l_extraFuncs, i_simCode);
614 1 l_jac := Tpl.popIter(l_jac);
615 1 ret_94 := listAppend(i_allEquations, i_initialEquations);
616 1 (l_alg, l_extraFuncs, l_extraFuncsDecl, _, l_stateDerVectorName) := CodegenCpp.algloopfiles(Tpl.emptyTxt, ret_94, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), SimCodeFunction.contextAlgloop, 0, l_stateDerVectorName, false);
617 1 ret_96 := SimCodeCodegenUtil.getSubPartitions(i_clockedPartitions);
618 1 l_clk := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
619 1 (l_clk, l_stateDerVectorName, l_extraFuncsDecl, l_extraFuncs) := lm_58(l_clk, ret_96, l_stateDerVectorName, l_extraFuncsDecl, l_extraFuncs, i_simCode);
620 1 l_clk := Tpl.popIter(l_clk);
621 1 (txt_97, l_extraFuncs, l_extraFuncsDecl, _) := CodegenCpp.algloopMainfile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), SimCodeFunction.contextAlgloop);
622 1 txt_98 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
623 1 txt_98 := Tpl.writeStr(txt_98, i_fileNamePrefix);
624 1 txt_98 := Tpl.writeTok(txt_98, Tpl.ST_STRING("AlgLoopMain.cpp"));
625 1 Tpl.textFile(txt_97, Tpl.textString(txt_98));
626 1 (txt_99, l_extraFuncs, l_extraFuncsDecl, _) := CodegenCpp.calcHelperMainfile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")));
627 1 txt_100 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
628 1 txt_100 := Tpl.writeStr(txt_100, i_fileNamePrefix);
629 1 txt_100 := Tpl.writeTok(txt_100, Tpl.ST_STRING("CalcHelperMain.cpp"));
630 1 Tpl.textFile(txt_99, Tpl.textString(txt_100));
631 then txt;
632
633 case ( txt,
634 _ )
635 then txt;
636 end match;
637 end translateModel;
638
639 protected function fun_60
640 input Tpl.Text in_txt;
641 input SimCode.SimCode in_a_simCode;
642 input Tpl.Text in_a_extraFuncs;
643 input Tpl.Text in_a_extraFuncsDecl;
644 input Tpl.Text in_a_extraFuncsNamespace;
645
646 output Tpl.Text out_txt;
647 output Tpl.Text out_a_extraFuncs;
648 output Tpl.Text out_a_extraFuncsDecl;
649 output Tpl.Text out_a_extraFuncsNamespace;
650 algorithm
651 (out_txt, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) :=
652 match(in_txt, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace)
653 local
654 Tpl.Text txt;
655 Tpl.Text a_extraFuncs;
656 Tpl.Text a_extraFuncsDecl;
657 Tpl.Text a_extraFuncsNamespace;
658 SimCode.SimCode i_simCode;
659
660 case ( txt,
661 (i_simCode as SimCode.SIMCODE(modelInfo = _)),
662 a_extraFuncs,
663 a_extraFuncsDecl,
664 a_extraFuncsNamespace )
665 algorithm
666 1 (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := additionalHpcomIncludesForParallelCode(txt, i_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
667 then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
668
669 case ( txt,
670 _,
671 a_extraFuncs,
672 a_extraFuncsDecl,
673 a_extraFuncsNamespace )
674 ✗ then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
675 end match;
676 end fun_60;
677
678 public function additionalHpcomIncludes
679 input Tpl.Text txt;
680 input SimCode.SimCode a_simCode;
681 input Tpl.Text a_extraFuncs;
682 input Tpl.Text a_extraFuncsDecl;
683 input Tpl.Text a_extraFuncsNamespace;
684 input Boolean a_useFlatArrayNotation;
685
686 output Tpl.Text out_txt;
687 output Tpl.Text out_a_extraFuncs;
688 output Tpl.Text out_a_extraFuncsDecl;
689 output Tpl.Text out_a_extraFuncsNamespace;
690 algorithm
691 1 (out_txt, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := fun_60(txt, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
692 end additionalHpcomIncludes;
693
694 protected function fun_62
695 input Tpl.Text in_txt;
696 input String in_mArg;
697
698 output Tpl.Text out_txt;
699 algorithm
700 out_txt :=
701 match(in_txt, in_mArg)
702 local
703 Tpl.Text txt;
704
705 case ( txt,
706 "openmp" )
707 algorithm
708 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#include <omp.h>"));
709 then txt;
710
711 case ( txt,
712 "pthreads" )
713 then txt;
714
715 case ( txt,
716 "pthreads_spin" )
717 then txt;
718
719 case ( txt,
720 "tbb" )
721 algorithm
722 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
723 "#include <tbb/tbb.h>\n",
724 "#include <tbb/flow_graph.h>\n",
725 "#include <tbb/tbb_stddef.h>\n",
726 "#if TBB_INTERFACE_VERSION >= 8000\n",
727 "#include <tbb/task_arena.h>\n",
728 "#endif"
729 }, false));
730 then txt;
731
732 case ( txt,
733 "mpi" )
734 algorithm
735 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#include <mpi.h>"));
736 then txt;
737
738 case ( txt,
739 _ )
740 then txt;
741 end match;
742 end fun_62;
743
744 public function additionalHpcomIncludesForParallelCode
745 input Tpl.Text txt;
746 input SimCode.SimCode a_simCode;
747 input Tpl.Text a_extraFuncs;
748 input Tpl.Text a_extraFuncsDecl;
749 input Tpl.Text a_extraFuncsNamespace;
750
751 output Tpl.Text out_txt;
752 output Tpl.Text out_a_extraFuncs;
753 output Tpl.Text out_a_extraFuncsDecl;
754 output Tpl.Text out_a_extraFuncsNamespace;
755 protected
756 String str_2;
757 String ret_1;
758 Tpl.Text l_type;
759 algorithm
760 1 ret_1 := Flags.getConfigString(Flags.HPCOM_CODE);
761 1 l_type := Tpl.writeStr(Tpl.emptyTxt, ret_1);
762 1 str_2 := Tpl.textString(l_type);
763 1 out_txt := fun_62(txt, str_2);
764 out_a_extraFuncs := a_extraFuncs;
765 out_a_extraFuncsDecl := a_extraFuncsDecl;
766 out_a_extraFuncsNamespace := a_extraFuncsNamespace;
767 end additionalHpcomIncludesForParallelCode;
768
769 protected function fun_64
770 input Tpl.Text in_txt;
771 input String in_mArg;
772
773 output Tpl.Text out_txt;
774 algorithm
775 out_txt :=
776 match(in_txt, in_mArg)
777 local
778 Tpl.Text txt;
779
780 case ( txt,
781 "openmp" )
782 algorithm
783 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("return (long unsigned int)omp_get_thread_num();"));
784 then txt;
785
786 case ( txt,
787 "mpi" )
788 algorithm
789 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("return -1; //not supported"));
790 then txt;
791
792 case ( txt,
793 "tbb" )
794 algorithm
795 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("return -1; //not supported"));
796 then txt;
797
798 case ( txt,
799 _ )
800 algorithm
801 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
802 "#if defined(USE_THREAD)\n",
803 " return std::hash<std::thread::id>()(std::this_thread::get_id());\n",
804 "#else\n",
805 " return 0;\n",
806 "#endif"
807 }, false));
808 then txt;
809 end match;
810 end fun_64;
811
812 protected function lm_65
813 input output Tpl.Text txt;
814 input list<Integer> items;
815 algorithm
816 ✗ for lstElt_65 in items loop
817 txt := match lstElt_65
818 local
819 Integer i_threadIdx;
820 Integer ret_0;
821
822 case i_threadIdx
823 algorithm
824 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("MeasureTimeValues* measuredSchedulerStartValues_"));
825 ✗ ret_0 := intSub(i_threadIdx, 1);
826 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
827 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
828 ✗ txt := Tpl.nextIter(txt);
829 then txt;
830 end match;
831 end for;
832 end lm_65;
833
834 protected function lm_66
835 input output Tpl.Text txt;
836 input list<Integer> items;
837 algorithm
838 ✗ for lstElt_66 in items loop
839 txt := match lstElt_66
840 local
841 Integer i_threadIdx;
842 Integer ret_0;
843
844 case i_threadIdx
845 algorithm
846 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("MeasureTimeValues* measuredSchedulerEndValues_"));
847 ✗ ret_0 := intSub(i_threadIdx, 1);
848 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
849 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
850 ✗ txt := Tpl.nextIter(txt);
851 then txt;
852 end match;
853 end for;
854 end lm_66;
855
856 protected function fun_67
857 input Tpl.Text in_txt;
858 input Boolean in_mArg;
859
860 output Tpl.Text out_txt;
861 algorithm
862 out_txt :=
863 match(in_txt, in_mArg)
864 local
865 Tpl.Text txt;
866 list<Integer> ret_3;
867 Integer ret_2;
868 list<Integer> ret_1;
869 Integer ret_0;
870
871 case ( txt,
872 false )
873 then txt;
874
875 case ( txt,
876 _ )
877 algorithm
878 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
879 "std::vector<MeasureTimeData*> *measureTimeArrayHpcom;\n",
880 "std::vector<MeasureTimeData*> *measureTimeSchedulerArrayHpcom_evaluateODE;\n",
881 "std::vector<MeasureTimeData*> *measureTimeSchedulerArrayHpcom_evaluateDAE;\n",
882 "std::vector<MeasureTimeData*> *measureTimeSchedulerArrayHpcom_evaluateZeroFuncs;\n",
883 "//MeasureTimeValues *measuredStartValuesODE, *measuredEndValuesODE;\n",
884 "MeasureTimeValues *measuredSchedulerStartValues, *measuredSchedulerEndValues;\n",
885 "\n",
886 "#ifdef MEASURETIME_MODELFUNCTIONS\n",
887 "std::vector<MeasureTimeData*> *measureTimeThreadArrayOdeHpcom;\n",
888 "std::vector<MeasureTimeData*> *measureTimeThreadArrayDaeHpcom;\n",
889 "std::vector<MeasureTimeData*> *measureTimeThreadArrayZeroFuncHpcom;\n"
890 }, true));
891 ✗ ret_0 := Flags.getConfigInt(Flags.NUM_PROC);
892 ✗ ret_1 := List.intRange(ret_0);
893 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
894 ✗ txt := lm_65(txt, ret_1);
895 ✗ txt := Tpl.popIter(txt);
896 ✗ txt := Tpl.softNewLine(txt);
897 ✗ ret_2 := Flags.getConfigInt(Flags.NUM_PROC);
898 ✗ ret_3 := List.intRange(ret_2);
899 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
900 ✗ txt := lm_66(txt, ret_3);
901 ✗ txt := Tpl.popIter(txt);
902 ✗ txt := Tpl.softNewLine(txt);
903 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#endif //MEASURETIME_MODELFUNCTIONS"));
904 then txt;
905 end match;
906 end fun_67;
907
908 protected function fun_68
909 input Tpl.Text in_txt;
910 input SimCode.SimCode in_a_simCode;
911 input Tpl.Text in_a_extraFuncsDecl;
912
913 output Tpl.Text out_txt;
914 output Tpl.Text out_a_extraFuncsDecl;
915 algorithm
916 (out_txt, out_a_extraFuncsDecl) :=
917 match(in_txt, in_a_simCode, in_a_extraFuncsDecl)
918 local
919 Tpl.Text txt;
920 Tpl.Text a_extraFuncsDecl;
921 Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> i_hpcomData_schedules;
922 Boolean ret_5;
923 Boolean ret_4;
924 String ret_3;
925 String str_2;
926 String ret_1;
927 Tpl.Text l_type;
928
929 case ( txt,
930 SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(name = _), hpcomData = HpcOmSimCode.HPCOMDATA(schedules = i_hpcomData_schedules)),
931 a_extraFuncsDecl )
932 algorithm
933 1 a_extraFuncsDecl := generateAdditionalFunctionHeaders(a_extraFuncsDecl, i_hpcomData_schedules);
934 1 a_extraFuncsDecl := generateAdditionalHpcomVarHeaders(a_extraFuncsDecl, i_hpcomData_schedules);
935 1 ret_1 := Flags.getConfigString(Flags.HPCOM_CODE);
936 1 l_type := Tpl.writeStr(Tpl.emptyTxt, ret_1);
937 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
938 "static long unsigned int getThreadNumber()\n",
939 "{\n"
940 }, true));
941 1 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
942 1 str_2 := Tpl.textString(l_type);
943 1 txt := fun_64(txt, str_2);
944 1 txt := Tpl.softNewLine(txt);
945 1 txt := Tpl.popBlock(txt);
946 1 txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
947 1 ret_3 := Flags.getConfigString(Flags.PROFILING_LEVEL);
948
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 ret_4 := stringEq(ret_3, "none");
949 1 ret_5 := boolNot(ret_4);
950 1 txt := fun_67(txt, ret_5);
951 then (txt, a_extraFuncsDecl);
952
953 case ( txt,
954 _,
955 a_extraFuncsDecl )
956 then (txt, a_extraFuncsDecl);
957 end match;
958 end fun_68;
959
960 public function additionalHpcomProtectedMemberDeclaration
961 input Tpl.Text txt;
962 input SimCode.SimCode a_simCode;
963 input Tpl.Text a_extraFuncs;
964 input Tpl.Text a_extraFuncsDecl;
965 input Tpl.Text a_extraFuncsNamespace;
966 input Boolean a_useFlatArrayNotation;
967
968 output Tpl.Text out_txt;
969 output Tpl.Text out_a_extraFuncs;
970 output Tpl.Text out_a_extraFuncsDecl;
971 output Tpl.Text out_a_extraFuncsNamespace;
972 algorithm
973 1 (out_txt, out_a_extraFuncsDecl) := fun_68(txt, a_simCode, a_extraFuncsDecl);
974 out_a_extraFuncs := a_extraFuncs;
975 out_a_extraFuncsNamespace := a_extraFuncsNamespace;
976 end additionalHpcomProtectedMemberDeclaration;
977
978 protected function fun_70
979 input Tpl.Text in_txt;
980 input String in_mArg;
981
982 output Tpl.Text out_txt;
983 algorithm
984 out_txt :=
985 match(in_txt, in_mArg)
986 local
987 Tpl.Text txt;
988
989 case ( txt,
990 "openmp" )
991 then txt;
992
993 case ( txt,
994 "tbb" )
995 algorithm
996 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
997 "//Required for Intel TBB\n",
998 "struct VoidFunctionBody {\n",
999 " function<void(void)> void_function;\n",
1000 " VoidFunctionBody(function<void(void)> void_function) : void_function(void_function) { }\n",
1001 " FORCE_INLINE void operator()( tbb::flow::continue_msg ) const\n",
1002 " {\n",
1003 " void_function();\n",
1004 " }\n",
1005 "};\n",
1006 "#if TBB_INTERFACE_VERSION >= 8000\n",
1007 "struct TbbArenaFunctor\n",
1008 "{\n",
1009 " tbb::flow::graph * g;\n",
1010 " tbb::flow::broadcast_node<tbb::flow::continue_msg> * sn;\n",
1011 "\n",
1012 " TbbArenaFunctor( )\n",
1013 " {\n",
1014 " g = NULL;\n",
1015 " sn = NULL;\n",
1016 " }\n",
1017 "\n",
1018 " TbbArenaFunctor( tbb::flow::graph & in_g , tbb::flow::broadcast_node<tbb::flow::continue_msg> & in_sn )\n",
1019 " {\n",
1020 " g = &in_g;\n",
1021 " sn = &in_sn;\n",
1022 " }\n",
1023 "\n",
1024 " void operator()()\n",
1025 " {\n",
1026 " sn->try_put( tbb::flow::continue_msg() );\n",
1027 " g->wait_for_all();\n",
1028 " }\n",
1029 "\n",
1030 "};\n",
1031 "#endif"
1032 }, false));
1033 then txt;
1034
1035 case ( txt,
1036 _ )
1037 then txt;
1038 end match;
1039 end fun_70;
1040
1041 protected function fun_71
1042 input Tpl.Text in_txt;
1043 input HpcOmSimCode.Schedule in_a_odeSchedule;
1044 input Tpl.Text in_a_type;
1045
1046 output Tpl.Text out_txt;
1047 algorithm
1048 out_txt :=
1049 match(in_txt, in_a_odeSchedule, in_a_type)
1050 local
1051 Tpl.Text txt;
1052 Tpl.Text a_type;
1053 String str_0;
1054
1055 case ( txt,
1056 HpcOmSimCode.TASKDEPSCHEDULE(tasks = _),
1057 a_type )
1058 algorithm
1059 ✗ str_0 := Tpl.textString(a_type);
1060 ✗ txt := fun_70(txt, str_0);
1061 then txt;
1062
1063 case ( txt,
1064 _,
1065 _ )
1066 then txt;
1067 end match;
1068 end fun_71;
1069
1070 public function generateAdditionalStructHeaders
1071 input Tpl.Text txt;
1072 input HpcOmSimCode.Schedule a_odeSchedule;
1073
1074 output Tpl.Text out_txt;
1075 protected
1076 String ret_1;
1077 Tpl.Text l_type;
1078 algorithm
1079 ✗ ret_1 := Flags.getConfigString(Flags.HPCOM_CODE);
1080 ✗ l_type := Tpl.writeStr(Tpl.emptyTxt, ret_1);
1081 ✗ out_txt := fun_71(txt, a_odeSchedule, l_type);
1082 end generateAdditionalStructHeaders;
1083
1084 protected function lm_73
1085 input output Tpl.Text txt;
1086 input list<list<HpcOmSimCode.Task>> items;
1087 algorithm
1088 ✗ for lstElt_73 in items loop
1089 txt := match lstElt_73
1090 local
1091 Integer x_i0;
1092
1093 case _
1094 algorithm
1095 ✗ x_i0 := Tpl.getIteri_i0(txt);
1096 ✗ txt := generateThreadFunctionHeaderDecl(txt, x_i0);
1097 ✗ txt := Tpl.nextIter(txt);
1098 then txt;
1099 end match;
1100 end for;
1101 end lm_73;
1102
1103 protected function fun_74
1104 input Tpl.Text in_txt;
1105 input String in_mArg;
1106 input array<list<HpcOmSimCode.Task>> in_a_odeSchedule_threadTasks;
1107
1108 output Tpl.Text out_txt;
1109 algorithm
1110 out_txt :=
1111 match(in_txt, in_mArg, in_a_odeSchedule_threadTasks)
1112 local
1113 Tpl.Text txt;
1114 array<list<HpcOmSimCode.Task>> a_odeSchedule_threadTasks;
1115 list<list<HpcOmSimCode.Task>> ret_2;
1116 list<list<HpcOmSimCode.Task>> ret_1;
1117 Tpl.Text l_headers;
1118
1119 case ( txt,
1120 "openmp",
1121 _ )
1122 then txt;
1123
1124 case ( txt,
1125 _,
1126 a_odeSchedule_threadTasks )
1127 algorithm
1128 ✗ ret_1 := arrayList(a_odeSchedule_threadTasks);
1129 ✗ ret_2 := listRest(ret_1);
1130 ✗ l_headers := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1131 ✗ l_headers := lm_73(l_headers, ret_2);
1132 ✗ l_headers := Tpl.popIter(l_headers);
1133 ✗ txt := Tpl.writeText(txt, l_headers);
1134 then txt;
1135 end match;
1136 end fun_74;
1137
1138 protected function fun_75
1139 input Tpl.Text in_txt;
1140 input tuple<HpcOmSimCode.Task, list<Integer>> in_a_task;
1141
1142 output Tpl.Text out_txt;
1143 algorithm
1144 out_txt :=
1145 match(in_txt, in_a_task)
1146 local
1147 Tpl.Text txt;
1148 Integer i_task_index;
1149
1150 case ( txt,
1151 (HpcOmSimCode.CALCTASK(index = i_task_index), _) )
1152 algorithm
1153 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("void taskFuncOde_"));
1154 ✗ txt := Tpl.writeStr(txt, intString(i_task_index));
1155 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("();"));
1156 then txt;
1157
1158 case ( txt,
1159 _ )
1160 then txt;
1161 end match;
1162 end fun_75;
1163
1164 protected function lm_76
1165 input output Tpl.Text txt;
1166 input list<tuple<HpcOmSimCode.Task, list<Integer>>> items;
1167 algorithm
1168 ✗ for lstElt_76 in items loop
1169 txt := match lstElt_76
1170 local
1171 tuple<HpcOmSimCode.Task, list<Integer>> i_task;
1172
1173 case i_task
1174 algorithm
1175 ✗ txt := fun_75(txt, i_task);
1176 ✗ txt := Tpl.nextIter(txt);
1177 then txt;
1178 end match;
1179 end for;
1180 end lm_76;
1181
1182 protected function fun_77
1183 input Tpl.Text in_txt;
1184 input tuple<HpcOmSimCode.Task, list<Integer>> in_a_task;
1185
1186 output Tpl.Text out_txt;
1187 algorithm
1188 out_txt :=
1189 match(in_txt, in_a_task)
1190 local
1191 Tpl.Text txt;
1192 Integer i_task_index;
1193
1194 case ( txt,
1195 (HpcOmSimCode.CALCTASK(index = i_task_index), _) )
1196 algorithm
1197 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("void taskFuncAll_"));
1198 ✗ txt := Tpl.writeStr(txt, intString(i_task_index));
1199 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("();"));
1200 then txt;
1201
1202 case ( txt,
1203 _ )
1204 then txt;
1205 end match;
1206 end fun_77;
1207
1208 protected function lm_78
1209 input output Tpl.Text txt;
1210 input list<tuple<HpcOmSimCode.Task, list<Integer>>> items;
1211 algorithm
1212 ✗ for lstElt_78 in items loop
1213 txt := match lstElt_78
1214 local
1215 tuple<HpcOmSimCode.Task, list<Integer>> i_task;
1216
1217 case i_task
1218 algorithm
1219 ✗ txt := fun_77(txt, i_task);
1220 ✗ txt := Tpl.nextIter(txt);
1221 then txt;
1222 end match;
1223 end for;
1224 end lm_78;
1225
1226 protected function fun_79
1227 input Tpl.Text in_txt;
1228 input tuple<HpcOmSimCode.Task, list<Integer>> in_a_task;
1229
1230 output Tpl.Text out_txt;
1231 algorithm
1232 out_txt :=
1233 match(in_txt, in_a_task)
1234 local
1235 Tpl.Text txt;
1236 Integer i_task_index;
1237
1238 case ( txt,
1239 (HpcOmSimCode.CALCTASK(index = i_task_index), _) )
1240 algorithm
1241 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("void taskFuncZeroFunc_"));
1242 ✗ txt := Tpl.writeStr(txt, intString(i_task_index));
1243 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("();"));
1244 then txt;
1245
1246 case ( txt,
1247 _ )
1248 then txt;
1249 end match;
1250 end fun_79;
1251
1252 protected function lm_80
1253 input output Tpl.Text txt;
1254 input list<tuple<HpcOmSimCode.Task, list<Integer>>> items;
1255 algorithm
1256 ✗ for lstElt_80 in items loop
1257 txt := match lstElt_80
1258 local
1259 tuple<HpcOmSimCode.Task, list<Integer>> i_task;
1260
1261 case i_task
1262 algorithm
1263 ✗ txt := fun_79(txt, i_task);
1264 ✗ txt := Tpl.nextIter(txt);
1265 then txt;
1266 end match;
1267 end for;
1268 end lm_80;
1269
1270 protected function fun_81
1271 input Tpl.Text in_txt;
1272 input String in_mArg;
1273 input HpcOmSimCode.Schedule in_a_odeSchedule;
1274 input list<tuple<HpcOmSimCode.Task, list<Integer>>> in_a_zeroFuncSchedule_tasks;
1275 input list<tuple<HpcOmSimCode.Task, list<Integer>>> in_a_daeSchedule_tasks;
1276 input list<tuple<HpcOmSimCode.Task, list<Integer>>> in_a_odeSchedule_tasks;
1277
1278 output Tpl.Text out_txt;
1279 algorithm
1280 out_txt :=
1281 match(in_txt, in_mArg, in_a_odeSchedule, in_a_zeroFuncSchedule_tasks, in_a_daeSchedule_tasks, in_a_odeSchedule_tasks)
1282 local
1283 Tpl.Text txt;
1284 HpcOmSimCode.Schedule a_odeSchedule;
1285 list<tuple<HpcOmSimCode.Task, list<Integer>>> a_zeroFuncSchedule_tasks;
1286 list<tuple<HpcOmSimCode.Task, list<Integer>>> a_daeSchedule_tasks;
1287 list<tuple<HpcOmSimCode.Task, list<Integer>>> a_odeSchedule_tasks;
1288 Tpl.Text l_voidfuncsZeroFunc;
1289 Tpl.Text l_voidfuncsDae;
1290 Tpl.Text l_voidfuncsOde;
1291
1292 case ( txt,
1293 "openmp",
1294 _,
1295 _,
1296 _,
1297 _ )
1298 then txt;
1299
1300 case ( txt,
1301 "tbb",
1302 a_odeSchedule,
1303 a_zeroFuncSchedule_tasks,
1304 a_daeSchedule_tasks,
1305 a_odeSchedule_tasks )
1306 algorithm
1307 ✗ l_voidfuncsOde := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1308 ✗ l_voidfuncsOde := lm_76(l_voidfuncsOde, a_odeSchedule_tasks);
1309 ✗ l_voidfuncsOde := Tpl.popIter(l_voidfuncsOde);
1310 ✗ l_voidfuncsDae := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1311 ✗ l_voidfuncsDae := lm_78(l_voidfuncsDae, a_daeSchedule_tasks);
1312 ✗ l_voidfuncsDae := Tpl.popIter(l_voidfuncsDae);
1313 ✗ l_voidfuncsZeroFunc := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1314 ✗ l_voidfuncsZeroFunc := lm_80(l_voidfuncsZeroFunc, a_zeroFuncSchedule_tasks);
1315 ✗ l_voidfuncsZeroFunc := Tpl.popIter(l_voidfuncsZeroFunc);
1316 ✗ txt := generateAdditionalStructHeaders(txt, a_odeSchedule);
1317 ✗ txt := Tpl.softNewLine(txt);
1318 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
1319 ✗ txt := Tpl.writeText(txt, l_voidfuncsOde);
1320 ✗ txt := Tpl.softNewLine(txt);
1321 ✗ txt := Tpl.writeText(txt, l_voidfuncsDae);
1322 ✗ txt := Tpl.softNewLine(txt);
1323 ✗ txt := Tpl.writeText(txt, l_voidfuncsZeroFunc);
1324 then txt;
1325
1326 case ( txt,
1327 _,
1328 _,
1329 _,
1330 _,
1331 _ )
1332 then txt;
1333 end match;
1334 end fun_81;
1335
1336 protected function fun_82
1337 input Tpl.Text in_txt;
1338 input Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> in_a_schedulesOpt;
1339 input Tpl.Text in_a_type;
1340
1341 output Tpl.Text out_txt;
1342 algorithm
1343 out_txt :=
1344 match(in_txt, in_a_schedulesOpt, in_a_type)
1345 local
1346 Tpl.Text txt;
1347 Tpl.Text a_type;
1348 HpcOmSimCode.Schedule i_odeSchedule;
1349 list<tuple<HpcOmSimCode.Task, list<Integer>>> i_zeroFuncSchedule_tasks;
1350 list<tuple<HpcOmSimCode.Task, list<Integer>>> i_daeSchedule_tasks;
1351 list<tuple<HpcOmSimCode.Task, list<Integer>>> i_odeSchedule_tasks;
1352 array<list<HpcOmSimCode.Task>> i_odeSchedule_threadTasks;
1353 String str_1;
1354 String str_0;
1355
1356 case ( txt,
1357 SOME((HpcOmSimCode.THREADSCHEDULE(threadTasks = i_odeSchedule_threadTasks), _, _)),
1358 a_type )
1359 algorithm
1360 ✗ str_0 := Tpl.textString(a_type);
1361 ✗ txt := fun_74(txt, str_0, i_odeSchedule_threadTasks);
1362 then txt;
1363
1364 case ( txt,
1365 SOME(((i_odeSchedule as HpcOmSimCode.TASKDEPSCHEDULE(tasks = i_odeSchedule_tasks)), HpcOmSimCode.TASKDEPSCHEDULE(tasks = i_daeSchedule_tasks), HpcOmSimCode.TASKDEPSCHEDULE(tasks = i_zeroFuncSchedule_tasks))),
1366 a_type )
1367 algorithm
1368 ✗ str_1 := Tpl.textString(a_type);
1369 ✗ txt := fun_81(txt, str_1, i_odeSchedule, i_zeroFuncSchedule_tasks, i_daeSchedule_tasks, i_odeSchedule_tasks);
1370 then txt;
1371
1372 case ( txt,
1373 _,
1374 _ )
1375 then txt;
1376 end match;
1377 end fun_82;
1378
1379 public function generateAdditionalFunctionHeaders
1380 input Tpl.Text txt;
1381 input Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> a_schedulesOpt;
1382
1383 output Tpl.Text out_txt;
1384 protected
1385 String ret_1;
1386 Tpl.Text l_type;
1387 algorithm
1388 1 ret_1 := Flags.getConfigString(Flags.HPCOM_CODE);
1389 1 l_type := Tpl.writeStr(Tpl.emptyTxt, ret_1);
1390 1 out_txt := Tpl.writeTok(txt, Tpl.ST_LINE("FORCE_INLINE void evaluateParallel(const UPDATETYPE command, int evaluateMode);\n"));
1391 1 out_txt := fun_82(out_txt, a_schedulesOpt, l_type);
1392 end generateAdditionalFunctionHeaders;
1393
1394 protected function lm_84
1395 input output Tpl.Text txt;
1396 input list<Integer> items;
1397 input Tpl.Text a_type;
1398 algorithm
1399
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 for lstElt_84 in items loop
1400 txt := match lstElt_84
1401 local
1402 Integer x_i0;
1403
1404 case _
1405 algorithm
1406 1 x_i0 := Tpl.getIteri_i0(txt);
1407 1 txt := generateThreadHeaderDecl(txt, x_i0, Tpl.textString(a_type));
1408 1 txt := Tpl.nextIter(txt);
1409 then txt;
1410 end match;
1411 end for;
1412 end lm_84;
1413
1414 protected function lm_85
1415 input output Tpl.Text txt;
1416 input list<Integer> items;
1417 input Tpl.Text a_type;
1418 algorithm
1419 ✗ for lstElt_85 in items loop
1420 txt := match lstElt_85
1421 local
1422 Integer x_i0;
1423
1424 case _
1425 algorithm
1426 ✗ x_i0 := Tpl.getIteri_i0(txt);
1427 ✗ txt := generateThreadHeaderDecl(txt, x_i0, Tpl.textString(a_type));
1428 ✗ txt := Tpl.nextIter(txt);
1429 then txt;
1430 end match;
1431 end for;
1432 end lm_85;
1433
1434 protected function fun_86
1435 input Tpl.Text in_txt;
1436 input String in_mArg;
1437 input Tpl.Text in_a_type;
1438
1439 output Tpl.Text out_txt;
1440 algorithm
1441 out_txt :=
1442 match(in_txt, in_mArg, in_a_type)
1443 local
1444 Tpl.Text txt;
1445 Tpl.Text a_type;
1446 Integer ret_5;
1447 list<Integer> ret_4;
1448 Integer ret_3;
1449 Integer ret_2;
1450 list<Integer> ret_1;
1451 Integer ret_0;
1452
1453 case ( txt,
1454 "pthreads",
1455 a_type )
1456 algorithm
1457 1 ret_0 := Flags.getConfigInt(Flags.NUM_PROC);
1458 1 ret_1 := List.intRange(ret_0);
1459 1 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), NONE(), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1460 1 txt := lm_84(txt, ret_1, a_type);
1461 1 txt := Tpl.popIter(txt);
1462 1 txt := Tpl.softNewLine(txt);
1463 1 ret_2 := Flags.getConfigInt(Flags.NUM_PROC);
1464 1 txt := createBarrierByName(txt, "levelBarrier", "", ret_2, Tpl.textString(a_type));
1465 1 txt := Tpl.softNewLine(txt);
1466 1 txt := createLockByLockName(txt, "measureTimeArrayLock", "", Tpl.textString(a_type));
1467 1 txt := Tpl.softNewLine(txt);
1468 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("bool _simulationFinished;"));
1469 then txt;
1470
1471 case ( txt,
1472 "pthreads_spin",
1473 a_type )
1474 algorithm
1475 ✗ ret_3 := Flags.getConfigInt(Flags.NUM_PROC);
1476 ✗ ret_4 := List.intRange(ret_3);
1477 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), NONE(), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1478 ✗ txt := lm_85(txt, ret_4, a_type);
1479 ✗ txt := Tpl.popIter(txt);
1480 ✗ txt := Tpl.softNewLine(txt);
1481 ✗ ret_5 := Flags.getConfigInt(Flags.NUM_PROC);
1482 ✗ txt := createBarrierByName(txt, "levelBarrier", "", ret_5, Tpl.textString(a_type));
1483 ✗ txt := Tpl.softNewLine(txt);
1484 ✗ txt := createLockByLockName(txt, "measureTimeArrayLock", "", Tpl.textString(a_type));
1485 ✗ txt := Tpl.softNewLine(txt);
1486 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("bool _simulationFinished;"));
1487 then txt;
1488
1489 case ( txt,
1490 _,
1491 _ )
1492 then txt;
1493 end match;
1494 end fun_86;
1495
1496 protected function lm_87
1497 input output Tpl.Text txt;
1498 input list<list<HpcOmSimCode.Task>> items;
1499 input Tpl.Text a_type;
1500 algorithm
1501 ✗ for lstElt_87 in items loop
1502 txt := match lstElt_87
1503 local
1504 Integer x_i0;
1505
1506 case _
1507 algorithm
1508 ✗ x_i0 := Tpl.getIteri_i0(txt);
1509 ✗ txt := generateThreadHeaderDecl(txt, x_i0, Tpl.textString(a_type));
1510 ✗ txt := Tpl.nextIter(txt);
1511 then txt;
1512 end match;
1513 end for;
1514 end lm_87;
1515
1516 protected function lm_88
1517 input output Tpl.Text txt;
1518 input list<list<HpcOmSimCode.Task>> items;
1519 input Tpl.Text a_type;
1520 algorithm
1521 ✗ for lstElt_88 in items loop
1522 txt := match lstElt_88
1523 local
1524 Integer x_i0;
1525
1526 case _
1527 algorithm
1528 ✗ x_i0 := Tpl.getIteri_i0(txt);
1529 ✗ txt := generateThreadHeaderDecl(txt, x_i0, Tpl.textString(a_type));
1530 ✗ txt := Tpl.nextIter(txt);
1531 then txt;
1532 end match;
1533 end for;
1534 end lm_88;
1535
1536 protected function lm_89
1537 input output Tpl.Text txt;
1538 input list<list<HpcOmSimCode.Task>> items;
1539 input Tpl.Text a_type;
1540 algorithm
1541 ✗ for lstElt_89 in items loop
1542 txt := match lstElt_89
1543 local
1544 Integer x_i0;
1545
1546 case _
1547 algorithm
1548 ✗ x_i0 := Tpl.getIteri_i0(txt);
1549 ✗ txt := createLockByLockName(txt, intString(x_i0), "th_lock", Tpl.textString(a_type));
1550 ✗ txt := Tpl.nextIter(txt);
1551 then txt;
1552 end match;
1553 end for;
1554 end lm_89;
1555
1556 protected function lm_90
1557 input output Tpl.Text txt;
1558 input list<list<HpcOmSimCode.Task>> items;
1559 input Tpl.Text a_type;
1560 algorithm
1561 ✗ for lstElt_90 in items loop
1562 txt := match lstElt_90
1563 local
1564 Integer x_i0;
1565
1566 case _
1567 algorithm
1568 ✗ x_i0 := Tpl.getIteri_i0(txt);
1569 ✗ txt := createLockByLockName(txt, intString(x_i0), "th_lock1", Tpl.textString(a_type));
1570 ✗ txt := Tpl.nextIter(txt);
1571 then txt;
1572 end match;
1573 end for;
1574 end lm_90;
1575
1576 protected function fun_91
1577 input Tpl.Text in_txt;
1578 input String in_mArg;
1579 input Tpl.Text in_a_zeroFuncLocks;
1580 input Tpl.Text in_a_daeLocks;
1581 input Tpl.Text in_a_odeLocks;
1582 input Tpl.Text in_a_type;
1583 input array<list<HpcOmSimCode.Task>> in_a_odeSchedule_threadTasks;
1584
1585 output Tpl.Text out_txt;
1586 algorithm
1587 out_txt :=
1588 match(in_txt, in_mArg, in_a_zeroFuncLocks, in_a_daeLocks, in_a_odeLocks, in_a_type, in_a_odeSchedule_threadTasks)
1589 local
1590 Tpl.Text txt;
1591 Tpl.Text a_zeroFuncLocks;
1592 Tpl.Text a_daeLocks;
1593 Tpl.Text a_odeLocks;
1594 Tpl.Text a_type;
1595 array<list<HpcOmSimCode.Task>> a_odeSchedule_threadTasks;
1596 list<list<HpcOmSimCode.Task>> ret_9;
1597 list<list<HpcOmSimCode.Task>> ret_8;
1598 Tpl.Text l_thLocks1;
1599 list<list<HpcOmSimCode.Task>> ret_6;
1600 list<list<HpcOmSimCode.Task>> ret_5;
1601 Tpl.Text l_thLocks;
1602 list<list<HpcOmSimCode.Task>> ret_3;
1603 list<list<HpcOmSimCode.Task>> ret_2;
1604 list<list<HpcOmSimCode.Task>> ret_1;
1605 Tpl.Text l_threadDecl;
1606
1607 case ( txt,
1608 "openmp",
1609 a_zeroFuncLocks,
1610 a_daeLocks,
1611 a_odeLocks,
1612 a_type,
1613 a_odeSchedule_threadTasks )
1614 algorithm
1615 ✗ ret_1 := arrayList(a_odeSchedule_threadTasks);
1616 ✗ l_threadDecl := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1617 ✗ l_threadDecl := lm_87(l_threadDecl, ret_1, a_type);
1618 ✗ l_threadDecl := Tpl.popIter(l_threadDecl);
1619 ✗ txt := Tpl.writeText(txt, a_odeLocks);
1620 ✗ txt := Tpl.softNewLine(txt);
1621 ✗ txt := Tpl.writeText(txt, a_daeLocks);
1622 ✗ txt := Tpl.softNewLine(txt);
1623 ✗ txt := Tpl.writeText(txt, a_zeroFuncLocks);
1624 ✗ txt := Tpl.softNewLine(txt);
1625 ✗ txt := Tpl.writeText(txt, l_threadDecl);
1626 then txt;
1627
1628 case ( txt,
1629 "mpi",
1630 _,
1631 _,
1632 _,
1633 _,
1634 _ )
1635 algorithm
1636 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("//MF Todo BLABLUB"));
1637 then txt;
1638
1639 case ( txt,
1640 _,
1641 a_zeroFuncLocks,
1642 a_daeLocks,
1643 a_odeLocks,
1644 a_type,
1645 a_odeSchedule_threadTasks )
1646 algorithm
1647 ✗ ret_2 := arrayList(a_odeSchedule_threadTasks);
1648 ✗ ret_3 := listRest(ret_2);
1649 ✗ l_threadDecl := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1650 ✗ l_threadDecl := lm_88(l_threadDecl, ret_3, a_type);
1651 ✗ l_threadDecl := Tpl.popIter(l_threadDecl);
1652 ✗ ret_5 := arrayList(a_odeSchedule_threadTasks);
1653 ✗ ret_6 := listRest(ret_5);
1654 ✗ l_thLocks := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1655 ✗ l_thLocks := lm_89(l_thLocks, ret_6, a_type);
1656 ✗ l_thLocks := Tpl.popIter(l_thLocks);
1657 ✗ ret_8 := arrayList(a_odeSchedule_threadTasks);
1658 ✗ ret_9 := listRest(ret_8);
1659 ✗ l_thLocks1 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1660 ✗ l_thLocks1 := lm_90(l_thLocks1, ret_9, a_type);
1661 ✗ l_thLocks1 := Tpl.popIter(l_thLocks1);
1662 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("bool _terminateThreads;\n"));
1663 ✗ txt := Tpl.writeText(txt, a_odeLocks);
1664 ✗ txt := Tpl.softNewLine(txt);
1665 ✗ txt := Tpl.writeText(txt, a_daeLocks);
1666 ✗ txt := Tpl.softNewLine(txt);
1667 ✗ txt := Tpl.writeText(txt, a_zeroFuncLocks);
1668 ✗ txt := Tpl.softNewLine(txt);
1669 ✗ txt := Tpl.writeText(txt, l_thLocks);
1670 ✗ txt := Tpl.softNewLine(txt);
1671 ✗ txt := Tpl.writeText(txt, l_thLocks1);
1672 ✗ txt := Tpl.softNewLine(txt);
1673 ✗ txt := Tpl.writeText(txt, l_threadDecl);
1674 then txt;
1675 end match;
1676 end fun_91;
1677
1678 protected function fun_92
1679 input Tpl.Text in_txt;
1680 input String in_mArg;
1681
1682 output Tpl.Text out_txt;
1683 algorithm
1684 out_txt :=
1685 match(in_txt, in_mArg)
1686 local
1687 Tpl.Text txt;
1688
1689 case ( txt,
1690 "openmp" )
1691 algorithm
1692 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
1693 then txt;
1694
1695 case ( txt,
1696 "tbb" )
1697 algorithm
1698 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1699 "tbb::flow::graph _tbbGraphOde;\n",
1700 "tbb::flow::broadcast_node<tbb::flow::continue_msg> _tbbStartNodeOde;\n",
1701 "tbb::flow::graph _tbbGraphAll;\n",
1702 "tbb::flow::broadcast_node<tbb::flow::continue_msg> _tbbStartNodeAll;\n",
1703 "tbb::flow::graph _tbbGraphZeroFunc;\n",
1704 "tbb::flow::broadcast_node<tbb::flow::continue_msg> _tbbStartNodeZeroFunc;\n",
1705 "std::vector<tbb::flow::continue_node<tbb::flow::continue_msg>* > _tbbNodeListOde;\n",
1706 "std::vector<tbb::flow::continue_node<tbb::flow::continue_msg>* > _tbbNodeListAll;\n",
1707 "std::vector<tbb::flow::continue_node<tbb::flow::continue_msg>* > _tbbNodeListZeroFunc;\n",
1708 "#if TBB_INTERFACE_VERSION >= 8000\n",
1709 "tbb::task_arena _tbbArena;\n",
1710 "TbbArenaFunctor _tbbArenaFunctorOde;\n",
1711 "TbbArenaFunctor _tbbArenaFunctorAll;\n",
1712 "TbbArenaFunctor _tbbArenaFunctorZeroFunc;\n",
1713 "#endif"
1714 }, false));
1715 then txt;
1716
1717 case ( txt,
1718 _ )
1719 then txt;
1720 end match;
1721 end fun_92;
1722
1723 protected function fun_93
1724 input Tpl.Text in_txt;
1725 input Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> in_a_schedulesOpt;
1726 input Tpl.Text in_a_type;
1727
1728 output Tpl.Text out_txt;
1729 algorithm
1730 out_txt :=
1731 match(in_txt, in_a_schedulesOpt, in_a_type)
1732 local
1733 Tpl.Text txt;
1734 Tpl.Text a_type;
1735 array<list<HpcOmSimCode.Task>> i_odeSchedule_threadTasks;
1736 list<HpcOmSimCode.Task> i_zeroFuncSchedule_outgoingDepTasks;
1737 list<HpcOmSimCode.Task> i_daeSchedule_outgoingDepTasks;
1738 list<HpcOmSimCode.Task> i_odeSchedule_outgoingDepTasks;
1739 String str_8;
1740 String str_7;
1741 Integer ret_6;
1742 Tpl.Text l_zeroFuncLocks;
1743 Integer ret_4;
1744 Tpl.Text l_daeLocks;
1745 Integer ret_2;
1746 Tpl.Text l_odeLocks;
1747 String str_0;
1748
1749 case ( txt,
1750 SOME((HpcOmSimCode.LEVELSCHEDULE(useFixedAssignments = true), _, _)),
1751 a_type )
1752 algorithm
1753 1 str_0 := Tpl.textString(a_type);
1754 1 txt := fun_86(txt, str_0, a_type);
1755 then txt;
1756
1757 case ( txt,
1758 SOME((HpcOmSimCode.THREADSCHEDULE(outgoingDepTasks = i_odeSchedule_outgoingDepTasks, threadTasks = i_odeSchedule_threadTasks), HpcOmSimCode.THREADSCHEDULE(outgoingDepTasks = i_daeSchedule_outgoingDepTasks), HpcOmSimCode.THREADSCHEDULE(outgoingDepTasks = i_zeroFuncSchedule_outgoingDepTasks))),
1759 a_type )
1760 algorithm
1761 ✗ ret_2 := listLength(i_odeSchedule_outgoingDepTasks);
1762 ✗ l_odeLocks := createLockArrayByName(Tpl.emptyTxt, ret_2, "_lockOde", Tpl.textString(a_type));
1763 ✗ ret_4 := listLength(i_daeSchedule_outgoingDepTasks);
1764 ✗ l_daeLocks := createLockArrayByName(Tpl.emptyTxt, ret_4, "_lockDae", Tpl.textString(a_type));
1765 ✗ ret_6 := listLength(i_zeroFuncSchedule_outgoingDepTasks);
1766 ✗ l_zeroFuncLocks := createLockArrayByName(Tpl.emptyTxt, ret_6, "_lockZeroFunc", Tpl.textString(a_type));
1767 ✗ str_7 := Tpl.textString(a_type);
1768 ✗ txt := fun_91(txt, str_7, l_zeroFuncLocks, l_daeLocks, l_odeLocks, a_type, i_odeSchedule_threadTasks);
1769 then txt;
1770
1771 case ( txt,
1772 SOME((HpcOmSimCode.TASKDEPSCHEDULE(tasks = _), _, _)),
1773 a_type )
1774 algorithm
1775 ✗ str_8 := Tpl.textString(a_type);
1776 ✗ txt := fun_92(txt, str_8);
1777 then txt;
1778
1779 case ( txt,
1780 _,
1781 _ )
1782 then txt;
1783 end match;
1784 end fun_93;
1785
1786 public function generateAdditionalHpcomVarHeaders
1787 input Tpl.Text txt;
1788 input Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> a_schedulesOpt;
1789
1790 output Tpl.Text out_txt;
1791 protected
1792 String ret_1;
1793 Tpl.Text l_type;
1794 algorithm
1795 1 ret_1 := Flags.getConfigString(Flags.HPCOM_CODE);
1796 1 l_type := Tpl.writeStr(Tpl.emptyTxt, ret_1);
1797 1 out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1798 "UPDATETYPE _command;\n",
1799 "int _evaluateMode;\n"
1800 }, true));
1801 1 out_txt := fun_93(out_txt, a_schedulesOpt, l_type);
1802 end generateAdditionalHpcomVarHeaders;
1803
1804 protected function fun_95
1805 input Tpl.Text in_txt;
1806 input String in_a_iType;
1807 input Integer in_a_threadIdx;
1808
1809 output Tpl.Text out_txt;
1810 algorithm
1811 out_txt :=
1812 match(in_txt, in_a_iType, in_a_threadIdx)
1813 local
1814 Tpl.Text txt;
1815 Integer a_threadIdx;
1816
1817 case ( txt,
1818 "openmp",
1819 _ )
1820 then txt;
1821
1822 case ( txt,
1823 _,
1824 a_threadIdx )
1825 algorithm
1826 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("thread* evaluateThread"));
1827 1 txt := Tpl.writeStr(txt, intString(a_threadIdx));
1828 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
1829 then txt;
1830 end match;
1831 end fun_95;
1832
1833 public function generateThreadHeaderDecl
1834 input Tpl.Text txt;
1835 input Integer a_threadIdx;
1836 input String a_iType;
1837
1838 output Tpl.Text out_txt;
1839 algorithm
1840 1 out_txt := fun_95(txt, a_iType, a_threadIdx);
1841 end generateThreadHeaderDecl;
1842
1843 public function generateThreadFunctionHeaderDecl
1844 input Tpl.Text txt;
1845 input Integer a_threadIdx;
1846
1847 output Tpl.Text out_txt;
1848 algorithm
1849 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("void evaluateThreadFunc"));
1850 ✗ out_txt := Tpl.writeStr(out_txt, intString(a_threadIdx));
1851 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("();"));
1852 end generateThreadFunctionHeaderDecl;
1853
1854 protected function fun_98
1855 input Tpl.Text in_txt;
1856 input String in_mArg;
1857 input Tpl.Text in_a_type;
1858
1859 output Tpl.Text out_txt;
1860 algorithm
1861 out_txt :=
1862 match(in_txt, in_mArg, in_a_type)
1863 local
1864 Tpl.Text txt;
1865 Tpl.Text a_type;
1866 Integer ret_1;
1867 Integer ret_0;
1868
1869 case ( txt,
1870 "pthreads",
1871 a_type )
1872 algorithm
1873 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1874 ",_command(IContinuous::UNDEF_UPDATE)\n",
1875 ",_simulationFinished(false)\n",
1876 ","
1877 }, false));
1878 1 ret_0 := Flags.getConfigInt(Flags.NUM_PROC);
1879 1 txt := initializeBarrierByName(txt, "levelBarrier", "", ret_0, Tpl.textString(a_type));
1880 then txt;
1881
1882 case ( txt,
1883 "pthreads_spin",
1884 a_type )
1885 algorithm
1886 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1887 ",_command(IContinuous::UNDEF_UPDATE)\n",
1888 ",_simulationFinished(false)\n",
1889 ","
1890 }, false));
1891 ✗ ret_1 := Flags.getConfigInt(Flags.NUM_PROC);
1892 ✗ txt := initializeBarrierByName(txt, "levelBarrier", "", ret_1, Tpl.textString(a_type));
1893 then txt;
1894
1895 case ( txt,
1896 _,
1897 _ )
1898 then txt;
1899 end match;
1900 end fun_98;
1901
1902 protected function fun_99
1903 input Tpl.Text in_txt;
1904 input String in_mArg;
1905 input list<tuple<HpcOmSimCode.Task, list<Integer>>> in_a_zeroFuncSchedule_tasks;
1906 input list<tuple<HpcOmSimCode.Task, list<Integer>>> in_a_daeSchedule_tasks;
1907 input list<tuple<HpcOmSimCode.Task, list<Integer>>> in_a_odeSchedule_tasks;
1908
1909 output Tpl.Text out_txt;
1910 algorithm
1911 out_txt :=
1912 match(in_txt, in_mArg, in_a_zeroFuncSchedule_tasks, in_a_daeSchedule_tasks, in_a_odeSchedule_tasks)
1913 local
1914 Tpl.Text txt;
1915 list<tuple<HpcOmSimCode.Task, list<Integer>>> a_zeroFuncSchedule_tasks;
1916 list<tuple<HpcOmSimCode.Task, list<Integer>>> a_daeSchedule_tasks;
1917 list<tuple<HpcOmSimCode.Task, list<Integer>>> a_odeSchedule_tasks;
1918 Integer ret_2;
1919 Integer ret_1;
1920 Integer ret_0;
1921
1922 case ( txt,
1923 "tbb",
1924 a_zeroFuncSchedule_tasks,
1925 a_daeSchedule_tasks,
1926 a_odeSchedule_tasks )
1927 algorithm
1928 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1929 ",_tbbGraphOde()\n",
1930 ",_tbbGraphAll()\n",
1931 ",_tbbGraphZeroFunc()\n",
1932 ",_tbbStartNodeOde(_tbbGraphOde)\n",
1933 ",_tbbStartNodeAll(_tbbGraphAll)\n",
1934 ",_tbbStartNodeZeroFunc(_tbbGraphZeroFunc)\n",
1935 ",_tbbNodeListOde("
1936 }, false));
1937 ✗ ret_0 := listLength(a_odeSchedule_tasks);
1938 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
1939 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1940 ",NULL)\n",
1941 ",_tbbNodeListAll("
1942 }, false));
1943 ✗ ret_1 := listLength(a_daeSchedule_tasks);
1944 ✗ txt := Tpl.writeStr(txt, intString(ret_1));
1945 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1946 ",NULL)\n",
1947 ",_tbbNodeListZeroFunc("
1948 }, false));
1949 ✗ ret_2 := listLength(a_zeroFuncSchedule_tasks);
1950 ✗ txt := Tpl.writeStr(txt, intString(ret_2));
1951 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(",NULL)"));
1952 then txt;
1953
1954 case ( txt,
1955 _,
1956 _,
1957 _,
1958 _ )
1959 then txt;
1960 end match;
1961 end fun_99;
1962
1963 protected function fun_100
1964 input Tpl.Text in_txt;
1965 input Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> in_a_scheduleOpt;
1966 input Tpl.Text in_a_type;
1967
1968 output Tpl.Text out_txt;
1969 algorithm
1970 out_txt :=
1971 match(in_txt, in_a_scheduleOpt, in_a_type)
1972 local
1973 Tpl.Text txt;
1974 Tpl.Text a_type;
1975 list<tuple<HpcOmSimCode.Task, list<Integer>>> i_zeroFuncSchedule_tasks;
1976 list<tuple<HpcOmSimCode.Task, list<Integer>>> i_daeSchedule_tasks;
1977 list<tuple<HpcOmSimCode.Task, list<Integer>>> i_odeSchedule_tasks;
1978 String str_1;
1979 String str_0;
1980
1981 case ( txt,
1982 SOME((HpcOmSimCode.LEVELSCHEDULE(useFixedAssignments = true), _, _)),
1983 a_type )
1984 algorithm
1985 1 str_0 := Tpl.textString(a_type);
1986 1 txt := fun_98(txt, str_0, a_type);
1987 then txt;
1988
1989 case ( txt,
1990 SOME((HpcOmSimCode.TASKDEPSCHEDULE(tasks = i_odeSchedule_tasks), HpcOmSimCode.TASKDEPSCHEDULE(tasks = i_daeSchedule_tasks), HpcOmSimCode.TASKDEPSCHEDULE(tasks = i_zeroFuncSchedule_tasks))),
1991 a_type )
1992 algorithm
1993 ✗ str_1 := Tpl.textString(a_type);
1994 ✗ txt := fun_99(txt, str_1, i_zeroFuncSchedule_tasks, i_daeSchedule_tasks, i_odeSchedule_tasks);
1995 then txt;
1996
1997 case ( txt,
1998 _,
1999 _ )
2000 then txt;
2001 end match;
2002 end fun_100;
2003
2004 public function additionalHpcomConstructorDefinitions
2005 input Tpl.Text txt;
2006 input Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> a_scheduleOpt;
2007
2008 output Tpl.Text out_txt;
2009 protected
2010 String ret_1;
2011 Tpl.Text l_type;
2012 algorithm
2013 1 ret_1 := Flags.getConfigString(Flags.HPCOM_CODE);
2014 1 l_type := Tpl.writeStr(Tpl.emptyTxt, ret_1);
2015 1 out_txt := fun_100(txt, a_scheduleOpt, l_type);
2016 end additionalHpcomConstructorDefinitions;
2017
2018 protected function fun_102
2019 input Tpl.Text in_txt;
2020 input Boolean in_mArg;
2021 input String in_a_fullModelName;
2022
2023 output Tpl.Text out_txt;
2024 algorithm
2025 out_txt :=
2026 match(in_txt, in_mArg, in_a_fullModelName)
2027 local
2028 Tpl.Text txt;
2029 String a_fullModelName;
2030 Integer ret_0;
2031
2032 case ( txt,
2033 false,
2034 _ )
2035 then txt;
2036
2037 case ( txt,
2038 _,
2039 a_fullModelName )
2040 algorithm
2041 ✗ ret_0 := Flags.getConfigInt(Flags.NUM_PROC);
2042 ✗ txt := generateThreadMeasureTimeDeclaration(txt, a_fullModelName, ret_0);
2043 then txt;
2044 end match;
2045 end fun_102;
2046
2047 protected function lm_103
2048 input output Tpl.Text txt;
2049 input list<Integer> items;
2050 input String a_modelNamePrefixStr;
2051 input Tpl.Text a_type;
2052 algorithm
2053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 for lstElt_103 in items loop
2054 txt := match lstElt_103
2055 local
2056 Integer x_i0;
2057
2058 case _
2059 algorithm
2060 ✗ x_i0 := Tpl.getIteri_i0(txt);
2061 ✗ txt := generateThread(txt, x_i0, Tpl.textString(a_type), a_modelNamePrefixStr, "evaluateThreadFunc");
2062 ✗ txt := Tpl.nextIter(txt);
2063 then txt;
2064 end match;
2065 end for;
2066 end lm_103;
2067
2068 protected function lm_104
2069 input output Tpl.Text txt;
2070 input list<Integer> items;
2071 algorithm
2072 ✗ for lstElt_104 in items loop
2073 txt := match lstElt_104
2074 local
2075 Integer i_levelIdx;
2076 Integer ret_0;
2077
2078 case i_levelIdx
2079 algorithm
2080 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("(*measureTimeSchedulerArrayHpcom_evaluateODE)["));
2081 ✗ ret_0 := intSub(i_levelIdx, 1);
2082 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
2083 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("] = new MeasureTimeData(\"evaluateODE_level_"));
2084 ✗ txt := Tpl.writeStr(txt, intString(i_levelIdx));
2085 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\");"));
2086 ✗ txt := Tpl.nextIter(txt);
2087 then txt;
2088 end match;
2089 end for;
2090 end lm_104;
2091
2092 protected function lm_105
2093 input output Tpl.Text txt;
2094 input list<Integer> items;
2095 algorithm
2096 ✗ for lstElt_105 in items loop
2097 txt := match lstElt_105
2098 local
2099 Integer i_levelIdx;
2100 Integer ret_0;
2101
2102 case i_levelIdx
2103 algorithm
2104 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("(*measureTimeSchedulerArrayHpcom_evaluateDAE)["));
2105 ✗ ret_0 := intSub(i_levelIdx, 1);
2106 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
2107 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("] = new MeasureTimeData(\"evaluateDAE_level_"));
2108 ✗ txt := Tpl.writeStr(txt, intString(i_levelIdx));
2109 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\");"));
2110 ✗ txt := Tpl.nextIter(txt);
2111 then txt;
2112 end match;
2113 end for;
2114 end lm_105;
2115
2116 protected function lm_106
2117 input output Tpl.Text txt;
2118 input list<Integer> items;
2119 algorithm
2120 ✗ for lstElt_106 in items loop
2121 txt := match lstElt_106
2122 local
2123 Integer i_levelIdx;
2124 Integer ret_0;
2125
2126 case i_levelIdx
2127 algorithm
2128 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("(*measureTimeSchedulerArrayHpcom_evaluateZeroFuncs)["));
2129 ✗ ret_0 := intSub(i_levelIdx, 1);
2130 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
2131 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("] = new MeasureTimeData(\"evaluateZeroFunc_level_"));
2132 ✗ txt := Tpl.writeStr(txt, intString(i_levelIdx));
2133 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\");"));
2134 ✗ txt := Tpl.nextIter(txt);
2135 then txt;
2136 end match;
2137 end for;
2138 end lm_106;
2139
2140 protected function fun_107
2141 input Tpl.Text in_txt;
2142 input Boolean in_mArg;
2143 input list<HpcOmSimCode.TaskList> in_a_zeroFuncSchedule_tasksOfLevels;
2144 input list<HpcOmSimCode.TaskList> in_a_daeSchedule_tasksOfLevels;
2145 input String in_a_fullModelName;
2146 input list<HpcOmSimCode.TaskList> in_a_odeSchedule_tasksOfLevels;
2147
2148 output Tpl.Text out_txt;
2149 algorithm
2150 out_txt :=
2151 match(in_txt, in_mArg, in_a_zeroFuncSchedule_tasksOfLevels, in_a_daeSchedule_tasksOfLevels, in_a_fullModelName, in_a_odeSchedule_tasksOfLevels)
2152 local
2153 Tpl.Text txt;
2154 list<HpcOmSimCode.TaskList> a_zeroFuncSchedule_tasksOfLevels;
2155 list<HpcOmSimCode.TaskList> a_daeSchedule_tasksOfLevels;
2156 String a_fullModelName;
2157 list<HpcOmSimCode.TaskList> a_odeSchedule_tasksOfLevels;
2158 list<Integer> ret_8;
2159 Integer ret_7;
2160 Integer ret_6;
2161 list<Integer> ret_5;
2162 Integer ret_4;
2163 Integer ret_3;
2164 list<Integer> ret_2;
2165 Integer ret_1;
2166 Integer ret_0;
2167
2168 case ( txt,
2169 false,
2170 _,
2171 _,
2172 _,
2173 _ )
2174 then txt;
2175
2176 case ( txt,
2177 _,
2178 a_zeroFuncSchedule_tasksOfLevels,
2179 a_daeSchedule_tasksOfLevels,
2180 a_fullModelName,
2181 a_odeSchedule_tasksOfLevels )
2182 algorithm
2183 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2184 "#ifdef MEASURETIME_MODELFUNCTIONS\n",
2185 "measureTimeSchedulerArrayHpcom_evaluateODE = new std::vector<MeasureTimeData*>(size_t("
2186 }, false));
2187 ✗ ret_0 := listLength(a_odeSchedule_tasksOfLevels);
2188 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
2189 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2190 "), NULL);\n",
2191 "MeasureTime::addResultContentBlock(\""
2192 }, false));
2193 ✗ txt := Tpl.writeStr(txt, a_fullModelName);
2194 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2195 "\",\"functions_HPCOM_Sections_ODE\",measureTimeSchedulerArrayHpcom_evaluateODE);\n",
2196 "measuredSchedulerStartValues = MeasureTime::getZeroValues();\n",
2197 "measuredSchedulerEndValues = MeasureTime::getZeroValues();\n"
2198 }, true));
2199 ✗ ret_1 := listLength(a_odeSchedule_tasksOfLevels);
2200 ✗ ret_2 := List.intRange(ret_1);
2201 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2202 ✗ txt := lm_104(txt, ret_2);
2203 ✗ txt := Tpl.popIter(txt);
2204 ✗ txt := Tpl.softNewLine(txt);
2205 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2206 "\n",
2207 "measureTimeSchedulerArrayHpcom_evaluateDAE = new std::vector<MeasureTimeData*>(size_t("
2208 }, false));
2209 ✗ ret_3 := listLength(a_daeSchedule_tasksOfLevels);
2210 ✗ txt := Tpl.writeStr(txt, intString(ret_3));
2211 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2212 "), NULL);\n",
2213 "MeasureTime::addResultContentBlock(\""
2214 }, false));
2215 ✗ txt := Tpl.writeStr(txt, a_fullModelName);
2216 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2217 "\",\"functions_HPCOM_Sections_DAE\",measureTimeSchedulerArrayHpcom_evaluateDAE);\n",
2218 "measuredSchedulerStartValues = MeasureTime::getZeroValues();\n",
2219 "measuredSchedulerEndValues = MeasureTime::getZeroValues();\n"
2220 }, true));
2221 ✗ ret_4 := listLength(a_daeSchedule_tasksOfLevels);
2222 ✗ ret_5 := List.intRange(ret_4);
2223 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2224 ✗ txt := lm_105(txt, ret_5);
2225 ✗ txt := Tpl.popIter(txt);
2226 ✗ txt := Tpl.softNewLine(txt);
2227 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2228 "\n",
2229 "measureTimeSchedulerArrayHpcom_evaluateZeroFuncs = new std::vector<MeasureTimeData*>(size_t("
2230 }, false));
2231 ✗ ret_6 := listLength(a_zeroFuncSchedule_tasksOfLevels);
2232 ✗ txt := Tpl.writeStr(txt, intString(ret_6));
2233 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2234 "), NULL);\n",
2235 "MeasureTime::addResultContentBlock(\""
2236 }, false));
2237 ✗ txt := Tpl.writeStr(txt, a_fullModelName);
2238 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2239 "\",\"functions_HPCOM_Sections_ZeroFuncs\",measureTimeSchedulerArrayHpcom_evaluateZeroFuncs);\n",
2240 "measuredSchedulerStartValues = MeasureTime::getZeroValues();\n",
2241 "measuredSchedulerEndValues = MeasureTime::getZeroValues();\n"
2242 }, true));
2243 ✗ ret_7 := listLength(a_zeroFuncSchedule_tasksOfLevels);
2244 ✗ ret_8 := List.intRange(ret_7);
2245 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2246 ✗ txt := lm_106(txt, ret_8);
2247 ✗ txt := Tpl.popIter(txt);
2248 ✗ txt := Tpl.softNewLine(txt);
2249 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#endif //MEASURETIME_MODELFUNCTIONS"));
2250 then txt;
2251 end match;
2252 end fun_107;
2253
2254 protected function lm_108
2255 input output Tpl.Text txt;
2256 input list<Integer> items;
2257 input String a_modelNamePrefixStr;
2258 input Tpl.Text a_type;
2259 algorithm
2260 ✗ for lstElt_108 in items loop
2261 txt := match lstElt_108
2262 local
2263 Integer x_i0;
2264
2265 case _
2266 algorithm
2267 ✗ x_i0 := Tpl.getIteri_i0(txt);
2268 ✗ txt := generateThread(txt, x_i0, Tpl.textString(a_type), a_modelNamePrefixStr, "evaluateThreadFunc");
2269 ✗ txt := Tpl.nextIter(txt);
2270 then txt;
2271 end match;
2272 end for;
2273 end lm_108;
2274
2275 protected function lm_109
2276 input output Tpl.Text txt;
2277 input list<Integer> items;
2278 algorithm
2279 ✗ for lstElt_109 in items loop
2280 txt := match lstElt_109
2281 local
2282 Integer i_levelIdx;
2283 Integer ret_0;
2284
2285 case i_levelIdx
2286 algorithm
2287 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("(*measureTimeSchedulerArrayHpcom_evaluateODE)["));
2288 ✗ ret_0 := intSub(i_levelIdx, 1);
2289 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
2290 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("] = new MeasureTimeData(\"evaluateODE_level_"));
2291 ✗ txt := Tpl.writeStr(txt, intString(i_levelIdx));
2292 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\");"));
2293 ✗ txt := Tpl.nextIter(txt);
2294 then txt;
2295 end match;
2296 end for;
2297 end lm_109;
2298
2299 protected function lm_110
2300 input output Tpl.Text txt;
2301 input list<Integer> items;
2302 algorithm
2303 ✗ for lstElt_110 in items loop
2304 txt := match lstElt_110
2305 local
2306 Integer i_levelIdx;
2307 Integer ret_0;
2308
2309 case i_levelIdx
2310 algorithm
2311 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("(*measureTimeSchedulerArrayHpcom_evaluateDAE)["));
2312 ✗ ret_0 := intSub(i_levelIdx, 1);
2313 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
2314 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("] = new MeasureTimeData(\"evaluateDAE_level_"));
2315 ✗ txt := Tpl.writeStr(txt, intString(i_levelIdx));
2316 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\");"));
2317 ✗ txt := Tpl.nextIter(txt);
2318 then txt;
2319 end match;
2320 end for;
2321 end lm_110;
2322
2323 protected function lm_111
2324 input output Tpl.Text txt;
2325 input list<Integer> items;
2326 algorithm
2327 ✗ for lstElt_111 in items loop
2328 txt := match lstElt_111
2329 local
2330 Integer i_levelIdx;
2331 Integer ret_0;
2332
2333 case i_levelIdx
2334 algorithm
2335 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("(*measureTimeSchedulerArrayHpcom_evaluateZeroFuncs)["));
2336 ✗ ret_0 := intSub(i_levelIdx, 1);
2337 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
2338 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("] = new MeasureTimeData(\"evaluateZeroFunc_level_"));
2339 ✗ txt := Tpl.writeStr(txt, intString(i_levelIdx));
2340 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\");"));
2341 ✗ txt := Tpl.nextIter(txt);
2342 then txt;
2343 end match;
2344 end for;
2345 end lm_111;
2346
2347 protected function fun_112
2348 input Tpl.Text in_txt;
2349 input Boolean in_mArg;
2350 input list<HpcOmSimCode.TaskList> in_a_zeroFuncSchedule_tasksOfLevels;
2351 input list<HpcOmSimCode.TaskList> in_a_daeSchedule_tasksOfLevels;
2352 input String in_a_fullModelName;
2353 input list<HpcOmSimCode.TaskList> in_a_odeSchedule_tasksOfLevels;
2354
2355 output Tpl.Text out_txt;
2356 algorithm
2357 out_txt :=
2358 match(in_txt, in_mArg, in_a_zeroFuncSchedule_tasksOfLevels, in_a_daeSchedule_tasksOfLevels, in_a_fullModelName, in_a_odeSchedule_tasksOfLevels)
2359 local
2360 Tpl.Text txt;
2361 list<HpcOmSimCode.TaskList> a_zeroFuncSchedule_tasksOfLevels;
2362 list<HpcOmSimCode.TaskList> a_daeSchedule_tasksOfLevels;
2363 String a_fullModelName;
2364 list<HpcOmSimCode.TaskList> a_odeSchedule_tasksOfLevels;
2365 list<Integer> ret_8;
2366 Integer ret_7;
2367 Integer ret_6;
2368 list<Integer> ret_5;
2369 Integer ret_4;
2370 Integer ret_3;
2371 list<Integer> ret_2;
2372 Integer ret_1;
2373 Integer ret_0;
2374
2375 case ( txt,
2376 false,
2377 _,
2378 _,
2379 _,
2380 _ )
2381 then txt;
2382
2383 case ( txt,
2384 _,
2385 a_zeroFuncSchedule_tasksOfLevels,
2386 a_daeSchedule_tasksOfLevels,
2387 a_fullModelName,
2388 a_odeSchedule_tasksOfLevels )
2389 algorithm
2390 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2391 "#ifdef MEASURETIME_MODELFUNCTIONS\n",
2392 "measureTimeSchedulerArrayHpcom_evaluateODE = new std::vector<MeasureTimeData*>(size_t("
2393 }, false));
2394 ✗ ret_0 := listLength(a_odeSchedule_tasksOfLevels);
2395 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
2396 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2397 "), NULL);\n",
2398 "MeasureTime::addResultContentBlock(\""
2399 }, false));
2400 ✗ txt := Tpl.writeStr(txt, a_fullModelName);
2401 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2402 "\",\"functions_HPCOM_Sections_ODE\",measureTimeSchedulerArrayHpcom_evaluateODE);\n",
2403 "measuredSchedulerStartValues = MeasureTime::getZeroValues();\n",
2404 "measuredSchedulerEndValues = MeasureTime::getZeroValues();\n"
2405 }, true));
2406 ✗ ret_1 := listLength(a_odeSchedule_tasksOfLevels);
2407 ✗ ret_2 := List.intRange(ret_1);
2408 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2409 ✗ txt := lm_109(txt, ret_2);
2410 ✗ txt := Tpl.popIter(txt);
2411 ✗ txt := Tpl.softNewLine(txt);
2412 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2413 "\n",
2414 "measureTimeSchedulerArrayHpcom_evaluateDAE = new std::vector<MeasureTimeData*>(size_t("
2415 }, false));
2416 ✗ ret_3 := listLength(a_daeSchedule_tasksOfLevels);
2417 ✗ txt := Tpl.writeStr(txt, intString(ret_3));
2418 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2419 "), NULL);\n",
2420 "MeasureTime::addResultContentBlock(\""
2421 }, false));
2422 ✗ txt := Tpl.writeStr(txt, a_fullModelName);
2423 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2424 "\",\"functions_HPCOM_Sections_DAE\",measureTimeSchedulerArrayHpcom_evaluateDAE);\n",
2425 "measuredSchedulerStartValues = MeasureTime::getZeroValues();\n",
2426 "measuredSchedulerEndValues = MeasureTime::getZeroValues();\n"
2427 }, true));
2428 ✗ ret_4 := listLength(a_daeSchedule_tasksOfLevels);
2429 ✗ ret_5 := List.intRange(ret_4);
2430 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2431 ✗ txt := lm_110(txt, ret_5);
2432 ✗ txt := Tpl.popIter(txt);
2433 ✗ txt := Tpl.softNewLine(txt);
2434 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2435 "\n",
2436 "measureTimeSchedulerArrayHpcom_evaluateZeroFuncs = new std::vector<MeasureTimeData*>(size_t("
2437 }, false));
2438 ✗ ret_6 := listLength(a_zeroFuncSchedule_tasksOfLevels);
2439 ✗ txt := Tpl.writeStr(txt, intString(ret_6));
2440 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2441 "), NULL);\n",
2442 "MeasureTime::addResultContentBlock(\""
2443 }, false));
2444 ✗ txt := Tpl.writeStr(txt, a_fullModelName);
2445 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2446 "\",\"functions_HPCOM_Sections_ZeroFuncs\",measureTimeSchedulerArrayHpcom_evaluateZeroFuncs);\n",
2447 "measuredSchedulerStartValues = MeasureTime::getZeroValues();\n",
2448 "measuredSchedulerEndValues = MeasureTime::getZeroValues();\n"
2449 }, true));
2450 ✗ ret_7 := listLength(a_zeroFuncSchedule_tasksOfLevels);
2451 ✗ ret_8 := List.intRange(ret_7);
2452 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2453 ✗ txt := lm_111(txt, ret_8);
2454 ✗ txt := Tpl.popIter(txt);
2455 ✗ txt := Tpl.softNewLine(txt);
2456 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#endif //MEASURETIME_MODELFUNCTIONS"));
2457 then txt;
2458 end match;
2459 end fun_112;
2460
2461 protected function fun_113
2462 input Tpl.Text in_txt;
2463 input String in_mArg;
2464 input list<HpcOmSimCode.TaskList> in_a_zeroFuncSchedule_tasksOfLevels;
2465 input list<HpcOmSimCode.TaskList> in_a_daeSchedule_tasksOfLevels;
2466 input String in_a_fullModelName;
2467 input list<HpcOmSimCode.TaskList> in_a_odeSchedule_tasksOfLevels;
2468 input String in_a_modelNamePrefixStr;
2469 input Tpl.Text in_a_type;
2470
2471 output Tpl.Text out_txt;
2472 algorithm
2473 out_txt :=
2474 match(in_txt, in_mArg, in_a_zeroFuncSchedule_tasksOfLevels, in_a_daeSchedule_tasksOfLevels, in_a_fullModelName, in_a_odeSchedule_tasksOfLevels, in_a_modelNamePrefixStr, in_a_type)
2475 local
2476 Tpl.Text txt;
2477 list<HpcOmSimCode.TaskList> a_zeroFuncSchedule_tasksOfLevels;
2478 list<HpcOmSimCode.TaskList> a_daeSchedule_tasksOfLevels;
2479 String a_fullModelName;
2480 list<HpcOmSimCode.TaskList> a_odeSchedule_tasksOfLevels;
2481 String a_modelNamePrefixStr;
2482 Tpl.Text a_type;
2483 Boolean ret_12;
2484 Boolean ret_11;
2485 String ret_10;
2486 list<Integer> ret_9;
2487 Integer ret_8;
2488 Integer ret_7;
2489 Boolean ret_6;
2490 Boolean ret_5;
2491 String ret_4;
2492 list<Integer> ret_3;
2493 Integer ret_2;
2494 Integer ret_1;
2495 Tpl.Text l_threadFuncs;
2496
2497 case ( txt,
2498 "pthreads",
2499 a_zeroFuncSchedule_tasksOfLevels,
2500 a_daeSchedule_tasksOfLevels,
2501 a_fullModelName,
2502 a_odeSchedule_tasksOfLevels,
2503 a_modelNamePrefixStr,
2504 a_type )
2505 algorithm
2506 1 ret_1 := Flags.getConfigInt(Flags.NUM_PROC);
2507 1 ret_2 := intSub(ret_1, 1);
2508 1 ret_3 := List.intRange(ret_2);
2509 1 l_threadFuncs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2510 1 l_threadFuncs := lm_103(l_threadFuncs, ret_3, a_modelNamePrefixStr, a_type);
2511 1 l_threadFuncs := Tpl.popIter(l_threadFuncs);
2512 1 txt := Tpl.writeText(txt, l_threadFuncs);
2513 1 txt := Tpl.softNewLine(txt);
2514 1 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2515 1 ret_4 := Flags.getConfigString(Flags.PROFILING_LEVEL);
2516
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 ret_5 := stringEq(ret_4, "none");
2517 1 ret_6 := boolNot(ret_5);
2518 1 txt := fun_107(txt, ret_6, a_zeroFuncSchedule_tasksOfLevels, a_daeSchedule_tasksOfLevels, a_fullModelName, a_odeSchedule_tasksOfLevels);
2519 then txt;
2520
2521 case ( txt,
2522 "pthreads_spin",
2523 a_zeroFuncSchedule_tasksOfLevels,
2524 a_daeSchedule_tasksOfLevels,
2525 a_fullModelName,
2526 a_odeSchedule_tasksOfLevels,
2527 a_modelNamePrefixStr,
2528 a_type )
2529 algorithm
2530 ✗ ret_7 := Flags.getConfigInt(Flags.NUM_PROC);
2531 ✗ ret_8 := intSub(ret_7, 1);
2532 ✗ ret_9 := List.intRange(ret_8);
2533 ✗ l_threadFuncs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2534 ✗ l_threadFuncs := lm_108(l_threadFuncs, ret_9, a_modelNamePrefixStr, a_type);
2535 ✗ l_threadFuncs := Tpl.popIter(l_threadFuncs);
2536 ✗ txt := Tpl.writeText(txt, l_threadFuncs);
2537 ✗ txt := Tpl.softNewLine(txt);
2538 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2539 ✗ ret_10 := Flags.getConfigString(Flags.PROFILING_LEVEL);
2540 ✗ ret_11 := stringEq(ret_10, "none");
2541 ✗ ret_12 := boolNot(ret_11);
2542 ✗ txt := fun_112(txt, ret_12, a_zeroFuncSchedule_tasksOfLevels, a_daeSchedule_tasksOfLevels, a_fullModelName, a_odeSchedule_tasksOfLevels);
2543 then txt;
2544
2545 case ( txt,
2546 _,
2547 _,
2548 _,
2549 _,
2550 _,
2551 _,
2552 _ )
2553 then txt;
2554 end match;
2555 end fun_113;
2556
2557 protected function lm_114
2558 input output Tpl.Text txt;
2559 input list<list<HpcOmSimCode.Task>> items;
2560 input String a_modelNamePrefixStr;
2561 input Tpl.Text a_type;
2562 algorithm
2563 ✗ for lstElt_114 in items loop
2564 txt := match lstElt_114
2565 local
2566 Integer x_i0;
2567
2568 case _
2569 algorithm
2570 ✗ x_i0 := Tpl.getIteri_i0(txt);
2571 ✗ txt := generateThread(txt, x_i0, Tpl.textString(a_type), a_modelNamePrefixStr, "evaluateThreadFunc");
2572 ✗ txt := Tpl.nextIter(txt);
2573 then txt;
2574 end match;
2575 end for;
2576 end lm_114;
2577
2578 protected function lm_115
2579 input output Tpl.Text txt;
2580 input list<list<HpcOmSimCode.Task>> items;
2581 input String a_modelNamePrefixStr;
2582 input Tpl.Text a_type;
2583 algorithm
2584 ✗ for lstElt_115 in items loop
2585 txt := match lstElt_115
2586 local
2587 Integer x_i0;
2588
2589 case _
2590 algorithm
2591 ✗ x_i0 := Tpl.getIteri_i0(txt);
2592 ✗ txt := generateThread(txt, x_i0, Tpl.textString(a_type), a_modelNamePrefixStr, "evaluateThreadFunc");
2593 ✗ txt := Tpl.nextIter(txt);
2594 then txt;
2595 end match;
2596 end for;
2597 end lm_115;
2598
2599 protected function lm_116
2600 input output Tpl.Text txt;
2601 input list<list<HpcOmSimCode.Task>> items;
2602 input Tpl.Text a_type;
2603 algorithm
2604 ✗ for lstElt_116 in items loop
2605 txt := match lstElt_116
2606 local
2607 Integer x_i0;
2608
2609 case _
2610 algorithm
2611 ✗ x_i0 := Tpl.getIteri_i0(txt);
2612 ✗ txt := initializeLockByLockName(txt, intString(x_i0), "th_lock", Tpl.textString(a_type));
2613 ✗ txt := Tpl.nextIter(txt);
2614 then txt;
2615 end match;
2616 end for;
2617 end lm_116;
2618
2619 protected function lm_117
2620 input output Tpl.Text txt;
2621 input list<list<HpcOmSimCode.Task>> items;
2622 input Tpl.Text a_type;
2623 algorithm
2624 ✗ for lstElt_117 in items loop
2625 txt := match lstElt_117
2626 local
2627 Integer x_i0;
2628
2629 case _
2630 algorithm
2631 ✗ x_i0 := Tpl.getIteri_i0(txt);
2632 ✗ txt := initializeLockByLockName(txt, intString(x_i0), "th_lock1", Tpl.textString(a_type));
2633 ✗ txt := Tpl.nextIter(txt);
2634 then txt;
2635 end match;
2636 end for;
2637 end lm_117;
2638
2639 protected function lm_118
2640 input output Tpl.Text txt;
2641 input list<list<HpcOmSimCode.Task>> items;
2642 input Tpl.Text a_type;
2643 algorithm
2644 ✗ for lstElt_118 in items loop
2645 txt := match lstElt_118
2646 local
2647 Integer x_i0;
2648
2649 case _
2650 algorithm
2651 ✗ x_i0 := Tpl.getIteri_i0(txt);
2652 ✗ txt := assignLockByLockName(txt, intString(x_i0), "th_lock", Tpl.textString(a_type));
2653 ✗ txt := Tpl.nextIter(txt);
2654 then txt;
2655 end match;
2656 end for;
2657 end lm_118;
2658
2659 protected function lm_119
2660 input output Tpl.Text txt;
2661 input list<list<HpcOmSimCode.Task>> items;
2662 input Tpl.Text a_type;
2663 algorithm
2664 ✗ for lstElt_119 in items loop
2665 txt := match lstElt_119
2666 local
2667 Integer x_i0;
2668
2669 case _
2670 algorithm
2671 ✗ x_i0 := Tpl.getIteri_i0(txt);
2672 ✗ txt := assignLockByLockName(txt, intString(x_i0), "th_lock1", Tpl.textString(a_type));
2673 ✗ txt := Tpl.nextIter(txt);
2674 then txt;
2675 end match;
2676 end for;
2677 end lm_119;
2678
2679 protected function fun_120
2680 input Tpl.Text in_txt;
2681 input String in_mArg;
2682 input Tpl.Text in_a_assignLocksZeroFunc;
2683 input Tpl.Text in_a_assignLocksOde;
2684 input Tpl.Text in_a_assignLocksDae;
2685 input Tpl.Text in_a_initLocksZeroFunc;
2686 input Tpl.Text in_a_initLocksDae;
2687 input Tpl.Text in_a_initLocksOde;
2688 input String in_a_modelNamePrefixStr;
2689 input Tpl.Text in_a_type;
2690 input array<list<HpcOmSimCode.Task>> in_a_odeSchedule_threadTasks;
2691
2692 output Tpl.Text out_txt;
2693 algorithm
2694 out_txt :=
2695 match(in_txt, in_mArg, in_a_assignLocksZeroFunc, in_a_assignLocksOde, in_a_assignLocksDae, in_a_initLocksZeroFunc, in_a_initLocksDae, in_a_initLocksOde, in_a_modelNamePrefixStr, in_a_type, in_a_odeSchedule_threadTasks)
2696 local
2697 Tpl.Text txt;
2698 Tpl.Text a_assignLocksZeroFunc;
2699 Tpl.Text a_assignLocksOde;
2700 Tpl.Text a_assignLocksDae;
2701 Tpl.Text a_initLocksZeroFunc;
2702 Tpl.Text a_initLocksDae;
2703 Tpl.Text a_initLocksOde;
2704 String a_modelNamePrefixStr;
2705 Tpl.Text a_type;
2706 array<list<HpcOmSimCode.Task>> a_odeSchedule_threadTasks;
2707 list<list<HpcOmSimCode.Task>> ret_15;
2708 list<list<HpcOmSimCode.Task>> ret_14;
2709 Tpl.Text l_threadAssignLocks1;
2710 list<list<HpcOmSimCode.Task>> ret_12;
2711 list<list<HpcOmSimCode.Task>> ret_11;
2712 Tpl.Text l_threadAssignLocks;
2713 list<list<HpcOmSimCode.Task>> ret_9;
2714 list<list<HpcOmSimCode.Task>> ret_8;
2715 Tpl.Text l_threadLocksInit1;
2716 list<list<HpcOmSimCode.Task>> ret_6;
2717 list<list<HpcOmSimCode.Task>> ret_5;
2718 Tpl.Text l_threadLocksInit;
2719 list<list<HpcOmSimCode.Task>> ret_3;
2720 list<list<HpcOmSimCode.Task>> ret_2;
2721 list<list<HpcOmSimCode.Task>> ret_1;
2722 Tpl.Text l_threadFuncs;
2723
2724 case ( txt,
2725 "openmp",
2726 _,
2727 _,
2728 _,
2729 a_initLocksZeroFunc,
2730 a_initLocksDae,
2731 a_initLocksOde,
2732 a_modelNamePrefixStr,
2733 a_type,
2734 a_odeSchedule_threadTasks )
2735 algorithm
2736 ✗ ret_1 := arrayList(a_odeSchedule_threadTasks);
2737 ✗ l_threadFuncs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2738 ✗ l_threadFuncs := lm_114(l_threadFuncs, ret_1, a_modelNamePrefixStr, a_type);
2739 ✗ l_threadFuncs := Tpl.popIter(l_threadFuncs);
2740 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("omp_set_dynamic(0);\n"));
2741 ✗ txt := Tpl.writeText(txt, l_threadFuncs);
2742 ✗ txt := Tpl.softNewLine(txt);
2743 ✗ txt := Tpl.writeText(txt, a_initLocksOde);
2744 ✗ txt := Tpl.softNewLine(txt);
2745 ✗ txt := Tpl.writeText(txt, a_initLocksDae);
2746 ✗ txt := Tpl.softNewLine(txt);
2747 ✗ txt := Tpl.writeText(txt, a_initLocksZeroFunc);
2748 then txt;
2749
2750 case ( txt,
2751 "mpi",
2752 _,
2753 _,
2754 _,
2755 _,
2756 _,
2757 _,
2758 _,
2759 _,
2760 _ )
2761 algorithm
2762 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("//MF: Initialize MPI related stuff - nothing todo?"));
2763 then txt;
2764
2765 case ( txt,
2766 _,
2767 a_assignLocksZeroFunc,
2768 a_assignLocksOde,
2769 a_assignLocksDae,
2770 a_initLocksZeroFunc,
2771 a_initLocksDae,
2772 a_initLocksOde,
2773 a_modelNamePrefixStr,
2774 a_type,
2775 a_odeSchedule_threadTasks )
2776 algorithm
2777 ✗ ret_2 := arrayList(a_odeSchedule_threadTasks);
2778 ✗ ret_3 := listRest(ret_2);
2779 ✗ l_threadFuncs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2780 ✗ l_threadFuncs := lm_115(l_threadFuncs, ret_3, a_modelNamePrefixStr, a_type);
2781 ✗ l_threadFuncs := Tpl.popIter(l_threadFuncs);
2782 ✗ ret_5 := arrayList(a_odeSchedule_threadTasks);
2783 ✗ ret_6 := listRest(ret_5);
2784 ✗ l_threadLocksInit := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2785 ✗ l_threadLocksInit := lm_116(l_threadLocksInit, ret_6, a_type);
2786 ✗ l_threadLocksInit := Tpl.popIter(l_threadLocksInit);
2787 ✗ ret_8 := arrayList(a_odeSchedule_threadTasks);
2788 ✗ ret_9 := listRest(ret_8);
2789 ✗ l_threadLocksInit1 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2790 ✗ l_threadLocksInit1 := lm_117(l_threadLocksInit1, ret_9, a_type);
2791 ✗ l_threadLocksInit1 := Tpl.popIter(l_threadLocksInit1);
2792 ✗ ret_11 := arrayList(a_odeSchedule_threadTasks);
2793 ✗ ret_12 := listRest(ret_11);
2794 ✗ l_threadAssignLocks := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2795 ✗ l_threadAssignLocks := lm_118(l_threadAssignLocks, ret_12, a_type);
2796 ✗ l_threadAssignLocks := Tpl.popIter(l_threadAssignLocks);
2797 ✗ ret_14 := arrayList(a_odeSchedule_threadTasks);
2798 ✗ ret_15 := listRest(ret_14);
2799 ✗ l_threadAssignLocks1 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2800 ✗ l_threadAssignLocks1 := lm_119(l_threadAssignLocks1, ret_15, a_type);
2801 ✗ l_threadAssignLocks1 := Tpl.popIter(l_threadAssignLocks1);
2802 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
2803 "_terminateThreads = false;\n",
2804 "_command = IContinuous::UNDEF_UPDATE;\n",
2805 "_evaluateMode = -1;\n",
2806 "\n"
2807 }, true));
2808 ✗ txt := Tpl.writeText(txt, a_initLocksOde);
2809 ✗ txt := Tpl.softNewLine(txt);
2810 ✗ txt := Tpl.writeText(txt, a_initLocksDae);
2811 ✗ txt := Tpl.softNewLine(txt);
2812 ✗ txt := Tpl.writeText(txt, a_initLocksZeroFunc);
2813 ✗ txt := Tpl.softNewLine(txt);
2814 ✗ txt := Tpl.writeText(txt, l_threadLocksInit);
2815 ✗ txt := Tpl.softNewLine(txt);
2816 ✗ txt := Tpl.writeText(txt, l_threadLocksInit1);
2817 ✗ txt := Tpl.softNewLine(txt);
2818 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2819 ✗ txt := Tpl.writeText(txt, a_assignLocksDae);
2820 ✗ txt := Tpl.softNewLine(txt);
2821 ✗ txt := Tpl.writeText(txt, a_assignLocksOde);
2822 ✗ txt := Tpl.softNewLine(txt);
2823 ✗ txt := Tpl.writeText(txt, a_assignLocksZeroFunc);
2824 ✗ txt := Tpl.softNewLine(txt);
2825 ✗ txt := Tpl.writeText(txt, l_threadAssignLocks);
2826 ✗ txt := Tpl.softNewLine(txt);
2827 ✗ txt := Tpl.writeText(txt, l_threadAssignLocks1);
2828 ✗ txt := Tpl.softNewLine(txt);
2829 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2830 ✗ txt := Tpl.writeText(txt, l_threadFuncs);
2831 then txt;
2832 end match;
2833 end fun_120;
2834
2835 protected function fun_121
2836 input Tpl.Text in_txt;
2837 input String in_mArg;
2838 input String in_a_modelNamePrefixStr;
2839 input list<tuple<HpcOmSimCode.Task, list<Integer>>> in_a_zeroFuncSchedule_tasks;
2840 input list<tuple<HpcOmSimCode.Task, list<Integer>>> in_a_daeSchedule_tasks;
2841 input list<tuple<HpcOmSimCode.Task, list<Integer>>> in_a_odeSchedule_tasks;
2842
2843 output Tpl.Text out_txt;
2844 algorithm
2845 out_txt :=
2846 match(in_txt, in_mArg, in_a_modelNamePrefixStr, in_a_zeroFuncSchedule_tasks, in_a_daeSchedule_tasks, in_a_odeSchedule_tasks)
2847 local
2848 Tpl.Text txt;
2849 String a_modelNamePrefixStr;
2850 list<tuple<HpcOmSimCode.Task, list<Integer>>> a_zeroFuncSchedule_tasks;
2851 list<tuple<HpcOmSimCode.Task, list<Integer>>> a_daeSchedule_tasks;
2852 list<tuple<HpcOmSimCode.Task, list<Integer>>> a_odeSchedule_tasks;
2853 Tpl.Text l_tbbVars;
2854
2855 case ( txt,
2856 "tbb",
2857 a_modelNamePrefixStr,
2858 a_zeroFuncSchedule_tasks,
2859 a_daeSchedule_tasks,
2860 a_odeSchedule_tasks )
2861 algorithm
2862 ✗ l_tbbVars := generateTbbConstructorExtension(Tpl.emptyTxt, a_odeSchedule_tasks, a_daeSchedule_tasks, a_zeroFuncSchedule_tasks, a_modelNamePrefixStr);
2863 ✗ txt := Tpl.writeText(txt, l_tbbVars);
2864 then txt;
2865
2866 case ( txt,
2867 _,
2868 _,
2869 _,
2870 _,
2871 _ )
2872 then txt;
2873 end match;
2874 end fun_121;
2875
2876 protected function fun_122
2877 input Tpl.Text in_txt;
2878 input Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> in_a_schedulesOpt;
2879 input String in_a_fullModelName;
2880 input String in_a_modelNamePrefixStr;
2881 input Tpl.Text in_a_type;
2882
2883 output Tpl.Text out_txt;
2884 algorithm
2885 out_txt :=
2886 match(in_txt, in_a_schedulesOpt, in_a_fullModelName, in_a_modelNamePrefixStr, in_a_type)
2887 local
2888 Tpl.Text txt;
2889 String a_fullModelName;
2890 String a_modelNamePrefixStr;
2891 Tpl.Text a_type;
2892 list<tuple<HpcOmSimCode.Task, list<Integer>>> i_zeroFuncSchedule_tasks;
2893 list<tuple<HpcOmSimCode.Task, list<Integer>>> i_daeSchedule_tasks;
2894 list<tuple<HpcOmSimCode.Task, list<Integer>>> i_odeSchedule_tasks;
2895 array<list<HpcOmSimCode.Task>> i_odeSchedule_threadTasks;
2896 list<HpcOmSimCode.Task> i_zeroFuncSchedule_outgoingDepTasks;
2897 list<HpcOmSimCode.Task> i_daeSchedule_outgoingDepTasks;
2898 list<HpcOmSimCode.Task> i_odeSchedule_outgoingDepTasks;
2899 list<HpcOmSimCode.TaskList> i_zeroFuncSchedule_tasksOfLevels;
2900 list<HpcOmSimCode.TaskList> i_daeSchedule_tasksOfLevels;
2901 list<HpcOmSimCode.TaskList> i_odeSchedule_tasksOfLevels;
2902 String str_14;
2903 String str_13;
2904 Integer ret_12;
2905 Tpl.Text l_assignLocksZeroFunc;
2906 Integer ret_10;
2907 Tpl.Text l_initLocksZeroFunc;
2908 Integer ret_8;
2909 Tpl.Text l_assignLocksDae;
2910 Integer ret_6;
2911 Tpl.Text l_initLocksDae;
2912 Integer ret_4;
2913 Tpl.Text l_assignLocksOde;
2914 Integer ret_2;
2915 Tpl.Text l_initLocksOde;
2916 String str_0;
2917
2918 case ( txt,
2919 SOME((HpcOmSimCode.LEVELSCHEDULE(useFixedAssignments = true, tasksOfLevels = i_odeSchedule_tasksOfLevels), HpcOmSimCode.LEVELSCHEDULE(useFixedAssignments = true, tasksOfLevels = i_daeSchedule_tasksOfLevels), HpcOmSimCode.LEVELSCHEDULE(useFixedAssignments = true, tasksOfLevels = i_zeroFuncSchedule_tasksOfLevels))),
2920 a_fullModelName,
2921 a_modelNamePrefixStr,
2922 a_type )
2923 algorithm
2924 1 str_0 := Tpl.textString(a_type);
2925 1 txt := fun_113(txt, str_0, i_zeroFuncSchedule_tasksOfLevels, i_daeSchedule_tasksOfLevels, a_fullModelName, i_odeSchedule_tasksOfLevels, a_modelNamePrefixStr, a_type);
2926 then txt;
2927
2928 case ( txt,
2929 SOME((HpcOmSimCode.THREADSCHEDULE(outgoingDepTasks = i_odeSchedule_outgoingDepTasks, threadTasks = i_odeSchedule_threadTasks), HpcOmSimCode.THREADSCHEDULE(outgoingDepTasks = i_daeSchedule_outgoingDepTasks), HpcOmSimCode.THREADSCHEDULE(outgoingDepTasks = i_zeroFuncSchedule_outgoingDepTasks))),
2930 _,
2931 a_modelNamePrefixStr,
2932 a_type )
2933 algorithm
2934 ✗ ret_2 := listLength(i_odeSchedule_outgoingDepTasks);
2935 ✗ l_initLocksOde := initializeArrayLocks(Tpl.emptyTxt, ret_2, "_lockOde", Tpl.textString(a_type));
2936 ✗ ret_4 := listLength(i_odeSchedule_outgoingDepTasks);
2937 ✗ l_assignLocksOde := assignArrayLocks(Tpl.emptyTxt, ret_4, "_lockOde", Tpl.textString(a_type));
2938 ✗ ret_6 := listLength(i_daeSchedule_outgoingDepTasks);
2939 ✗ l_initLocksDae := initializeArrayLocks(Tpl.emptyTxt, ret_6, "_lockDae", Tpl.textString(a_type));
2940 ✗ ret_8 := listLength(i_daeSchedule_outgoingDepTasks);
2941 ✗ l_assignLocksDae := assignArrayLocks(Tpl.emptyTxt, ret_8, "_lockDae", Tpl.textString(a_type));
2942 ✗ ret_10 := listLength(i_zeroFuncSchedule_outgoingDepTasks);
2943 ✗ l_initLocksZeroFunc := initializeArrayLocks(Tpl.emptyTxt, ret_10, "_lockZeroFunc", Tpl.textString(a_type));
2944 ✗ ret_12 := listLength(i_zeroFuncSchedule_outgoingDepTasks);
2945 ✗ l_assignLocksZeroFunc := assignArrayLocks(Tpl.emptyTxt, ret_12, "_lockZeroFunc", Tpl.textString(a_type));
2946 ✗ str_13 := Tpl.textString(a_type);
2947 ✗ txt := fun_120(txt, str_13, l_assignLocksZeroFunc, l_assignLocksOde, l_assignLocksDae, l_initLocksZeroFunc, l_initLocksDae, l_initLocksOde, a_modelNamePrefixStr, a_type, i_odeSchedule_threadTasks);
2948 then txt;
2949
2950 case ( txt,
2951 SOME((HpcOmSimCode.TASKDEPSCHEDULE(tasks = i_odeSchedule_tasks), HpcOmSimCode.TASKDEPSCHEDULE(tasks = i_daeSchedule_tasks), HpcOmSimCode.TASKDEPSCHEDULE(tasks = i_zeroFuncSchedule_tasks))),
2952 _,
2953 a_modelNamePrefixStr,
2954 a_type )
2955 algorithm
2956 ✗ str_14 := Tpl.textString(a_type);
2957 ✗ txt := fun_121(txt, str_14, a_modelNamePrefixStr, i_zeroFuncSchedule_tasks, i_daeSchedule_tasks, i_odeSchedule_tasks);
2958 then txt;
2959
2960 case ( txt,
2961 _,
2962 _,
2963 _,
2964 _ )
2965 then txt;
2966 end match;
2967 end fun_122;
2968
2969 public function additionalHpcomConstructorBodyStatements
2970 input Tpl.Text txt;
2971 input Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> a_schedulesOpt;
2972 input String a_modelNamePrefixStr;
2973 input String a_fullModelName;
2974
2975 output Tpl.Text out_txt;
2976 protected
2977 Tpl.Text l_schedulerSpecificReturn;
2978 Boolean ret_5;
2979 Boolean ret_4;
2980 String ret_3;
2981 Tpl.Text l_threadMeasureTimeBlocks;
2982 String ret_1;
2983 Tpl.Text l_type;
2984 algorithm
2985 1 ret_1 := Flags.getConfigString(Flags.HPCOM_CODE);
2986 1 l_type := Tpl.writeStr(Tpl.emptyTxt, ret_1);
2987 1 ret_3 := Flags.getConfigString(Flags.PROFILING_LEVEL);
2988
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 ret_4 := stringEq(ret_3, "none");
2989 1 ret_5 := boolNot(ret_4);
2990 1 l_threadMeasureTimeBlocks := fun_102(Tpl.emptyTxt, ret_5, a_fullModelName);
2991 1 l_schedulerSpecificReturn := fun_122(Tpl.emptyTxt, a_schedulesOpt, a_fullModelName, a_modelNamePrefixStr, l_type);
2992 1 out_txt := Tpl.writeText(txt, l_schedulerSpecificReturn);
2993 1 out_txt := Tpl.softNewLine(out_txt);
2994 1 out_txt := Tpl.writeText(out_txt, l_threadMeasureTimeBlocks);
2995 end additionalHpcomConstructorBodyStatements;
2996
2997 protected function lm_124
2998 input output Tpl.Text txt;
2999 input list<Integer> items;
3000 algorithm
3001 ✗ for lstElt_124 in items loop
3002 txt := match lstElt_124
3003 local
3004 Integer i_threadIdx;
3005 Integer ret_0;
3006
3007 case i_threadIdx
3008 algorithm
3009 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("measuredSchedulerStartValues_"));
3010 ✗ ret_0 := intSub(i_threadIdx, 1);
3011 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
3012 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = MeasureTime::getZeroValues();"));
3013 ✗ txt := Tpl.nextIter(txt);
3014 then txt;
3015 end match;
3016 end for;
3017 end lm_124;
3018
3019 protected function lm_125
3020 input output Tpl.Text txt;
3021 input list<Integer> items;
3022 algorithm
3023 ✗ for lstElt_125 in items loop
3024 txt := match lstElt_125
3025 local
3026 Integer i_threadIdx;
3027 Integer ret_0;
3028
3029 case i_threadIdx
3030 algorithm
3031 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("measuredSchedulerEndValues_"));
3032 ✗ ret_0 := intSub(i_threadIdx, 1);
3033 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
3034 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = MeasureTime::getZeroValues();"));
3035 ✗ txt := Tpl.nextIter(txt);
3036 then txt;
3037 end match;
3038 end for;
3039 end lm_125;
3040
3041 protected function lm_126
3042 input output Tpl.Text txt;
3043 input list<Integer> items;
3044 algorithm
3045 ✗ for lstElt_126 in items loop
3046 txt := match lstElt_126
3047 local
3048 Integer i_threadIdx;
3049 Integer ret_0;
3050
3051 case i_threadIdx
3052 algorithm
3053 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("(*measureTimeThreadArrayOdeHpcom)["));
3054 ✗ ret_0 := intSub(i_threadIdx, 1);
3055 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
3056 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("] = new MeasureTimeData(\"evaluateODE_thread_"));
3057 ✗ txt := Tpl.writeStr(txt, intString(i_threadIdx));
3058 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\");"));
3059 ✗ txt := Tpl.nextIter(txt);
3060 then txt;
3061 end match;
3062 end for;
3063 end lm_126;
3064
3065 protected function lm_127
3066 input output Tpl.Text txt;
3067 input list<Integer> items;
3068 algorithm
3069 ✗ for lstElt_127 in items loop
3070 txt := match lstElt_127
3071 local
3072 Integer i_threadIdx;
3073 Integer ret_0;
3074
3075 case i_threadIdx
3076 algorithm
3077 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("(*measureTimeThreadArrayDaeHpcom)["));
3078 ✗ ret_0 := intSub(i_threadIdx, 1);
3079 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
3080 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("] = new MeasureTimeData(\"evaluateDAE_thread_"));
3081 ✗ txt := Tpl.writeStr(txt, intString(i_threadIdx));
3082 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\");"));
3083 ✗ txt := Tpl.nextIter(txt);
3084 then txt;
3085 end match;
3086 end for;
3087 end lm_127;
3088
3089 protected function lm_128
3090 input output Tpl.Text txt;
3091 input list<Integer> items;
3092 algorithm
3093 ✗ for lstElt_128 in items loop
3094 txt := match lstElt_128
3095 local
3096 Integer i_threadIdx;
3097 Integer ret_0;
3098
3099 case i_threadIdx
3100 algorithm
3101 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("(*measureTimeThreadArrayZeroFuncHpcom)["));
3102 ✗ ret_0 := intSub(i_threadIdx, 1);
3103 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
3104 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("] = new MeasureTimeData(\"evaluateZeroFunc_thread_"));
3105 ✗ txt := Tpl.writeStr(txt, intString(i_threadIdx));
3106 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\");"));
3107 ✗ txt := Tpl.nextIter(txt);
3108 then txt;
3109 end match;
3110 end for;
3111 end lm_128;
3112
3113 public function generateThreadMeasureTimeDeclaration
3114 input Tpl.Text txt;
3115 input String a_fullModelName;
3116 input Integer a_numberOfThreads;
3117
3118 output Tpl.Text out_txt;
3119 protected
3120 list<Integer> ret_4;
3121 list<Integer> ret_3;
3122 list<Integer> ret_2;
3123 list<Integer> ret_1;
3124 list<Integer> ret_0;
3125 algorithm
3126 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
3127 "#ifdef MEASURETIME_MODELFUNCTIONS\n",
3128 "measureTimeThreadArrayOdeHpcom = new std::vector<MeasureTimeData*>(size_t("
3129 }, false));
3130 ✗ out_txt := Tpl.writeStr(out_txt, intString(a_numberOfThreads));
3131 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
3132 "), NULL);\n",
3133 "measureTimeThreadArrayDaeHpcom = new std::vector<MeasureTimeData*>(size_t("
3134 }, false));
3135 ✗ out_txt := Tpl.writeStr(out_txt, intString(a_numberOfThreads));
3136 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
3137 "), NULL);\n",
3138 "measureTimeThreadArrayZeroFuncHpcom = new std::vector<MeasureTimeData*>(size_t("
3139 }, false));
3140 ✗ out_txt := Tpl.writeStr(out_txt, intString(a_numberOfThreads));
3141 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
3142 "), NULL);\n",
3143 "MeasureTime::addResultContentBlock(\""
3144 }, false));
3145 ✗ out_txt := Tpl.writeStr(out_txt, a_fullModelName);
3146 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
3147 "\",\"evaluateODE_threads\",measureTimeThreadArrayOdeHpcom);\n",
3148 "MeasureTime::addResultContentBlock(\""
3149 }, false));
3150 ✗ out_txt := Tpl.writeStr(out_txt, a_fullModelName);
3151 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
3152 "\",\"evaluateDAE_threads\",measureTimeThreadArrayDaeHpcom);\n",
3153 "MeasureTime::addResultContentBlock(\""
3154 }, false));
3155 ✗ out_txt := Tpl.writeStr(out_txt, a_fullModelName);
3156 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE("\",\"evaluateZeroFunc_threads\",measureTimeThreadArrayZeroFuncHpcom);\n"));
3157 ✗ ret_0 := List.intRange(a_numberOfThreads);
3158 ✗ out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3159 ✗ out_txt := lm_124(out_txt, ret_0);
3160 ✗ out_txt := Tpl.popIter(out_txt);
3161 ✗ out_txt := Tpl.softNewLine(out_txt);
3162 ✗ ret_1 := List.intRange(a_numberOfThreads);
3163 ✗ out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3164 ✗ out_txt := lm_125(out_txt, ret_1);
3165 ✗ out_txt := Tpl.popIter(out_txt);
3166 ✗ out_txt := Tpl.softNewLine(out_txt);
3167 ✗ ret_2 := List.intRange(a_numberOfThreads);
3168 ✗ out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3169 ✗ out_txt := lm_126(out_txt, ret_2);
3170 ✗ out_txt := Tpl.popIter(out_txt);
3171 ✗ out_txt := Tpl.softNewLine(out_txt);
3172 ✗ ret_3 := List.intRange(a_numberOfThreads);
3173 ✗ out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3174 ✗ out_txt := lm_127(out_txt, ret_3);
3175 ✗ out_txt := Tpl.popIter(out_txt);
3176 ✗ out_txt := Tpl.softNewLine(out_txt);
3177 ✗ ret_4 := List.intRange(a_numberOfThreads);
3178 ✗ out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3179 ✗ out_txt := lm_128(out_txt, ret_4);
3180 ✗ out_txt := Tpl.popIter(out_txt);
3181 ✗ out_txt := Tpl.softNewLine(out_txt);
3182 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("#endif //MEASURETIME_MODELFUNCTIONS"));
3183 end generateThreadMeasureTimeDeclaration;
3184
3185 protected function fun_130
3186 input Tpl.Text in_txt;
3187 input String in_a_iType;
3188 input Integer in_a_numComms;
3189 input String in_a_lockName;
3190
3191 output Tpl.Text out_txt;
3192 algorithm
3193 out_txt :=
3194 match(in_txt, in_a_iType, in_a_numComms, in_a_lockName)
3195 local
3196 Tpl.Text txt;
3197 Integer a_numComms;
3198 String a_lockName;
3199
3200 case ( txt,
3201 "openmp",
3202 a_numComms,
3203 a_lockName )
3204 algorithm
3205 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("for(unsigned i=0;i<"));
3206 ✗ txt := Tpl.writeStr(txt, intString(a_numComms));
3207 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(";++i)\n"));
3208 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
3209 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("omp_init_lock(&"));
3210 ✗ txt := Tpl.writeStr(txt, a_lockName);
3211 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_[i]);"));
3212 ✗ txt := Tpl.popBlock(txt);
3213 then txt;
3214
3215 case ( txt,
3216 "pthreads",
3217 a_numComms,
3218 a_lockName )
3219 algorithm
3220 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("for(unsigned i=0;i<"));
3221 ✗ txt := Tpl.writeStr(txt, intString(a_numComms));
3222 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(";++i)\n"));
3223 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
3224 ✗ txt := Tpl.writeStr(txt, a_lockName);
3225 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_[i] = new alignedLock();"));
3226 ✗ txt := Tpl.popBlock(txt);
3227 then txt;
3228
3229 case ( txt,
3230 "pthreads_spin",
3231 a_numComms,
3232 a_lockName )
3233 algorithm
3234 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("for(unsigned i=0;i<"));
3235 ✗ txt := Tpl.writeStr(txt, intString(a_numComms));
3236 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(";++i)\n"));
3237 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
3238 ✗ txt := Tpl.writeStr(txt, a_lockName);
3239 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_[i] = new alignedSpinlock();"));
3240 ✗ txt := Tpl.popBlock(txt);
3241 then txt;
3242
3243 case ( txt,
3244 _,
3245 _,
3246 _ )
3247 algorithm
3248 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("//Unsupported parallel instrumentation"));
3249 then txt;
3250 end match;
3251 end fun_130;
3252
3253 public function initializeArrayLocks
3254 input Tpl.Text txt;
3255 input Integer a_numComms;
3256 input String a_lockName;
3257 input String a_iType;
3258
3259 output Tpl.Text out_txt;
3260 algorithm
3261 ✗ out_txt := fun_130(txt, a_iType, a_numComms, a_lockName);
3262 end initializeArrayLocks;
3263
3264 protected function fun_132
3265 input Tpl.Text in_txt;
3266 input String in_a_iType;
3267 input Integer in_a_numComms;
3268 input String in_a_lockName;
3269
3270 output Tpl.Text out_txt;
3271 algorithm
3272 out_txt :=
3273 match(in_txt, in_a_iType, in_a_numComms, in_a_lockName)
3274 local
3275 Tpl.Text txt;
3276 Integer a_numComms;
3277 String a_lockName;
3278
3279 case ( txt,
3280 "openmp",
3281 a_numComms,
3282 a_lockName )
3283 algorithm
3284 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("for(unsigned i=0;i<"));
3285 ✗ txt := Tpl.writeStr(txt, intString(a_numComms));
3286 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(";++i)\n"));
3287 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
3288 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("omp_set_lock(&"));
3289 ✗ txt := Tpl.writeStr(txt, a_lockName);
3290 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_[i]);"));
3291 ✗ txt := Tpl.popBlock(txt);
3292 then txt;
3293
3294 case ( txt,
3295 "pthreads",
3296 a_numComms,
3297 a_lockName )
3298 algorithm
3299 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("for(unsigned i=0;i<"));
3300 ✗ txt := Tpl.writeStr(txt, intString(a_numComms));
3301 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(";++i)\n"));
3302 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
3303 ✗ txt := Tpl.writeStr(txt, a_lockName);
3304 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_[i]->lock();"));
3305 ✗ txt := Tpl.popBlock(txt);
3306 then txt;
3307
3308 case ( txt,
3309 "pthreads_spin",
3310 a_numComms,
3311 a_lockName )
3312 algorithm
3313 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("for(unsigned i=0;i<"));
3314 ✗ txt := Tpl.writeStr(txt, intString(a_numComms));
3315 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(";++i)\n"));
3316 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
3317 ✗ txt := Tpl.writeStr(txt, a_lockName);
3318 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_[i]->lock();"));
3319 ✗ txt := Tpl.popBlock(txt);
3320 then txt;
3321
3322 case ( txt,
3323 _,
3324 _,
3325 _ )
3326 algorithm
3327 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("//Unsupported parallel instrumentation"));
3328 then txt;
3329 end match;
3330 end fun_132;
3331
3332 public function assignArrayLocks
3333 input Tpl.Text txt;
3334 input Integer a_numComms;
3335 input String a_lockName;
3336 input String a_iType;
3337
3338 output Tpl.Text out_txt;
3339 algorithm
3340 ✗ out_txt := fun_132(txt, a_iType, a_numComms, a_lockName);
3341 end assignArrayLocks;
3342
3343 protected function fun_134
3344 input Tpl.Text in_txt;
3345 input String in_a_iType;
3346 input Integer in_a_numComms;
3347 input String in_a_lockName;
3348
3349 output Tpl.Text out_txt;
3350 algorithm
3351 out_txt :=
3352 match(in_txt, in_a_iType, in_a_numComms, in_a_lockName)
3353 local
3354 Tpl.Text txt;
3355 Integer a_numComms;
3356 String a_lockName;
3357
3358 case ( txt,
3359 "openmp",
3360 a_numComms,
3361 a_lockName )
3362 algorithm
3363 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("omp_lock_t "));
3364 ✗ txt := Tpl.writeStr(txt, a_lockName);
3365 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_["));
3366 ✗ txt := Tpl.writeStr(txt, intString(a_numComms));
3367 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("];"));
3368 then txt;
3369
3370 case ( txt,
3371 "pthreads",
3372 a_numComms,
3373 a_lockName )
3374 algorithm
3375 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("alignedLock* "));
3376 ✗ txt := Tpl.writeStr(txt, a_lockName);
3377 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_["));
3378 ✗ txt := Tpl.writeStr(txt, intString(a_numComms));
3379 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("];"));
3380 then txt;
3381
3382 case ( txt,
3383 "pthreads_spin",
3384 a_numComms,
3385 a_lockName )
3386 algorithm
3387 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("alignedSpinlock* "));
3388 ✗ txt := Tpl.writeStr(txt, a_lockName);
3389 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_["));
3390 ✗ txt := Tpl.writeStr(txt, intString(a_numComms));
3391 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("];"));
3392 then txt;
3393
3394 case ( txt,
3395 _,
3396 _,
3397 _ )
3398 algorithm
3399 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("//Unsupported parallel instrumentation"));
3400 then txt;
3401 end match;
3402 end fun_134;
3403
3404 public function createLockArrayByName
3405 input Tpl.Text txt;
3406 input Integer a_numComms;
3407 input String a_lockName;
3408 input String a_iType;
3409
3410 output Tpl.Text out_txt;
3411 algorithm
3412 ✗ out_txt := fun_134(txt, a_iType, a_numComms, a_lockName);
3413 end createLockArrayByName;
3414
3415 protected function fun_136
3416 input Tpl.Text in_txt;
3417 input String in_a_iType;
3418 input Integer in_a_numComms;
3419 input String in_a_lockName;
3420
3421 output Tpl.Text out_txt;
3422 algorithm
3423 out_txt :=
3424 match(in_txt, in_a_iType, in_a_numComms, in_a_lockName)
3425 local
3426 Tpl.Text txt;
3427 Integer a_numComms;
3428 String a_lockName;
3429
3430 case ( txt,
3431 "openmp",
3432 a_numComms,
3433 a_lockName )
3434 algorithm
3435 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("for(unsigned i=0;i<"));
3436 ✗ txt := Tpl.writeStr(txt, intString(a_numComms));
3437 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(";++i)\n"));
3438 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
3439 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("omp_destroy_lock(&"));
3440 ✗ txt := Tpl.writeStr(txt, a_lockName);
3441 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_[i]);"));
3442 ✗ txt := Tpl.popBlock(txt);
3443 then txt;
3444
3445 case ( txt,
3446 "pthreads",
3447 a_numComms,
3448 a_lockName )
3449 algorithm
3450 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("for(unsigned i=0;i<"));
3451 ✗ txt := Tpl.writeStr(txt, intString(a_numComms));
3452 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(";++i)\n"));
3453 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
3454 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("delete "));
3455 ✗ txt := Tpl.writeStr(txt, a_lockName);
3456 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_[i];"));
3457 ✗ txt := Tpl.popBlock(txt);
3458 then txt;
3459
3460 case ( txt,
3461 "pthreads_spin",
3462 a_numComms,
3463 a_lockName )
3464 algorithm
3465 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("for(unsigned i=0;i<"));
3466 ✗ txt := Tpl.writeStr(txt, intString(a_numComms));
3467 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(";++i)\n"));
3468 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
3469 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("delete "));
3470 ✗ txt := Tpl.writeStr(txt, a_lockName);
3471 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_[i];"));
3472 ✗ txt := Tpl.popBlock(txt);
3473 then txt;
3474
3475 case ( txt,
3476 _,
3477 _,
3478 _ )
3479 algorithm
3480 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("//Unsupported parallel instrumentation"));
3481 then txt;
3482 end match;
3483 end fun_136;
3484
3485 public function destroyArrayLocks
3486 input Tpl.Text txt;
3487 input Integer a_numComms;
3488 input String a_lockName;
3489 input String a_iType;
3490
3491 output Tpl.Text out_txt;
3492 algorithm
3493 ✗ out_txt := fun_136(txt, a_iType, a_numComms, a_lockName);
3494 end destroyArrayLocks;
3495
3496 protected function fun_138
3497 input Tpl.Text in_txt;
3498 input String in_mArg;
3499
3500 output Tpl.Text out_txt;
3501 algorithm
3502 out_txt :=
3503 match(in_txt, in_mArg)
3504 local
3505 Tpl.Text txt;
3506
3507 case ( txt,
3508 "pthreads" )
3509 algorithm
3510 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
3511 "_simulationFinished = true;\n",
3512 "//_evaluateBarrier.wait();\n",
3513 "_levelBarrier.wait();\n",
3514 "//_evaluateBarrier.wait();\n",
3515 "_levelBarrier.wait();"
3516 }, false));
3517 then txt;
3518
3519 case ( txt,
3520 "pthreads_spin" )
3521 algorithm
3522 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
3523 "_simulationFinished = true;\n",
3524 "//_evaluateBarrier.wait();\n",
3525 "_levelBarrier.wait();\n",
3526 "//_evaluateBarrier.wait();\n",
3527 "_levelBarrier.wait();"
3528 }, false));
3529 then txt;
3530
3531 case ( txt,
3532 _ )
3533 then txt;
3534 end match;
3535 end fun_138;
3536
3537 protected function lm_139
3538 input output Tpl.Text txt;
3539 input list<list<HpcOmSimCode.Task>> items;
3540 input Tpl.Text a_type;
3541 algorithm
3542 ✗ for lstElt_139 in items loop
3543 txt := match lstElt_139
3544 local
3545 Integer x_i0;
3546
3547 case _
3548 algorithm
3549 ✗ x_i0 := Tpl.getIteri_i0(txt);
3550 ✗ txt := function_HPCOM_destroyThread(txt, intString(x_i0), Tpl.textString(a_type));
3551 ✗ txt := Tpl.nextIter(txt);
3552 then txt;
3553 end match;
3554 end for;
3555 end lm_139;
3556
3557 protected function lm_140
3558 input output Tpl.Text txt;
3559 input list<list<HpcOmSimCode.Task>> items;
3560 input Tpl.Text a_type;
3561 algorithm
3562 ✗ for lstElt_140 in items loop
3563 txt := match lstElt_140
3564 local
3565 Integer x_i0;
3566
3567 case _
3568 algorithm
3569 ✗ x_i0 := Tpl.getIteri_i0(txt);
3570 ✗ txt := destroyLockByLockName(txt, intString(x_i0), "th_lock", Tpl.textString(a_type));
3571 ✗ txt := Tpl.nextIter(txt);
3572 then txt;
3573 end match;
3574 end for;
3575 end lm_140;
3576
3577 protected function lm_141
3578 input output Tpl.Text txt;
3579 input list<list<HpcOmSimCode.Task>> items;
3580 input Tpl.Text a_type;
3581 algorithm
3582 ✗ for lstElt_141 in items loop
3583 txt := match lstElt_141
3584 local
3585 Integer x_i0;
3586
3587 case _
3588 algorithm
3589 ✗ x_i0 := Tpl.getIteri_i0(txt);
3590 ✗ txt := destroyLockByLockName(txt, intString(x_i0), "th_lock1", Tpl.textString(a_type));
3591 ✗ txt := Tpl.nextIter(txt);
3592 then txt;
3593 end match;
3594 end for;
3595 end lm_141;
3596
3597 protected function lm_142
3598 input output Tpl.Text txt;
3599 input list<list<HpcOmSimCode.Task>> items;
3600 input Tpl.Text a_type;
3601 algorithm
3602 ✗ for lstElt_142 in items loop
3603 txt := match lstElt_142
3604 local
3605 Integer x_i0;
3606
3607 case _
3608 algorithm
3609 ✗ x_i0 := Tpl.getIteri_i0(txt);
3610 ✗ txt := function_HPCOM_joinThread(txt, intString(x_i0), Tpl.textString(a_type));
3611 ✗ txt := Tpl.nextIter(txt);
3612 then txt;
3613 end match;
3614 end for;
3615 end lm_142;
3616
3617 protected function lm_143
3618 input output Tpl.Text txt;
3619 input list<list<HpcOmSimCode.Task>> items;
3620 input Tpl.Text a_type;
3621 algorithm
3622 ✗ for lstElt_143 in items loop
3623 txt := match lstElt_143
3624 local
3625 Integer x_i0;
3626
3627 case _
3628 algorithm
3629 ✗ x_i0 := Tpl.getIteri_i0(txt);
3630 ✗ txt := releaseLockByLockName(txt, intString(x_i0), "th_lock", Tpl.textString(a_type));
3631 ✗ txt := Tpl.nextIter(txt);
3632 then txt;
3633 end match;
3634 end for;
3635 end lm_143;
3636
3637 protected function fun_144
3638 input Tpl.Text in_txt;
3639 input String in_mArg;
3640 input Tpl.Text in_a_type;
3641 input array<list<HpcOmSimCode.Task>> in_a_odeSchedule_threadTasks;
3642 input Tpl.Text in_a_destroyLocksZeroFunc;
3643 input Tpl.Text in_a_destroyLocksDae;
3644 input Tpl.Text in_a_destroyLocksOde;
3645
3646 output Tpl.Text out_txt;
3647 algorithm
3648 out_txt :=
3649 match(in_txt, in_mArg, in_a_type, in_a_odeSchedule_threadTasks, in_a_destroyLocksZeroFunc, in_a_destroyLocksDae, in_a_destroyLocksOde)
3650 local
3651 Tpl.Text txt;
3652 Tpl.Text a_type;
3653 array<list<HpcOmSimCode.Task>> a_odeSchedule_threadTasks;
3654 Tpl.Text a_destroyLocksZeroFunc;
3655 Tpl.Text a_destroyLocksDae;
3656 Tpl.Text a_destroyLocksOde;
3657 list<list<HpcOmSimCode.Task>> ret_14;
3658 list<list<HpcOmSimCode.Task>> ret_13;
3659 Tpl.Text l_threadReleaseLocks;
3660 list<list<HpcOmSimCode.Task>> ret_11;
3661 list<list<HpcOmSimCode.Task>> ret_10;
3662 Tpl.Text l_joinThreads;
3663 list<list<HpcOmSimCode.Task>> ret_8;
3664 list<list<HpcOmSimCode.Task>> ret_7;
3665 Tpl.Text l_threadLocksDel1;
3666 list<list<HpcOmSimCode.Task>> ret_5;
3667 list<list<HpcOmSimCode.Task>> ret_4;
3668 Tpl.Text l_threadLocksDel;
3669 list<list<HpcOmSimCode.Task>> ret_2;
3670 list<list<HpcOmSimCode.Task>> ret_1;
3671 Tpl.Text l_destroyThreads;
3672
3673 case ( txt,
3674 "openmp",
3675 _,
3676 _,
3677 a_destroyLocksZeroFunc,
3678 a_destroyLocksDae,
3679 a_destroyLocksOde )
3680 algorithm
3681 ✗ txt := Tpl.writeText(txt, a_destroyLocksOde);
3682 ✗ txt := Tpl.softNewLine(txt);
3683 ✗ txt := Tpl.writeText(txt, a_destroyLocksDae);
3684 ✗ txt := Tpl.softNewLine(txt);
3685 ✗ txt := Tpl.writeText(txt, a_destroyLocksZeroFunc);
3686 then txt;
3687
3688 case ( txt,
3689 "mpi",
3690 _,
3691 _,
3692 _,
3693 _,
3694 _ )
3695 algorithm
3696 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("//MF: Destruct MPI related stuff - nothing at the moment."));
3697 then txt;
3698
3699 case ( txt,
3700 _,
3701 a_type,
3702 a_odeSchedule_threadTasks,
3703 a_destroyLocksZeroFunc,
3704 a_destroyLocksDae,
3705 a_destroyLocksOde )
3706 algorithm
3707 ✗ ret_1 := arrayList(a_odeSchedule_threadTasks);
3708 ✗ ret_2 := listRest(ret_1);
3709 ✗ l_destroyThreads := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3710 ✗ l_destroyThreads := lm_139(l_destroyThreads, ret_2, a_type);
3711 ✗ l_destroyThreads := Tpl.popIter(l_destroyThreads);
3712 ✗ ret_4 := arrayList(a_odeSchedule_threadTasks);
3713 ✗ ret_5 := listRest(ret_4);
3714 ✗ l_threadLocksDel := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3715 ✗ l_threadLocksDel := lm_140(l_threadLocksDel, ret_5, a_type);
3716 ✗ l_threadLocksDel := Tpl.popIter(l_threadLocksDel);
3717 ✗ ret_7 := arrayList(a_odeSchedule_threadTasks);
3718 ✗ ret_8 := listRest(ret_7);
3719 ✗ l_threadLocksDel1 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3720 ✗ l_threadLocksDel1 := lm_141(l_threadLocksDel1, ret_8, a_type);
3721 ✗ l_threadLocksDel1 := Tpl.popIter(l_threadLocksDel1);
3722 ✗ ret_10 := arrayList(a_odeSchedule_threadTasks);
3723 ✗ ret_11 := listRest(ret_10);
3724 ✗ l_joinThreads := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3725 ✗ l_joinThreads := lm_142(l_joinThreads, ret_11, a_type);
3726 ✗ l_joinThreads := Tpl.popIter(l_joinThreads);
3727 ✗ ret_13 := arrayList(a_odeSchedule_threadTasks);
3728 ✗ ret_14 := listRest(ret_13);
3729 ✗ l_threadReleaseLocks := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3730 ✗ l_threadReleaseLocks := lm_143(l_threadReleaseLocks, ret_14, a_type);
3731 ✗ l_threadReleaseLocks := Tpl.popIter(l_threadReleaseLocks);
3732 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("_terminateThreads = true;\n"));
3733 ✗ txt := Tpl.writeText(txt, l_threadReleaseLocks);
3734 ✗ txt := Tpl.softNewLine(txt);
3735 ✗ txt := Tpl.writeText(txt, l_joinThreads);
3736 ✗ txt := Tpl.softNewLine(txt);
3737 ✗ txt := Tpl.writeText(txt, a_destroyLocksOde);
3738 ✗ txt := Tpl.softNewLine(txt);
3739 ✗ txt := Tpl.writeText(txt, a_destroyLocksDae);
3740 ✗ txt := Tpl.softNewLine(txt);
3741 ✗ txt := Tpl.writeText(txt, a_destroyLocksZeroFunc);
3742 ✗ txt := Tpl.softNewLine(txt);
3743 ✗ txt := Tpl.writeText(txt, l_threadLocksDel);
3744 ✗ txt := Tpl.softNewLine(txt);
3745 ✗ txt := Tpl.writeText(txt, l_threadLocksDel1);
3746 ✗ txt := Tpl.softNewLine(txt);
3747 ✗ txt := Tpl.writeText(txt, l_destroyThreads);
3748 then txt;
3749 end match;
3750 end fun_144;
3751
3752 protected function fun_145
3753 input Tpl.Text in_txt;
3754 input String in_mArg;
3755
3756 output Tpl.Text out_txt;
3757 algorithm
3758 out_txt :=
3759 match(in_txt, in_mArg)
3760 local
3761 Tpl.Text txt;
3762
3763 case ( txt,
3764 "tbb" )
3765 algorithm
3766 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
3767 "for(std::vector<tbb::flow::continue_node<tbb::flow::continue_msg>* >::iterator it = _tbbNodeListOde.begin(); it != _tbbNodeListOde.end(); it++)\n",
3768 " delete *it;\n",
3769 "for(std::vector<tbb::flow::continue_node<tbb::flow::continue_msg>* >::iterator it = _tbbNodeListAll.begin(); it != _tbbNodeListAll.end(); it++)\n",
3770 " delete *it;\n",
3771 "for(std::vector<tbb::flow::continue_node<tbb::flow::continue_msg>* >::iterator it = _tbbNodeListZeroFunc.begin(); it != _tbbNodeListZeroFunc.end(); it++)\n",
3772 " delete *it;"
3773 }, false));
3774 then txt;
3775
3776 case ( txt,
3777 _ )
3778 then txt;
3779 end match;
3780 end fun_145;
3781
3782 protected function fun_146
3783 input Tpl.Text in_txt;
3784 input Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> in_a_schedulesOpt;
3785 input Tpl.Text in_a_type;
3786
3787 output Tpl.Text out_txt;
3788 algorithm
3789 out_txt :=
3790 match(in_txt, in_a_schedulesOpt, in_a_type)
3791 local
3792 Tpl.Text txt;
3793 Tpl.Text a_type;
3794 array<list<HpcOmSimCode.Task>> i_odeSchedule_threadTasks;
3795 list<HpcOmSimCode.Task> i_zeroFuncSchedule_outgoingDepTasks;
3796 list<HpcOmSimCode.Task> i_daeSchedule_outgoingDepTasks;
3797 list<HpcOmSimCode.Task> i_odeSchedule_outgoingDepTasks;
3798 String str_8;
3799 String str_7;
3800 Integer ret_6;
3801 Tpl.Text l_destroyLocksZeroFunc;
3802 Integer ret_4;
3803 Tpl.Text l_destroyLocksDae;
3804 Integer ret_2;
3805 Tpl.Text l_destroyLocksOde;
3806 String str_0;
3807
3808 case ( txt,
3809 SOME((HpcOmSimCode.LEVELSCHEDULE(useFixedAssignments = true), _, _)),
3810 a_type )
3811 algorithm
3812 1 str_0 := Tpl.textString(a_type);
3813 1 txt := fun_138(txt, str_0);
3814 then txt;
3815
3816 case ( txt,
3817 SOME((HpcOmSimCode.THREADSCHEDULE(outgoingDepTasks = i_odeSchedule_outgoingDepTasks, threadTasks = i_odeSchedule_threadTasks), HpcOmSimCode.THREADSCHEDULE(outgoingDepTasks = i_daeSchedule_outgoingDepTasks), HpcOmSimCode.THREADSCHEDULE(outgoingDepTasks = i_zeroFuncSchedule_outgoingDepTasks))),
3818 a_type )
3819 algorithm
3820 ✗ ret_2 := listLength(i_odeSchedule_outgoingDepTasks);
3821 ✗ l_destroyLocksOde := destroyArrayLocks(Tpl.emptyTxt, ret_2, "_lockOde", Tpl.textString(a_type));
3822 ✗ ret_4 := listLength(i_daeSchedule_outgoingDepTasks);
3823 ✗ l_destroyLocksDae := destroyArrayLocks(Tpl.emptyTxt, ret_4, "_lockDae", Tpl.textString(a_type));
3824 ✗ ret_6 := listLength(i_zeroFuncSchedule_outgoingDepTasks);
3825 ✗ l_destroyLocksZeroFunc := destroyArrayLocks(Tpl.emptyTxt, ret_6, "_lockZeroFunc", Tpl.textString(a_type));
3826 ✗ str_7 := Tpl.textString(a_type);
3827 ✗ txt := fun_144(txt, str_7, a_type, i_odeSchedule_threadTasks, l_destroyLocksZeroFunc, l_destroyLocksDae, l_destroyLocksOde);
3828 then txt;
3829
3830 case ( txt,
3831 SOME((HpcOmSimCode.TASKDEPSCHEDULE(tasks = _), _, _)),
3832 a_type )
3833 algorithm
3834 ✗ str_8 := Tpl.textString(a_type);
3835 ✗ txt := fun_145(txt, str_8);
3836 then txt;
3837
3838 case ( txt,
3839 _,
3840 _ )
3841 then txt;
3842 end match;
3843 end fun_146;
3844
3845 protected function lm_147
3846 input output Tpl.Text txt;
3847 input list<Integer> items;
3848 algorithm
3849
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 for lstElt_147 in items loop
3850 txt := match lstElt_147
3851 local
3852 Integer i_threadIdx;
3853 Integer ret_0;
3854
3855 case i_threadIdx
3856 algorithm
3857 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("delete measuredSchedulerStartValues_"));
3858 1 ret_0 := intSub(i_threadIdx, 1);
3859 1 txt := Tpl.writeStr(txt, intString(ret_0));
3860 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
3861 1 txt := Tpl.nextIter(txt);
3862 then txt;
3863 end match;
3864 end for;
3865 end lm_147;
3866
3867 protected function lm_148
3868 input output Tpl.Text txt;
3869 input list<Integer> items;
3870 algorithm
3871
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 for lstElt_148 in items loop
3872 txt := match lstElt_148
3873 local
3874 Integer i_threadIdx;
3875 Integer ret_0;
3876
3877 case i_threadIdx
3878 algorithm
3879 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("delete measuredSchedulerEndValues_"));
3880 1 ret_0 := intSub(i_threadIdx, 1);
3881 1 txt := Tpl.writeStr(txt, intString(ret_0));
3882 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
3883 1 txt := Tpl.nextIter(txt);
3884 then txt;
3885 end match;
3886 end for;
3887 end lm_148;
3888
3889 public function additionalHpcomDestructorBodyStatements
3890 input Tpl.Text txt;
3891 input Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> a_schedulesOpt;
3892
3893 output Tpl.Text out_txt;
3894 protected
3895 list<Integer> ret_6;
3896 Integer ret_5;
3897 list<Integer> ret_4;
3898 Integer ret_3;
3899 Tpl.Text l_schedulerSpecificCode;
3900 String ret_1;
3901 Tpl.Text l_type;
3902 algorithm
3903 1 ret_1 := Flags.getConfigString(Flags.HPCOM_CODE);
3904 1 l_type := Tpl.writeStr(Tpl.emptyTxt, ret_1);
3905 1 l_schedulerSpecificCode := fun_146(Tpl.emptyTxt, a_schedulesOpt, l_type);
3906 1 out_txt := Tpl.writeTok(txt, Tpl.ST_LINE("#ifdef MEASURETIME_MODELFUNCTIONS\n"));
3907 1 ret_3 := Flags.getConfigInt(Flags.NUM_PROC);
3908 1 ret_4 := List.intRange(ret_3);
3909 1 out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3910 1 out_txt := lm_147(out_txt, ret_4);
3911 1 out_txt := Tpl.popIter(out_txt);
3912 1 out_txt := Tpl.softNewLine(out_txt);
3913 1 ret_5 := Flags.getConfigInt(Flags.NUM_PROC);
3914 1 ret_6 := List.intRange(ret_5);
3915 1 out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3916 1 out_txt := lm_148(out_txt, ret_6);
3917 1 out_txt := Tpl.popIter(out_txt);
3918 1 out_txt := Tpl.softNewLine(out_txt);
3919 1 out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE("#endif //MEASURETIME_MODELFUNCTIONS\n"));
3920 1 out_txt := Tpl.writeText(out_txt, l_schedulerSpecificCode);
3921 end additionalHpcomDestructorBodyStatements;
3922
3923 protected function fun_150
3924 input Tpl.Text in_txt;
3925 input SimCode.SimCode in_a_simCode;
3926 input Tpl.Text in_a_extraFuncs;
3927 input Boolean in_a_useFlatArrayNotation;
3928 input Tpl.Text in_a_stateDerVectorName;
3929 input SimCodeFunction.Context in_a_context;
3930 input Tpl.Text in_a_extraFuncsNamespace;
3931 input Tpl.Text in_a_extraFuncsDecl;
3932 input list<SimCode.SimEqSystem> in_a_allEquationsPlusWhen;
3933
3934 output Tpl.Text out_txt;
3935 output Tpl.Text out_a_extraFuncs;
3936 output Tpl.Text out_a_stateDerVectorName;
3937 output Tpl.Text out_a_extraFuncsNamespace;
3938 output Tpl.Text out_a_extraFuncsDecl;
3939 algorithm
3940 (out_txt, out_a_extraFuncs, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl) :=
3941 match(in_txt, in_a_simCode, in_a_extraFuncs, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_context, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_allEquationsPlusWhen)
3942 local
3943 Tpl.Text txt;
3944 Tpl.Text a_extraFuncs;
3945 Boolean a_useFlatArrayNotation;
3946 Tpl.Text a_stateDerVectorName;
3947 SimCodeFunction.Context a_context;
3948 Tpl.Text a_extraFuncsNamespace;
3949 Tpl.Text a_extraFuncsDecl;
3950 list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
3951 list<SimCode.ClockedPartition> i_clockedPartitions;
3952 list<SimCode.SimEqSystem> i_allEquations;
3953 Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> i_hpcomData_schedules;
3954 SimCode.SimCode i_simCode;
3955 Absyn.Path i_modelInfo_name;
3956 Boolean ret_6;
3957 Boolean ret_5;
3958 String ret_4;
3959 list<SimCode.SubPartition> ret_3;
3960 Tpl.Text txt_2;
3961 Tpl.Text l_parCode;
3962 Tpl.Text l_extraFuncsPar;
3963
3964 case ( txt,
3965 (i_simCode as SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(name = i_modelInfo_name), hpcomData = HpcOmSimCode.HPCOMDATA(schedules = i_hpcomData_schedules), allEquations = i_allEquations, clockedPartitions = i_clockedPartitions)),
3966 a_extraFuncs,
3967 a_useFlatArrayNotation,
3968 a_stateDerVectorName,
3969 a_context,
3970 a_extraFuncsNamespace,
3971 a_extraFuncsDecl,
3972 a_allEquationsPlusWhen )
3973 algorithm
3974 1 l_extraFuncsPar := Tpl.emptyTxt;
3975 1 txt_2 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, i_modelInfo_name);
3976 1 (l_parCode, l_extraFuncsPar, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := generateParallelEvaluate(Tpl.emptyTxt, a_allEquationsPlusWhen, i_modelInfo_name, i_simCode, l_extraFuncsPar, a_extraFuncsDecl, a_extraFuncsNamespace, i_hpcomData_schedules, a_context, a_stateDerVectorName, Tpl.textString(txt_2), a_useFlatArrayNotation);
3977 1 (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := CodegenCpp.equationFunctions(txt, i_allEquations, i_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, SimCodeFunction.contextSimulationDiscrete, a_stateDerVectorName, a_useFlatArrayNotation, false);
3978 1 txt := Tpl.softNewLine(txt);
3979 1 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
3980 1 (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := CodegenCpp.createEvaluateConditions(txt, i_allEquations, i_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, SimCodeFunction.contextOther, a_stateDerVectorName, a_useFlatArrayNotation);
3981 1 txt := Tpl.softNewLine(txt);
3982 1 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
3983 1 ret_3 := SimCodeCodegenUtil.getSubPartitions(i_clockedPartitions);
3984 1 ret_4 := Flags.getConfigString(Flags.PROFILING_LEVEL);
3985
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 ret_5 := stringEq(ret_4, "none");
3986 1 ret_6 := boolNot(ret_5);
3987 1 (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := CodegenCpp.clockedFunctions(txt, ret_3, i_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, SimCodeFunction.contextSimulationDiscrete, a_stateDerVectorName, a_useFlatArrayNotation, ret_6);
3988 1 txt := Tpl.softNewLine(txt);
3989 1 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
3990 1 txt := Tpl.writeText(txt, l_parCode);
3991 1 txt := Tpl.softNewLine(txt);
3992 1 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
3993 1 txt := Tpl.writeText(txt, l_extraFuncsPar);
3994 1 then (txt, a_extraFuncs, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl);
3995
3996 case ( txt,
3997 _,
3998 a_extraFuncs,
3999 _,
4000 a_stateDerVectorName,
4001 _,
4002 a_extraFuncsNamespace,
4003 a_extraFuncsDecl,
4004 _ )
4005 then (txt, a_extraFuncs, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl);
4006 end match;
4007 end fun_150;
4008
4009 public function updateHpcom
4010 input Tpl.Text txt;
4011 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
4012 input SimCode.SimCode a_simCode;
4013 input Tpl.Text a_extraFuncs;
4014 input Tpl.Text a_extraFuncsDecl;
4015 input Tpl.Text a_extraFuncsNamespace;
4016 input SimCodeFunction.Context a_context;
4017 input Tpl.Text a_stateDerVectorName;
4018 input Boolean a_useFlatArrayNotation;
4019
4020 output Tpl.Text out_txt;
4021 output Tpl.Text out_a_extraFuncs;
4022 output Tpl.Text out_a_extraFuncsDecl;
4023 output Tpl.Text out_a_extraFuncsNamespace;
4024 output Tpl.Text out_a_stateDerVectorName;
4025 protected
4026 Tpl.Text l_varDecls;
4027 algorithm
4028 l_varDecls := Tpl.emptyTxt;
4029 1 (out_txt, out_a_extraFuncs, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl) := fun_150(txt, a_simCode, a_extraFuncs, a_useFlatArrayNotation, a_stateDerVectorName, a_context, a_extraFuncsNamespace, a_extraFuncsDecl, a_allEquationsPlusWhen);
4030 end updateHpcom;
4031
4032 protected function fun_152
4033 input Tpl.Text in_txt;
4034 input Boolean in_mArg;
4035
4036 output Tpl.Text out_txt;
4037 algorithm
4038 out_txt :=
4039 match(in_txt, in_mArg)
4040 local
4041 Tpl.Text txt;
4042
4043 case ( txt,
4044 false )
4045 then txt;
4046
4047 case ( txt,
4048 _ )
4049 algorithm
4050 ✗ txt := CodegenCpp.generateMeasureTimeStartCode(txt, "measuredFunctionStartValues", "evaluateODE", "MEASURETIME_MODELFUNCTIONS");
4051 then txt;
4052 end match;
4053 end fun_152;
4054
4055 protected function fun_153
4056 input Tpl.Text in_txt;
4057 input Boolean in_mArg;
4058
4059 output Tpl.Text out_txt;
4060 algorithm
4061 out_txt :=
4062 match(in_txt, in_mArg)
4063 local
4064 Tpl.Text txt;
4065
4066 case ( txt,
4067 false )
4068 then txt;
4069
4070 case ( txt,
4071 _ )
4072 algorithm
4073 ✗ txt := CodegenCpp.generateMeasureTimeEndCode(txt, "measuredFunctionStartValues", "measuredFunctionEndValues", "(*measureTimeFunctionsArray)[0]", "evaluateODE", "MEASURETIME_MODELFUNCTIONS");
4074 then txt;
4075 end match;
4076 end fun_153;
4077
4078 protected function fun_154
4079 input Tpl.Text in_txt;
4080 input Boolean in_mArg;
4081
4082 output Tpl.Text out_txt;
4083 algorithm
4084 out_txt :=
4085 match(in_txt, in_mArg)
4086 local
4087 Tpl.Text txt;
4088
4089 case ( txt,
4090 false )
4091 then txt;
4092
4093 case ( txt,
4094 _ )
4095 algorithm
4096 ✗ txt := CodegenCpp.generateMeasureTimeStartCode(txt, "measuredFunctionStartValues", "evaluateAll", "MEASURETIME_MODELFUNCTIONS");
4097 then txt;
4098 end match;
4099 end fun_154;
4100
4101 protected function fun_155
4102 input Tpl.Text in_txt;
4103 input Boolean in_mArg;
4104
4105 output Tpl.Text out_txt;
4106 algorithm
4107 out_txt :=
4108 match(in_txt, in_mArg)
4109 local
4110 Tpl.Text txt;
4111
4112 case ( txt,
4113 false )
4114 then txt;
4115
4116 case ( txt,
4117 _ )
4118 algorithm
4119 ✗ txt := CodegenCpp.generateMeasureTimeEndCode(txt, "measuredFunctionStartValues", "measuredFunctionEndValues", "(*measureTimeFunctionsArray)[1]", "evaluateAll", "MEASURETIME_MODELFUNCTIONS");
4120 then txt;
4121 end match;
4122 end fun_155;
4123
4124 protected function fun_156
4125 input Tpl.Text in_txt;
4126 input Boolean in_mArg;
4127
4128 output Tpl.Text out_txt;
4129 algorithm
4130 out_txt :=
4131 match(in_txt, in_mArg)
4132 local
4133 Tpl.Text txt;
4134
4135 case ( txt,
4136 false )
4137 then txt;
4138
4139 case ( txt,
4140 _ )
4141 algorithm
4142 ✗ txt := CodegenCpp.generateMeasureTimeStartCode(txt, "measuredFunctionStartValues", "evaluateZeroFuncs", "MEASURETIME_MODELFUNCTIONS");
4143 then txt;
4144 end match;
4145 end fun_156;
4146
4147 protected function fun_157
4148 input Tpl.Text in_txt;
4149 input Boolean in_mArg;
4150
4151 output Tpl.Text out_txt;
4152 algorithm
4153 out_txt :=
4154 match(in_txt, in_mArg)
4155 local
4156 Tpl.Text txt;
4157
4158 case ( txt,
4159 false )
4160 then txt;
4161
4162 case ( txt,
4163 _ )
4164 algorithm
4165 ✗ txt := CodegenCpp.generateMeasureTimeEndCode(txt, "measuredFunctionStartValues", "measuredFunctionEndValues", "(*measureTimeFunctionsArray)[4]", "evaluateZeroFuncs", "MEASURETIME_MODELFUNCTIONS");
4166 then txt;
4167 end match;
4168 end fun_157;
4169
4170 protected function lm_158
4171 input output Tpl.Text txt;
4172 input list<HpcOmSimCode.TaskList> items;
4173 input Boolean a_useFlatArrayNotation;
4174 input Absyn.Path a_name;
4175 input output Tpl.Text a_extraFuncsDecl;
4176 input output Tpl.Text a_extraFuncs;
4177 input SimCode.SimCode a_simCode;
4178 input output Tpl.Text a_varDecls;
4179 input Tpl.Text a_type;
4180 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
4181 algorithm
4182 ✗ for lstElt_158 in items loop
4183 (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_158
4184 local
4185 HpcOmSimCode.TaskList i_tasks;
4186 Tpl.Text txt_0;
4187
4188 case i_tasks
4189 algorithm
4190 ✗ txt_0 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
4191 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_0) := generateLevelCodeForLevel(txt, a_allEquationsPlusWhen, i_tasks, Tpl.textString(a_type), a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_0, a_useFlatArrayNotation);
4192 ✗ txt := Tpl.nextIter(txt);
4193 then (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
4194 end match;
4195 end for;
4196 end lm_158;
4197
4198 protected function lm_159
4199 input output Tpl.Text txt;
4200 input list<HpcOmSimCode.TaskList> items;
4201 input Boolean a_useFlatArrayNotation;
4202 input Absyn.Path a_name;
4203 input output Tpl.Text a_extraFuncsDecl;
4204 input output Tpl.Text a_extraFuncs;
4205 input SimCode.SimCode a_simCode;
4206 input output Tpl.Text a_varDecls;
4207 input Tpl.Text a_type;
4208 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
4209 algorithm
4210 ✗ for lstElt_159 in items loop
4211 (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_159
4212 local
4213 HpcOmSimCode.TaskList i_tasks;
4214 Tpl.Text txt_0;
4215
4216 case i_tasks
4217 algorithm
4218 ✗ txt_0 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
4219 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_0) := generateLevelCodeForLevel(txt, a_allEquationsPlusWhen, i_tasks, Tpl.textString(a_type), a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_0, a_useFlatArrayNotation);
4220 ✗ txt := Tpl.nextIter(txt);
4221 then (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
4222 end match;
4223 end for;
4224 end lm_159;
4225
4226 protected function lm_160
4227 input output Tpl.Text txt;
4228 input list<HpcOmSimCode.TaskList> items;
4229 input Boolean a_useFlatArrayNotation;
4230 input Absyn.Path a_name;
4231 input output Tpl.Text a_extraFuncsDecl;
4232 input output Tpl.Text a_extraFuncs;
4233 input SimCode.SimCode a_simCode;
4234 input output Tpl.Text a_varDecls;
4235 input Tpl.Text a_type;
4236 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
4237 algorithm
4238 ✗ for lstElt_160 in items loop
4239 (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_160
4240 local
4241 HpcOmSimCode.TaskList i_tasks;
4242 Tpl.Text txt_0;
4243
4244 case i_tasks
4245 algorithm
4246 ✗ txt_0 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
4247 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_0) := generateLevelCodeForLevel(txt, a_allEquationsPlusWhen, i_tasks, Tpl.textString(a_type), a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_0, a_useFlatArrayNotation);
4248 ✗ txt := Tpl.nextIter(txt);
4249 then (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
4250 end match;
4251 end for;
4252 end lm_160;
4253
4254 protected function fun_161
4255 input Tpl.Text in_txt;
4256 input String in_mArg;
4257 input Tpl.Text in_a_type;
4258 input Tpl.Text in_a_functionHead;
4259 input Tpl.Text in_a_zeroFuncEqs;
4260 input Tpl.Text in_a_daeEqs;
4261 input Tpl.Text in_a_odeEqs;
4262 input Absyn.Path in_a_name;
4263 input Tpl.Text in_a_extraFuncsDecl;
4264
4265 output Tpl.Text out_txt;
4266 output Tpl.Text out_a_extraFuncsDecl;
4267 algorithm
4268 (out_txt, out_a_extraFuncsDecl) :=
4269 match(in_txt, in_mArg, in_a_type, in_a_functionHead, in_a_zeroFuncEqs, in_a_daeEqs, in_a_odeEqs, in_a_name, in_a_extraFuncsDecl)
4270 local
4271 Tpl.Text txt;
4272 Tpl.Text a_type;
4273 Tpl.Text a_functionHead;
4274 Tpl.Text a_zeroFuncEqs;
4275 Tpl.Text a_daeEqs;
4276 Tpl.Text a_odeEqs;
4277 Absyn.Path a_name;
4278 Tpl.Text a_extraFuncsDecl;
4279 Integer ret_2;
4280 Integer ret_1;
4281 Integer ret_0;
4282
4283 case ( txt,
4284 "openmp",
4285 _,
4286 a_functionHead,
4287 a_zeroFuncEqs,
4288 a_daeEqs,
4289 a_odeEqs,
4290 a_name,
4291 a_extraFuncsDecl )
4292 algorithm
4293 ✗ a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING_LIST({
4294 "void evaluateODE_Parallel();\n",
4295 "void evaluateAll_Parallel();\n",
4296 "void evaluateZeroFuncs_Parallel();"
4297 }, false));
4298 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("void "));
4299 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
4300 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4301 "::evaluateODE_Parallel()\n",
4302 "{\n"
4303 }, true));
4304 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4305 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#pragma omp parallel num_threads("));
4306 ✗ ret_0 := Flags.getConfigInt(Flags.NUM_PROC);
4307 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
4308 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4309 ")\n",
4310 "{\n"
4311 }, true));
4312 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4313 ✗ txt := Tpl.writeText(txt, a_odeEqs);
4314 ✗ txt := Tpl.softNewLine(txt);
4315 ✗ txt := Tpl.popBlock(txt);
4316 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
4317 ✗ txt := Tpl.popBlock(txt);
4318 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4319 "}\n",
4320 "\n",
4321 "void "
4322 }, false));
4323 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
4324 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4325 "::evaluateAll_Parallel()\n",
4326 "{\n"
4327 }, true));
4328 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4329 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#pragma omp parallel num_threads("));
4330 ✗ ret_1 := Flags.getConfigInt(Flags.NUM_PROC);
4331 ✗ txt := Tpl.writeStr(txt, intString(ret_1));
4332 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4333 ")\n",
4334 "{\n"
4335 }, true));
4336 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4337 ✗ txt := Tpl.writeText(txt, a_daeEqs);
4338 ✗ txt := Tpl.softNewLine(txt);
4339 ✗ txt := Tpl.popBlock(txt);
4340 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
4341 ✗ txt := Tpl.popBlock(txt);
4342 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4343 "}\n",
4344 "\n",
4345 "void "
4346 }, false));
4347 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
4348 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4349 "::evaluateZeroFuncs_Parallel()\n",
4350 "{\n"
4351 }, true));
4352 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4353 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#pragma omp parallel num_threads("));
4354 ✗ ret_2 := Flags.getConfigInt(Flags.NUM_PROC);
4355 ✗ txt := Tpl.writeStr(txt, intString(ret_2));
4356 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4357 ")\n",
4358 "{\n"
4359 }, true));
4360 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4361 ✗ txt := Tpl.writeText(txt, a_zeroFuncEqs);
4362 ✗ txt := Tpl.softNewLine(txt);
4363 ✗ txt := Tpl.popBlock(txt);
4364 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
4365 ✗ txt := Tpl.popBlock(txt);
4366 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4367 "}\n",
4368 "\n"
4369 }, true));
4370 ✗ txt := Tpl.writeText(txt, a_functionHead);
4371 ✗ txt := Tpl.softNewLine(txt);
4372 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4373 "{\n",
4374 " this->_evaluateMode = _evaluateMode;\n",
4375 " this->_command = command;\n",
4376 " if(evaluateMode == 0)\n",
4377 " {\n",
4378 " evaluateODE_Parallel();\n",
4379 " }\n",
4380 " else if(evaluateMode < 0)\n",
4381 " {\n",
4382 " evaluateAll_Parallel();\n",
4383 " }\n",
4384 " else\n",
4385 " {\n",
4386 " evaluateZeroFuncs_Parallel();\n",
4387 " }\n",
4388 "}"
4389 }, false));
4390 then (txt, a_extraFuncsDecl);
4391
4392 case ( txt,
4393 _,
4394 a_type,
4395 a_functionHead,
4396 _,
4397 _,
4398 _,
4399 _,
4400 a_extraFuncsDecl )
4401 algorithm
4402 ✗ txt := Tpl.writeText(txt, a_functionHead);
4403 ✗ txt := Tpl.softNewLine(txt);
4404 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("{\n"));
4405 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4406 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("throw std::runtime_error(\"Type "));
4407 ✗ txt := Tpl.writeText(txt, a_type);
4408 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(" is unsupported for level scheduling.\");\n"));
4409 ✗ txt := Tpl.popBlock(txt);
4410 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
4411 then (txt, a_extraFuncsDecl);
4412 end match;
4413 end fun_161;
4414
4415 protected function lm_162
4416 input output Tpl.Text txt;
4417 input list<array<list<HpcOmSimCode.Task>>> items;
4418 input Boolean a_useFlatArrayNotation;
4419 input output Tpl.Text a_extraFuncsDecl;
4420 input output Tpl.Text a_extraFuncs;
4421 input SimCode.SimCode a_simCode;
4422 input Absyn.Path a_name;
4423 input output Tpl.Text a_varDecls;
4424 input Tpl.Text a_type;
4425 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
4426 algorithm
4427 ✗ for lstElt_162 in items loop
4428 (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_162
4429 local
4430 array<list<HpcOmSimCode.Task>> i_tasks;
4431 Tpl.Text txt_0;
4432
4433 case i_tasks
4434 algorithm
4435 ✗ txt_0 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
4436 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_0) := generateLevelFixedCodeForLevel(txt, a_allEquationsPlusWhen, i_tasks, Tpl.textString(a_type), a_varDecls, a_name, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_0, a_useFlatArrayNotation);
4437 ✗ txt := Tpl.nextIter(txt);
4438 then (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
4439 end match;
4440 end for;
4441 end lm_162;
4442
4443 protected function lm_163
4444 input output Tpl.Text txt;
4445 input list<array<list<HpcOmSimCode.Task>>> items;
4446 input Boolean a_useFlatArrayNotation;
4447 input output Tpl.Text a_extraFuncsDecl;
4448 input output Tpl.Text a_extraFuncs;
4449 input SimCode.SimCode a_simCode;
4450 input Absyn.Path a_name;
4451 input output Tpl.Text a_varDecls;
4452 input Tpl.Text a_type;
4453 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
4454 algorithm
4455 ✗ for lstElt_163 in items loop
4456 (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_163
4457 local
4458 array<list<HpcOmSimCode.Task>> i_tasks;
4459 Tpl.Text txt_0;
4460
4461 case i_tasks
4462 algorithm
4463 ✗ txt_0 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
4464 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_0) := generateLevelFixedCodeForLevel(txt, a_allEquationsPlusWhen, i_tasks, Tpl.textString(a_type), a_varDecls, a_name, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_0, a_useFlatArrayNotation);
4465 ✗ txt := Tpl.nextIter(txt);
4466 then (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
4467 end match;
4468 end for;
4469 end lm_163;
4470
4471 protected function lm_164
4472 input output Tpl.Text txt;
4473 input list<array<list<HpcOmSimCode.Task>>> items;
4474 input Boolean a_useFlatArrayNotation;
4475 input output Tpl.Text a_extraFuncsDecl;
4476 input output Tpl.Text a_extraFuncs;
4477 input SimCode.SimCode a_simCode;
4478 input Absyn.Path a_name;
4479 input output Tpl.Text a_varDecls;
4480 input Tpl.Text a_type;
4481 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
4482 algorithm
4483 ✗ for lstElt_164 in items loop
4484 (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_164
4485 local
4486 array<list<HpcOmSimCode.Task>> i_tasks;
4487 Tpl.Text txt_0;
4488
4489 case i_tasks
4490 algorithm
4491 ✗ txt_0 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
4492 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_0) := generateLevelFixedCodeForLevel(txt, a_allEquationsPlusWhen, i_tasks, Tpl.textString(a_type), a_varDecls, a_name, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_0, a_useFlatArrayNotation);
4493 ✗ txt := Tpl.nextIter(txt);
4494 then (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
4495 end match;
4496 end for;
4497 end lm_164;
4498
4499 protected function lm_165
4500 input output Tpl.Text txt;
4501 input list<tuple<list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>>> items;
4502 input Boolean a_useFlatArrayNotation;
4503 input output Tpl.Text a_extraFuncsDecl;
4504 input output Tpl.Text a_extraFuncs;
4505 input SimCode.SimCode a_simCode;
4506 input Absyn.Path a_name;
4507 input output Tpl.Text a_varDecls;
4508 input Tpl.Text a_type;
4509 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
4510 algorithm
4511
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 for lstElt_165 in items loop
4512 (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_165
4513 local
4514 Integer x_i0;
4515 tuple<list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>> i_tasks;
4516 Tpl.Text txt_0;
4517
4518 case i_tasks
4519 algorithm
4520 1 x_i0 := Tpl.getIteri_i0(txt);
4521 1 txt_0 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
4522 1 (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_0) := generateLevelFixedCodeForThread(txt, a_allEquationsPlusWhen, i_tasks, x_i0, Tpl.textString(a_type), a_varDecls, a_name, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_0, a_useFlatArrayNotation);
4523 1 txt := Tpl.nextIter(txt);
4524 then (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
4525 end match;
4526 end for;
4527 end lm_165;
4528
4529 protected function lm_166
4530 input output Tpl.Text txt;
4531 input list<Integer> items;
4532 input Tpl.Text a_type;
4533 algorithm
4534
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 for lstElt_166 in items loop
4535 txt := match lstElt_166
4536 local
4537 Integer i_tt;
4538 Tpl.Text txt_0;
4539
4540 case i_tt
4541 algorithm
4542 1 txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("threadLock"));
4543 1 txt_0 := Tpl.writeStr(txt_0, intString(i_tt));
4544 1 txt := createLockByLockName(txt, Tpl.textString(txt_0), "", Tpl.textString(a_type));
4545 1 txt := Tpl.nextIter(txt);
4546 then txt;
4547 end match;
4548 end for;
4549 end lm_166;
4550
4551 protected function lm_167
4552 input output Tpl.Text txt;
4553 input list<tuple<list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>>> items;
4554 input Boolean a_useFlatArrayNotation;
4555 input output Tpl.Text a_extraFuncsDecl;
4556 input output Tpl.Text a_extraFuncs;
4557 input SimCode.SimCode a_simCode;
4558 input Absyn.Path a_name;
4559 input output Tpl.Text a_varDecls;
4560 input Tpl.Text a_type;
4561 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
4562 algorithm
4563 ✗ for lstElt_167 in items loop
4564 (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_167
4565 local
4566 Integer x_i0;
4567 tuple<list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>> i_tasks;
4568 Tpl.Text txt_0;
4569
4570 case i_tasks
4571 algorithm
4572 ✗ x_i0 := Tpl.getIteri_i0(txt);
4573 ✗ txt_0 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
4574 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_0) := generateLevelFixedCodeForThread(txt, a_allEquationsPlusWhen, i_tasks, x_i0, Tpl.textString(a_type), a_varDecls, a_name, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_0, a_useFlatArrayNotation);
4575 ✗ txt := Tpl.nextIter(txt);
4576 then (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
4577 end match;
4578 end for;
4579 end lm_167;
4580
4581 protected function lm_168
4582 input output Tpl.Text txt;
4583 input list<Integer> items;
4584 input Tpl.Text a_type;
4585 algorithm
4586 ✗ for lstElt_168 in items loop
4587 txt := match lstElt_168
4588 local
4589 Integer i_tt;
4590 Tpl.Text txt_0;
4591
4592 case i_tt
4593 algorithm
4594 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("threadLock"));
4595 ✗ txt_0 := Tpl.writeStr(txt_0, intString(i_tt));
4596 ✗ txt := createLockByLockName(txt, Tpl.textString(txt_0), "", Tpl.textString(a_type));
4597 ✗ txt := Tpl.nextIter(txt);
4598 then txt;
4599 end match;
4600 end for;
4601 end lm_168;
4602
4603 protected function fun_169
4604 input Tpl.Text in_txt;
4605 input String in_mArg;
4606 input Tpl.Text in_a_extraFuncsNamespace;
4607 input Tpl.Text in_a_functionHead;
4608 input HpcOmSimCode.Schedule in_a_zeroFuncSchedule;
4609 input HpcOmSimCode.Schedule in_a_daeSchedule;
4610 input Boolean in_a_useFlatArrayNotation;
4611 input Tpl.Text in_a_extraFuncsDecl;
4612 input Tpl.Text in_a_extraFuncs;
4613 input SimCode.SimCode in_a_simCode;
4614 input Absyn.Path in_a_name;
4615 input Tpl.Text in_a_varDecls;
4616 input Tpl.Text in_a_type;
4617 input list<SimCode.SimEqSystem> in_a_allEquationsPlusWhen;
4618 input HpcOmSimCode.Schedule in_a_odeSchedule;
4619
4620 output Tpl.Text out_txt;
4621 output Tpl.Text out_a_extraFuncsNamespace;
4622 output Tpl.Text out_a_extraFuncsDecl;
4623 output Tpl.Text out_a_extraFuncs;
4624 output Tpl.Text out_a_varDecls;
4625 algorithm
4626 (out_txt, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls) :=
4627 match(in_txt, in_mArg, in_a_extraFuncsNamespace, in_a_functionHead, in_a_zeroFuncSchedule, in_a_daeSchedule, in_a_useFlatArrayNotation, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_name, in_a_varDecls, in_a_type, in_a_allEquationsPlusWhen, in_a_odeSchedule)
4628 local
4629 Tpl.Text txt;
4630 Tpl.Text a_extraFuncsNamespace;
4631 Tpl.Text a_functionHead;
4632 HpcOmSimCode.Schedule a_zeroFuncSchedule;
4633 HpcOmSimCode.Schedule a_daeSchedule;
4634 Boolean a_useFlatArrayNotation;
4635 Tpl.Text a_extraFuncsDecl;
4636 Tpl.Text a_extraFuncs;
4637 SimCode.SimCode a_simCode;
4638 Absyn.Path a_name;
4639 Tpl.Text a_varDecls;
4640 Tpl.Text a_type;
4641 list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
4642 HpcOmSimCode.Schedule a_odeSchedule;
4643 list<Integer> ret_23;
4644 Integer ret_22;
4645 list<tuple<list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>>> ret_21;
4646 array<tuple<list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>>> ret_20;
4647 Integer ret_19;
4648 list<Integer> ret_18;
4649 Integer ret_17;
4650 Tpl.Text l_threadLocks;
4651 list<tuple<list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>>> ret_15;
4652 array<tuple<list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>>> ret_14;
4653 Integer ret_13;
4654 Tpl.Text l_eqsFuncs;
4655 Integer ret_11;
4656 Integer ret_10;
4657 Integer ret_9;
4658 list<array<list<HpcOmSimCode.Task>>> ret_8;
4659 Integer ret_7;
4660 Tpl.Text l_zeroFuncEqs;
4661 list<array<list<HpcOmSimCode.Task>>> ret_5;
4662 Integer ret_4;
4663 Tpl.Text l_daeEqs;
4664 list<array<list<HpcOmSimCode.Task>>> ret_2;
4665 Integer ret_1;
4666 Tpl.Text l_odeEqs;
4667
4668 case ( txt,
4669 "openmp",
4670 a_extraFuncsNamespace,
4671 a_functionHead,
4672 a_zeroFuncSchedule,
4673 a_daeSchedule,
4674 a_useFlatArrayNotation,
4675 a_extraFuncsDecl,
4676 a_extraFuncs,
4677 a_simCode,
4678 a_name,
4679 a_varDecls,
4680 a_type,
4681 a_allEquationsPlusWhen,
4682 a_odeSchedule )
4683 algorithm
4684 ✗ ret_1 := Flags.getConfigInt(Flags.NUM_PROC);
4685 ✗ ret_2 := HpcOmCodegenUtil.convertFixedLevelScheduleToLevelThreadLists(a_odeSchedule, ret_1);
4686 ✗ l_odeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
4687 ✗ (l_odeEqs, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_162(l_odeEqs, ret_2, a_useFlatArrayNotation, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_name, a_varDecls, a_type, a_allEquationsPlusWhen);
4688 ✗ l_odeEqs := Tpl.popIter(l_odeEqs);
4689 ✗ ret_4 := Flags.getConfigInt(Flags.NUM_PROC);
4690 ✗ ret_5 := HpcOmCodegenUtil.convertFixedLevelScheduleToLevelThreadLists(a_daeSchedule, ret_4);
4691 ✗ l_daeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
4692 ✗ (l_daeEqs, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_163(l_daeEqs, ret_5, a_useFlatArrayNotation, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_name, a_varDecls, a_type, a_allEquationsPlusWhen);
4693 ✗ l_daeEqs := Tpl.popIter(l_daeEqs);
4694 ✗ ret_7 := Flags.getConfigInt(Flags.NUM_PROC);
4695 ✗ ret_8 := HpcOmCodegenUtil.convertFixedLevelScheduleToLevelThreadLists(a_zeroFuncSchedule, ret_7);
4696 ✗ l_zeroFuncEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
4697 ✗ (l_zeroFuncEqs, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_164(l_zeroFuncEqs, ret_8, a_useFlatArrayNotation, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_name, a_varDecls, a_type, a_allEquationsPlusWhen);
4698 ✗ l_zeroFuncEqs := Tpl.popIter(l_zeroFuncEqs);
4699 ✗ a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING_LIST({
4700 "void evaluateODE_Parallel();\n",
4701 "void evaluateAll_Parallel();\n",
4702 "void evaluateZeroFuncs_Parallel();"
4703 }, false));
4704 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("void "));
4705 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
4706 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4707 "::evaluateODE_Parallel()\n",
4708 "{\n"
4709 }, true));
4710 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4711 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#pragma omp parallel num_threads("));
4712 ✗ ret_9 := Flags.getConfigInt(Flags.NUM_PROC);
4713 ✗ txt := Tpl.writeStr(txt, intString(ret_9));
4714 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4715 ")\n",
4716 "{\n",
4717 " int threadNum = getThreadNumber();\n"
4718 }, true));
4719 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4720 ✗ txt := Tpl.writeText(txt, l_odeEqs);
4721 ✗ txt := Tpl.softNewLine(txt);
4722 ✗ txt := Tpl.popBlock(txt);
4723 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
4724 ✗ txt := Tpl.popBlock(txt);
4725 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4726 "}\n",
4727 "\n",
4728 "void "
4729 }, false));
4730 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
4731 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4732 "::evaluateAll_Parallel()\n",
4733 "{\n"
4734 }, true));
4735 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4736 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#pragma omp parallel num_threads("));
4737 ✗ ret_10 := Flags.getConfigInt(Flags.NUM_PROC);
4738 ✗ txt := Tpl.writeStr(txt, intString(ret_10));
4739 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4740 ")\n",
4741 "{\n",
4742 " int threadNum = getThreadNumber();\n"
4743 }, true));
4744 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4745 ✗ txt := Tpl.writeText(txt, l_daeEqs);
4746 ✗ txt := Tpl.softNewLine(txt);
4747 ✗ txt := Tpl.popBlock(txt);
4748 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
4749 ✗ txt := Tpl.popBlock(txt);
4750 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4751 "}\n",
4752 "\n",
4753 "void "
4754 }, false));
4755 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
4756 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4757 "::evaluateZeroFuncs_Parallel()\n",
4758 "{\n"
4759 }, true));
4760 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4761 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#pragma omp parallel num_threads("));
4762 ✗ ret_11 := Flags.getConfigInt(Flags.NUM_PROC);
4763 ✗ txt := Tpl.writeStr(txt, intString(ret_11));
4764 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4765 ")\n",
4766 "{\n",
4767 " int threadNum = getThreadNumber();\n"
4768 }, true));
4769 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4770 ✗ txt := Tpl.writeText(txt, l_zeroFuncEqs);
4771 ✗ txt := Tpl.softNewLine(txt);
4772 ✗ txt := Tpl.popBlock(txt);
4773 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
4774 ✗ txt := Tpl.popBlock(txt);
4775 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4776 "}\n",
4777 "\n"
4778 }, true));
4779 ✗ txt := Tpl.writeText(txt, a_functionHead);
4780 ✗ txt := Tpl.softNewLine(txt);
4781 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4782 "{\n",
4783 " this->_evaluateMode = _evaluateMode;\n",
4784 " this->_command = command;\n",
4785 " if(evaluateMode == 0)\n",
4786 " {\n",
4787 " evaluateODE_Parallel();\n",
4788 " }\n",
4789 " else if(evaluateMode < 0)\n",
4790 " {\n",
4791 " evaluateAll_Parallel();\n",
4792 " }\n",
4793 " else\n",
4794 " {\n",
4795 " evaluateZeroFuncs_Parallel();\n",
4796 " }\n",
4797 "}"
4798 }, false));
4799 ✗ then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
4800
4801 case ( txt,
4802 "pthreads",
4803 a_extraFuncsNamespace,
4804 a_functionHead,
4805 a_zeroFuncSchedule,
4806 a_daeSchedule,
4807 a_useFlatArrayNotation,
4808 a_extraFuncsDecl,
4809 a_extraFuncs,
4810 a_simCode,
4811 a_name,
4812 a_varDecls,
4813 a_type,
4814 a_allEquationsPlusWhen,
4815 a_odeSchedule )
4816 algorithm
4817 1 ret_13 := Flags.getConfigInt(Flags.NUM_PROC);
4818 1 ret_14 := HpcOmCodegenUtil.convertFixedLevelScheduleToTaskLists(a_odeSchedule, a_daeSchedule, a_zeroFuncSchedule, ret_13);
4819 1 ret_15 := arrayList(ret_14);
4820 1 l_eqsFuncs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
4821 1 (l_eqsFuncs, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_165(l_eqsFuncs, ret_15, a_useFlatArrayNotation, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_name, a_varDecls, a_type, a_allEquationsPlusWhen);
4822 1 l_eqsFuncs := Tpl.popIter(l_eqsFuncs);
4823 1 ret_17 := Flags.getConfigInt(Flags.NUM_PROC);
4824 1 ret_18 := List.intRange(ret_17);
4825 1 l_threadLocks := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
4826 1 l_threadLocks := lm_166(l_threadLocks, ret_18, a_type);
4827 1 l_threadLocks := Tpl.popIter(l_threadLocks);
4828 1 txt := Tpl.writeText(txt, l_eqsFuncs);
4829 1 txt := Tpl.softNewLine(txt);
4830 1 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
4831 1 txt := Tpl.writeText(txt, a_functionHead);
4832 1 txt := Tpl.softNewLine(txt);
4833 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4834 "{\n",
4835 " this->_command = command;\n",
4836 " this->_evaluateMode = evaluateMode;\n",
4837 "\n",
4838 " if(evaluateMode == 0) //evaluate ODE\n",
4839 " {\n",
4840 " _levelBarrier.wait();\n",
4841 " evaluateThreadFuncODE_0();\n",
4842 " _levelBarrier.wait();\n",
4843 "\n"
4844 }, true));
4845 1 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
4846 1 (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := generateStateVarPrefetchCode(txt, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
4847 1 txt := Tpl.softNewLine(txt);
4848 1 txt := Tpl.popBlock(txt);
4849 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4850 " }\n",
4851 " else if(evaluateMode < 0) //evaluate All\n",
4852 " {\n",
4853 " _levelBarrier.wait();\n",
4854 " evaluateThreadFuncAll_0();\n",
4855 " _levelBarrier.wait();\n",
4856 " }\n",
4857 " else //evaluate ZeroFuncs\n",
4858 " {\n",
4859 " _levelBarrier.wait();\n",
4860 " evaluateThreadFuncZeroFunc_0();\n",
4861 " _levelBarrier.wait();\n",
4862 " }\n",
4863 "}"
4864 }, false));
4865 1 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
4866
4867 case ( txt,
4868 "pthreads_spin",
4869 a_extraFuncsNamespace,
4870 a_functionHead,
4871 a_zeroFuncSchedule,
4872 a_daeSchedule,
4873 a_useFlatArrayNotation,
4874 a_extraFuncsDecl,
4875 a_extraFuncs,
4876 a_simCode,
4877 a_name,
4878 a_varDecls,
4879 a_type,
4880 a_allEquationsPlusWhen,
4881 a_odeSchedule )
4882 algorithm
4883 ✗ ret_19 := Flags.getConfigInt(Flags.NUM_PROC);
4884 ✗ ret_20 := HpcOmCodegenUtil.convertFixedLevelScheduleToTaskLists(a_odeSchedule, a_daeSchedule, a_zeroFuncSchedule, ret_19);
4885 ✗ ret_21 := arrayList(ret_20);
4886 ✗ l_eqsFuncs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
4887 ✗ (l_eqsFuncs, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_167(l_eqsFuncs, ret_21, a_useFlatArrayNotation, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_name, a_varDecls, a_type, a_allEquationsPlusWhen);
4888 ✗ l_eqsFuncs := Tpl.popIter(l_eqsFuncs);
4889 ✗ ret_22 := Flags.getConfigInt(Flags.NUM_PROC);
4890 ✗ ret_23 := List.intRange(ret_22);
4891 ✗ l_threadLocks := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
4892 ✗ l_threadLocks := lm_168(l_threadLocks, ret_23, a_type);
4893 ✗ l_threadLocks := Tpl.popIter(l_threadLocks);
4894 ✗ txt := Tpl.writeText(txt, l_eqsFuncs);
4895 ✗ txt := Tpl.softNewLine(txt);
4896 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
4897 ✗ txt := Tpl.writeText(txt, a_functionHead);
4898 ✗ txt := Tpl.softNewLine(txt);
4899 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4900 "{\n",
4901 " this->_command = command;\n",
4902 " this->_evaluateMode = evaluateMode;\n",
4903 "\n",
4904 " if(evaluateMode == 0) //evaluate ODE\n",
4905 " {\n",
4906 " _levelBarrier.wait();\n",
4907 " evaluateThreadFuncODE_0();\n",
4908 " _levelBarrier.wait();\n",
4909 "\n"
4910 }, true));
4911 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
4912 ✗ (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := generateStateVarPrefetchCode(txt, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
4913 ✗ txt := Tpl.softNewLine(txt);
4914 ✗ txt := Tpl.popBlock(txt);
4915 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
4916 " }\n",
4917 " else if(evaluateMode < 0) //evaluate All\n",
4918 " {\n",
4919 " _levelBarrier.wait();\n",
4920 " evaluateThreadFuncAll_0();\n",
4921 " _levelBarrier.wait();\n",
4922 " }\n",
4923 " else //evaluate ZeroFuncs\n",
4924 " {\n",
4925 " _levelBarrier.wait();\n",
4926 " evaluateThreadFuncZeroFunc_0();\n",
4927 " _levelBarrier.wait();\n",
4928 " }\n",
4929 "}"
4930 }, false));
4931 ✗ then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
4932
4933 case ( txt,
4934 _,
4935 a_extraFuncsNamespace,
4936 a_functionHead,
4937 _,
4938 _,
4939 _,
4940 a_extraFuncsDecl,
4941 a_extraFuncs,
4942 _,
4943 _,
4944 a_varDecls,
4945 a_type,
4946 _,
4947 _ )
4948 algorithm
4949 ✗ txt := Tpl.writeText(txt, a_functionHead);
4950 ✗ txt := Tpl.softNewLine(txt);
4951 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("{\n"));
4952 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
4953 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("throw std::runtime_error(\"Type "));
4954 ✗ txt := Tpl.writeText(txt, a_type);
4955 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(" is unsupported for levelfix scheduling.\");\n"));
4956 ✗ txt := Tpl.popBlock(txt);
4957 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
4958 ✗ then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
4959 end match;
4960 end fun_169;
4961
4962 protected function lm_170
4963 input output Tpl.Text txt;
4964 input list<list<HpcOmSimCode.Task>> items;
4965 input Tpl.Text a_type;
4966 input array<list<HpcOmSimCode.Task>> a_threadTasksOde;
4967 algorithm
4968 ✗ for lstElt_170 in items loop
4969 txt := match lstElt_170
4970 local
4971 Integer x_i0;
4972 list<HpcOmSimCode.Task> ret_1;
4973 Integer ret_0;
4974
4975 case _
4976 algorithm
4977 ✗ x_i0 := Tpl.getIteri_i0(txt);
4978 ✗ ret_0 := intAdd(x_i0, 1);
4979 ✗ ret_1 := arrayGet(a_threadTasksOde, ret_0);
4980 ✗ txt := function_HPCOM_assignThreadLocks(txt, ret_1, "_lockOde", x_i0, Tpl.textString(a_type));
4981 ✗ txt := Tpl.nextIter(txt);
4982 then txt;
4983 end match;
4984 end for;
4985 end lm_170;
4986
4987 protected function lm_171
4988 input output Tpl.Text txt;
4989 input list<list<HpcOmSimCode.Task>> items;
4990 input Tpl.Text a_type;
4991 input array<list<HpcOmSimCode.Task>> a_threadTasksOde;
4992 algorithm
4993 ✗ for lstElt_171 in items loop
4994 txt := match lstElt_171
4995 local
4996 Integer x_i0;
4997 list<HpcOmSimCode.Task> ret_1;
4998 Integer ret_0;
4999
5000 case _
5001 algorithm
5002 ✗ x_i0 := Tpl.getIteri_i0(txt);
5003 ✗ ret_0 := intAdd(x_i0, 1);
5004 ✗ ret_1 := arrayGet(a_threadTasksOde, ret_0);
5005 ✗ txt := function_HPCOM_releaseThreadLocks(txt, ret_1, "_lockOde", x_i0, Tpl.textString(a_type));
5006 ✗ txt := Tpl.nextIter(txt);
5007 then txt;
5008 end match;
5009 end for;
5010 end lm_171;
5011
5012 protected function lm_172
5013 input output Tpl.Text txt;
5014 input list<list<HpcOmSimCode.Task>> items;
5015 input Tpl.Text a_type;
5016 input array<list<HpcOmSimCode.Task>> a_threadTasksDae;
5017 algorithm
5018 ✗ for lstElt_172 in items loop
5019 txt := match lstElt_172
5020 local
5021 Integer x_i0;
5022 list<HpcOmSimCode.Task> ret_1;
5023 Integer ret_0;
5024
5025 case _
5026 algorithm
5027 ✗ x_i0 := Tpl.getIteri_i0(txt);
5028 ✗ ret_0 := intAdd(x_i0, 1);
5029 ✗ ret_1 := arrayGet(a_threadTasksDae, ret_0);
5030 ✗ txt := function_HPCOM_assignThreadLocks(txt, ret_1, "_lockDae", x_i0, Tpl.textString(a_type));
5031 ✗ txt := Tpl.nextIter(txt);
5032 then txt;
5033 end match;
5034 end for;
5035 end lm_172;
5036
5037 protected function lm_173
5038 input output Tpl.Text txt;
5039 input list<list<HpcOmSimCode.Task>> items;
5040 input Tpl.Text a_type;
5041 input array<list<HpcOmSimCode.Task>> a_threadTasksDae;
5042 algorithm
5043 ✗ for lstElt_173 in items loop
5044 txt := match lstElt_173
5045 local
5046 Integer x_i0;
5047 list<HpcOmSimCode.Task> ret_1;
5048 Integer ret_0;
5049
5050 case _
5051 algorithm
5052 ✗ x_i0 := Tpl.getIteri_i0(txt);
5053 ✗ ret_0 := intAdd(x_i0, 1);
5054 ✗ ret_1 := arrayGet(a_threadTasksDae, ret_0);
5055 ✗ txt := function_HPCOM_releaseThreadLocks(txt, ret_1, "_lockDae", x_i0, Tpl.textString(a_type));
5056 ✗ txt := Tpl.nextIter(txt);
5057 then txt;
5058 end match;
5059 end for;
5060 end lm_173;
5061
5062 protected function lm_174
5063 input output Tpl.Text txt;
5064 input list<list<HpcOmSimCode.Task>> items;
5065 input Tpl.Text a_type;
5066 input array<list<HpcOmSimCode.Task>> a_threadTasksZeroFunc;
5067 algorithm
5068 ✗ for lstElt_174 in items loop
5069 txt := match lstElt_174
5070 local
5071 Integer x_i0;
5072 list<HpcOmSimCode.Task> ret_1;
5073 Integer ret_0;
5074
5075 case _
5076 algorithm
5077 ✗ x_i0 := Tpl.getIteri_i0(txt);
5078 ✗ ret_0 := intAdd(x_i0, 1);
5079 ✗ ret_1 := arrayGet(a_threadTasksZeroFunc, ret_0);
5080 ✗ txt := function_HPCOM_assignThreadLocks(txt, ret_1, "_lockZeroFunc", x_i0, Tpl.textString(a_type));
5081 ✗ txt := Tpl.nextIter(txt);
5082 then txt;
5083 end match;
5084 end for;
5085 end lm_174;
5086
5087 protected function lm_175
5088 input output Tpl.Text txt;
5089 input list<list<HpcOmSimCode.Task>> items;
5090 input Tpl.Text a_type;
5091 input array<list<HpcOmSimCode.Task>> a_threadTasksZeroFunc;
5092 algorithm
5093 ✗ for lstElt_175 in items loop
5094 txt := match lstElt_175
5095 local
5096 Integer x_i0;
5097 list<HpcOmSimCode.Task> ret_1;
5098 Integer ret_0;
5099
5100 case _
5101 algorithm
5102 ✗ x_i0 := Tpl.getIteri_i0(txt);
5103 ✗ ret_0 := intAdd(x_i0, 1);
5104 ✗ ret_1 := arrayGet(a_threadTasksZeroFunc, ret_0);
5105 ✗ txt := function_HPCOM_releaseThreadLocks(txt, ret_1, "_lockZeroFunc", x_i0, Tpl.textString(a_type));
5106 ✗ txt := Tpl.nextIter(txt);
5107 then txt;
5108 end match;
5109 end for;
5110 end lm_175;
5111
5112 protected function lm_176
5113 input output Tpl.Text txt;
5114 input list<list<HpcOmSimCode.Task>> items;
5115 input Boolean a_useFlatArrayNotation;
5116 input Absyn.Path a_name;
5117 input output Tpl.Text a_extraFuncsDecl;
5118 input output Tpl.Text a_extraFuncs;
5119 input SimCode.SimCode a_simCode;
5120 input output Tpl.Text a_varDecls;
5121 input Tpl.Text a_type;
5122 input array<list<HpcOmSimCode.Task>> a_threadTasksOde;
5123 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
5124 algorithm
5125 ✗ for lstElt_176 in items loop
5126 (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_176
5127 local
5128 Integer x_i0;
5129 list<HpcOmSimCode.Task> i_tt;
5130 Tpl.Text txt_2;
5131 Integer ret_1;
5132 Integer ret_0;
5133
5134 case i_tt
5135 algorithm
5136 ✗ x_i0 := Tpl.getIteri_i0(txt);
5137 ret_0 := arrayLength(a_threadTasksOde);
5138 ✗ ret_1 := intSub(ret_0, 1);
5139 ✗ txt_2 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
5140 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_2) := parallelThreadCodeWithSplit(txt, a_allEquationsPlusWhen, i_tt, x_i0, ret_1, Tpl.textString(a_type), "_lockOde", a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_2, "evaluateODE", a_useFlatArrayNotation);
5141 ✗ txt := Tpl.nextIter(txt);
5142 then (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
5143 end match;
5144 end for;
5145 end lm_176;
5146
5147 protected function lm_177
5148 input output Tpl.Text txt;
5149 input list<list<HpcOmSimCode.Task>> items;
5150 input Boolean a_useFlatArrayNotation;
5151 input Absyn.Path a_name;
5152 input output Tpl.Text a_extraFuncsDecl;
5153 input output Tpl.Text a_extraFuncs;
5154 input SimCode.SimCode a_simCode;
5155 input output Tpl.Text a_varDecls;
5156 input Tpl.Text a_type;
5157 input array<list<HpcOmSimCode.Task>> a_threadTasksDae;
5158 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
5159 algorithm
5160 ✗ for lstElt_177 in items loop
5161 (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_177
5162 local
5163 Integer x_i0;
5164 list<HpcOmSimCode.Task> i_tt;
5165 Tpl.Text txt_2;
5166 Integer ret_1;
5167 Integer ret_0;
5168
5169 case i_tt
5170 algorithm
5171 ✗ x_i0 := Tpl.getIteri_i0(txt);
5172 ret_0 := arrayLength(a_threadTasksDae);
5173 ✗ ret_1 := intSub(ret_0, 1);
5174 ✗ txt_2 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
5175 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_2) := parallelThreadCodeWithSplit(txt, a_allEquationsPlusWhen, i_tt, x_i0, ret_1, Tpl.textString(a_type), "_lockDae", a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_2, "evaluateAll", a_useFlatArrayNotation);
5176 ✗ txt := Tpl.nextIter(txt);
5177 then (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
5178 end match;
5179 end for;
5180 end lm_177;
5181
5182 protected function lm_178
5183 input output Tpl.Text txt;
5184 input list<list<HpcOmSimCode.Task>> items;
5185 input Boolean a_useFlatArrayNotation;
5186 input Absyn.Path a_name;
5187 input output Tpl.Text a_extraFuncsDecl;
5188 input output Tpl.Text a_extraFuncs;
5189 input SimCode.SimCode a_simCode;
5190 input output Tpl.Text a_varDecls;
5191 input Tpl.Text a_type;
5192 input array<list<HpcOmSimCode.Task>> a_threadTasksZeroFunc;
5193 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
5194 algorithm
5195 ✗ for lstElt_178 in items loop
5196 (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_178
5197 local
5198 Integer x_i0;
5199 list<HpcOmSimCode.Task> i_tt;
5200 Tpl.Text txt_2;
5201 Integer ret_1;
5202 Integer ret_0;
5203
5204 case i_tt
5205 algorithm
5206 ✗ x_i0 := Tpl.getIteri_i0(txt);
5207 ret_0 := arrayLength(a_threadTasksZeroFunc);
5208 ✗ ret_1 := intSub(ret_0, 1);
5209 ✗ txt_2 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
5210 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_2) := parallelThreadCodeWithSplit(txt, a_allEquationsPlusWhen, i_tt, x_i0, ret_1, Tpl.textString(a_type), "_lockZeroFunc", a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_2, "evaluateZeroFunc", a_useFlatArrayNotation);
5211 ✗ txt := Tpl.nextIter(txt);
5212 then (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
5213 end match;
5214 end for;
5215 end lm_178;
5216
5217 protected function lm_179
5218 input output Tpl.Text txt;
5219 input list<Integer> items;
5220 input Boolean a_useFlatArrayNotation;
5221 input output Tpl.Text a_mainThreadCode;
5222 input Absyn.Path a_name;
5223 input output Tpl.Text a_extraFuncsDecl;
5224 input output Tpl.Text a_extraFuncs;
5225 input SimCode.SimCode a_simCode;
5226 input output Tpl.Text a_varDecls;
5227 input String a_modelNamePrefixStr;
5228 input Tpl.Text a_type;
5229 input array<list<HpcOmSimCode.Task>> a_zeroFuncSchedule_threadTasks;
5230 input array<list<HpcOmSimCode.Task>> a_daeSchedule_threadTasks;
5231 input array<list<HpcOmSimCode.Task>> a_odeSchedule_threadTasks;
5232 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
5233 algorithm
5234 ✗ for lstElt_179 in items loop
5235 (txt, a_mainThreadCode, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_179
5236 local
5237 Integer i_threadIdx;
5238 Tpl.Text txt_4;
5239 Integer ret_3;
5240 list<HpcOmSimCode.Task> ret_2;
5241 list<HpcOmSimCode.Task> ret_1;
5242 list<HpcOmSimCode.Task> ret_0;
5243
5244 case i_threadIdx
5245 algorithm
5246 ✗ ret_0 := arrayGet(a_odeSchedule_threadTasks, i_threadIdx);
5247 ✗ ret_1 := arrayGet(a_daeSchedule_threadTasks, i_threadIdx);
5248 ✗ ret_2 := arrayGet(a_zeroFuncSchedule_threadTasks, i_threadIdx);
5249 ✗ ret_3 := intSub(i_threadIdx, 1);
5250 ✗ txt_4 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
5251 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_4, a_mainThreadCode) := generateThreadFunc(txt, a_allEquationsPlusWhen, ret_0, ret_1, ret_2, Tpl.textString(a_type), ret_3, a_modelNamePrefixStr, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_4, a_mainThreadCode, a_useFlatArrayNotation);
5252 ✗ txt := Tpl.nextIter(txt);
5253 then (txt, a_mainThreadCode, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
5254 end match;
5255 end for;
5256 end lm_179;
5257
5258 protected function lm_180
5259 input output Tpl.Text txt;
5260 input list<list<HpcOmSimCode.Task>> items;
5261 input Tpl.Text a_type;
5262 algorithm
5263 ✗ for lstElt_180 in items loop
5264 txt := match lstElt_180
5265 local
5266 Integer x_i0;
5267
5268 case _
5269 algorithm
5270 ✗ x_i0 := Tpl.getIteri_i0(txt);
5271 ✗ txt := assignLockByLockName(txt, intString(x_i0), "th_lock1", Tpl.textString(a_type));
5272 ✗ txt := Tpl.nextIter(txt);
5273 then txt;
5274 end match;
5275 end for;
5276 end lm_180;
5277
5278 protected function lm_181
5279 input output Tpl.Text txt;
5280 input list<list<HpcOmSimCode.Task>> items;
5281 input Tpl.Text a_type;
5282 algorithm
5283 ✗ for lstElt_181 in items loop
5284 txt := match lstElt_181
5285 local
5286 Integer x_i0;
5287
5288 case _
5289 algorithm
5290 ✗ x_i0 := Tpl.getIteri_i0(txt);
5291 ✗ txt := releaseLockByLockName(txt, intString(x_i0), "th_lock", Tpl.textString(a_type));
5292 ✗ txt := Tpl.nextIter(txt);
5293 then txt;
5294 end match;
5295 end for;
5296 end lm_181;
5297
5298 protected function fun_182
5299 input Tpl.Text in_txt;
5300 input String in_mArg;
5301 input String in_a_modelNamePrefixStr;
5302 input array<list<HpcOmSimCode.Task>> in_a_zeroFuncSchedule_threadTasks;
5303 input array<list<HpcOmSimCode.Task>> in_a_daeSchedule_threadTasks;
5304 input array<list<HpcOmSimCode.Task>> in_a_odeSchedule_threadTasks;
5305 input Tpl.Text in_a_functionHead;
5306 input Boolean in_a_useFlatArrayNotation;
5307 input Absyn.Path in_a_name;
5308 input Tpl.Text in_a_extraFuncsDecl;
5309 input Tpl.Text in_a_extraFuncs;
5310 input SimCode.SimCode in_a_simCode;
5311 input Tpl.Text in_a_varDecls;
5312 input list<SimCode.SimEqSystem> in_a_allEquationsPlusWhen;
5313 input array<list<HpcOmSimCode.Task>> in_a_threadTasksZeroFunc;
5314 input array<list<HpcOmSimCode.Task>> in_a_threadTasksDae;
5315 input Tpl.Text in_a_type;
5316 input array<list<HpcOmSimCode.Task>> in_a_threadTasksOde;
5317
5318 output Tpl.Text out_txt;
5319 output Tpl.Text out_a_extraFuncsDecl;
5320 output Tpl.Text out_a_extraFuncs;
5321 output Tpl.Text out_a_varDecls;
5322 algorithm
5323 (out_txt, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls) :=
5324 match(in_txt, in_mArg, in_a_modelNamePrefixStr, in_a_zeroFuncSchedule_threadTasks, in_a_daeSchedule_threadTasks, in_a_odeSchedule_threadTasks, in_a_functionHead, in_a_useFlatArrayNotation, in_a_name, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_allEquationsPlusWhen, in_a_threadTasksZeroFunc, in_a_threadTasksDae, in_a_type, in_a_threadTasksOde)
5325 local
5326 Tpl.Text txt;
5327 String a_modelNamePrefixStr;
5328 array<list<HpcOmSimCode.Task>> a_zeroFuncSchedule_threadTasks;
5329 array<list<HpcOmSimCode.Task>> a_daeSchedule_threadTasks;
5330 array<list<HpcOmSimCode.Task>> a_odeSchedule_threadTasks;
5331 Tpl.Text a_functionHead;
5332 Boolean a_useFlatArrayNotation;
5333 Absyn.Path a_name;
5334 Tpl.Text a_extraFuncsDecl;
5335 Tpl.Text a_extraFuncs;
5336 SimCode.SimCode a_simCode;
5337 Tpl.Text a_varDecls;
5338 list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
5339 array<list<HpcOmSimCode.Task>> a_threadTasksZeroFunc;
5340 array<list<HpcOmSimCode.Task>> a_threadTasksDae;
5341 Tpl.Text a_type;
5342 array<list<HpcOmSimCode.Task>> a_threadTasksOde;
5343 list<list<HpcOmSimCode.Task>> ret_30;
5344 list<list<HpcOmSimCode.Task>> ret_29;
5345 Tpl.Text l_threadReleaseLocks;
5346 list<list<HpcOmSimCode.Task>> ret_27;
5347 list<list<HpcOmSimCode.Task>> ret_26;
5348 Tpl.Text l_threadAssignLocks1;
5349 list<Integer> ret_24;
5350 Integer ret_23;
5351 Tpl.Text l_threadFuncs;
5352 Tpl.Text l_mainThreadCode;
5353 Integer ret_20;
5354 Integer ret_19;
5355 Integer ret_18;
5356 list<list<HpcOmSimCode.Task>> ret_17;
5357 Tpl.Text l_zeroFuncEqs;
5358 list<list<HpcOmSimCode.Task>> ret_15;
5359 Tpl.Text l_daeEqs;
5360 list<list<HpcOmSimCode.Task>> ret_13;
5361 Tpl.Text l_odeEqs;
5362 list<list<HpcOmSimCode.Task>> ret_11;
5363 Tpl.Text l_threadReleaseLocksZeroFunc;
5364 list<list<HpcOmSimCode.Task>> ret_9;
5365 Tpl.Text l_threadAssignLocksZeroFunc;
5366 list<list<HpcOmSimCode.Task>> ret_7;
5367 Tpl.Text l_threadReleaseLocksDae;
5368 list<list<HpcOmSimCode.Task>> ret_5;
5369 Tpl.Text l_threadAssignLocksDae;
5370 list<list<HpcOmSimCode.Task>> ret_3;
5371 Tpl.Text l_threadReleaseLocksOde;
5372 list<list<HpcOmSimCode.Task>> ret_1;
5373 Tpl.Text l_threadAssignLocksOde;
5374
5375 case ( txt,
5376 "openmp",
5377 _,
5378 _,
5379 _,
5380 _,
5381 a_functionHead,
5382 a_useFlatArrayNotation,
5383 a_name,
5384 a_extraFuncsDecl,
5385 a_extraFuncs,
5386 a_simCode,
5387 a_varDecls,
5388 a_allEquationsPlusWhen,
5389 a_threadTasksZeroFunc,
5390 a_threadTasksDae,
5391 a_type,
5392 a_threadTasksOde )
5393 algorithm
5394 ✗ ret_1 := arrayList(a_threadTasksOde);
5395 ✗ l_threadAssignLocksOde := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5396 ✗ l_threadAssignLocksOde := lm_170(l_threadAssignLocksOde, ret_1, a_type, a_threadTasksOde);
5397 ✗ l_threadAssignLocksOde := Tpl.popIter(l_threadAssignLocksOde);
5398 ✗ ret_3 := arrayList(a_threadTasksOde);
5399 ✗ l_threadReleaseLocksOde := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5400 ✗ l_threadReleaseLocksOde := lm_171(l_threadReleaseLocksOde, ret_3, a_type, a_threadTasksOde);
5401 ✗ l_threadReleaseLocksOde := Tpl.popIter(l_threadReleaseLocksOde);
5402 ✗ ret_5 := arrayList(a_threadTasksOde);
5403 ✗ l_threadAssignLocksDae := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5404 ✗ l_threadAssignLocksDae := lm_172(l_threadAssignLocksDae, ret_5, a_type, a_threadTasksDae);
5405 ✗ l_threadAssignLocksDae := Tpl.popIter(l_threadAssignLocksDae);
5406 ✗ ret_7 := arrayList(a_threadTasksOde);
5407 ✗ l_threadReleaseLocksDae := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5408 ✗ l_threadReleaseLocksDae := lm_173(l_threadReleaseLocksDae, ret_7, a_type, a_threadTasksDae);
5409 ✗ l_threadReleaseLocksDae := Tpl.popIter(l_threadReleaseLocksDae);
5410 ✗ ret_9 := arrayList(a_threadTasksZeroFunc);
5411 ✗ l_threadAssignLocksZeroFunc := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5412 ✗ l_threadAssignLocksZeroFunc := lm_174(l_threadAssignLocksZeroFunc, ret_9, a_type, a_threadTasksZeroFunc);
5413 ✗ l_threadAssignLocksZeroFunc := Tpl.popIter(l_threadAssignLocksZeroFunc);
5414 ✗ ret_11 := arrayList(a_threadTasksZeroFunc);
5415 ✗ l_threadReleaseLocksZeroFunc := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5416 ✗ l_threadReleaseLocksZeroFunc := lm_175(l_threadReleaseLocksZeroFunc, ret_11, a_type, a_threadTasksZeroFunc);
5417 ✗ l_threadReleaseLocksZeroFunc := Tpl.popIter(l_threadReleaseLocksZeroFunc);
5418 ✗ ret_13 := arrayList(a_threadTasksOde);
5419 ✗ l_odeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5420 ✗ (l_odeEqs, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_176(l_odeEqs, ret_13, a_useFlatArrayNotation, a_name, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_type, a_threadTasksOde, a_allEquationsPlusWhen);
5421 ✗ l_odeEqs := Tpl.popIter(l_odeEqs);
5422 ✗ ret_15 := arrayList(a_threadTasksDae);
5423 ✗ l_daeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5424 ✗ (l_daeEqs, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_177(l_daeEqs, ret_15, a_useFlatArrayNotation, a_name, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_type, a_threadTasksDae, a_allEquationsPlusWhen);
5425 ✗ l_daeEqs := Tpl.popIter(l_daeEqs);
5426 ✗ ret_17 := arrayList(a_threadTasksZeroFunc);
5427 ✗ l_zeroFuncEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5428 ✗ (l_zeroFuncEqs, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_178(l_zeroFuncEqs, ret_17, a_useFlatArrayNotation, a_name, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_type, a_threadTasksZeroFunc, a_allEquationsPlusWhen);
5429 ✗ l_zeroFuncEqs := Tpl.popIter(l_zeroFuncEqs);
5430 ✗ a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING_LIST({
5431 "void evaluateODE_Parallel();\n",
5432 "void evaluateAll_Parallel();\n",
5433 "void evaluateZeroFuncs_Parallel();"
5434 }, false));
5435 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("void "));
5436 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
5437 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5438 "::evaluateODE_Parallel()\n",
5439 "{\n"
5440 }, true));
5441 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
5442 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#pragma omp parallel num_threads("));
5443 ✗ ret_18 := Flags.getConfigInt(Flags.NUM_PROC);
5444 ✗ txt := Tpl.writeStr(txt, intString(ret_18));
5445 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5446 ")\n",
5447 "{\n",
5448 " int threadNum = getThreadNumber();\n"
5449 }, true));
5450 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
5451 ✗ txt := Tpl.writeText(txt, l_threadAssignLocksOde);
5452 ✗ txt := Tpl.softNewLine(txt);
5453 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("#pragma omp barrier\n"));
5454 ✗ txt := Tpl.writeText(txt, l_odeEqs);
5455 ✗ txt := Tpl.softNewLine(txt);
5456 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("#pragma omp barrier\n"));
5457 ✗ txt := Tpl.writeText(txt, l_threadReleaseLocksOde);
5458 ✗ txt := Tpl.softNewLine(txt);
5459 ✗ txt := Tpl.popBlock(txt);
5460 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
5461 ✗ txt := Tpl.popBlock(txt);
5462 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5463 "}\n",
5464 "\n",
5465 "void "
5466 }, false));
5467 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
5468 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5469 "::evaluateAll_Parallel()\n",
5470 "{\n"
5471 }, true));
5472 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
5473 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#pragma omp parallel num_threads("));
5474 ✗ ret_19 := Flags.getConfigInt(Flags.NUM_PROC);
5475 ✗ txt := Tpl.writeStr(txt, intString(ret_19));
5476 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5477 ")\n",
5478 "{\n",
5479 " int threadNum = getThreadNumber();\n"
5480 }, true));
5481 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
5482 ✗ txt := Tpl.writeText(txt, l_threadAssignLocksDae);
5483 ✗ txt := Tpl.softNewLine(txt);
5484 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("#pragma omp barrier\n"));
5485 ✗ txt := Tpl.writeText(txt, l_daeEqs);
5486 ✗ txt := Tpl.softNewLine(txt);
5487 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("#pragma omp barrier\n"));
5488 ✗ txt := Tpl.writeText(txt, l_threadReleaseLocksDae);
5489 ✗ txt := Tpl.softNewLine(txt);
5490 ✗ txt := Tpl.popBlock(txt);
5491 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
5492 ✗ txt := Tpl.popBlock(txt);
5493 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5494 "}\n",
5495 "\n",
5496 "void "
5497 }, false));
5498 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
5499 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5500 "::evaluateZeroFuncs_Parallel()\n",
5501 "{\n"
5502 }, true));
5503 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
5504 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#pragma omp parallel num_threads("));
5505 ✗ ret_20 := Flags.getConfigInt(Flags.NUM_PROC);
5506 ✗ txt := Tpl.writeStr(txt, intString(ret_20));
5507 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5508 ")\n",
5509 "{\n",
5510 " int threadNum = getThreadNumber();\n"
5511 }, true));
5512 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
5513 ✗ txt := Tpl.writeText(txt, l_threadAssignLocksZeroFunc);
5514 ✗ txt := Tpl.softNewLine(txt);
5515 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("#pragma omp barrier\n"));
5516 ✗ txt := Tpl.writeText(txt, l_zeroFuncEqs);
5517 ✗ txt := Tpl.softNewLine(txt);
5518 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("#pragma omp barrier\n"));
5519 ✗ txt := Tpl.writeText(txt, l_threadReleaseLocksZeroFunc);
5520 ✗ txt := Tpl.softNewLine(txt);
5521 ✗ txt := Tpl.popBlock(txt);
5522 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
5523 ✗ txt := Tpl.popBlock(txt);
5524 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5525 "}\n",
5526 "\n"
5527 }, true));
5528 ✗ txt := Tpl.writeText(txt, a_functionHead);
5529 ✗ txt := Tpl.softNewLine(txt);
5530 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5531 "{\n",
5532 " this->_evaluateMode = _evaluateMode;\n",
5533 " this->_command = command;\n",
5534 " if(evaluateMode == 0)\n",
5535 " {\n",
5536 " evaluateODE_Parallel();\n",
5537 " }\n",
5538 " else if(evaluateMode < 0)\n",
5539 " {\n",
5540 " evaluateAll_Parallel();\n",
5541 " }\n",
5542 " else\n",
5543 " {\n",
5544 " evaluateZeroFuncs_Parallel();\n",
5545 " }\n",
5546 "}"
5547 }, false));
5548 ✗ then (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
5549
5550 case ( txt,
5551 "mpi",
5552 _,
5553 _,
5554 _,
5555 _,
5556 a_functionHead,
5557 _,
5558 _,
5559 a_extraFuncsDecl,
5560 a_extraFuncs,
5561 _,
5562 a_varDecls,
5563 _,
5564 _,
5565 _,
5566 _,
5567 _ )
5568 algorithm
5569 ✗ txt := Tpl.writeText(txt, a_functionHead);
5570 ✗ txt := Tpl.softNewLine(txt);
5571 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5572 "{\n",
5573 " // MFlehmig: Todo\n",
5574 "}"
5575 }, false));
5576 ✗ then (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
5577
5578 case ( txt,
5579 _,
5580 a_modelNamePrefixStr,
5581 a_zeroFuncSchedule_threadTasks,
5582 a_daeSchedule_threadTasks,
5583 a_odeSchedule_threadTasks,
5584 a_functionHead,
5585 a_useFlatArrayNotation,
5586 a_name,
5587 a_extraFuncsDecl,
5588 a_extraFuncs,
5589 a_simCode,
5590 a_varDecls,
5591 a_allEquationsPlusWhen,
5592 _,
5593 _,
5594 a_type,
5595 _ )
5596 algorithm
5597 ✗ l_mainThreadCode := Tpl.emptyTxt;
5598 ret_23 := arrayLength(a_odeSchedule_threadTasks);
5599 ✗ ret_24 := List.intRange(ret_23);
5600 ✗ l_threadFuncs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5601 ✗ (l_threadFuncs, l_mainThreadCode, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_179(l_threadFuncs, ret_24, a_useFlatArrayNotation, l_mainThreadCode, a_name, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_modelNamePrefixStr, a_type, a_zeroFuncSchedule_threadTasks, a_daeSchedule_threadTasks, a_odeSchedule_threadTasks, a_allEquationsPlusWhen);
5602 ✗ l_threadFuncs := Tpl.popIter(l_threadFuncs);
5603 ✗ ret_26 := arrayList(a_odeSchedule_threadTasks);
5604 ✗ ret_27 := listRest(ret_26);
5605 ✗ l_threadAssignLocks1 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5606 ✗ l_threadAssignLocks1 := lm_180(l_threadAssignLocks1, ret_27, a_type);
5607 ✗ l_threadAssignLocks1 := Tpl.popIter(l_threadAssignLocks1);
5608 ✗ ret_29 := arrayList(a_odeSchedule_threadTasks);
5609 ✗ ret_30 := listRest(ret_29);
5610 ✗ l_threadReleaseLocks := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5611 ✗ l_threadReleaseLocks := lm_181(l_threadReleaseLocks, ret_30, a_type);
5612 ✗ l_threadReleaseLocks := Tpl.popIter(l_threadReleaseLocks);
5613 ✗ txt := Tpl.writeText(txt, l_threadFuncs);
5614 ✗ txt := Tpl.softNewLine(txt);
5615 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
5616 ✗ txt := Tpl.writeText(txt, a_functionHead);
5617 ✗ txt := Tpl.softNewLine(txt);
5618 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5619 "{\n",
5620 " this->_evaluateMode = _evaluateMode;\n",
5621 " this->_command = command;\n"
5622 }, true));
5623 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
5624 ✗ txt := Tpl.writeText(txt, l_threadReleaseLocks);
5625 ✗ txt := Tpl.softNewLine(txt);
5626 ✗ txt := Tpl.writeText(txt, l_mainThreadCode);
5627 ✗ txt := Tpl.softNewLine(txt);
5628 ✗ txt := Tpl.writeText(txt, l_threadAssignLocks1);
5629 ✗ txt := Tpl.softNewLine(txt);
5630 ✗ txt := Tpl.popBlock(txt);
5631 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
5632 ✗ then (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
5633 end match;
5634 end fun_182;
5635
5636 protected function fun_183
5637 input Tpl.Text in_txt;
5638 input String in_mArg;
5639 input Absyn.Path in_a_name;
5640 input Tpl.Text in_a_functionHead;
5641 input list<tuple<HpcOmSimCode.Task, list<Integer>>> in_a_zeroFuncSchedule_tasks;
5642 input list<tuple<HpcOmSimCode.Task, list<Integer>>> in_a_daeSchedule_tasks;
5643 input Boolean in_a_useFlatArrayNotation;
5644 input Tpl.Text in_a_extraFuncsNamespace;
5645 input Tpl.Text in_a_extraFuncsDecl;
5646 input Tpl.Text in_a_extraFuncs;
5647 input SimCode.SimCode in_a_simCode;
5648 input Tpl.Text in_a_varDecls;
5649 input Tpl.Text in_a_type;
5650 input list<SimCode.SimEqSystem> in_a_allEquationsPlusWhen;
5651 input list<tuple<HpcOmSimCode.Task, list<Integer>>> in_a_odeSchedule_tasks;
5652
5653 output Tpl.Text out_txt;
5654 output Tpl.Text out_a_extraFuncsNamespace;
5655 output Tpl.Text out_a_extraFuncsDecl;
5656 output Tpl.Text out_a_extraFuncs;
5657 output Tpl.Text out_a_varDecls;
5658 algorithm
5659 (out_txt, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls) :=
5660 match(in_txt, in_mArg, in_a_name, in_a_functionHead, in_a_zeroFuncSchedule_tasks, in_a_daeSchedule_tasks, in_a_useFlatArrayNotation, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_type, in_a_allEquationsPlusWhen, in_a_odeSchedule_tasks)
5661 local
5662 Tpl.Text txt;
5663 Absyn.Path a_name;
5664 Tpl.Text a_functionHead;
5665 list<tuple<HpcOmSimCode.Task, list<Integer>>> a_zeroFuncSchedule_tasks;
5666 list<tuple<HpcOmSimCode.Task, list<Integer>>> a_daeSchedule_tasks;
5667 Boolean a_useFlatArrayNotation;
5668 Tpl.Text a_extraFuncsNamespace;
5669 Tpl.Text a_extraFuncsDecl;
5670 Tpl.Text a_extraFuncs;
5671 SimCode.SimCode a_simCode;
5672 Tpl.Text a_varDecls;
5673 Tpl.Text a_type;
5674 list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
5675 list<tuple<HpcOmSimCode.Task, list<Integer>>> a_odeSchedule_tasks;
5676 Tpl.Text l_taskFuncs;
5677 Tpl.Text l_zeroFuncTaskEqs;
5678 Tpl.Text l_daeTaskEqs;
5679 Tpl.Text l_odeTaskEqs;
5680
5681 case ( txt,
5682 "openmp",
5683 _,
5684 a_functionHead,
5685 a_zeroFuncSchedule_tasks,
5686 a_daeSchedule_tasks,
5687 a_useFlatArrayNotation,
5688 a_extraFuncsNamespace,
5689 a_extraFuncsDecl,
5690 a_extraFuncs,
5691 a_simCode,
5692 a_varDecls,
5693 a_type,
5694 a_allEquationsPlusWhen,
5695 a_odeSchedule_tasks )
5696 algorithm
5697 ✗ (l_odeTaskEqs, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := function_HPCOM_TaskDep(Tpl.emptyTxt, a_odeSchedule_tasks, a_allEquationsPlusWhen, Tpl.textString(a_type), a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
5698 ✗ (l_daeTaskEqs, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := function_HPCOM_TaskDep(Tpl.emptyTxt, a_daeSchedule_tasks, a_allEquationsPlusWhen, Tpl.textString(a_type), a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
5699 ✗ (l_zeroFuncTaskEqs, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := function_HPCOM_TaskDep(Tpl.emptyTxt, a_zeroFuncSchedule_tasks, a_allEquationsPlusWhen, Tpl.textString(a_type), a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
5700 ✗ txt := Tpl.writeText(txt, a_functionHead);
5701 ✗ txt := Tpl.softNewLine(txt);
5702 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5703 "{\n",
5704 " this->_evaluateMode = _evaluateMode;\n",
5705 " this->_command = command;\n"
5706 }, true));
5707 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
5708 ✗ txt := Tpl.writeText(txt, a_varDecls);
5709 ✗ txt := Tpl.softNewLine(txt);
5710 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5711 "if(_evaluateMode == 0)\n",
5712 "{\n"
5713 }, true));
5714 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
5715 ✗ txt := Tpl.writeText(txt, l_odeTaskEqs);
5716 ✗ txt := Tpl.softNewLine(txt);
5717 ✗ txt := Tpl.popBlock(txt);
5718 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5719 "}\n",
5720 "else if(_evaluateMode < 0)\n",
5721 "{\n"
5722 }, true));
5723 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
5724 ✗ txt := Tpl.writeText(txt, l_daeTaskEqs);
5725 ✗ txt := Tpl.softNewLine(txt);
5726 ✗ txt := Tpl.popBlock(txt);
5727 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5728 "}\n",
5729 "else\n",
5730 "{\n"
5731 }, true));
5732 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
5733 ✗ txt := Tpl.writeText(txt, l_zeroFuncTaskEqs);
5734 ✗ txt := Tpl.softNewLine(txt);
5735 ✗ txt := Tpl.popBlock(txt);
5736 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
5737 ✗ txt := Tpl.popBlock(txt);
5738 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
5739 ✗ then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
5740
5741 case ( txt,
5742 "tbb",
5743 a_name,
5744 a_functionHead,
5745 a_zeroFuncSchedule_tasks,
5746 a_daeSchedule_tasks,
5747 a_useFlatArrayNotation,
5748 a_extraFuncsNamespace,
5749 a_extraFuncsDecl,
5750 a_extraFuncs,
5751 a_simCode,
5752 a_varDecls,
5753 a_type,
5754 a_allEquationsPlusWhen,
5755 a_odeSchedule_tasks )
5756 algorithm
5757 ✗ (l_taskFuncs, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := function_HPCOM_TaskDep_voidfunc(Tpl.emptyTxt, a_odeSchedule_tasks, a_daeSchedule_tasks, a_zeroFuncSchedule_tasks, a_allEquationsPlusWhen, Tpl.textString(a_type), a_name, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
5758 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("//void functions for functionhandling in tbb_nodes\n"));
5759 ✗ txt := Tpl.writeText(txt, l_taskFuncs);
5760 ✗ txt := Tpl.softNewLine(txt);
5761 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
5762 ✗ txt := Tpl.writeText(txt, a_functionHead);
5763 ✗ txt := Tpl.softNewLine(txt);
5764 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5765 "{\n",
5766 " this->_evaluateMode = _evaluateMode;\n",
5767 " this->_command = command;\n"
5768 }, true));
5769 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
5770 ✗ txt := Tpl.writeText(txt, a_varDecls);
5771 ✗ txt := Tpl.softNewLine(txt);
5772 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5773 "if(_evaluateMode == 0)\n",
5774 "{\n",
5775 " #if TBB_INTERFACE_VERSION >= 8000\n",
5776 " _tbbArena.execute(_tbbArenaFunctorOde);\n",
5777 " #else\n",
5778 " _tbbStartNodeOde.try_put(tbb::flow::continue_msg());\n",
5779 " _tbbGraphOde.wait_for_all();\n",
5780 " #endif\n",
5781 "}\n",
5782 "else if(_evaluateMode < 0)\n",
5783 "{\n",
5784 " #if TBB_INTERFACE_VERSION >= 8000\n",
5785 " _tbbArena.execute(_tbbArenaFunctorAll);\n",
5786 " #else\n",
5787 " _tbbStartNodeAll.try_put(tbb::flow::continue_msg());\n",
5788 " _tbbGraphAll.wait_for_all();\n",
5789 " #endif\n",
5790 "}\n",
5791 "else\n",
5792 "{\n",
5793 " #if TBB_INTERFACE_VERSION >= 8000\n",
5794 " _tbbArena.execute(_tbbArenaFunctorZeroFunc);\n",
5795 " #else\n",
5796 " _tbbStartNodeZeroFunc.try_put(tbb::flow::continue_msg());\n",
5797 " _tbbGraphZeroFunc.wait_for_all();\n",
5798 " #endif\n",
5799 "}\n"
5800 }, true));
5801 ✗ txt := Tpl.popBlock(txt);
5802 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
5803 ✗ then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
5804
5805 case ( txt,
5806 _,
5807 _,
5808 _,
5809 _,
5810 _,
5811 _,
5812 a_extraFuncsNamespace,
5813 a_extraFuncsDecl,
5814 a_extraFuncs,
5815 _,
5816 a_varDecls,
5817 _,
5818 _,
5819 _ )
5820 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
5821 end match;
5822 end fun_183;
5823
5824 protected function fun_184
5825 input Tpl.Text in_txt;
5826 input Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> in_a_schedulesOpt;
5827 input String in_a_modelNamePrefixStr;
5828 input Tpl.Text in_a_extraFuncsNamespace;
5829 input Tpl.Text in_a_type;
5830 input Boolean in_a_useFlatArrayNotation;
5831 input Absyn.Path in_a_name;
5832 input Tpl.Text in_a_extraFuncsDecl;
5833 input Tpl.Text in_a_extraFuncs;
5834 input SimCode.SimCode in_a_simCode;
5835 input Tpl.Text in_a_varDecls;
5836 input list<SimCode.SimEqSystem> in_a_allEquationsPlusWhen;
5837 input Tpl.Text in_a_functionHead;
5838
5839 output Tpl.Text out_txt;
5840 output Tpl.Text out_a_extraFuncsNamespace;
5841 output Tpl.Text out_a_extraFuncsDecl;
5842 output Tpl.Text out_a_extraFuncs;
5843 output Tpl.Text out_a_varDecls;
5844 algorithm
5845 (out_txt, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls) :=
5846 match(in_txt, in_a_schedulesOpt, in_a_modelNamePrefixStr, in_a_extraFuncsNamespace, in_a_type, in_a_useFlatArrayNotation, in_a_name, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_allEquationsPlusWhen, in_a_functionHead)
5847 local
5848 Tpl.Text txt;
5849 String a_modelNamePrefixStr;
5850 Tpl.Text a_extraFuncsNamespace;
5851 Tpl.Text a_type;
5852 Boolean a_useFlatArrayNotation;
5853 Absyn.Path a_name;
5854 Tpl.Text a_extraFuncsDecl;
5855 Tpl.Text a_extraFuncs;
5856 SimCode.SimCode a_simCode;
5857 Tpl.Text a_varDecls;
5858 list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
5859 Tpl.Text a_functionHead;
5860 list<tuple<HpcOmSimCode.Task, list<Integer>>> i_zeroFuncSchedule_tasks;
5861 list<tuple<HpcOmSimCode.Task, list<Integer>>> i_daeSchedule_tasks;
5862 list<tuple<HpcOmSimCode.Task, list<Integer>>> i_odeSchedule_tasks;
5863 array<list<HpcOmSimCode.Task>> i_zeroFuncSchedule_threadTasks;
5864 array<list<HpcOmSimCode.Task>> i_daeSchedule_threadTasks;
5865 array<list<HpcOmSimCode.Task>> i_odeSchedule_threadTasks;
5866 array<list<HpcOmSimCode.Task>> i_threadTasksZeroFunc;
5867 array<list<HpcOmSimCode.Task>> i_threadTasksDae;
5868 array<list<HpcOmSimCode.Task>> i_threadTasksOde;
5869 HpcOmSimCode.Schedule i_zeroFuncSchedule;
5870 HpcOmSimCode.Schedule i_daeSchedule;
5871 HpcOmSimCode.Schedule i_odeSchedule;
5872 list<HpcOmSimCode.TaskList> i_tasksOfLevelsZeroFunc;
5873 list<HpcOmSimCode.TaskList> i_tasksOfLevelsDae;
5874 list<HpcOmSimCode.TaskList> i_tasksOfLevelsOde;
5875 list<HpcOmSimCode.Task> i_taskListZeroFunc;
5876 list<HpcOmSimCode.Task> i_taskListDae;
5877 list<HpcOmSimCode.Task> i_taskListOde;
5878 String str_9;
5879 String str_8;
5880 String str_7;
5881 String str_6;
5882 Tpl.Text l_zeroFuncEqs;
5883 Tpl.Text l_daeEqs;
5884 Tpl.Text l_odeEqs;
5885 Tpl.Text txt_2;
5886 Tpl.Text txt_1;
5887 Tpl.Text txt_0;
5888
5889 case ( txt,
5890 SOME((HpcOmSimCode.EMPTYSCHEDULE(tasks = HpcOmSimCode.SERIALTASKLIST(tasks = i_taskListOde)), HpcOmSimCode.EMPTYSCHEDULE(tasks = HpcOmSimCode.SERIALTASKLIST(tasks = i_taskListDae)), HpcOmSimCode.EMPTYSCHEDULE(tasks = HpcOmSimCode.SERIALTASKLIST(tasks = i_taskListZeroFunc)))),
5891 _,
5892 a_extraFuncsNamespace,
5893 _,
5894 a_useFlatArrayNotation,
5895 a_name,
5896 a_extraFuncsDecl,
5897 a_extraFuncs,
5898 a_simCode,
5899 a_varDecls,
5900 a_allEquationsPlusWhen,
5901 a_functionHead )
5902 algorithm
5903 ✗ txt := Tpl.writeText(txt, a_functionHead);
5904 ✗ txt := Tpl.softNewLine(txt);
5905 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5906 "{\n",
5907 " if(evaluateMode == 0) //evaluate ODE\n",
5908 " {\n"
5909 }, true));
5910 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
5911 ✗ txt_0 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
5912 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_0) := parallelThreadCodeWithSplit(txt, a_allEquationsPlusWhen, i_taskListOde, 1, 1, "", "", a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_0, "evaluateODE_Th1", a_useFlatArrayNotation);
5913 ✗ txt := Tpl.softNewLine(txt);
5914 ✗ txt := Tpl.popBlock(txt);
5915 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5916 " }\n",
5917 " else if(evaluateMode < 0) //evaluate All\n",
5918 " {\n"
5919 }, true));
5920 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
5921 ✗ txt_1 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
5922 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_1) := parallelThreadCodeWithSplit(txt, a_allEquationsPlusWhen, i_taskListDae, 1, 1, "", "", a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_1, "evaluateAll_Th1", a_useFlatArrayNotation);
5923 ✗ txt := Tpl.softNewLine(txt);
5924 ✗ txt := Tpl.popBlock(txt);
5925 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5926 " }\n",
5927 " else //evaluate ZeroFuncs\n",
5928 " {\n"
5929 }, true));
5930 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
5931 ✗ txt_2 := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, a_name);
5932 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, txt_2) := parallelThreadCodeWithSplit(txt, a_allEquationsPlusWhen, i_taskListZeroFunc, 1, 1, "", "", a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, txt_2, "evaluateZeroFunc_Th1", a_useFlatArrayNotation);
5933 ✗ txt := Tpl.softNewLine(txt);
5934 ✗ txt := Tpl.popBlock(txt);
5935 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
5936 " }\n",
5937 "}"
5938 }, false));
5939 ✗ then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
5940
5941 case ( txt,
5942 SOME((HpcOmSimCode.LEVELSCHEDULE(useFixedAssignments = false, tasksOfLevels = i_tasksOfLevelsOde), HpcOmSimCode.LEVELSCHEDULE(useFixedAssignments = false, tasksOfLevels = i_tasksOfLevelsDae), HpcOmSimCode.LEVELSCHEDULE(useFixedAssignments = false, tasksOfLevels = i_tasksOfLevelsZeroFunc))),
5943 _,
5944 a_extraFuncsNamespace,
5945 a_type,
5946 a_useFlatArrayNotation,
5947 a_name,
5948 a_extraFuncsDecl,
5949 a_extraFuncs,
5950 a_simCode,
5951 a_varDecls,
5952 a_allEquationsPlusWhen,
5953 a_functionHead )
5954 algorithm
5955 ✗ l_odeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5956 ✗ (l_odeEqs, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_158(l_odeEqs, i_tasksOfLevelsOde, a_useFlatArrayNotation, a_name, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_type, a_allEquationsPlusWhen);
5957 ✗ l_odeEqs := Tpl.popIter(l_odeEqs);
5958 ✗ l_daeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5959 ✗ (l_daeEqs, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_159(l_daeEqs, i_tasksOfLevelsDae, a_useFlatArrayNotation, a_name, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_type, a_allEquationsPlusWhen);
5960 ✗ l_daeEqs := Tpl.popIter(l_daeEqs);
5961 ✗ l_zeroFuncEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5962 ✗ (l_zeroFuncEqs, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_160(l_zeroFuncEqs, i_tasksOfLevelsZeroFunc, a_useFlatArrayNotation, a_name, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_type, a_allEquationsPlusWhen);
5963 ✗ l_zeroFuncEqs := Tpl.popIter(l_zeroFuncEqs);
5964 ✗ str_6 := Tpl.textString(a_type);
5965 ✗ (txt, a_extraFuncsDecl) := fun_161(txt, str_6, a_type, a_functionHead, l_zeroFuncEqs, l_daeEqs, l_odeEqs, a_name, a_extraFuncsDecl);
5966 ✗ then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
5967
5968 case ( txt,
5969 SOME(((i_odeSchedule as HpcOmSimCode.LEVELSCHEDULE(useFixedAssignments = true)), (i_daeSchedule as HpcOmSimCode.LEVELSCHEDULE(useFixedAssignments = true)), (i_zeroFuncSchedule as HpcOmSimCode.LEVELSCHEDULE(useFixedAssignments = true)))),
5970 _,
5971 a_extraFuncsNamespace,
5972 a_type,
5973 a_useFlatArrayNotation,
5974 a_name,
5975 a_extraFuncsDecl,
5976 a_extraFuncs,
5977 a_simCode,
5978 a_varDecls,
5979 a_allEquationsPlusWhen,
5980 a_functionHead )
5981 algorithm
5982 1 str_7 := Tpl.textString(a_type);
5983 1 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := fun_169(txt, str_7, a_extraFuncsNamespace, a_functionHead, i_zeroFuncSchedule, i_daeSchedule, a_useFlatArrayNotation, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_name, a_varDecls, a_type, a_allEquationsPlusWhen, i_odeSchedule);
5984 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
5985
5986 case ( txt,
5987 SOME((HpcOmSimCode.THREADSCHEDULE(threadTasks = (i_odeSchedule_threadTasks as i_threadTasksOde)), HpcOmSimCode.THREADSCHEDULE(threadTasks = (i_daeSchedule_threadTasks as i_threadTasksDae)), HpcOmSimCode.THREADSCHEDULE(threadTasks = (i_zeroFuncSchedule_threadTasks as i_threadTasksZeroFunc)))),
5988 a_modelNamePrefixStr,
5989 a_extraFuncsNamespace,
5990 a_type,
5991 a_useFlatArrayNotation,
5992 a_name,
5993 a_extraFuncsDecl,
5994 a_extraFuncs,
5995 a_simCode,
5996 a_varDecls,
5997 a_allEquationsPlusWhen,
5998 a_functionHead )
5999 algorithm
6000 ✗ str_8 := Tpl.textString(a_type);
6001 ✗ (txt, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := fun_182(txt, str_8, a_modelNamePrefixStr, i_zeroFuncSchedule_threadTasks, i_daeSchedule_threadTasks, i_odeSchedule_threadTasks, a_functionHead, a_useFlatArrayNotation, a_name, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_allEquationsPlusWhen, i_threadTasksZeroFunc, i_threadTasksDae, a_type, i_threadTasksOde);
6002 ✗ then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
6003
6004 case ( txt,
6005 SOME((HpcOmSimCode.TASKDEPSCHEDULE(tasks = i_odeSchedule_tasks), HpcOmSimCode.TASKDEPSCHEDULE(tasks = i_daeSchedule_tasks), HpcOmSimCode.TASKDEPSCHEDULE(tasks = i_zeroFuncSchedule_tasks))),
6006 _,
6007 a_extraFuncsNamespace,
6008 a_type,
6009 a_useFlatArrayNotation,
6010 a_name,
6011 a_extraFuncsDecl,
6012 a_extraFuncs,
6013 a_simCode,
6014 a_varDecls,
6015 a_allEquationsPlusWhen,
6016 a_functionHead )
6017 algorithm
6018 ✗ str_9 := Tpl.textString(a_type);
6019 ✗ (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := fun_183(txt, str_9, a_name, a_functionHead, i_zeroFuncSchedule_tasks, i_daeSchedule_tasks, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_type, a_allEquationsPlusWhen, i_odeSchedule_tasks);
6020 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
6021
6022 case ( txt,
6023 _,
6024 _,
6025 a_extraFuncsNamespace,
6026 _,
6027 _,
6028 _,
6029 a_extraFuncsDecl,
6030 a_extraFuncs,
6031 _,
6032 a_varDecls,
6033 _,
6034 _ )
6035 ✗ then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
6036 end match;
6037 end fun_184;
6038
6039 protected function fun_185
6040 input Tpl.Text in_txt;
6041 input SimCode.SimCode in_a_simCode;
6042 input list<SimCode.SimEqSystem> in_a_allEquationsPlusWhen;
6043 input Absyn.Path in_a_name;
6044 input Tpl.Text in_a_extraFuncs;
6045 input Tpl.Text in_a_extraFuncsDecl;
6046 input Tpl.Text in_a_extraFuncsNamespace;
6047 input Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> in_a_schedulesOpt;
6048 input String in_a_modelNamePrefixStr;
6049 input Boolean in_a_useFlatArrayNotation;
6050
6051 output Tpl.Text out_txt;
6052 output Tpl.Text out_a_extraFuncs;
6053 output Tpl.Text out_a_extraFuncsDecl;
6054 output Tpl.Text out_a_extraFuncsNamespace;
6055 algorithm
6056 (out_txt, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) :=
6057 match(in_txt, in_a_simCode, in_a_allEquationsPlusWhen, in_a_name, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_schedulesOpt, in_a_modelNamePrefixStr, in_a_useFlatArrayNotation)
6058 local
6059 Tpl.Text txt;
6060 list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
6061 Absyn.Path a_name;
6062 Tpl.Text a_extraFuncs;
6063 Tpl.Text a_extraFuncsDecl;
6064 Tpl.Text a_extraFuncsNamespace;
6065 Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> a_schedulesOpt;
6066 String a_modelNamePrefixStr;
6067 Boolean a_useFlatArrayNotation;
6068 list<SimCode.ClockedPartition> i_clockedPartitions;
6069 SimCode.SimCode i_simCode;
6070 Tpl.Text txt_28;
6071 Tpl.Text l_functionHead;
6072 String ret_26;
6073 Tpl.Text l_type;
6074 Boolean ret_24;
6075 Boolean ret_23;
6076 String ret_22;
6077 Tpl.Text l_measureTimeEvaluateZeroFuncEnd;
6078 Boolean ret_20;
6079 Boolean ret_19;
6080 String ret_18;
6081 Tpl.Text l_measureTimeEvaluateZeroFuncStart;
6082 Boolean ret_16;
6083 Boolean ret_15;
6084 String ret_14;
6085 Tpl.Text l_measureTimeEvaluateAllEnd;
6086 Boolean ret_12;
6087 Boolean ret_11;
6088 String ret_10;
6089 Tpl.Text l_measureTimeEvaluateAllStart;
6090 Boolean ret_8;
6091 Boolean ret_7;
6092 String ret_6;
6093 Tpl.Text l_measureTimeEvaluateOdeEnd;
6094 Boolean ret_4;
6095 Boolean ret_3;
6096 String ret_2;
6097 Tpl.Text l_measureTimeEvaluateOdeStart;
6098 Tpl.Text l_varDecls;
6099
6100 case ( txt,
6101 (i_simCode as SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(name = _), clockedPartitions = i_clockedPartitions)),
6102 a_allEquationsPlusWhen,
6103 a_name,
6104 a_extraFuncs,
6105 a_extraFuncsDecl,
6106 a_extraFuncsNamespace,
6107 a_schedulesOpt,
6108 a_modelNamePrefixStr,
6109 a_useFlatArrayNotation )
6110 algorithm
6111 1 l_varDecls := Tpl.emptyTxt;
6112 1 ret_2 := Flags.getConfigString(Flags.PROFILING_LEVEL);
6113
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 ret_3 := stringEq(ret_2, "none");
6114 1 ret_4 := boolNot(ret_3);
6115 1 l_measureTimeEvaluateOdeStart := fun_152(Tpl.emptyTxt, ret_4);
6116 1 ret_6 := Flags.getConfigString(Flags.PROFILING_LEVEL);
6117
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 ret_7 := stringEq(ret_6, "none");
6118 1 ret_8 := boolNot(ret_7);
6119 1 l_measureTimeEvaluateOdeEnd := fun_153(Tpl.emptyTxt, ret_8);
6120 1 ret_10 := Flags.getConfigString(Flags.PROFILING_LEVEL);
6121
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 ret_11 := stringEq(ret_10, "none");
6122 1 ret_12 := boolNot(ret_11);
6123 1 l_measureTimeEvaluateAllStart := fun_154(Tpl.emptyTxt, ret_12);
6124 1 ret_14 := Flags.getConfigString(Flags.PROFILING_LEVEL);
6125
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 ret_15 := stringEq(ret_14, "none");
6126 1 ret_16 := boolNot(ret_15);
6127 1 l_measureTimeEvaluateAllEnd := fun_155(Tpl.emptyTxt, ret_16);
6128 1 ret_18 := Flags.getConfigString(Flags.PROFILING_LEVEL);
6129
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 ret_19 := stringEq(ret_18, "none");
6130 1 ret_20 := boolNot(ret_19);
6131 1 l_measureTimeEvaluateZeroFuncStart := fun_156(Tpl.emptyTxt, ret_20);
6132 1 ret_22 := Flags.getConfigString(Flags.PROFILING_LEVEL);
6133
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 ret_23 := stringEq(ret_22, "none");
6134 1 ret_24 := boolNot(ret_23);
6135 1 l_measureTimeEvaluateZeroFuncEnd := fun_157(Tpl.emptyTxt, ret_24);
6136 1 ret_26 := Flags.getConfigString(Flags.HPCOM_CODE);
6137 1 l_type := Tpl.writeStr(Tpl.emptyTxt, ret_26);
6138 1 l_functionHead := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("//using type: "));
6139 1 l_functionHead := Tpl.writeText(l_functionHead, l_type);
6140 1 l_functionHead := Tpl.softNewLine(l_functionHead);
6141 1 l_functionHead := Tpl.writeTok(l_functionHead, Tpl.ST_STRING_LIST({
6142 "\n",
6143 "void "
6144 }, false));
6145 1 l_functionHead := CodegenCpp.lastIdentOfPath(l_functionHead, a_name);
6146 1 l_functionHead := Tpl.writeTok(l_functionHead, Tpl.ST_STRING_LIST({
6147 "::evaluateZeroFuncs(const UPDATETYPE command)\n",
6148 "{\n"
6149 }, true));
6150 1 l_functionHead := Tpl.pushBlock(l_functionHead, Tpl.BT_INDENT(2));
6151 1 l_functionHead := Tpl.writeText(l_functionHead, l_measureTimeEvaluateZeroFuncStart);
6152 1 l_functionHead := Tpl.softNewLine(l_functionHead);
6153 1 l_functionHead := Tpl.writeTok(l_functionHead, Tpl.ST_LINE("evaluateParallel(command, 1);\n"));
6154 1 l_functionHead := Tpl.writeText(l_functionHead, l_measureTimeEvaluateZeroFuncEnd);
6155 1 l_functionHead := Tpl.softNewLine(l_functionHead);
6156 1 l_functionHead := Tpl.popBlock(l_functionHead);
6157 1 l_functionHead := Tpl.writeTok(l_functionHead, Tpl.ST_STRING_LIST({
6158 "}\n",
6159 "\n",
6160 "bool "
6161 }, false));
6162 1 l_functionHead := CodegenCpp.lastIdentOfPath(l_functionHead, a_name);
6163 1 l_functionHead := Tpl.writeTok(l_functionHead, Tpl.ST_STRING_LIST({
6164 "::evaluateAll(const UPDATETYPE command)\n",
6165 "{\n"
6166 }, true));
6167 1 l_functionHead := Tpl.pushBlock(l_functionHead, Tpl.BT_INDENT(2));
6168 1 l_functionHead := Tpl.writeText(l_functionHead, l_measureTimeEvaluateAllStart);
6169 1 l_functionHead := Tpl.softNewLine(l_functionHead);
6170 1 l_functionHead := Tpl.writeTok(l_functionHead, Tpl.ST_NEW_LINE());
6171 1 txt_28 := CodegenCppCommon.timeEventLength(Tpl.emptyTxt, i_simCode);
6172 1 l_functionHead := CodegenCpp.createTimeConditionTreatments(l_functionHead, Tpl.textString(txt_28), i_clockedPartitions);
6173 1 l_functionHead := Tpl.softNewLine(l_functionHead);
6174 1 l_functionHead := Tpl.writeTok(l_functionHead, Tpl.ST_NEW_LINE());
6175 1 l_functionHead := Tpl.writeText(l_functionHead, l_varDecls);
6176 1 l_functionHead := Tpl.softNewLine(l_functionHead);
6177 1 l_functionHead := Tpl.writeTok(l_functionHead, Tpl.ST_STRING_LIST({
6178 "\n",
6179 "evaluateParallel(command, -1);\n"
6180 }, true));
6181 1 l_functionHead := Tpl.writeText(l_functionHead, l_measureTimeEvaluateAllEnd);
6182 1 l_functionHead := Tpl.softNewLine(l_functionHead);
6183 1 l_functionHead := Tpl.writeTok(l_functionHead, Tpl.ST_STRING_LIST({
6184 "\n",
6185 "return _state_var_reinitialized;\n"
6186 }, true));
6187 1 l_functionHead := Tpl.popBlock(l_functionHead);
6188 1 l_functionHead := Tpl.writeTok(l_functionHead, Tpl.ST_STRING_LIST({
6189 "}\n",
6190 "\n",
6191 "void "
6192 }, false));
6193 1 l_functionHead := CodegenCpp.lastIdentOfPath(l_functionHead, a_name);
6194 1 l_functionHead := Tpl.writeTok(l_functionHead, Tpl.ST_STRING_LIST({
6195 "::evaluateODE(const UPDATETYPE command)\n",
6196 "{\n"
6197 }, true));
6198 1 l_functionHead := Tpl.pushBlock(l_functionHead, Tpl.BT_INDENT(2));
6199 1 l_functionHead := Tpl.writeText(l_functionHead, l_measureTimeEvaluateOdeStart);
6200 1 l_functionHead := Tpl.softNewLine(l_functionHead);
6201 1 l_functionHead := Tpl.writeTok(l_functionHead, Tpl.ST_LINE("evaluateParallel(command, 0);\n"));
6202 1 l_functionHead := Tpl.writeText(l_functionHead, l_measureTimeEvaluateOdeEnd);
6203 1 l_functionHead := Tpl.softNewLine(l_functionHead);
6204 1 l_functionHead := Tpl.popBlock(l_functionHead);
6205 1 l_functionHead := Tpl.writeTok(l_functionHead, Tpl.ST_STRING_LIST({
6206 "}\n",
6207 "\n",
6208 "//evaluateMode = 0 : evaluateODE\n",
6209 "//evaluateMode < 0 : evaluateAll\n",
6210 "//evaluateMode > 0 : evaluateZeroFunc\n",
6211 "void "
6212 }, false));
6213 1 l_functionHead := CodegenCpp.lastIdentOfPath(l_functionHead, a_name);
6214 1 l_functionHead := Tpl.writeTok(l_functionHead, Tpl.ST_STRING("::evaluateParallel(const UPDATETYPE command, int evaluateMode)"));
6215 1 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, l_varDecls) := fun_184(txt, a_schedulesOpt, a_modelNamePrefixStr, a_extraFuncsNamespace, l_type, a_useFlatArrayNotation, a_name, a_extraFuncsDecl, a_extraFuncs, i_simCode, l_varDecls, a_allEquationsPlusWhen, l_functionHead);
6216 1 then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
6217
6218 case ( txt,
6219 _,
6220 _,
6221 _,
6222 a_extraFuncs,
6223 a_extraFuncsDecl,
6224 a_extraFuncsNamespace,
6225 _,
6226 _,
6227 _ )
6228 then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
6229 end match;
6230 end fun_185;
6231
6232 public function generateParallelEvaluate
6233 input Tpl.Text txt;
6234 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
6235 input Absyn.Path a_name;
6236 input SimCode.SimCode a_simCode;
6237 input Tpl.Text a_extraFuncs;
6238 input Tpl.Text a_extraFuncsDecl;
6239 input Tpl.Text a_extraFuncsNamespace;
6240 input Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> a_schedulesOpt;
6241 input SimCodeFunction.Context a_context;
6242 input Tpl.Text a_stateDerVectorName;
6243 input String a_modelNamePrefixStr;
6244 input Boolean a_useFlatArrayNotation;
6245
6246 output Tpl.Text out_txt;
6247 output Tpl.Text out_a_extraFuncs;
6248 output Tpl.Text out_a_extraFuncsDecl;
6249 output Tpl.Text out_a_extraFuncsNamespace;
6250 output Tpl.Text out_a_stateDerVectorName;
6251 algorithm
6252 1 (out_txt, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := fun_185(txt, a_simCode, a_allEquationsPlusWhen, a_name, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_schedulesOpt, a_modelNamePrefixStr, a_useFlatArrayNotation);
6253 out_a_stateDerVectorName := a_stateDerVectorName;
6254 end generateParallelEvaluate;
6255
6256 protected function lm_187
6257 input output Tpl.Text txt;
6258 input list<Integer> items;
6259 algorithm
6260
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 time.
3 for lstElt_187 in items loop
6261 txt := match lstElt_187
6262 local
6263 Integer i_index;
6264
6265 case i_index
6266 algorithm
6267 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("PREFETCH(&__z["));
6268 2 txt := Tpl.writeStr(txt, intString(i_index));
6269 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("], 0, 3);"));
6270 2 txt := Tpl.nextIter(txt);
6271 then txt;
6272 end match;
6273 end for;
6274 end lm_187;
6275
6276 protected function fun_188
6277 input Tpl.Text in_txt;
6278 input SimCode.SimCode in_a_simCode;
6279
6280 output Tpl.Text out_txt;
6281 algorithm
6282 out_txt :=
6283 match(in_txt, in_a_simCode)
6284 local
6285 Tpl.Text txt;
6286 list<SimCodeVar.SimVar> i_vars_stateVars;
6287 list<Integer> ret_2;
6288 Integer ret_1;
6289 Integer ret_0;
6290
6291 case ( txt,
6292 SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(vars = SimCodeVar.SIMVARS(stateVars = i_vars_stateVars))) )
6293 algorithm
6294 1 ret_0 := listLength(i_vars_stateVars);
6295 1 ret_1 := intSub(ret_0, 1);
6296 1 ret_2 := List.intRange3(0, 8, ret_1);
6297 1 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
6298 1 txt := lm_187(txt, ret_2);
6299 1 txt := Tpl.popIter(txt);
6300 then txt;
6301
6302 case ( txt,
6303 _ )
6304 then txt;
6305 end match;
6306 end fun_188;
6307
6308 public function generateStateVarPrefetchCode
6309 input Tpl.Text txt;
6310 input SimCode.SimCode a_simCode;
6311 input Tpl.Text a_extraFuncs;
6312 input Tpl.Text a_extraFuncsDecl;
6313 input Tpl.Text a_extraFuncsNamespace;
6314
6315 output Tpl.Text out_txt;
6316 output Tpl.Text out_a_extraFuncs;
6317 output Tpl.Text out_a_extraFuncsDecl;
6318 output Tpl.Text out_a_extraFuncsNamespace;
6319 algorithm
6320 1 out_txt := fun_188(txt, a_simCode);
6321 out_a_extraFuncs := a_extraFuncs;
6322 out_a_extraFuncsDecl := a_extraFuncsDecl;
6323 out_a_extraFuncsNamespace := a_extraFuncsNamespace;
6324 end generateStateVarPrefetchCode;
6325
6326 protected function lm_190
6327 input output Tpl.Text txt;
6328 input list<HpcOmSimCode.Task> items;
6329 input Boolean a_useFlatArrayNotation;
6330 input output Tpl.Text a_extraFuncsNamespace;
6331 input output Tpl.Text a_extraFuncsDecl;
6332 input output Tpl.Text a_extraFuncs;
6333 input SimCode.SimCode a_simCode;
6334 input output Tpl.Text a_varDecls;
6335 input String a_iType;
6336 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
6337 algorithm
6338 ✗ for lstElt_190 in items loop
6339 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_190
6340 local
6341 HpcOmSimCode.Task i_task;
6342
6343 case i_task
6344 algorithm
6345 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := generateLevelCodeForTask(txt, a_allEquationsPlusWhen, i_task, a_iType, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
6346 ✗ txt := Tpl.nextIter(txt);
6347 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
6348 end match;
6349 end for;
6350 end lm_190;
6351
6352 protected function lm_191
6353 input output Tpl.Text txt;
6354 input list<HpcOmSimCode.Task> items;
6355 input Boolean a_useFlatArrayNotation;
6356 input output Tpl.Text a_extraFuncsNamespace;
6357 input output Tpl.Text a_extraFuncsDecl;
6358 input output Tpl.Text a_extraFuncs;
6359 input SimCode.SimCode a_simCode;
6360 input output Tpl.Text a_varDecls;
6361 input String a_iType;
6362 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
6363 algorithm
6364 ✗ for lstElt_191 in items loop
6365 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_191
6366 local
6367 HpcOmSimCode.Task i_task;
6368
6369 case i_task
6370 algorithm
6371 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := generateLevelCodeForTask(txt, a_allEquationsPlusWhen, i_task, a_iType, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
6372 ✗ txt := Tpl.nextIter(txt);
6373 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
6374 end match;
6375 end for;
6376 end lm_191;
6377
6378 protected function fun_192
6379 input Tpl.Text in_txt;
6380 input HpcOmSimCode.TaskList in_a_tasksOfLevel;
6381 input list<SimCode.SimEqSystem> in_a_allEquationsPlusWhen;
6382 input String in_a_iType;
6383 input Tpl.Text in_a_varDecls;
6384 input SimCode.SimCode in_a_simCode;
6385 input Tpl.Text in_a_extraFuncs;
6386 input Tpl.Text in_a_extraFuncsDecl;
6387 input Tpl.Text in_a_extraFuncsNamespace;
6388 input Boolean in_a_useFlatArrayNotation;
6389
6390 output Tpl.Text out_txt;
6391 output Tpl.Text out_a_varDecls;
6392 output Tpl.Text out_a_extraFuncs;
6393 output Tpl.Text out_a_extraFuncsDecl;
6394 output Tpl.Text out_a_extraFuncsNamespace;
6395 algorithm
6396 (out_txt, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) :=
6397 match(in_txt, in_a_tasksOfLevel, in_a_allEquationsPlusWhen, in_a_iType, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_useFlatArrayNotation)
6398 local
6399 Tpl.Text txt;
6400 list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
6401 String a_iType;
6402 Tpl.Text a_varDecls;
6403 SimCode.SimCode a_simCode;
6404 Tpl.Text a_extraFuncs;
6405 Tpl.Text a_extraFuncsDecl;
6406 Tpl.Text a_extraFuncsNamespace;
6407 Boolean a_useFlatArrayNotation;
6408 list<HpcOmSimCode.Task> i_tasks;
6409 Tpl.Text l_odeEqs;
6410
6411 case ( txt,
6412 HpcOmSimCode.PARALLELTASKLIST(tasks = i_tasks),
6413 a_allEquationsPlusWhen,
6414 a_iType,
6415 a_varDecls,
6416 a_simCode,
6417 a_extraFuncs,
6418 a_extraFuncsDecl,
6419 a_extraFuncsNamespace,
6420 a_useFlatArrayNotation )
6421 algorithm
6422 ✗ l_odeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
6423 ✗ (l_odeEqs, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_190(l_odeEqs, i_tasks, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_iType, a_allEquationsPlusWhen);
6424 ✗ l_odeEqs := Tpl.popIter(l_odeEqs);
6425 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
6426 "#pragma omp sections\n",
6427 "{\n"
6428 }, true));
6429 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
6430 ✗ txt := Tpl.writeText(txt, l_odeEqs);
6431 ✗ txt := Tpl.softNewLine(txt);
6432 ✗ txt := Tpl.popBlock(txt);
6433 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
6434 ✗ then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
6435
6436 case ( txt,
6437 HpcOmSimCode.SERIALTASKLIST(tasks = i_tasks),
6438 a_allEquationsPlusWhen,
6439 a_iType,
6440 a_varDecls,
6441 a_simCode,
6442 a_extraFuncs,
6443 a_extraFuncsDecl,
6444 a_extraFuncsNamespace,
6445 a_useFlatArrayNotation )
6446 algorithm
6447 ✗ l_odeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
6448 ✗ (l_odeEqs, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_191(l_odeEqs, i_tasks, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_iType, a_allEquationsPlusWhen);
6449 ✗ l_odeEqs := Tpl.popIter(l_odeEqs);
6450 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
6451 "#pragma omp master\n",
6452 "{\n"
6453 }, true));
6454 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
6455 ✗ txt := Tpl.writeText(txt, l_odeEqs);
6456 ✗ txt := Tpl.softNewLine(txt);
6457 ✗ txt := Tpl.popBlock(txt);
6458 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
6459 "}\n",
6460 "#pragma omp barrier"
6461 }, false));
6462 ✗ then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
6463
6464 case ( txt,
6465 _,
6466 _,
6467 _,
6468 a_varDecls,
6469 _,
6470 a_extraFuncs,
6471 a_extraFuncsDecl,
6472 a_extraFuncsNamespace,
6473 _ )
6474 then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
6475 end match;
6476 end fun_192;
6477
6478 public function generateLevelCodeForLevel
6479 input Tpl.Text txt;
6480 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
6481 input HpcOmSimCode.TaskList a_tasksOfLevel;
6482 input String a_iType;
6483 input Tpl.Text a_varDecls;
6484 input SimCode.SimCode a_simCode;
6485 input Tpl.Text a_extraFuncs;
6486 input Tpl.Text a_extraFuncsDecl;
6487 input Tpl.Text a_extraFuncsNamespace;
6488 input Boolean a_useFlatArrayNotation;
6489
6490 output Tpl.Text out_txt;
6491 output Tpl.Text out_a_varDecls;
6492 output Tpl.Text out_a_extraFuncs;
6493 output Tpl.Text out_a_extraFuncsDecl;
6494 output Tpl.Text out_a_extraFuncsNamespace;
6495 algorithm
6496 ✗ (out_txt, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := fun_192(txt, a_tasksOfLevel, a_allEquationsPlusWhen, a_iType, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
6497 end generateLevelCodeForLevel;
6498
6499 public function generateLevelCodeForTask
6500 input Tpl.Text txt;
6501 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
6502 input HpcOmSimCode.Task a_iTask;
6503 input String a_iType;
6504 input Tpl.Text a_varDecls;
6505 input SimCode.SimCode a_simCode;
6506 input Tpl.Text a_extraFuncs;
6507 input Tpl.Text a_extraFuncsDecl;
6508 input Tpl.Text a_extraFuncsNamespace;
6509 input Boolean a_useFlatArrayNotation;
6510
6511 output Tpl.Text out_txt;
6512 output Tpl.Text out_a_varDecls;
6513 output Tpl.Text out_a_extraFuncs;
6514 output Tpl.Text out_a_extraFuncsDecl;
6515 output Tpl.Text out_a_extraFuncsNamespace;
6516 algorithm
6517 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
6518 "#pragma omp section\n",
6519 "{\n"
6520 }, true));
6521 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
6522 ✗ (out_txt, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := taskCode(out_txt, a_allEquationsPlusWhen, a_iTask, a_iType, "", a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
6523 ✗ out_txt := Tpl.softNewLine(out_txt);
6524 ✗ out_txt := Tpl.popBlock(out_txt);
6525 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("}"));
6526 end generateLevelCodeForTask;
6527
6528 protected function lm_195
6529 input output Tpl.Text txt;
6530 input list<HpcOmSimCode.Task> items;
6531 input Boolean a_useFlatArrayNotation;
6532 input output Tpl.Text a_extraFuncsNamespace;
6533 input output Tpl.Text a_extraFuncsDecl;
6534 input output Tpl.Text a_extraFuncs;
6535 input SimCode.SimCode a_simCode;
6536 input output Tpl.Text a_varDecls;
6537 input String a_iType;
6538 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
6539 algorithm
6540 ✗ for lstElt_195 in items loop
6541 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_195
6542 local
6543 HpcOmSimCode.Task i_t;
6544
6545 case i_t
6546 algorithm
6547 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := taskCode(txt, a_allEquationsPlusWhen, i_t, a_iType, "", a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
6548 ✗ txt := Tpl.nextIter(txt);
6549 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
6550 end match;
6551 end for;
6552 end lm_195;
6553
6554 protected function lm_196
6555 input output Tpl.Text txt;
6556 input list<list<HpcOmSimCode.Task>> items;
6557 input Boolean a_useFlatArrayNotation;
6558 input output Tpl.Text a_extraFuncsNamespace;
6559 input output Tpl.Text a_extraFuncsDecl;
6560 input output Tpl.Text a_extraFuncs;
6561 input SimCode.SimCode a_simCode;
6562 input output Tpl.Text a_varDecls;
6563 input String a_iType;
6564 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
6565 algorithm
6566 ✗ for lstElt_196 in items loop
6567 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_196
6568 local
6569 Integer x_i0;
6570 list<HpcOmSimCode.Task> i_threadTasks;
6571
6572 case i_threadTasks
6573 algorithm
6574 ✗ x_i0 := Tpl.getIteri_i0(txt);
6575 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("if(threadNum == "));
6576 ✗ txt := Tpl.writeStr(txt, intString(x_i0));
6577 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(") {\n"));
6578 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
6579 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
6580 ✗ (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_195(txt, i_threadTasks, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_iType, a_allEquationsPlusWhen);
6581 ✗ txt := Tpl.popIter(txt);
6582 ✗ txt := Tpl.softNewLine(txt);
6583 ✗ txt := Tpl.popBlock(txt);
6584 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
6585 ✗ txt := Tpl.nextIter(txt);
6586 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
6587 end match;
6588 end for;
6589 end lm_196;
6590
6591 public function generateLevelFixedCodeForLevel
6592 input Tpl.Text txt;
6593 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
6594 input array<list<HpcOmSimCode.Task>> a_tasksOfLevel;
6595 input String a_iType;
6596 input Tpl.Text a_varDecls;
6597 input Absyn.Path a_name;
6598 input SimCode.SimCode a_simCode;
6599 input Tpl.Text a_extraFuncs;
6600 input Tpl.Text a_extraFuncsDecl;
6601 input Tpl.Text a_extraFuncsNamespace;
6602 input Boolean a_useFlatArrayNotation;
6603
6604 output Tpl.Text out_txt;
6605 output Tpl.Text out_a_varDecls;
6606 output Tpl.Text out_a_extraFuncs;
6607 output Tpl.Text out_a_extraFuncsDecl;
6608 output Tpl.Text out_a_extraFuncsNamespace;
6609 protected
6610 list<list<HpcOmSimCode.Task>> ret_1;
6611 Tpl.Text l_eqs;
6612 algorithm
6613 ✗ ret_1 := arrayList(a_tasksOfLevel);
6614 ✗ l_eqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
6615 ✗ (l_eqs, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls) := lm_196(l_eqs, ret_1, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_iType, a_allEquationsPlusWhen);
6616 ✗ l_eqs := Tpl.popIter(l_eqs);
6617 ✗ out_txt := Tpl.writeText(txt, l_eqs);
6618 ✗ out_txt := Tpl.softNewLine(out_txt);
6619 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("#pragma omp barrier"));
6620 end generateLevelFixedCodeForLevel;
6621
6622 protected function lm_198
6623 input output Tpl.Text txt;
6624 input list<list<HpcOmSimCode.Task>> items;
6625 input Boolean a_useFlatArrayNotation;
6626 input output Tpl.Text a_extraFuncsNamespace;
6627 input output Tpl.Text a_extraFuncsDecl;
6628 input output Tpl.Text a_extraFuncs;
6629 input SimCode.SimCode a_simCode;
6630 input output Tpl.Text a_varDecls;
6631 input String a_iType;
6632 input Integer a_iThreadIdx;
6633 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
6634 algorithm
6635
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 time.
3 for lstElt_198 in items loop
6636 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_198
6637 local
6638 Integer x_levelIdx;
6639 list<HpcOmSimCode.Task> i_tasks;
6640
6641 case i_tasks
6642 algorithm
6643 2 x_levelIdx := Tpl.getIteri_i0(txt);
6644 2 (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := generateLevelFixedCodeForThreadLevel(txt, a_allEquationsPlusWhen, i_tasks, a_iThreadIdx, "evaluateODE", a_iType, x_levelIdx, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
6645 2 txt := Tpl.nextIter(txt);
6646 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
6647 end match;
6648 end for;
6649 end lm_198;
6650
6651 protected function lm_199
6652 input output Tpl.Text txt;
6653 input list<list<HpcOmSimCode.Task>> items;
6654 input Boolean a_useFlatArrayNotation;
6655 input output Tpl.Text a_extraFuncsNamespace;
6656 input output Tpl.Text a_extraFuncsDecl;
6657 input output Tpl.Text a_extraFuncs;
6658 input SimCode.SimCode a_simCode;
6659 input output Tpl.Text a_varDecls;
6660 input String a_iType;
6661 input Integer a_iThreadIdx;
6662 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
6663 algorithm
6664
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 time.
5 for lstElt_199 in items loop
6665 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_199
6666 local
6667 Integer x_levelIdx;
6668 list<HpcOmSimCode.Task> i_tasks;
6669
6670 case i_tasks
6671 algorithm
6672 4 x_levelIdx := Tpl.getIteri_i0(txt);
6673 4 (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := generateLevelFixedCodeForThreadLevel(txt, a_allEquationsPlusWhen, i_tasks, a_iThreadIdx, "evaluateDAE", a_iType, x_levelIdx, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
6674 4 txt := Tpl.nextIter(txt);
6675 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
6676 end match;
6677 end for;
6678 end lm_199;
6679
6680 protected function lm_200
6681 input output Tpl.Text txt;
6682 input list<list<HpcOmSimCode.Task>> items;
6683 input Boolean a_useFlatArrayNotation;
6684 input output Tpl.Text a_extraFuncsNamespace;
6685 input output Tpl.Text a_extraFuncsDecl;
6686 input output Tpl.Text a_extraFuncs;
6687 input SimCode.SimCode a_simCode;
6688 input output Tpl.Text a_varDecls;
6689 input String a_iType;
6690 input Integer a_iThreadIdx;
6691 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
6692 algorithm
6693
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 for lstElt_200 in items loop
6694 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_200
6695 local
6696 Integer x_levelIdx;
6697 list<HpcOmSimCode.Task> i_tasks;
6698
6699 case i_tasks
6700 algorithm
6701 1 x_levelIdx := Tpl.getIteri_i0(txt);
6702 1 (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := generateLevelFixedCodeForThreadLevel(txt, a_allEquationsPlusWhen, i_tasks, a_iThreadIdx, "evaluateZeroFuncs", a_iType, x_levelIdx, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
6703 1 txt := Tpl.nextIter(txt);
6704 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
6705 end match;
6706 end for;
6707 end lm_200;
6708
6709 protected function fun_201
6710 input Tpl.Text in_txt;
6711 input Boolean in_mArg;
6712
6713 output Tpl.Text out_txt;
6714 algorithm
6715 out_txt :=
6716 match(in_txt, in_mArg)
6717 local
6718 Tpl.Text txt;
6719
6720 case ( txt,
6721 false )
6722 then txt;
6723
6724 case ( txt,
6725 _ )
6726 algorithm
6727 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
6728 "MeasureTimeValues *valuesStart = MeasureTime::getZeroValues();\n",
6729 "MeasureTimeValues *valuesEnd = MeasureTime::getZeroValues();"
6730 }, false));
6731 then txt;
6732 end match;
6733 end fun_201;
6734
6735 protected function fun_202
6736 input Tpl.Text in_txt;
6737 input Boolean in_mArg;
6738 input Integer in_a_iThreadIdx;
6739
6740 output Tpl.Text out_txt;
6741 algorithm
6742 out_txt :=
6743 match(in_txt, in_mArg, in_a_iThreadIdx)
6744 local
6745 Tpl.Text txt;
6746 Integer a_iThreadIdx;
6747 Tpl.Text txt_0;
6748
6749 case ( txt,
6750 false,
6751 _ )
6752 then txt;
6753
6754 case ( txt,
6755 _,
6756 a_iThreadIdx )
6757 algorithm
6758 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("evaluateODEThread"));
6759 ✗ txt_0 := Tpl.writeStr(txt_0, intString(a_iThreadIdx));
6760 ✗ txt := CodegenCpp.generateMeasureTimeStartCode(txt, "valuesStart", Tpl.textString(txt_0), "MEASURETIME_MODELFUNCTIONS");
6761 then txt;
6762 end match;
6763 end fun_202;
6764
6765 protected function fun_203
6766 input Tpl.Text in_txt;
6767 input Boolean in_mArg;
6768 input Integer in_a_iThreadIdx;
6769
6770 output Tpl.Text out_txt;
6771 algorithm
6772 out_txt :=
6773 match(in_txt, in_mArg, in_a_iThreadIdx)
6774 local
6775 Tpl.Text txt;
6776 Integer a_iThreadIdx;
6777 Tpl.Text txt_1;
6778 Tpl.Text txt_0;
6779
6780 case ( txt,
6781 false,
6782 _ )
6783 then txt;
6784
6785 case ( txt,
6786 _,
6787 a_iThreadIdx )
6788 algorithm
6789 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("(*measureTimeThreadArrayOdeHpcom)["));
6790 ✗ txt_0 := Tpl.writeStr(txt_0, intString(a_iThreadIdx));
6791 ✗ txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("]"));
6792 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("evaluateODEThread"));
6793 ✗ txt_1 := Tpl.writeStr(txt_1, intString(a_iThreadIdx));
6794 ✗ txt := CodegenCpp.generateMeasureTimeEndCode(txt, "valuesStart", "valuesEnd", Tpl.textString(txt_0), Tpl.textString(txt_1), "MEASURETIME_MODELFUNCTIONS");
6795 then txt;
6796 end match;
6797 end fun_203;
6798
6799 protected function fun_204
6800 input Tpl.Text in_txt;
6801 input Boolean in_mArg;
6802 input Integer in_a_iThreadIdx;
6803
6804 output Tpl.Text out_txt;
6805 algorithm
6806 out_txt :=
6807 match(in_txt, in_mArg, in_a_iThreadIdx)
6808 local
6809 Tpl.Text txt;
6810 Integer a_iThreadIdx;
6811 Tpl.Text txt_1;
6812 Tpl.Text txt_0;
6813
6814 case ( txt,
6815 false,
6816 _ )
6817 then txt;
6818
6819 case ( txt,
6820 _,
6821 a_iThreadIdx )
6822 algorithm
6823 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("(*measureTimeThreadArrayDaeHpcom)["));
6824 ✗ txt_0 := Tpl.writeStr(txt_0, intString(a_iThreadIdx));
6825 ✗ txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("]"));
6826 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("evaluateDaeThread"));
6827 ✗ txt_1 := Tpl.writeStr(txt_1, intString(a_iThreadIdx));
6828 ✗ txt := CodegenCpp.generateMeasureTimeEndCode(txt, "valuesStart", "valuesEnd", Tpl.textString(txt_0), Tpl.textString(txt_1), "MEASURETIME_MODELFUNCTIONS");
6829 then txt;
6830 end match;
6831 end fun_204;
6832
6833 protected function fun_205
6834 input Tpl.Text in_txt;
6835 input Boolean in_mArg;
6836 input Integer in_a_iThreadIdx;
6837
6838 output Tpl.Text out_txt;
6839 algorithm
6840 out_txt :=
6841 match(in_txt, in_mArg, in_a_iThreadIdx)
6842 local
6843 Tpl.Text txt;
6844 Integer a_iThreadIdx;
6845 Tpl.Text txt_1;
6846 Tpl.Text txt_0;
6847
6848 case ( txt,
6849 false,
6850 _ )
6851 then txt;
6852
6853 case ( txt,
6854 _,
6855 a_iThreadIdx )
6856 algorithm
6857 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("(*measureTimeThreadArrayZeroFuncHpcom)["));
6858 ✗ txt_0 := Tpl.writeStr(txt_0, intString(a_iThreadIdx));
6859 ✗ txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("]"));
6860 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("evaluateZeroFuncThread"));
6861 ✗ txt_1 := Tpl.writeStr(txt_1, intString(a_iThreadIdx));
6862 ✗ txt := CodegenCpp.generateMeasureTimeEndCode(txt, "valuesStart", "valuesEnd", Tpl.textString(txt_0), Tpl.textString(txt_1), "MEASURETIME_MODELFUNCTIONS");
6863 then txt;
6864 end match;
6865 end fun_205;
6866
6867 protected function fun_206
6868 input Tpl.Text in_txt;
6869 input Boolean in_mArg;
6870
6871 output Tpl.Text out_txt;
6872 algorithm
6873 out_txt :=
6874 match(in_txt, in_mArg)
6875 local
6876 Tpl.Text txt;
6877
6878 case ( txt,
6879 false )
6880 then txt;
6881
6882 case ( txt,
6883 _ )
6884 algorithm
6885 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
6886 "delete valuesStart;\n",
6887 "delete valuesEnd;"
6888 }, false));
6889 then txt;
6890 end match;
6891 end fun_206;
6892
6893 protected function fun_207
6894 input Tpl.Text in_txt;
6895 input Boolean in_mArg;
6896 input Integer in_a_iThreadIdx;
6897 input Absyn.Path in_a_name;
6898
6899 output Tpl.Text out_txt;
6900 algorithm
6901 out_txt :=
6902 match(in_txt, in_mArg, in_a_iThreadIdx, in_a_name)
6903 local
6904 Tpl.Text txt;
6905 Integer a_iThreadIdx;
6906 Absyn.Path a_name;
6907 Boolean ret_17;
6908 Boolean ret_16;
6909 String ret_15;
6910 Boolean ret_14;
6911 Boolean ret_13;
6912 String ret_12;
6913 Boolean ret_11;
6914 Boolean ret_10;
6915 String ret_9;
6916 Boolean ret_8;
6917 Boolean ret_7;
6918 String ret_6;
6919 Boolean ret_5;
6920 Boolean ret_4;
6921 String ret_3;
6922 Boolean ret_2;
6923 Boolean ret_1;
6924 String ret_0;
6925
6926 case ( txt,
6927 false,
6928 _,
6929 _ )
6930 then txt;
6931
6932 case ( txt,
6933 _,
6934 a_iThreadIdx,
6935 a_name )
6936 algorithm
6937 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("void "));
6938 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
6939 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFunc"));
6940 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
6941 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
6942 "()\n",
6943 "{\n"
6944 }, true));
6945 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
6946 ✗ ret_0 := Flags.getConfigString(Flags.PROFILING_LEVEL);
6947 ✗ ret_1 := stringEq(ret_0, "none");
6948 ✗ ret_2 := boolNot(ret_1);
6949 ✗ txt := fun_201(txt, ret_2);
6950 ✗ txt := Tpl.softNewLine(txt);
6951 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
6952 "\n",
6953 "while(!_simulationFinished)\n",
6954 "{\n",
6955 " //_evaluateBarrier.wait();\n",
6956 " _levelBarrier.wait();\n",
6957 " if(_simulationFinished)\n",
6958 " {\n",
6959 " //_evaluateBarrier.wait();\n",
6960 " _levelBarrier.wait();\n",
6961 " break;\n",
6962 " }\n"
6963 }, true));
6964 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
6965 ✗ ret_3 := Flags.getConfigString(Flags.PROFILING_LEVEL);
6966 ✗ ret_4 := stringEq(ret_3, "none");
6967 ✗ ret_5 := boolNot(ret_4);
6968 ✗ txt := fun_202(txt, ret_5, a_iThreadIdx);
6969 ✗ txt := Tpl.softNewLine(txt);
6970 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
6971 "if(_evaluateMode == 0)\n",
6972 "{\n"
6973 }, true));
6974 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
6975 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("evaluateThreadFuncODE_"));
6976 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
6977 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("();\n"));
6978 ✗ ret_6 := Flags.getConfigString(Flags.PROFILING_LEVEL);
6979 ✗ ret_7 := stringEq(ret_6, "none");
6980 ✗ ret_8 := boolNot(ret_7);
6981 ✗ txt := fun_203(txt, ret_8, a_iThreadIdx);
6982 ✗ txt := Tpl.softNewLine(txt);
6983 ✗ txt := Tpl.popBlock(txt);
6984 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
6985 "}\n",
6986 "else if(_evaluateMode < 0)\n",
6987 "{\n"
6988 }, true));
6989 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
6990 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("evaluateThreadFuncAll_"));
6991 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
6992 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("();\n"));
6993 ✗ ret_9 := Flags.getConfigString(Flags.PROFILING_LEVEL);
6994 ✗ ret_10 := stringEq(ret_9, "none");
6995 ✗ ret_11 := boolNot(ret_10);
6996 ✗ txt := fun_204(txt, ret_11, a_iThreadIdx);
6997 ✗ txt := Tpl.softNewLine(txt);
6998 ✗ txt := Tpl.popBlock(txt);
6999 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7000 "}\n",
7001 "else\n",
7002 "{\n"
7003 }, true));
7004 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
7005 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("evaluateThreadFuncZeroFunc_"));
7006 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
7007 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("();\n"));
7008 ✗ ret_12 := Flags.getConfigString(Flags.PROFILING_LEVEL);
7009 ✗ ret_13 := stringEq(ret_12, "none");
7010 ✗ ret_14 := boolNot(ret_13);
7011 ✗ txt := fun_205(txt, ret_14, a_iThreadIdx);
7012 ✗ txt := Tpl.softNewLine(txt);
7013 ✗ txt := Tpl.popBlock(txt);
7014 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7015 "}\n",
7016 "\n",
7017 "//_evaluateBarrier.wait();\n",
7018 "_levelBarrier.wait();\n"
7019 }, true));
7020 ✗ txt := Tpl.popBlock(txt);
7021 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
7022 ✗ ret_15 := Flags.getConfigString(Flags.PROFILING_LEVEL);
7023 ✗ ret_16 := stringEq(ret_15, "none");
7024 ✗ ret_17 := boolNot(ret_16);
7025 ✗ txt := fun_206(txt, ret_17);
7026 ✗ txt := Tpl.softNewLine(txt);
7027 ✗ txt := Tpl.popBlock(txt);
7028 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
7029 then txt;
7030 end match;
7031 end fun_207;
7032
7033 protected function fun_208
7034 input Tpl.Text in_txt;
7035 input tuple<list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>> in_a_tasksOfLevels;
7036 input Absyn.Path in_a_name;
7037 input Boolean in_a_useFlatArrayNotation;
7038 input Tpl.Text in_a_extraFuncsNamespace;
7039 input Tpl.Text in_a_extraFuncsDecl;
7040 input Tpl.Text in_a_extraFuncs;
7041 input SimCode.SimCode in_a_simCode;
7042 input Tpl.Text in_a_varDecls;
7043 input String in_a_iType;
7044 input Integer in_a_iThreadIdx;
7045 input list<SimCode.SimEqSystem> in_a_allEquationsPlusWhen;
7046
7047 output Tpl.Text out_txt;
7048 output Tpl.Text out_a_extraFuncsNamespace;
7049 output Tpl.Text out_a_extraFuncsDecl;
7050 output Tpl.Text out_a_extraFuncs;
7051 output Tpl.Text out_a_varDecls;
7052 algorithm
7053 (out_txt, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls) :=
7054 match(in_txt, in_a_tasksOfLevels, in_a_name, in_a_useFlatArrayNotation, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_iType, in_a_iThreadIdx, in_a_allEquationsPlusWhen)
7055 local
7056 Tpl.Text txt;
7057 Absyn.Path a_name;
7058 Boolean a_useFlatArrayNotation;
7059 Tpl.Text a_extraFuncsNamespace;
7060 Tpl.Text a_extraFuncsDecl;
7061 Tpl.Text a_extraFuncs;
7062 SimCode.SimCode a_simCode;
7063 Tpl.Text a_varDecls;
7064 String a_iType;
7065 Integer a_iThreadIdx;
7066 list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
7067 list<list<HpcOmSimCode.Task>> i_zeroFuncTasksOfLevel;
7068 list<list<HpcOmSimCode.Task>> i_daeTasksOfLevel;
7069 list<list<HpcOmSimCode.Task>> i_odeTasksOfLevel;
7070 Boolean ret_3;
7071 Tpl.Text l_zeroFuncEqs;
7072 Tpl.Text l_daeEqs;
7073 Tpl.Text l_odeEqs;
7074
7075 case ( txt,
7076 (i_odeTasksOfLevel, i_daeTasksOfLevel, i_zeroFuncTasksOfLevel),
7077 a_name,
7078 a_useFlatArrayNotation,
7079 a_extraFuncsNamespace,
7080 a_extraFuncsDecl,
7081 a_extraFuncs,
7082 a_simCode,
7083 a_varDecls,
7084 a_iType,
7085 a_iThreadIdx,
7086 a_allEquationsPlusWhen )
7087 algorithm
7088 1 l_odeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
7089 1 (l_odeEqs, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_198(l_odeEqs, i_odeTasksOfLevel, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_iType, a_iThreadIdx, a_allEquationsPlusWhen);
7090 1 l_odeEqs := Tpl.popIter(l_odeEqs);
7091 1 l_daeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
7092 1 (l_daeEqs, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_199(l_daeEqs, i_daeTasksOfLevel, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_iType, a_iThreadIdx, a_allEquationsPlusWhen);
7093 1 l_daeEqs := Tpl.popIter(l_daeEqs);
7094 1 l_zeroFuncEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
7095 1 (l_zeroFuncEqs, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_200(l_zeroFuncEqs, i_zeroFuncTasksOfLevel, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_iType, a_iThreadIdx, a_allEquationsPlusWhen);
7096 1 l_zeroFuncEqs := Tpl.popIter(l_zeroFuncEqs);
7097 1 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING("void evaluateThreadFuncODE_"));
7098 1 a_extraFuncsDecl := Tpl.writeStr(a_extraFuncsDecl, intString(a_iThreadIdx));
7099 1 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING_LIST({
7100 "();\n",
7101 "void evaluateThreadFuncAll_"
7102 }, false));
7103 1 a_extraFuncsDecl := Tpl.writeStr(a_extraFuncsDecl, intString(a_iThreadIdx));
7104 1 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING_LIST({
7105 "();\n",
7106 "void evaluateThreadFuncZeroFunc_"
7107 }, false));
7108 1 a_extraFuncsDecl := Tpl.writeStr(a_extraFuncsDecl, intString(a_iThreadIdx));
7109 1 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING_LIST({
7110 "();\n",
7111 "void evaluateThreadFunc"
7112 }, false));
7113 1 a_extraFuncsDecl := Tpl.writeStr(a_extraFuncsDecl, intString(a_iThreadIdx));
7114 1 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_LINE("();\n"));
7115 1 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_NEW_LINE());
7116 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("void "));
7117 1 txt := CodegenCpp.lastIdentOfPath(txt, a_name);
7118 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFuncODE_"));
7119 1 txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
7120 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7121 "()\n",
7122 "{\n"
7123 }, true));
7124 1 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
7125 1 txt := Tpl.writeText(txt, l_odeEqs);
7126 1 txt := Tpl.softNewLine(txt);
7127 1 txt := Tpl.popBlock(txt);
7128 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7129 "}\n",
7130 "\n",
7131 "void "
7132 }, false));
7133 1 txt := CodegenCpp.lastIdentOfPath(txt, a_name);
7134 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFuncAll_"));
7135 1 txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
7136 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7137 "()\n",
7138 "{\n"
7139 }, true));
7140 1 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
7141 1 txt := Tpl.writeText(txt, l_daeEqs);
7142 1 txt := Tpl.softNewLine(txt);
7143 1 txt := Tpl.popBlock(txt);
7144 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7145 "}\n",
7146 "\n",
7147 "void "
7148 }, false));
7149 1 txt := CodegenCpp.lastIdentOfPath(txt, a_name);
7150 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFuncZeroFunc_"));
7151 1 txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
7152 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7153 "()\n",
7154 "{\n"
7155 }, true));
7156 1 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
7157 1 txt := Tpl.writeText(txt, l_zeroFuncEqs);
7158 1 txt := Tpl.softNewLine(txt);
7159 1 txt := Tpl.popBlock(txt);
7160 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7161 "}\n",
7162 "\n"
7163 }, true));
7164 1 ret_3 := intGt(a_iThreadIdx, 0);
7165 1 txt := fun_207(txt, ret_3, a_iThreadIdx, a_name);
7166 1 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
7167
7168 case ( txt,
7169 _,
7170 _,
7171 _,
7172 a_extraFuncsNamespace,
7173 a_extraFuncsDecl,
7174 a_extraFuncs,
7175 _,
7176 a_varDecls,
7177 _,
7178 _,
7179 _ )
7180 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
7181 end match;
7182 end fun_208;
7183
7184 protected function lm_209
7185 input output Tpl.Text txt;
7186 input list<list<HpcOmSimCode.Task>> items;
7187 input Boolean a_useFlatArrayNotation;
7188 input output Tpl.Text a_extraFuncsNamespace;
7189 input output Tpl.Text a_extraFuncsDecl;
7190 input output Tpl.Text a_extraFuncs;
7191 input SimCode.SimCode a_simCode;
7192 input output Tpl.Text a_varDecls;
7193 input String a_iType;
7194 input Integer a_iThreadIdx;
7195 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
7196 algorithm
7197 ✗ for lstElt_209 in items loop
7198 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_209
7199 local
7200 Integer x_levelIdx;
7201 list<HpcOmSimCode.Task> i_tasks;
7202
7203 case i_tasks
7204 algorithm
7205 ✗ x_levelIdx := Tpl.getIteri_i0(txt);
7206 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := generateLevelFixedCodeForThreadLevel(txt, a_allEquationsPlusWhen, i_tasks, a_iThreadIdx, "evaluateODE", a_iType, x_levelIdx, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
7207 ✗ txt := Tpl.nextIter(txt);
7208 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
7209 end match;
7210 end for;
7211 end lm_209;
7212
7213 protected function lm_210
7214 input output Tpl.Text txt;
7215 input list<list<HpcOmSimCode.Task>> items;
7216 input Boolean a_useFlatArrayNotation;
7217 input output Tpl.Text a_extraFuncsNamespace;
7218 input output Tpl.Text a_extraFuncsDecl;
7219 input output Tpl.Text a_extraFuncs;
7220 input SimCode.SimCode a_simCode;
7221 input output Tpl.Text a_varDecls;
7222 input String a_iType;
7223 input Integer a_iThreadIdx;
7224 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
7225 algorithm
7226 ✗ for lstElt_210 in items loop
7227 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_210
7228 local
7229 Integer x_levelIdx;
7230 list<HpcOmSimCode.Task> i_tasks;
7231
7232 case i_tasks
7233 algorithm
7234 ✗ x_levelIdx := Tpl.getIteri_i0(txt);
7235 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := generateLevelFixedCodeForThreadLevel(txt, a_allEquationsPlusWhen, i_tasks, a_iThreadIdx, "evaluateDAE", a_iType, x_levelIdx, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
7236 ✗ txt := Tpl.nextIter(txt);
7237 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
7238 end match;
7239 end for;
7240 end lm_210;
7241
7242 protected function lm_211
7243 input output Tpl.Text txt;
7244 input list<list<HpcOmSimCode.Task>> items;
7245 input Boolean a_useFlatArrayNotation;
7246 input output Tpl.Text a_extraFuncsNamespace;
7247 input output Tpl.Text a_extraFuncsDecl;
7248 input output Tpl.Text a_extraFuncs;
7249 input SimCode.SimCode a_simCode;
7250 input output Tpl.Text a_varDecls;
7251 input String a_iType;
7252 input Integer a_iThreadIdx;
7253 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
7254 algorithm
7255 ✗ for lstElt_211 in items loop
7256 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_211
7257 local
7258 Integer x_levelIdx;
7259 list<HpcOmSimCode.Task> i_tasks;
7260
7261 case i_tasks
7262 algorithm
7263 ✗ x_levelIdx := Tpl.getIteri_i0(txt);
7264 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := generateLevelFixedCodeForThreadLevel(txt, a_allEquationsPlusWhen, i_tasks, a_iThreadIdx, "evaluateZeroFuncs", a_iType, x_levelIdx, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
7265 ✗ txt := Tpl.nextIter(txt);
7266 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
7267 end match;
7268 end for;
7269 end lm_211;
7270
7271 protected function fun_212
7272 input Tpl.Text in_txt;
7273 input Boolean in_mArg;
7274
7275 output Tpl.Text out_txt;
7276 algorithm
7277 out_txt :=
7278 match(in_txt, in_mArg)
7279 local
7280 Tpl.Text txt;
7281
7282 case ( txt,
7283 false )
7284 then txt;
7285
7286 case ( txt,
7287 _ )
7288 algorithm
7289 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7290 "MeasureTimeValues *valuesStart = MeasureTime::getZeroValues();\n",
7291 "MeasureTimeValues *valuesEnd = MeasureTime::getZeroValues();"
7292 }, false));
7293 then txt;
7294 end match;
7295 end fun_212;
7296
7297 protected function fun_213
7298 input Tpl.Text in_txt;
7299 input Boolean in_mArg;
7300 input Integer in_a_iThreadIdx;
7301
7302 output Tpl.Text out_txt;
7303 algorithm
7304 out_txt :=
7305 match(in_txt, in_mArg, in_a_iThreadIdx)
7306 local
7307 Tpl.Text txt;
7308 Integer a_iThreadIdx;
7309 Tpl.Text txt_0;
7310
7311 case ( txt,
7312 false,
7313 _ )
7314 then txt;
7315
7316 case ( txt,
7317 _,
7318 a_iThreadIdx )
7319 algorithm
7320 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("evaluateODEThread"));
7321 ✗ txt_0 := Tpl.writeStr(txt_0, intString(a_iThreadIdx));
7322 ✗ txt := CodegenCpp.generateMeasureTimeStartCode(txt, "valuesStart", Tpl.textString(txt_0), "MEASURETIME_MODELFUNCTIONS");
7323 then txt;
7324 end match;
7325 end fun_213;
7326
7327 protected function fun_214
7328 input Tpl.Text in_txt;
7329 input Boolean in_mArg;
7330 input Integer in_a_iThreadIdx;
7331
7332 output Tpl.Text out_txt;
7333 algorithm
7334 out_txt :=
7335 match(in_txt, in_mArg, in_a_iThreadIdx)
7336 local
7337 Tpl.Text txt;
7338 Integer a_iThreadIdx;
7339 Tpl.Text txt_1;
7340 Tpl.Text txt_0;
7341
7342 case ( txt,
7343 false,
7344 _ )
7345 then txt;
7346
7347 case ( txt,
7348 _,
7349 a_iThreadIdx )
7350 algorithm
7351 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("(*measureTimeThreadArrayOdeHpcom)["));
7352 ✗ txt_0 := Tpl.writeStr(txt_0, intString(a_iThreadIdx));
7353 ✗ txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("]"));
7354 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("evaluateODEThread"));
7355 ✗ txt_1 := Tpl.writeStr(txt_1, intString(a_iThreadIdx));
7356 ✗ txt := CodegenCpp.generateMeasureTimeEndCode(txt, "valuesStart", "valuesEnd", Tpl.textString(txt_0), Tpl.textString(txt_1), "MEASURETIME_MODELFUNCTIONS");
7357 then txt;
7358 end match;
7359 end fun_214;
7360
7361 protected function fun_215
7362 input Tpl.Text in_txt;
7363 input Boolean in_mArg;
7364 input Integer in_a_iThreadIdx;
7365
7366 output Tpl.Text out_txt;
7367 algorithm
7368 out_txt :=
7369 match(in_txt, in_mArg, in_a_iThreadIdx)
7370 local
7371 Tpl.Text txt;
7372 Integer a_iThreadIdx;
7373 Tpl.Text txt_1;
7374 Tpl.Text txt_0;
7375
7376 case ( txt,
7377 false,
7378 _ )
7379 then txt;
7380
7381 case ( txt,
7382 _,
7383 a_iThreadIdx )
7384 algorithm
7385 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("(*measureTimeThreadArrayDaeHpcom)["));
7386 ✗ txt_0 := Tpl.writeStr(txt_0, intString(a_iThreadIdx));
7387 ✗ txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("]"));
7388 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("evaluateDaeThread"));
7389 ✗ txt_1 := Tpl.writeStr(txt_1, intString(a_iThreadIdx));
7390 ✗ txt := CodegenCpp.generateMeasureTimeEndCode(txt, "valuesStart", "valuesEnd", Tpl.textString(txt_0), Tpl.textString(txt_1), "MEASURETIME_MODELFUNCTIONS");
7391 then txt;
7392 end match;
7393 end fun_215;
7394
7395 protected function fun_216
7396 input Tpl.Text in_txt;
7397 input Boolean in_mArg;
7398 input Integer in_a_iThreadIdx;
7399
7400 output Tpl.Text out_txt;
7401 algorithm
7402 out_txt :=
7403 match(in_txt, in_mArg, in_a_iThreadIdx)
7404 local
7405 Tpl.Text txt;
7406 Integer a_iThreadIdx;
7407 Tpl.Text txt_1;
7408 Tpl.Text txt_0;
7409
7410 case ( txt,
7411 false,
7412 _ )
7413 then txt;
7414
7415 case ( txt,
7416 _,
7417 a_iThreadIdx )
7418 algorithm
7419 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("(*measureTimeThreadArrayZeroFuncHpcom)["));
7420 ✗ txt_0 := Tpl.writeStr(txt_0, intString(a_iThreadIdx));
7421 ✗ txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("]"));
7422 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("evaluateZeroFuncThread"));
7423 ✗ txt_1 := Tpl.writeStr(txt_1, intString(a_iThreadIdx));
7424 ✗ txt := CodegenCpp.generateMeasureTimeEndCode(txt, "valuesStart", "valuesEnd", Tpl.textString(txt_0), Tpl.textString(txt_1), "MEASURETIME_MODELFUNCTIONS");
7425 then txt;
7426 end match;
7427 end fun_216;
7428
7429 protected function fun_217
7430 input Tpl.Text in_txt;
7431 input Boolean in_mArg;
7432
7433 output Tpl.Text out_txt;
7434 algorithm
7435 out_txt :=
7436 match(in_txt, in_mArg)
7437 local
7438 Tpl.Text txt;
7439
7440 case ( txt,
7441 false )
7442 then txt;
7443
7444 case ( txt,
7445 _ )
7446 algorithm
7447 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7448 "delete valuesStart;\n",
7449 "delete valuesEnd;"
7450 }, false));
7451 then txt;
7452 end match;
7453 end fun_217;
7454
7455 protected function fun_218
7456 input Tpl.Text in_txt;
7457 input Boolean in_mArg;
7458 input Integer in_a_iThreadIdx;
7459 input Absyn.Path in_a_name;
7460
7461 output Tpl.Text out_txt;
7462 algorithm
7463 out_txt :=
7464 match(in_txt, in_mArg, in_a_iThreadIdx, in_a_name)
7465 local
7466 Tpl.Text txt;
7467 Integer a_iThreadIdx;
7468 Absyn.Path a_name;
7469 Boolean ret_17;
7470 Boolean ret_16;
7471 String ret_15;
7472 Boolean ret_14;
7473 Boolean ret_13;
7474 String ret_12;
7475 Boolean ret_11;
7476 Boolean ret_10;
7477 String ret_9;
7478 Boolean ret_8;
7479 Boolean ret_7;
7480 String ret_6;
7481 Boolean ret_5;
7482 Boolean ret_4;
7483 String ret_3;
7484 Boolean ret_2;
7485 Boolean ret_1;
7486 String ret_0;
7487
7488 case ( txt,
7489 false,
7490 _,
7491 _ )
7492 then txt;
7493
7494 case ( txt,
7495 _,
7496 a_iThreadIdx,
7497 a_name )
7498 algorithm
7499 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("void "));
7500 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
7501 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFunc"));
7502 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
7503 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7504 "()\n",
7505 "{\n"
7506 }, true));
7507 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
7508 ✗ ret_0 := Flags.getConfigString(Flags.PROFILING_LEVEL);
7509 ✗ ret_1 := stringEq(ret_0, "none");
7510 ✗ ret_2 := boolNot(ret_1);
7511 ✗ txt := fun_212(txt, ret_2);
7512 ✗ txt := Tpl.softNewLine(txt);
7513 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7514 "\n",
7515 "while(!_simulationFinished)\n",
7516 "{\n",
7517 " //_evaluateBarrier.wait();\n",
7518 " _levelBarrier.wait();\n",
7519 " if(_simulationFinished)\n",
7520 " {\n",
7521 " //_evaluateBarrier.wait();\n",
7522 " _levelBarrier.wait();\n",
7523 " break;\n",
7524 " }\n"
7525 }, true));
7526 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
7527 ✗ ret_3 := Flags.getConfigString(Flags.PROFILING_LEVEL);
7528 ✗ ret_4 := stringEq(ret_3, "none");
7529 ✗ ret_5 := boolNot(ret_4);
7530 ✗ txt := fun_213(txt, ret_5, a_iThreadIdx);
7531 ✗ txt := Tpl.softNewLine(txt);
7532 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7533 "if(_evaluateMode == 0)\n",
7534 "{\n"
7535 }, true));
7536 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
7537 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("evaluateThreadFuncODE_"));
7538 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
7539 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("();\n"));
7540 ✗ ret_6 := Flags.getConfigString(Flags.PROFILING_LEVEL);
7541 ✗ ret_7 := stringEq(ret_6, "none");
7542 ✗ ret_8 := boolNot(ret_7);
7543 ✗ txt := fun_214(txt, ret_8, a_iThreadIdx);
7544 ✗ txt := Tpl.softNewLine(txt);
7545 ✗ txt := Tpl.popBlock(txt);
7546 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7547 "}\n",
7548 "else if(_evaluateMode < 0)\n",
7549 "{\n"
7550 }, true));
7551 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
7552 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("evaluateThreadFuncAll_"));
7553 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
7554 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("();\n"));
7555 ✗ ret_9 := Flags.getConfigString(Flags.PROFILING_LEVEL);
7556 ✗ ret_10 := stringEq(ret_9, "none");
7557 ✗ ret_11 := boolNot(ret_10);
7558 ✗ txt := fun_215(txt, ret_11, a_iThreadIdx);
7559 ✗ txt := Tpl.softNewLine(txt);
7560 ✗ txt := Tpl.popBlock(txt);
7561 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7562 "}\n",
7563 "else\n",
7564 "{\n"
7565 }, true));
7566 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
7567 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("evaluateThreadFuncZeroFunc_"));
7568 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
7569 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("();\n"));
7570 ✗ ret_12 := Flags.getConfigString(Flags.PROFILING_LEVEL);
7571 ✗ ret_13 := stringEq(ret_12, "none");
7572 ✗ ret_14 := boolNot(ret_13);
7573 ✗ txt := fun_216(txt, ret_14, a_iThreadIdx);
7574 ✗ txt := Tpl.softNewLine(txt);
7575 ✗ txt := Tpl.popBlock(txt);
7576 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7577 "}\n",
7578 "\n",
7579 "//_evaluateBarrier.wait();\n",
7580 "_levelBarrier.wait();\n"
7581 }, true));
7582 ✗ txt := Tpl.popBlock(txt);
7583 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
7584 ✗ ret_15 := Flags.getConfigString(Flags.PROFILING_LEVEL);
7585 ✗ ret_16 := stringEq(ret_15, "none");
7586 ✗ ret_17 := boolNot(ret_16);
7587 ✗ txt := fun_217(txt, ret_17);
7588 ✗ txt := Tpl.softNewLine(txt);
7589 ✗ txt := Tpl.popBlock(txt);
7590 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
7591 then txt;
7592 end match;
7593 end fun_218;
7594
7595 protected function fun_219
7596 input Tpl.Text in_txt;
7597 input tuple<list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>> in_a_tasksOfLevels;
7598 input Absyn.Path in_a_name;
7599 input Boolean in_a_useFlatArrayNotation;
7600 input Tpl.Text in_a_extraFuncsNamespace;
7601 input Tpl.Text in_a_extraFuncsDecl;
7602 input Tpl.Text in_a_extraFuncs;
7603 input SimCode.SimCode in_a_simCode;
7604 input Tpl.Text in_a_varDecls;
7605 input String in_a_iType;
7606 input Integer in_a_iThreadIdx;
7607 input list<SimCode.SimEqSystem> in_a_allEquationsPlusWhen;
7608
7609 output Tpl.Text out_txt;
7610 output Tpl.Text out_a_extraFuncsNamespace;
7611 output Tpl.Text out_a_extraFuncsDecl;
7612 output Tpl.Text out_a_extraFuncs;
7613 output Tpl.Text out_a_varDecls;
7614 algorithm
7615 (out_txt, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls) :=
7616 match(in_txt, in_a_tasksOfLevels, in_a_name, in_a_useFlatArrayNotation, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_iType, in_a_iThreadIdx, in_a_allEquationsPlusWhen)
7617 local
7618 Tpl.Text txt;
7619 Absyn.Path a_name;
7620 Boolean a_useFlatArrayNotation;
7621 Tpl.Text a_extraFuncsNamespace;
7622 Tpl.Text a_extraFuncsDecl;
7623 Tpl.Text a_extraFuncs;
7624 SimCode.SimCode a_simCode;
7625 Tpl.Text a_varDecls;
7626 String a_iType;
7627 Integer a_iThreadIdx;
7628 list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
7629 list<list<HpcOmSimCode.Task>> i_zeroFuncTasksOfLevel;
7630 list<list<HpcOmSimCode.Task>> i_daeTasksOfLevel;
7631 list<list<HpcOmSimCode.Task>> i_odeTasksOfLevel;
7632 Boolean ret_3;
7633 Tpl.Text l_zeroFuncEqs;
7634 Tpl.Text l_daeEqs;
7635 Tpl.Text l_odeEqs;
7636
7637 case ( txt,
7638 (i_odeTasksOfLevel, i_daeTasksOfLevel, i_zeroFuncTasksOfLevel),
7639 a_name,
7640 a_useFlatArrayNotation,
7641 a_extraFuncsNamespace,
7642 a_extraFuncsDecl,
7643 a_extraFuncs,
7644 a_simCode,
7645 a_varDecls,
7646 a_iType,
7647 a_iThreadIdx,
7648 a_allEquationsPlusWhen )
7649 algorithm
7650 ✗ l_odeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
7651 ✗ (l_odeEqs, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_209(l_odeEqs, i_odeTasksOfLevel, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_iType, a_iThreadIdx, a_allEquationsPlusWhen);
7652 ✗ l_odeEqs := Tpl.popIter(l_odeEqs);
7653 ✗ l_daeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
7654 ✗ (l_daeEqs, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_210(l_daeEqs, i_daeTasksOfLevel, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_iType, a_iThreadIdx, a_allEquationsPlusWhen);
7655 ✗ l_daeEqs := Tpl.popIter(l_daeEqs);
7656 ✗ l_zeroFuncEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
7657 ✗ (l_zeroFuncEqs, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_211(l_zeroFuncEqs, i_zeroFuncTasksOfLevel, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_iType, a_iThreadIdx, a_allEquationsPlusWhen);
7658 ✗ l_zeroFuncEqs := Tpl.popIter(l_zeroFuncEqs);
7659 ✗ a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING("void evaluateThreadFuncODE_"));
7660 ✗ a_extraFuncsDecl := Tpl.writeStr(a_extraFuncsDecl, intString(a_iThreadIdx));
7661 ✗ a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING_LIST({
7662 "();\n",
7663 "void evaluateThreadFuncAll_"
7664 }, false));
7665 ✗ a_extraFuncsDecl := Tpl.writeStr(a_extraFuncsDecl, intString(a_iThreadIdx));
7666 ✗ a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING_LIST({
7667 "();\n",
7668 "void evaluateThreadFuncZeroFunc_"
7669 }, false));
7670 ✗ a_extraFuncsDecl := Tpl.writeStr(a_extraFuncsDecl, intString(a_iThreadIdx));
7671 ✗ a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING_LIST({
7672 "();\n",
7673 "void evaluateThreadFunc"
7674 }, false));
7675 ✗ a_extraFuncsDecl := Tpl.writeStr(a_extraFuncsDecl, intString(a_iThreadIdx));
7676 ✗ a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_LINE("();\n"));
7677 ✗ a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_NEW_LINE());
7678 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("void "));
7679 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
7680 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFuncODE_"));
7681 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
7682 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7683 "()\n",
7684 "{\n"
7685 }, true));
7686 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
7687 ✗ txt := Tpl.writeText(txt, l_odeEqs);
7688 ✗ txt := Tpl.softNewLine(txt);
7689 ✗ txt := Tpl.popBlock(txt);
7690 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7691 "}\n",
7692 "\n",
7693 "void "
7694 }, false));
7695 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
7696 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFuncAll_"));
7697 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
7698 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7699 "()\n",
7700 "{\n"
7701 }, true));
7702 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
7703 ✗ txt := Tpl.writeText(txt, l_daeEqs);
7704 ✗ txt := Tpl.softNewLine(txt);
7705 ✗ txt := Tpl.popBlock(txt);
7706 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7707 "}\n",
7708 "\n",
7709 "void "
7710 }, false));
7711 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
7712 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFuncZeroFunc_"));
7713 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
7714 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7715 "()\n",
7716 "{\n"
7717 }, true));
7718 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
7719 ✗ txt := Tpl.writeText(txt, l_zeroFuncEqs);
7720 ✗ txt := Tpl.softNewLine(txt);
7721 ✗ txt := Tpl.popBlock(txt);
7722 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7723 "}\n",
7724 "\n"
7725 }, true));
7726 ✗ ret_3 := intGt(a_iThreadIdx, 0);
7727 ✗ txt := fun_218(txt, ret_3, a_iThreadIdx, a_name);
7728 ✗ then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
7729
7730 case ( txt,
7731 _,
7732 _,
7733 _,
7734 a_extraFuncsNamespace,
7735 a_extraFuncsDecl,
7736 a_extraFuncs,
7737 _,
7738 a_varDecls,
7739 _,
7740 _,
7741 _ )
7742 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
7743 end match;
7744 end fun_219;
7745
7746 protected function fun_220
7747 input Tpl.Text in_txt;
7748 input String in_a_iType;
7749 input list<SimCode.SimEqSystem> in_a_allEquationsPlusWhen;
7750 input tuple<list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>> in_a_tasksOfLevels;
7751 input Integer in_a_iThreadIdx;
7752 input Tpl.Text in_a_varDecls;
7753 input Absyn.Path in_a_name;
7754 input SimCode.SimCode in_a_simCode;
7755 input Tpl.Text in_a_extraFuncs;
7756 input Tpl.Text in_a_extraFuncsDecl;
7757 input Tpl.Text in_a_extraFuncsNamespace;
7758 input Boolean in_a_useFlatArrayNotation;
7759
7760 output Tpl.Text out_txt;
7761 output Tpl.Text out_a_varDecls;
7762 output Tpl.Text out_a_extraFuncs;
7763 output Tpl.Text out_a_extraFuncsDecl;
7764 output Tpl.Text out_a_extraFuncsNamespace;
7765 algorithm
7766 (out_txt, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) :=
7767 match(in_txt, in_a_iType, in_a_allEquationsPlusWhen, in_a_tasksOfLevels, in_a_iThreadIdx, in_a_varDecls, in_a_name, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_useFlatArrayNotation)
7768 local
7769 Tpl.Text txt;
7770 list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
7771 tuple<list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>> a_tasksOfLevels;
7772 Integer a_iThreadIdx;
7773 Tpl.Text a_varDecls;
7774 Absyn.Path a_name;
7775 SimCode.SimCode a_simCode;
7776 Tpl.Text a_extraFuncs;
7777 Tpl.Text a_extraFuncsDecl;
7778 Tpl.Text a_extraFuncsNamespace;
7779 Boolean a_useFlatArrayNotation;
7780 String i_iType;
7781
7782 case ( txt,
7783 (i_iType as "pthreads"),
7784 a_allEquationsPlusWhen,
7785 a_tasksOfLevels,
7786 a_iThreadIdx,
7787 a_varDecls,
7788 a_name,
7789 a_simCode,
7790 a_extraFuncs,
7791 a_extraFuncsDecl,
7792 a_extraFuncsNamespace,
7793 a_useFlatArrayNotation )
7794 algorithm
7795 1 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := fun_208(txt, a_tasksOfLevels, a_name, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, i_iType, a_iThreadIdx, a_allEquationsPlusWhen);
7796 1 then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
7797
7798 case ( txt,
7799 (i_iType as "pthreads_spin"),
7800 a_allEquationsPlusWhen,
7801 a_tasksOfLevels,
7802 a_iThreadIdx,
7803 a_varDecls,
7804 a_name,
7805 a_simCode,
7806 a_extraFuncs,
7807 a_extraFuncsDecl,
7808 a_extraFuncsNamespace,
7809 a_useFlatArrayNotation )
7810 algorithm
7811 ✗ (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := fun_219(txt, a_tasksOfLevels, a_name, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, i_iType, a_iThreadIdx, a_allEquationsPlusWhen);
7812 ✗ then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
7813
7814 case ( txt,
7815 _,
7816 _,
7817 _,
7818 _,
7819 a_varDecls,
7820 _,
7821 _,
7822 a_extraFuncs,
7823 a_extraFuncsDecl,
7824 a_extraFuncsNamespace,
7825 _ )
7826 then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
7827 end match;
7828 end fun_220;
7829
7830 public function generateLevelFixedCodeForThread
7831 input Tpl.Text txt;
7832 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
7833 input tuple<list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>, list<list<HpcOmSimCode.Task>>> a_tasksOfLevels;
7834 input Integer a_iThreadIdx;
7835 input String a_iType;
7836 input Tpl.Text a_varDecls;
7837 input Absyn.Path a_name;
7838 input SimCode.SimCode a_simCode;
7839 input Tpl.Text a_extraFuncs;
7840 input Tpl.Text a_extraFuncsDecl;
7841 input Tpl.Text a_extraFuncsNamespace;
7842 input Boolean a_useFlatArrayNotation;
7843
7844 output Tpl.Text out_txt;
7845 output Tpl.Text out_a_varDecls;
7846 output Tpl.Text out_a_extraFuncs;
7847 output Tpl.Text out_a_extraFuncsDecl;
7848 output Tpl.Text out_a_extraFuncsNamespace;
7849 algorithm
7850 1 (out_txt, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := fun_220(txt, a_iType, a_allEquationsPlusWhen, a_tasksOfLevels, a_iThreadIdx, a_varDecls, a_name, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
7851 end generateLevelFixedCodeForThread;
7852
7853 protected function lm_222
7854 input output Tpl.Text txt;
7855 input list<HpcOmSimCode.Task> items;
7856 input Boolean a_useFlatArrayNotation;
7857 input output Tpl.Text a_extraFuncsNamespace;
7858 input output Tpl.Text a_extraFuncsDecl;
7859 input output Tpl.Text a_extraFuncs;
7860 input SimCode.SimCode a_simCode;
7861 input output Tpl.Text a_varDecls;
7862 input String a_iType;
7863 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
7864 algorithm
7865
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 7 times.
109 for lstElt_222 in items loop
7866 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_222
7867 local
7868 HpcOmSimCode.Task i_t;
7869
7870 case i_t
7871 algorithm
7872 102 (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := taskCode(txt, a_allEquationsPlusWhen, i_t, a_iType, "", a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
7873 102 txt := Tpl.nextIter(txt);
7874 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
7875 end match;
7876 end for;
7877 end lm_222;
7878
7879 protected function fun_223
7880 input Tpl.Text in_txt;
7881 input Boolean in_mArg;
7882 input Integer in_a_iLevelIdx;
7883 input String in_a_functionName;
7884
7885 output Tpl.Text out_txt;
7886 algorithm
7887 out_txt :=
7888 match(in_txt, in_mArg, in_a_iLevelIdx, in_a_functionName)
7889 local
7890 Tpl.Text txt;
7891 Integer a_iLevelIdx;
7892 String a_functionName;
7893 Tpl.Text txt_0;
7894 Integer ret_0;
7895
7896 case ( txt,
7897 false,
7898 _,
7899 _ )
7900 then txt;
7901
7902 case ( txt,
7903 _,
7904 a_iLevelIdx,
7905 a_functionName )
7906 algorithm
7907 7 txt_0 := Tpl.writeStr(Tpl.emptyTxt, a_functionName);
7908 7 txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("_level_"));
7909 7 ret_0 := intAdd(a_iLevelIdx, 1);
7910 7 txt_0 := Tpl.writeStr(txt_0, intString(ret_0));
7911 7 txt := CodegenCpp.generateMeasureTimeStartCode(txt, "measuredSchedulerStartValues", Tpl.textString(txt_0), "MEASURETIME_MODELFUNCTIONS");
7912 then txt;
7913 end match;
7914 end fun_223;
7915
7916 protected function fun_224
7917 input Tpl.Text in_txt;
7918 input Boolean in_mArg;
7919
7920 output Tpl.Text out_txt;
7921 algorithm
7922 out_txt :=
7923 match(in_txt, in_mArg)
7924 local
7925 Tpl.Text txt;
7926
7927 case ( txt,
7928 false )
7929 then txt;
7930
7931 case ( txt,
7932 _ )
7933 then txt;
7934 end match;
7935 end fun_224;
7936
7937 protected function fun_225
7938 input Tpl.Text in_txt;
7939 input Boolean in_mArg;
7940 input Integer in_a_iLevelIdx;
7941 input String in_a_functionName;
7942
7943 output Tpl.Text out_txt;
7944 algorithm
7945 out_txt :=
7946 match(in_txt, in_mArg, in_a_iLevelIdx, in_a_functionName)
7947 local
7948 Tpl.Text txt;
7949 Integer a_iLevelIdx;
7950 String a_functionName;
7951 Tpl.Text txt_1;
7952 Integer ret_1;
7953 Tpl.Text txt_0;
7954
7955 case ( txt,
7956 false,
7957 _,
7958 _ )
7959 then txt;
7960
7961 case ( txt,
7962 _,
7963 a_iLevelIdx,
7964 a_functionName )
7965 algorithm
7966 7 txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("(*measureTimeSchedulerArrayHpcom_"));
7967 7 txt_0 := Tpl.writeStr(txt_0, a_functionName);
7968 7 txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING(")["));
7969 7 txt_0 := Tpl.writeStr(txt_0, intString(a_iLevelIdx));
7970 7 txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("]"));
7971 7 txt_1 := Tpl.writeStr(Tpl.emptyTxt, a_functionName);
7972 7 txt_1 := Tpl.writeTok(txt_1, Tpl.ST_STRING("_level_"));
7973 7 ret_1 := intAdd(a_iLevelIdx, 1);
7974 7 txt_1 := Tpl.writeStr(txt_1, intString(ret_1));
7975 7 txt := CodegenCpp.generateMeasureTimeEndCode(txt, "measuredSchedulerStartValues", "measuredSchedulerEndValues", Tpl.textString(txt_0), Tpl.textString(txt_1), "MEASURETIME_MODELFUNCTIONS");
7976 then txt;
7977 end match;
7978 end fun_225;
7979
7980 public function generateLevelFixedCodeForThreadLevel
7981 input Tpl.Text txt;
7982 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
7983 input list<HpcOmSimCode.Task> a_tasksOfLevel;
7984 input Integer a_iThreadIdx;
7985 input String a_functionName;
7986 input String a_iType;
7987 input Integer a_iLevelIdx;
7988 input Tpl.Text a_varDecls;
7989 input SimCode.SimCode a_simCode;
7990 input Tpl.Text a_extraFuncs;
7991 input Tpl.Text a_extraFuncsDecl;
7992 input Tpl.Text a_extraFuncsNamespace;
7993 input Boolean a_useFlatArrayNotation;
7994
7995 output Tpl.Text out_txt;
7996 output Tpl.Text out_a_varDecls;
7997 output Tpl.Text out_a_extraFuncs;
7998 output Tpl.Text out_a_extraFuncsDecl;
7999 output Tpl.Text out_a_extraFuncsNamespace;
8000 protected
8001 Boolean ret_3;
8002 Boolean ret_2;
8003 Boolean ret_1;
8004 Tpl.Text l_tasks;
8005 algorithm
8006 7 l_tasks := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
8007 7 (l_tasks, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls) := lm_222(l_tasks, a_tasksOfLevel, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_iType, a_allEquationsPlusWhen);
8008 7 l_tasks := Tpl.popIter(l_tasks);
8009 7 out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("//Start of Level "));
8010 7 out_txt := Tpl.writeStr(out_txt, intString(a_iLevelIdx));
8011 7 out_txt := Tpl.softNewLine(out_txt);
8012 7 ret_1 := intEq(a_iThreadIdx, 0);
8013 7 out_txt := fun_223(out_txt, ret_1, a_iLevelIdx, a_functionName);
8014 7 out_txt := Tpl.softNewLine(out_txt);
8015 7 out_txt := Tpl.writeTok(out_txt, Tpl.ST_NEW_LINE());
8016
1/4
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
7 ret_2 := stringEq(Tpl.textString(l_tasks), "");
8017 7 out_txt := fun_224(out_txt, ret_2);
8018 7 out_txt := Tpl.softNewLine(out_txt);
8019 7 out_txt := Tpl.writeText(out_txt, l_tasks);
8020 7 out_txt := Tpl.softNewLine(out_txt);
8021 7 out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
8022 "_levelBarrier.wait();\n",
8023 "\n"
8024 }, true));
8025 ret_3 := intEq(a_iThreadIdx, 0);
8026 7 out_txt := fun_225(out_txt, ret_3, a_iLevelIdx, a_functionName);
8027 7 out_txt := Tpl.softNewLine(out_txt);
8028 7 out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("//End of Level "));
8029 7 out_txt := Tpl.writeStr(out_txt, intString(a_iLevelIdx));
8030 end generateLevelFixedCodeForThreadLevel;
8031
8032 protected function lm_227
8033 input output Tpl.Text txt;
8034 input list<tuple<HpcOmSimCode.Task, list<Integer>>> items;
8035 input Boolean a_useFlatArrayNotation;
8036 input output Tpl.Text a_extraFuncsNamespace;
8037 input output Tpl.Text a_extraFuncsDecl;
8038 input output Tpl.Text a_extraFuncs;
8039 input SimCode.SimCode a_simCode;
8040 input output Tpl.Text a_varDecls;
8041 input String a_iType;
8042 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
8043 algorithm
8044 ✗ for lstElt_227 in items loop
8045 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_227
8046 local
8047 tuple<HpcOmSimCode.Task, list<Integer>> i_t;
8048
8049 case i_t
8050 algorithm
8051 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := function_HPCOM_TaskDep0(txt, i_t, a_allEquationsPlusWhen, a_iType, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
8052 ✗ txt := Tpl.nextIter(txt);
8053 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
8054 end match;
8055 end for;
8056 end lm_227;
8057
8058 public function function_HPCOM_TaskDep
8059 input Tpl.Text txt;
8060 input list<tuple<HpcOmSimCode.Task, list<Integer>>> a_tasks;
8061 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
8062 input String a_iType;
8063 input Tpl.Text a_varDecls;
8064 input SimCode.SimCode a_simCode;
8065 input Tpl.Text a_extraFuncs;
8066 input Tpl.Text a_extraFuncsDecl;
8067 input Tpl.Text a_extraFuncsNamespace;
8068 input Boolean a_useFlatArrayNotation;
8069
8070 output Tpl.Text out_txt;
8071 output Tpl.Text out_a_varDecls;
8072 output Tpl.Text out_a_extraFuncs;
8073 output Tpl.Text out_a_extraFuncsDecl;
8074 output Tpl.Text out_a_extraFuncsNamespace;
8075 protected
8076 Tpl.Text l_odeEqs;
8077 algorithm
8078 ✗ l_odeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
8079 ✗ (l_odeEqs, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls) := lm_227(l_odeEqs, a_tasks, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_iType, a_allEquationsPlusWhen);
8080 ✗ l_odeEqs := Tpl.popIter(l_odeEqs);
8081 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
8082 "\n",
8083 "int t[0];\n",
8084 "#pragma omp parallel\n",
8085 "{\n",
8086 " #pragma omp master\n",
8087 " {\n"
8088 }, true));
8089 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(4));
8090 ✗ out_txt := Tpl.writeText(out_txt, l_odeEqs);
8091 ✗ out_txt := Tpl.softNewLine(out_txt);
8092 ✗ out_txt := Tpl.popBlock(out_txt);
8093 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
8094 " }\n",
8095 "}"
8096 }, false));
8097 end function_HPCOM_TaskDep;
8098
8099 protected function lm_229
8100 input output Tpl.Text txt;
8101 input list<Integer> items;
8102 algorithm
8103 ✗ for lstElt_229 in items loop
8104 txt := match lstElt_229
8105 local
8106 Integer i_p;
8107
8108 case i_p
8109 algorithm
8110 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("t["));
8111 ✗ txt := Tpl.writeStr(txt, intString(i_p));
8112 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("]"));
8113 ✗ txt := Tpl.nextIter(txt);
8114 then txt;
8115 end match;
8116 end for;
8117 end lm_229;
8118
8119 protected function lm_230
8120 input output Tpl.Text txt;
8121 input list<Integer> items;
8122 algorithm
8123 ✗ for lstElt_230 in items loop
8124 txt := match lstElt_230
8125 local
8126 Integer i_p;
8127
8128 case i_p
8129 algorithm
8130 ✗ txt := Tpl.writeStr(txt, intString(i_p));
8131 ✗ txt := Tpl.nextIter(txt);
8132 then txt;
8133 end match;
8134 end for;
8135 end lm_230;
8136
8137 protected function fun_231
8138 input Tpl.Text in_txt;
8139 input Boolean in_mArg;
8140 input Tpl.Text in_a_parentDependencies;
8141
8142 output Tpl.Text out_txt;
8143 algorithm
8144 out_txt :=
8145 match(in_txt, in_mArg, in_a_parentDependencies)
8146 local
8147 Tpl.Text txt;
8148 Tpl.Text a_parentDependencies;
8149
8150 case ( txt,
8151 false,
8152 _ )
8153 then txt;
8154
8155 case ( txt,
8156 _,
8157 a_parentDependencies )
8158 algorithm
8159 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("depend(in:"));
8160 ✗ txt := Tpl.writeText(txt, a_parentDependencies);
8161 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") "));
8162 then txt;
8163 end match;
8164 end fun_231;
8165
8166 public function function_HPCOM_TaskDep0
8167 input Tpl.Text in_txt;
8168 input tuple<HpcOmSimCode.Task, list<Integer>> in_a_taskIn;
8169 input list<SimCode.SimEqSystem> in_a_allEquationsPlusWhen;
8170 input String in_a_iType;
8171 input Tpl.Text in_a_varDecls;
8172 input SimCode.SimCode in_a_simCode;
8173 input Tpl.Text in_a_extraFuncs;
8174 input Tpl.Text in_a_extraFuncsDecl;
8175 input Tpl.Text in_a_extraFuncsNamespace;
8176 input Boolean in_a_useFlatArrayNotation;
8177
8178 output Tpl.Text out_txt;
8179 output Tpl.Text out_a_varDecls;
8180 output Tpl.Text out_a_extraFuncs;
8181 output Tpl.Text out_a_extraFuncsDecl;
8182 output Tpl.Text out_a_extraFuncsNamespace;
8183 algorithm
8184 (out_txt, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) :=
8185 match(in_txt, in_a_taskIn, in_a_allEquationsPlusWhen, in_a_iType, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_useFlatArrayNotation)
8186 local
8187 Tpl.Text txt;
8188 list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
8189 String a_iType;
8190 Tpl.Text a_varDecls;
8191 SimCode.SimCode a_simCode;
8192 Tpl.Text a_extraFuncs;
8193 Tpl.Text a_extraFuncsDecl;
8194 Tpl.Text a_extraFuncsNamespace;
8195 Boolean a_useFlatArrayNotation;
8196 Integer i_task_index;
8197 list<Integer> i_parents;
8198 HpcOmSimCode.Task i_task;
8199 Boolean ret_5;
8200 Integer ret_4;
8201 Tpl.Text l_depIn;
8202 Tpl.Text l_taskDependencies;
8203 Tpl.Text l_parentDependencies;
8204 Tpl.Text l_taskEqs;
8205
8206 case ( txt,
8207 ((i_task as HpcOmSimCode.CALCTASK(index = i_task_index)), i_parents),
8208 a_allEquationsPlusWhen,
8209 a_iType,
8210 a_varDecls,
8211 a_simCode,
8212 a_extraFuncs,
8213 a_extraFuncsDecl,
8214 a_extraFuncsNamespace,
8215 a_useFlatArrayNotation )
8216 algorithm
8217 ✗ (l_taskEqs, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := taskCode(Tpl.emptyTxt, a_allEquationsPlusWhen, i_task, a_iType, "", a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
8218 ✗ l_parentDependencies := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
8219 ✗ l_parentDependencies := lm_229(l_parentDependencies, i_parents);
8220 ✗ l_parentDependencies := Tpl.popIter(l_parentDependencies);
8221 ✗ l_taskDependencies := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
8222 ✗ l_taskDependencies := lm_230(l_taskDependencies, i_parents);
8223 ✗ l_taskDependencies := Tpl.popIter(l_taskDependencies);
8224 ✗ ret_4 := listLength(i_parents);
8225 ✗ ret_5 := intGt(ret_4, 0);
8226 ✗ l_depIn := fun_231(Tpl.emptyTxt, ret_5, l_parentDependencies);
8227 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("//TG_NODE: "));
8228 ✗ txt := Tpl.writeStr(txt, intString(i_task_index));
8229 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" TG_PARENTS: "));
8230 ✗ txt := Tpl.writeText(txt, l_taskDependencies);
8231 ✗ txt := Tpl.softNewLine(txt);
8232 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#pragma omp task "));
8233 ✗ txt := Tpl.writeText(txt, l_depIn);
8234 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("depend(out:t["));
8235 ✗ txt := Tpl.writeStr(txt, intString(i_task_index));
8236 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
8237 "])\n",
8238 "{\n"
8239 }, true));
8240 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
8241 ✗ txt := Tpl.writeText(txt, l_taskEqs);
8242 ✗ txt := Tpl.softNewLine(txt);
8243 ✗ txt := Tpl.popBlock(txt);
8244 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
8245 ✗ then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
8246
8247 case ( txt,
8248 _,
8249 _,
8250 _,
8251 a_varDecls,
8252 _,
8253 a_extraFuncs,
8254 a_extraFuncsDecl,
8255 a_extraFuncsNamespace,
8256 _ )
8257 then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
8258 end match;
8259 end function_HPCOM_TaskDep0;
8260
8261 protected function lm_233
8262 input output Tpl.Text txt;
8263 input list<tuple<HpcOmSimCode.Task, list<Integer>>> items;
8264 input String a_modelNamePrefixStr;
8265 algorithm
8266 ✗ for lstElt_233 in items loop
8267 txt := match lstElt_233
8268 local
8269 Integer x_i;
8270 tuple<HpcOmSimCode.Task, list<Integer>> i_t;
8271
8272 case i_t
8273 algorithm
8274 ✗ x_i := Tpl.getIteri_i0(txt);
8275 ✗ txt := generateTbbConstructorExtensionNodes(txt, i_t, x_i, "Ode", a_modelNamePrefixStr);
8276 ✗ txt := Tpl.nextIter(txt);
8277 then txt;
8278 end match;
8279 end for;
8280 end lm_233;
8281
8282 protected function lm_234
8283 input output Tpl.Text txt;
8284 input list<tuple<HpcOmSimCode.Task, list<Integer>>> items;
8285 input String a_modelNamePrefixStr;
8286 algorithm
8287 ✗ for lstElt_234 in items loop
8288 txt := match lstElt_234
8289 local
8290 Integer x_i;
8291 tuple<HpcOmSimCode.Task, list<Integer>> i_t;
8292
8293 case i_t
8294 algorithm
8295 ✗ x_i := Tpl.getIteri_i0(txt);
8296 ✗ txt := generateTbbConstructorExtensionEdges(txt, i_t, x_i, "Ode", a_modelNamePrefixStr);
8297 ✗ txt := Tpl.nextIter(txt);
8298 then txt;
8299 end match;
8300 end for;
8301 end lm_234;
8302
8303 protected function lm_235
8304 input output Tpl.Text txt;
8305 input list<tuple<HpcOmSimCode.Task, list<Integer>>> items;
8306 input String a_modelNamePrefixStr;
8307 algorithm
8308 ✗ for lstElt_235 in items loop
8309 txt := match lstElt_235
8310 local
8311 Integer x_i;
8312 tuple<HpcOmSimCode.Task, list<Integer>> i_t;
8313
8314 case i_t
8315 algorithm
8316 ✗ x_i := Tpl.getIteri_i0(txt);
8317 ✗ txt := generateTbbConstructorExtensionNodes(txt, i_t, x_i, "All", a_modelNamePrefixStr);
8318 ✗ txt := Tpl.nextIter(txt);
8319 then txt;
8320 end match;
8321 end for;
8322 end lm_235;
8323
8324 protected function lm_236
8325 input output Tpl.Text txt;
8326 input list<tuple<HpcOmSimCode.Task, list<Integer>>> items;
8327 input String a_modelNamePrefixStr;
8328 algorithm
8329 ✗ for lstElt_236 in items loop
8330 txt := match lstElt_236
8331 local
8332 Integer x_i;
8333 tuple<HpcOmSimCode.Task, list<Integer>> i_t;
8334
8335 case i_t
8336 algorithm
8337 ✗ x_i := Tpl.getIteri_i0(txt);
8338 ✗ txt := generateTbbConstructorExtensionEdges(txt, i_t, x_i, "All", a_modelNamePrefixStr);
8339 ✗ txt := Tpl.nextIter(txt);
8340 then txt;
8341 end match;
8342 end for;
8343 end lm_236;
8344
8345 protected function lm_237
8346 input output Tpl.Text txt;
8347 input list<tuple<HpcOmSimCode.Task, list<Integer>>> items;
8348 input String a_modelNamePrefixStr;
8349 algorithm
8350 ✗ for lstElt_237 in items loop
8351 txt := match lstElt_237
8352 local
8353 Integer x_i;
8354 tuple<HpcOmSimCode.Task, list<Integer>> i_t;
8355
8356 case i_t
8357 algorithm
8358 ✗ x_i := Tpl.getIteri_i0(txt);
8359 ✗ txt := generateTbbConstructorExtensionNodes(txt, i_t, x_i, "ZeroFunc", a_modelNamePrefixStr);
8360 ✗ txt := Tpl.nextIter(txt);
8361 then txt;
8362 end match;
8363 end for;
8364 end lm_237;
8365
8366 protected function lm_238
8367 input output Tpl.Text txt;
8368 input list<tuple<HpcOmSimCode.Task, list<Integer>>> items;
8369 input String a_modelNamePrefixStr;
8370 algorithm
8371 ✗ for lstElt_238 in items loop
8372 txt := match lstElt_238
8373 local
8374 Integer x_i;
8375 tuple<HpcOmSimCode.Task, list<Integer>> i_t;
8376
8377 case i_t
8378 algorithm
8379 ✗ x_i := Tpl.getIteri_i0(txt);
8380 ✗ txt := generateTbbConstructorExtensionEdges(txt, i_t, x_i, "ZeroFunc", a_modelNamePrefixStr);
8381 ✗ txt := Tpl.nextIter(txt);
8382 then txt;
8383 end match;
8384 end for;
8385 end lm_238;
8386
8387 public function generateTbbConstructorExtension
8388 input Tpl.Text txt;
8389 input list<tuple<HpcOmSimCode.Task, list<Integer>>> a_odeTasks;
8390 input list<tuple<HpcOmSimCode.Task, list<Integer>>> a_daeTasks;
8391 input list<tuple<HpcOmSimCode.Task, list<Integer>>> a_zeroFuncTasks;
8392 input String a_modelNamePrefixStr;
8393
8394 output Tpl.Text out_txt;
8395 protected
8396 Integer ret_6;
8397 Tpl.Text l_zeroFuncEdges;
8398 Tpl.Text l_zeroFuncNodes;
8399 Tpl.Text l_daeEdges;
8400 Tpl.Text l_daeNodes;
8401 Tpl.Text l_odeEdges;
8402 Tpl.Text l_odeNodes;
8403 algorithm
8404 ✗ l_odeNodes := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
8405 ✗ l_odeNodes := lm_233(l_odeNodes, a_odeTasks, a_modelNamePrefixStr);
8406 ✗ l_odeNodes := Tpl.popIter(l_odeNodes);
8407 ✗ l_odeEdges := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
8408 ✗ l_odeEdges := lm_234(l_odeEdges, a_odeTasks, a_modelNamePrefixStr);
8409 ✗ l_odeEdges := Tpl.popIter(l_odeEdges);
8410 ✗ l_daeNodes := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
8411 ✗ l_daeNodes := lm_235(l_daeNodes, a_daeTasks, a_modelNamePrefixStr);
8412 ✗ l_daeNodes := Tpl.popIter(l_daeNodes);
8413 ✗ l_daeEdges := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
8414 ✗ l_daeEdges := lm_236(l_daeEdges, a_daeTasks, a_modelNamePrefixStr);
8415 ✗ l_daeEdges := Tpl.popIter(l_daeEdges);
8416 ✗ l_zeroFuncNodes := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
8417 ✗ l_zeroFuncNodes := lm_237(l_zeroFuncNodes, a_zeroFuncTasks, a_modelNamePrefixStr);
8418 ✗ l_zeroFuncNodes := Tpl.popIter(l_zeroFuncNodes);
8419 ✗ l_zeroFuncEdges := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
8420 ✗ l_zeroFuncEdges := lm_238(l_zeroFuncEdges, a_zeroFuncTasks, a_modelNamePrefixStr);
8421 ✗ l_zeroFuncEdges := Tpl.popIter(l_zeroFuncEdges);
8422 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_LINE("tbb::flow::continue_node<tbb::flow::continue_msg> *tbb_task;\n"));
8423 ✗ out_txt := Tpl.writeText(out_txt, l_odeNodes);
8424 ✗ out_txt := Tpl.softNewLine(out_txt);
8425 ✗ out_txt := Tpl.writeText(out_txt, l_odeEdges);
8426 ✗ out_txt := Tpl.softNewLine(out_txt);
8427 ✗ out_txt := Tpl.writeText(out_txt, l_daeNodes);
8428 ✗ out_txt := Tpl.softNewLine(out_txt);
8429 ✗ out_txt := Tpl.writeText(out_txt, l_daeEdges);
8430 ✗ out_txt := Tpl.softNewLine(out_txt);
8431 ✗ out_txt := Tpl.writeText(out_txt, l_zeroFuncNodes);
8432 ✗ out_txt := Tpl.softNewLine(out_txt);
8433 ✗ out_txt := Tpl.writeText(out_txt, l_zeroFuncEdges);
8434 ✗ out_txt := Tpl.softNewLine(out_txt);
8435 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
8436 "#if TBB_INTERFACE_VERSION >= 8000\n",
8437 "_tbbArena = tbb::task_arena("
8438 }, false));
8439 ✗ ret_6 := Flags.getConfigInt(Flags.NUM_PROC);
8440 ✗ out_txt := Tpl.writeStr(out_txt, intString(ret_6));
8441 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
8442 ");\n",
8443 "_tbbArenaFunctorOde = TbbArenaFunctor(_tbbGraphOde,_tbbStartNodeOde);\n",
8444 "_tbbArenaFunctorAll = TbbArenaFunctor(_tbbGraphAll,_tbbStartNodeAll);\n",
8445 "_tbbArenaFunctorZeroFunc = TbbArenaFunctor(_tbbGraphZeroFunc,_tbbStartNodeZeroFunc);\n",
8446 "#endif"
8447 }, false));
8448 end generateTbbConstructorExtension;
8449
8450 public function generateTbbConstructorExtensionNodes
8451 input Tpl.Text in_txt;
8452 input tuple<HpcOmSimCode.Task, list<Integer>> in_a_taskIn;
8453 input Integer in_a_taskIndex;
8454 input String in_a_funcSuffix;
8455 input String in_a_modelNamePrefixStr;
8456
8457 output Tpl.Text out_txt;
8458 algorithm
8459 out_txt :=
8460 match(in_txt, in_a_taskIn, in_a_taskIndex, in_a_funcSuffix, in_a_modelNamePrefixStr)
8461 local
8462 Tpl.Text txt;
8463 Integer a_taskIndex;
8464 String a_funcSuffix;
8465 String a_modelNamePrefixStr;
8466 Integer i_task_index;
8467
8468 case ( txt,
8469 (HpcOmSimCode.CALCTASK(index = i_task_index), _),
8470 a_taskIndex,
8471 a_funcSuffix,
8472 a_modelNamePrefixStr )
8473 algorithm
8474 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("tbb_task = new tbb::flow::continue_node<tbb::flow::continue_msg>(_tbbGraph"));
8475 ✗ txt := Tpl.writeStr(txt, a_funcSuffix);
8476 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(",VoidFunctionBody(bind<void>(&"));
8477 ✗ txt := Tpl.writeStr(txt, a_modelNamePrefixStr);
8478 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::taskFunc"));
8479 ✗ txt := Tpl.writeStr(txt, a_funcSuffix);
8480 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
8481 ✗ txt := Tpl.writeStr(txt, intString(i_task_index));
8482 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
8483 ",this)));\n",
8484 "_tbbNodeList"
8485 }, false));
8486 ✗ txt := Tpl.writeStr(txt, a_funcSuffix);
8487 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".at("));
8488 ✗ txt := Tpl.writeStr(txt, intString(a_taskIndex));
8489 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") = tbb_task;"));
8490 then txt;
8491
8492 case ( txt,
8493 _,
8494 _,
8495 _,
8496 _ )
8497 then txt;
8498 end match;
8499 end generateTbbConstructorExtensionNodes;
8500
8501 protected function lm_241
8502 input output Tpl.Text txt;
8503 input list<Integer> items;
8504 input Integer a_taskIndex;
8505 input String a_funcSuffix;
8506 algorithm
8507 ✗ for lstElt_241 in items loop
8508 txt := match lstElt_241
8509 local
8510 Integer i_p;
8511 Integer ret_0;
8512
8513 case i_p
8514 algorithm
8515 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("tbb::flow::make_edge(*(_tbbNodeList"));
8516 ✗ txt := Tpl.writeStr(txt, a_funcSuffix);
8517 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".at("));
8518 ✗ ret_0 := intSub(i_p, 1);
8519 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
8520 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")),*(_tbbNodeList"));
8521 ✗ txt := Tpl.writeStr(txt, a_funcSuffix);
8522 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".at("));
8523 ✗ txt := Tpl.writeStr(txt, intString(a_taskIndex));
8524 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")));"));
8525 ✗ txt := Tpl.nextIter(txt);
8526 then txt;
8527 end match;
8528 end for;
8529 end lm_241;
8530
8531 protected function fun_242
8532 input Tpl.Text in_txt;
8533 input Boolean in_mArg;
8534 input Integer in_a_taskIndex;
8535 input String in_a_funcSuffix;
8536
8537 output Tpl.Text out_txt;
8538 algorithm
8539 out_txt :=
8540 match(in_txt, in_mArg, in_a_taskIndex, in_a_funcSuffix)
8541 local
8542 Tpl.Text txt;
8543 Integer a_taskIndex;
8544 String a_funcSuffix;
8545
8546 case ( txt,
8547 false,
8548 _,
8549 _ )
8550 then txt;
8551
8552 case ( txt,
8553 _,
8554 a_taskIndex,
8555 a_funcSuffix )
8556 algorithm
8557 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("tbb::flow::make_edge(_tbbStartNode"));
8558 ✗ txt := Tpl.writeStr(txt, a_funcSuffix);
8559 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(",*(_tbbNodeList"));
8560 ✗ txt := Tpl.writeStr(txt, a_funcSuffix);
8561 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".at("));
8562 ✗ txt := Tpl.writeStr(txt, intString(a_taskIndex));
8563 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")));"));
8564 then txt;
8565 end match;
8566 end fun_242;
8567
8568 protected function fun_243
8569 input Tpl.Text in_txt;
8570 input tuple<HpcOmSimCode.Task, list<Integer>> in_a_taskIn;
8571 input Integer in_a_taskIndex;
8572 input String in_a_funcSuffix;
8573
8574 output Tpl.Text out_txt;
8575 algorithm
8576 out_txt :=
8577 match(in_txt, in_a_taskIn, in_a_taskIndex, in_a_funcSuffix)
8578 local
8579 Tpl.Text txt;
8580 Integer a_taskIndex;
8581 String a_funcSuffix;
8582 list<Integer> i_parents;
8583 Boolean ret_3;
8584 Integer ret_2;
8585 Tpl.Text l_startNodeEdge;
8586 Tpl.Text l_parentEdges;
8587
8588 case ( txt,
8589 (HpcOmSimCode.CALCTASK(weighting = _), i_parents),
8590 a_taskIndex,
8591 a_funcSuffix )
8592 algorithm
8593 ✗ l_parentEdges := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
8594 ✗ l_parentEdges := lm_241(l_parentEdges, i_parents, a_taskIndex, a_funcSuffix);
8595 ✗ l_parentEdges := Tpl.popIter(l_parentEdges);
8596 ✗ ret_2 := listLength(i_parents);
8597 ✗ ret_3 := intEq(0, ret_2);
8598 ✗ l_startNodeEdge := fun_242(Tpl.emptyTxt, ret_3, a_taskIndex, a_funcSuffix);
8599 ✗ txt := Tpl.writeText(txt, l_parentEdges);
8600 ✗ txt := Tpl.softNewLine(txt);
8601 ✗ txt := Tpl.writeText(txt, l_startNodeEdge);
8602 then txt;
8603
8604 case ( txt,
8605 _,
8606 _,
8607 _ )
8608 then txt;
8609 end match;
8610 end fun_243;
8611
8612 public function generateTbbConstructorExtensionEdges
8613 input Tpl.Text txt;
8614 input tuple<HpcOmSimCode.Task, list<Integer>> a_taskIn;
8615 input Integer a_taskIndex;
8616 input String a_funcSuffix;
8617 input String a_modelNamePrefixStr;
8618
8619 output Tpl.Text out_txt;
8620 algorithm
8621 ✗ out_txt := fun_243(txt, a_taskIn, a_taskIndex, a_funcSuffix);
8622 end generateTbbConstructorExtensionEdges;
8623
8624 protected function lm_245
8625 input output Tpl.Text txt;
8626 input list<tuple<HpcOmSimCode.Task, list<Integer>>> items;
8627 input Boolean a_useFlatArrayNotation;
8628 input output Tpl.Text a_extraFuncsNamespace;
8629 input output Tpl.Text a_extraFuncsDecl;
8630 input output Tpl.Text a_extraFuncs;
8631 input SimCode.SimCode a_simCode;
8632 input output Tpl.Text a_varDecls;
8633 input Absyn.Path a_name;
8634 input String a_iType;
8635 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
8636 algorithm
8637 ✗ for lstElt_245 in items loop
8638 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_245
8639 local
8640 tuple<HpcOmSimCode.Task, list<Integer>> i_t;
8641
8642 case i_t
8643 algorithm
8644 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := function_HPCOM_TaskDep_voidfunc0(txt, i_t, a_allEquationsPlusWhen, a_iType, "Ode", a_name, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
8645 ✗ txt := Tpl.nextIter(txt);
8646 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
8647 end match;
8648 end for;
8649 end lm_245;
8650
8651 protected function lm_246
8652 input output Tpl.Text txt;
8653 input list<tuple<HpcOmSimCode.Task, list<Integer>>> items;
8654 input Boolean a_useFlatArrayNotation;
8655 input output Tpl.Text a_extraFuncsNamespace;
8656 input output Tpl.Text a_extraFuncsDecl;
8657 input output Tpl.Text a_extraFuncs;
8658 input SimCode.SimCode a_simCode;
8659 input output Tpl.Text a_varDecls;
8660 input Absyn.Path a_name;
8661 input String a_iType;
8662 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
8663 algorithm
8664 ✗ for lstElt_246 in items loop
8665 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_246
8666 local
8667 tuple<HpcOmSimCode.Task, list<Integer>> i_t;
8668
8669 case i_t
8670 algorithm
8671 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := function_HPCOM_TaskDep_voidfunc0(txt, i_t, a_allEquationsPlusWhen, a_iType, "All", a_name, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
8672 ✗ txt := Tpl.nextIter(txt);
8673 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
8674 end match;
8675 end for;
8676 end lm_246;
8677
8678 protected function lm_247
8679 input output Tpl.Text txt;
8680 input list<tuple<HpcOmSimCode.Task, list<Integer>>> items;
8681 input Boolean a_useFlatArrayNotation;
8682 input output Tpl.Text a_extraFuncsNamespace;
8683 input output Tpl.Text a_extraFuncsDecl;
8684 input output Tpl.Text a_extraFuncs;
8685 input SimCode.SimCode a_simCode;
8686 input output Tpl.Text a_varDecls;
8687 input Absyn.Path a_name;
8688 input String a_iType;
8689 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
8690 algorithm
8691 ✗ for lstElt_247 in items loop
8692 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_247
8693 local
8694 tuple<HpcOmSimCode.Task, list<Integer>> i_t;
8695
8696 case i_t
8697 algorithm
8698 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := function_HPCOM_TaskDep_voidfunc0(txt, i_t, a_allEquationsPlusWhen, a_iType, "ZeroFunc", a_name, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
8699 ✗ txt := Tpl.nextIter(txt);
8700 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
8701 end match;
8702 end for;
8703 end lm_247;
8704
8705 public function function_HPCOM_TaskDep_voidfunc
8706 input Tpl.Text txt;
8707 input list<tuple<HpcOmSimCode.Task, list<Integer>>> a_odeTasks;
8708 input list<tuple<HpcOmSimCode.Task, list<Integer>>> a_daeTasks;
8709 input list<tuple<HpcOmSimCode.Task, list<Integer>>> a_zeroFuncTasks;
8710 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
8711 input String a_iType;
8712 input Absyn.Path a_name;
8713 input Tpl.Text a_varDecls;
8714 input SimCode.SimCode a_simCode;
8715 input Tpl.Text a_extraFuncs;
8716 input Tpl.Text a_extraFuncsDecl;
8717 input Tpl.Text a_extraFuncsNamespace;
8718 input Boolean a_useFlatArrayNotation;
8719
8720 output Tpl.Text out_txt;
8721 output Tpl.Text out_a_varDecls;
8722 output Tpl.Text out_a_extraFuncs;
8723 output Tpl.Text out_a_extraFuncsDecl;
8724 output Tpl.Text out_a_extraFuncsNamespace;
8725 protected
8726 Tpl.Text l_funcTasksZeroFunc;
8727 Tpl.Text l_funcTasksDae;
8728 Tpl.Text l_funcTasksOde;
8729 algorithm
8730 ✗ l_funcTasksOde := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
8731 ✗ (l_funcTasksOde, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls) := lm_245(l_funcTasksOde, a_odeTasks, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_name, a_iType, a_allEquationsPlusWhen);
8732 ✗ l_funcTasksOde := Tpl.popIter(l_funcTasksOde);
8733 ✗ l_funcTasksDae := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
8734 ✗ (l_funcTasksDae, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls) := lm_246(l_funcTasksDae, a_daeTasks, a_useFlatArrayNotation, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, a_simCode, out_a_varDecls, a_name, a_iType, a_allEquationsPlusWhen);
8735 ✗ l_funcTasksDae := Tpl.popIter(l_funcTasksDae);
8736 ✗ l_funcTasksZeroFunc := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
8737 ✗ (l_funcTasksZeroFunc, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls) := lm_247(l_funcTasksZeroFunc, a_zeroFuncTasks, a_useFlatArrayNotation, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, a_simCode, out_a_varDecls, a_name, a_iType, a_allEquationsPlusWhen);
8738 ✗ l_funcTasksZeroFunc := Tpl.popIter(l_funcTasksZeroFunc);
8739 ✗ out_txt := Tpl.writeText(txt, l_funcTasksOde);
8740 ✗ out_txt := Tpl.softNewLine(out_txt);
8741 ✗ out_txt := Tpl.writeText(out_txt, l_funcTasksDae);
8742 ✗ out_txt := Tpl.softNewLine(out_txt);
8743 ✗ out_txt := Tpl.writeText(out_txt, l_funcTasksZeroFunc);
8744 end function_HPCOM_TaskDep_voidfunc;
8745
8746 protected function fun_249
8747 input Tpl.Text in_txt;
8748 input tuple<HpcOmSimCode.Task, list<Integer>> in_a_taskIn;
8749 input list<SimCode.SimEqSystem> in_a_allEquationsPlusWhen;
8750 input String in_a_iType;
8751 input String in_a_funcSuffix;
8752 input Absyn.Path in_a_name;
8753 input SimCode.SimCode in_a_simCode;
8754 input Tpl.Text in_a_extraFuncs;
8755 input Tpl.Text in_a_extraFuncsDecl;
8756 input Tpl.Text in_a_extraFuncsNamespace;
8757 input Boolean in_a_useFlatArrayNotation;
8758
8759 output Tpl.Text out_txt;
8760 output Tpl.Text out_a_extraFuncs;
8761 output Tpl.Text out_a_extraFuncsDecl;
8762 output Tpl.Text out_a_extraFuncsNamespace;
8763 algorithm
8764 (out_txt, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) :=
8765 match(in_txt, in_a_taskIn, in_a_allEquationsPlusWhen, in_a_iType, in_a_funcSuffix, in_a_name, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_useFlatArrayNotation)
8766 local
8767 Tpl.Text txt;
8768 list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
8769 String a_iType;
8770 String a_funcSuffix;
8771 Absyn.Path a_name;
8772 SimCode.SimCode a_simCode;
8773 Tpl.Text a_extraFuncs;
8774 Tpl.Text a_extraFuncsDecl;
8775 Tpl.Text a_extraFuncsNamespace;
8776 Boolean a_useFlatArrayNotation;
8777 Integer i_task_index;
8778 HpcOmSimCode.Task i_task;
8779 Tpl.Text l_taskEqs;
8780 Tpl.Text l_tempvarDecl;
8781
8782 case ( txt,
8783 ((i_task as HpcOmSimCode.CALCTASK(index = i_task_index)), _),
8784 a_allEquationsPlusWhen,
8785 a_iType,
8786 a_funcSuffix,
8787 a_name,
8788 a_simCode,
8789 a_extraFuncs,
8790 a_extraFuncsDecl,
8791 a_extraFuncsNamespace,
8792 a_useFlatArrayNotation )
8793 algorithm
8794 ✗ l_tempvarDecl := Tpl.emptyTxt;
8795 ✗ (l_taskEqs, l_tempvarDecl, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := taskCode(Tpl.emptyTxt, a_allEquationsPlusWhen, i_task, a_iType, "", l_tempvarDecl, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
8796 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("void "));
8797 ✗ txt := CodegenCpp.lastIdentOfPath(txt, a_name);
8798 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::taskFunc"));
8799 ✗ txt := Tpl.writeStr(txt, a_funcSuffix);
8800 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
8801 ✗ txt := Tpl.writeStr(txt, intString(i_task_index));
8802 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
8803 "()\n",
8804 "{\n"
8805 }, true));
8806 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
8807 ✗ txt := Tpl.writeText(txt, l_tempvarDecl);
8808 ✗ txt := Tpl.softNewLine(txt);
8809 ✗ txt := Tpl.writeText(txt, l_taskEqs);
8810 ✗ txt := Tpl.softNewLine(txt);
8811 ✗ txt := Tpl.popBlock(txt);
8812 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
8813 ✗ then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
8814
8815 case ( txt,
8816 _,
8817 _,
8818 _,
8819 _,
8820 _,
8821 _,
8822 a_extraFuncs,
8823 a_extraFuncsDecl,
8824 a_extraFuncsNamespace,
8825 _ )
8826 then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
8827 end match;
8828 end fun_249;
8829
8830 public function function_HPCOM_TaskDep_voidfunc0
8831 input Tpl.Text txt;
8832 input tuple<HpcOmSimCode.Task, list<Integer>> a_taskIn;
8833 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
8834 input String a_iType;
8835 input String a_funcSuffix;
8836 input Absyn.Path a_name;
8837 input Tpl.Text a_varDecls;
8838 input SimCode.SimCode a_simCode;
8839 input Tpl.Text a_extraFuncs;
8840 input Tpl.Text a_extraFuncsDecl;
8841 input Tpl.Text a_extraFuncsNamespace;
8842 input Boolean a_useFlatArrayNotation;
8843
8844 output Tpl.Text out_txt;
8845 output Tpl.Text out_a_varDecls;
8846 output Tpl.Text out_a_extraFuncs;
8847 output Tpl.Text out_a_extraFuncsDecl;
8848 output Tpl.Text out_a_extraFuncsNamespace;
8849 algorithm
8850 ✗ (out_txt, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := fun_249(txt, a_taskIn, a_allEquationsPlusWhen, a_iType, a_funcSuffix, a_name, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
8851 out_a_varDecls := a_varDecls;
8852 end function_HPCOM_TaskDep_voidfunc0;
8853
8854 protected function fun_251
8855 input Tpl.Text in_txt;
8856 input Boolean in_mArg;
8857 input Tpl.Text in_a_relLock;
8858 input Tpl.Text in_a_assLock;
8859 input Tpl.Text in_a_taskEqsZeroFunc;
8860 input Tpl.Text in_a_taskEqsDae;
8861 input Tpl.Text in_a_taskEqsOde;
8862 input String in_a_modelNamePrefixStr;
8863 input Integer in_a_iThreadIdx;
8864 input Tpl.Text in_a_varDeclsLoc;
8865 input Tpl.Text in_a_mainThreadCode;
8866
8867 output Tpl.Text out_txt;
8868 output Tpl.Text out_a_mainThreadCode;
8869 algorithm
8870 (out_txt, out_a_mainThreadCode) :=
8871 match(in_txt, in_mArg, in_a_relLock, in_a_assLock, in_a_taskEqsZeroFunc, in_a_taskEqsDae, in_a_taskEqsOde, in_a_modelNamePrefixStr, in_a_iThreadIdx, in_a_varDeclsLoc, in_a_mainThreadCode)
8872 local
8873 Tpl.Text txt;
8874 Tpl.Text a_relLock;
8875 Tpl.Text a_assLock;
8876 Tpl.Text a_taskEqsZeroFunc;
8877 Tpl.Text a_taskEqsDae;
8878 Tpl.Text a_taskEqsOde;
8879 String a_modelNamePrefixStr;
8880 Integer a_iThreadIdx;
8881 Tpl.Text a_varDeclsLoc;
8882 Tpl.Text a_mainThreadCode;
8883 Integer ret_1;
8884 Integer ret_0;
8885
8886 case ( txt,
8887 false,
8888 _,
8889 _,
8890 a_taskEqsZeroFunc,
8891 a_taskEqsDae,
8892 a_taskEqsOde,
8893 a_modelNamePrefixStr,
8894 a_iThreadIdx,
8895 a_varDeclsLoc,
8896 a_mainThreadCode )
8897 algorithm
8898 ✗ a_mainThreadCode := Tpl.writeText(a_mainThreadCode, a_varDeclsLoc);
8899 ✗ a_mainThreadCode := Tpl.writeTok(a_mainThreadCode, Tpl.ST_STRING_LIST({
8900 "#ifdef MEASURETIME_MODELFUNCTIONS\n",
8901 "MeasureTimeValues *measuredSchedulerStartValues = measuredSchedulerStartValues_0;\n",
8902 "MeasureTimeValues *measuredSchedulerEndValues = measuredSchedulerEndValues_0;\n",
8903 "#endif //MEASURETIME_MODELFUNCTIONS\n",
8904 "if(_evaluateMode == 0)\n",
8905 "{\n"
8906 }, true));
8907 ✗ a_mainThreadCode := Tpl.pushBlock(a_mainThreadCode, Tpl.BT_INDENT(2));
8908 ✗ a_mainThreadCode := Tpl.writeTok(a_mainThreadCode, Tpl.ST_STRING("evaluateThreadFuncODE_"));
8909 ✗ a_mainThreadCode := Tpl.writeStr(a_mainThreadCode, intString(a_iThreadIdx));
8910 ✗ a_mainThreadCode := Tpl.writeTok(a_mainThreadCode, Tpl.ST_LINE("();\n"));
8911 ✗ a_mainThreadCode := Tpl.popBlock(a_mainThreadCode);
8912 ✗ a_mainThreadCode := Tpl.writeTok(a_mainThreadCode, Tpl.ST_STRING_LIST({
8913 "}\n",
8914 "else if(_evaluateMode < 0)\n",
8915 "{\n"
8916 }, true));
8917 ✗ a_mainThreadCode := Tpl.pushBlock(a_mainThreadCode, Tpl.BT_INDENT(2));
8918 ✗ a_mainThreadCode := Tpl.writeTok(a_mainThreadCode, Tpl.ST_STRING("evaluateThreadFuncAll_"));
8919 ✗ a_mainThreadCode := Tpl.writeStr(a_mainThreadCode, intString(a_iThreadIdx));
8920 ✗ a_mainThreadCode := Tpl.writeTok(a_mainThreadCode, Tpl.ST_LINE("();\n"));
8921 ✗ a_mainThreadCode := Tpl.popBlock(a_mainThreadCode);
8922 ✗ a_mainThreadCode := Tpl.writeTok(a_mainThreadCode, Tpl.ST_STRING_LIST({
8923 "}\n",
8924 "else\n",
8925 "{\n"
8926 }, true));
8927 ✗ a_mainThreadCode := Tpl.pushBlock(a_mainThreadCode, Tpl.BT_INDENT(2));
8928 ✗ a_mainThreadCode := Tpl.writeTok(a_mainThreadCode, Tpl.ST_STRING("evaluateThreadFuncZeroFunc_"));
8929 ✗ a_mainThreadCode := Tpl.writeStr(a_mainThreadCode, intString(a_iThreadIdx));
8930 ✗ a_mainThreadCode := Tpl.writeTok(a_mainThreadCode, Tpl.ST_LINE("();\n"));
8931 ✗ a_mainThreadCode := Tpl.popBlock(a_mainThreadCode);
8932 ✗ a_mainThreadCode := Tpl.writeTok(a_mainThreadCode, Tpl.ST_STRING("}"));
8933 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("void "));
8934 ✗ txt := Tpl.writeStr(txt, a_modelNamePrefixStr);
8935 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFuncODE_"));
8936 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
8937 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
8938 "()\n",
8939 "{\n"
8940 }, true));
8941 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
8942 ✗ txt := Tpl.writeText(txt, a_taskEqsOde);
8943 ✗ txt := Tpl.softNewLine(txt);
8944 ✗ txt := Tpl.popBlock(txt);
8945 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
8946 "}\n",
8947 "\n",
8948 "void "
8949 }, false));
8950 ✗ txt := Tpl.writeStr(txt, a_modelNamePrefixStr);
8951 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFuncAll_"));
8952 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
8953 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
8954 "()\n",
8955 "{\n"
8956 }, true));
8957 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
8958 ✗ txt := Tpl.writeText(txt, a_taskEqsDae);
8959 ✗ txt := Tpl.softNewLine(txt);
8960 ✗ txt := Tpl.popBlock(txt);
8961 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
8962 "}\n",
8963 "\n",
8964 "void "
8965 }, false));
8966 ✗ txt := Tpl.writeStr(txt, a_modelNamePrefixStr);
8967 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFuncZeroFunc_"));
8968 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
8969 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
8970 "()\n",
8971 "{\n"
8972 }, true));
8973 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
8974 ✗ txt := Tpl.writeText(txt, a_taskEqsZeroFunc);
8975 ✗ txt := Tpl.softNewLine(txt);
8976 ✗ txt := Tpl.popBlock(txt);
8977 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
8978 then (txt, a_mainThreadCode);
8979
8980 case ( txt,
8981 _,
8982 a_relLock,
8983 a_assLock,
8984 a_taskEqsZeroFunc,
8985 a_taskEqsDae,
8986 a_taskEqsOde,
8987 a_modelNamePrefixStr,
8988 a_iThreadIdx,
8989 a_varDeclsLoc,
8990 a_mainThreadCode )
8991 algorithm
8992 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("void "));
8993 ✗ txt := Tpl.writeStr(txt, a_modelNamePrefixStr);
8994 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFuncODE_"));
8995 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
8996 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
8997 "()\n",
8998 "{\n"
8999 }, true));
9000 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
9001 ✗ txt := Tpl.writeText(txt, a_taskEqsOde);
9002 ✗ txt := Tpl.softNewLine(txt);
9003 ✗ txt := Tpl.popBlock(txt);
9004 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
9005 "}\n",
9006 "\n",
9007 "void "
9008 }, false));
9009 ✗ txt := Tpl.writeStr(txt, a_modelNamePrefixStr);
9010 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFuncAll_"));
9011 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
9012 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
9013 "()\n",
9014 "{\n"
9015 }, true));
9016 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
9017 ✗ txt := Tpl.writeText(txt, a_taskEqsDae);
9018 ✗ txt := Tpl.softNewLine(txt);
9019 ✗ txt := Tpl.popBlock(txt);
9020 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
9021 "}\n",
9022 "\n",
9023 "void "
9024 }, false));
9025 ✗ txt := Tpl.writeStr(txt, a_modelNamePrefixStr);
9026 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFuncZeroFunc_"));
9027 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
9028 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
9029 "()\n",
9030 "{\n"
9031 }, true));
9032 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
9033 ✗ txt := Tpl.writeText(txt, a_taskEqsZeroFunc);
9034 ✗ txt := Tpl.softNewLine(txt);
9035 ✗ txt := Tpl.popBlock(txt);
9036 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
9037 "}\n",
9038 "\n",
9039 "void "
9040 }, false));
9041 ✗ txt := Tpl.writeStr(txt, a_modelNamePrefixStr);
9042 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::evaluateThreadFunc"));
9043 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
9044 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
9045 "()\n",
9046 "{\n",
9047 " #ifdef MEASURETIME_MODELFUNCTIONS\n"
9048 }, true));
9049 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
9050 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("MeasureTimeValues *measuredSchedulerStartValues = measuredSchedulerStartValues_"));
9051 ✗ ret_0 := intSub(a_iThreadIdx, 1);
9052 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
9053 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
9054 ";\n",
9055 "MeasureTimeValues *measuredSchedulerEndValues = measuredSchedulerEndValues_"
9056 }, false));
9057 ret_1 := intSub(a_iThreadIdx, 1);
9058 ✗ txt := Tpl.writeStr(txt, intString(ret_1));
9059 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
9060 ";\n",
9061 "#endif //MEASURETIME_MODELFUNCTIONS\n"
9062 }, true));
9063 ✗ txt := Tpl.writeText(txt, a_varDeclsLoc);
9064 ✗ txt := Tpl.softNewLine(txt);
9065 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
9066 "while(1)\n",
9067 "{\n"
9068 }, true));
9069 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
9070 ✗ txt := Tpl.writeText(txt, a_assLock);
9071 ✗ txt := Tpl.softNewLine(txt);
9072 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
9073 "if(_terminateThreads)\n",
9074 " return;\n",
9075 "\n",
9076 "if(_evaluateMode == 0)\n",
9077 "{\n"
9078 }, true));
9079 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
9080 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("evaluateThreadFuncODE_"));
9081 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
9082 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("();\n"));
9083 ✗ txt := Tpl.popBlock(txt);
9084 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
9085 "}\n",
9086 "else if(_evaluateMode < 0)\n",
9087 "{\n"
9088 }, true));
9089 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
9090 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("evaluateThreadFuncAll_"));
9091 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
9092 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("();\n"));
9093 ✗ txt := Tpl.popBlock(txt);
9094 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
9095 "}\n",
9096 "else\n",
9097 "{\n"
9098 }, true));
9099 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
9100 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("evaluateThreadFuncZeroFunc_"));
9101 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadIdx));
9102 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("();\n"));
9103 ✗ txt := Tpl.popBlock(txt);
9104 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
9105 ✗ txt := Tpl.writeText(txt, a_relLock);
9106 ✗ txt := Tpl.softNewLine(txt);
9107 ✗ txt := Tpl.popBlock(txt);
9108 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("}\n"));
9109 ✗ txt := Tpl.popBlock(txt);
9110 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
9111 then (txt, a_mainThreadCode);
9112 end match;
9113 end fun_251;
9114
9115 public function generateThreadFunc
9116 input Tpl.Text txt;
9117 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
9118 input list<HpcOmSimCode.Task> a_threadTasksOde;
9119 input list<HpcOmSimCode.Task> a_threadTasksDae;
9120 input list<HpcOmSimCode.Task> a_threadTasksZeroFunc;
9121 input String a_iType;
9122 input Integer a_iThreadIdx;
9123 input String a_modelNamePrefixStr;
9124 input Tpl.Text a_varDecls;
9125 input SimCode.SimCode a_simCode;
9126 input Tpl.Text a_extraFuncs;
9127 input Tpl.Text a_extraFuncsDecl;
9128 input Tpl.Text a_extraFuncsNamespace;
9129 input Tpl.Text a_mainThreadCode;
9130 input Boolean a_useFlatArrayNotation;
9131
9132 output Tpl.Text out_txt;
9133 output Tpl.Text out_a_varDecls;
9134 output Tpl.Text out_a_extraFuncs;
9135 output Tpl.Text out_a_extraFuncsDecl;
9136 output Tpl.Text out_a_extraFuncsNamespace;
9137 output Tpl.Text out_a_mainThreadCode;
9138 protected
9139 Boolean ret_6;
9140 Tpl.Text l_relLock;
9141 Tpl.Text l_assLock;
9142 Tpl.Text l_taskEqsZeroFunc;
9143 Tpl.Text l_taskEqsDae;
9144 Tpl.Text l_taskEqsOde;
9145 Tpl.Text l_varDeclsLoc;
9146 algorithm
9147 ✗ l_varDeclsLoc := Tpl.emptyTxt;
9148 ✗ (l_taskEqsOde, l_varDeclsLoc, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := parallelThreadCode(Tpl.emptyTxt, a_allEquationsPlusWhen, a_threadTasksOde, a_iThreadIdx, a_iType, "_lockOde", l_varDeclsLoc, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, "evaluateODE", a_useFlatArrayNotation);
9149 ✗ (l_taskEqsDae, l_varDeclsLoc, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := parallelThreadCode(Tpl.emptyTxt, a_allEquationsPlusWhen, a_threadTasksDae, a_iThreadIdx, a_iType, "_lockDae", l_varDeclsLoc, a_simCode, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, "evaluateAll", a_useFlatArrayNotation);
9150 ✗ (l_taskEqsZeroFunc, l_varDeclsLoc, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := parallelThreadCode(Tpl.emptyTxt, a_allEquationsPlusWhen, a_threadTasksZeroFunc, a_iThreadIdx, a_iType, "_lockZeroFunc", l_varDeclsLoc, a_simCode, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, "evaluateZeroFunc", a_useFlatArrayNotation);
9151 ✗ l_assLock := assignLockByLockName(Tpl.emptyTxt, intString(a_iThreadIdx), "th_lock", a_iType);
9152 ✗ l_relLock := releaseLockByLockName(Tpl.emptyTxt, intString(a_iThreadIdx), "th_lock1", a_iType);
9153 ✗ out_a_extraFuncsDecl := Tpl.writeTok(out_a_extraFuncsDecl, Tpl.ST_STRING("void evaluateThreadFuncODE_"));
9154 ✗ out_a_extraFuncsDecl := Tpl.writeStr(out_a_extraFuncsDecl, intString(a_iThreadIdx));
9155 ✗ out_a_extraFuncsDecl := Tpl.writeTok(out_a_extraFuncsDecl, Tpl.ST_STRING_LIST({
9156 "();\n",
9157 "void evaluateThreadFuncAll_"
9158 }, false));
9159 ✗ out_a_extraFuncsDecl := Tpl.writeStr(out_a_extraFuncsDecl, intString(a_iThreadIdx));
9160 ✗ out_a_extraFuncsDecl := Tpl.writeTok(out_a_extraFuncsDecl, Tpl.ST_STRING_LIST({
9161 "();\n",
9162 "void evaluateThreadFuncZeroFunc_"
9163 }, false));
9164 ✗ out_a_extraFuncsDecl := Tpl.writeStr(out_a_extraFuncsDecl, intString(a_iThreadIdx));
9165 ✗ out_a_extraFuncsDecl := Tpl.writeTok(out_a_extraFuncsDecl, Tpl.ST_STRING("();"));
9166 ✗ ret_6 := intGt(a_iThreadIdx, 0);
9167 ✗ (out_txt, out_a_mainThreadCode) := fun_251(txt, ret_6, l_relLock, l_assLock, l_taskEqsZeroFunc, l_taskEqsDae, l_taskEqsOde, a_modelNamePrefixStr, a_iThreadIdx, l_varDeclsLoc, a_mainThreadCode);
9168 out_a_varDecls := a_varDecls;
9169 end generateThreadFunc;
9170
9171 protected function fun_253
9172 input Tpl.Text in_txt;
9173 input HpcOmSimCode.Task in_a_tt;
9174 input String in_a_iType;
9175 input String in_a_iLockPrefix;
9176
9177 output Tpl.Text out_txt;
9178 algorithm
9179 out_txt :=
9180 match(in_txt, in_a_tt, in_a_iType, in_a_iLockPrefix)
9181 local
9182 Tpl.Text txt;
9183 String a_iType;
9184 String a_iLockPrefix;
9185 HpcOmSimCode.Task i_task;
9186
9187 case ( txt,
9188 (i_task as HpcOmSimCode.DEPTASK(outgoing = true)),
9189 a_iType,
9190 a_iLockPrefix )
9191 algorithm
9192 ✗ txt := assignLockByDepTask(txt, i_task, a_iLockPrefix, a_iType);
9193 then txt;
9194
9195 case ( txt,
9196 _,
9197 _,
9198 _ )
9199 then txt;
9200 end match;
9201 end fun_253;
9202
9203 protected function lm_254
9204 input output Tpl.Text txt;
9205 input list<HpcOmSimCode.Task> items;
9206 input String a_iType;
9207 input String a_iLockPrefix;
9208 algorithm
9209 ✗ for lstElt_254 in items loop
9210 txt := match lstElt_254
9211 local
9212 HpcOmSimCode.Task i_tt;
9213
9214 case i_tt
9215 algorithm
9216 ✗ txt := fun_253(txt, i_tt, a_iType, a_iLockPrefix);
9217 ✗ txt := Tpl.nextIter(txt);
9218 then txt;
9219 end match;
9220 end for;
9221 end lm_254;
9222
9223 protected function fun_255
9224 input Tpl.Text in_txt;
9225 input Boolean in_mArg;
9226
9227 output Tpl.Text out_txt;
9228 algorithm
9229 out_txt :=
9230 match(in_txt, in_mArg)
9231 local
9232 Tpl.Text txt;
9233
9234 case ( txt,
9235 false )
9236 then txt;
9237
9238 case ( txt,
9239 _ )
9240 algorithm
9241 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("else "));
9242 then txt;
9243 end match;
9244 end fun_255;
9245
9246 public function function_HPCOM_assignThreadLocks
9247 input Tpl.Text txt;
9248 input list<HpcOmSimCode.Task> a_iThreadTasks;
9249 input String a_iLockPrefix;
9250 input Integer a_iThreadNum;
9251 input String a_iType;
9252
9253 output Tpl.Text out_txt;
9254 protected
9255 Boolean ret_1;
9256 Tpl.Text l_lockAssign;
9257 algorithm
9258 ✗ l_lockAssign := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
9259 ✗ l_lockAssign := lm_254(l_lockAssign, a_iThreadTasks, a_iType, a_iLockPrefix);
9260 ✗ l_lockAssign := Tpl.popIter(l_lockAssign);
9261 ✗ ret_1 := intNe(a_iThreadNum, 0);
9262 ✗ out_txt := fun_255(txt, ret_1);
9263 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("if(threadNum == "));
9264 ✗ out_txt := Tpl.writeStr(out_txt, intString(a_iThreadNum));
9265 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
9266 ")\n",
9267 "{\n"
9268 }, true));
9269 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
9270 ✗ out_txt := Tpl.writeText(out_txt, l_lockAssign);
9271 ✗ out_txt := Tpl.softNewLine(out_txt);
9272 ✗ out_txt := Tpl.popBlock(out_txt);
9273 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("}"));
9274 end function_HPCOM_assignThreadLocks;
9275
9276 protected function fun_257
9277 input Tpl.Text in_txt;
9278 input HpcOmSimCode.Task in_a_tt;
9279 input String in_a_iType;
9280 input String in_a_iLockPrefix;
9281
9282 output Tpl.Text out_txt;
9283 algorithm
9284 out_txt :=
9285 match(in_txt, in_a_tt, in_a_iType, in_a_iLockPrefix)
9286 local
9287 Tpl.Text txt;
9288 String a_iType;
9289 String a_iLockPrefix;
9290 HpcOmSimCode.Task i_tt;
9291
9292 case ( txt,
9293 (i_tt as HpcOmSimCode.DEPTASK(outgoing = false)),
9294 a_iType,
9295 a_iLockPrefix )
9296 algorithm
9297 ✗ txt := releaseLockByDepTask(txt, i_tt, a_iLockPrefix, a_iType);
9298 then txt;
9299
9300 case ( txt,
9301 _,
9302 _,
9303 _ )
9304 then txt;
9305 end match;
9306 end fun_257;
9307
9308 protected function lm_258
9309 input output Tpl.Text txt;
9310 input list<HpcOmSimCode.Task> items;
9311 input String a_iType;
9312 input String a_iLockPrefix;
9313 algorithm
9314 ✗ for lstElt_258 in items loop
9315 txt := match lstElt_258
9316 local
9317 HpcOmSimCode.Task i_tt;
9318
9319 case i_tt
9320 algorithm
9321 ✗ txt := fun_257(txt, i_tt, a_iType, a_iLockPrefix);
9322 ✗ txt := Tpl.nextIter(txt);
9323 then txt;
9324 end match;
9325 end for;
9326 end lm_258;
9327
9328 protected function fun_259
9329 input Tpl.Text in_txt;
9330 input Boolean in_mArg;
9331
9332 output Tpl.Text out_txt;
9333 algorithm
9334 out_txt :=
9335 match(in_txt, in_mArg)
9336 local
9337 Tpl.Text txt;
9338
9339 case ( txt,
9340 false )
9341 then txt;
9342
9343 case ( txt,
9344 _ )
9345 algorithm
9346 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("else "));
9347 then txt;
9348 end match;
9349 end fun_259;
9350
9351 public function function_HPCOM_releaseThreadLocks
9352 input Tpl.Text txt;
9353 input list<HpcOmSimCode.Task> a_iThreadTasks;
9354 input String a_iLockPrefix;
9355 input Integer a_iThreadNum;
9356 input String a_iType;
9357
9358 output Tpl.Text out_txt;
9359 protected
9360 Boolean ret_1;
9361 Tpl.Text l_lockAssign;
9362 algorithm
9363 ✗ l_lockAssign := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
9364 ✗ l_lockAssign := lm_258(l_lockAssign, a_iThreadTasks, a_iType, a_iLockPrefix);
9365 ✗ l_lockAssign := Tpl.popIter(l_lockAssign);
9366 ✗ ret_1 := intNe(a_iThreadNum, 0);
9367 ✗ out_txt := fun_259(txt, ret_1);
9368 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("if(threadNum == "));
9369 ✗ out_txt := Tpl.writeStr(out_txt, intString(a_iThreadNum));
9370 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
9371 ")\n",
9372 "{\n"
9373 }, true));
9374 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
9375 ✗ out_txt := Tpl.writeText(out_txt, l_lockAssign);
9376 ✗ out_txt := Tpl.softNewLine(out_txt);
9377 ✗ out_txt := Tpl.popBlock(out_txt);
9378 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("}"));
9379 end function_HPCOM_releaseThreadLocks;
9380
9381 protected function lm_261
9382 input output Tpl.Text txt;
9383 input list<list<HpcOmSimCode.Task>> items;
9384 input Boolean a_useFlatArrayNotation;
9385 input Integer a_iThreadNum;
9386 input String a_extraFunctionName;
9387 input output Tpl.Text a_extraFuncsNamespace;
9388 input output Tpl.Text a_extraFuncsDecl;
9389 input output Tpl.Text a_extraFuncs;
9390 input SimCode.SimCode a_simCode;
9391 input output Tpl.Text a_varDecls;
9392 input String a_lockPrefix;
9393 input String a_iType;
9394 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
9395 algorithm
9396 ✗ for lstElt_261 in items loop
9397 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_261
9398 local
9399 Integer x_i0;
9400 list<HpcOmSimCode.Task> i_tt;
9401 Tpl.Text txt_0;
9402
9403 case i_tt
9404 algorithm
9405 ✗ x_i0 := Tpl.getIteri_i0(txt);
9406 ✗ txt_0 := Tpl.writeStr(Tpl.emptyTxt, a_extraFunctionName);
9407 ✗ txt_0 := Tpl.writeTok(txt_0, Tpl.ST_STRING("_Th"));
9408 ✗ txt_0 := Tpl.writeStr(txt_0, intString(a_iThreadNum));
9409 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := parallelThreadCode(txt, a_allEquationsPlusWhen, i_tt, x_i0, a_iType, a_lockPrefix, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, Tpl.textString(txt_0), a_useFlatArrayNotation);
9410 ✗ txt := Tpl.nextIter(txt);
9411 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
9412 end match;
9413 end for;
9414 end lm_261;
9415
9416 protected function fun_262
9417 input Tpl.Text in_txt;
9418 input Boolean in_mArg;
9419
9420 output Tpl.Text out_txt;
9421 algorithm
9422 out_txt :=
9423 match(in_txt, in_mArg)
9424 local
9425 Tpl.Text txt;
9426
9427 case ( txt,
9428 false )
9429 then txt;
9430
9431 case ( txt,
9432 _ )
9433 algorithm
9434 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("switch(threadNum) "));
9435 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
9436 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("{"));
9437 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
9438 then txt;
9439 end match;
9440 end fun_262;
9441
9442 protected function fun_263
9443 input Tpl.Text in_txt;
9444 input Boolean in_mArg;
9445
9446 output Tpl.Text out_txt;
9447 algorithm
9448 out_txt :=
9449 match(in_txt, in_mArg)
9450 local
9451 Tpl.Text txt;
9452
9453 case ( txt,
9454 false )
9455 then txt;
9456
9457 case ( txt,
9458 _ )
9459 algorithm
9460 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
9461 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
9462 then txt;
9463 end match;
9464 end fun_263;
9465
9466 protected function fun_264
9467 input Tpl.Text in_txt;
9468 input String in_a_iType;
9469 input Integer in_a_iMaxThreadNumber;
9470 input Tpl.Text in_a_functionCalls;
9471 input Integer in_a_iThreadNum;
9472
9473 output Tpl.Text out_txt;
9474 algorithm
9475 out_txt :=
9476 match(in_txt, in_a_iType, in_a_iMaxThreadNumber, in_a_functionCalls, in_a_iThreadNum)
9477 local
9478 Tpl.Text txt;
9479 Integer a_iMaxThreadNumber;
9480 Tpl.Text a_functionCalls;
9481 Integer a_iThreadNum;
9482 Boolean ret_1;
9483 Boolean ret_0;
9484
9485 case ( txt,
9486 "openmp",
9487 a_iMaxThreadNumber,
9488 a_functionCalls,
9489 a_iThreadNum )
9490 algorithm
9491 ✗ ret_0 := intEq(a_iThreadNum, 0);
9492 ✗ txt := fun_262(txt, ret_0);
9493 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("case "));
9494 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadNum));
9495 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(":\n"));
9496 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
9497 ✗ txt := Tpl.writeText(txt, a_functionCalls);
9498 ✗ txt := Tpl.softNewLine(txt);
9499 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("break;\n"));
9500 ✗ txt := Tpl.popBlock(txt);
9501 ✗ ret_1 := intEq(a_iThreadNum, a_iMaxThreadNumber);
9502 ✗ txt := fun_263(txt, ret_1);
9503 then txt;
9504
9505 case ( txt,
9506 "mpi",
9507 _,
9508 a_functionCalls,
9509 a_iThreadNum )
9510 algorithm
9511 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("if (world_rank == "));
9512 ✗ txt := Tpl.writeStr(txt, intString(a_iThreadNum));
9513 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
9514 ")\n",
9515 "{\n"
9516 }, true));
9517 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
9518 ✗ txt := Tpl.writeText(txt, a_functionCalls);
9519 ✗ txt := Tpl.softNewLine(txt);
9520 ✗ txt := Tpl.popBlock(txt);
9521 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
9522 then txt;
9523
9524 case ( txt,
9525 _,
9526 _,
9527 a_functionCalls,
9528 _ )
9529 algorithm
9530 ✗ txt := Tpl.writeText(txt, a_functionCalls);
9531 then txt;
9532 end match;
9533 end fun_264;
9534
9535 public function parallelThreadCodeWithSplit
9536 input Tpl.Text txt;
9537 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
9538 input list<HpcOmSimCode.Task> a_threadTaskList;
9539 input Integer a_iThreadNum;
9540 input Integer a_iMaxThreadNumber;
9541 input String a_iType;
9542 input String a_lockPrefix;
9543 input Tpl.Text a_varDecls;
9544 input SimCode.SimCode a_simCode;
9545 input Tpl.Text a_extraFuncs;
9546 input Tpl.Text a_extraFuncsDecl;
9547 input Tpl.Text a_extraFuncsNamespace;
9548 input String a_extraFunctionName;
9549 input Boolean a_useFlatArrayNotation;
9550
9551 output Tpl.Text out_txt;
9552 output Tpl.Text out_a_varDecls;
9553 output Tpl.Text out_a_extraFuncs;
9554 output Tpl.Text out_a_extraFuncsDecl;
9555 output Tpl.Text out_a_extraFuncsNamespace;
9556 protected
9557 list<list<HpcOmSimCode.Task>> ret_1;
9558 Tpl.Text l_functionCalls;
9559 algorithm
9560 ✗ ret_1 := List.partition(a_threadTaskList, 100);
9561 ✗ l_functionCalls := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
9562 ✗ (l_functionCalls, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls) := lm_261(l_functionCalls, ret_1, a_useFlatArrayNotation, a_iThreadNum, a_extraFunctionName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_lockPrefix, a_iType, a_allEquationsPlusWhen);
9563 ✗ l_functionCalls := Tpl.popIter(l_functionCalls);
9564 ✗ out_txt := fun_264(txt, a_iType, a_iMaxThreadNumber, l_functionCalls, a_iThreadNum);
9565 end parallelThreadCodeWithSplit;
9566
9567 protected function lm_266
9568 input output Tpl.Text txt;
9569 input list<HpcOmSimCode.Task> items;
9570 input Boolean a_useFlatArrayNotation;
9571 input output Tpl.Text a_extraFuncsNamespace;
9572 input output Tpl.Text a_extraFuncsDecl;
9573 input output Tpl.Text a_extraFuncs;
9574 input SimCode.SimCode a_simCode;
9575 input output Tpl.Text a_varDecls;
9576 input String a_lockPrefix;
9577 input String a_iType;
9578 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
9579 algorithm
9580 ✗ for lstElt_266 in items loop
9581 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_266
9582 local
9583 HpcOmSimCode.Task i_tt;
9584
9585 case i_tt
9586 algorithm
9587 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := taskCode(txt, a_allEquationsPlusWhen, i_tt, a_iType, a_lockPrefix, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
9588 ✗ txt := Tpl.nextIter(txt);
9589 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
9590 end match;
9591 end for;
9592 end lm_266;
9593
9594 public function parallelThreadCode
9595 input Tpl.Text txt;
9596 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
9597 input list<HpcOmSimCode.Task> a_threadTaskList;
9598 input Integer a_iPartitionIndex;
9599 input String a_iType;
9600 input String a_lockPrefix;
9601 input Tpl.Text a_varDecls;
9602 input SimCode.SimCode a_simCode;
9603 input Tpl.Text a_extraFuncs;
9604 input Tpl.Text a_extraFuncsDecl;
9605 input Tpl.Text a_extraFuncsNamespace;
9606 input String a_extraFunctionName;
9607 input Boolean a_useFlatArrayNotation;
9608
9609 output Tpl.Text out_txt;
9610 output Tpl.Text out_a_varDecls;
9611 output Tpl.Text out_a_extraFuncs;
9612 output Tpl.Text out_a_extraFuncsDecl;
9613 output Tpl.Text out_a_extraFuncsNamespace;
9614 protected
9615 Tpl.Text l_threadTasks;
9616 algorithm
9617 ✗ l_threadTasks := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
9618 ✗ (l_threadTasks, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls) := lm_266(l_threadTasks, a_threadTaskList, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_lockPrefix, a_iType, a_allEquationsPlusWhen);
9619 ✗ l_threadTasks := Tpl.popIter(l_threadTasks);
9620 ✗ out_a_extraFuncs := Tpl.writeTok(out_a_extraFuncs, Tpl.ST_STRING("void "));
9621 ✗ out_a_extraFuncs := Tpl.writeText(out_a_extraFuncs, out_a_extraFuncsNamespace);
9622 ✗ out_a_extraFuncs := Tpl.writeTok(out_a_extraFuncs, Tpl.ST_STRING("::"));
9623 ✗ out_a_extraFuncs := Tpl.writeStr(out_a_extraFuncs, a_extraFunctionName);
9624 ✗ out_a_extraFuncs := Tpl.writeTok(out_a_extraFuncs, Tpl.ST_STRING("_"));
9625 ✗ out_a_extraFuncs := Tpl.writeStr(out_a_extraFuncs, intString(a_iPartitionIndex));
9626 ✗ out_a_extraFuncs := Tpl.writeTok(out_a_extraFuncs, Tpl.ST_STRING_LIST({
9627 "()\n",
9628 "{\n"
9629 }, true));
9630 ✗ out_a_extraFuncs := Tpl.pushBlock(out_a_extraFuncs, Tpl.BT_INDENT(2));
9631 ✗ out_a_extraFuncs := Tpl.writeText(out_a_extraFuncs, l_threadTasks);
9632 ✗ out_a_extraFuncs := Tpl.softNewLine(out_a_extraFuncs);
9633 ✗ out_a_extraFuncs := Tpl.popBlock(out_a_extraFuncs);
9634 ✗ out_a_extraFuncs := Tpl.writeTok(out_a_extraFuncs, Tpl.ST_STRING("}"));
9635 ✗ out_a_extraFuncs := Tpl.writeTok(out_a_extraFuncs, Tpl.ST_NEW_LINE());
9636 ✗ out_a_extraFuncs := Tpl.writeTok(out_a_extraFuncs, Tpl.ST_NEW_LINE());
9637 ✗ out_a_extraFuncsDecl := Tpl.writeTok(out_a_extraFuncsDecl, Tpl.ST_STRING("void "));
9638 ✗ out_a_extraFuncsDecl := Tpl.writeStr(out_a_extraFuncsDecl, a_extraFunctionName);
9639 ✗ out_a_extraFuncsDecl := Tpl.writeTok(out_a_extraFuncsDecl, Tpl.ST_STRING("_"));
9640 ✗ out_a_extraFuncsDecl := Tpl.writeStr(out_a_extraFuncsDecl, intString(a_iPartitionIndex));
9641 ✗ out_a_extraFuncsDecl := Tpl.writeTok(out_a_extraFuncsDecl, Tpl.ST_STRING("();"));
9642 ✗ out_txt := Tpl.writeStr(txt, a_extraFunctionName);
9643 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("_"));
9644 ✗ out_txt := Tpl.writeStr(out_txt, intString(a_iPartitionIndex));
9645 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("();"));
9646 end parallelThreadCode;
9647
9648 protected function lm_268
9649 input output Tpl.Text txt;
9650 input list<Integer> items;
9651 input Boolean a_useFlatArrayNotation;
9652 input output Tpl.Text a_extraFuncsNamespace;
9653 input output Tpl.Text a_extraFuncsDecl;
9654 input output Tpl.Text a_extraFuncs;
9655 input SimCode.SimCode a_simCode;
9656 input output Tpl.Text a_varDecls;
9657 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
9658 algorithm
9659 ✗ for lstElt_268 in items loop
9660 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_268
9661 local
9662 Integer i_eq;
9663
9664 case i_eq
9665 algorithm
9666 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := equationNamesHPCOM_(txt, i_eq, a_allEquationsPlusWhen, SimCodeFunction.contextSimulationNonDiscrete, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
9667 ✗ txt := Tpl.nextIter(txt);
9668 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
9669 end match;
9670 end for;
9671 end lm_268;
9672
9673 protected function lm_269
9674 input output Tpl.Text txt;
9675 input list<Integer> items;
9676 input Boolean a_useFlatArrayNotation;
9677 input output Tpl.Text a_extraFuncsNamespace;
9678 input output Tpl.Text a_extraFuncsDecl;
9679 input output Tpl.Text a_extraFuncs;
9680 input SimCode.SimCode a_simCode;
9681 input output Tpl.Text a_varDecls;
9682 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
9683 algorithm
9684
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 102 times.
273 for lstElt_269 in items loop
9685 (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := match lstElt_269
9686 local
9687 Integer i_eq;
9688
9689 case i_eq
9690 algorithm
9691 171 (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := equationNamesHPCOM_(txt, i_eq, a_allEquationsPlusWhen, SimCodeFunction.contextSimulationNonDiscrete, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
9692 171 txt := Tpl.nextIter(txt);
9693 then (txt, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls);
9694 end match;
9695 end for;
9696 end lm_269;
9697
9698 protected function lm_270
9699 input output Tpl.Text txt;
9700 input list<Integer> items;
9701 algorithm
9702
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 102 times.
204 for lstElt_270 in items loop
9703 txt := match lstElt_270
9704 local
9705 Integer i_task;
9706
9707 case i_task
9708 algorithm
9709 102 txt := Tpl.writeStr(txt, intString(i_task));
9710 102 txt := Tpl.nextIter(txt);
9711 then txt;
9712 end match;
9713 end for;
9714 end lm_270;
9715
9716 protected function fun_271
9717 input Tpl.Text in_txt;
9718 input HpcOmSimCode.Task in_a_iTask;
9719 input list<SimCode.SimEqSystem> in_a_allEquationsPlusWhen;
9720 input String in_a_iType;
9721 input String in_a_lockPrefix;
9722 input Tpl.Text in_a_varDecls;
9723 input SimCode.SimCode in_a_simCode;
9724 input Tpl.Text in_a_extraFuncs;
9725 input Tpl.Text in_a_extraFuncsDecl;
9726 input Tpl.Text in_a_extraFuncsNamespace;
9727 input Boolean in_a_useFlatArrayNotation;
9728
9729 output Tpl.Text out_txt;
9730 output Tpl.Text out_a_varDecls;
9731 output Tpl.Text out_a_extraFuncs;
9732 output Tpl.Text out_a_extraFuncsDecl;
9733 output Tpl.Text out_a_extraFuncsNamespace;
9734 algorithm
9735 (out_txt, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) :=
9736 match(in_txt, in_a_iTask, in_a_allEquationsPlusWhen, in_a_iType, in_a_lockPrefix, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_useFlatArrayNotation)
9737 local
9738 Tpl.Text txt;
9739 list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
9740 String a_iType;
9741 String a_lockPrefix;
9742 Tpl.Text a_varDecls;
9743 SimCode.SimCode a_simCode;
9744 Tpl.Text a_extraFuncs;
9745 Tpl.Text a_extraFuncsDecl;
9746 Tpl.Text a_extraFuncsNamespace;
9747 Boolean a_useFlatArrayNotation;
9748 HpcOmSimCode.Task i_task;
9749 list<Integer> i_task_nodeIdc;
9750 Integer i_task_index;
9751 list<Integer> i_task_eqIdc;
9752 Tpl.Text l_relLck;
9753 Tpl.Text l_assLck;
9754 Tpl.Text l_taskStr;
9755 Tpl.Text l_varDeclsLocal;
9756 Tpl.Text l_odeEqs;
9757
9758 case ( txt,
9759 HpcOmSimCode.CALCTASK(eqIdc = i_task_eqIdc, index = i_task_index),
9760 a_allEquationsPlusWhen,
9761 _,
9762 _,
9763 a_varDecls,
9764 a_simCode,
9765 a_extraFuncs,
9766 a_extraFuncsDecl,
9767 a_extraFuncsNamespace,
9768 a_useFlatArrayNotation )
9769 algorithm
9770 ✗ l_odeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
9771 ✗ (l_odeEqs, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_268(l_odeEqs, i_task_eqIdc, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_allEquationsPlusWhen);
9772 ✗ l_odeEqs := Tpl.popIter(l_odeEqs);
9773 l_varDeclsLocal := Tpl.emptyTxt;
9774 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("// Task "));
9775 ✗ txt := Tpl.writeStr(txt, intString(i_task_index));
9776 ✗ txt := Tpl.softNewLine(txt);
9777 ✗ txt := Tpl.writeText(txt, l_odeEqs);
9778 ✗ txt := Tpl.softNewLine(txt);
9779 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("// End Task "));
9780 ✗ txt := Tpl.writeStr(txt, intString(i_task_index));
9781 ✗ then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
9782
9783 case ( txt,
9784 HpcOmSimCode.CALCTASK_LEVEL(eqIdc = i_task_eqIdc, nodeIdc = i_task_nodeIdc),
9785 a_allEquationsPlusWhen,
9786 _,
9787 _,
9788 a_varDecls,
9789 a_simCode,
9790 a_extraFuncs,
9791 a_extraFuncsDecl,
9792 a_extraFuncsNamespace,
9793 a_useFlatArrayNotation )
9794 algorithm
9795 102 l_odeEqs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
9796 102 (l_odeEqs, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls) := lm_269(l_odeEqs, i_task_eqIdc, a_useFlatArrayNotation, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_allEquationsPlusWhen);
9797 102 l_odeEqs := Tpl.popIter(l_odeEqs);
9798 102 l_taskStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
9799 102 l_taskStr := lm_270(l_taskStr, i_task_nodeIdc);
9800 102 l_taskStr := Tpl.popIter(l_taskStr);
9801 l_varDeclsLocal := Tpl.emptyTxt;
9802 102 txt := Tpl.writeTok(txt, Tpl.ST_STRING("// Tasks "));
9803 102 txt := Tpl.writeText(txt, l_taskStr);
9804 102 txt := Tpl.softNewLine(txt);
9805 102 txt := Tpl.writeText(txt, l_odeEqs);
9806 102 then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
9807
9808 case ( txt,
9809 (i_task as HpcOmSimCode.DEPTASK(outgoing = false)),
9810 _,
9811 a_iType,
9812 a_lockPrefix,
9813 a_varDecls,
9814 _,
9815 a_extraFuncs,
9816 a_extraFuncsDecl,
9817 a_extraFuncsNamespace,
9818 _ )
9819 algorithm
9820 ✗ l_assLck := assignLockByDepTask(Tpl.emptyTxt, i_task, a_lockPrefix, a_iType);
9821 ✗ txt := Tpl.writeText(txt, l_assLck);
9822 ✗ then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
9823
9824 case ( txt,
9825 (i_task as HpcOmSimCode.DEPTASK(outgoing = true)),
9826 _,
9827 a_iType,
9828 a_lockPrefix,
9829 a_varDecls,
9830 _,
9831 a_extraFuncs,
9832 a_extraFuncsDecl,
9833 a_extraFuncsNamespace,
9834 _ )
9835 algorithm
9836 ✗ l_relLck := releaseLockByDepTask(Tpl.emptyTxt, i_task, a_lockPrefix, a_iType);
9837 ✗ txt := Tpl.writeText(txt, l_relLck);
9838 ✗ then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
9839
9840 case ( txt,
9841 _,
9842 _,
9843 _,
9844 _,
9845 a_varDecls,
9846 _,
9847 a_extraFuncs,
9848 a_extraFuncsDecl,
9849 a_extraFuncsNamespace,
9850 _ )
9851 then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
9852 end match;
9853 end fun_271;
9854
9855 public function taskCode
9856 input Tpl.Text txt;
9857 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
9858 input HpcOmSimCode.Task a_iTask;
9859 input String a_iType;
9860 input String a_lockPrefix;
9861 input Tpl.Text a_varDecls;
9862 input SimCode.SimCode a_simCode;
9863 input Tpl.Text a_extraFuncs;
9864 input Tpl.Text a_extraFuncsDecl;
9865 input Tpl.Text a_extraFuncsNamespace;
9866 input Boolean a_useFlatArrayNotation;
9867
9868 output Tpl.Text out_txt;
9869 output Tpl.Text out_a_varDecls;
9870 output Tpl.Text out_a_extraFuncs;
9871 output Tpl.Text out_a_extraFuncsDecl;
9872 output Tpl.Text out_a_extraFuncsNamespace;
9873 algorithm
9874 102 (out_txt, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := fun_271(txt, a_iTask, a_allEquationsPlusWhen, a_iType, a_lockPrefix, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
9875 end taskCode;
9876
9877 public function equationNamesHPCOM_
9878 input Tpl.Text txt;
9879 input Integer a_idx;
9880 input list<SimCode.SimEqSystem> a_allEquationsPlusWhen;
9881 input SimCodeFunction.Context a_context;
9882 input Tpl.Text a_varDecls;
9883 input SimCode.SimCode a_simCode;
9884 input Tpl.Text a_extraFuncs;
9885 input Tpl.Text a_extraFuncsDecl;
9886 input Tpl.Text a_extraFuncsNamespace;
9887 input Boolean a_useFlatArrayNotation;
9888
9889 output Tpl.Text out_txt;
9890 output Tpl.Text out_a_varDecls;
9891 output Tpl.Text out_a_extraFuncs;
9892 output Tpl.Text out_a_extraFuncsDecl;
9893 output Tpl.Text out_a_extraFuncsNamespace;
9894 protected
9895 SimCode.SimEqSystem ret_1;
9896 Tpl.Text l_eq;
9897 algorithm
9898 171 ret_1 := HpcOmCodegenUtil.getSimCodeEqByIndex(a_allEquationsPlusWhen, a_idx);
9899 171 (l_eq, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := equationHPCOM_(Tpl.emptyTxt, ret_1, a_idx, a_context, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_useFlatArrayNotation);
9900 171 out_txt := Tpl.writeText(txt, l_eq);
9901 end equationNamesHPCOM_;
9902
9903 public function equationHPCOM_
9904 input Tpl.Text txt;
9905 input SimCode.SimEqSystem a_eq;
9906 input Integer a_idx;
9907 input SimCodeFunction.Context a_context;
9908 input Tpl.Text a_varDecls;
9909 input SimCode.SimCode a_simCode;
9910 input Tpl.Text a_extraFuncs;
9911 input Tpl.Text a_extraFuncsDecl;
9912 input Tpl.Text a_extraFuncsNamespace;
9913 input Boolean a_useFlatArrayNotation;
9914
9915 output Tpl.Text out_txt;
9916 output Tpl.Text out_a_varDecls;
9917 output Tpl.Text out_a_extraFuncs;
9918 output Tpl.Text out_a_extraFuncsDecl;
9919 output Tpl.Text out_a_extraFuncsNamespace;
9920 algorithm
9921 171 (out_txt, _) := CodegenCpp.equation_function_call(txt, a_eq, a_context, a_simCode, Tpl.strTokText(Tpl.ST_STRING("evaluate")));
9922 out_a_varDecls := a_varDecls;
9923 out_a_extraFuncs := a_extraFuncs;
9924 out_a_extraFuncsDecl := a_extraFuncsDecl;
9925 out_a_extraFuncsNamespace := a_extraFuncsNamespace;
9926 end equationHPCOM_;
9927
9928 protected function fun_275
9929 input Tpl.Text in_txt;
9930 input String in_a_iType;
9931 input String in_a_threadIdx;
9932
9933 output Tpl.Text out_txt;
9934 algorithm
9935 out_txt :=
9936 match(in_txt, in_a_iType, in_a_threadIdx)
9937 local
9938 Tpl.Text txt;
9939 String a_threadIdx;
9940
9941 case ( txt,
9942 "openmp",
9943 _ )
9944 then txt;
9945
9946 case ( txt,
9947 _,
9948 a_threadIdx )
9949 algorithm
9950 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("evaluateThread"));
9951 ✗ txt := Tpl.writeStr(txt, a_threadIdx);
9952 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("->join();"));
9953 then txt;
9954 end match;
9955 end fun_275;
9956
9957 public function function_HPCOM_joinThread
9958 input Tpl.Text txt;
9959 input String a_threadIdx;
9960 input String a_iType;
9961
9962 output Tpl.Text out_txt;
9963 algorithm
9964 ✗ out_txt := fun_275(txt, a_iType, a_threadIdx);
9965 end function_HPCOM_joinThread;
9966
9967 protected function fun_277
9968 input Tpl.Text in_txt;
9969 input String in_a_iType;
9970 input String in_a_threadIdx;
9971
9972 output Tpl.Text out_txt;
9973 algorithm
9974 out_txt :=
9975 match(in_txt, in_a_iType, in_a_threadIdx)
9976 local
9977 Tpl.Text txt;
9978 String a_threadIdx;
9979
9980 case ( txt,
9981 "openmp",
9982 _ )
9983 then txt;
9984
9985 case ( txt,
9986 _,
9987 a_threadIdx )
9988 algorithm
9989 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("delete evaluateThread"));
9990 ✗ txt := Tpl.writeStr(txt, a_threadIdx);
9991 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
9992 then txt;
9993 end match;
9994 end fun_277;
9995
9996 public function function_HPCOM_destroyThread
9997 input Tpl.Text txt;
9998 input String a_threadIdx;
9999 input String a_iType;
10000
10001 output Tpl.Text out_txt;
10002 algorithm
10003 ✗ out_txt := fun_277(txt, a_iType, a_threadIdx);
10004 end function_HPCOM_destroyThread;
10005
10006 protected function fun_279
10007 input Tpl.Text in_txt;
10008 input String in_a_iType;
10009 input Integer in_a_threadIdx;
10010 input String in_a_modelNamePrefixStr;
10011 input String in_a_funcName;
10012
10013 output Tpl.Text out_txt;
10014 algorithm
10015 out_txt :=
10016 match(in_txt, in_a_iType, in_a_threadIdx, in_a_modelNamePrefixStr, in_a_funcName)
10017 local
10018 Tpl.Text txt;
10019 Integer a_threadIdx;
10020 String a_modelNamePrefixStr;
10021 String a_funcName;
10022
10023 case ( txt,
10024 "openmp",
10025 _,
10026 _,
10027 _ )
10028 then txt;
10029
10030 case ( txt,
10031 _,
10032 a_threadIdx,
10033 a_modelNamePrefixStr,
10034 a_funcName )
10035 algorithm
10036 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("evaluateThread"));
10037 ✗ txt := Tpl.writeStr(txt, intString(a_threadIdx));
10038 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = new thread(bind(&"));
10039 ✗ txt := Tpl.writeStr(txt, a_modelNamePrefixStr);
10040 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("::"));
10041 ✗ txt := Tpl.writeStr(txt, a_funcName);
10042 ✗ txt := Tpl.writeStr(txt, intString(a_threadIdx));
10043 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", this));"));
10044 then txt;
10045 end match;
10046 end fun_279;
10047
10048 public function generateThread
10049 input Tpl.Text txt;
10050 input Integer a_threadIdx;
10051 input String a_iType;
10052 input String a_modelNamePrefixStr;
10053 input String a_funcName;
10054
10055 output Tpl.Text out_txt;
10056 algorithm
10057 ✗ out_txt := fun_279(txt, a_iType, a_threadIdx, a_modelNamePrefixStr, a_funcName);
10058 end generateThread;
10059
10060 public function getLockNameByDepTask
10061 input Tpl.Text in_txt;
10062 input HpcOmSimCode.Task in_a_depTask;
10063
10064 output Tpl.Text out_txt;
10065 algorithm
10066 out_txt :=
10067 match(in_txt, in_a_depTask)
10068 local
10069 Tpl.Text txt;
10070 Integer i_task_id;
10071
10072 case ( txt,
10073 HpcOmSimCode.DEPTASK(id = i_task_id) )
10074 algorithm
10075 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("["));
10076 ✗ txt := Tpl.writeStr(txt, intString(i_task_id));
10077 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("]"));
10078 then txt;
10079
10080 case ( txt,
10081 _ )
10082 algorithm
10083 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("invalidLockTask"));
10084 then txt;
10085 end match;
10086 end getLockNameByDepTask;
10087
10088 public function initializeLockByDepTask
10089 input Tpl.Text txt;
10090 input HpcOmSimCode.Task a_depTask;
10091 input String a_lockPrefix;
10092 input String a_iType;
10093
10094 output Tpl.Text out_txt;
10095 protected
10096 Tpl.Text l_lockName;
10097 algorithm
10098 ✗ l_lockName := getLockNameByDepTask(Tpl.emptyTxt, a_depTask);
10099 ✗ out_txt := initializeLockByLockName(txt, Tpl.textString(l_lockName), a_lockPrefix, a_iType);
10100 end initializeLockByDepTask;
10101
10102 protected function fun_283
10103 input Tpl.Text in_txt;
10104 input String in_a_iType;
10105 input String in_a_lockName;
10106 input String in_a_lockPrefix;
10107
10108 output Tpl.Text out_txt;
10109 algorithm
10110 out_txt :=
10111 match(in_txt, in_a_iType, in_a_lockName, in_a_lockPrefix)
10112 local
10113 Tpl.Text txt;
10114 String a_lockName;
10115 String a_lockPrefix;
10116
10117 case ( txt,
10118 "openmp",
10119 a_lockName,
10120 a_lockPrefix )
10121 algorithm
10122 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("omp_init_lock(&"));
10123 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10124 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10125 ✗ txt := Tpl.writeStr(txt, a_lockName);
10126 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
10127 then txt;
10128
10129 case ( txt,
10130 "pthreads",
10131 a_lockName,
10132 a_lockPrefix )
10133 algorithm
10134 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10135 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10136 ✗ txt := Tpl.writeStr(txt, a_lockName);
10137 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = new alignedLock();"));
10138 then txt;
10139
10140 case ( txt,
10141 "pthreads_spin",
10142 a_lockName,
10143 a_lockPrefix )
10144 algorithm
10145 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10146 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10147 ✗ txt := Tpl.writeStr(txt, a_lockName);
10148 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = new alignedSpinlock();"));
10149 then txt;
10150
10151 case ( txt,
10152 _,
10153 _,
10154 _ )
10155 then txt;
10156 end match;
10157 end fun_283;
10158
10159 public function initializeLockByLockName
10160 input Tpl.Text txt;
10161 input String a_lockName;
10162 input String a_lockPrefix;
10163 input String a_iType;
10164
10165 output Tpl.Text out_txt;
10166 algorithm
10167 ✗ out_txt := fun_283(txt, a_iType, a_lockName, a_lockPrefix);
10168 end initializeLockByLockName;
10169
10170 protected function fun_285
10171 input Tpl.Text in_txt;
10172 input String in_a_iType;
10173 input String in_a_lockName;
10174 input String in_a_lockPrefix;
10175 input Integer in_a_numberOfThreads;
10176
10177 output Tpl.Text out_txt;
10178 algorithm
10179 out_txt :=
10180 match(in_txt, in_a_iType, in_a_lockName, in_a_lockPrefix, in_a_numberOfThreads)
10181 local
10182 Tpl.Text txt;
10183 String a_lockName;
10184 String a_lockPrefix;
10185 Integer a_numberOfThreads;
10186
10187 case ( txt,
10188 "pthreads",
10189 a_lockName,
10190 a_lockPrefix,
10191 a_numberOfThreads )
10192 algorithm
10193 1 txt := Tpl.writeStr(txt, a_lockPrefix);
10194 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10195 1 txt := Tpl.writeStr(txt, a_lockName);
10196 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
10197 1 txt := Tpl.writeStr(txt, intString(a_numberOfThreads));
10198 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
10199 then txt;
10200
10201 case ( txt,
10202 "pthreads_spin",
10203 a_lockName,
10204 a_lockPrefix,
10205 a_numberOfThreads )
10206 algorithm
10207 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10208 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10209 ✗ txt := Tpl.writeStr(txt, a_lockName);
10210 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
10211 ✗ txt := Tpl.writeStr(txt, intString(a_numberOfThreads));
10212 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
10213 then txt;
10214
10215 case ( txt,
10216 _,
10217 _,
10218 _,
10219 _ )
10220 then txt;
10221 end match;
10222 end fun_285;
10223
10224 public function initializeBarrierByName
10225 input Tpl.Text txt;
10226 input String a_lockName;
10227 input String a_lockPrefix;
10228 input Integer a_numberOfThreads;
10229 input String a_iType;
10230
10231 output Tpl.Text out_txt;
10232 algorithm
10233 1 out_txt := fun_285(txt, a_iType, a_lockName, a_lockPrefix, a_numberOfThreads);
10234 end initializeBarrierByName;
10235
10236 public function createLockByDepTask
10237 input Tpl.Text txt;
10238 input HpcOmSimCode.Task a_depTask;
10239 input String a_lockPrefix;
10240 input String a_iType;
10241
10242 output Tpl.Text out_txt;
10243 protected
10244 Tpl.Text l_lockName;
10245 algorithm
10246 ✗ l_lockName := getLockNameByDepTask(Tpl.emptyTxt, a_depTask);
10247 ✗ out_txt := createLockByLockName(txt, Tpl.textString(l_lockName), a_lockPrefix, a_iType);
10248 end createLockByDepTask;
10249
10250 protected function fun_288
10251 input Tpl.Text in_txt;
10252 input String in_a_iType;
10253 input String in_a_lockName;
10254 input String in_a_lockPrefix;
10255
10256 output Tpl.Text out_txt;
10257 algorithm
10258 out_txt :=
10259 match(in_txt, in_a_iType, in_a_lockName, in_a_lockPrefix)
10260 local
10261 Tpl.Text txt;
10262 String a_lockName;
10263 String a_lockPrefix;
10264
10265 case ( txt,
10266 "openmp",
10267 a_lockName,
10268 a_lockPrefix )
10269 algorithm
10270 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("omp_lock_t "));
10271 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10272 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10273 ✗ txt := Tpl.writeStr(txt, a_lockName);
10274 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
10275 then txt;
10276
10277 case ( txt,
10278 "pthreads",
10279 a_lockName,
10280 a_lockPrefix )
10281 algorithm
10282 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("alignedLock* "));
10283 2 txt := Tpl.writeStr(txt, a_lockPrefix);
10284 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10285 2 txt := Tpl.writeStr(txt, a_lockName);
10286 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
10287 then txt;
10288
10289 case ( txt,
10290 "pthreads_spin",
10291 a_lockName,
10292 a_lockPrefix )
10293 algorithm
10294 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("alignedSpinlock* "));
10295 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10296 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10297 ✗ txt := Tpl.writeStr(txt, a_lockName);
10298 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
10299 then txt;
10300
10301 case ( txt,
10302 _,
10303 _,
10304 _ )
10305 then txt;
10306 end match;
10307 end fun_288;
10308
10309 public function createLockByLockName
10310 input Tpl.Text txt;
10311 input String a_lockName;
10312 input String a_lockPrefix;
10313 input String a_iType;
10314
10315 output Tpl.Text out_txt;
10316 algorithm
10317 2 out_txt := fun_288(txt, a_iType, a_lockName, a_lockPrefix);
10318 end createLockByLockName;
10319
10320 protected function fun_290
10321 input Tpl.Text in_txt;
10322 input String in_a_iType;
10323 input String in_a_lockName;
10324 input String in_a_lockPrefix;
10325
10326 output Tpl.Text out_txt;
10327 algorithm
10328 out_txt :=
10329 match(in_txt, in_a_iType, in_a_lockName, in_a_lockPrefix)
10330 local
10331 Tpl.Text txt;
10332 String a_lockName;
10333 String a_lockPrefix;
10334
10335 case ( txt,
10336 "pthreads",
10337 a_lockName,
10338 a_lockPrefix )
10339 algorithm
10340 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("busywaiting_barrier "));
10341 1 txt := Tpl.writeStr(txt, a_lockPrefix);
10342 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10343 1 txt := Tpl.writeStr(txt, a_lockName);
10344 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
10345 then txt;
10346
10347 case ( txt,
10348 "pthreads_spin",
10349 a_lockName,
10350 a_lockPrefix )
10351 algorithm
10352 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("busywaiting_barrier "));
10353 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10354 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10355 ✗ txt := Tpl.writeStr(txt, a_lockName);
10356 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
10357 then txt;
10358
10359 case ( txt,
10360 _,
10361 _,
10362 _ )
10363 then txt;
10364 end match;
10365 end fun_290;
10366
10367 public function createBarrierByName
10368 input Tpl.Text txt;
10369 input String a_lockName;
10370 input String a_lockPrefix;
10371 input Integer a_numOfThreads;
10372 input String a_iType;
10373
10374 output Tpl.Text out_txt;
10375 algorithm
10376 1 out_txt := fun_290(txt, a_iType, a_lockName, a_lockPrefix);
10377 end createBarrierByName;
10378
10379 public function destroyLockByDepTask
10380 input Tpl.Text txt;
10381 input HpcOmSimCode.Task a_depTask;
10382 input String a_lockPrefix;
10383 input String a_iType;
10384
10385 output Tpl.Text out_txt;
10386 protected
10387 Tpl.Text l_lockName;
10388 algorithm
10389 ✗ l_lockName := getLockNameByDepTask(Tpl.emptyTxt, a_depTask);
10390 ✗ out_txt := destroyLockByLockName(txt, Tpl.textString(l_lockName), a_lockPrefix, a_iType);
10391 end destroyLockByDepTask;
10392
10393 protected function fun_293
10394 input Tpl.Text in_txt;
10395 input String in_a_iType;
10396 input String in_a_lockName;
10397 input String in_a_lockPrefix;
10398
10399 output Tpl.Text out_txt;
10400 algorithm
10401 out_txt :=
10402 match(in_txt, in_a_iType, in_a_lockName, in_a_lockPrefix)
10403 local
10404 Tpl.Text txt;
10405 String a_lockName;
10406 String a_lockPrefix;
10407
10408 case ( txt,
10409 "openmp",
10410 a_lockName,
10411 a_lockPrefix )
10412 algorithm
10413 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("omp_destroy_lock(&"));
10414 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10415 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10416 ✗ txt := Tpl.writeStr(txt, a_lockName);
10417 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
10418 then txt;
10419
10420 case ( txt,
10421 "pthreads",
10422 a_lockName,
10423 a_lockPrefix )
10424 algorithm
10425 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("delete "));
10426 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10427 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10428 ✗ txt := Tpl.writeStr(txt, a_lockName);
10429 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
10430 then txt;
10431
10432 case ( txt,
10433 "pthreads_spin",
10434 a_lockName,
10435 a_lockPrefix )
10436 algorithm
10437 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("delete "));
10438 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10439 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10440 ✗ txt := Tpl.writeStr(txt, a_lockName);
10441 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
10442 then txt;
10443
10444 case ( txt,
10445 _,
10446 _,
10447 _ )
10448 then txt;
10449 end match;
10450 end fun_293;
10451
10452 public function destroyLockByLockName
10453 input Tpl.Text txt;
10454 input String a_lockName;
10455 input String a_lockPrefix;
10456 input String a_iType;
10457
10458 output Tpl.Text out_txt;
10459 algorithm
10460 ✗ out_txt := fun_293(txt, a_iType, a_lockName, a_lockPrefix);
10461 end destroyLockByLockName;
10462
10463 public function assignLockByDepTask
10464 input Tpl.Text in_txt;
10465 input HpcOmSimCode.Task in_a_depTask;
10466 input String in_a_lockPrefix;
10467 input String in_a_iType;
10468
10469 output Tpl.Text out_txt;
10470 algorithm
10471 out_txt :=
10472 match(in_txt, in_a_depTask, in_a_lockPrefix, in_a_iType)
10473 local
10474 Tpl.Text txt;
10475 String a_lockPrefix;
10476 String a_iType;
10477 HpcOmSimCode.Task i_depTask;
10478 Tpl.Text l_lockName;
10479
10480 case ( txt,
10481 (i_depTask as HpcOmSimCode.DEPTASK(sourceTask = _)),
10482 a_lockPrefix,
10483 a_iType )
10484 algorithm
10485 ✗ l_lockName := getLockNameByDepTask(Tpl.emptyTxt, i_depTask);
10486 ✗ txt := assignLockByLockName(txt, Tpl.textString(l_lockName), a_lockPrefix, a_iType);
10487 then txt;
10488
10489 case ( txt,
10490 _,
10491 _,
10492 _ )
10493 then txt;
10494 end match;
10495 end assignLockByDepTask;
10496
10497 public function printCommunicationInfoVariables
10498 input Tpl.Text txt;
10499 input HpcOmSimCode.CommunicationInfo a_commInfo;
10500
10501 output Tpl.Text out_txt;
10502 algorithm
10503 out_txt := txt;
10504 end printCommunicationInfoVariables;
10505
10506 protected function fun_297
10507 input Tpl.Text in_txt;
10508 input String in_a_iType;
10509 input String in_a_lockName;
10510 input String in_a_lockPrefix;
10511
10512 output Tpl.Text out_txt;
10513 algorithm
10514 out_txt :=
10515 match(in_txt, in_a_iType, in_a_lockName, in_a_lockPrefix)
10516 local
10517 Tpl.Text txt;
10518 String a_lockName;
10519 String a_lockPrefix;
10520
10521 case ( txt,
10522 "openmp",
10523 a_lockName,
10524 a_lockPrefix )
10525 algorithm
10526 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("omp_set_lock(&"));
10527 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10528 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10529 ✗ txt := Tpl.writeStr(txt, a_lockName);
10530 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
10531 then txt;
10532
10533 case ( txt,
10534 "pthreads",
10535 a_lockName,
10536 a_lockPrefix )
10537 algorithm
10538 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10539 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10540 ✗ txt := Tpl.writeStr(txt, a_lockName);
10541 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("->lock();"));
10542 then txt;
10543
10544 case ( txt,
10545 "pthreads_spin",
10546 a_lockName,
10547 a_lockPrefix )
10548 algorithm
10549 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10550 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10551 ✗ txt := Tpl.writeStr(txt, a_lockName);
10552 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("->lock();"));
10553 then txt;
10554
10555 case ( txt,
10556 _,
10557 _,
10558 _ )
10559 then txt;
10560 end match;
10561 end fun_297;
10562
10563 public function assignLockByLockName
10564 input Tpl.Text txt;
10565 input String a_lockName;
10566 input String a_lockPrefix;
10567 input String a_iType;
10568
10569 output Tpl.Text out_txt;
10570 algorithm
10571 ✗ out_txt := fun_297(txt, a_iType, a_lockName, a_lockPrefix);
10572 end assignLockByLockName;
10573
10574 public function releaseLockByDepTask
10575 input Tpl.Text txt;
10576 input HpcOmSimCode.Task a_depTask;
10577 input String a_lockPrefix;
10578 input String a_iType;
10579
10580 output Tpl.Text out_txt;
10581 protected
10582 Tpl.Text l_lockName;
10583 algorithm
10584 ✗ l_lockName := getLockNameByDepTask(Tpl.emptyTxt, a_depTask);
10585 ✗ out_txt := releaseLockByLockName(txt, Tpl.textString(l_lockName), a_lockPrefix, a_iType);
10586 end releaseLockByDepTask;
10587
10588 protected function fun_300
10589 input Tpl.Text in_txt;
10590 input String in_a_iType;
10591 input String in_a_lockName;
10592 input String in_a_lockPrefix;
10593
10594 output Tpl.Text out_txt;
10595 algorithm
10596 out_txt :=
10597 match(in_txt, in_a_iType, in_a_lockName, in_a_lockPrefix)
10598 local
10599 Tpl.Text txt;
10600 String a_lockName;
10601 String a_lockPrefix;
10602
10603 case ( txt,
10604 "openmp",
10605 a_lockName,
10606 a_lockPrefix )
10607 algorithm
10608 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("omp_unset_lock(&"));
10609 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10610 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10611 ✗ txt := Tpl.writeStr(txt, a_lockName);
10612 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
10613 then txt;
10614
10615 case ( txt,
10616 "pthreads",
10617 a_lockName,
10618 a_lockPrefix )
10619 algorithm
10620 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10621 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10622 ✗ txt := Tpl.writeStr(txt, a_lockName);
10623 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("->unlock();"));
10624 then txt;
10625
10626 case ( txt,
10627 "pthreads_spin",
10628 a_lockName,
10629 a_lockPrefix )
10630 algorithm
10631 ✗ txt := Tpl.writeStr(txt, a_lockPrefix);
10632 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
10633 ✗ txt := Tpl.writeStr(txt, a_lockName);
10634 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("->unlock();"));
10635 then txt;
10636
10637 case ( txt,
10638 _,
10639 _,
10640 _ )
10641 then txt;
10642 end match;
10643 end fun_300;
10644
10645 public function releaseLockByLockName
10646 input Tpl.Text txt;
10647 input String a_lockName;
10648 input String a_lockPrefix;
10649 input String a_iType;
10650
10651 output Tpl.Text out_txt;
10652 algorithm
10653 ✗ out_txt := fun_300(txt, a_iType, a_lockName, a_lockPrefix);
10654 end releaseLockByLockName;
10655
10656 public function mpiFinalize
10657 input Tpl.Text txt;
10658
10659 output Tpl.Text out_txt;
10660 algorithm
10661 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
10662 "} // End sequential\n",
10663 "MPI_Finalize();"
10664 }, false));
10665 end mpiFinalize;
10666
10667 public function mpiInit
10668 input Tpl.Text txt;
10669
10670 output Tpl.Text out_txt;
10671 algorithm
10672 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
10673 "char** argvNotConst = const_cast<char**>(argv);\n",
10674 "MPI_Init(&argc, &argvNotConst);\n",
10675 "int world_rank, world_size;\n",
10676 "MPI_Comm_size(MPI_COMM_WORLD, &world_size);\n",
10677 "MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);\n",
10678 "std::cout << \"Hello world! This is MPI process \" << world_rank\n",
10679 " << \" of \" << world_size << \" processes.\" << endl;\n",
10680 "\n",
10681 "// Run simulation in sequential\n",
10682 "if (0 == world_rank) {\n",
10683 " std::cout << \"Remark: Simulation is not (yet) MPI parallel!\\n\";"
10684 }, false));
10685 end mpiInit;
10686
10687 public function mpiRunCommandInRunScript
10688 input Tpl.Text in_txt;
10689 input String in_a_type;
10690 input Tpl.Text in_a_getNumOfProcs;
10691 input Tpl.Text in_a_execCommandLinux;
10692
10693 output Tpl.Text out_txt;
10694 output Tpl.Text out_a_getNumOfProcs;
10695 output Tpl.Text out_a_execCommandLinux;
10696 algorithm
10697 (out_txt, out_a_getNumOfProcs, out_a_execCommandLinux) :=
10698 match(in_txt, in_a_type, in_a_getNumOfProcs, in_a_execCommandLinux)
10699 local
10700 Tpl.Text txt;
10701 Tpl.Text a_getNumOfProcs;
10702 Tpl.Text a_execCommandLinux;
10703
10704 case ( txt,
10705 "mpi",
10706 a_getNumOfProcs,
10707 a_execCommandLinux )
10708 algorithm
10709 ✗ a_execCommandLinux := Tpl.writeTok(a_execCommandLinux, Tpl.ST_STRING("mpirun -np ${NPROCESSORS}"));
10710 ✗ a_getNumOfProcs := Tpl.writeTok(a_getNumOfProcs, Tpl.ST_STRING_LIST({
10711 "\n",
10712 "if [ $# -gt 0 ]; then\n",
10713 " NPROCESSORS=$1\n",
10714 " shift \n",
10715 "else\n",
10716 " NPROCESSORS=1\n",
10717 "fi\n",
10718 "\n"
10719 }, true));
10720 then (txt, a_getNumOfProcs, a_execCommandLinux);
10721
10722 case ( txt,
10723 _,
10724 a_getNumOfProcs,
10725 a_execCommandLinux )
10726 algorithm
10727 1 a_execCommandLinux := Tpl.writeTok(a_execCommandLinux, Tpl.ST_STRING("exec"));
10728 then (txt, a_getNumOfProcs, a_execCommandLinux);
10729 end match;
10730 end mpiRunCommandInRunScript;
10731
10732 protected function fun_305
10733 input Tpl.Text in_txt;
10734 input Boolean in_mArg;
10735
10736 output Tpl.Text out_txt;
10737 algorithm
10738 out_txt :=
10739 match(in_txt, in_mArg)
10740 local
10741 Tpl.Text txt;
10742
10743 case ( txt,
10744 false )
10745 then txt;
10746
10747 case ( txt,
10748 _ )
10749 algorithm
10750 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("mpi"));
10751 then txt;
10752 end match;
10753 end fun_305;
10754
10755 public function simulationMainRunScript
10756 input Tpl.Text txt;
10757 input SimCode.SimCode a_simCode;
10758 input Tpl.Text a_extraFuncs;
10759 input Tpl.Text a_extraFuncsDecl;
10760 input Tpl.Text a_extraFuncsNamespace;
10761
10762 output Tpl.Text out_txt;
10763 output Tpl.Text out_a_extraFuncs;
10764 output Tpl.Text out_a_extraFuncsDecl;
10765 output Tpl.Text out_a_extraFuncsNamespace;
10766 protected
10767 Tpl.Text l_preRunCommandWindows;
10768 Tpl.Text l_0__;
10769 Tpl.Text l_execCommandLinux;
10770 Tpl.Text l_preRunCommandLinux;
10771 Boolean ret_1;
10772 Tpl.Text l_type;
10773 algorithm
10774 1 ret_1 := Flags.isSet(Flags.USEMPI);
10775 1 l_type := fun_305(Tpl.emptyTxt, ret_1);
10776 1 l_preRunCommandLinux := Tpl.emptyTxt;
10777 1 l_execCommandLinux := Tpl.emptyTxt;
10778 1 (l_0__, l_preRunCommandLinux, l_execCommandLinux) := mpiRunCommandInRunScript(Tpl.emptyTxt, Tpl.textString(l_type), l_preRunCommandLinux, l_execCommandLinux);
10779 l_preRunCommandWindows := Tpl.emptyTxt;
10780 1 (out_txt, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := CodegenCpp.simulationMainRunScript(txt, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, Tpl.textString(l_preRunCommandLinux), Tpl.textString(l_preRunCommandWindows), Tpl.textString(l_execCommandLinux));
10781 end simulationMainRunScript;
10782
10783 protected function fun_307
10784 input Tpl.Text in_txt;
10785 input Boolean in_mArg;
10786
10787 output Tpl.Text out_txt;
10788 algorithm
10789 out_txt :=
10790 match(in_txt, in_mArg)
10791 local
10792 Tpl.Text txt;
10793
10794 case ( txt,
10795 false )
10796 then txt;
10797
10798 case ( txt,
10799 _ )
10800 algorithm
10801 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" -fopenmp"));
10802 then txt;
10803 end match;
10804 end fun_307;
10805
10806 protected function fun_308
10807 input Tpl.Text in_txt;
10808 input Boolean in_mArg;
10809
10810 output Tpl.Text out_txt;
10811 algorithm
10812 out_txt :=
10813 match(in_txt, in_mArg)
10814 local
10815 Tpl.Text txt;
10816
10817 case ( txt,
10818 false )
10819 then txt;
10820
10821 case ( txt,
10822 _ )
10823 algorithm
10824 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" -I\"$(INTEL_TBB_INCLUDE)\""));
10825 then txt;
10826 end match;
10827 end fun_308;
10828
10829 protected function fun_309
10830 input Tpl.Text in_txt;
10831 input Boolean in_mArg;
10832
10833 output Tpl.Text out_txt;
10834 algorithm
10835 out_txt :=
10836 match(in_txt, in_mArg)
10837 local
10838 Tpl.Text txt;
10839
10840 case ( txt,
10841 false )
10842 then txt;
10843
10844 case ( txt,
10845 _ )
10846 algorithm
10847 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("/openmp"));
10848 then txt;
10849 end match;
10850 end fun_309;
10851
10852 protected function fun_310
10853 input Tpl.Text in_txt;
10854 input Boolean in_mArg;
10855
10856 output Tpl.Text out_txt;
10857 algorithm
10858 out_txt :=
10859 match(in_txt, in_mArg)
10860 local
10861 Tpl.Text txt;
10862
10863 case ( txt,
10864 false )
10865 then txt;
10866
10867 case ( txt,
10868 _ )
10869 algorithm
10870 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("-L$(INTEL_TBB_LIBS) $(INTEL_TBB_LIBRARIES) "));
10871 then txt;
10872 end match;
10873 end fun_310;
10874
10875 protected function fun_311
10876 input Tpl.Text in_txt;
10877 input Boolean in_mArg;
10878
10879 output Tpl.Text out_txt;
10880 algorithm
10881 out_txt :=
10882 match(in_txt, in_mArg)
10883 local
10884 Tpl.Text txt;
10885
10886 case ( txt,
10887 false )
10888 then txt;
10889
10890 case ( txt,
10891 _ )
10892 algorithm
10893 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" -fopenmp"));
10894 then txt;
10895 end match;
10896 end fun_311;
10897
10898 public function getAdditionalMakefileFlags
10899 input Tpl.Text txt;
10900 input Tpl.Text a_additionalLinkerFlags__GCC;
10901 input Tpl.Text a_additionalLinkerFlags__MSVC;
10902 input Tpl.Text a_additionalCFlags__GCC;
10903 input Tpl.Text a_additionalCFlags__MSVC;
10904
10905 output Tpl.Text out_txt;
10906 output Tpl.Text out_a_additionalLinkerFlags__GCC;
10907 output Tpl.Text out_a_additionalLinkerFlags__MSVC;
10908 output Tpl.Text out_a_additionalCFlags__GCC;
10909 output Tpl.Text out_a_additionalCFlags__MSVC;
10910 protected
10911 Boolean ret_6;
10912 Boolean ret_5;
10913 Boolean ret_4;
10914 Boolean ret_3;
10915 Boolean ret_2;
10916 String ret_1;
10917 Tpl.Text l_type;
10918 algorithm
10919 1 ret_1 := Flags.getConfigString(Flags.HPCOM_CODE);
10920 1 l_type := Tpl.writeStr(Tpl.emptyTxt, ret_1);
10921
1/4
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
1 ret_2 := stringEq(Tpl.textString(l_type), "openmp");
10922 1 out_a_additionalCFlags__GCC := fun_307(a_additionalCFlags__GCC, ret_2);
10923
1/4
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
1 ret_3 := stringEq(Tpl.textString(l_type), "tbb");
10924 1 out_a_additionalCFlags__GCC := fun_308(out_a_additionalCFlags__GCC, ret_3);
10925
1/4
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
1 ret_4 := stringEq(Tpl.textString(l_type), "openmp");
10926 1 out_a_additionalCFlags__MSVC := fun_309(a_additionalCFlags__MSVC, ret_4);
10927
1/4
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
1 ret_5 := stringEq(Tpl.textString(l_type), "tbb");
10928 1 out_a_additionalLinkerFlags__GCC := fun_310(a_additionalLinkerFlags__GCC, ret_5);
10929
1/4
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
1 ret_6 := stringEq(Tpl.textString(l_type), "openmp");
10930 1 out_a_additionalLinkerFlags__GCC := fun_311(out_a_additionalLinkerFlags__GCC, ret_6);
10931 out_txt := txt;
10932 out_a_additionalLinkerFlags__MSVC := a_additionalLinkerFlags__MSVC;
10933 end getAdditionalMakefileFlags;
10934
10935 public function simulationMakefile
10936 input Tpl.Text txt;
10937 input String a_target;
10938 input SimCode.SimCode a_simCode;
10939 input Tpl.Text a_extraFuncs;
10940 input Tpl.Text a_extraFuncsDecl;
10941 input Tpl.Text a_extraFuncsNamespace;
10942
10943 output Tpl.Text out_txt;
10944 output Tpl.Text out_a_extraFuncs;
10945 output Tpl.Text out_a_extraFuncsDecl;
10946 output Tpl.Text out_a_extraFuncsNamespace;
10947 protected
10948 Boolean ret_4;
10949 Tpl.Text l_additionalLinkerFlags__MSVC;
10950 Tpl.Text l_additionalLinkerFlags__GCC;
10951 Tpl.Text l_additionalCFlags__MSVC;
10952 Tpl.Text l_additionalCFlags__GCC;
10953 algorithm
10954 1 l_additionalCFlags__GCC := Tpl.emptyTxt;
10955 1 l_additionalCFlags__MSVC := Tpl.emptyTxt;
10956 1 l_additionalLinkerFlags__GCC := Tpl.emptyTxt;
10957 1 l_additionalLinkerFlags__MSVC := Tpl.emptyTxt;
10958 1 (out_txt, l_additionalLinkerFlags__GCC, l_additionalLinkerFlags__MSVC, l_additionalCFlags__GCC, l_additionalCFlags__MSVC) := getAdditionalMakefileFlags(txt, l_additionalLinkerFlags__GCC, l_additionalLinkerFlags__MSVC, l_additionalCFlags__GCC, l_additionalCFlags__MSVC);
10959 1 out_txt := Tpl.softNewLine(out_txt);
10960 1 ret_4 := Flags.isSet(Flags.USEMPI);
10961 1 (out_txt, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := CodegenCpp.simulationMakefile(out_txt, a_target, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, Tpl.textString(l_additionalLinkerFlags__GCC), Tpl.textString(l_additionalLinkerFlags__MSVC), Tpl.textString(l_additionalCFlags__GCC), Tpl.textString(l_additionalCFlags__MSVC), ret_4);
10962 end simulationMakefile;
10963
10964 protected function fun_314
10965 input Tpl.Text in_txt;
10966 input Option<HpcOmSimCode.MemoryMap> in_a_hpcOmMemoryOpt;
10967 input SimCode.ModelInfo in_a_modelInfo;
10968
10969 output Tpl.Text out_txt;
10970 algorithm
10971 out_txt :=
10972 match(in_txt, in_a_hpcOmMemoryOpt, in_a_modelInfo)
10973 local
10974 Tpl.Text txt;
10975 SimCode.ModelInfo a_modelInfo;
10976 Integer i_boolArraySize;
10977 Integer i_intArraySize;
10978 Integer i_floatArraySize;
10979
10980 case ( txt,
10981 SOME(HpcOmSimCode.MEMORYMAP_ARRAY(floatArraySize = i_floatArraySize, intArraySize = i_intArraySize, boolArraySize = i_boolArraySize)),
10982 _ )
10983 algorithm
10984 1 txt := Tpl.writeStr(txt, intString(i_floatArraySize));
10985 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + "));
10986 1 txt := Tpl.writeStr(txt, intString(i_intArraySize));
10987 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + "));
10988 1 txt := Tpl.writeStr(txt, intString(i_boolArraySize));
10989 then txt;
10990
10991 case ( txt,
10992 _,
10993 a_modelInfo )
10994 algorithm
10995 ✗ txt := CodegenCpp.getPreVarsCount(txt, a_modelInfo);
10996 then txt;
10997 end match;
10998 end fun_314;
10999
11000 public function numPreVarsHpcom
11001 input Tpl.Text txt;
11002 input SimCode.ModelInfo a_modelInfo;
11003 input Option<HpcOmSimCode.MemoryMap> a_hpcOmMemoryOpt;
11004
11005 output Tpl.Text out_txt;
11006 algorithm
11007 1 out_txt := fun_314(txt, a_hpcOmMemoryOpt, a_modelInfo);
11008 end numPreVarsHpcom;
11009
11010 protected function fun_316
11011 input Tpl.Text in_txt;
11012 input Option<HpcOmSimCode.MemoryMap> in_a_hpcOmMemoryOpt;
11013 input SimCode.ModelInfo in_a_modelInfo;
11014
11015 output Tpl.Text out_txt;
11016 algorithm
11017 out_txt :=
11018 match(in_txt, in_a_hpcOmMemoryOpt, in_a_modelInfo)
11019 local
11020 Tpl.Text txt;
11021 SimCode.ModelInfo a_modelInfo;
11022 Integer i_floatArraySize;
11023
11024 case ( txt,
11025 SOME(HpcOmSimCode.MEMORYMAP_ARRAY(floatArraySize = i_floatArraySize)),
11026 _ )
11027 algorithm
11028 1 txt := Tpl.writeStr(txt, intString(i_floatArraySize));
11029 then txt;
11030
11031 case ( txt,
11032 _,
11033 a_modelInfo )
11034 algorithm
11035 ✗ txt := CodegenCpp.numRealvars(txt, a_modelInfo);
11036 then txt;
11037 end match;
11038 end fun_316;
11039
11040 public function numRealvarsHpcom
11041 input Tpl.Text txt;
11042 input SimCode.ModelInfo a_modelInfo;
11043 input Option<HpcOmSimCode.MemoryMap> a_hpcOmMemoryOpt;
11044
11045 output Tpl.Text out_txt;
11046 algorithm
11047 1 out_txt := fun_316(txt, a_hpcOmMemoryOpt, a_modelInfo);
11048 end numRealvarsHpcom;
11049
11050 protected function fun_318
11051 input Tpl.Text in_txt;
11052 input Option<HpcOmSimCode.MemoryMap> in_a_hpcOmMemoryOpt;
11053 input SimCode.ModelInfo in_a_modelInfo;
11054
11055 output Tpl.Text out_txt;
11056 algorithm
11057 out_txt :=
11058 match(in_txt, in_a_hpcOmMemoryOpt, in_a_modelInfo)
11059 local
11060 Tpl.Text txt;
11061 SimCode.ModelInfo a_modelInfo;
11062 Integer i_intArraySize;
11063
11064 case ( txt,
11065 SOME(HpcOmSimCode.MEMORYMAP_ARRAY(intArraySize = i_intArraySize)),
11066 _ )
11067 algorithm
11068 1 txt := Tpl.writeStr(txt, intString(i_intArraySize));
11069 then txt;
11070
11071 case ( txt,
11072 _,
11073 a_modelInfo )
11074 algorithm
11075 ✗ txt := CodegenCpp.numIntvars(txt, a_modelInfo);
11076 then txt;
11077 end match;
11078 end fun_318;
11079
11080 public function numIntvarsHpcom
11081 input Tpl.Text txt;
11082 input SimCode.ModelInfo a_modelInfo;
11083 input Option<HpcOmSimCode.MemoryMap> a_hpcOmMemoryOpt;
11084
11085 output Tpl.Text out_txt;
11086 algorithm
11087 1 out_txt := fun_318(txt, a_hpcOmMemoryOpt, a_modelInfo);
11088 end numIntvarsHpcom;
11089
11090 protected function fun_320
11091 input Tpl.Text in_txt;
11092 input Option<HpcOmSimCode.MemoryMap> in_a_hpcOmMemoryOpt;
11093 input SimCode.ModelInfo in_a_modelInfo;
11094
11095 output Tpl.Text out_txt;
11096 algorithm
11097 out_txt :=
11098 match(in_txt, in_a_hpcOmMemoryOpt, in_a_modelInfo)
11099 local
11100 Tpl.Text txt;
11101 SimCode.ModelInfo a_modelInfo;
11102 Integer i_boolArraySize;
11103
11104 case ( txt,
11105 SOME(HpcOmSimCode.MEMORYMAP_ARRAY(boolArraySize = i_boolArraySize)),
11106 _ )
11107 algorithm
11108 1 txt := Tpl.writeStr(txt, intString(i_boolArraySize));
11109 then txt;
11110
11111 case ( txt,
11112 _,
11113 a_modelInfo )
11114 algorithm
11115 ✗ txt := CodegenCpp.numBoolvars(txt, a_modelInfo);
11116 then txt;
11117 end match;
11118 end fun_320;
11119
11120 public function numBoolvarsHpcom
11121 input Tpl.Text txt;
11122 input SimCode.ModelInfo a_modelInfo;
11123 input Option<HpcOmSimCode.MemoryMap> a_hpcOmMemoryOpt;
11124
11125 output Tpl.Text out_txt;
11126 algorithm
11127 1 out_txt := fun_320(txt, a_hpcOmMemoryOpt, a_modelInfo);
11128 end numBoolvarsHpcom;
11129
11130 protected function fun_322
11131 input Tpl.Text in_txt;
11132 input Option<HpcOmSimCode.MemoryMap> in_a_hpcOmMemoryOpt;
11133 input SimCode.ModelInfo in_a_modelInfo;
11134
11135 output Tpl.Text out_txt;
11136 algorithm
11137 out_txt :=
11138 match(in_txt, in_a_hpcOmMemoryOpt, in_a_modelInfo)
11139 local
11140 Tpl.Text txt;
11141 SimCode.ModelInfo a_modelInfo;
11142 Integer i_stringArraySize;
11143
11144 case ( txt,
11145 SOME(HpcOmSimCode.MEMORYMAP_ARRAY(stringArraySize = i_stringArraySize)),
11146 _ )
11147 algorithm
11148 ✗ txt := Tpl.writeStr(txt, intString(i_stringArraySize));
11149 then txt;
11150
11151 case ( txt,
11152 _,
11153 a_modelInfo )
11154 algorithm
11155 ✗ txt := CodegenCpp.numStringvars(txt, a_modelInfo);
11156 then txt;
11157 end match;
11158 end fun_322;
11159
11160 public function numStringvarsHpcom
11161 input Tpl.Text txt;
11162 input SimCode.ModelInfo a_modelInfo;
11163 input Option<HpcOmSimCode.MemoryMap> a_hpcOmMemoryOpt;
11164
11165 output Tpl.Text out_txt;
11166 algorithm
11167 ✗ out_txt := fun_322(txt, a_hpcOmMemoryOpt, a_modelInfo);
11168 end numStringvarsHpcom;
11169
11170 annotation(__OpenModelica_Interface="codegen_cpp_ext");
11171 end CodegenCppHpcom;
11172