Skip to content
Snippets Groups Projects
Commit 624d6559 authored by Markus Blatt's avatar Markus Blatt
Browse files

Use MPI in the DUNE way (deactivating the CXX bindings using

the ENABLE trick).
Added an utility cmake function to add the necessary flags for
compilation and linking.

[[Imported from SVN: r6614]]
parent 5a8519fd
No related branches found
No related tags found
No related merge requests found
......@@ -16,8 +16,8 @@ set(DUNE_COMMON_VERSION_MAJOR "${DUNE_VERSION_MAJOR}")
set(DUNE_COMMON_VERSION_MINOR "${DUNE_VERSION_MINOR}")
set(DUNE_COMMON_VERSION_REVISION "${DUNE_VERSION_REVISION}")
message("DUNE_USE_ONLY_STATIC_LIB ${DUNE_USE_ONLY_STATIC_LIB}")
option("DUNE_USE_ONLY_STATIC_LIBS" "If set to ON, we will force static linkage everywhere")
message("DUNE_USE_ONLY_STATIC_LIBS ${DUNE_USE_ONLY_STATIC_LIBS}")
if(DUNE_USE_ONLY_STATIC_LIBS)
# Use only static libraries.
# We do this by overriding the library suffixes.
......@@ -37,7 +37,7 @@ include(DuneStreams)
dune_set_minimal_debug_level()
# include dune-common and current directory to include pathtest
include_directories("${CMAKE_SOURCE_DIR}" ".")
include_directories("${CMAKE_SOURCE_DIR}")
link_directories("${CMAKE_SOURCE_DIR}/lib")
# set required compiler flags for C++11 (former C++0x)
......@@ -52,13 +52,8 @@ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -DHAVE_MEMORY=${HAVE_MEMORY}")
# search for packages
find_package(PkgConfig)
find_package(MPI)
if(MPI_FOUND)
set(HAVE_MPI MPI_CXX_FOUND)
add_definitions("${MPI_CXX_COMPILE_FLAGS}")
#add_definitions("-DENABLE_MPI=1")
include_directories(${MPI_CXX_INCLUDE_PATH})
endif(MPI_FOUND)
include(DUNEMPI)
find_package(Boost)
set(HAVE_BOOST BOOST_FOUND)
......@@ -70,6 +65,7 @@ set(HAVE_LAPACK LAPACK_FOUND)
# make calling fortran routines from C/C++ possible
include(FortranCInterface)
FortranCInterface_VERIFY(CXX)
FortranCInterface_HEADER(FC.h MACRO_NAMESPACE "FC_")
# actually write the config.h file to disk
......
find_package(MPI)
find_package(Threads)
if(MPI_FOUND)
set(HAVE_MPI MPI_CXX_FOUND)
# We do not support the CXX bindings of MPI
set(MPI_DUNE_COMPILE_FLAGS ${MPI_C_COMPILE_FLAGS} CACHE STRING
"Compile flags used by DUNE when compiling MPI programs")
set(MPI_DUNE_INCLUDE_PATH ${MPI_C_INCLUDE_PATH} CACHE STRING
"Include path used by DUNE when compiling MPI programs")
# There seems to be no target specific include path, use the global one.
include_directories(${MPI_DUNE_INCLUDE_PATH})
set(MPI_DUNE_LINK_FLAGS ${MPI_C_LINK_FLAG} CACHE STRING
"Link flags used by DUNE when compiling MPI programs")
set(MPI_DUNE_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${MPI_C_LIBRARIES} CACHE STRING
"Libraries used by DUNE when linking MPI programs")
# Check whether the MPI-2 standard is supported
include(CMakePushCheckState)
include(CheckFunctionExists)
cmake_push_check_state()
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES};${MPI_DUNE_LIBRARIES})
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} "-DENABLE_MPI=1 -DMPICH_SKIP_MPICXX -DMPIPP_H")
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES};${MPI_DUNE_INCLUDE_PATH})
check_function_exists(MPI_Finalized MPI_2)
cmake_pop_check_state()
endif(MPI_FOUND)
# A macro that adds the MPI flags for the compilation
function(add_DUNE_MPI_flags _target)
if(MPI_FOUND)
target_link_libraries(${_target} ${MPI_DUNE_LIBRARIES})
# The definitions are a hack as we do not seem to know which MPI implementation was
# found.
SET_TARGET_PROPERTIES(${_target} PROPERTIES COMPILE_FLAGS ${MPI_DUNE_COMPILE_FLAGS}
"-DENABLE_MPI=1 -DMPICH_SKIP_MPICXX -DMPIPP_H")
SET_TARGET_PROPERTIES(${_target} PROPERTIES LINK_FLAGS ${MPI_DUNE_LINK_FLAGS} "")
#SET_TARGET_PROPERTIES(indicestest PROPERTIES INCLUDE_PATH ${MPI_CC_INCLUDE_PATH})
endif(MPI_FOUND)
endfunction()
......@@ -57,7 +57,9 @@
/* Define to 1 if you have the <malloc.h> header file. */
// Not used! #cmakedefine01 HAVE_MALLOC_H
#cmakedefine01 HAVE_MPI
#cmakedefine HAVE_MPI ENABLE_MPI
/* Define to 1 if the MPI2 Standard is supported */
#cmakedefine01 MPI_2
#cmakedefine01 HAVE_BOOST
......
......@@ -4,28 +4,22 @@ set(MPITESTPROGS indicestest indexsettest syncertest selectiontest)
# but just build them on demand
add_dependencies(build_tests ${MPITESTPROGS})
add_executable("indexsettest" indexsettest.cc)
target_link_libraries("indexsettest" "dunecommon")
target_link_libraries("indexsettest" "dunecommon" ${CMAKE_THREAD_LIBS_INIT} ${})
include(DUNEMPI)
add_executable("indicestest" indicestest.cc)
target_link_libraries("indicestest" "dunecommon")
if(MPI_FOUND)
target_link_libraries(indicestest ${MPI_CXX_LIBRARIES})
endif(MPI_FOUND)
add_DUNE_MPI_flags(indicestest)
add_executable("selectiontest" selectiontest.cc)
target_link_libraries("selectiontest" "dunecommon")
if(MPI_FOUND)
target_link_libraries(selectiontest ${MPI_CXX_LIBRARIES})
endif(MPI_FOUND)
add_DUNE_MPI_flags(selectiontest)
#add_executable("syncertest" syncertest.cc)
#if(MPI_FOUND)
# target_link_libraries(syncertest ${MPI_CXX_LIBRARIES})
#endif(MPI_FOUND)
add_executable("syncertest" syncertest.cc)
target_link_libraries("syncertest" "dunecommon")
add_DUNE_MPI_flags(syncertest)
add_test(indexsettest indexsettest)
add_test(selectiontest selectiontest)
if(MPI_CXX_FOUND)
add_test(indicestest indicestest)
#add_test(syncertest syncertest)
endif(MPI_CXX_FOUND)
add_test(indicestest indicestest)
add_test(syncertest syncertest)
......@@ -94,25 +94,21 @@ add_executable("iteratorfacadetest" iteratorfacadetest.cc)
add_executable("lrutest" lrutest.cc)
add_executable("mpiguardtest" mpiguardtest.cc)
target_link_libraries("mpiguardtest" "dunecommon")
if(MPI_FOUND)
target_link_libraries(mpiguardtest ${MPI_CXX_LIBRARIES})
endif(MPI_FOUND)
add_DUNE_MPI_flags(mpiguardtest)
add_executable("mpicollectivecommunication" mpicollectivecommunication.cc)
target_link_libraries(mpicollectivecommunication "dunecommon")
if(MPI_FOUND)
target_link_libraries(mpicollectivecommunication ${MPI_CXX_LIBRARIES})
endif(MPI_FOUND)
add_DUNE_MPI_flags(mpicollectivecommunication)
add_executable("mpihelpertest" mpihelpertest.cc)
target_link_libraries(mpihelpertest "dunecommon")
if(MPI_FOUND)
target_link_libraries(mpihelpertest ${MPI_CXX_LIBRARIES})
endif(MPI_FOUND)
add_DUNE_MPI_flags(mpihelpertest)
add_executable("mpihelpertest2" mpihelpertest.cc)
target_link_libraries(mpihelpertest2 "dunecommon")
if(MPI_FOUND)
target_link_libraries(mpihelpertest2 ${MPI_CXX_LIBRARIES})
endif(MPI_FOUND)
add_DUNE_MPI_flags(mpihelpertest2)
set_target_properties(mpihelpertest2 PROPERTIES COMPILE_FLAGS "-DMPIHELPER_PREINITIALIZE")
add_executable("nullptr_test" nullptr-test.cc nullptr-test2.cc)
target_link_libraries(nullptr_test "dunecommon")
add_executable("nullptr_test_fail" EXCLUDE_FROM_ALL nullptr-test.cc)
......@@ -204,9 +200,7 @@ add_test(gcdlcmtest gcdlcmtest)
add_test(iteratorfacadetest iteratorfacadetest)
add_test(iteratorfacadetest2 iteratorfacadetest2)
add_test(lrutest lrutest)
if(MPI_CXX_FOUND)
add_test(mpicollectivecommunication mpicollectivecommunication)
endif(MPI_CXX_FOUND)
add_test(mpicollectivecommunication mpicollectivecommunication)
add_test(mpiguardtest mpiguardtest)
add_test(mpihelpertest mpihelpertest)
add_test(mpihelpertest2 mpihelpertest2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment