1

我正在搜索用于configure.ac检查 Boost MPI 的 autoconf 宏。

在互联网上找到其中的几个并不难,但我尝试过的一个都没有按预期工作。

ax_boost_mpi.m4你用什么

编辑:我会更好地解释我的要求。我需要宏来告诉我 Boost MPI 是否可用(定义HAVE_BOOST_MPI)以将编译器和链接器标志存储在某处并将编译器从普通 c++ 编译器切换到可用的 mpiCC 或 mpic++。

如果未找到 Boost MPI,我希望能够选择是否要停止配置过程并出现错误或继续使用 g++ 而未定义 HAVE_BOOST_MPI。

另外,它应该定义一个 MPIRUN 变量以允许运行一些检查。

4

3 回答 3

1

我不知道这里有交钥匙解决方案,但这并不意味着一个人不可用。

通过一些工作,您可能可以调整http://www.gnu.org/software/autoconf-archive/ax_mpi.html#ax_mpihttp://github.com/tsuna/boost.m4来做您想做的事。前者挖掘 MPI 编译器,后者检查 Boost MPI。您必须向 boost.m4 添加一个 Boost MPI 检查,因为它没有。您必须添加自己的 MPIRUN 搜索机制。

如果您找到解决方案和/或推出自己的解决方案,请分享。

于 2010-04-09T13:13:18.510 回答
1
# ===========================================================================
#
# SYNOPSIS
#
#   AX_BOOST_MPI
#
# DESCRIPTION
#
#   Test for MPI library from the Boost C++ libraries. The macro
#   requires a preceding call to AX_BOOST_BASE, AX_BOOST_SERIALIZATION 
#   and AX_MPI. You also need to set CXX="$MPICXX" before calling the 
#   macro.
#
#   This macro calls:
#
#     AC_SUBST(BOOST_MPI_LIB)
#
#   And sets:
#
#     HAVE_BOOST_MPI
#
# LICENSE
#
#   Based on Boost Serialize by:
#   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
#
#   Copyright (c) 2010 Mirko Maischberger <mirko.maischberger@gmail.com>
#
#   Copying and distribution of this file, with or without modification, are
#   permitted in any medium without royalty provided the copyright notice
#   and this notice are preserved. This file is offered as-is, without any
#   warranty.

#serial 1

AC_DEFUN([AX_BOOST_MPI],
[
    AC_ARG_WITH([boost-mpi],
    AS_HELP_STRING([--with-boost-mpi@<:@=special-lib@:>@],
                   [use the MPI library from boost - it is possible to 
                      specify a certain library for the linker
                      e.g. --with-boost-mpi=boost_mpi-gcc-mt-d-1_33_1 ]),
        [
        if test "$withval" = "no"; then
            want_boost="no"
        elif test "$withval" = "yes"; then
            want_boost="yes"
            ax_boost_user_mpi_lib=""
        else
            want_boost="yes"
            ax_boost_user_mpi_lib="$withval"
        fi
        ],
        [want_boost="yes"]
    )

    if test "x$want_boost" = "xyes"; then
        AC_REQUIRE([AC_PROG_CC])
        CPPFLAGS_SAVED="$CPPFLAGS"
        CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
        AC_MSG_WARN(BOOST_CPPFLAGS $BOOST_CPPFLAGS)
        export CPPFLAGS

        LDFLAGS_SAVED="$LDFLAGS"
        LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
        export LDFLAGS

        LIBS_SAVED="$LIBS"
        LIBS="$LIBS $BOOST_SERIALIZATION_LIB"
        export LIBS

        AC_CACHE_CHECK(whether the Boost::MPI library is available,
                       ax_cv_boost_mpi,
        [AC_LANG_PUSH([C++])
             AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/mpi.hpp>
                                                ]],
                                   [[int argc = 0; 
                                     char **argv = 0;
                                     boost::mpi::environment env(argc,argv);
                                     return 0;
                                   ]]),
                   ax_cv_boost_mpi=yes, ax_cv_boost_mpi=no)
         AC_LANG_POP([C++])
        ])
        if test "x$ax_cv_boost_mpi" = "xyes"; then
            AC_DEFINE(HAVE_BOOST_MPI,,[define if the Boost::MPI library is available])
            BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
            if test "x$ax_boost_user_mpi_lib" = "x"; then
                for libextension in `ls $BOOSTLIBDIR/libboost_mpi*.{so,a}* 2>/dev/null | grep -v python | sed 's,.*/,,' | sed -e 's;^lib\(boost_mpi.*\)\.so.*$;\1;' -e 's;^lib\(boost_mpi.*\)\.a*$;\1;'` ; do
                     ax_lib=${libextension}
                    AC_CHECK_LIB($ax_lib, exit,
                                 [BOOST_MPI_LIB="-l$ax_lib"; AC_SUBST(BOOST_MPI_LIB) link_mpi="yes"; break],
                                 [link_mpi="no"])
                  done
                if test "x$link_mpi" != "xyes"; then
                for libextension in `ls $BOOSTLIBDIR/boost_mpi*.{dll,a}* 2>/dev/null | grep -v python | sed 's,.*/,,' | sed -e 's;^\(boost_mpi.*\)\.dll.*$;\1;' -e 's;^\(boost_mpi.*\)\.a*$;\1;'` ; do
                     ax_lib=${libextension} 
                    AC_CHECK_LIB($ax_lib, exit,
                                 [BOOST_MPI_LIB="-l$ax_lib"; AC_SUBST(BOOST_MPI_LIB) link_mpi="yes"; break],
                                 [link_mpi="no"])
                  done
                fi

            else
               for ax_lib in $ax_boost_user_mpi_lib boost_mpi-$ax_boost_user_mpi_lib; do
                      AC_CHECK_LIB($ax_lib, exit,
                                   [BOOST_MPI_LIB="-l$ax_lib"; AC_SUBST(BOOST_MPI_LIB) link_mpi="yes"; break],
                                   [link_mpi="no"])
                  done

            fi
            if test "x$link_mpi" != "xyes"; then
                AC_MSG_ERROR(Could not link against $ax_lib !)
            fi
        fi
        LIBS="$LIBS_SAVED"
        CPPFLAGS="$CPPFLAGS_SAVED"
        LDFLAGS="$LDFLAGS_SAVED"
    fi
])
于 2010-04-09T15:57:15.147 回答
0

这条评论有点晚了,但我会在这里添加它,以便其他搜索相同主题的人可以找到它。我个人一直在寻找一个集成到 boost.m4 中的函数,它定义了与其他 boost 库(BOOST_MPI_LDFLAGS、BOOST_MPI_LIBS)类似的变量。我终于添加了一个并在这里提交了一个拉取请求:

https://github.com/tsuna/boost.m4/pull/50

如果 CXX/CXXCPP 已经定义(通过 ax_mpi.m4、acx_mpi.m4 等),这将使用 MPICXX 变量,否则使用现有的 CXX/CXXCPP。

于 2013-12-09T15:20:22.917 回答