[Rd] Best way to manage configuration for openMP support

Dirk Eddelbuettel edd at debian.org
Tue Sep 14 13:40:52 CEST 2010


On 14 September 2010 at 11:06, Karl Forner wrote:
| I've written a package that may use OpenMP to speed up computations. OpenMP
| is supported in recent Gcc versions by using the -fopenmp flag.
| The problem is that flag crashed gcc versions that do not support OpenMP.
| So what is the best way for a package to handle this issue. Has someone a
| configure script that deals with this ?

I don't know off-hand of any CRAN packages that do that, but you could look
at Luke Tierney's pnmath package which uses Open MP. It may have a test.

Else, you can query gcc for minimum versions. I have some configure code from
way back when then tested for a minimum version of 3.0 (!!):

# We are using C++
AC_LANG(C++)
AC_REQUIRE_CPP

AC_PROG_CXX
if test "${GXX}" = yes; then
    gxx_version=`${CXX} -v 2>&1 | grep "^.*g.. version" | \\
		       sed -e 's/^.*g.. version *//'`
    case ${gxx_version} in
        1.*|2.*)
	     AC_MSG_WARN([Only g++ version 3.0 or greater can be used with RQuantib.])
	     AC_MSG_ERROR([Please use a different compiler.])   
        ;;
    esac
fi

You could do the same for gcc and strip out major version (4) and minor (0 or
1) and then complain.  With 4.2 you should be fine.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com



More information about the R-devel mailing list