Skip to content

Commit e61248d

Browse files
committed
mpi: add new status_set/get functions
MPI4.1 introduced a few new MPI_Status_get/set functions. This PR is the C API implementations of the functions. Signed-off-by: Edgar Gabriel <[email protected]>
1 parent b79b3e9 commit e61248d

File tree

8 files changed

+365
-0
lines changed

8 files changed

+365
-0
lines changed

ompi/include/mpi.h.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* Copyright (c) 2018 Triad National Security, LLC. All rights
2929
* Copyright (c) 2018-2022 Triad National Security, LLC. All rights
3030
* reserved.
31+
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved
3132
* $COPYRIGHT$
3233
*
3334
* Additional copyrights may follow
@@ -1985,7 +1986,13 @@ OMPI_DECLSPEC int MPI_Status_f082c(const MPI_F08_status *f08_status, MPI_Status
19851986
OMPI_DECLSPEC int MPI_Status_f082f(const MPI_F08_status *f08_status, MPI_Fint *f_status);
19861987
OMPI_DECLSPEC int MPI_Status_f2c(const MPI_Fint *f_status, MPI_Status *c_status);
19871988
OMPI_DECLSPEC int MPI_Status_f2f08(const MPI_Fint *f_status, MPI_F08_status *f08_status);
1989+
OMPI_DECLSPEC int MPI_Status_get_error(const MPI_Status *status, int *error);
1990+
OMPI_DECLSPEC int MPI_Status_get_source(const MPI_Status *status, int *source);
1991+
OMPI_DECLSPEC int MPI_Status_get_tag(const MPI_Status *status, int *tag);
19881992
OMPI_DECLSPEC int MPI_Status_set_cancelled(MPI_Status *status, int flag);
1993+
OMPI_DECLSPEC int MPI_Status_set_error(MPI_Status *status, int error);
1994+
OMPI_DECLSPEC int MPI_Status_set_source(MPI_Status *status, int source);
1995+
OMPI_DECLSPEC int MPI_Status_set_tag(MPI_Status *status, int tag);
19891996
OMPI_DECLSPEC int MPI_Status_set_elements(MPI_Status *status, MPI_Datatype datatype,
19901997
int count);
19911998
OMPI_DECLSPEC int MPI_Status_set_elements_x(MPI_Status *status, MPI_Datatype datatype,
@@ -2746,7 +2753,13 @@ OMPI_DECLSPEC int PMPI_Status_f082f(const MPI_F08_status *f08_status, MPI_Fint
27462753
OMPI_DECLSPEC int PMPI_Status_f082c(const MPI_F08_status *f08_status, MPI_Status *c_status);
27472754
OMPI_DECLSPEC int PMPI_Status_f2c(const MPI_Fint *f_status, MPI_Status *c_status);
27482755
OMPI_DECLSPEC int PMPI_Status_f2f08(const MPI_Fint *f_status, MPI_F08_status *f08_status);
2756+
OMPI_DECLSPEC int PMPI_Status_get_error(const MPI_Status *status, int *error);
2757+
OMPI_DECLSPEC int PMPI_Status_get_source(const MPI_Status *status, int *source);
2758+
OMPI_DECLSPEC int PMPI_Status_get_tag(const MPI_Status *status, int *tag);
27492759
OMPI_DECLSPEC int PMPI_Status_set_cancelled(MPI_Status *status, int flag);
2760+
OMPI_DECLSPEC int PMPI_Status_set_error(MPI_Status *status, int error);
2761+
OMPI_DECLSPEC int PMPI_Status_set_source(MPI_Status *status, int source);
2762+
OMPI_DECLSPEC int PMPI_Status_set_tag(MPI_Status *status, int tag);
27502763
OMPI_DECLSPEC int PMPI_Status_set_elements(MPI_Status *status, MPI_Datatype datatype,
27512764
int count);
27522765
OMPI_DECLSPEC int PMPI_Status_set_elements_x(MPI_Status *status, MPI_Datatype datatype,

ompi/mpi/c/Makefile.am

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# and Technology (RIST). All rights reserved.
2020
# Copyright (c) 2021 Amazon.com, Inc. or its affiliates. All Rights
2121
# reserved.
22+
# Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights reserved.
2223
# $COPYRIGHT$
2324
#
2425
# Additional copyrights may follow
@@ -392,9 +393,15 @@ interface_profile_sources = \
392393
status_f082f.c \
393394
status_f2c.c \
394395
status_f2f08.c \
396+
status_get_error.c \
397+
status_get_source.c \
398+
status_get_tag.c \
395399
status_set_cancelled.c \
396400
status_set_elements.c \
397401
status_set_elements_x.c \
402+
status_set_error.c \
403+
status_set_source.c \
404+
status_set_tag.c \
398405
testall.c \
399406
testany.c \
400407
test.c \

ompi/mpi/c/status_get_error.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
4+
* $COPYRIGHT$
5+
*
6+
* Additional copyrights may follow
7+
*
8+
* $HEADER$
9+
*/
10+
#include "ompi_config.h"
11+
#include <stdio.h>
12+
#include <limits.h>
13+
14+
#include "ompi/mpi/c/bindings.h"
15+
#include "ompi/runtime/params.h"
16+
#include "ompi/errhandler/errhandler.h"
17+
#include "ompi/memchecker.h"
18+
19+
#if OMPI_BUILD_MPI_PROFILING
20+
#if OPAL_HAVE_WEAK_SYMBOLS
21+
#pragma weak MPI_Status_get_error = PMPI_Status_get_error
22+
#endif
23+
#define MPI_Status_get_error PMPI_Status_get_error
24+
#endif
25+
26+
static const char FUNC_NAME[] = "MPI_Status_get_error";
27+
28+
29+
int MPI_Status_get_error(const MPI_Status *status, int *error)
30+
{
31+
int rc = MPI_SUCCESS;
32+
33+
MEMCHECKER(
34+
if (status != MPI_STATUSES_IGNORE) {
35+
/*
36+
* Before checking the complete status, we need to reset the definedness
37+
* of the MPI_ERROR-field (single-completion calls wait/test).
38+
*/
39+
opal_memchecker_base_mem_defined((void*)&status->MPI_ERROR, sizeof(int));
40+
memchecker_status(status);
41+
memchecker_datatype(datatype);
42+
}
43+
);
44+
45+
if (MPI_PARAM_CHECK) {
46+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
47+
if (NULL == status ||
48+
MPI_STATUS_IGNORE == status ||
49+
MPI_STATUSES_IGNORE == status) {
50+
rc = MPI_ERR_ARG;
51+
}
52+
if (NULL == error) {
53+
rc = MPI_ERR_ARG;
54+
}
55+
56+
OMPI_ERRHANDLER_NOHANDLE_CHECK(rc, rc, FUNC_NAME);
57+
}
58+
59+
*error = status->MPI_ERROR;
60+
return MPI_SUCCESS;
61+
}

ompi/mpi/c/status_get_source.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
4+
* $COPYRIGHT$
5+
*
6+
* Additional copyrights may follow
7+
*
8+
* $HEADER$
9+
*/
10+
#include "ompi_config.h"
11+
#include <stdio.h>
12+
#include <limits.h>
13+
14+
#include "ompi/mpi/c/bindings.h"
15+
#include "ompi/runtime/params.h"
16+
#include "ompi/errhandler/errhandler.h"
17+
#include "ompi/memchecker.h"
18+
19+
#if OMPI_BUILD_MPI_PROFILING
20+
#if OPAL_HAVE_WEAK_SYMBOLS
21+
#pragma weak MPI_Status_get_source = PMPI_Status_get_source
22+
#endif
23+
#define MPI_Status_get_source PMPI_Status_get_source
24+
#endif
25+
26+
static const char FUNC_NAME[] = "MPI_Status_get_source";
27+
28+
29+
int MPI_Status_get_source(const MPI_Status *status, int *source)
30+
{
31+
int rc = MPI_SUCCESS;
32+
33+
MEMCHECKER(
34+
if (status != MPI_STATUSES_IGNORE) {
35+
/*
36+
* Before checking the complete status, we need to reset the definedness
37+
* of the MPI_ERROR-field (single-completion calls wait/test).
38+
*/
39+
opal_memchecker_base_mem_defined((void*)&status->MPI_ERROR, sizeof(int));
40+
memchecker_status(status);
41+
memchecker_datatype(datatype);
42+
}
43+
);
44+
45+
if (MPI_PARAM_CHECK) {
46+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
47+
if (NULL == status ||
48+
MPI_STATUS_IGNORE == status ||
49+
MPI_STATUSES_IGNORE == status) {
50+
rc = MPI_ERR_ARG;
51+
}
52+
if (NULL == source) {
53+
rc = MPI_ERR_ARG;
54+
}
55+
56+
OMPI_ERRHANDLER_NOHANDLE_CHECK(rc, rc, FUNC_NAME);
57+
}
58+
59+
*source = status->MPI_SOURCE;
60+
return MPI_SUCCESS;
61+
}

ompi/mpi/c/status_get_tag.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
4+
* $COPYRIGHT$
5+
*
6+
* Additional copyrights may follow
7+
*
8+
* $HEADER$
9+
*/
10+
#include "ompi_config.h"
11+
#include <stdio.h>
12+
#include <limits.h>
13+
14+
#include "ompi/mpi/c/bindings.h"
15+
#include "ompi/runtime/params.h"
16+
#include "ompi/errhandler/errhandler.h"
17+
#include "ompi/memchecker.h"
18+
19+
#if OMPI_BUILD_MPI_PROFILING
20+
#if OPAL_HAVE_WEAK_SYMBOLS
21+
#pragma weak MPI_Status_get_tag = PMPI_Status_get_tag
22+
#endif
23+
#define MPI_Status_get_tag PMPI_Status_get_tag
24+
#endif
25+
26+
static const char FUNC_NAME[] = "MPI_Status_get_tag";
27+
28+
29+
int MPI_Status_get_tag(const MPI_Status *status, int *tag)
30+
{
31+
int rc = MPI_SUCCESS;
32+
33+
MEMCHECKER(
34+
if (status != MPI_STATUSES_IGNORE) {
35+
/*
36+
* Before checking the complete status, we need to reset the definedness
37+
* of the MPI_ERROR-field (single-completion calls wait/test).
38+
*/
39+
opal_memchecker_base_mem_defined((void*)&status->MPI_ERROR, sizeof(int));
40+
memchecker_status(status);
41+
memchecker_datatype(datatype);
42+
}
43+
);
44+
45+
if (MPI_PARAM_CHECK) {
46+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
47+
if (NULL == status ||
48+
MPI_STATUS_IGNORE == status ||
49+
MPI_STATUSES_IGNORE == status) {
50+
rc = MPI_ERR_ARG;
51+
}
52+
if (NULL == tag) {
53+
rc = MPI_ERR_ARG;
54+
}
55+
56+
OMPI_ERRHANDLER_NOHANDLE_CHECK(rc, rc, FUNC_NAME);
57+
}
58+
59+
*tag = status->MPI_TAG;
60+
return MPI_SUCCESS;
61+
}

ompi/mpi/c/status_set_error.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
3+
* $COPYRIGHT$
4+
*
5+
* Additional copyrights may follow
6+
*
7+
* $HEADER$
8+
*/
9+
#include "ompi_config.h"
10+
#include <stdio.h>
11+
12+
#include "ompi/mpi/c/bindings.h"
13+
#include "ompi/runtime/params.h"
14+
#include "ompi/communicator/communicator.h"
15+
#include "ompi/errhandler/errhandler.h"
16+
#include "ompi/memchecker.h"
17+
18+
#if OMPI_BUILD_MPI_PROFILING
19+
#if OPAL_HAVE_WEAK_SYMBOLS
20+
#pragma weak MPI_Status_set_error = PMPI_Status_set_error
21+
#endif
22+
#define MPI_Status_set_error PMPI_Status_set_error
23+
#endif
24+
25+
static const char FUNC_NAME[] = "MPI_Status_set_error";
26+
27+
28+
int MPI_Status_set_error(MPI_Status *status, int error)
29+
{
30+
MEMCHECKER(
31+
if(status != MPI_STATUSES_IGNORE) {
32+
/*
33+
* Before checking the complete status, we need to reset the definedness
34+
* of the MPI_ERROR-field (single-completion calls wait/test).
35+
*/
36+
opal_memchecker_base_mem_defined(&status->MPI_ERROR, sizeof(int));
37+
memchecker_status(status);
38+
}
39+
);
40+
41+
if (MPI_PARAM_CHECK) {
42+
int rc = MPI_SUCCESS;
43+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
44+
if (NULL == status ||
45+
MPI_STATUS_IGNORE == status ||
46+
MPI_STATUSES_IGNORE == status) {
47+
rc = MPI_ERR_ARG;
48+
}
49+
OMPI_ERRHANDLER_NOHANDLE_CHECK(rc, rc, FUNC_NAME);
50+
}
51+
52+
status->MPI_ERROR = error;
53+
return MPI_SUCCESS;
54+
}

ompi/mpi/c/status_set_source.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
3+
* $COPYRIGHT$
4+
*
5+
* Additional copyrights may follow
6+
*
7+
* $HEADER$
8+
*/
9+
#include "ompi_config.h"
10+
#include <stdio.h>
11+
12+
#include "ompi/mpi/c/bindings.h"
13+
#include "ompi/runtime/params.h"
14+
#include "ompi/communicator/communicator.h"
15+
#include "ompi/errhandler/errhandler.h"
16+
#include "ompi/memchecker.h"
17+
18+
#if OMPI_BUILD_MPI_PROFILING
19+
#if OPAL_HAVE_WEAK_SYMBOLS
20+
#pragma weak MPI_Status_set_source = PMPI_Status_set_source
21+
#endif
22+
#define MPI_Status_set_source PMPI_Status_set_source
23+
#endif
24+
25+
static const char FUNC_NAME[] = "MPI_Status_set_source";
26+
27+
28+
int MPI_Status_set_source(MPI_Status *status, int source)
29+
{
30+
MEMCHECKER(
31+
if(status != MPI_STATUSES_IGNORE) {
32+
/*
33+
* Before checking the complete status, we need to reset the definedness
34+
* of the MPI_ERROR-field (single-completion calls wait/test).
35+
*/
36+
opal_memchecker_base_mem_defined(&status->MPI_ERROR, sizeof(int));
37+
memchecker_status(status);
38+
}
39+
);
40+
41+
if (MPI_PARAM_CHECK) {
42+
int rc = MPI_SUCCESS;
43+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
44+
if (NULL == status ||
45+
MPI_STATUS_IGNORE == status ||
46+
MPI_STATUSES_IGNORE == status) {
47+
rc = MPI_ERR_ARG;
48+
}
49+
OMPI_ERRHANDLER_NOHANDLE_CHECK(rc, rc, FUNC_NAME);
50+
}
51+
52+
status->MPI_SOURCE = source;
53+
return MPI_SUCCESS;
54+
}

0 commit comments

Comments
 (0)