|
Boost-Commit : |
From: dgregor_at_[hidden]
Date: 2008-03-06 16:24:30
Author: dgregor
Date: 2008-03-06 16:24:30 EST (Thu, 06 Mar 2008)
New Revision: 43532
URL: http://svn.boost.org/trac/boost/changeset/43532
Log:
Support for building and testing Boost.MPI
Added:
branches/CMake/release/libs/mpi/CMakeLists.txt (contents, props changed)
branches/CMake/release/libs/mpi/src/CMakeLists.txt (contents, props changed)
branches/CMake/release/libs/mpi/test/CMakeLists.txt (contents, props changed)
branches/CMake/release/tools/build/CMake/FindMPI.cmake (contents, props changed)
Added: branches/CMake/release/libs/mpi/CMakeLists.txt
==============================================================================
--- (empty file)
+++ branches/CMake/release/libs/mpi/CMakeLists.txt 2008-03-06 16:24:30 EST (Thu, 06 Mar 2008)
@@ -0,0 +1,10 @@
+include(FindMPI)
+
+if (MPI_FOUND)
+ boost_library_project(
+ MPI
+ SRCDIRS src
+ TESTDIRS test
+ )
+endif(MPI_FOUND)
+
Added: branches/CMake/release/libs/mpi/src/CMakeLists.txt
==============================================================================
--- (empty file)
+++ branches/CMake/release/libs/mpi/src/CMakeLists.txt 2008-03-06 16:24:30 EST (Thu, 06 Mar 2008)
@@ -0,0 +1,29 @@
+add_definitions(-DBOOST_MPI_SOURCE=1)
+include_directories(${MPI_INCLUDE_PATH})
+
+boost_add_library(
+ boost_mpi
+ broadcast.cpp
+ communicator.cpp
+ computation_tree.cpp
+ content_oarchive.cpp
+ environment.cpp
+ exception.cpp
+ graph_communicator.cpp
+ group.cpp
+ intercommunicator.cpp
+ mpi_datatype_cache.cpp
+ mpi_datatype_oarchive.cpp
+ packed_iarchive.cpp
+ packed_oarchive.cpp
+ packed_skeleton_iarchive.cpp
+ packed_skeleton_oarchive.cpp
+ point_to_point.cpp
+ request.cpp
+ text_skeleton_oarchive.cpp
+ DEPENDS boost_serialization
+ COMPILE_FLAGS "${MPI_COMPILE_FLAGS}"
+ LINK_FLAGS "${MPI_LINK_FLAGS}"
+ LINK_LIBS ${MPI_LIBRARIES}
+ SHARED_COMPILE_FLAGS "-DBOOST_MPI_DYN_LINK=1"
+ )
Added: branches/CMake/release/libs/mpi/test/CMakeLists.txt
==============================================================================
--- (empty file)
+++ branches/CMake/release/libs/mpi/test/CMakeLists.txt 2008-03-06 16:24:30 EST (Thu, 06 Mar 2008)
@@ -0,0 +1,63 @@
+include_directories(${MPI_INCLUDE_PATH})
+
+# Declare a test for the Boost.MPI library, which may involve both
+# building the test and executing it with varying numbers of
+# processes.
+#
+# boost_mpi_test(testname
+# [source1 source2 ...]
+# [ARGS arg1 arg2 ...]
+# [SCHEDULE procs1 procs2 ...]
+#
+# testname is the name of the test. source1, source2, etc. are the
+# source files that will be built and linked into the test
+# executable. If no source files are provided, the file "testname.cpp"
+# will be used instead.
+macro(boost_mpi_test testname)
+ PARSE_ARGUMENTS(MPI_TEST "SCHEDULE;ARGS" "" ${ARGN})
+
+ # Determine the test sources
+ if (MPI_TEST_DEFAULT_ARGS)
+ set(MPI_TEST_SOURCES ${MPI_TEST_DEFAULT_ARGS})
+ else (MPI_TEST_DEFAULT_ARGS)
+ set(MPI_TEST_SOURCES "${testname}.cpp")
+ endif (MPI_TEST_DEFAULT_ARGS)
+
+ # Build the test executable
+ boost_add_executable(${testname}
+ ${MPI_TEST_SOURCES}
+ OUTPUT_NAME tests/${PROJECT_NAME}/${testname}
+ NO_INSTALL
+ DEPENDS boost_mpi
+ COMPILE_FLAGS "${MPI_COMPILE_FLAGS}"
+ LINK_FLAGS "${MPI_LINK_FLAGS}"
+ LINK_LIBS ${MPI_LIBRARIES}
+ SHARED_COMPILE_FLAGS "-DBOOST_MPI_DYN_LINK=1")
+ if (THIS_EXE_OKAY)
+ if (NOT MPI_TEST_SCHEDULE)
+ set(MPI_TEST_SCHEDULE 1 2 3 4 7 8 13 17)
+ endif (NOT MPI_TEST_SCHEDULE)
+
+ foreach(PROCS ${MPI_TEST_SCHEDULE})
+ add_test("${PROJECT_NAME}::${testname}-${PROCS}"
+ ${MPIEXEC}
+ -n ${PROCS}
+ ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/tests/${PROJECT_NAME}/${testname}
+ ${BOOST_TEST_ARGS}
+ )
+ endforeach(PROCS)
+ endif (THIS_EXE_OKAY)
+endmacro(boost_mpi_test)
+
+boost_mpi_test(all_gather_test)
+boost_mpi_test(all_reduce_test)
+boost_mpi_test(all_to_all_test)
+boost_mpi_test(broadcast_test SCHEDULE 2 17)
+boost_mpi_test(graph_topology_test SCHEDULE 2 7 13)
+boost_mpi_test(is_mpi_op_test SCHEDULE 1)
+boost_mpi_test(nonblocking_test)
+boost_mpi_test(reduce_test)
+boost_mpi_test(ring_test SCHEDULE 2 3 4 7 8 13 17)
+boost_mpi_test(scan_test)
+boost_mpi_test(scatter_test)
+boost_mpi_test(skeleton_content_test SCHEDULE 2 3 4 7 8 13 17)
Added: branches/CMake/release/tools/build/CMake/FindMPI.cmake
==============================================================================
--- (empty file)
+++ branches/CMake/release/tools/build/CMake/FindMPI.cmake 2008-03-06 16:24:30 EST (Thu, 06 Mar 2008)
@@ -0,0 +1,214 @@
+# This module looks for the Message Passing Interface (MPI).
+#
+# This module will set the following variables:
+# MPI_FOUND TRUE if we have found MPI
+# MPI_COMPILE_FLAGS Compilation flags for MPI programs
+# MPI_INCLUDE_PATH Include path for MPI header
+# MPI_LINK_FLAGS Linking flags for MPI programs
+# MPI_LIBRARIES Libraries to link MPI programs against
+# MPI_LIBRARY Deprecated; first MPI library to link against
+# MPI_EXTRA_LIBRARY Deprecated; second MPI library to link against
+# MPIEXEC Executable for running MPI programs
+#
+# This module will attempt to auto-detect these settings, first by
+# looking for a C++ MPI driver (e.g., mpic++, mpiCC, or mpicxx; set by
+# MPICXX) and later by checking common MPI paths and library names.
+
+# Try to find the MPI driver program
+find_program(MPICXX
+ NAMES mpic++ mpicxx mpiCC
+ DOC "MPI C++ compiler. Used only to detect MPI compilation flags.")
+mark_as_advanced(MPICXX)
+
+find_program(MPIEXEC
+ NAMES mpiexec mpirun
+ DOC "Executable for running MPI programs.")
+mark_as_advanced(MPIEXEC)
+
+if (NOT OLD_MPICXX STREQUAL MPICXX)
+ set(MPI_FORCE_RECONFIGURE TRUE)
+ set(OLD_MPICXX ${MPICXX} CACHE INTERNAL "Previous value of MPICXX" FORCE)
+endif (NOT OLD_MPICXX STREQUAL MPICXX)
+
+if (NOT MPICXX)
+ # If there is no MPI C++ compiler, we force ourselves to configure
+ # MPI the old way.
+ set(MPI_FORCE_RECONFIGURE TRUE)
+endif (NOT MPICXX)
+
+if (MPICXX)
+ # Check whether the -showme:compile option works. This indicates
+ # that we have either Open MPI or a newer version of LAM-MPI, and
+ # implies that -showme:link will also work.
+ exec_program(${MPICXX}
+ ARGS -showme:compile
+ OUTPUT_VARIABLE MPI_COMPILE_CMDLINE
+ RETURN_VALUE MPICXX_RETURN)
+
+ if (MPICXX_RETURN EQUAL 0)
+ # If we appear to have -showme:compile, then we should also have
+ # -showme:link. Try it.
+ exec_program(${MPICXX}
+ ARGS -showme:link
+ OUTPUT_VARIABLE MPI_LINK_CMDLINE
+ RETURN_VALUE MPICXX_RETURN)
+ endif (MPICXX_RETURN EQUAL 0)
+
+ if (MPICXX_RETURN EQUAL 0)
+ # Do nothing: we have our command lines now
+ else (MPICXX_RETURN EQUAL 0)
+ # Older versions of LAM-MPI have "-showme". Try it.
+ exec_program(${MPICXX}
+ ARGS -showme
+ OUTPUT_VARIABLE MPI_COMPILE_CMDLINE
+ RETURN_VALUE MPICXX_RETURN)
+ endif (MPICXX_RETURN EQUAL 0)
+
+ if (MPICXX_RETURN EQUAL 0)
+ # Do nothing: we have our command lines now
+ else (MPICXX_RETURN EQUAL 0)
+ # MPICH uses "-show". Try it.
+ exec_program(${MPICXX}
+ ARGS -show
+ OUTPUT_VARIABLE MPI_COMPILE_CMDLINE
+ RETURN_VALUE MPICXX_RETURN)
+ endif (MPICXX_RETURN EQUAL 0)
+
+ if (MPICXX_RETURN EQUAL 0)
+ # We have our command lines, but we might need to copy
+ # MPI_COMPILE_CMDLINE into MPI_LINK_CMDLINE, if the underlying
+ if (NOT MPI_LINK_CMDLINE)
+ SET(MPI_LINK_CMDLINE ${MPI_COMPILE_CMDLINE})
+ endif (NOT MPI_LINK_CMDLINE)
+ else (MPICXX_RETURN EQUAL 0)
+ message(STATUS "Unable to determine MPI from MPI driver ${MPICXX}")
+ endif (MPICXX_RETURN EQUAL 0)
+endif (MPICXX)
+
+if (NOT MPI_FORCE_RECONFIGURE)
+ # We don't actually have to reconfigure anything
+elseif (MPI_COMPILE_CMDLINE)
+ # Extract compile flags from the compile command line.
+ string(REGEX MATCHALL "-D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS ${MPI_COMPILE_CMDLINE})
+ set(MPI_COMPILE_FLAGS_WORK)
+ foreach(FLAG ${MPI_ALL_COMPILE_FLAGS})
+ if (MPI_COMPILE_FLAGS_WORK)
+ set(MPI_COMPILE_FLAGS_WORK "${MPI_COMPILE_FLAGS_WORK} ${FLAG}")
+ else(MPI_COMPILE_FLAGS_WORK)
+ set(MPI_COMPILE_FLAGS_WORK ${FLAG})
+ endif(MPI_COMPILE_FLAGS_WORK)
+ endforeach(FLAG)
+
+ # Extract include paths from compile command line
+ string(REGEX MATCH "-I([^\" ]+|\"[^\"]+\")" MPI_INCLUDE_PATH ${MPI_COMPILE_CMDLINE})
+ string(REGEX REPLACE "^-I" "" MPI_INCLUDE_PATH ${MPI_INCLUDE_PATH})
+ string(REGEX REPLACE "//" "/" MPI_INCLUDE_PATH ${MPI_INCLUDE_PATH})
+
+ # Extract linker paths from the link command line
+ string(REGEX MATCH "-L([^\" ]+|\"[^\"]+\")" MPI_LINK_PATH ${MPI_LINK_CMDLINE})
+ string(REGEX REPLACE "^-L" "" MPI_LINK_PATH ${MPI_LINK_PATH})
+ string(REGEX REPLACE "//" "/" MPI_LINK_PATH ${MPI_LINK_PATH})
+
+ # Extract linker flags from the link command line
+ string(REGEX MATCHALL "-Wl,([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS ${MPI_LINK_CMDLINE})
+ set(MPI_LINK_FLAGS_WORK)
+ foreach(FLAG ${MPI_ALL_LINK_FLAGS})
+ if (MPI_LINK_FLAGS_WORK)
+ set(MPI_LINK_FLAGS_WORK "${MPI_LINK_FLAGS_WORK} ${FLAG}")
+ else(MPI_LINK_FLAGS_WORK)
+ set(MPI_LINK_FLAGS_WORK ${FLAG})
+ endif(MPI_LINK_FLAGS_WORK)
+ endforeach(FLAG)
+
+ # Extract the set of libraries to link against from the link command
+ # line
+ string(REGEX MATCHALL "-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES ${MPI_LINK_CMDLINE})
+
+ # Determine full path names for all of the libraries that one needs
+ # to link against in an MPI program
+ set(MPI_LIBRARIES)
+ foreach(LIB ${MPI_LIBNAMES})
+ string(REGEX REPLACE "^-l" "" LIB ${LIB})
+ set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
+ find_library(MPI_LIB ${LIB} PATHS ${MPI_LINK_PATH})
+ if (MPI_LIB)
+ list(APPEND MPI_LIBRARIES ${MPI_LIB})
+ else (MPI_LIB)
+ status(ERROR "Unable to find MPI library ${LIB}")
+ endif (MPI_LIB)
+ endforeach(LIB)
+ set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI detection" FORCE)
+
+ # Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and
+ # MPI_EXTRA_LIBRARY.
+ list(LENGTH MPI_LIBRARIES MPI_NUMLIBS)
+ if (MPI_NUMLIBS GREATER 0)
+ list(GET MPI_LIBRARIES 0 MPI_LIBRARY)
+ else (MPI_NUMLIBS GREATER 0)
+ set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND")
+ endif (MPI_NUMLIBS GREATER 0)
+ if (MPI_NUMLIBS GREATER 1)
+ cdr(MPI_EXTRA_LIBRARY ${MPI_LIBRARIES})
+ else (MPI_NUMLIBS GREATER 1)
+ set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND")
+ endif (MPI_NUMLIBS GREATER 1)
+
+ # Set up all of the appropriate cache entries
+ set(MPI_FOUND TRUE CACHE INTERNAL "Whether MPI was found" FORCE)
+
+ if (NOT MPI_FORCE_RECONFIGURE)
+ set(MPI_COMPILE_FLAGS ${MPI_COMPILE_FLAGS_WORK} CACHE STRING "MPI compilation flags")
+ set(MPI_INCLUDE_PATH ${MPI_INCLUDE_PATH} CACHE STRING "MPI include path")
+ set(MPI_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI linking flags")
+ set(MPI_LIBRARIES ${MPI_LIBRARIES} CACHE STRING "MPI libraries to link against, separated by semicolons")
+ else (NOT MPI_FORCE_RECONFIGURE)
+ set(MPI_COMPILE_FLAGS ${MPI_COMPILE_FLAGS_WORK} CACHE STRING "MPI compilation flags" FORCE)
+ set(MPI_INCLUDE_PATH ${MPI_INCLUDE_PATH} CACHE STRING "MPI include path" FORCE)
+ set(MPI_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI linking flags" FORCE)
+ set(MPI_LIBRARIES ${MPI_LIBRARIES} CACHE STRING "MPI libraries to link against, separated by semicolons" FORCE)
+ endif (NOT MPI_FORCE_RECONFIGURE)
+else (MPI_COMPILE_CMDLINE)
+ find_path(MPI_INCLUDE_PATH mpi.h
+ /usr/local/include
+ /usr/include
+ /usr/include/mpi
+ /usr/local/mpi/include
+ "C:/Program Files/MPICH/SDK/Include"
+ "C:/Program Files/Microsoft Compute Cluster Pack/Include"
+ )
+
+ # TODO: How do we know whether we're building 32-bit vs. 64-bit?
+ find_library(MPI_LIBRARY
+ NAMES mpi mpich
+ PATHS /usr/lib /usr/local/lib /usr/local/mpi/lib
+ "C:/Program Files/MPICH/SDK/Lib"
+ "C:/Program Files/Microsoft Compute Cluster Pack/Lib/i386"
+ )
+
+ find_library(MPI_EXTRA_LIBRARY
+ NAMES mpi++
+ PATHS /usr/lib /usr/local/lib /usr/local/mpi/lib
+ "C:/Program Files/MPICH/SDK/Lib"
+ "C:/Program Files/Microsoft Compute Cluster Pack/Lib/i386"
+ DOC "If a second MPI library is necessary, specify it here.")
+
+ set(MPI_COMPILE_FLAGS "" CACHE STRING "MPI compilation flags")
+ set(MPI_LINK_FLAGS "" CACHE STRING "MPI linking flags")
+
+ if (MPI_EXTRA_LIBRARY)
+ set(MPI_LIBRARIES "${MPI_LIBRARY};${MPI_EXTRA_LIBRARY}" CACHE STRING "MPI libraries to link against, separated by semicolons")
+ else (MPI_EXTRA_LIBRARY)
+ set(MPI_LIBRARIES ${MPI_LIBRARY} CACHE STRING "MPI libraries to link against, separated by semicolons")
+ endif (MPI_EXTRA_LIBRARY)
+
+ if (MPI_LIBRARY)
+ set(MPI_FOUND TRUE CACHE INTERNAL "Whether MPI was found" FORCE)
+ else (MPI_LIBRARY)
+ set(MPI_FOUND FALSE CACHE INTERNAL "Whether MPI was found" FORCE)
+ endif (MPI_LIBRARY)
+endif (NOT MPI_FORCE_RECONFIGURE)
+
+set(MPI_LIBRARY ${MPI_LIBRARY} CACHE INTERNAL "MPI library to link against. Deprecated: use MPI_LIBRARIES instead")
+set(MPI_EXTRA_LIBRARY ${MPI_EXTRA_LIBRARY} CACHE INTERNAL "Second MPI library to link against. Deprecated: use MPI_LIBRARIES instead")
+
+mark_as_advanced(MPI_INCLUDE_PATH MPI_COMPILE_FLAGS MPI_LINK_FLAGS MPI_LIBRARIES)
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk