Skip to content

Commit

Permalink
Update MPI build
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbuurlage committed Nov 1, 2018
1 parent 8e80a09 commit 3dee0e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
31 changes: 16 additions & 15 deletions backends/mpi/build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,46 @@ cmake_minimum_required(VERSION 3.0.0)

set(BACKEND_NAME mpi)
project(bulk_${BACKEND_NAME})

find_package(MPI QUIET)

if(MPI_CXX_FOUND)
include_directories(
"../../../include"
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Wfatal-errors -Wextra -Werror -g -O3")
add_library(bulk_mpi INTERFACE)
target_include_directories(bulk_mpi INTERFACE ".." ${MPI_INCLUDE_PATH})
target_compile_options(bulk_mpi INTERFACE ${MPI_COMPILE_FLAGS})
target_link_libraries(bulk_mpi INTERFACE ${MPI_LIBRARIES} bulk)
target_compile_definitions(bulk_mpi INTERFACE BACKEND_MPI)

add_custom_target(${BACKEND_NAME})
add_definitions(-DBACKEND_MPI)

set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS})
include_directories(${MPI_INCLUDE_PATH})

foreach(source_file ${EXAMPLE_SOURCES})
string(REPLACE ".cpp" "" source_name ${source_file})
add_executable(${BACKEND_NAME}_${source_name} ${EXAMPLE_DIR}${source_file})
target_link_libraries(${BACKEND_NAME}_${source_name} ${MPI_LIBRARIES})
target_link_libraries(${BACKEND_NAME}_${source_name} bulk_mpi)
target_compile_options(${BACKEND_NAME}_${source_name} PRIVATE ${BULK_SUGGESTED_COMPILE_OPTIONS})
add_dependencies(${BACKEND_NAME} ${BACKEND_NAME}_${source_name})
endforeach(source_file)

# PSC example

add_executable(${BACKEND_NAME}_psc "../../../examples/psc/psc_example.cpp")
target_link_libraries(${BACKEND_NAME}_psc bulk_thread)
target_link_libraries(${BACKEND_NAME}_psc bulk_mpi)
target_include_directories(${BACKEND_NAME}_psc PRIVATE "../../../examples/psc/include")
target_compile_options(${BACKEND_NAME}_psc PRIVATE ${BULK_SUGGESTED_COMPILE_OPTIONS})
add_dependencies(${BACKEND_NAME} ${BACKEND_NAME}_psc)

# Benchmark executable

add_executable(${BACKEND_NAME}_benchmark "../../../benchmark/benchmark.cpp")
target_link_libraries(${BACKEND_NAME}_benchmark ${MPI_LIBRARIES})
target_link_libraries(${BACKEND_NAME}_benchmark bulk_mpi)
target_compile_options(${BACKEND_NAME}_benchmark PRIVATE ${BULK_SUGGESTED_COMPILE_OPTIONS})
add_dependencies(${BACKEND_NAME} ${BACKEND_NAME}_benchmark)

# Bulk tests that work for any backend

add_executable(${BACKEND_NAME}_unittests ${TEST_SOURCES})
target_link_libraries(${BACKEND_NAME}_unittests ${MPI_LIBRARIES})
target_link_libraries(${BACKEND_NAME}_unittests bulk_mpi)
target_compile_options(${BACKEND_NAME}_unittests PRIVATE ${BULK_SUGGESTED_COMPILE_OPTIONS})
add_dependencies(${BACKEND_NAME} ${BACKEND_NAME}_unittests)

# Examples specific for mpi backend
Expand All @@ -58,7 +58,8 @@ if(MPI_CXX_FOUND)
foreach(source_file ${MPI_EXAMPLE_SOURCES})
string(REPLACE ".cpp" "" source_name ${source_file})
add_executable(${BACKEND_NAME}_${source_name} ${MPI_EXAMPLE_DIR}${source_file})
target_link_libraries(${BACKEND_NAME}_${source_name} ${MPI_LIBRARIES})
target_link_libraries(${BACKEND_NAME}_${source_name} bulk_mpi)
target_compile_options(${BACKEND_NAME}_${source_name} PRIVATE ${BULK_SUGGESTED_COMPILE_OPTIONS})
add_dependencies(${BACKEND_NAME} ${BACKEND_NAME}_${source_name})
endforeach(source_file)

Expand Down
2 changes: 1 addition & 1 deletion backends/thread/build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ project(bulk_${BACKEND_NAME})
add_library(bulk_thread INTERFACE)
target_include_directories(bulk_thread INTERFACE "..")
target_link_libraries(bulk_thread INTERFACE pthread bulk)
target_compile_definitions(bulk_thread INTERFACE BACKEND_THREAD)

add_custom_target(${BACKEND_NAME})
add_definitions(-DBACKEND_THREAD)

include_directories(
"../../../include"
Expand Down

0 comments on commit 3dee0e6

Please sign in to comment.