Skip to content

Commit

Permalink
Compile with our own libopenblas unless the user configures --with-la…
Browse files Browse the repository at this point in the history
…pack=-llapack or similar

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17244 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Sep 15, 2013
1 parent 030a5f4 commit 3d9fd5f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
19 changes: 4 additions & 15 deletions Compiler/BackEnd/SimCodeUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -9084,31 +9084,20 @@ algorithm
local
String str, fopenmp;

// seems lapack can show on Lapack form or lapack (different case) (MLS revision 6155)
case Absyn.STRING("lapack")
then getLibraryStringInGccFormat(Absyn.STRING("Lapack"));

// Lapack on MinGW/Windows is linked against f2c
case Absyn.STRING("Lapack")
equation
true = "Windows_NT" ==& System.os();
then {"-llapack-mingw", "-ltmglib-mingw", "-lblas-mingw", "-lf2c"};
// Lapack is always included
case Absyn.STRING("lapack") then {};
case Absyn.STRING("Lapack") then {};

// omcruntime on windows needs linking with mico2313 and wsock and then some :)
case Absyn.STRING(str as "omcruntime")
equation
true = "Windows_NT" ==& System.os();
str = "-l" +& str;
strs = getLibraryStringInGccFormat(Absyn.STRING("Lapack"));
fopenmp = getFOpenMPFlag();
strs = str :: fopenmp :: "-lintl" :: "-liconv" :: "-lexpat" :: "-lsqlite3" :: "-llpsolve55" :: "-lmico2313" :: "-lws2_32" :: "-lregex" :: strs;
strs = str :: fopenmp :: "-lintl" :: "-liconv" :: "-lexpat" :: "-lsqlite3" :: "-llpsolve55" :: "-lmico2313" :: "-lws2_32" :: "-lregex" :: {};
then
strs;

// The library is not actually named libLapack.so.
// Which is a problem, since MSL says it does.
case Absyn.STRING("Lapack") then {"-llapack"};

// Wonder if there may be issues if we have duplicates in the Corba libs
// and the other libs. Some other developer will probably swear over this
// hack some day, but at least I get an early weekend.
Expand Down
2 changes: 0 additions & 2 deletions Compiler/runtime/errorext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ typedef struct errorext_struct {
string *lastDeletedCheckpoint;
} errorext_members;

errorext_members members;

#include <pthread.h>

pthread_once_t errorext_once_create_key = PTHREAD_ONCE_INIT;
Expand Down
9 changes: 7 additions & 2 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ install-python:
install-openturns: mkbuilddirs
(time cp SimulationRuntime/OpenTurns/* $(builddir_share)/omc/scripts/OpenTurns/)

interactive: .testvariables mkbuilddirs boehm-gc fmil msl-external-libs lis
interactive: .testvariables mkbuilddirs boehm-gc fmil msl-external-libs lis $(LAPACK_TARGET)
$(MAKE) -C SimulationRuntime/interactive -f $(defaultMakefileTarget)
# Depends on libinteractive.a
$(MAKE) -C SimulationRuntime/c -f $(defaultMakefileTarget)
Expand Down Expand Up @@ -87,6 +87,11 @@ build/include/omc/gc_version.h: 3rdParty/gc-7.2/include/gc_version.h mkbuilddirs
3rdParty/gc-7.2/Makefile: 3rdParty/gc-7.2/Makefile.in 3rdParty/gc-7.2/configure
(cd 3rdParty/gc-7.2 && ./configure $(GC_THREADS) --enable-large-config CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS) -DTHREAD_LOCAL_ALLOC")

build/lib/omc/libopenblas_openmodelica.a:
$(MAKE) -C 3rdParty/OpenBLAS-0.2.8 CC=$(CC) USE_THREAD=0 NO_LAPACKE=1 LIBNAMESUFFIX=openmodelica
$(MAKE) -C 3rdParty/OpenBLAS-0.2.8 PREFIX=${abs_top_builddir}/build OPENBLAS_LIBRARY_DIR=${abs_top_builddir}/build/lib/omc OPENBLAS_INCLUDE_DIR=${abs_top_builddir}/3rdParty/build/install-includes/ NO_LAPACKE=1 LIBNAMESUFFIX=openmodelica install
openblas: build/lib/omc/libopenblas_openmodelica.a

fmi: interactive
$(MAKE) -C SimulationRuntime/fmi/import -f $(defaultMakefileTarget)
(cp -p SimulationRuntime/fmi/import/fmuWrapper.h SimulationRuntime/fmi/import/xmlparser.h $(builddir_inc))
Expand All @@ -105,7 +110,7 @@ opencl_rt_clean:
breakprocess:
(cd testsuite/openmodelica/bootstrapping && time g++ BreakProcess.cpp -o BreakProcess -static-libgcc)
(cd testsuite/openmodelica/bootstrapping && cp BreakProcess.exe ../../../$(builddir_bin)/)

runtimeCPP:
$(MAKE) -C SimulationRuntime/cpp/ -f $(defaultMakefileTarget)

Expand Down
2 changes: 2 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ all : release qtclients @OMSHELL_TERMINAL@

autoconfGeneratedFiles = @GENERATED_AUTOCONF_FILES@

abs_top_builddir=@abs_top_builddir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
Expand All @@ -26,6 +27,7 @@ LINK=@LINK@
MSL_EXTRA_ARGS=@MSL_EXTRA_ARGS@
GC_THREADS=--enable-threads=posix
LIBFMILIB=@LIBFMILIB@
LAPACK_TARGET=@LAPACK_TARGET@

include Makefile.common

Expand Down
20 changes: 13 additions & 7 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ AC_SUBST(MSL_EXTRA_ARGS)
AC_SUBST(WITH_HWLOC)
AC_SUBST(OS_TARGET)
AC_SUBST(LIS_LDFLAGS)
AC_SUBST(LAPACK_TARGET)

FINAL_MESSAGES="\nConfigured OpenModelica successfully using the following options:"

Expand Down Expand Up @@ -347,21 +348,26 @@ fi
fi

# Cannot use AX_LAPACK since it assumes a Fortran compiler is used
AC_ARG_WITH(lapack, [ --with-lapack=[-llapack -lblas]],[LD_LAPACK="$withval"],[LD_LAPACK="-llapack -lblas"])
if test "$LD_LAPACK" = "yes"; then
LD_LAPACK="-llapack -lblas"
fi
LIBS="$LD_LAPACK"
AC_ARG_WITH(lapack, [ --with-lapack=[internal] (use -llapack -lblas to use system-provided version instead of OpenBLAS)],[LD_LAPACK="$withval"],[LD_LAPACK="internal"])
AC_MSG_CHECKING([LAPACK flags])
AC_LINK_IFELSE([AC_LANG_CALL([], [dgesv_])],[AC_MSG_RESULT([ok])],[AC_MSG_ERROR([failed using $LD_LAPACK])])
if test "$LD_LAPACK" = "internal"; then
LD_LAPACK="-lopenblas_openmodelica"
LAPACK_TARGET="openblas"
AC_MSG_RESULT([internal OpenBLAS compiled during the build process])
else
LIBS="$LD_LAPACK"
AC_LINK_IFELSE([AC_LANG_CALL([], [dgesv_])],[AC_MSG_RESULT([$LD_LAPACK])],[AC_MSG_ERROR([failed using $LD_LAPACK])])
fi

AC_CHECK_HEADERS(kinsol/kinsol.h kinsol/kinsol_dense.h nvector/nvector_serial.h sundials/sundials_types.h sundials/sundials_math.h,[],[NO_SUNDIALS="yes"])
SUNDIALS_LDFLAGS="-lsundials_kinsol -lsundials_nvecserial $LD_LAPACK"
LIBS="$SUNDIALS_LDFLAGS -lm"
AC_MSG_CHECKING([Sundials linking])
AC_LINK_IFELSE([AC_LANG_CALL([], [KINInit])],
[AC_MSG_RESULT([ok])],
[AC_MSG_RESULT([failed to link KINInit]); NO_SUNDIALS="yes"])
[LIBS="-lsundials_kinsol -lsundials_nvecserial -lm";
AC_LINK_IFELSE([AC_LANG_CALL([], [KINInit])],
[AC_MSG_RESULT([ok])],[AC_MSG_RESULT([failed to link KINInit]); NO_SUNDIALS="yes"])])

if ! test "$NO_SUNDIALS" = "yes"; then
FINAL_MESSAGES="$FINAL_MESSAGES\nSimulations may use sundials suite: Yes"
Expand Down

0 comments on commit 3d9fd5f

Please sign in to comment.