From 549fe860907840122ab940091842cd72c547c17e Mon Sep 17 00:00:00 2001 From: mflehmig Date: Fri, 5 Jul 2019 12:49:22 +0200 Subject: [PATCH] Add support for parallel Jacobian evaluation - Parallel Jacobian evaluation will be encapsulated by USE_PARJAC defines. - Enable parallel Jacobian evaluation passing --enable-parjac to OMCompiler/configure, which will check for OpenMP support and add corresponding Flags to simulation makefile and c runtime makefile. --- OMCompiler/SimulationRuntime/c/Makefile.in | 11 ++++++++++ OMCompiler/configure.ac | 24 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/OMCompiler/SimulationRuntime/c/Makefile.in b/OMCompiler/SimulationRuntime/c/Makefile.in index 774c9df222a..5cca7489fb5 100644 --- a/OMCompiler/SimulationRuntime/c/Makefile.in +++ b/OMCompiler/SimulationRuntime/c/Makefile.in @@ -14,6 +14,10 @@ CC = @CC@ CXX = @CXX@ CONFIG_CPPFLAGS = @CPPFLAGS@ CXXFLAGS = @CXXFLAGS@ +OMPCC = @CC@ @OMPCFLAGS@ +OMPCFLAGS=@OMPCFLAGS@ + + ifeq ($(OMC_MINIMAL_RUNTIME),) IPOPT_CFLAGS=@IPOPT_CFLAGS@ else @@ -31,6 +35,13 @@ LDFLAGS=-L$(OMBUILDDIR)/lib/@host_short@/omc @RT_LDFLAGS@ LDFLAGS_SIM=-L$(OMBUILDDIR)/lib/@host_short@/omc @RT_LDFLAGS_SIM@ endif +USE_PARJAC = @USE_PARJAC@ +ifeq (@USE_PARJAC@,yes) + CONFIG_CFLAGS+=@OMPCFLAGS@ -DUSE_PARJAC + LDFLAGS+=@OMPCFLAGS@ +else + OMPCFLAGS= +endif defaultMakefileTarget = Makefile LIBMAKEFILE = Makefile diff --git a/OMCompiler/configure.ac b/OMCompiler/configure.ac index dbd52b10420..d3dcdd77da2 100644 --- a/OMCompiler/configure.ac +++ b/OMCompiler/configure.ac @@ -468,6 +468,30 @@ AC_MSG_RESULT([$RUNTIMECFLAGS]) CC="$CC_OLD" CFLAGS="$CFLAGS_OLD" +dnl Parallel Jacobian evaluation in C runtime +dnl OpenMP needs to be available +dnl If enabled, model needs to be compiled using -DUSE_PARJAC (add to RUNTIMECFLAGS) +AC_ARG_ENABLE( + [parjac], + AS_HELP_STRING([--enable-parjac], + [enable parallel symbolical Jacobian evaluation in C runtime]), + [want_parjac=$enableval], + [want_parjac=no] +) +USE_PARJAC="no" +if test x$want_parjac = xyes; then + AC_MSG_CHECKING([for parallel Jacobian evaluation]) + if test "$CONFIG_WITH_OPENMP=1"; then + USE_PARJAC="yes" + RUNTIMECFLAGS="$RUNTIMECFLAGS $OMPCFLAGS -DUSE_PARJAC" + else + AC_MSG_WARN([========= OpenMP is not available, not define par. jac]) + fi +fi +AC_MSG_RESULT([$USE_PARJAC]) +AC_SUBST(USE_PARJAC) + + LIBS="" AC_SEARCH_LIBS(dlopen,dl) LIBDL="$LIBS"