用于 Boost MPI 的 Autoconf 宏?

发布于 2024-08-28 08:29:51 字数 408 浏览 14 评论 0原文

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

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

您使用什么ax_boost_mpi.m4

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

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

作为一个优点,它应该定义一个 MPIRUN 变量以允许运行一些检查。

I'm searching an autoconf macro to use in my configure.ac that checks for Boost MPI.

It's not hard to find a couple of them on the Internet but none of the one I tried worked as expected.

What ax_boost_mpi.m4 do you use?

EDIT: I'll explain my requirement better. I need the macro to tell me if Boost MPI is available or not (defining HAVE_BOOST_MPI) to store the compiler and linker flags somewhere and to switch the compiler from the nornal c++ compiler to an available mpiCC or mpic++.

If the Boost MPI is not found I'd like to be able to choose if I want to stop the configuration process with an error or continue using g++ without HAVE_BOOST_MPI defined.

As a plus it should define an MPIRUN variable to allow running some checks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陈年往事 2024-09-04 08:29:51

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

通过一些工作,您可能可以适应 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 搜索机制。

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

I'm unaware of a turnkey solution here, but that doesn't mean one's unavailable.

With some work, you could probably adapt http://www.gnu.org/software/autoconf-archive/ax_mpi.html#ax_mpi and http://github.com/tsuna/boost.m4 to do what you want. The former digging up the MPI compiler and the latter checking for Boost MPI. You'd have to add a Boost MPI check to boost.m4 as it doesn't have one. You'd have to add your own MPIRUN-searching mechanism.

If you find a solution and/or roll your own, please do share.

囚我心虐我身 2024-09-04 08:29:51
# ===========================================================================
#
# 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 <[email protected]>
#
#   Copyright (c) 2010 Mirko Maischberger <[email protected]>
#
#   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
])
# ===========================================================================
#
# 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 <[email protected]>
#
#   Copyright (c) 2010 Mirko Maischberger <[email protected]>
#
#   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
])
眼睛会笑 2024-09-04 08:29:51

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

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

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

This comment is a bit late, but I will add it here so that others searching for the same topic can find it. I had personally been looking for a function integrated into boost.m4 that defined similar variables as the other boost libraries (BOOST_MPI_LDFLAGS, BOOST_MPI_LIBS). I finally just added one and submitted a pull request here:

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

This uses the MPICXX variable for CXX/CXXCPP if it is already defined (by ax_mpi.m4, acx_mpi.m4, etc), otherwise it uses the existing CXX/CXXCPP.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文