Skip to content

Commit d85191b

Browse files
committed
Add missing MPI_Status conversion subroutines
Only in C bindings: - MPI_Status_c2f08() - MPI_Status_f082c() In all bindings but mpif.h - MPI_Status_f082f() - MPI_Status_f2f08() and the PMPI_* related subroutines As initially inteded by the MPI forum, the Fortran to/from Fortran 2008 conversion subtoutines are *not* implemented in the mpif.h bindings. See the discussion at mpi-forum/mpi-issues#298 Refs. #1475 Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
1 parent a876ef6 commit d85191b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1058
-70
lines changed

config/ompi_config_files.m4

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# -*- shell-script -*-
22
#
33
# Copyright (c) 2009-2020 Cisco Systems, Inc. All rights reserved
4-
# Copyright (c) 2017-2018 Research Organization for Information Science
5-
# and Technology (RIST). All rights reserved.
4+
# Copyright (c) 2017-2020 Research Organization for Information Science
5+
# and Technology (RIST). All rights reserved.
66
# Copyright (c) 2018 Los Alamos National Security, LLC. All rights
77
# reserved.
88
# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
@@ -29,6 +29,8 @@ AC_DEFUN([OMPI_CONFIG_FILES],[
2929
ompi/mpi/fortran/base/Makefile
3030
ompi/mpi/fortran/mpif-h/Makefile
3131
ompi/mpi/fortran/mpif-h/profile/Makefile
32+
ompi/mpi/fortran/use-mpi/Makefile
33+
ompi/mpi/fortran/use-mpi/mpi-types.F90
3234
ompi/mpi/fortran/use-mpi-tkr/Makefile
3335
ompi/mpi/fortran/use-mpi-tkr/fortran_sizes.h
3436
ompi/mpi/fortran/use-mpi-tkr/fortran_kinds.sh

config/ompi_setup_mpi_fortran.m4

+27-14
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,21 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[
387387
[OMPI_TRY_FORTRAN_BINDINGS=$OMPI_FORTRAN_MPIFH_BINDINGS
388388
AC_MSG_RESULT([no])])
389389

390+
OMPI_FORTRAN_HAVE_BIND_C_TYPE=0
391+
OMPI_FORTRAN_HAVE_TYPE_MPI_STATUS=0
392+
393+
AS_IF([test $OMPI_BUILD_FORTRAN_BINDINGS -ge $OMPI_FORTRAN_USEMPI_BINDINGS],
394+
[OMPI_FORTRAN_CHECK_BIND_C_TYPE(
395+
[OMPI_FORTRAN_HAVE_BIND_C_TYPE=1
396+
OMPI_FORTRAN_HAVE_TYPE_MPI_STATUS=1])])
397+
398+
AC_SUBST(OMPI_FORTRAN_HAVE_TYPE_MPI_STATUS)
399+
AM_CONDITIONAL(OMPI_FORTRAN_HAVE_TYPE_MPI_STATUS,
400+
[test $OMPI_FORTRAN_HAVE_TYPE_MPI_STATUS -eq 1])
401+
#AC_DEFINE_UNQUOTED(OMPI_FORTRAN_HAVE_TYPE_MPI_STATUS,
402+
#[$OMPI_FORTRAN_HAVE_TYPE_MPI_STATUS],
403+
#[For configure-fortran-output.h: Whether the compiler supports TYPE(MPI_Status) or not])
404+
390405
#---------------------------------
391406
# Fortran use mpi_f08 MPI bindings
392407
#---------------------------------
@@ -422,14 +437,11 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[
422437
[OMPI_FORTRAN_HAVE_BIND_C_SUB=0
423438
OMPI_BUILD_FORTRAN_BINDINGS=$OMPI_FORTRAN_USEMPI_BINDINGS])])
424439

425-
OMPI_FORTRAN_HAVE_BIND_C_TYPE=0
426440
AS_IF([test $OMPI_TRY_FORTRAN_BINDINGS -ge $OMPI_FORTRAN_USEMPIF08_BINDINGS && \
427441
test $OMPI_BUILD_FORTRAN_BINDINGS -ge $OMPI_FORTRAN_USEMPIF08_BINDINGS],
428442
[ # If we don't have TYPE, BIND(C), we won't build mpi_f08 at all
429-
OMPI_FORTRAN_CHECK_BIND_C_TYPE(
430-
[OMPI_FORTRAN_HAVE_BIND_C_TYPE=1],
431-
[OMPI_FORTRAN_HAVE_BIND_C_TYPE=0
432-
OMPI_BUILD_FORTRAN_BINDINGS=$OMPI_FORTRAN_USEMPI_BINDINGS])])
443+
AS_IF([test $OMPI_FORTRAN_HAVE_BIND_C_TYPE -ne 1],
444+
[OMPI_BUILD_FORTRAN_BINDINGS=$OMPI_FORTRAN_USEMPI_BINDINGS])])
433445

434446
# Per discussion on the devel list starting here:
435447
# https://www.open-mpi.org/community/lists/devel/2014/01/13799.php
@@ -701,6 +713,16 @@ end type test_mpi_handle],
701713
AM_CONDITIONAL(OMPI_BUILD_FORTRAN_USEMPI_IGNORE_TKR_BINDINGS,
702714
[test $OMPI_BUILD_FORTRAN_BINDINGS -ge $OMPI_FORTRAN_USEMPI_BINDINGS && \
703715
test $OMPI_FORTRAN_HAVE_IGNORE_TKR -eq 1])
716+
# True if we support TYPE, BIND(C)
717+
AC_DEFINE_UNQUOTED(OMPI_FORTRAN_HAVE_BIND_C_TYPE,
718+
[$OMPI_FORTRAN_HAVE_BIND_C_TYPE],
719+
[For ompi_info: Whether the compiler supports TYPE, BIND(C) or not])
720+
721+
# For mpif-status.h, configure-fortran-output.h, mpi-f08-types.F90 (and ompi_info)
722+
AC_SUBST([OMPI_FORTRAN_HAVE_PRIVATE])
723+
AC_DEFINE_UNQUOTED([OMPI_FORTRAN_HAVE_PRIVATE],
724+
[$OMPI_FORTRAN_HAVE_PRIVATE],
725+
[For mpif-status.h, mpi-f08-types.f90 and ompi_info: whether the compiler supports the "private" keyword or not (used in TYPE(MPI_Status))])
704726

705727
# -------------------
706728
# use mpi_f08 final setup
@@ -749,22 +771,13 @@ end type test_mpi_handle],
749771
AC_DEFINE_UNQUOTED(OMPI_FORTRAN_HAVE_BIND_C_SUB,
750772
[$OMPI_FORTRAN_HAVE_BIND_C_SUB],
751773
[For ompi_info: Whether the compiler supports SUBROUTINE ... BIND(C) or not])
752-
AC_DEFINE_UNQUOTED(OMPI_FORTRAN_HAVE_BIND_C_TYPE,
753-
[$OMPI_FORTRAN_HAVE_BIND_C_TYPE],
754-
[For ompi_info: Whether the compiler supports TYPE, BIND(C) or not])
755774
AC_DEFINE_UNQUOTED(OMPI_FORTRAN_HAVE_BIND_C_TYPE_NAME,
756775
[$OMPI_FORTRAN_HAVE_BIND_C_TYPE_NAME],
757776
[For ompi_info: Whether the compiler supports TYPE, BIND(C, NAME="name") or not])
758777
AC_DEFINE_UNQUOTED([OMPI_FORTRAN_HAVE_OPTIONAL_ARGS],
759778
[$OMPI_FORTRAN_HAVE_OPTIONAL_ARGS],
760779
[For ompi_info: whether the Fortran compiler supports optional arguments or not])
761780

762-
# For configure-fortran-output.h, mpi-f08-types.F90 (and ompi_info)
763-
AC_SUBST([OMPI_FORTRAN_HAVE_PRIVATE])
764-
AC_DEFINE_UNQUOTED([OMPI_FORTRAN_HAVE_PRIVATE],
765-
[$OMPI_FORTRAN_HAVE_PRIVATE],
766-
[For mpi-f08-types.f90 and ompi_info: whether the compiler supports the "private" keyword or not (used in MPI_Status)])
767-
768781
# For configure-fortran-output.h, mpi-f08-interfaces-callbacks.F90
769782
# (and ompi_info)
770783
AC_SUBST([OMPI_FORTRAN_HAVE_ABSTRACT])

ompi/Makefile.am

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
1616
# reserved.
1717
# Copyright (c) 2015-2019 Intel, Inc. All rights reserved.
18-
# Copyright (c) 2015-2018 Research Organization for Information Science
19-
# and Technology (RIST). All rights reserved.
18+
# Copyright (c) 2015-2020 Research Organization for Information Science
19+
# and Technology (RIST). All rights reserved.
2020
# Copyright (c) 2016 IBM Corporation. All rights reserved.
2121
# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
2222
# $COPYRIGHT$
@@ -88,6 +88,7 @@ SUBDIRS = \
8888
. \
8989
$(OMPI_MPIEXT_MPIFH_DIRS) \
9090
mpi/fortran/mpif-h \
91+
mpi/fortran/use-mpi \
9192
$(OMPI_MPIEXT_USEMPI_DIR) \
9293
$(OMPI_FORTRAN_USEMPI_DIR) \
9394
mpi/fortran/mpiext-use-mpi \
@@ -121,6 +122,7 @@ DIST_SUBDIRS = \
121122
mpi/tool \
122123
mpi/fortran/base \
123124
mpi/fortran/mpif-h \
125+
mpi/fortran/use-mpi \
124126
mpi/fortran/use-mpi-tkr \
125127
mpi/fortran/use-mpi-ignore-tkr \
126128
mpi/fortran/mpiext-use-mpi \

ompi/include/mpi.h.in

+9
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ typedef struct ompi_op_t *MPI_Op;
411411
typedef struct ompi_request_t *MPI_Request;
412412
typedef struct ompi_message_t *MPI_Message;
413413
typedef struct ompi_status_public_t MPI_Status;
414+
typedef struct ompi_f08_status_public_t MPI_F08_status;
414415
typedef struct ompi_win_t *MPI_Win;
415416
typedef struct mca_base_var_enum_t *MPI_T_enum;
416417
typedef struct ompi_mpit_cvar_handle_t *MPI_T_cvar_handle;
@@ -1779,7 +1780,11 @@ OMPI_DECLSPEC int MPI_Ssend(const void *buf, int count, MPI_Datatype datatype,
17791780
OMPI_DECLSPEC int MPI_Start(MPI_Request *request);
17801781
OMPI_DECLSPEC int MPI_Startall(int count, MPI_Request array_of_requests[]);
17811782
OMPI_DECLSPEC int MPI_Status_c2f(const MPI_Status *c_status, MPI_Fint *f_status);
1783+
OMPI_DECLSPEC int MPI_Status_c2f08(const MPI_Status *c_status, MPI_F08_status *f08_status);
1784+
OMPI_DECLSPEC int MPI_Status_f082c(const MPI_F08_status *f08_status, MPI_Status *c_status);
1785+
OMPI_DECLSPEC int MPI_Status_f082f(const MPI_F08_status *f08_status, MPI_Fint *f_status);
17821786
OMPI_DECLSPEC int MPI_Status_f2c(const MPI_Fint *f_status, MPI_Status *c_status);
1787+
OMPI_DECLSPEC int MPI_Status_f2f08(const MPI_Fint *f_status, MPI_F08_status *f08_status);
17831788
OMPI_DECLSPEC int MPI_Status_set_cancelled(MPI_Status *status, int flag);
17841789
OMPI_DECLSPEC int MPI_Status_set_elements(MPI_Status *status, MPI_Datatype datatype,
17851790
int count);
@@ -2440,7 +2445,11 @@ OMPI_DECLSPEC int PMPI_Ssend(const void *buf, int count, MPI_Datatype datatype,
24402445
OMPI_DECLSPEC int PMPI_Start(MPI_Request *request);
24412446
OMPI_DECLSPEC int PMPI_Startall(int count, MPI_Request array_of_requests[]);
24422447
OMPI_DECLSPEC int PMPI_Status_c2f(const MPI_Status *c_status, MPI_Fint *f_status);
2448+
OMPI_DECLSPEC int PMPI_Status_c2f08(const MPI_Status *c_status, MPI_F08_status *f08_status);
2449+
OMPI_DECLSPEC int PMPI_Status_f082f(const MPI_F08_status *f08_status, MPI_Fint *f_status);
2450+
OMPI_DECLSPEC int PMPI_Status_f082c(const MPI_F08_status *f08_status, MPI_Status *c_status);
24432451
OMPI_DECLSPEC int PMPI_Status_f2c(const MPI_Fint *f_status, MPI_Status *c_status);
2452+
OMPI_DECLSPEC int PMPI_Status_f2f08(const MPI_Fint *f_status, MPI_F08_status *f08_status);
24442453
OMPI_DECLSPEC int PMPI_Status_set_cancelled(MPI_Status *status, int flag);
24452454
OMPI_DECLSPEC int PMPI_Status_set_elements(MPI_Status *status, MPI_Datatype datatype,
24462455
int count);

ompi/mpi/c/Makefile.am

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# Copyright (c) 2012-2013 Inria. All rights reserved.
1616
# Copyright (c) 2013-2018 Los Alamos National Security, LLC. All rights
1717
# reserved.
18-
# Copyright (c) 2015-2018 Research Organization for Information Science
19-
# and Technology (RIST). All rights reserved.
18+
# Copyright (c) 2015-2020 Research Organization for Information Science
19+
# and Technology (RIST). All rights reserved.
2020
# $COPYRIGHT$
2121
#
2222
# Additional copyrights may follow
@@ -339,7 +339,11 @@ libmpi_c_mpi_la_SOURCES = \
339339
start.c \
340340
startall.c \
341341
status_c2f.c \
342+
status_c2f08.c \
343+
status_f082c.c \
344+
status_f082f.c \
342345
status_f2c.c \
346+
status_f2f08.c \
343347
status_set_cancelled.c \
344348
status_set_elements.c \
345349
status_set_elements_x.c \

ompi/mpi/c/profile/Makefile.am

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
# Copyright (c) 2012-2013 Inria. All rights reserved.
1717
# Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1818
# reserved.
19-
# Copyright (c) 2015-2018 Research Organization for Information Science
20-
# and Technology (RIST). All rights reserved.
19+
# Copyright (c) 2015-2020 Research Organization for Information Science
20+
# and Technology (RIST). All rights reserved.
2121
# $COPYRIGHT$
2222
#
2323
# Additional copyrights may follow
@@ -319,6 +319,10 @@ nodist_libmpi_c_pmpi_la_SOURCES = \
319319
pstart.c \
320320
pstartall.c \
321321
pstatus_c2f.c \
322+
pstatus_c2f08.c \
323+
pstatus_f082c.c \
324+
pstatus_f082f.c \
325+
pstatus_f2f08.c \
322326
pstatus_f2c.c \
323327
pstatus_set_cancelled.c \
324328
pstatus_set_elements.c \

ompi/mpi/c/status_c2f08.c

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
4+
* University Research and Technology
5+
* Corporation. All rights reserved.
6+
* Copyright (c) 2004-2005 The University of Tennessee and The University
7+
* of Tennessee Research Foundation. All rights
8+
* reserved.
9+
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
10+
* University of Stuttgart. All rights reserved.
11+
* Copyright (c) 2004-2005 The Regents of the University of California.
12+
* All rights reserved.
13+
* Copyright (c) 2010-2012 Cisco Systems, Inc. All rights reserved.
14+
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
15+
* reserved.
16+
* Copyright (c) 2015-2020 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
18+
* $COPYRIGHT$
19+
*
20+
* Additional copyrights may follow
21+
*
22+
* $HEADER$
23+
*/
24+
#include "ompi_config.h"
25+
#include <stdio.h>
26+
27+
#include "ompi/mpi/c/bindings.h"
28+
#include "ompi/runtime/params.h"
29+
#include "ompi/communicator/communicator.h"
30+
#include "ompi/errhandler/errhandler.h"
31+
#include "ompi/mpi/fortran/base/fint_2_int.h"
32+
#include "ompi/mpi/fortran/base/constants.h"
33+
#include "ompi/memchecker.h"
34+
35+
#if OMPI_BUILD_MPI_PROFILING
36+
#if OPAL_HAVE_WEAK_SYMBOLS
37+
#pragma weak MPI_Status_c2f08 = PMPI_Status_c2f08
38+
#endif
39+
#define MPI_Status_c2f08 PMPI_Status_c2f08
40+
#endif
41+
42+
static const char FUNC_NAME[] = "MPI_Status_c2f08";
43+
44+
45+
int MPI_Status_c2f08(const MPI_Status *c_status, MPI_F08_status *f08_status)
46+
{
47+
const int *c_ints;
48+
MEMCHECKER(
49+
if(c_status != MPI_STATUSES_IGNORE) {
50+
/*
51+
* Before checking the complete status, we need to reset the definedness
52+
* of the MPI_ERROR-field (single-completion calls wait/test).
53+
*/
54+
opal_memchecker_base_mem_defined((void*)&c_status->MPI_ERROR, sizeof(int));
55+
memchecker_status(c_status);
56+
}
57+
);
58+
59+
OPAL_CR_NOOP_PROGRESS();
60+
61+
if (MPI_PARAM_CHECK) {
62+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
63+
64+
/* MPI-2:4.12.5 says that if you pass in
65+
MPI_STATUS[ES]_IGNORE, it's erroneous */
66+
67+
if (NULL == c_status || MPI_STATUS_IGNORE == c_status ||
68+
MPI_STATUSES_IGNORE == c_status || NULL == f08_status) {
69+
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
70+
MPI_ERR_IN_STATUS, FUNC_NAME);
71+
}
72+
}
73+
74+
/* ***NOTE*** See huge comment in status_c2f.c (yes, I know
75+
there's a size_t member in the C MPI_Status -- go
76+
read that comment for an explanation why copying
77+
everything as a bunch of int's is ok). */
78+
f08_status->MPI_SOURCE = OMPI_INT_2_FINT(c_status->MPI_SOURCE);
79+
f08_status->MPI_TAG = OMPI_INT_2_FINT(c_status->MPI_TAG);
80+
f08_status->MPI_ERROR = OMPI_INT_2_FINT(c_status->MPI_ERROR);
81+
c_ints = (const int *)c_status + 3;
82+
for(int i = 0; i < (int)(sizeof(MPI_Status) / sizeof(int) - 3); i++ )
83+
f08_status->internal[i] = OMPI_INT_2_FINT(c_ints[i]);
84+
85+
return MPI_SUCCESS;
86+
}

ompi/mpi/c/status_f082c.c

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
4+
* University Research and Technology
5+
* Corporation. All rights reserved.
6+
* Copyright (c) 2004-2005 The University of Tennessee and The University
7+
* of Tennessee Research Foundation. All rights
8+
* reserved.
9+
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10+
* University of Stuttgart. All rights reserved.
11+
* Copyright (c) 2004-2005 The Regents of the University of California.
12+
* All rights reserved.
13+
* Copyright (c) 2010-2012 Cisco Systems, Inc. All rights reserved.
14+
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
15+
* reserved.
16+
* Copyright (c) 2015-2020 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
18+
* $COPYRIGHT$
19+
*
20+
* Additional copyrights may follow
21+
*
22+
* $HEADER$
23+
*/
24+
#include "ompi_config.h"
25+
26+
#include "ompi/mpi/c/bindings.h"
27+
#include "ompi/runtime/params.h"
28+
#include "ompi/communicator/communicator.h"
29+
#include "ompi/errhandler/errhandler.h"
30+
#include "ompi/mpi/fortran/base/fint_2_int.h"
31+
#include "ompi/mpi/fortran/base/constants.h"
32+
33+
#if OMPI_BUILD_MPI_PROFILING
34+
#if OPAL_HAVE_WEAK_SYMBOLS
35+
#pragma weak MPI_Status_f082c = PMPI_Status_f082c
36+
#endif
37+
#define MPI_Status_f082c PMPI_Status_f082c
38+
#endif
39+
40+
static const char FUNC_NAME[] = "MPI_Status_f082c";
41+
42+
43+
int MPI_Status_f082c(const MPI_F08_status *f08_status, MPI_Status *c_status)
44+
{
45+
int *c_ints;
46+
OPAL_CR_NOOP_PROGRESS();
47+
48+
if (MPI_PARAM_CHECK) {
49+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
50+
51+
/* MPI-2:4.12.5 says that if you pass in
52+
MPI_STATUS[ES]_IGNORE, it's erroneous */
53+
54+
if (NULL == f08_status ||
55+
#if OMPI_BUILD_FORTRAN_BINDINGS
56+
/* This section is #if'ed out if we are not building the
57+
fortran bindings because these macros check values
58+
against constants that only exist if the fortran
59+
bindings exist. */
60+
OMPI_IS_FORTRAN_STATUS_IGNORE(f08_status) ||
61+
OMPI_IS_FORTRAN_STATUSES_IGNORE(f08_status) ||
62+
#endif
63+
NULL == c_status) {
64+
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
65+
MPI_ERR_IN_STATUS, FUNC_NAME);
66+
}
67+
}
68+
69+
/* ***NOTE*** See huge comment in status_c2f.c (yes, I know
70+
there's a size_t member in the C MPI_Status -- go
71+
read that comment for an explanation why copying
72+
everything as a bunch of int's is ok).
73+
74+
We can't use OMPI_FINT_2_INT here because of some complications
75+
with include files. :-( So just do the casting manually. */
76+
c_status->MPI_SOURCE = (int)f08_status->MPI_SOURCE;
77+
c_status->MPI_TAG = (int)f08_status->MPI_TAG;
78+
c_status->MPI_ERROR = (int)f08_status->MPI_ERROR;
79+
c_ints = (int *)c_status + 3;
80+
for(int i=0; i < (int)(sizeof(MPI_Status) / sizeof(int) - 3); i++)
81+
c_ints[i] = (int)f08_status->internal[i];
82+
83+
return MPI_SUCCESS;
84+
}

0 commit comments

Comments
 (0)