|
| 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 | +} |
0 commit comments