root/ompi/mpi/c/get_elements.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Get_elements

   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-2010 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 
  24 #include "ompi_config.h"
  25 #include <stdio.h>
  26 #include <limits.h>
  27 
  28 #include "ompi/mpi/c/bindings.h"
  29 #include "ompi/runtime/params.h"
  30 #include "ompi/communicator/communicator.h"
  31 #include "ompi/errhandler/errhandler.h"
  32 #include "ompi/datatype/ompi_datatype.h"
  33 #include "ompi/memchecker.h"
  34 
  35 #if OMPI_BUILD_MPI_PROFILING
  36 #if OPAL_HAVE_WEAK_SYMBOLS
  37 #pragma weak MPI_Get_elements = PMPI_Get_elements
  38 #endif
  39 #define MPI_Get_elements PMPI_Get_elements
  40 #endif
  41 
  42 static const char FUNC_NAME[] = "MPI_Get_elements";
  43 
  44 int MPI_Get_elements(const MPI_Status *status, MPI_Datatype datatype, int *count)
  45 {
  46     size_t internal_count;
  47     int ret;
  48 
  49     OPAL_CR_NOOP_PROGRESS();
  50 
  51     MEMCHECKER(
  52                if (status != MPI_STATUSES_IGNORE) {
  53                    /*
  54                     * Before checking the complete status, we need to reset the definedness
  55                     * of the MPI_ERROR-field (single-completion calls wait/test).
  56                     */
  57                    opal_memchecker_base_mem_defined((void*)&status->MPI_ERROR, sizeof(int));
  58                    memchecker_status(status);
  59                    memchecker_datatype(datatype);
  60                }
  61                );
  62 
  63     if (MPI_PARAM_CHECK) {
  64         int err = MPI_SUCCESS;
  65         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  66         if (NULL == status || MPI_STATUSES_IGNORE == status ||
  67             MPI_STATUS_IGNORE == status || NULL == count) {
  68             err = MPI_ERR_ARG;
  69         } else if (NULL == datatype || MPI_DATATYPE_NULL == datatype) {
  70             err = MPI_ERR_TYPE;
  71         } else {
  72             OMPI_CHECK_DATATYPE_FOR_RECV(err, datatype, 1);
  73         }
  74         OMPI_ERRHANDLER_CHECK(err, MPI_COMM_WORLD, err, FUNC_NAME);
  75     }
  76 
  77     ret = ompi_datatype_get_elements (datatype, status->_ucount, &internal_count);
  78     if (OMPI_SUCCESS == ret || OMPI_ERR_VALUE_OUT_OF_BOUNDS == ret) {
  79         if (OMPI_SUCCESS == ret && internal_count <= INT_MAX) {
  80             *count = internal_count;
  81         } else {
  82             /* If we have more elements that we can represent with a signed int then we must
  83              * set count to MPI_UNDEFINED (MPI 3.0).
  84              */
  85             *count = MPI_UNDEFINED;
  86         }
  87 
  88         return MPI_SUCCESS;
  89     }
  90 
  91     return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME);
  92 }

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