Chris@42: dnl @synopsis AX_OPENMP([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) Chris@42: dnl @summary determine how to compile programs using OpenMP Chris@42: dnl @category InstalledPackages Chris@42: dnl Chris@42: dnl This macro tries to find out how to compile programs that Chris@42: dnl use OpenMP, a standard API and set of compiler directives for Chris@42: dnl parallel programming (see http://www.openmp.org/). Chris@42: dnl Chris@42: dnl On success, it sets the OPENMP_CFLAGS/OPENMP_CXXFLAGS/OPENMP_FFLAGS Chris@42: dnl output variable to the flag (e.g. -omp) used both to compile *and* link Chris@42: dnl OpenMP programs in the current language. Chris@42: dnl Chris@42: dnl NOTE: You are assumed to not only compile your program with these Chris@42: dnl flags, but also link it with them as well. Chris@42: dnl Chris@42: dnl If you want to compile everything with OpenMP, you should set: Chris@42: dnl Chris@42: dnl CFLAGS="$CFLAGS $OPENMP_CFLAGS" Chris@42: dnl #OR# CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS" Chris@42: dnl #OR# FFLAGS="$FFLAGS $OPENMP_FFLAGS" Chris@42: dnl Chris@42: dnl (depending on the selected language). Chris@42: dnl Chris@42: dnl The user can override the default choice by setting the corresponding Chris@42: dnl environment variable (e.g. OPENMP_CFLAGS). Chris@42: dnl Chris@42: dnl ACTION-IF-FOUND is a list of shell commands to run if an OpenMP Chris@42: dnl flag is found, and ACTION-IF-NOT-FOUND is a list of commands Chris@42: dnl to run it if it is not found. If ACTION-IF-FOUND is not specified, Chris@42: dnl the default action will define HAVE_OPENMP. Chris@42: dnl Chris@42: dnl @version 2006-11-20 Chris@42: dnl @license GPLWithACException Chris@42: dnl @author Steven G. Johnson Chris@42: Chris@42: AC_DEFUN([AX_OPENMP], [ Chris@42: AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX Chris@42: Chris@42: AC_CACHE_CHECK([for OpenMP flag of _AC_LANG compiler], ax_cv_[]_AC_LANG_ABBREV[]_openmp, [save[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS Chris@42: ax_cv_[]_AC_LANG_ABBREV[]_openmp=unknown Chris@42: # Flags to try: -fopenmp (gcc), -openmp (icc), -mp (SGI & PGI), Chris@42: # -xopenmp (Sun), -omp (Tru64), -qsmp=omp (AIX), none Chris@42: ax_openmp_flags="-fopenmp -openmp -mp -xopenmp -omp -qsmp=omp none" Chris@42: if test "x$OPENMP_[]_AC_LANG_PREFIX[]FLAGS" != x; then Chris@42: ax_openmp_flags="$OPENMP_[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flags" Chris@42: fi Chris@42: for ax_openmp_flag in $ax_openmp_flags; do Chris@42: case $ax_openmp_flag in Chris@42: none) []_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[] ;; Chris@42: *) []_AC_LANG_PREFIX[]FLAGS="$save[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flag" ;; Chris@42: esac Chris@42: AC_TRY_LINK_FUNC(omp_set_num_threads, Chris@42: [ax_cv_[]_AC_LANG_ABBREV[]_openmp=$ax_openmp_flag; break]) Chris@42: done Chris@42: []_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[]FLAGS Chris@42: ]) Chris@42: if test "x$ax_cv_[]_AC_LANG_ABBREV[]_openmp" = "xunknown"; then Chris@42: m4_default([$2],:) Chris@42: else Chris@42: if test "x$ax_cv_[]_AC_LANG_ABBREV[]_openmp" != "xnone"; then Chris@42: OPENMP_[]_AC_LANG_PREFIX[]FLAGS=$ax_cv_[]_AC_LANG_ABBREV[]_openmp Chris@42: fi Chris@42: m4_default([$1], [AC_DEFINE(HAVE_OPENMP,1,[Define if OpenMP is enabled])]) Chris@42: fi Chris@42: AC_SUBST(OPENMP_[]_AC_LANG_PREFIX[]FLAGS) Chris@42: ])dnl AX_OPENMP