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

Commit

Permalink
Add support for clang (3.7+) OpenMP
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Oct 26, 2016
1 parent 295a040 commit 5515de8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Compiler/runtime/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GRAPHINCLUDE=../../3rdParty/metis-5.1.0/include
GRAPHSTREAMINCLUDE = ../../3rdParty/graphstream/gs-netstream/c++/src/
CJSONINCLUDE = ../../3rdParty/cJSON
CFLAGS = @CFLAGS@ $(USE_CORBA)
OMPCC = @OMPCC@
OMPCC = @CC@ @OMPCFLAGS@
OMBUILDDIR = @OMBUILDDIR@
OMC=@OMC@

Expand Down
2 changes: 1 addition & 1 deletion Compiler/runtime/config.unix.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#define DEFAULT_CC "@RUNTIMECC@"
#define DEFAULT_CXX "@CXX@"
#define DEFAULT_OMPCC "@OMPCC@"
#define DEFAULT_OMPCC "@CC@ @OMPCFLAGS@"
#define DEFAULT_MAKE "@MAKE@"
#define DEFAULT_TRIPLE "@host_short@"

Expand Down
3 changes: 2 additions & 1 deletion SimulationRuntime/cpp/Makefile.env.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
OMBUILDDIR=@OMBUILDDIR@
LIBINSTALLEXT=lib/@host_short@/omc/cpp
LIBINSTALLEXT=lib/@host_short@/omc/cpp
OMPCFLAGS=@OMPCFLAGS@
2 changes: 1 addition & 1 deletion SimulationRuntime/cpp/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ BUILDTYPE=@CMAKE_BUILDTYPE@
CMAKE_COMMANDS=@CMAKE_COMMANDS@
CMAKE_ARGS=$(patsubst CMAKE_%, -D%, $(filter CMAKE_%, $(MAKEFLAGS)))

CMAKE_FLAGS=-DCMAKE_BUILD_TYPE=$(BUILDTYPE) $(BOOST_ROOT_COMMAND) $(BOOST_STATIC_LINKING_COMMAND) $(CPP_03_COMMAND) $(BOOST_REALPATHS_COMMAND) $(PARALLEL_OUTPUT_COMMAND) $(RUNTIME_PROFILING_COMMAND) $(SCOREP_COMMAND) $(FMU_SUNDIALS_COMMAND) $(LOGGER_COMMAND) -DCMAKE_BUILD_TYPE=$(BUILDTYPE) -DCMAKE_INSTALL_PREFIX:PATH="$(OMBUILDDIR)" -DLIBINSTALLEXT=$(LIBINSTALLEXT) -DSCOREP_HOME:STRING="$(SCOREP_HOME)" $(BUILD_DOC_COMMAND) $(CMAKE_ARGS)
CMAKE_FLAGS=-DCMAKE_BUILD_TYPE=$(BUILDTYPE) $(BOOST_ROOT_COMMAND) $(BOOST_STATIC_LINKING_COMMAND) $(CPP_03_COMMAND) $(BOOST_REALPATHS_COMMAND) $(PARALLEL_OUTPUT_COMMAND) $(RUNTIME_PROFILING_COMMAND) $(SCOREP_COMMAND) $(FMU_SUNDIALS_COMMAND) $(LOGGER_COMMAND) -DCMAKE_BUILD_TYPE=$(BUILDTYPE) -DCMAKE_INSTALL_PREFIX:PATH="$(OMBUILDDIR)" -DLIBINSTALLEXT=$(LIBINSTALLEXT) -DSCOREP_HOME:STRING="$(SCOREP_HOME)" $(BUILD_DOC_COMMAND) $(CMAKE_ARGS) -DOpenMP_CXX_FLAGS="$(OMPCFLAGS)"

runtimeCpp:
$(foreach PLATFORM, $(PLATFORMS), \
Expand Down
61 changes: 27 additions & 34 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ AC_SUBST(OMSHELL_TERMINAL)
AC_SUBST(MODELICA_SPEC_PLATFORM)
AC_SUBST(OPENMODELICA_SPEC_PLATFORM)
AC_SUBST(OMC_LIBS)
AC_SUBST(OMPCC)
AC_SUBST(OMPCFLAGS)
AC_SUBST(RUNTIMECC)
AC_SUBST(RUNTIMECFLAGS)
AC_SUBST(MAKE)
Expand Down Expand Up @@ -372,43 +372,36 @@ return 0;
dnl Check if OpenMP is available
AC_MSG_CHECKING([for OpenMP])

AC_ARG_VAR(OMPCC, [Selects a compiler to be used to compile OpenMP code. Useful if the main CC does not support OpenMP.])
CONFIG_WITH_OPENMP=0
for OMPCCTEST in "-fopenmp=libomp" "-fopenmp=libiomp5" "-fopenmp"; do
if test "$CONFIG_WITH_OPENMP" = 0; then
CFLAGS_OLD="$CFLAGS"
CFLAGS="$OMPCCTEST"

AC_TRY_LINK([
#if !defined(_OPENMP)
#error "Not an OpenMP compiler"
#endif
#include <omp.h>
#include <stdio.h>
], [
int i;
#pragma omp parallel for private(i) schedule(dynamic)
for (i=0; i<16; i++)
printf("Thread %d doing work %d\n", omp_get_thread_num(), i);
return 0;
], [OMPCFLAGS="$CFLAGS"; CONFIG_WITH_OPENMP=1]
)
CFLAGS="$CFLAGS_OLD"
fi
done

CC_OLD="$CC"
CFLAGS_OLD="$CFLAGS"
if test -z "$OMPCC"; then
CFLAGS=" -fopenmp"
if test "$CONFIG_WITH_OPENMP" = 0; then
AC_MSG_RESULT([no]);
else
CC="$OMPCC"
CFLAGS=""
AC_MSG_RESULT([$OMPCFLAGS]);
fi

AC_TRY_LINK([
#if !defined(_OPENMP)
#error "Not an OpenMP compiler"
#endif
#include <omp.h>
#include <stdio.h>
], [
int i;
#pragma omp parallel for private(i) schedule(dynamic)
for (i=0; i<16; i++)
printf("Thread %d\n", i);
return 0;
], [OMPCC="$CC$CFLAGS"; AC_MSG_RESULT([$OMPCC]); CONFIG_WITH_OPENMP=1],
[
if test -z "$OMPCC"; then
OMPCC="$CC_OLD"
AC_MSG_RESULT([no]);
else
AC_MSG_ERROR([failed (user gave $OMPCC)]);
fi
CONFIG_WITH_OPENMP=0
]
)
CC="$CC_OLD"
CFLAGS="$CFLAGS_OLD"

AC_ARG_VAR(RUNTIMECC, [Selects a compiler to be used to compile generated code. It is more important to compile fast than to generate fast code for the runtime compiler.])
AC_ARG_VAR(RUNTIMECFLAGS, [CFLAGS for the selected runtime compiler (defaults to -O0 -falign-functions -march=native -mfpmath=sse -fPIC as long as neither gives warnings to the CC). Note that heavy optimisations may cause the run-time to be faster while increasing compile-time. -O0 is often best.])

Expand Down

0 comments on commit 5515de8

Please sign in to comment.