Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 43 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 99)

# Add warning flags to help with debugging
set(CMAKE_C_FLAGS "-Wall -Wextra -Wpedantic -Wshadow")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -Wshadow")
string(TOLOWER ${CMAKE_BUILD_TYPE} build_type)
message(STATUS "Build type: ${CMAKE_BUILD_TYPE} -> ${build_type}")
if(build_type STREQUAL "debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -Wshadow")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wshadow")
endif()

# Build Options
option(USE_CUDA "Enable NVIDIA CUDA support" OFF)
Expand All @@ -22,26 +26,15 @@ set(MPICXX "mpicxx" CACHE STRING "MPICXX command")
set(MPIRUN "mpirun" CACHE STRING "MPIRUN command")
set(CUDA_ARCH "75" CACHE STRING "CUDA Architecture")

include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")

# Find MPI
find_package(MPI REQUIRED)
if (MPI_COMPILER_FLAGS)
add_compile_options(${MPI_COMPILER_FLAGS})
endif()
include_directories(${MPI_INCLUDE_PATH})
set(EXTERNAL_LIBS ${MPI_LIBRARIES})
set(EXTERNAL_LIBS "MPI::MPI_CXX")

# Find OpenMP (not required)
find_package(OpenMP)
if (${OpenMP_CXX_FOUND})
# Add OpenMP flags to compile options
add_compile_options(${OpenMP_CXX_FLAGS})

set(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${OpenMP_CXX_LIBRARIES})
list(APPEND EXTERNAL_LIBS "OpenMP::OpenMP_CXX")
add_definitions(-DOPENMP)
message(STATUS "Found OpenMP ${OpenMP_CXX_LIBRARIES}")
endif()

# Set default language of .cpp files
Expand Down Expand Up @@ -71,14 +64,9 @@ elseif (USE_HIP)
endif()
endif()

add_subdirectory(src/utils)
add_subdirectory(src/communicator)
add_subdirectory(src/persistent)
add_subdirectory(src/collective)
add_subdirectory(src/neighborhood)
if(USE_CUDA OR USE_HIP)
add_subdirectory(src/heterogeneous)
endif()
message(STATUS "Compiling all files as: ${locality_aware_LANG}")

add_subdirectory(src)

set_source_files_properties(
${utils_SOURCES}
Expand All @@ -97,30 +85,48 @@ add_library(mpi_advance
${neighborhood_SOURCES} ${neighborhood_HEADERS}
${heterogeneous_SOURCES} ${heterogeneous_HEADERS}
)

set_target_properties(mpi_advance PROPERTIES PUBLIC_HEADER src/mpi_advance.h)

target_include_directories(mpi_advance PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>
)

target_link_libraries(mpi_advance PUBLIC ${EXTERNAL_LIBS})

install(TARGETS mpi_advance
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(TARGETS mpi_advance)

install(FILES src/mpi_advance.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
### Install all headers that locality_aware exports
install(FILES ${utils_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/utils)
install(FILES ${communicator_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/communicator)
install(FILES ${collective_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/collective)
install(FILES ${persistent_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/persistent)
install(FILES ${neighborhood_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/neighborhood)
install(FILES ${heterogeneous_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/heterogeneous)

if (ENABLE_UNIT_TESTS)
enable_testing()
add_subdirectory(src/collective/tests)
add_subdirectory(src/neighborhood/tests)
if (USE_GPU)
add_subdirectory(src/heterogeneous/tests)
endif(USE_GPU)
endif()

add_subdirectory(benchmarks)

### Installation Requirements for Spack Package ###
include(CMakePackageConfigHelpers)

# Install the actual target(s) and register them for export
install(TARGETS mpi_advance
EXPORT mpiadvanceTargets
DESTINATION lib)

# Export the targets into a CMake package
install(EXPORT mpiadvanceTargets
NAMESPACE MPIAdvance::
DESTINATION share/mpiadvance)

configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/locality_aware-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/mpiadvance-config.cmake"
INSTALL_DESTINATION share/mpiadvance)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/mpiadvance-config.cmake"
DESTINATION share/mpiadvance)
############## End of Spack Section ################

Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/mpiadvanceTargets.cmake")

find_package(OpenMP)
find_package(MPI REQUIRED)
22 changes: 0 additions & 22 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include_directories(".")

add_subdirectory(utils)
add_subdirectory(communicator)
add_subdirectory(persistent)
Expand All @@ -9,26 +7,6 @@ if(USE_CUDA OR USE_HIP)
add_subdirectory(heterogeneous)
endif()

set_source_files_properties(
${utils_SOURCES}
${communicator_SOURCES}
${collective_SOURCES}
${persistent_SOURCES}
${neighborhood_SOURCES}
${heterogeneous_SOURCES}
PROPERTIES LANGUAGE ${locality_aware_LANG})

add_library(mpi_advance
${utils_SOURCES} ${utils_HEADERS}
${communicator_SOURCES} ${communicator_HEADERS}
${collective_SOURCES} ${collective_HEADERS}
${persistent_SOURCES} ${persistent_HEADERS}
${neighborhood_SOURCES} ${neighborhood_HEADERS}
${heterogeneous_SOURCES} ${heterogeneous_HEADERS}
)

target_link_libraries(mpi_advance ${MPI_LIBRARIES})

if (ENABLE_UNIT_TESTS)
add_subdirectory(collective/tests)
add_subdirectory(neighborhood/tests)
Expand Down
9 changes: 2 additions & 7 deletions src/collective/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)
file(GLOB collective_HEADERS CONFIGURE_DEPENDS "*.h")
file(GLOB collective_SOURCES CONFIGURE_DEPENDS "*.c")

set_source_files_properties(
${collective_HEADERS} ${collective_SOURCES}
PROPERTIES LANGUAGE ${locality_aware_LANG})

set(collective_HEADERS ${collective_HEADERS} PARENT_SCOPE)
set(collective_SOURCES ${collective_SOURCES} PARENT_SCOPE)
set(collective_HEADERS ${collective_HEADERS} CACHE INTERNAL "All headers for collective files.")
set(collective_SOURCES ${collective_SOURCES} CACHE INTERNAL "All source files for collective directory.")

6 changes: 2 additions & 4 deletions src/communicator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)

file(GLOB communicator_HEADERS CONFIGURE_DEPENDS "*.h")
file(GLOB communicator_SOURCES CONFIGURE_DEPENDS "*.c")

set(communicator_HEADERS ${communicator_HEADERS} PARENT_SCOPE)
set(communicator_SOURCES ${communicator_SOURCES} PARENT_SCOPE)
set(communicator_HEADERS ${communicator_HEADERS} CACHE INTERNAL "All headers for communicator files.")
set(communicator_SOURCES ${communicator_SOURCES} CACHE INTERNAL "All source files for communicator directory.")

6 changes: 2 additions & 4 deletions src/heterogeneous/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)

file(GLOB heterogeneous_HEADERS CONFIGURE_DEPENDS "*.h")
file(GLOB heterogeneous_SOURCES CONFIGURE_DEPENDS "*.c")

set(heterogeneous_HEADERS ${heterogeneous_HEADERS} PARENT_SCOPE)
set(heterogeneous_SOURCES ${heterogeneous_SOURCES} PARENT_SCOPE)
set(heterogeneous_HEADERS ${heterogeneous_HEADERS} CACHE INTERNAL "All headers for heterogeneous files.")
set(heterogeneous_SOURCES ${heterogeneous_SOURCES} CACHE INTERNAL "All source files for heterogeneous directory.")

message(STATUS ${heterogeneous_HEADERS} ${heterogeneous_SOURCES})
6 changes: 2 additions & 4 deletions src/neighborhood/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)

file(GLOB neighborhood_HEADERS CONFIGURE_DEPENDS "*.h")
file(GLOB neighborhood_SOURCES CONFIGURE_DEPENDS "*.c" "*.cpp")

set(neighborhood_HEADERS ${neighborhood_HEADERS} PARENT_SCOPE)
set(neighborhood_SOURCES ${neighborhood_SOURCES} PARENT_SCOPE)
set(neighborhood_HEADERS ${neighborhood_HEADERS} CACHE INTERNAL "All headers for neighborhood files.")
set(neighborhood_SOURCES ${neighborhood_SOURCES} CACHE INTERNAL "All source files for neighborhood directory.")

6 changes: 2 additions & 4 deletions src/persistent/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)

file(GLOB persistent_HEADERS CONFIGURE_DEPENDS "*.h")
file(GLOB persistent_SOURCES CONFIGURE_DEPENDS "*.c")

set(persistent_HEADERS ${persistent_HEADERS} PARENT_SCOPE)
set(persistent_SOURCES ${persistent_SOURCES} PARENT_SCOPE)
set(persistent_HEADERS ${persistent_HEADERS} CACHE INTERNAL "All headers for persistent files.")
set(persistent_SOURCES ${persistent_SOURCES} CACHE INTERNAL "All source files for persistent directory.")

11 changes: 2 additions & 9 deletions src/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)

if (USE_CUDA)
set(gpu_util_HEADERS
src/utils/utils_cuda.h
Expand All @@ -11,17 +9,12 @@ elseif (USE_HIP)
endif()

file(GLOB utils_SOURCES CONFIGURE_DEPENDS "*.cpp")
set(utils_SOURCES ${utils_SOURCES} PARENT_SCOPE)
set(utils_SOURCES ${utils_SOURCES} CACHE INTERNAL "All source files for utils directory.")


set(utils_HEADERS
src/utils/utils.h
${gpu_util_HEADERS}
PARENT_SCOPE
CACHE INTERNAL "All headers for utils files."
)

#set(utils_SOURCES
# src/utils/utils.cpp
# PARENT_SCOPE
# )