Skip to content

Commit 09e106c

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Change the default simulation opt. level to -Os
Testing has shown that the performance of clang seems to be good enough to enable -Os by default now. It's still slightly slower for most models, especially small ones. But it should be a good default for larger models. The optimization level for simulations is now set by Susan, and setCFlags will override this. This makes it possible for dynload to use a different optimization level unless set by setCFlags. The disadvantage is that getCFlags does not show what optimization level the simulations will use (unless explicitly set by setCFlags), and this will be different for C++ and C. Note that this is how the MinGW version of OM worked before (except the default for simulations was -O0). OMEdit also has an option to change optimization level, so it should be reasonably convenient for the user to change this to -O0 if desired. Disabled -march=native as a default flag since it is annoying for FMUs. Belonging to [master]: - OpenModelica/OMCompiler#1869
1 parent 46dca42 commit 09e106c

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

Compiler/Script/CevalScriptBackend.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3288,7 +3288,7 @@ protected
32883288
dquote = if isWindows then "\"" else "'";
32893289
algorithm
32903290
CC := System.getCCompiler();
3291-
CFLAGS := System.stringReplace(System.getCFlags(),"${MODELICAUSERCFLAGS}","");
3291+
CFLAGS := "-Os "+System.stringReplace(System.getCFlags(),"${MODELICAUSERCFLAGS}","");
32923292
LDFLAGS := ("-L"+dquote+Settings.getInstallationDirectoryPath()+"/lib/"+System.getTriple()+"/omc"+dquote+" "+
32933293
"-Wl,-rpath,"+dquote+Settings.getInstallationDirectoryPath()+"/lib/"+System.getTriple()+"/omc"+dquote+" "+
32943294
System.getLDFlags()+" ");

Compiler/Template/CodegenC.tpl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5707,8 +5707,6 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
57075707
<<
57085708
# Makefile generated by OpenModelica
57095709

5710-
# Simulations use -O0 by default
5711-
SIM_OR_DYNLOAD_OPT_LEVEL=
57125710
MODELICAUSERCFLAGS=
57135711
CC=cl
57145712
CXX=cl
@@ -5780,7 +5778,7 @@ case SIMCODE(modelInfo=MODELINFO(varInfo=varInfo as VARINFO(__)), delayedExps=DE
57805778
EXEEXT=<%makefileParams.exeext%>
57815779
DLLEXT=<%makefileParams.dllext%>
57825780
CFLAGS_BASED_ON_INIT_FILE=<%extraCflags%>
5783-
DEBUG_FLAGS=<% if boolOr(acceptMetaModelicaGrammar(), Flags.isSet(Flags.GEN_DEBUG_SYMBOLS)) then "-O0 -g"%>
5781+
DEBUG_FLAGS=<% if boolOr(getRunningTestsuite(), boolOr(acceptMetaModelicaGrammar(), Flags.isSet(Flags.GEN_DEBUG_SYMBOLS))) then "-O0" else "-Os"%><% if Flags.isSet(Flags.GEN_DEBUG_SYMBOLS) then " -g" %>
57845782
CFLAGS=$(CFLAGS_BASED_ON_INIT_FILE) $(DEBUG_FLAGS) <%makefileParams.cflags%> <%match sopt case SOME(s as SIMULATION_SETTINGS(__)) then '<%s.cflags%> ' /* From the simulate() command */%>
57855783
<% if stringEq(Config.simCodeTarget(),"JavaScript") then 'OMC_EMCC_PRE_JS=<%makefileParams.omhome%>/lib/<%getTriple()%>/omc/emcc/pre.js<%\n%>'
57865784
%>CPPFLAGS=<%makefileParams.includes ; separator=" "%> -I"<%makefileParams.omhome%>/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME<% if stringEq(Config.simCodeTarget(),"JavaScript") then " -DOMC_EMCC"%><% if Flags.isSet(Flags.OMC_RELOCATABLE_FUNCTIONS) then " -DOMC_GENERATE_RELOCATABLE_CODE"%> -DOMC_MODEL_PREFIX=<%modelNamePrefix(simCode)%> -DOMC_NUM_MIXED_SYSTEMS=<%varInfo.numMixedSystems%> -DOMC_NUM_LINEAR_SYSTEMS=<%varInfo.numLinearSystems%> -DOMC_NUM_NONLINEAR_SYSTEMS=<%varInfo.numNonLinearSystems%> -DOMC_NDELAY_EXPRESSIONS=<%maxDelayedIndex%> -DOMC_NVAR_STRING=<%varInfo.numStringAlgVars%>

Compiler/runtime/omc_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@
115115
* Visual Studio then use the SSE instructions,
116116
* not the normal i387 FPU
117117
*/
118-
#define DEFAULT_CFLAGS "${SIM_OR_DYNLOAD_OPT_LEVEL} -falign-functions -msse2 -mfpmath=sse ${MODELICAUSERCFLAGS}"
118+
#define DEFAULT_CFLAGS "-falign-functions -msse2 -mfpmath=sse ${MODELICAUSERCFLAGS}"
119119
#else
120-
#define DEFAULT_CFLAGS "${SIM_OR_DYNLOAD_OPT_LEVEL} -falign-functions ${MODELICAUSERCFLAGS}"
120+
#define DEFAULT_CFLAGS "-falign-functions ${MODELICAUSERCFLAGS}"
121121
#endif
122122
#if defined(__x86_64__)
123123
/* -fPIC needed on x86_64! */

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ if test -z "$RUNTIMECFLAGS"; then
432432
AC_TRY_LINK([], [return 0;], [AC_MSG_RESULT($CC ok);],[AC_MSG_ERROR($CC failed)])
433433
CFLAGS="$FPIC"
434434
AC_MSG_CHECKING([runtime compiler CFLAGS])
435-
for flag in -O0 -falign-functions -march=native -mfpmath=sse; do
435+
for flag in -falign-functions -mfpmath=sse; do
436436
RUNTIMECFLAGS="$CFLAGS"
437437
CFLAGS="$RUNTIMECFLAGS $flag -Werror"
438438
AC_TRY_LINK([], [return 0;], [CFLAGS="$RUNTIMECFLAGS $flag"],[CFLAGS="$RUNTIMECFLAGS"])

0 commit comments

Comments
 (0)