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

Backports from master #3860

Closed
Closed
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
19 changes: 15 additions & 4 deletions cmake/DetectOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,11 @@ if(ADIOS2_USE_SST AND NOT WIN32)
endif()
endif()
if(ADIOS2_HAVE_MPI)
set(CMAKE_REQUIRED_LIBRARIES MPI::MPI_C)
include(CheckCSourceRuns)
check_c_source_runs([=[
set(CMAKE_REQUIRED_LIBRARIES "MPI::MPI_C;Threads::Threads")
include(CheckCXXSourceRuns)
check_cxx_source_runs([=[
#include <chrono>
#include <future>
#include <mpi.h>
#include <stdlib.h>

Expand All @@ -419,9 +421,18 @@ if(ADIOS2_USE_SST AND NOT WIN32)

int main()
{
// Timeout after 5 second
auto task = std::async(std::launch::async, []() {
std::this_thread::sleep_for(std::chrono::seconds(5));
exit(EXIT_FAILURE);
});

char* port_name = new char[MPI_MAX_PORT_NAME];
MPI_Init_thread(NULL, NULL, MPI_THREAD_MULTIPLE, NULL);
MPI_Open_port(MPI_INFO_NULL, malloc(sizeof(char) * MPI_MAX_PORT_NAME));
MPI_Open_port(MPI_INFO_NULL, port_name);
MPI_Close_port(port_name);
MPI_Finalize();
exit(EXIT_SUCCESS);
}]=]
ADIOS2_HAVE_MPI_CLIENT_SERVER)
unset(CMAKE_REQUIRED_LIBRARIES)
Expand Down
5 changes: 5 additions & 0 deletions cmake/adios2-config-common.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ endif()

set(ADIOS2_HAVE_Fortran @ADIOS2_HAVE_Fortran@)
set(ADIOS2_HAVE_MPI @ADIOS2_HAVE_MPI@)
set(ADIOS2_HAVE_CUDA @ADIOS2_HAVE_CUDA@)
set(ADIOS2_HAVE_Kokkos @ADIOS2_HAVE_Kokkos@)
set(ADIOS2_HAVE_Kokkos_CUDA @ADIOS2_HAVE_Kokkos_CUDA@)
set(ADIOS2_HAVE_Kokkos_HIP @ADIOS2_HAVE_Kokkos_HIP@)
set(ADIOS2_HAVE_Kokkos_SYCL @ADIOS2_HAVE_Kokkos_SYCL@)

function(adios2_add_thirdparty_target PackageName)
add_library(adios2::thirdparty::${PackageName} INTERFACE IMPORTED)
Expand Down
2 changes: 1 addition & 1 deletion cmake/adios2-config-install.cmake.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.12)

set(_ADIOS2_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}")
Expand Down
2 changes: 1 addition & 1 deletion cmake/install/post/adios2-config-dummy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.12)

project(adios2-config-dummy C CXX)

Expand Down
6 changes: 6 additions & 0 deletions cmake/install/post/generate-adios2-config.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ if [ "${1:0:1}" != "/" ]
then
# Convert relative paths to absolute based on DESTDIR
PREFIX="${DESTDIR:-$(pwd)}/$1"
else
# check if the PREFIX directory exists and prepend DESTDIR if not
if [ ! -d "${PREFIX}" ]
then
PREFIX="${DESTDIR}$1"
fi
fi

shift
Expand Down
66 changes: 20 additions & 46 deletions source/adios2/toolkit/sst/dp/mpi_dp.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
#define QUOTE(name) #name
#define MACRO_TO_STR(name) QUOTE(name)

static pthread_once_t OnceMpiInitializer = PTHREAD_ONCE_INIT;

/*****Stream Basic Structures ***********************************************/

typedef struct _MpiReaderContactInfo
Expand Down Expand Up @@ -249,40 +247,6 @@ static void MpiReadReplyHandler(CManager cm, CMConnection conn, void *msg_v,
static void MpiReadRequestHandler(CManager cm, CMConnection conn, void *msg_v,
void *client_Data, attr_list attrs);

/**
* Initialize MPI in the mode that it is required for MPI_DP to work.
*
* It can be called multiple times.
*/
static void MpiInitialize()
{
int IsInitialized = 0;
int provided;

MPI_Initialized(&IsInitialized);
if (!IsInitialized)
{
MPI_Init_thread(NULL, NULL, MPI_THREAD_MULTIPLE, &provided);
}
else
{
MPI_Query_thread(&provided);
}

if (provided != MPI_THREAD_MULTIPLE)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (!rank)
{
fprintf(stderr,
"MPI init without MPI_THREAD_MULTIPLE (Externally "
"initialized:%s)\n",
IsInitialized ? "true" : "false");
}
}
}

/*****Public accessible functions********************************************/

/**
Expand All @@ -301,8 +265,6 @@ static DP_RS_Stream MpiInitReader(CP_Services Svcs, void *CP_Stream,
struct _SstParams *Params,
attr_list WriterContact, SstStats Stats)
{
pthread_once(&OnceMpiInitializer, MpiInitialize);

MpiStreamRD Stream = calloc(sizeof(struct _MpiStreamRD), 1);
CManager cm = Svcs->getCManager(CP_Stream);
SMPI_Comm comm = Svcs->getMPIComm(CP_Stream);
Expand Down Expand Up @@ -344,8 +306,6 @@ static DP_WS_Stream MpiInitWriter(CP_Services Svcs, void *CP_Stream,
struct _SstParams *Params, attr_list DPAttrs,
SstStats Stats)
{
pthread_once(&OnceMpiInitializer, MpiInitialize);

MpiStreamWR Stream = calloc(sizeof(struct _MpiStreamWR), 1);
CManager cm = Svcs->getCManager(CP_Stream);
SMPI_Comm comm = Svcs->getMPIComm(CP_Stream);
Expand Down Expand Up @@ -848,16 +808,30 @@ static void MpiReleaseTimeStep(CP_Services Svcs, DP_WS_Stream Stream_v,
static int MpiGetPriority(CP_Services Svcs, void *CP_Stream,
struct _SstParams *Params)
{
#if defined(MPICH)
// Only enabled when MPI_THREAD_MULTIPLE and using MPICH
int IsInitialized = 0;
int provided = 0;
pthread_once(&OnceMpiInitializer, MpiInitialize);
MPI_Query_thread(&provided);
if (provided == MPI_THREAD_MULTIPLE)
int IsMPICH = 0;
#if defined(MPICH)
IsMPICH = 1;

MPI_Initialized(&IsInitialized);
if (IsInitialized)
{
return 100;
MPI_Query_thread(&provided);
// Only enabled when MPI_THREAD_MULTIPLE and using MPICH
if (provided == MPI_THREAD_MULTIPLE)
{
return 100;
}
}
#endif

Svcs->verbose(CP_Stream, DPTraceVerbose,
"MPI DP disabled since the following predicate is false: "
"(MPICH=%s AND MPI_initialized=%s AND MPI_THREAD_MULTIPLE=%s)",
IsMPICH ? "true" : "false", IsInitialized ? "true" : "false",
provided == MPI_THREAD_MULTIPLE ? "true" : "false");

return -100;
}

Expand Down
10 changes: 9 additions & 1 deletion thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,20 @@ add_subdirectory(nlohmann_json)
adios2_add_thirdparty_target(nlohmann_json nlohmann_json_wrapper)

if(ADIOS2_USE_EXTERNAL_YAMLCPP)
find_package(yaml-cpp REQUIRED)
find_package(yaml-cpp 0.7.0 REQUIRED)
else()
add_subdirectory(yaml-cpp)
endif()

adios2_add_thirdparty_target(yaml-cpp yaml-cpp)

# YAML-cpp does not add the incdir/libdir to its target rather it exposes it
# through the cmake variables YAML_CPP_INCLUDE_DIR and YAML_CPP_LIBRARY_DIR
if(yaml-cpp_VERSION VERSION_GREATER_EQUAL 0.8)
target_include_directories(adios2::thirdparty::yaml-cpp INTERFACE ${YAML_CPP_INCLUDE_DIR})
target_link_directories(adios2::thirdparty::yaml-cpp INTERFACE ${YAML_CPP_LIBRARY_DIR})
endif()

if(WIN32)
add_subdirectory(mingw-w64)
endif()
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/EVPath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_CMAKEDIR}/thirdparty")
set(EVPATH_LIBRARY_PREFIX adios2${ADIOS2_LIBRARY_SUFFIX}_ CACHE INTERNAL "")
set(EVPATH_QUIET ON CACHE INTERNAL "")
set(EVPATH_INSTALL_HEADERS OFF CACHE INTERNAL "")
set(EVPATH_INSTALL_MODULE_DIR "${CMAKE_INSTALL_LIBDIR}/adios2_evpath_modules" CACHE INTERNAL "")
set(EVPATH_INSTALL_MODULE_DIR "${CMAKE_INSTALL_LIBDIR}/adios2-evpath-modules-${ADIOS2_VERSION_MAJOR}_${ADIOS2_VERSION_MINOR}" CACHE INTERNAL "")
set(EVPATH_INSTALL_PKGCONFIG OFF CACHE INTERNAL "")
set(EVPATH_NO_RDMA ON CACHE INTERNAL "")
set(EVPATH_USE_UDT4 OFF CACHE INTERNAL "")
Expand Down
Loading