Skip to content

Commit

Permalink
Merge pull request #6838 from raffenet/4.2.x-updates
Browse files Browse the repository at this point in the history
[4.2.x] cherry-picked fixes in preparation of 4.2.0rc1
  • Loading branch information
raffenet authored Dec 8, 2023
2 parents b7f6fbe + 3482f29 commit 211aa59
Show file tree
Hide file tree
Showing 17 changed files with 202 additions and 38 deletions.
4 changes: 2 additions & 2 deletions README.vin
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
MPICH Release %VERSION%

MPICH is a high-performance and widely portable implementation of the
MPI-4.0 standard from the Argonne National Laboratory. This release
has all MPI 4.0 functions and features required by the standard with
MPI-4.1 standard from the Argonne National Laboratory. This release
has all MPI 4.1 functions and features required by the standard with
the exception of support for user-defined data representations for I/O.

This README file should contain enough information to get you started
Expand Down
2 changes: 1 addition & 1 deletion maint/version.m4
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# changing this by playing with diversions, but then we would probably be
# playing with autotools-fire.

m4_define([MPICH_VERSION_m4],[4.2.0b1])dnl
m4_define([MPICH_VERSION_m4],[4.2.0rc1])dnl
m4_define([MPICH_RELEASE_DATE_m4],[unreleased development copy])dnl

# For libtool ABI versioning rules see:
Expand Down
10 changes: 10 additions & 0 deletions src/binding/c/rma_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ MPI_Accumulate:
.seealso: MPI_Raccumulate
.impl: mpid
.earlyreturn: pt2pt_proc_null
{ -- error_check --
MPI_Datatype origin_elem, target_elem;
MPIR_Datatype_get_basic_type(origin_datatype, origin_elem);
MPIR_Datatype_get_basic_type(target_datatype, target_elem);
if ((origin_count > 0 && origin_elem != MPI_DATATYPE_NULL) ||
(target_count > 0 && target_elem != MPI_DATATYPE_NULL)) {
MPIR_ERR_CHKANDJUMP(origin_elem != target_elem, mpi_errno, MPI_ERR_TYPE,
"**dtypemismatch");
}
}

MPI_Compare_and_swap:
.desc: Perform one-sided atomic compare-and-swap.
Expand Down
2 changes: 1 addition & 1 deletion src/binding/fortran/use_mpi/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ mpi_fc_sources += \
# We need the MPI constants in a separate module for some of the
# interface definitions (the ones that need MPI_ADDRESS_KIND or
# MPI_OFFSET_KIND)
src/binding/fortran/use_mpi/mpi.$(MOD)-stamp: src/binding/fortran/use_mpi/$(MPICONSTMOD).$(MOD) src/binding/fortran/use_mpi/$(MPISIZEOFMOD).$(MOD) src/binding/fortran/use_mpi/$(MPIBASEMOD).$(MOD) $(srcdir)/src/binding/fortran/use_mpi/mpi.f90 src/binding/fortran/use_mpi/mpifnoext.h
src/binding/fortran/use_mpi/mpi.$(MOD)-stamp: src/binding/fortran/use_mpi/$(MPICONSTMOD).$(MOD) src/binding/fortran/use_mpi/$(MPISIZEOFMOD).$(MOD) src/binding/fortran/use_mpi/$(MPIBASEMOD).$(MOD) src/binding/fortran/use_mpi/$(PMPIBASEMOD).$(MOD) $(srcdir)/src/binding/fortran/use_mpi/mpi.f90 src/binding/fortran/use_mpi/mpifnoext.h
@rm -f src/binding/fortran/use_mpi/mpi-tmp
@touch src/binding/fortran/use_mpi/mpi-tmp
@( cd src/binding/fortran/use_mpi && \
Expand Down
7 changes: 7 additions & 0 deletions src/mpi/request/mpir_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ static void init_builtin_request(MPIR_Request * req, int handle, MPIR_Request_ki
req->cc_ptr = &req->cc;
req->status.MPI_ERROR = MPI_SUCCESS;
MPIR_STATUS_SET_CANCEL_BIT(req->status, FALSE);
if (kind == MPIR_REQUEST_KIND__RECV) {
/* precompleted recv request is returned when source is MPI_PROC_NULL,
* or when we are certain status won't be needed. Thus, initialize the
* status for MPI_PROC_NULL. */
req->status.MPI_SOURCE = MPI_PROC_NULL;
req->status.MPI_TAG = MPI_ANY_TAG;
}
req->comm = NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/mpid/ch4/netmod/ucx/subconfigure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ AM_COND_IF([BUILD_CH4_NETMOD_UCX],[
else
ucx_opt_flags=""
fi
PAC_CONFIG_SUBDIR_ARGS([modules/ucx],[--disable-static --enable-embedded --with-java=no $ucx_opt_flags],[],[AC_MSG_ERROR(ucx configure failed)])
PAC_CONFIG_SUBDIR_ARGS([modules/ucx],[--disable-static --enable-embedded --with-java=no --with-go=no $ucx_opt_flags],[],[AC_MSG_ERROR(ucx configure failed)])
PAC_POP_ALL_FLAGS()
ucxdir="modules/ucx"
fi
Expand Down
23 changes: 22 additions & 1 deletion src/mpid/ch4/netmod/ucx/ucx_pre.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,30 @@ typedef struct {
ucp_datatype_t ucp_datatype;
} MPIDI_UCX_dt_t;

enum MPIDI_UCX_reqtype {
MPIDI_UCX_RECV_CONTIG,
MPIDI_UCX_RECV_UNPACK,
MPIDI_UCX_RECV_IOV,
MPIDI_UCX_RECV_UCX_DT,
};

typedef union {
ucp_tag_message_h message_handler;
MPIDI_UCX_ucp_request_t *ucp_request;
struct {
MPIDI_UCX_ucp_request_t *ucp_request;
enum MPIDI_UCX_reqtype type;
union {
struct {
void *pack_buf;
void *user_buf;
MPI_Aint count;
MPI_Datatype datatype;
} pack;
struct {
ucp_dt_iov_t *iov;
} iov;
} u;
} s;
} MPIDI_UCX_request_t;

typedef struct {
Expand Down
87 changes: 79 additions & 8 deletions src/mpid/ch4/netmod/ucx/ucx_recv.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@

#include "ucx_impl.h"

/*
=== BEGIN_MPI_T_CVAR_INFO_BLOCK ===
cvars:
- name : MPIR_CVAR_UCX_DT_RECV
category : CH4_UCX
type : boolean
default : false
class : none
verbosity : MPI_T_VERBOSITY_USER_BASIC
scope : MPI_T_SCOPE_ALL_EQ
description : |-
Variable to select method for receiving noncontiguous data
true - Use UCX datatype with pack/unpack callbacks
false - MPICH will decide to pack/unpack at completion or use IOVs
based on the datatype
=== END_MPI_T_CVAR_INFO_BLOCK ===
*/

#define MPIDI_UCX_ENABLE_IOV (UCP_VERSION(UCP_API_MAJOR, UCP_API_MINOR) >= UCP_VERSION(1, 16))

MPL_STATIC_INLINE_PREFIX void MPIDI_UCX_recv_cmpl_cb(void *request, ucs_status_t status,
const ucp_tag_recv_info_t * info,
void *user_data)
Expand All @@ -31,6 +52,24 @@ MPL_STATIC_INLINE_PREFIX void MPIDI_UCX_recv_cmpl_cb(void *request, ucs_status_t
rreq->status.MPI_TAG = MPIDI_UCX_get_tag(info->sender_tag);
MPIR_STATUS_SET_COUNT(rreq->status, count);
}

if (MPIDI_UCX_REQ(rreq).s.type == MPIDI_UCX_RECV_UNPACK) {
void *pack_buf = MPIDI_UCX_REQ(rreq).s.u.pack.pack_buf;
void *user_buf = MPIDI_UCX_REQ(rreq).s.u.pack.user_buf;
MPI_Aint user_count = MPIDI_UCX_REQ(rreq).s.u.pack.count;
MPI_Datatype datatype = MPIDI_UCX_REQ(rreq).s.u.pack.datatype;
MPI_Aint actual_unpack_bytes;

MPIR_Typerep_unpack(pack_buf, info->length, user_buf, user_count, datatype,
0, &actual_unpack_bytes, MPIR_TYPEREP_FLAG_NONE);
if (actual_unpack_bytes < info->length) {
rreq->status.MPI_ERROR = MPI_ERR_TRUNCATE;
}
MPIR_Datatype_release_if_not_builtin(datatype);
MPL_free(MPIDI_UCX_REQ(rreq).s.u.pack.pack_buf);
} else if (MPIDI_UCX_REQ(rreq).s.type == MPIDI_UCX_RECV_IOV) {
MPL_free(MPIDI_UCX_REQ(rreq).s.u.iov.iov);
}
#ifndef MPIDI_CH4_DIRECT_NETMOD
int is_cancelled;
MPIDI_anysrc_try_cancel_partner(rreq, &is_cancelled);
Expand Down Expand Up @@ -119,12 +158,44 @@ MPL_STATIC_INLINE_PREFIX int MPIDI_UCX_recv(void *buf,
if (dt_contig) {
recv_buf = MPIR_get_contig_ptr(buf, dt_true_lb);
recv_count = data_sz;
MPIDI_UCX_REQ(req).s.type = MPIDI_UCX_RECV_CONTIG;
} else {
recv_buf = buf;
recv_count = count;
param.op_attr_mask |= UCP_OP_ATTR_FIELD_DATATYPE;
param.datatype = dt_ptr->dev.netmod.ucx.ucp_datatype;
MPIR_Datatype_ptr_add_ref(dt_ptr);
if (MPIR_CVAR_UCX_DT_RECV) {
recv_buf = buf;
recv_count = count;
param.op_attr_mask |= UCP_OP_ATTR_FIELD_DATATYPE;
param.datatype = dt_ptr->dev.netmod.ucx.ucp_datatype;
MPIR_Datatype_ptr_add_ref(dt_ptr);
MPIDI_UCX_REQ(req).s.type = MPIDI_UCX_RECV_UCX_DT;
} else {
MPI_Aint density;
MPIR_Datatype_get_density(datatype, density);

if (MPIDI_UCX_ENABLE_IOV && density >= MPIR_CVAR_CH4_IOV_DENSITY_MIN) {
MPI_Aint iov_len, actual_iov_len;
MPIR_Typerep_get_iov_len(count, datatype, &iov_len);
ucp_dt_iov_t *iov = MPL_malloc(sizeof(ucp_dt_iov_t) * iov_len, MPL_MEM_BUFFER);
MPIR_Typerep_to_iov_offset(buf, count, datatype, 0, (struct iovec *) iov,
iov_len, &actual_iov_len);
MPIR_Assert(iov_len == actual_iov_len);

recv_buf = iov;
recv_count = iov_len;
param.op_attr_mask |= UCP_OP_ATTR_FIELD_DATATYPE;
param.datatype = ucp_dt_make_iov();
MPIDI_UCX_REQ(req).s.u.iov.iov = iov;
MPIDI_UCX_REQ(req).s.type = MPIDI_UCX_RECV_IOV;
} else {
MPIDI_UCX_REQ(req).s.u.pack.datatype = datatype;
MPIR_Datatype_add_ref_if_not_builtin(datatype);
MPIDI_UCX_REQ(req).s.u.pack.user_buf = buf;
MPIDI_UCX_REQ(req).s.u.pack.count = count;
MPIDI_UCX_REQ(req).s.u.pack.pack_buf = MPL_malloc(data_sz, MPL_MEM_BUFFER);
recv_buf = MPIDI_UCX_REQ(req).s.u.pack.pack_buf;
recv_count = data_sz;
MPIDI_UCX_REQ(req).s.type = MPIDI_UCX_RECV_UNPACK;
}
}
}

ucp_request =
Expand All @@ -133,7 +204,7 @@ MPL_STATIC_INLINE_PREFIX int MPIDI_UCX_recv(void *buf,
ucp_tag, tag_mask, &param);
MPIDI_UCX_CHK_REQUEST(ucp_request);

MPIDI_UCX_REQ(req).ucp_request = ucp_request;
MPIDI_UCX_REQ(req).s.ucp_request = ucp_request;
*request = req;

fn_exit:
Expand Down Expand Up @@ -197,7 +268,7 @@ MPL_STATIC_INLINE_PREFIX int MPIDI_NM_mpi_imrecv(void *buf,
&param);
MPIDI_UCX_CHK_REQUEST(ucp_request);

MPIDI_UCX_REQ(message).ucp_request = ucp_request;
MPIDI_UCX_REQ(message).s.ucp_request = ucp_request;

fn_exit:
MPIDI_UCX_THREAD_CS_EXIT_VCI(vci);
Expand Down Expand Up @@ -252,7 +323,7 @@ MPL_STATIC_INLINE_PREFIX int MPIDI_NM_mpi_cancel_recv(MPIR_Request * rreq, bool

if (!MPIR_Request_is_complete(rreq)) {
int vci = MPIDI_Request_get_vci(rreq);
ucp_request_cancel(MPIDI_UCX_global.ctx[vci].worker, MPIDI_UCX_REQ(rreq).ucp_request);
ucp_request_cancel(MPIDI_UCX_global.ctx[vci].worker, MPIDI_UCX_REQ(rreq).s.ucp_request);
}

MPIR_FUNC_EXIT;
Expand Down
4 changes: 2 additions & 2 deletions src/mpid/ch4/netmod/ucx/ucx_send.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ MPL_STATIC_INLINE_PREFIX int MPIDI_UCX_send(const void *buf,
MPIR_Request_add_ref(req);
}
ucp_request->req = req;
MPIDI_UCX_REQ(req).ucp_request = ucp_request;
MPIDI_UCX_REQ(req).s.ucp_request = ucp_request;
} else if (req != NULL) {
MPIR_cc_set(&req->cc, 0);
} else if (have_request) {
Expand Down Expand Up @@ -160,7 +160,7 @@ MPL_STATIC_INLINE_PREFIX int MPIDI_NM_mpi_cancel_send(MPIR_Request * sreq)
if (!MPIR_Request_is_complete(sreq)) {
int vci = MPIDI_Request_get_vci(sreq);
MPIDI_UCX_THREAD_CS_ENTER_VCI(vci);
ucp_request_cancel(MPIDI_UCX_global.ctx[vci].worker, MPIDI_UCX_REQ(sreq).ucp_request);
ucp_request_cancel(MPIDI_UCX_global.ctx[vci].worker, MPIDI_UCX_REQ(sreq).s.ucp_request);
MPIDI_UCX_THREAD_CS_EXIT_VCI(vci);
}

Expand Down
16 changes: 1 addition & 15 deletions src/mpl/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -813,15 +813,7 @@ case $with_proc_mutex_package in
AC_CHECK_FUNCS(pthread_mutexattr_setpshared)

AC_CHECK_FUNCS(pthread_setaffinity_np)

#
# Check for the Linux functions for controlling processor affinity.
#
# LINUX: sched_setaffinity
# AIX: bindprocessor
# OSX (Leopard): thread_policy_set
AC_CHECK_FUNCS([sched_setaffinity sched_getaffinity bindprocessor thread_policy_set])
if test "$ac_cv_func_sched_setaffinity" = "yes" ; then
if test "$ac_cv_func_pthread_setaffinity_np" = "yes" ; then
# Test for the cpu process set type
AC_CACHE_CHECK([whether cpu_set_t available],pac_cv_have_cpu_set_t,[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sched.h>]],[[cpu_set_t t;]])],
Expand All @@ -842,15 +834,9 @@ case $with_proc_mutex_package in
if test "$pac_cv_cpu_set_defined" = "yes" ; then
AC_DEFINE(HAVE_CPU_SET_MACROS,1,[Define if CPU_SET and CPU_ZERO defined])
fi
# FIXME: Some versions of sched_setaffinity return ENOSYS (!),
# so we should test for the unfriendly and useless behavior
fi
fi

if test "$ac_cv_func_pthread_setaffinity_np" = "yes" ; then
AC_DEFINE(HAVE_PTHREAD_SETAFFINITY_NP,1, [Define if pthread_setaffinity_np is available.])
fi

AC_MSG_NOTICE([POSIX will be used for interprocess mutex package.])
PROC_MUTEX_PACKAGE_NAME=MPL_PROC_MUTEX_PACKAGE_POSIX
;;
Expand Down
3 changes: 2 additions & 1 deletion src/mpl/src/thread/mpl_thread_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ void *MPLI_thread_start(void *arg)
void MPL_thread_set_affinity(MPL_thread_id_t thread, int *affinity_arr, int affinity_size,
int *errp)
{
#if defined(MPL_HAVE_PTHREAD_SETAFFINITY_NP) && defined(MPL_HAVE_CPU_SET_MACROS)
#if defined(MPL_HAVE_PTHREAD_SETAFFINITY_NP) && defined(MPL_HAVE_CPU_SET_MACROS) && defined(__linux__)
/* FIXME: this implementation uses Linux-specific types and macros */
int err = MPL_SUCCESS;
int proc_idx, set_size = 0;
cpu_set_t cpuset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static struct HYD_node *global_node_list = NULL;
#if defined(HAVE_SLURM)
static HYD_status list_to_nodes(char *str)
{
hostlist_t hostlist;
hostlist_t *hostlist;
char *host;
int k = 0;
HYD_status status = HYD_SUCCESS;
Expand Down
16 changes: 15 additions & 1 deletion src/util/mpir_pmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,27 @@ static int check_MPIR_CVAR_PMI_VERSION(void)
return MPI_SUCCESS;
}

/* When user call MPIR_pmi_finalize, we will postpone the actual PMI_Finalize
* and set finalize_pending flag instead. The exit hook will call PMI_Finalize
* when the finalize_pending flag is set. This is to prevent an abnormal exit
* to show up as a normal exit.
*/
static int finalize_pending = 0;
static void MPIR_pmi_finalize_on_exit(void)
{
SWITCH_PMI(pmi1_exit(), pmi2_exit(), pmix_exit());
if (finalize_pending > 0) {
SWITCH_PMI(pmi1_exit(), pmi2_exit(), pmix_exit());
}
}

int MPIR_pmi_init(void)
{
int mpi_errno = MPI_SUCCESS;
static bool pmi_connected = false;

if (finalize_pending > 0) {
finalize_pending--;
}
mpi_errno = check_MPIR_CVAR_PMI_VERSION();
MPIR_ERR_CHECK(mpi_errno);

Expand Down Expand Up @@ -206,6 +217,9 @@ void MPIR_pmi_finalize(void)
MPL_free(hwloc_topology_xmlfile);
hwloc_topology_xmlfile = NULL;
MPL_free(MPIR_Process.coords);

/* delay PMI_Finalize to the exit hook */
finalize_pending++;
}

void MPIR_pmi_abort(int exit_code, const char *error_msg)
Expand Down
1 change: 1 addition & 0 deletions test/mpi/pt2pt/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ noinst_PROGRAMS = \
waitany_null \
probe_unexp \
probenull \
recvnull \
inactivereq \
waittestnull \
sendall \
Expand Down
51 changes: 51 additions & 0 deletions test/mpi/pt2pt/recvnull.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/

#include <stdio.h>
#include "mpi.h"
#include "mpitest.h"

/*
* This program checks that MPI_Irecv and MPI_Recv correctly handle
* a source of MPI_PROC_NULL
*/

int main(int argc, char **argv)
{
int flag;
int errs = 0;
MPI_Status status;
MPI_Request req;

MTest_Init(&argc, &argv);

MPI_Irecv(NULL, 0, MPI_DATATYPE_NULL, MPI_PROC_NULL, 10, MPI_COMM_WORLD, &req);
MPI_Waitall(1, &req, &status);
if (status.MPI_SOURCE != MPI_PROC_NULL) {
printf("Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n", status.MPI_SOURCE);
errs++;
}
if (status.MPI_TAG != MPI_ANY_TAG) {
printf("Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n", status.MPI_TAG);
errs++;
}

/* If Irecv failed, Recv is likely to as well. Avoid a possible hang
* by testing Recv only if Irecv test passed */
if (errs == 0) {
MPI_Recv(NULL, 0, MPI_DATATYPE_NULL, MPI_PROC_NULL, 10, MPI_COMM_WORLD, &status);
if (status.MPI_SOURCE != MPI_PROC_NULL) {
printf("Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n", status.MPI_SOURCE);
errs++;
}
if (status.MPI_TAG != MPI_ANY_TAG) {
printf("Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n", status.MPI_TAG);
errs++;
}
}

MTest_Finalize(errs);
return MTestReturnValue(errs);
}
Loading

0 comments on commit 211aa59

Please sign in to comment.