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
8 changes: 4 additions & 4 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
fetch-depth: 0
- uses: cachix/install-nix-action@v13
with:
nix_path: nixpkgs=channel:nixos-20.09
nix_path: nixpkgs=channel:nixos-24.05
- run: nix-build -A aml
distcheck:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -190,7 +190,7 @@ jobs:
run:
shell: bash
container:
image: nvcr.io/nvidia/nvhpc:24.7-devel-cuda12.5-ubuntu22.04
image: nvcr.io/nvidia/nvhpc:24.7-devel-cuda12.5-ubuntu24.04
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -202,11 +202,11 @@ jobs:
echo "0.8.0" > .tarball-version
- name: build
run: |
source /usr/share/lmod/6.6/init/bash
source /usr/share/lmod/lmod/init/bash
module load nvhpc
./autogen.sh
mkdir build
./configure --prefix=`pwd`/build --with-cuda CUDA_HOME=$NVHPC_ROOT/cuda
./configure --prefix=`pwd`/build --without-hwloc --with-cuda CUDA_HOME=$NVHPC_ROOT/cuda
make
make check
make install
Expand Down
60 changes: 59 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects 1.12])
AC_LANG([C])
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AC_PROG_CC_C99
AM_PROG_CC_C_O
AC_PROG_CPP
AC_TYPE_SIZE_T
Expand Down Expand Up @@ -141,6 +140,57 @@ else
fi
AC_SUBST(OPENMP_LIBS)

# MPI support
#############

AC_ARG_WITH([mpi],
[AS_HELP_STRING([--with-mpi],
[support mpi inside the library (default is check)])],
[
if test "x$withval" = "xno"; then
want_mpi="no"
else
want_mpi="yes"
fi
],
[
want_mpi="check"
])

MPI_CFLAGS=""
MPI_LIBS=""
if test "x$want_mpi" != "xno"; then
AC_MSG_NOTICE([starting checks for MPI])
AC_CHECK_PROGS(MPICC, mpicc hcc mpxlc_r mpxlc mpcc cmpicc, no)

if test "x$MPICC" = "xno"; then
AC_MSG_NOTICE([No MPI compiler found])
if test "x$want_mpi" = "xyes"; then
AC_MSG_ERROR([MPI compiler (mpicc) not found but --with-mpi was requested])
fi

have_mpi=0
else
MPI_CC_SHOW=`$MPICC -show 2>/dev/null`
for arg in $MPI_CC_SHOW; do
case "$arg" in
-I*|-D*|-std=*|-f*) MPI_CFLAGS="$MPI_CFLAGS $arg" ;;
-L*|-l*|-Wl,*|-W*) MPI_LIBS="$MPI_LIBS $arg" ;;
*) ;; # Skip compiler name or unknown args
esac
done
have_mpi=1
CC="$MPICC"
fi
fi

AC_SUBST([MPI_CFLAGS])
AC_SUBST([MPI_LIBS])
AC_SUBST([MPICC])
AC_SUBST([HAVE_MPI],[$have_mpi])
AC_DEFINE_UNQUOTED([HAVE_MPI], [$have_mpi], [Whether aml supports MPI.])
AM_CONDITIONAL([HAVE_MPI], [test "$have_mpi" == "1"])

# NUMA support
##############

Expand Down Expand Up @@ -450,6 +500,14 @@ Active: $HAVE_OPENMP
CFLAGS: $OPENMP_CFLAGS
LDFLAGS: $OPENMP_LIBS

MPI:
======

Active: $HAVE_MPI
MPICC: $MPICC
CFLAGS: $MPI_CFLAGS
LDFLAGS: $MPI_LIBS

HWLOC:
======

Expand Down
5 changes: 5 additions & 0 deletions include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ include_aml_area_HEADERS += aml/area/hip.h
include_aml_dma_HEADERS += aml/dma/hip.h
endif

if HAVE_MPI
include_aml_area_HEADERS += aml/area/mpi.h
include_aml_backend_HEADERS += aml/utils/backend/mpi.h
endif

if HAVE_OPENCL
include_aml_area_HEADERS += aml/area/opencl.h
endif
Expand Down
139 changes: 139 additions & 0 deletions include/aml/area/mpi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/*******************************************************************************
* Copyright 2019 UChicago Argonne, LLC.
* (c.f. AUTHORS, LICENSE)
*
* This file is part of the AML project.
* For more info, see https://github.com/anlsys/aml
*
* SPDX-License-Identifier: BSD-3-Clause
******************************************************************************/

#ifndef AML_AREA_MPI_H
#define AML_AREA_MPI_H

#ifdef __cplusplus
extern "C" {
#endif

#include <mpi.h>

/**
* @defgroup aml_area_mpi "AML MPI Areas"
* @brief MPI RDMA Implementation of AML Areas.
*
* This building block relies on the MPI One-sided operations to implement
* allocations.
*
* @code
* #include <aml/area/mpi.h>
* @endcode
* @{
**/

/**
* Options that can eventually be passed to mmap
* call.
**/
struct aml_area_mpi_mmap_options {
/**
* Specify the communicator for an allocation.
**/
MPI_Comm comm;
/**
* Specify the info for an allocation.
**/
MPI_Info info;
/**
* Return variable for the underlying window.
**/
MPI_Win win;
/**
* Unit displacement (in bytes)
**/
int disp;
};

/**
* Contains area operations implementation
* for the MPI area.
**/
extern struct aml_area_ops aml_area_mpi_ops;

/**
* Default MPI area:
* Uses COMM_WORLD and allocates every time.
* Can be used out-of-the-box with aml_area_*() functions.
**/
extern struct aml_area aml_area_mpi;

/**
* Implementation of aml_area_data for MPI areas.
**/
struct aml_area_mpi_data {
/** hash table keeping track of windows **/
struct aml_area_mpi_window *windows;
};

/**
* \brief MPI area creation.
*
* Allocates and initializes struct aml_area implemented by aml_area_mpi
* operations.
* @param[out] area pointer to an uninitialized struct aml_area pointer to
* receive the new area.
* @return On success, returns 0 and fills "area" with a pointer to the new
* aml_area.
* @return On failure, fills "area" with NULL and returns one of AML error
* codes:
* - AML_ENOMEM if there wasn't enough memory available.
**/
int aml_area_mpi_create(struct aml_area **area);

/**
* \brief MPI area destruction.
*
* Destroys (finalizes and frees resources) struct aml_area created by
* aml_area_mpi_create().
*
* @param area address of an initialized struct aml_area pointer, which will be
* reset to NULL on return from this call.
**/
void aml_area_mpi_destroy(struct aml_area **area);

/**
* \brief mmap block for AML area.
*
* This function is a wrapper around the MPI_Win_allocate call using arguments
* set in opts.
* @param area_data: An aml_area_mpi_data.
* @param size: The size to allocate.
* @param opts: See "aml_area_mpi_mmap_options".
* @return a valid memory pointer, or NULL on failure.
* On failure, "errno" should be checked for further information.
**/
void *aml_area_mpi_mmap(const struct aml_area_data *area_data,
size_t size,
struct aml_area_mmap_options *opts);

/**
* \brief munmap hook for AML area.
*
* Unmaps memory mapped with aml_area_mpi_mmap().
* @param area_data: unused
* @param ptr: The virtual memory to unmap.
* @param size: The size of the virtual memory to unmap.
* @return AML_SUCCESS on success, else AML_FAILURE.
* On failure, "errno" should be checked for further information.
**/
int aml_area_mpi_munmap(const struct aml_area_data *area_data,
void *ptr,
const size_t size);

/**
* @}
**/

#ifdef __cplusplus
}
#endif
#endif // AML_AREA_MPI_H
50 changes: 50 additions & 0 deletions include/aml/utils/backend/mpi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*******************************************************************************
* Copyright 2019 UChicago Argonne, LLC.
* (c.f. AUTHORS, LICENSE)
*
* This file is part of the AML project.
* For more info, see https://github.com/anlsys/aml
*
* SPDX-License-Identifier: BSD-3-Clause
******************************************************************************/

#ifndef AML_UTILS_BACKEND_MPI_H
#define AML_UTILS_BACKEND_MPI_H

#ifdef __cplusplus
extern "C" {
#endif

/**
* @defgroup aml_backend_mpi "AML MPI Utils"
* @brief Boilerplate Code and Initialization for MPI Backend.
* @code
* #include <aml/utils/backend/mpi.h>
* @endcode
*
* @{
**/

/**
* MPI backend initialization function.
* This function should only be called once.
* This function should not fail unless the system is out of memory.
*
* @return AML_SUCCESS on success.
* @return -AML_ENOMEM on error.
*/
int aml_backend_mpi_init(void);

/**
* linux backend initialization function.
*/
int aml_backend_mpi_finalize(void);

/**
* @}
**/

#ifdef __cplusplus
}
#endif
#endif // AML_UTILS_BACKEND_MPI_H
16 changes: 10 additions & 6 deletions include/aml/utils/features.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,23 @@
#define AML_HAVE_BACKEND_ZE @HAVE_ZE@
/** Whether aml had hip capabilities at compile time **/
#define AML_HAVE_BACKEND_HIP @HAVE_HIP@
/** Whether aml had mpi capabilities at compile time **/
#define AML_HAVE_BACKEND_MPI @HAVE_MPI@

/** Flag for checking runtime suport for libnuma **/
/** Flag for checking runtime support for libnuma **/
#define AML_BACKEND_LIBNUMA (1UL<<1)
/** Flag for checking runtime suport for cuda **/
/** Flag for checking runtime support for cuda **/
#define AML_BACKEND_CUDA (1UL<<2)
/** Flag for checking runtime suport for hwloc **/
/** Flag for checking runtime support for hwloc **/
#define AML_BACKEND_HWLOC (1UL<<3)
/** Flag for checking runtime suport for opencl **/
/** Flag for checking runtime support for opencl **/
#define AML_BACKEND_OPENCL (1UL<<4)
/** Flag for checking runtime suport for level zero **/
/** Flag for checking runtime support for level zero **/
#define AML_BACKEND_ZE (1UL<<5)
/** Flag for checking runtime suport for hip **/
/** Flag for checking runtime support for hip **/
#define AML_BACKEND_HIP (1UL<<6)
/** Flag for checking runtime support for mpi **/
#define AML_BACKEND_MPI (1UL<<7)

/**
* Check if a set of backends can be used at runtime.
Expand Down
Loading