Skip to content

Commit 1d5c8e9

Browse files
committed
Add missing MPI_Status conversion subroutines
- MPI_Status_c2f08() - MPI_Status_f082c() - MPI_Status_f082f() - MPI_Status_f2f08() and the PMPI_* related subroutines Refs. #1475 Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 4d0c23c commit 1d5c8e9

18 files changed

+596
-12
lines changed

ompi/include/mpi.h.in

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* reserved.
1818
* Copyright (c) 2011-2013 INRIA. All rights reserved.
1919
* Copyright (c) 2015 University of Houston. All rights reserved.
20-
* Copyright (c) 2015-2018 Research Organization for Information Science
21-
* and Technology (RIST). All rights reserved.
20+
* Copyright (c) 2015-2020 Research Organization for Information Science
21+
* and Technology (RIST). All rights reserved.
2222
* Copyright (c) 2017-2019 IBM Corporation. All rights reserved.
2323
* Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
2424
* $COPYRIGHT$
@@ -390,6 +390,7 @@ typedef struct ompi_op_t *MPI_Op;
390390
typedef struct ompi_request_t *MPI_Request;
391391
typedef struct ompi_message_t *MPI_Message;
392392
typedef struct ompi_status_public_t MPI_Status;
393+
typedef struct ompi_f08_status_public_t MPI_F08_status;
393394
typedef struct ompi_win_t *MPI_Win;
394395
typedef struct mca_base_var_enum_t *MPI_T_enum;
395396
typedef struct ompi_mpit_cvar_handle_t *MPI_T_cvar_handle;
@@ -414,6 +415,24 @@ struct ompi_status_public_t {
414415
};
415416
typedef struct ompi_status_public_t ompi_status_public_t;
416417

418+
/*
419+
* MPI_F08_status
420+
*/
421+
struct ompi_f08_status_public_t {
422+
/* These fields are publicly defined in the MPI specification.
423+
User applications may freely read from these fields. */
424+
MPI_Fint MPI_SOURCE;
425+
MPI_Fint MPI_TAG;
426+
MPI_Fint MPI_ERROR;
427+
/* The following two fields are internal to the Open MPI
428+
implementation and should not be accessed by MPI applications.
429+
They are subject to change at any time. These are not the
430+
droids you're looking for. */
431+
int _cancelled;
432+
size_t _ucount;
433+
};
434+
typedef struct ompi_f08_status_public_t ompi_f08_status_public_t;
435+
417436
/*
418437
* User typedefs
419438
*/
@@ -1742,7 +1761,11 @@ OMPI_DECLSPEC int MPI_Ssend(const void *buf, int count, MPI_Datatype datatype,
17421761
OMPI_DECLSPEC int MPI_Start(MPI_Request *request);
17431762
OMPI_DECLSPEC int MPI_Startall(int count, MPI_Request array_of_requests[]);
17441763
OMPI_DECLSPEC int MPI_Status_c2f(const MPI_Status *c_status, MPI_Fint *f_status);
1764+
OMPI_DECLSPEC int MPI_Status_c2f08(const MPI_Status *c_status, MPI_F08_status *f08_status);
1765+
OMPI_DECLSPEC int MPI_Status_f082c(const MPI_F08_status *f08_status, MPI_Status *c_status);
1766+
OMPI_DECLSPEC int MPI_Status_f082f(const MPI_F08_status *f08_status, MPI_Fint *f_status);
17451767
OMPI_DECLSPEC int MPI_Status_f2c(const MPI_Fint *f_status, MPI_Status *c_status);
1768+
OMPI_DECLSPEC int MPI_Status_f2f08(const MPI_Fint *f_status, MPI_F08_status *f08_status);
17461769
OMPI_DECLSPEC int MPI_Status_set_cancelled(MPI_Status *status, int flag);
17471770
OMPI_DECLSPEC int MPI_Status_set_elements(MPI_Status *status, MPI_Datatype datatype,
17481771
int count);
@@ -2403,7 +2426,11 @@ OMPI_DECLSPEC int PMPI_Ssend(const void *buf, int count, MPI_Datatype datatype,
24032426
OMPI_DECLSPEC int PMPI_Start(MPI_Request *request);
24042427
OMPI_DECLSPEC int PMPI_Startall(int count, MPI_Request array_of_requests[]);
24052428
OMPI_DECLSPEC int PMPI_Status_c2f(const MPI_Status *c_status, MPI_Fint *f_status);
2429+
OMPI_DECLSPEC int PMPI_Status_c2f08(const MPI_Status *c_status, MPI_F08_status *f08_status);
2430+
OMPI_DECLSPEC int PMPI_Status_f082f(const MPI_F08_status *f08_status, MPI_Fint *f_status);
2431+
OMPI_DECLSPEC int PMPI_Status_f082c(const MPI_F08_status *f08_status, MPI_Status *c_status);
24062432
OMPI_DECLSPEC int PMPI_Status_f2c(const MPI_Fint *f_status, MPI_Status *c_status);
2433+
OMPI_DECLSPEC int PMPI_Status_f2f08(const MPI_Fint *f_status, MPI_F08_status *f08_status);
24072434
OMPI_DECLSPEC int PMPI_Status_set_cancelled(MPI_Status *status, int flag);
24082435
OMPI_DECLSPEC int PMPI_Status_set_elements(MPI_Status *status, MPI_Datatype datatype,
24092436
int count);

ompi/mpi/c/Makefile.am

Lines changed: 6 additions & 2 deletions
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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
MEMCHECKER(
48+
if(c_status != MPI_STATUSES_IGNORE) {
49+
/*
50+
* Before checking the complete status, we need to reset the definedness
51+
* of the MPI_ERROR-field (single-completion calls wait/test).
52+
*/
53+
opal_memchecker_base_mem_defined((void*)&c_status->MPI_ERROR, sizeof(int));
54+
memchecker_status(c_status);
55+
}
56+
);
57+
58+
OPAL_CR_NOOP_PROGRESS();
59+
60+
if (MPI_PARAM_CHECK) {
61+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
62+
63+
/* MPI-2:4.12.5 says that if you pass in
64+
MPI_STATUS[ES]_IGNORE, it's erroneous */
65+
66+
if (NULL == c_status || MPI_STATUS_IGNORE == c_status ||
67+
MPI_STATUSES_IGNORE == c_status || NULL == f08_status) {
68+
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
69+
MPI_ERR_IN_STATUS, FUNC_NAME);
70+
}
71+
}
72+
73+
/* Note that MPI-2.2 16.3.5 states that even the hidden data in a
74+
status must be converted (!). This is somewhat problematic
75+
because the Fortran data is all INTEGERS while the C MPI_Status
76+
contains a size_t. That being said, note 2 things:
77+
78+
1. The _ucount and _canceled members are never accessed from
79+
Fortran.
80+
2. configure calculated a value of MPI_STATUS_SIZE to ensure
81+
that the Fortran status is the Right size to hold the C
82+
MPI_Status (including the size_t member).
83+
84+
So for the purposes of this function, just copy over all the
85+
data as if they were int's. This works because all OMPI
86+
Fortran MPI API functions that take a status as an IN argument
87+
first call MPI_Status_f2c on it before using it (in which case
88+
we'll do the exact opposite copy, thereby rebuilding the size_t
89+
value properly before it is accessed in C).
90+
91+
Note that if sizeof(int) > sizeof(INTEGER), we're potentially
92+
hosed anyway (i.e., even the public values in the status could
93+
get truncated). But if sizeof(int) == sizeof(INTEGER) or
94+
sizeof(int) < sizeof(INTEGER), everything should be kosher. */
95+
96+
f08_status->MPI_SOURCE = OMPI_INT_2_FINT(c_status->MPI_SOURCE);
97+
f08_status->MPI_TAG = OMPI_INT_2_FINT(c_status->MPI_TAG);
98+
f08_status->MPI_ERROR = OMPI_INT_2_FINT(c_status->MPI_ERROR);
99+
f08_status->_cancelled = c_status->_cancelled;
100+
f08_status->_ucount = c_status->_ucount;
101+
102+
return MPI_SUCCESS;
103+
}

ompi/mpi/c/status_f082c.c

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
OPAL_CR_NOOP_PROGRESS();
46+
47+
if (MPI_PARAM_CHECK) {
48+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
49+
50+
/* MPI-2:4.12.5 says that if you pass in
51+
MPI_STATUS[ES]_IGNORE, it's erroneous */
52+
53+
if (NULL == f08_status ||
54+
#if OMPI_BUILD_FORTRAN_BINDINGS
55+
/* This section is #if'ed out if we are not building the
56+
fortran bindings because these macros check values
57+
against constants that only exist if the fortran
58+
bindings exist. */
59+
OMPI_IS_FORTRAN_STATUS_IGNORE(f08_status) ||
60+
OMPI_IS_FORTRAN_STATUSES_IGNORE(f08_status) ||
61+
#endif
62+
NULL == c_status) {
63+
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
64+
MPI_ERR_IN_STATUS, FUNC_NAME);
65+
}
66+
}
67+
68+
/* We can't use OMPI_FINT_2_INT here because of some complications
69+
with include files. :-( So just do the casting manually. */
70+
71+
c_status->MPI_SOURCE = (int)f08_status->MPI_SOURCE;
72+
c_status->MPI_TAG = (int)f08_status->MPI_TAG;
73+
c_status->MPI_ERROR = (int)f08_status->MPI_ERROR;
74+
c_status->_cancelled = f08_status->_cancelled;
75+
c_status->_ucount = f08_status->_ucount;
76+
77+
return MPI_SUCCESS;
78+
}

ompi/mpi/c/status_f082f.c

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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_f082f = PMPI_Status_f082f
36+
#endif
37+
#define MPI_Status_f082f PMPI_Status_f082f
38+
#endif
39+
40+
static const char FUNC_NAME[] = "MPI_Status_f082f";
41+
42+
43+
int MPI_Status_f082f(const MPI_F08_status *f08_status, MPI_Fint *f_status)
44+
{
45+
OPAL_CR_NOOP_PROGRESS();
46+
47+
if (MPI_PARAM_CHECK) {
48+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
49+
50+
/* MPI-2:4.12.5 says that if you pass in
51+
MPI_STATUS[ES]_IGNORE, it's erroneous */
52+
53+
if (NULL == f08_status ||
54+
#if OMPI_BUILD_FORTRAN_BINDINGS
55+
/* This section is #if'ed out if we are not building the
56+
fortran bindings because these macros check values
57+
against constants that only exist if the fortran
58+
bindings exist. */
59+
OMPI_IS_FORTRAN_STATUS_IGNORE(f08_status) ||
60+
OMPI_IS_FORTRAN_STATUSES_IGNORE(f08_status) ||
61+
#endif
62+
NULL == f_status) {
63+
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
64+
MPI_ERR_IN_STATUS, FUNC_NAME);
65+
}
66+
}
67+
68+
MPI_Status c_status;
69+
int ret;
70+
71+
ret = PMPI_Status_f082c(f08_status, &c_status);
72+
if (MPI_SUCCESS != ret) {
73+
return ret;
74+
}
75+
76+
ret = PMPI_Status_c2f(&c_status, f_status);
77+
78+
return ret;
79+
}

0 commit comments

Comments
 (0)