root/ompi/mpi/c/sendrecv.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPI_Sendrecv

   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-2018 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) 2013      Los Alamos National Security, LLC.  All rights
  14  *                         reserved.
  15  * Copyright (c) 2015      Research Organization for Information Science
  16  *                         and Technology (RIST). All rights reserved.
  17  * $COPYRIGHT$
  18  *
  19  * Additional copyrights may follow
  20  *
  21  * $HEADER$
  22  */
  23 #include "ompi_config.h"
  24 
  25 #include "ompi/mpi/c/bindings.h"
  26 #include "ompi/runtime/params.h"
  27 #include "ompi/communicator/communicator.h"
  28 #include "ompi/errhandler/errhandler.h"
  29 #include "ompi/mca/pml/pml.h"
  30 #include "ompi/request/request.h"
  31 #include "ompi/memchecker.h"
  32 #include "ompi/runtime/ompi_spc.h"
  33 
  34 #if OMPI_BUILD_MPI_PROFILING
  35 #if OPAL_HAVE_WEAK_SYMBOLS
  36 #pragma weak MPI_Sendrecv = PMPI_Sendrecv
  37 #endif
  38 #define MPI_Sendrecv PMPI_Sendrecv
  39 #endif
  40 
  41 static const char FUNC_NAME[] = "MPI_Sendrecv";
  42 
  43 
  44 int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
  45                  int dest, int sendtag, void *recvbuf, int recvcount,
  46                  MPI_Datatype recvtype, int source, int recvtag,
  47                  MPI_Comm comm,  MPI_Status *status)
  48 {
  49     ompi_request_t* req;
  50     int rc = MPI_SUCCESS;
  51 
  52     SPC_RECORD(OMPI_SPC_SENDRECV, 1);
  53 
  54     MEMCHECKER(
  55         memchecker_datatype(sendtype);
  56         memchecker_datatype(recvtype);
  57         memchecker_call(&opal_memchecker_base_isdefined, sendbuf, sendcount, sendtype);
  58         memchecker_comm(comm);
  59     );
  60 
  61     if ( MPI_PARAM_CHECK ) {
  62         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  63         OMPI_CHECK_DATATYPE_FOR_SEND(rc, sendtype, sendcount);
  64         OMPI_CHECK_DATATYPE_FOR_RECV(rc, recvtype, recvcount);
  65         OMPI_CHECK_USER_BUFFER(rc, sendbuf, sendtype, sendcount);
  66         OMPI_CHECK_USER_BUFFER(rc, recvbuf, recvtype, recvcount);
  67 
  68         if (ompi_comm_invalid(comm)) {
  69             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
  70         } else if (dest != MPI_PROC_NULL && ompi_comm_peer_invalid(comm, dest)) {
  71             rc = MPI_ERR_RANK;
  72         } else if (sendtag < 0 || sendtag > mca_pml.pml_max_tag) {
  73             rc = MPI_ERR_TAG;
  74         } else if (source != MPI_PROC_NULL && source != MPI_ANY_SOURCE && ompi_comm_peer_invalid(comm, source)) {
  75             rc = MPI_ERR_RANK;
  76         } else if (((recvtag < 0) && (recvtag !=  MPI_ANY_TAG)) || (recvtag > mca_pml.pml_max_tag)) {
  77             rc = MPI_ERR_TAG;
  78         }
  79         OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
  80     }
  81 
  82     OPAL_CR_ENTER_LIBRARY();
  83 
  84     if (source != MPI_PROC_NULL) { /* post recv */
  85         rc = MCA_PML_CALL(irecv(recvbuf, recvcount, recvtype,
  86                                 source, recvtag, comm, &req));
  87         OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
  88     }
  89 
  90     if (dest != MPI_PROC_NULL) { /* send */
  91         rc = MCA_PML_CALL(send(sendbuf, sendcount, sendtype, dest,
  92                                sendtag, MCA_PML_BASE_SEND_STANDARD, comm));
  93         OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME);
  94     }
  95 
  96     if (source != MPI_PROC_NULL) { /* wait for recv */
  97         rc = ompi_request_wait(&req, status);
  98     } else {
  99         if (MPI_STATUS_IGNORE != status) {
 100             *status = ompi_request_empty.req_status;
 101         }
 102         rc = MPI_SUCCESS;
 103     }
 104     OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME);
 105 }

/* [<][>][^][v][top][bottom][index][help] */