Skip to content

MPI4:implement MPI_Comm_idup_with_info #9707

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

Merged
merged 3 commits into from
Jan 24, 2022
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
4 changes: 4 additions & 0 deletions ompi/include/mpi.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,8 @@ OMPI_DECLSPEC int MPI_Comm_disconnect(MPI_Comm *comm);
OMPI_DECLSPEC int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm);
OMPI_DECLSPEC int MPI_Comm_idup(MPI_Comm comm, MPI_Comm *newcomm, MPI_Request *request);
OMPI_DECLSPEC int MPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm *newcomm);
OMPI_DECLSPEC int MPI_Comm_idup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm *newcomm,
MPI_Request *request);
OMPI_DECLSPEC MPI_Comm MPI_Comm_f2c(MPI_Fint comm);
OMPI_DECLSPEC int MPI_Comm_free_keyval(int *comm_keyval);
OMPI_DECLSPEC int MPI_Comm_free(MPI_Comm *comm);
Expand Down Expand Up @@ -2178,6 +2180,8 @@ OMPI_DECLSPEC int PMPI_Comm_disconnect(MPI_Comm *comm);
OMPI_DECLSPEC int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm);
OMPI_DECLSPEC int PMPI_Comm_idup(MPI_Comm comm, MPI_Comm *newcomm, MPI_Request *request);
OMPI_DECLSPEC int PMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm *newcomm);
OMPI_DECLSPEC int PMPI_Comm_idup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm *newcomm,
MPI_Request *request);
OMPI_DECLSPEC MPI_Comm PMPI_Comm_f2c(MPI_Fint comm);
OMPI_DECLSPEC int PMPI_Comm_free_keyval(int *comm_keyval);
OMPI_DECLSPEC int PMPI_Comm_free(MPI_Comm *comm);
Expand Down
1 change: 1 addition & 0 deletions ompi/mpi/c/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ interface_profile_sources = \
comm_dup.c \
comm_dup_with_info.c \
comm_idup.c \
comm_idup_with_info.c \
comm_f2c.c \
comm_free.c \
comm_free_keyval.c \
Expand Down
86 changes: 86 additions & 0 deletions ompi/mpi/c/comm_idup_with_info.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2020 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2006-2008 University of Houston. All rights reserved.
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
* Copyright (c) 2021 Triad National Security, LLC. All rights
* reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include <stdio.h>

#include "ompi/mpi/c/bindings.h"
#include "ompi/runtime/params.h"
#include "ompi/communicator/communicator.h"
#include "ompi/errhandler/errhandler.h"
#include "ompi/memchecker.h"

#if OMPI_BUILD_MPI_PROFILING
#if OPAL_HAVE_WEAK_SYMBOLS
#pragma weak MPI_Comm_idup_with_info = PMPI_Comm_idup_with_info
#endif
#define MPI_Comm_idup_with_info PMPI_Comm_idup_with_info
#endif

static const char FUNC_NAME[] = "MPI_Comm_idup_with_info";

int MPI_Comm_idup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm *newcomm, MPI_Request *request)
{
int rc;

MEMCHECKER(
memchecker_comm(comm);
);

/* argument checking */
if ( MPI_PARAM_CHECK ) {
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);

if (ompi_comm_invalid (comm))
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_COMM,
FUNC_NAME);
if (NULL == info || ompi_info_is_freed(info)) {
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_INFO,
FUNC_NAME);
}

if ( NULL == newcomm )
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG,
FUNC_NAME);
}

#if OPAL_ENABLE_FT_MPI
/*
* An early check, so as to return early if we are using a broken
* communicator. This is not absolutely necessary since we will
* check for this, and other, error conditions during the operation.
*/
if( OPAL_UNLIKELY(!ompi_comm_iface_create_check(comm, &rc)) ) {
OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME);
}
#endif

rc = ompi_comm_idup_with_info (comm, &info->super, newcomm, request);
OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME);
}

1 change: 1 addition & 0 deletions ompi/mpi/fortran/mpif-h/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ lib@OMPI_LIBMPI_NAME@_mpifh_la_SOURCES += \
comm_dup_f.c \
comm_dup_with_info_f.c \
comm_idup_f.c \
comm_idup_with_info_f.c \
comm_free_f.c \
comm_free_keyval_f.c \
comm_get_attr_f.c \
Expand Down
92 changes: 92 additions & 0 deletions ompi/mpi/fortran/mpif-h/comm_idup_with_info_f.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2011-2013 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2021 Triad National Security, LLC. All rights
* reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/

#include "ompi_config.h"

#include "ompi/mpi/fortran/mpif-h/bindings.h"

#if OMPI_BUILD_MPI_PROFILING
#if OPAL_HAVE_WEAK_SYMBOLS
#pragma weak PMPI_COMM_IDUP_WITH_INFO = ompi_comm_idup_with_info_f
#pragma weak pmpi_comm_idup_with_info = ompi_comm_idup_with_info_f
#pragma weak pmpi_comm_idup_with_info_ = ompi_comm_idup_with_info_f
#pragma weak pmpi_comm_idup_with_info__ = ompi_comm_idup_with_info_f

#pragma weak PMPI_Comm_idup_with_info_f = ompi_comm_idup_with_info_f
#pragma weak PMPI_Comm_idup_with_info_f08 = ompi_comm_idup_with_info_f
#else
OMPI_GENERATE_F77_BINDINGS (PMPI_COMM_IDUP_WITH_INFO,
pmpi_comm_idup_with_info,
pmpi_comm_idup_with_info_,
pmpi_comm_idup_with_info__,
pompi_comm_idup_with_info_f,
(MPI_Fint *comm, MPI_Fint *info, MPI_Fint *newcomm, MPI_Fint *request, MPI_Fint *ierr),
(comm, info, newcomm, request, ierr) )
#endif
#endif

#if OPAL_HAVE_WEAK_SYMBOLS
#pragma weak MPI_COMM_IDUP_WITH_INFO = ompi_comm_idup_with_info_f
#pragma weak mpi_comm_idup_with_info = ompi_comm_idup_with_info_f
#pragma weak mpi_comm_idup_with_info_ = ompi_comm_idup_with_info_f
#pragma weak mpi_comm_idup_with_info__ = ompi_comm_idup_with_info_f

#pragma weak MPI_Comm_idup_with_info_f = ompi_comm_idup_with_info_f
#pragma weak MPI_Comm_idup_with_info_f08 = ompi_comm_idup_with_info_f
#else
#if ! OMPI_BUILD_MPI_PROFILING
OMPI_GENERATE_F77_BINDINGS (MPI_COMM_IDUP_WITH_INFO,
mpi_comm_idup_with_info,
mpi_comm_idup_with_info_,
mpi_comm_idup_with_info__,
ompi_comm_idup_with_info_f,
(MPI_Fint *comm, MPI_Fint *info, MPI_Fint *newcomm, MPI_Fint *request, MPI_Fint *ierr),
(comm, info, newcomm, request, ierr) )
#else
#define ompi_comm_idup_with_info_f pompi_comm_idup_with_info_f
#endif
#endif


void ompi_comm_idup_with_info_f(MPI_Fint *comm, MPI_Fint *info, MPI_Fint *newcomm, MPI_Fint *request, MPI_Fint *ierr)
{
int c_ierr;
MPI_Comm c_newcomm;
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
MPI_Info c_info;
MPI_Request c_req;

c_info = PMPI_Info_f2c(*info);

c_ierr = PMPI_Comm_idup_with_info(c_comm, c_info, &c_newcomm, &c_req);
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

if (MPI_SUCCESS == c_ierr) {
*newcomm = PMPI_Comm_c2f(c_newcomm);
*request = PMPI_Request_c2f(c_req);
}
}
1 change: 1 addition & 0 deletions ompi/mpi/fortran/mpif-h/profile/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ linked_files = \
pcomm_dup_f.c \
pcomm_dup_with_info_f.c \
pcomm_idup_f.c \
pcomm_idup_with_info_f.c \
pcomm_free_f.c \
pcomm_free_keyval_f.c \
pcomm_get_attr_f.c \
Expand Down
1 change: 1 addition & 0 deletions ompi/mpi/fortran/mpif-h/prototypes_mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ PN2(void, MPI_Comm_disconnect, mpi_comm_disconnect, MPI_COMM_DISCONNECT, (MPI_Fi
PN2(void, MPI_Comm_dup, mpi_comm_dup, MPI_COMM_DUP, (MPI_Fint *comm, MPI_Fint *newcomm, MPI_Fint *ierr));
PN2(void, MPI_Comm_dup_with_info, mpi_comm_dup_with_info, MPI_COMM_DUP_WITH_INFO, (MPI_Fint *comm, MPI_Fint *info, MPI_Fint *newcomm, MPI_Fint *ierr));
PN2(void, MPI_Comm_idup, mpi_comm_idup, MPI_COMM_IDUP, (MPI_Fint *comm, MPI_Fint *newcomm, MPI_Fint *request, MPI_Fint *ierr));
PN2(void, MPI_Comm_idup_with_info, mpi_comm_idup_with_info, MPI_COMM_IDUP_WITH_INFO, (MPI_Fint *comm, MPI_Fint *info, MPI_Fint *newcomm, MPI_Fint *request, MPI_Fint *ierr));
PN2(void, MPI_Comm_free_keyval, mpi_comm_free_keyval, MPI_COMM_FREE_KEYVAL, (MPI_Fint *comm_keyval, MPI_Fint *ierr));
PN2(void, MPI_Comm_free, mpi_comm_free, MPI_COMM_FREE, (MPI_Fint *comm, MPI_Fint *ierr));
PN2(void, MPI_Comm_get_attr, mpi_comm_get_attr, MPI_COMM_GET_ATTR, (MPI_Fint *comm, MPI_Fint *comm_keyval, MPI_Aint *attribute_val, ompi_fortran_logical_t *flag, MPI_Fint *ierr));
Expand Down
1 change: 1 addition & 0 deletions ompi/mpi/fortran/use-mpi-f08/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ mpi_api_files = \
comm_dup_f08.F90 \
comm_dup_with_info_f08.F90 \
comm_idup_f08.F90 \
comm_idup_with_info_f08.F90 \
comm_free_f08.F90 \
comm_free_keyval_f08.F90 \
comm_get_attr_f08.F90 \
Expand Down
12 changes: 12 additions & 0 deletions ompi/mpi/fortran/use-mpi-f08/bindings/mpi-f-interfaces-bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
! Copyright (c) 2015-2020 Research Organization for Information Science
! and Technology (RIST). All rights reserved.
! Copyright (c) 2021 Bull S.A.S. All rights reserved.
! Copyright (c) 2021 Triad National Security, LLC. All rights
! reserved.
! $COPYRIGHT$
!
! This file provides the interface specifications for the MPI Fortran
Expand Down Expand Up @@ -1617,6 +1619,16 @@ subroutine ompi_comm_dup_with_info_f(comm, info, newcomm, ierror) &
integer, intent(out) :: ierror
end subroutine ompi_comm_dup_with_info_f

subroutine ompi_comm_idup_with_info_f(comm, info, newcomm, request, ierror) &
BIND(C, name="ompi_comm_idup_with_info_f")
implicit none
integer, intent(in) :: comm
integer, intent(in) :: info
integer, intent(out) :: newcomm
integer, intent(out) :: request
integer, intent(out) :: ierror
end subroutine ompi_comm_idup_with_info_f

subroutine ompi_comm_free_f(comm,ierror) &
BIND(C, name="ompi_comm_free_f")
implicit none
Expand Down
30 changes: 30 additions & 0 deletions ompi/mpi/fortran/use-mpi-f08/comm_idup_with_info_f08.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
! -*- f90 -*-
!
! Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved.
! Copyright (c) 2009-2013 Los Alamos National Security, LLC.
! All rights reserved.
! Copyright (c) 2018-2020 Research Organization for Information Science
! and Technology (RIST). All rights reserved.
! Copyright (c) 2021 Triad National Security, LLC. All rights
! reserved.
! $COPYRIGHT$

#include "mpi-f08-rename.h"

subroutine MPI_Comm_idup_with_info_f08(comm,info,newcomm,request,ierror)
use :: mpi_f08_types, only : MPI_Comm, MPI_Info, MPI_Request
use :: ompi_mpifh_bindings, only : ompi_comm_idup_with_info_f
implicit none
TYPE(MPI_Comm), INTENT(IN) :: comm
TYPE(MPI_Info), INTENT(IN) :: info
TYPE(MPI_Comm), INTENT(OUT) :: newcomm
TYPE(MPI_Request), INTENT(OUT) :: request
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
integer :: c_ierror

call ompi_comm_idup_with_info_f(comm%MPI_VAL,info%MPI_VAL,newcomm%MPI_VAL,request%MPI_VAL,c_ierror)
if (present(ierror)) ierror = c_ierror

end subroutine MPI_Comm_idup_with_info_f08


15 changes: 15 additions & 0 deletions ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
! Copyright (c) 2015-2020 Research Organization for Information Science
! and Technology (RIST). All rights reserved.
! Copyright (c) 2017-2018 FUJITSU LIMITED. All rights reserved.
! Copyright (c) 2021 Triad National Security, LLC. All rights
! reserved.
! $COPYRIGHT$
!
! This file provides the interface specifications for the MPI Fortran
Expand Down Expand Up @@ -1861,6 +1863,19 @@ subroutine MPI_Comm_idup_f08(comm,newcomm,request,ierror)
end subroutine MPI_Comm_idup_f08
end interface MPI_Comm_idup

interface MPI_Comm_idup_with_info
subroutine MPI_Comm_idup_with_info_f08(comm,info,newcomm,request,ierror)
use :: mpi_f08_types, only : MPI_Comm, MPI_Request, MPI_info
implicit none
TYPE(MPI_Comm), INTENT(IN) :: comm
TYPE(MPI_Info), INTENT(IN) :: info
TYPE(MPI_Comm), INTENT(OUT) :: newcomm
TYPE(MPI_Request), INTENT(OUT) :: request
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
end subroutine MPI_Comm_idup_with_info_f08
end interface MPI_Comm_idup_with_info


interface MPI_Comm_free
subroutine MPI_Comm_free_f08(comm,ierror)
use :: mpi_f08_types, only : MPI_Comm
Expand Down
2 changes: 2 additions & 0 deletions ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-rename.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@
#define MPI_Comm_dup_with_info_f08 PMPI_Comm_dup_with_info_f08
#define MPI_Comm_idup PMPI_Comm_idup
#define MPI_Comm_idup_f08 PMPI_Comm_idup_f08
#define MPI_Comm_idup_with_info PMPI_Comm_idup_with_info
#define MPI_Comm_idup_with_info_f08 PMPI_Comm_idup_with_info_f08
#define MPI_Comm_free PMPI_Comm_free
#define MPI_Comm_free_f08 PMPI_Comm_free_f08
#define MPI_Comm_free_keyval PMPI_Comm_free_keyval
Expand Down
1 change: 1 addition & 0 deletions ompi/mpi/fortran/use-mpi-f08/profile/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pmpi_api_files = \
pcomm_dup_f08.F90 \
pcomm_dup_with_info_f08.F90 \
pcomm_idup_f08.F90 \
pcomm_idup_with_info_f08.F90 \
pcomm_free_f08.F90 \
pcomm_free_keyval_f08.F90 \
pcomm_get_attr_f08.F90 \
Expand Down
11 changes: 11 additions & 0 deletions ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-interfaces.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,17 @@ end subroutine MPI_Comm_idup

end interface

interface

subroutine MPI_Comm_idup_with_info(comm, info, newcomm, request, ierror)
integer, intent(in) :: comm
integer, intent(in) :: info
integer, intent(out) :: newcomm
integer, intent(out) :: request
integer, intent(out) :: ierror
end subroutine MPI_Comm_idup_with_info

end interface

interface

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#define MPI_Comm_get_parent PMPI_Comm_get_parent
#define MPI_Comm_group PMPI_Comm_group
#define MPI_Comm_idup PMPI_Comm_idup
#define MPI_Comm_idup_with_info PMPI_Comm_idup_with_info
#define MPI_Comm_join PMPI_Comm_join
#define MPI_Comm_rank PMPI_Comm_rank
#define MPI_Comm_remote_group PMPI_Comm_remote_group
Expand Down
11 changes: 11 additions & 0 deletions ompi/mpi/fortran/use-mpi-tkr/mpi-f90-interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,17 @@ end subroutine MPI_Comm_idup

end interface

interface

subroutine MPI_Comm_idup_with_info(comm, info, newcomm, request, ierror)
integer, intent(in) :: comm
integer, intent(in) :: info
integer, intent(out) :: newcomm
integer, intent(out) :: request
integer, intent(out) :: ierror
end subroutine MPI_Comm_idup_with_info

end interface

interface

Expand Down
1 change: 1 addition & 0 deletions ompi/mpi/fortran/use-mpi-tkr/pmpi-f90-interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#define MPI_Comm_dup PMPI_Comm_dup
#define MPI_Comm_dup_with_info PMPI_Comm_dup_with_info
#define MPI_Comm_idup PMPI_Comm_idup
#define MPI_Comm_idup_with_info PMPI_Comm_idup_with_info
#define MPI_Comm_free PMPI_Comm_free
#define MPI_Comm_free_keyval PMPI_Comm_free_keyval
#define MPI_Comm_get_info PMPI_Comm_get_info
Expand Down
Loading