Skip to content

Commit 74414e0

Browse files
authored
Merge pull request #9925 from abouteiller/ulfm/ishrink
Ulfm/ishrink: add the MPI_COMM_ISHRINK operation
2 parents e4695b2 + 1110a12 commit 74414e0

File tree

13 files changed

+662
-72
lines changed

13 files changed

+662
-72
lines changed

ompi/communicator/communicator.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,11 @@ OMPI_DECLSPEC int ompi_comm_revoke_internal(ompi_communicator_t* comm);
633633
*/
634634
OMPI_DECLSPEC int ompi_comm_shrink_internal(ompi_communicator_t* comm, ompi_communicator_t** newcomm);
635635

636+
/*
637+
* Shrink the communicator
638+
*/
639+
OMPI_DECLSPEC int ompi_comm_ishrink_internal(ompi_communicator_t* comm, ompi_communicator_t** newcomm, ompi_request_t** request);
640+
636641
/*
637642
* Check if the process is active
638643
*/

ompi/communicator/ft/comm_ft.c

Lines changed: 407 additions & 68 deletions
Large diffs are not rendered by default.

ompi/mpiext/ftmpi/c/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ libmpiext_ftmpi_c_la_SOURCES = \
2727
comm_revoke.c \
2828
comm_is_revoked.c \
2929
comm_shrink.c \
30+
comm_ishrink.c \
3031
comm_failure_ack.c \
3132
comm_failure_get_acked.c \
3233
comm_get_failed.c \

ompi/mpiext/ftmpi/c/comm_ishrink.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2018-2022 The University of Tennessee and The University
3+
* of Tennessee Research Foundation. All rights
4+
* reserved.
5+
* $COPYRIGHT$
6+
*
7+
* Additional copyrights may follow
8+
*
9+
* $HEADER$
10+
*/
11+
#include "ompi_config.h"
12+
13+
#include "ompi/mpi/c/bindings.h"
14+
#include "ompi/runtime/params.h"
15+
#include "ompi/communicator/communicator.h"
16+
#include "ompi/request/request.h"
17+
#include "ompi/proc/proc.h"
18+
#include "ompi/op/op.h"
19+
20+
#if OMPI_BUILD_MPI_PROFILING
21+
#if OPAL_HAVE_WEAK_SYMBOLS
22+
#pragma weak MPIX_Comm_ishrink = PMPIX_Comm_ishrink
23+
#endif
24+
#define MPIX_Comm_ishrink PMPIX_Comm_ishrink
25+
#endif
26+
27+
#include "ompi/mpiext/ftmpi/c/mpiext_ftmpi_c.h"
28+
29+
static const char FUNC_NAME[] = "MPIX_Comm_ishrink";
30+
31+
32+
int MPIX_Comm_ishrink(MPI_Comm comm, MPI_Comm* newcomm, MPI_Request *request)
33+
{
34+
int rc = MPI_SUCCESS;
35+
36+
/* Argument checking */
37+
if (MPI_PARAM_CHECK) {
38+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
39+
if (ompi_comm_invalid(comm)) {
40+
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
41+
}
42+
if (NULL == newcomm) {
43+
rc = MPI_ERR_ARG;
44+
}
45+
if (NULL == request) {
46+
rc = MPI_ERR_REQUEST;
47+
}
48+
OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
49+
}
50+
51+
rc = ompi_comm_ishrink_internal(comm, newcomm, request);
52+
OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME);
53+
}
54+

ompi/mpiext/ftmpi/c/mpiext_ftmpi_c.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2010-2012 Oak Ridge National Labs. All rights reserved.
3-
* Copyright (c) 2010-2020 The University of Tennessee and the University
3+
* Copyright (c) 2010-2023 The University of Tennessee and the University
44
* of Tennessee research Foundation. All rights
55
* reserved.
66
* $COPYRIGHT$
@@ -25,6 +25,7 @@
2525
OMPI_DECLSPEC int MPIX_Comm_revoke(MPI_Comm comm);
2626
OMPI_DECLSPEC int MPIX_Comm_is_revoked(MPI_Comm comm, int *flag);
2727
OMPI_DECLSPEC int MPIX_Comm_shrink(MPI_Comm comm, MPI_Comm *newcomm);
28+
OMPI_DECLSPEC int MPIX_Comm_ishrink(MPI_Comm comm, MPI_Comm *newcomm, MPI_Request *request);
2829
OMPI_DECLSPEC int MPIX_Comm_failure_ack(MPI_Comm comm);
2930
OMPI_DECLSPEC int MPIX_Comm_failure_get_acked(MPI_Comm comm, MPI_Group *failedgrp);
3031
OMPI_DECLSPEC int MPIX_Comm_get_failed(MPI_Comm comm, MPI_Group *failedgroup);
@@ -47,4 +48,5 @@ OMPI_DECLSPEC int OMPI_Comm_failure_inject(MPI_Comm comm, bool notify);
4748
/* Provide defines to facilitate the detection of the new API */
4849
#define OMPI_HAVE_MPIX_COMM_GET_FAILED 1
4950
#define OMPI_HAVE_MPIX_COMM_ACK_FAILED 1
51+
#define OMPI_HAVE_MPIX_COMM_ISHRINK 1
5052

ompi/mpiext/ftmpi/mpif-h/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ f77_sources = \
2424
comm_revoke_f.c \
2525
comm_is_revoked_f.c \
2626
comm_shrink_f.c \
27+
comm_ishrink_f.c \
2728
comm_get_failed_f.c \
2829
comm_ack_failed_f.c \
2930
comm_failure_ack_f.c \
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2010-2022 The University of Tennessee and the University
3+
* of Tennessee Research Foundation. All rights
4+
* reserved.
5+
* $COPYRIGHT$
6+
*
7+
* Additional copyrights may follow
8+
*
9+
* $HEADER$
10+
*/
11+
#include "ompi_config.h"
12+
13+
#include "ompi/mpi/fortran/mpif-h/bindings.h"
14+
#include "ompi/mpi/fortran/base/constants.h"
15+
16+
#include "ompi/mpiext/ftmpi/c/mpiext_ftmpi_c.h"
17+
#include "ompi/mpiext/ftmpi/mpif-h/prototypes_mpi.h"
18+
19+
#include "ompi/communicator/communicator.h"
20+
#include "ompi/request/request.h"
21+
#include "ompi/mpi/fortran/base/fint_2_int.h"
22+
23+
#if OPAL_HAVE_WEAK_SYMBOLS
24+
#pragma weak PMPIX_COMM_ISHRINK = ompix_comm_ishrink_f
25+
#pragma weak pmpix_comm_ishrink = ompix_comm_ishrink_f
26+
#pragma weak pmpix_comm_ishrink_ = ompix_comm_ishrink_f
27+
#pragma weak pmpix_comm_ishrink__ = ompix_comm_ishrink_f
28+
#pragma weak PMPIX_Comm_ishrink_f = ompix_comm_ishrink_f
29+
#pragma weak PMPIX_Comm_ishrink_f08 = ompix_comm_ishrink_f
30+
31+
#pragma weak MPIX_COMM_ISHRINK = ompix_comm_ishrink_f
32+
#pragma weak mpix_comm_ishrink = ompix_comm_ishrink_f
33+
#pragma weak mpix_comm_ishrink_ = ompix_comm_ishrink_f
34+
#pragma weak mpix_comm_ishrink__ = ompix_comm_ishrink_f
35+
#pragma weak MPIX_Comm_ishrink_f = ompix_comm_ishrink_f
36+
#pragma weak MPIX_Comm_ishrink_f08 = ompix_comm_ishrink_f
37+
38+
#else /* No weak symbols */
39+
OMPI_GENERATE_F77_BINDINGS(PMPIX_COMM_ISHRINK,
40+
pmpix_comm_ishrink,
41+
pmpix_comm_ishrink_,
42+
pmpix_comm_ishrink__,
43+
ompix_comm_ishrink_f,
44+
(MPI_Fint *comm, MPI_Fint *newcomm, MPI_Fint *request, MPI_Fint *ierr),
45+
(comm, newcomm, request, ierr))
46+
47+
OMPI_GENERATE_F77_BINDINGS(MPIX_COMM_ISHRINK,
48+
mpix_comm_ishrink,
49+
mpix_comm_ishrink_,
50+
mpix_comm_ishrink__,
51+
ompix_comm_ishrink_f,
52+
(MPI_Fint *comm, MPI_Fint *newcomm, MPI_Fint *request, MPI_Fint *ierr),
53+
(comm, newcomm, request, ierr))
54+
#endif
55+
56+
void ompix_comm_ishrink_f(MPI_Fint *comm, MPI_Fint *newcomm, MPI_Fint *request, MPI_Fint *ierr)
57+
{
58+
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
59+
MPI_Request c_req;
60+
MPI_Comm c_newcomm;
61+
62+
*ierr = OMPI_INT_2_FINT(MPIX_Comm_ishrink(c_comm,
63+
&c_newcomm,
64+
&c_req));
65+
66+
if (MPI_SUCCESS == OMPI_FINT_2_INT(*ierr)) {
67+
*request = PMPI_Request_c2f(c_req);
68+
*newcomm = PMPI_Comm_c2f(c_newcomm);
69+
}
70+
else {
71+
*newcomm = PMPI_Comm_c2f(&ompi_mpi_comm_null.comm);
72+
}
73+
}

ompi/mpiext/ftmpi/mpif-h/comm_shrink_f.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010-2019 The University of Tennessee and the University
2+
* Copyright (c) 2010-2022 The University of Tennessee and the University
33
* of Tennessee Research Foundation. All rights
44
* reserved.
55
* $COPYRIGHT$
@@ -16,6 +16,8 @@
1616
#include "ompi/mpiext/ftmpi/c/mpiext_ftmpi_c.h"
1717
#include "ompi/mpiext/ftmpi/mpif-h/prototypes_mpi.h"
1818

19+
#include "ompi/communicator/communicator.h"
20+
1921
#if OPAL_HAVE_WEAK_SYMBOLS
2022
#pragma weak PMPIX_COMM_SHRINK = ompix_comm_shrink_f
2123
#pragma weak pmpix_comm_shrink = ompix_comm_shrink_f
@@ -59,4 +61,7 @@ void ompix_comm_shrink_f(MPI_Fint *comm, MPI_Fint *newcomm, MPI_Fint *ierr)
5961
if (MPI_SUCCESS == OMPI_FINT_2_INT(*ierr)) {
6062
*newcomm = PMPI_Comm_c2f(c_newcomm);
6163
}
64+
else {
65+
*newcomm = PMPI_Comm_c2f(&ompi_mpi_comm_null.comm);
66+
}
6267
}

ompi/mpiext/ftmpi/use-mpi-f08/Makefile.am

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ mpi_api_files = \
6262
comm_ack_failed_f08.F90 \
6363
comm_agree_f08.F90 \
6464
comm_iagree_f08.F90 \
65-
comm_shrink_f08.F90
65+
comm_shrink_f08.F90 \
66+
comm_ishrink_f08.F90
6667

6768
pmpi_api_files = \
6869
profile/pcomm_revoke_f08.F90 \
@@ -73,7 +74,8 @@ pmpi_api_files = \
7374
profile/pcomm_ack_failed_f08.F90 \
7475
profile/pcomm_agree_f08.F90 \
7576
profile/pcomm_iagree_f08.F90 \
76-
profile/pcomm_shrink_f08.F90
77+
profile/pcomm_shrink_f08.F90 \
78+
profile/pcomm_ishrink_f08.F90
7779

7880
mpi_api_lo_files = $(mpi_api_files:.F90=.lo)
7981
pmpi_api_lo_files = $(pmpi_api_files:.F90=.lo)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
! -*- f90 -*-
2+
!
3+
! Copyright (c) 2018-2022 The University of Tennessee and the University
4+
! of Tennessee Research Foundation. All rights
5+
! reserved.
6+
! $COPYRIGHT$
7+
!
8+
! Additional copyrights may follow
9+
!
10+
! $HEADER$
11+
!
12+
13+
subroutine MPIX_Comm_ishrink_f08(comm, newcomm, request, ierror)
14+
use :: mpi_f08_types, only : MPI_Comm, MPI_Request
15+
implicit none
16+
interface
17+
subroutine ompix_comm_ishrink_f(comm, newcomm, request, ierror) &
18+
BIND(C, name="ompix_comm_shrink_f")
19+
implicit none
20+
INTEGER, INTENT(IN) :: comm
21+
INTEGER, INTENT(OUT) :: newcomm
22+
INTEGER, INTENT(OUT) :: request
23+
INTEGER, INTENT(OUT) :: ierror
24+
end subroutine ompix_comm_ishrink_f
25+
end interface
26+
TYPE(MPI_Comm), INTENT(IN) :: comm
27+
TYPE(MPI_Comm), INTENT(OUT) :: newcomm
28+
TYPE(MPI_Request), INTENT(OUT) :: request
29+
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
30+
integer :: c_ierror
31+
32+
call ompix_comm_ishrink_f(comm%MPI_VAL, newcomm%MPI_VAL, request%MPI_VAL, c_ierror)
33+
if (present(ierror)) ierror = c_ierror
34+
35+
end subroutine MPIX_Comm_ishrink_f08

0 commit comments

Comments
 (0)