Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 1749c2e

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Disable CC optimizations on linear systems
Linear systems are huge and typically just assign array elements to literal values. Huge functions take a long time to optimize for little gain (relative to the cost of running the linear solver). Belonging to [master]: - #1950
1 parent 8abed04 commit 1749c2e

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Compiler/Template/CodegenC.tpl

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,6 +2054,7 @@ template functionSetupLinearSystemsTemp(list<SimEqSystem> linearSystems, String
20542054
<% if profileAll() then 'SIM_PROF_ACC_EQ(<%ls.index%>);' %>
20552055
TRACE_POP
20562056
}
2057+
OMC_DISABLE_OPT
20572058
void initializeStaticLSData<%ls.index%>(void *inData, threadData_t *threadData, void *systemData)
20582059
{
20592060
DATA* data = (DATA*) inData;
@@ -2086,6 +2087,7 @@ template functionSetupLinearSystemsTemp(list<SimEqSystem> linearSystems, String
20862087
>> ;separator="\n")
20872088
<<
20882089
<%auxFunction%>
2090+
OMC_DISABLE_OPT
20892091
void setLinearMatrixA<%ls.index%>(void *inData, threadData_t *threadData, void *systemData)
20902092
{
20912093
const int equationIndexes[2] = {1,<%ls.index%>};
@@ -2094,6 +2096,7 @@ template functionSetupLinearSystemsTemp(list<SimEqSystem> linearSystems, String
20942096
<%varDecls%>
20952097
<%MatrixA%>
20962098
}
2099+
OMC_DISABLE_OPT
20972100
void setLinearVectorb<%ls.index%>(void *inData, threadData_t *threadData, void *systemData)
20982101
{
20992102
const int equationIndexes[2] = {1,<%ls.index%>};
@@ -2102,6 +2105,7 @@ template functionSetupLinearSystemsTemp(list<SimEqSystem> linearSystems, String
21022105
<%varDecls2%>
21032106
<%vectorb%>
21042107
}
2108+
OMC_DISABLE_OPT
21052109
void initializeStaticLSData<%ls.index%>(void *inData, threadData_t *threadData, void *systemData)
21062110
{
21072111
DATA* data = (DATA*) inData;
@@ -2184,6 +2188,7 @@ template functionSetupLinearSystemsTemp(list<SimEqSystem> linearSystems, String
21842188
<% if profileAll() then 'SIM_PROF_ACC_EQ(<%ls.index%>);' %>
21852189
TRACE_POP
21862190
}
2191+
OMC_DISABLE_OPT
21872192
void initializeStaticLSData<%ls.index%>(void *inData, threadData_t *threadData, void *systemData)
21882193
{
21892194
DATA* data = (DATA*) inData;
@@ -2210,6 +2215,7 @@ template functionSetupLinearSystemsTemp(list<SimEqSystem> linearSystems, String
22102215
<% if profileAll() then 'SIM_PROF_ACC_EQ(<%at.index%>);' %>
22112216
TRACE_POP
22122217
}
2218+
OMC_DISABLE_OPT
22132219
void initializeStaticLSData<%at.index%>(void *inData, threadData_t *threadData, void *systemData)
22142220
{
22152221
DATA* data = (DATA*) inData;
@@ -2266,6 +2272,7 @@ template functionSetupLinearSystemsTemp(list<SimEqSystem> linearSystems, String
22662272

22672273
<<
22682274
<%auxFunction%>
2275+
OMC_DISABLE_OPT
22692276
void setLinearMatrixA<%ls.index%>(void *inData, void *systemData)
22702277
{
22712278
const int equationIndexes[2] = {1,<%ls.index%>};
@@ -2274,6 +2281,7 @@ template functionSetupLinearSystemsTemp(list<SimEqSystem> linearSystems, String
22742281
<%varDecls%>
22752282
<%MatrixA%>
22762283
}
2284+
OMC_DISABLE_OPT
22772285
void setLinearVectorb<%ls.index%>(void *inData, void *systemData)
22782286
{
22792287
const int equationIndexes[2] = {1,<%ls.index%>};
@@ -2282,6 +2290,7 @@ template functionSetupLinearSystemsTemp(list<SimEqSystem> linearSystems, String
22822290
<%varDecls2%>
22832291
<%vectorb%>
22842292
}
2293+
OMC_DISABLE_OPT
22852294
void initializeStaticLSData<%ls.index%>(void *inData, threadData_t *threadData, void *systemData)
22862295
{
22872296
DATA* data = (DATA*) inData;
@@ -2291,6 +2300,7 @@ template functionSetupLinearSystemsTemp(list<SimEqSystem> linearSystems, String
22912300
}
22922301

22932302
<%auxFunction2%>
2303+
OMC_DISABLE_OPT
22942304
void setLinearMatrixA<%at.index%>(void *inData, void *systemData)
22952305
{
22962306
const int equationIndexes[2] = {1,<%at.index%>};
@@ -2299,6 +2309,7 @@ template functionSetupLinearSystemsTemp(list<SimEqSystem> linearSystems, String
22992309
<%varDecls3%>
23002310
<%MatrixA2%>
23012311
}
2312+
OMC_DISABLE_OPT
23022313
void setLinearVectorb<%at.index%>(void *inData, void *systemData)
23032314
{
23042315
const int equationIndexes[2] = {1,<%at.index%>};
@@ -2307,6 +2318,7 @@ template functionSetupLinearSystemsTemp(list<SimEqSystem> linearSystems, String
23072318
<%varDecls4%>
23082319
<%vectorb2%>
23092320
}
2321+
OMC_DISABLE_OPT
23102322
void initializeStaticLSData<%at.index%>(void *inData, threadData_t *threadData, void *systemData)
23112323
{
23122324
DATA* data = (DATA*) inData;
@@ -3798,6 +3810,7 @@ template functionXXX_systems(list<list<SimEqSystem>> eqs, String name, Text &loo
37983810
/* Text before the function head */
37993811
<<
38003812
<%funcs%>
3813+
OMC_DISABLE_OPT
38013814
static void (*function<%name%>_systems[<%nFuncs%>])(DATA *, threadData_t *threadData) = {
38023815
<%funcNames%>
38033816
};
@@ -4123,7 +4136,7 @@ template functionDAE(list<SimEqSystem> allEquationsPlusWhen, String modelNamePre
41234136
<%&eqfuncs%>
41244137
41254138
<%eqArrayDecl%>
4126-
4139+
OMC_DISABLE_OPT
41274140
int <%symbolName(modelNamePrefix,"functionDAE")%>(DATA *data, threadData_t *threadData)
41284141
{
41294142
TRACE_PUSH
@@ -4769,6 +4782,7 @@ template equation_arrayFormat(SimEqSystem eq, String name, Context context, Inte
47694782
let &tmp = buffer ""
47704783
let &varD = buffer ""
47714784
let &tempeqns = buffer ""
4785+
let &OMC_DISABLE_OPT = buffer ""
47724786
let() = System.tmpTickResetIndex(0,1) /* Boxed array indices */
47734787
let disc = match context
47744788
case SIMULATION_CONTEXT(genDiscrete=true) then 1
@@ -4786,7 +4800,9 @@ template equation_arrayFormat(SimEqSystem eq, String name, Context context, Inte
47864800
case e as SES_INVERSE_ALGORITHM(__)
47874801
then equationAlgorithm(e, context, &varD, &tempeqns)
47884802
case e as SES_LINEAR(__)
4789-
then equationLinear(e, context, &varD)
4803+
then
4804+
let &OMC_DISABLE_OPT += 'OMC_DISABLE_OPT<%\n%>'
4805+
equationLinear(e, context, &varD)
47904806
// no dynamic tearing
47914807
case e as SES_NONLINEAR(nlSystem=nls as NONLINEARSYSTEM(__), alternativeTearing=NONE()) then
47924808
let &tempeqns += (nls.eqs |> eq => 'void <%symbolName(modelNamePrefix,"eqFunction")%>_<%equationIndex(eq)%>(DATA*,threadData_t*);' ; separator = "\n")
@@ -4815,7 +4831,7 @@ template equation_arrayFormat(SimEqSystem eq, String name, Context context, Inte
48154831
/*
48164832
<%dumpEqs(fill(eq,1))%>
48174833
*/
4818-
void <%symbolName(modelNamePrefix,"eqFunction")%>_<%ix%>(DATA *data, threadData_t *threadData)
4834+
<%OMC_DISABLE_OPT%>void <%symbolName(modelNamePrefix,"eqFunction")%>_<%ix%>(DATA *data, threadData_t *threadData)
48194835
{
48204836
TRACE_PUSH
48214837
const int equationIndexes[2] = {1,<%ix%>};
@@ -4852,7 +4868,7 @@ template equation_impl2(Integer clockIndex, SimEqSystem eq, Context context, Str
48524868
This template should not be used for a SES_RESIDUAL.
48534869
Residual equations are handled differently."
48544870
::=
4855-
let OMC_NO_OPT = if noOpt then 'OMC_DISABLE_OPT<%\n%>'
4871+
let OMC_NO_OPT = if noOpt then 'OMC_DISABLE_OPT<%\n%>' else (match eq case SES_LINEAR(__) then 'OMC_DISABLE_OPT<%\n%>')
48564872
match eq
48574873
case e as SES_ALGORITHM(statements={})
48584874
then ""

0 commit comments

Comments
 (0)