Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MPI option to AXL #129

Merged
merged 3 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#
# TODO: Add MPI for CI
#
slurm-job:
tags:
- quartz
Expand Down
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
INCLUDE(GNUInstallDirs)

# Configuration Options
OPTION(MPI "Enable MPI operations for AXL" OFF)
MESSAGE(STATUS "MPI: ${MPI}")

OPTION(BUILD_SHARED_LIBS "Whether to build shared libraries" ON)
MESSAGE(STATUS "BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")

Expand Down Expand Up @@ -45,6 +48,21 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")

LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

## MPI
IF(MPI)
INCLUDE(SetupMPI)
IF(MPI_C_FOUND)
INCLUDE_DIRECTORIES(${MPI_C_INCLUDE_PATH})
LIST(APPEND AXL_EXTERNAL_LIBS ${MPI_C_LIBRARIES})
ELSE(MPI_C_FOUND)
MESSAGE(FATAL_ERROR
"Could not find MPI! "
"Either add an MPI compiler to your path "
"or force CMake to build using the correct compiler (`export CC=mpicc`). "
"To disable MPI, set -DMPI=OFF")
ENDIF(MPI_C_FOUND)
ENDIF(MPI)

## KVTREE
FIND_PACKAGE(KVTREE REQUIRED)
IF(KVTREE_FOUND)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Some useful CMake command line options:

- `-DCMAKE_INSTALL_PREFIX=[path]`: Place to install the AXL library
- `-DCMAKE_BUILD_TYPE=[Debug/Release]`: Build with debugging or optimizations
- `-DMPI`: Build with support for MPI movement of kvtree objects
mcfadden8 marked this conversation as resolved.
Show resolved Hide resolved

For building with IBM BB API (optional):

Expand All @@ -39,6 +40,7 @@ For building with IBM BB API (optional):
- C
- CMake, Version 2.8+
- [KVTree](https://github.com/LLNL/KVTree)
- MPI (optional)

## Authors

Expand Down
77 changes: 77 additions & 0 deletions cmake/SetupMPI.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
###############################################################################
# Copyright (c) 2017, Lawrence Livermore National Security, LLC.
#
# Produced at the Lawrence Livermore National Laboratory
#
# LLNL-CODE-725085
#
# All rights reserved.
#
# This file is part of BLT.
#
# For additional details, please also read BLT/LICENSE.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the disclaimer below.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the disclaimer (as noted below) in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the name of the LLNS/LLNL nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
# LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
###############################################################################

################################
# MPI
################################

find_package(MPI)
message(STATUS "MPI C Compile Flags: ${MPI_C_COMPILE_FLAGS}")
message(STATUS "MPI C Include Path: ${MPI_C_INCLUDE_PATH}")
message(STATUS "MPI C Link Flags: ${MPI_C_LINK_FLAGS}")
message(STATUS "MPI C Libraries: ${MPI_C_LIBRARIES}")

message(STATUS "MPI CXX Compile Flags: ${MPI_CXX_COMPILE_FLAGS}")
message(STATUS "MPI CXX Include Path: ${MPI_CXX_INCLUDE_PATH}")
message(STATUS "MPI CXX Link Flags: ${MPI_CXX_LINK_FLAGS}")
message(STATUS "MPI CXX Libraries: ${MPI_CXX_LIBRARIES}")

message(STATUS "MPI Executable: ${MPIEXEC}")
message(STATUS "MPI Num Proc Flag: ${MPIEXEC_NUMPROC_FLAG}")


if (ENABLE_FORTRAN)
# Determine if we should use fortran mpif.h header or fortran mpi module
find_path(mpif_path
NAMES "mpif.h"
PATHS ${MPI_Fortran_INCLUDE_PATH}
NO_DEFAULT_PATH
)

if(mpif_path)
set(MPI_Fortran_USE_MPIF ON CACHE PATH "")
message(STATUS "Using MPI Fortran header: mpif.h")
else()
set(MPI_Fortran_USE_MPIF OFF CACHE PATH "")
message(STATUS "Using MPI Fortran module: mpi.mod")
endif()
endif()
13 changes: 10 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
###########

# Install header files
LIST(APPEND libaxl_install_headers
axl.h
)
LIST(APPEND libaxl_install_headers axl.h)

IF(MPI_FOUND)
LIST(APPEND libaxl_install_headers axl_mpi.h)
ENDIF(MPI_FOUND)

INSTALL(FILES ${libaxl_install_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

LIST(APPEND libaxl_srcs
Expand All @@ -19,6 +22,10 @@ LIST(APPEND libaxl_srcs
axl_util.c
)

IF(MPI_FOUND)
LIST(APPEND libaxl_srcs axl_mpi.c)
ENDIF(MPI_FOUND)

IF(HAVE_PTHREADS)
LIST(APPEND libaxl_srcs axl_pthread.c)
ENDIF(HAVE_PTHREADS)
Expand Down
Loading