Mercurial > hg > octave-lojdl
changeset 10471:bcabc1c4f20c
Add detection of OpenMP support to configure. Disabled by default
author | David Bateman <dbateman@free.fr> |
---|---|
date | Sat, 27 Mar 2010 18:23:54 +0100 |
parents | 9500a66118dc |
children | 944aa97069ed |
files | ChangeLog acinclude.m4 configure.ac liboctave/ChangeLog liboctave/Makefile.am liboctave/oct-openmp.h |
diffstat | 6 files changed, 107 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-03-27 David Bateman <dbateman@free.fr> + + * acinclude.m4 (OCTAVE_CHECK_OPENMP): Macro to check for OpenMP support + * configure.ac: Use it here. Disable OpenMP support by default + 2010-03-25 John W. Eaton <jwe@octave.org> * bootstrap.conf (gnulib_modules): Sort the list.
--- a/acinclude.m4 +++ b/acinclude.m4 @@ -1065,6 +1065,35 @@ fi ]) dnl +dnl Check for support of OpenMP with a given compiler flag. If +dnl found define HAVE_OPENMP and add the compile flag to CFLAGS +dnl and CXXFLAGS. +dnl +AC_DEFUN([OCTAVE_CHECK_OPENMP], +[AC_MSG_CHECKING([for support of OpenMP]) +XCFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $1" +AC_CACHE_VAL(octave_cv_check_openmp,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include <omp.h> +#include <stdio.h> +]], [[ +int main(int argc, char* argv[]) +{ + _Pragma("omp parallel") + printf("Hello, world.\n"); + return 0; +} +]])],octave_cv_openmp=yes, octave_cv_openmmp=no, octave_cv_openmp=no)]) +AC_MSG_RESULT($octave_cv_openmp) +if test "$octave_cv_openmp" = yes; then + AC_DEFINE(HAVE_OPENMP,1,[Define if compiler supports OpenMP]) + CXXFLAGS="$CXXFLAGS $1" +else + CFLAGS="$XCFLAGS" +fi +]) +dnl dnl Configure paths for FreeType2 dnl Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor dnl
--- a/configure.ac +++ b/configure.ac @@ -427,6 +427,26 @@ ;; esac +## Test whether the compiler supports OpenMP. Experimental so disable by +## default. Enable it with the flag --enable-openmp +USE_OPENMP=false +AC_ARG_ENABLE(openmp, + [AS_HELP_STRING([--enable-openmp], + [(EXPERIMENTAL) use OpenMP SMP multi-threading])], + [if test "$enableval" = yes; then USE_OPENMP=true; fi], []) +if $USE_OPENMP; then + case "$canonical_host_type" in + *-*-mingw* | *-*-cygwin* | *-*-gnu*) + OCTAVE_CHECK_OPENMP(-fopenmp) + ;; + *-*-msdosmsvc) + ## FIXME is this the right flag for MSVC? + OCTAVE_CHECK_OPENMP(-openmp) + ;; + ## Add other compilers supporting OpenMP here + esac +fi + AC_SUBST(XTRA_CFLAGS) AC_SUBST(XTRA_CXXFLAGS) @@ -2314,6 +2334,19 @@ warn_msg_printed=true fi +if $USE_OPENMP; then + AC_MSG_WARN([]) + AC_MSG_WARN([You used the EXPERIMENTAL --enable-openmp option.]) + AC_MSG_WARN([Are you sure that is what you want to do?]) + AC_MSG_WARN([]) + AC_MSG_WARN([This option enables experimental SMP multithreding]) + AC_MSG_WARN([code that has had very little testing. There is no]) + AC_MSG_WARN([certainity that the results returned by Octave with]) + AC_MSG_WARN([this option enabled will be correct.]) + AC_MSG_WARN([]) + warn_msg_printed=true +fi + native_graphics=true if test -n "$warn_freetype"; then AC_MSG_WARN([$warn_freetype])
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2010-03-27 David Bateman <dbateman@free.fr> + + * oct-openmp.h: New file. + * Makefile.am (INCS): Add it here. + 2010-03-26 Jaroslav Hajek <highegg@gmail.com> * Sparse.cc (Sparse<T>::index (const idx_vector&, const idx_vector&, bool)):
--- a/liboctave/Makefile.am +++ b/liboctave/Makefile.am @@ -223,6 +223,7 @@ oct-mem.h \ oct-mutex.h \ oct-norm.h \ + oct-openmp.h \ oct-passwd.h \ oct-rand.h \ oct-rl-edit.h \
new file mode 100644 --- /dev/null +++ b/liboctave/oct-openmp.h @@ -0,0 +1,34 @@ +/* + +Copyright (C) 2010 David Bateman + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +<http://www.gnu.org/licenses/>. + +*/ + +#if !defined (octave_openmp_h) +#define octave_openmp_h 1 + +/* A macro to make using OpenMP easier, and easier to disable */ +#ifdef HAVE_OPENMP +#include <omp.h> +#define OCTAVE_OMP_PRAGMA(x) _Pragma (#x) +#else +#define OCTAVE_OMP_PRAGMA(x) +#endif + +#endif