Skip to content

Commit

Permalink
- Use -O3 -falign-functions for simulations (our users should not run…
Browse files Browse the repository at this point in the history
… LARGE simulations with -O0...)

- Use -O0 -falign-functions for dynamically loaded functions (we generally only execute this code once)
- falign-functions is needed in order to make garbage collection work


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8071 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Mar 3, 2011
1 parent 2ccc988 commit e0f32bf
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Compiler/runtime/config.h
Expand Up @@ -63,9 +63,9 @@
* Visual Studio then use the SSE instructions,
* not the normal i387 FPU
*/
#define DEFAULT_CFLAGS "-msse2 -mfpmath=sse ${MODELICAUSERCFLAGS}"
#define DEFAULT_CFLAGS "${SIM_OR_DYNLOAD_OPT_LEVEL} -falign-functions -msse2 -mfpmath=sse ${MODELICAUSERCFLAGS}"
#else
#define DEFAULT_CFLAGS "${MODELICAUSERCFLAGS}"
#define DEFAULT_CFLAGS "${SIM_OR_DYNLOAD_OPT_LEVEL} -falign-functions ${MODELICAUSERCFLAGS}"
#endif
#if defined(__x86_64__)
/* -fPIC needed on x86_64! */
Expand Down
4 changes: 2 additions & 2 deletions Compiler/runtime/config.unix.h.in
Expand Up @@ -18,10 +18,10 @@
#endif

#ifdef __APPLE_CC__
#define DEFAULT_CFLAGS "-msse2 -mfpmath=sse ${MODELICAUSERCFLAGS}"
#define DEFAULT_CFLAGS "${SIM_OR_DYNLOAD_OPT_LEVEL} -falign-functions -msse2 -mfpmath=sse ${MODELICAUSERCFLAGS}"
#define CONFIG_OS "OSX"
#else
#define DEFAULT_CFLAGS "-march=native -mfpmath=sse ${MODELICAUSERCFLAGS}"
#define DEFAULT_CFLAGS "${SIM_OR_DYNLOAD_OPT_LEVEL} -falign-functions -march=native -mfpmath=sse ${MODELICAUSERCFLAGS}"
#define CONFIG_OS "linux"
#endif

Expand Down
5 changes: 5 additions & 0 deletions Compiler/susan_codegen/SimCode/SimCodeC.tpl
Expand Up @@ -1706,6 +1706,7 @@ template functionDAE( list<SimEqSystem> allEquationsPlusWhen,

let reinit = (whenClauses |> when hasindex i0 =>


genreinits(when, &varDecls,i0)
;separator="\n")
<<
Expand Down Expand Up @@ -2493,6 +2494,8 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__)) then
<<
# Makefile generated by OpenModelica

# Simulations use -O3 by default
SIM_OR_DYNLOAD_OPT_LEVEL=-O3
CC=<%makefileParams.ccompiler%>
CXX=<%makefileParams.cxxcompiler%>
LINK=<%makefileParams.linker%>
Expand Down Expand Up @@ -2651,6 +2654,8 @@ case FUNCTIONCODE(makefileParams=MAKEFILE_PARAMS(__)) then
<<
# Makefile generated by OpenModelica

# Dynamic loading uses -O0 by default
SIM_OR_DYNLOAD_OPT_LEVEL=-O0
CC=<%makefileParams.ccompiler%>
CXX=<%makefileParams.cxxcompiler%>
LINK=<%makefileParams.linker%>
Expand Down
7 changes: 5 additions & 2 deletions c_runtime/Makefile.common
Expand Up @@ -15,8 +15,8 @@ ddasrt.o dlinpk.o enorm.o hybrd1.o nelmead.o qform.o r1updt.o \
biglag.o ddassl.o dogleg.o fdjac1.o hybrj.o newuoa.o qrfac.o trsapp.o \
daux.o dlamch.o dpmpar.o hybrd.o lsame.o newuob.o r1mpyq.o update.o division.o\
java_interface.o meta_modelica.o meta_modelica_builtin.o meta_modelica_real.o \
meta_modelica_string_lit.o rtclock.o ModelicaUtilities.o simulation_varinfo.o \
read_matlab4.o \
meta_modelica_string_lit.o meta_modelica_catch.o rtclock.o ModelicaUtilities.o \
simulation_varinfo.o read_matlab4.o \
$(EXTRA_OBJS)

SIMOBJS = $(FOBJS) simulation_runtime.o simulation_init.o simulation_input.o \
Expand Down Expand Up @@ -120,6 +120,9 @@ libf2c/libf2c.a :
cd libf2c && $(MAKE) -f $(LIBF2CMAKEFILE)
ranlib $@

meta_modelica_catch.o : meta_modelica_catch.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c -g $<

install: libc_runtime.a libsim.a libf2c/libf2c.a interactive/libinteractive.a $(LIBSENDDATA) omdevinstall ModelicaExternalC/libModelicaExternalC.a
cp $(HFILES) $(builddir_inc)/
cp $(LIBS) $(builddir_lib)/
Expand Down
7 changes: 0 additions & 7 deletions c_runtime/meta_modelica.c
Expand Up @@ -509,10 +509,3 @@ void* boxptr_valueHashMod(void *p, void *mod)
{
return mmc_mk_icon(mmc_prim_hash(p) % (unsigned long) mmc_unbox_integer(mod));
}

void mmc_catch_dummy_fn()
{
#line 1 "Catch.omc"
return;
}
/* Keep mmc_catch_dummy_fn() last in the file since it uses #line */
2 changes: 1 addition & 1 deletion c_runtime/meta_modelica.h
Expand Up @@ -379,14 +379,14 @@ typedef base_array_t mmc__unbox__array_rettype;

#include <setjmp.h>

void mmc_catch_dummy_fn();
#if 1
/* Use something like this if needed...
#define MMC_JMP_BUF_SIZE 8192
extern jmp_buf mmc_jumper[MMC_JMP_BUF_SIZE];
extern int jmp_buf_index;
*/
extern jmp_buf *mmc_jumper;
void mmc_catch_dummy_fn();
#define MMC_TRY() {jmp_buf new_mmc_jumper, *old_jumper; old_jumper = mmc_jumper; mmc_jumper = &new_mmc_jumper; if (setjmp(new_mmc_jumper) == 0) {
#define MMC_CATCH() } mmc_jumper = old_jumper; mmc_catch_dummy_fn();}
#define MMC_THROW() longjmp(*mmc_jumper,1)
Expand Down
36 changes: 36 additions & 0 deletions c_runtime/meta_modelica_catch.c
@@ -0,0 +1,36 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Linköping University,
* Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
* AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
* ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from Linköping University, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
* OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/

void mmc_catch_dummy_fn()
{
#line 1 "Catch.omc"
return;
}

0 comments on commit e0f32bf

Please sign in to comment.