using OpenMP only if the compiler supports it (e.g. GCC>4.2)
Status: Beta
Brought to you by:
m_schellens
As mentioned on the forum, and noted by Alain, GDL failes to compile when OpenMP support is enabled (-fopenmp) but the compiler does not support it. In case of GCC, OpenMP is supported since 4.2, and for older versions the default setting of with-openmp=true seem to break the compilation.
In ImageMagick it is handled with the following checks:
if test "${GCC}" = "yes"; then
AC_CHECK_LIB(gomp,GOMP_parallel_start,GOMP_LIBS="-lgomp",,) # gcc
else
AC_CHECK_LIB(mtsk,sunw_mp_register_warn,GOMP_LIBS="-lmtsk",,) # solaris cc
AC_CHECK_LIB(xlsmp,_xlsmpFlush,LIB_OMP="-lxlsmp",,) # AIX xlc
fi
I'll look at it some time soon - just putting here not to forget, comments welcome.
Sylwester
I've replaced the previous logic for toggling the OpenMP support in the configure script with a call to the AC_OPENMP macro. The macro should detect if the compiler supports OpenMP and disable OpenMP when the --disable-openmp option is supplied. Hope that fixes the problem. Please report if you test compilation with OpenMP.
S.
I'm re-opening this item, as it is still the case after this change:
http://gnudatalanguage.cvs.sourceforge.net/viewvc/gnudatalanguage/gdl/configure.in?r1=1.82&r2=1.83&sortby=date
To clarify, there are now two problems:
- configure script is not detecting GSL when using GCC without OpenMP support (when -fopenmp is used, which is the default setting)
- there's no way of disabling OpenMP without modifying configure.in/configure
As a result, it's not possible to compile GDL with GCC <4.2 without manually disabling OpenMP in configure.in and regenerating configure scripts.
config.log:
...
configure:14995: checking for gsl_cdf_ugaussian_P in -lgsl
configure:15020: g++ -o conftest -g -O2 -I/opt/local/include -L/opt/local/lib -fopenmp -L/opt/local/lib -fopenmp conftes
cc1plus: error: unrecognized command line option "-fopenmp"
cc1plus: error: unrecognized command line option "-fopenmp"
configure:15020: $? = 1
configure: failed program was:
...
One option is the AC_OPENMP macro, another one would be to use something like the above-mentioned check using AC_CHECK_LIB? Any comments?
Best,
Sylwester.
P.S. I vote for the AM_MAINTAINER_MODE([disable]) to get rid of the problems with unneeded "autoreconf" calls by make - any comments?
A comment on --with-openmp flag: I am using a compiler which I know not supporting -fopenmp, so I passed --with-openmp=no to configure, meaning disabling it. Result:
configure: WARNING: unrecognized options: --with-openmp
I fixed it by adding with_openmp to the list ac_user_opts and by changing references to with-openmp with with_openmp, i.e. by changing this piece of code:
--------------------
if test "x$with-openmp" = "x"; then
with-openmp=yes
fi
if test "x$with-openmp" != "xno"; then
CPPFLAGS="$CPPFLAGS -fopenmp"
LDFLAGS="$LDFLAGS -fopenmp"
fi
--------------------
with this:
--------------------
if test "x$with_openmp" = "x"; then
with_openmp=yes
fi
if test "x$with_openmp" != "xno"; then
CPPFLAGS="$CPPFLAGS -fopenmp"
LDFLAGS="$LDFLAGS -fopenmp"
fi
-------------------
Thats fixed in the CVS and 0.9rc4. OpenMP is now detected by checking for omp.h header.
The current solution does not work with the Intel C++ compiler (which compiles current GDL without problem). That is, the omp.h file is found but the -fopenmp option is unrecognised:
icc: command line warning #10006: ignoring unknown option '-fopenmp'
The OpenMP options for icc have the -openmp* naming.
This was an autoconf-related issue.
Autoconf is now not supported anymore (in favour of CMake).
Closing.
S.