Skip to content

Commit

Permalink
- Inline some more MetaModelica functions
Browse files Browse the repository at this point in the history
- OMCC: Combine the Absyn.INFO lines/columns into the OMCCTypes.TOKEN directly (1 fewer allocation)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19466 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Mar 6, 2014
1 parent fcd56fe commit 31afcca
Show file tree
Hide file tree
Showing 15 changed files with 641 additions and 395 deletions.
13 changes: 1 addition & 12 deletions Compiler/Template/CodegenC.tpl
Expand Up @@ -9829,18 +9829,7 @@ end daeExpMetarecordcall;
template daeExpMetaHelperBoxStart(Integer numVariables)
"Helper to determine how mmc_mk_box should be called."
::=
match numVariables
case 0
case 1
case 2
case 3
case 4
case 5
case 6
case 7
case 8
case 9 then '<%numVariables%>('
else '(<%numVariables%>, '
if intGt(numVariables,20) then '(<%numVariables%>, ' else '<%numVariables%>('
end daeExpMetaHelperBoxStart;

template outDecl(String ty, Text &varDecls /*BUFP*/)
Expand Down
16 changes: 9 additions & 7 deletions SimulationRuntime/c/Makefile.common
Expand Up @@ -18,6 +18,7 @@ RUNTIME_HEADERS = $(LIBF2CHEADER) \
./math-support/blaswrap.h \
./openmodelica_func.h \
./openmodelica.h \
./openmodelica_types.h \
./simulation_data.h \
./ModelicaUtilities.h

Expand Down Expand Up @@ -49,6 +50,7 @@ RUNTIMESIMSOLVER_HEADERS = ./simulation/solver/delay.h \
RUNTIMEMETA_HEADERS = ./meta/meta_modelica_builtin_boxptr.h \
./meta/meta_modelica_builtin.h \
./meta/meta_modelica.h \
./meta/meta_modelica_mk_box.h \
./meta/meta_modelica_real.h \
./meta/meta_modelica_segv.h \
./meta/meta_modelica_string_lit.h
Expand Down Expand Up @@ -150,32 +152,32 @@ libOpenModelicaFMIRuntimeC.dylib: $(FMIOBJSPATH) $(builddir_lib)/libf2c.a
$(CC) -shared -o $@ $(FMIOBJSPATH) $(LDFLAGS_SIM) -undefined dynamic_lookup -install_name '@rpath/$@'

$(METAOBJSPATH):%$(OBJ_EXT): %.c $(METAHFILESPATH) $(COMMON_HEADERS)
$(CC) -c $(CFLAGS) -o $@ $< -I$(METAPATH) -I$(UTILPATH)
$(CC) -c -I$(METAPATH) -I$(UTILPATH) $(CFLAGS) -o $@ $<

meta/meta_modelica_catch$(OBJ_EXT): meta/meta_modelica_catch.c
$(CC) -c $(CFLAGS) -o $@ $< -g

$(UTILOBJSPATH):%$(OBJ_EXT): %.c $(UTILHFILESPATH) $(COMMON_HEADERS)
$(CC) -c $(CFLAGS) -o $@ $< -I$(UTILPATH) -I$(METAPATH)
$(CC) -c -I$(UTILPATH) -I$(METAPATH) $(CFLAGS) -o $@ $<

$(MATHOBJSPATH):%$(OBJ_EXT): %.c $(MATHHFILESPATH) $(COMMON_HEADERS)
$(CC) -c $(CFLAGS) $(FPMATHFORTRAN) -o $@ $< -I$(MATHPATH) -I$(UTILPATH)
$(CC) -c -I$(MATHPATH) -I$(UTILPATH) $(CFLAGS) $(FPMATHFORTRAN) -o $@ $<

$(SOLVEROBJSPATH):%$(OBJ_EXT): %.c $(SOLVERHFILESPATH) $(RESULTSHFILESPATH) $(INITIALIZATIONHFILESPATH) $(OPTIMIZATIONHFILESPATH) $(COMMON_HEADERS)
$(CC) -c $(CFLAGS) -o $@ $< -I$(SOLVERPATH) -I$(INITIALIZATIONPATH) -I$(OPTIMIZATIONPATH) -I$(RESULTSPATH) -I$(SIMPATH) -I$(MATHPATH) -I$(UTILPATH)
$(CC) -c -I$(SOLVERPATH) -I$(INITIALIZATIONPATH) -I$(OPTIMIZATIONPATH) -I$(RESULTSPATH) -I$(SIMPATH) -I$(MATHPATH) -I$(UTILPATH) $(CFLAGS) -o $@ $<

$(INITIALIZATIONOBJSPATH):%$(OBJ_EXT): %.c $(SOLVERHFILESPATH) $(INITIALIZATIONHFILESPATH) $(COMMON_HEADERS)
$(CC) -c $(CFLAGS) -o $@ $< -I$(SOLVERPATH) -I$(INITIALIZATIONPATH) -I$(SIMPATH) -I$(MATHPATH) -I$(UTILPATH)
$(CC) -c -I$(SOLVERPATH) -I$(INITIALIZATIONPATH) -I$(SIMPATH) -I$(MATHPATH) -I$(UTILPATH) $(CFLAGS) -o $@ $<

$(RESULTSOBJSPATH):%$(OBJ_EXT): %.cpp $(RESULTSFILESPATH) $(COMMON_HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<

$(SIMOBJSPATH):%$(OBJ_EXT): %.cpp linearization/linearize.cpp $(SIMHFILESPATH) $(COMMON_HEADERS)
$(CXX) -c $(CXXFLAGS) -o $@ $< -I$(SIMPATH) -I$(UTILPATH) -I$(MATHPATH) -I$(RESULTSPATH) -I$(SOLVERPATH) -I$(INITIALIZATIONPATH) -Ilinearization/
$(CXX) -c -I$(SIMPATH) -I$(UTILPATH) -I$(MATHPATH) -I$(RESULTSPATH) -I$(SOLVERPATH) -I$(INITIALIZATIONPATH) -Ilinearization/ $(CXXFLAGS) -o $@ $<

$(SIMOBJSPATHC):%$(OBJ_EXT): %.c $(SIMHFILESPATH) $(COMMON_HEADERS)
@echo Deps: $(SIMHFILESPATH) $(COMMON_HEADERS)
$(CC) -c $(CFLAGS) -o $@ $< -I$(SIMPATH) -I$(UTILPATH) -I$(MATHPATH) -I$(RESULTSPATH) -I$(SOLVERPATH) -I$(INITIALIZATIONPATH) -Ilinearization/
$(CC) -c -I$(SIMPATH) -I$(UTILPATH) -I$(MATHPATH) -I$(RESULTSPATH) -I$(SOLVERPATH) -I$(INITIALIZATIONPATH) -Ilinearization/ $(CFLAGS) -o $@ $<

$(OPTIMIZATIONOBJSPATH):%$(OBJ_EXT): %.c $(OPTIMIZATIONHFILESPATH) $(COMMON_HEADERS)
$(CC) -c $(CFLAGS) -o $@ $<
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/meta/gc/common.h
Expand Up @@ -36,7 +36,7 @@
extern "C" {
#endif

#include "util/modelica.h"
#include "openmodelica_types.h"

/***********************************************************************/
/***********************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/meta/gc/generational.h
Expand Up @@ -46,7 +46,7 @@
extern "C" {
#endif

#include "util/modelica.h"
#include "openmodelica_types.h"
#include "mmc_gc.h"

/* the allocated from C region */
Expand Down
6 changes: 0 additions & 6 deletions SimulationRuntime/c/meta/gc/marksweep.c
Expand Up @@ -591,12 +591,6 @@ void *mmc_alloc_words(unsigned nwords)
static mmc_GC_state_type x_mmc_GC_state;
mmc_GC_state_type *mmc_GC_state = &x_mmc_GC_state;

/* primary allocation routine for MetaModelica */
void *mmc_alloc_words(unsigned nwords)
{
return GC_MALLOC(nwords * sizeof(void*));
}

#else /* NO GC */

static mmc_GC_state_type x_mmc_GC_state;
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/meta/gc/marksweep.h
Expand Up @@ -67,7 +67,7 @@ extern "C"
{
#endif

#include "util/modelica.h"
#include "openmodelica_types.h"

struct mmc_GC_mas_state_type /* the structure of GC state */
{
Expand Down
17 changes: 13 additions & 4 deletions SimulationRuntime/c/meta/gc/mmc_gc.h
Expand Up @@ -60,7 +60,6 @@
extern "C" {
#endif

#include "util/modelica.h"
#include "common.h"
#include "roots.h"
#include "generational.h"
Expand All @@ -84,11 +83,14 @@ extern mmc_GC_state_type* mmc_GC_state;

/* checks if the pointer is in range */
int is_in_range(modelica_metatype p, modelica_metatype start, size_t bytes);
/* primary allocation routines for MetaModelica */
void *mmc_alloc_words(unsigned nwords);

#if defined(_MMC_GC_)

#include "util/modelica.h"

/* primary allocation routines for MetaModelica */
void *mmc_alloc_words(unsigned nwords);

DLLExport void mmc_GC_set_state(mmc_GC_state_type* state);
/* initialization of MetaModelica GC */
int mmc_GC_init(mmc_GC_settings_type settings);
Expand Down Expand Up @@ -132,10 +134,17 @@ int GC_pthread_join(pthread_t, void **);
#define mmc_GC_collect(local_GC_state)

/* Atomic pointers only work correctly if we use untagged pointers */
#define mmc_alloc_words_atomic(nwords) GC_MALLOC_ATOMIC((nwords) * sizeof(void*))
static inline void* mmc_alloc_words_atomic(unsigned int nwords) {
return GC_MALLOC_ATOMIC((nwords) * sizeof(void*));
}
static inline void* mmc_alloc_words(unsigned int nwords) {
return GC_MALLOC((nwords) * sizeof(void*));
}

#else /* NO_GC */

/* primary allocation routines for MetaModelica */
void *mmc_alloc_words(unsigned nwords);
#define mmc_GC_init(settings)
#define mmc_GC_init_default(void)
#define mmc_GC_clear(void)
Expand Down

0 comments on commit 31afcca

Please sign in to comment.