root/ompi/mca/pml/base/pml_base_sendreq.h

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

INCLUDED FROM


   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2016 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) 2006      Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2015      Research Organization for Information Science
  15  *                         and Technology (RIST). All rights reserved.
  16  * Copyright (c) 2016      Los Alamos National Security, LLC. All rights
  17  *                         reserved.
  18  * Copyright (c) 2017      Intel, Inc. All rights reserved.
  19  * $COPYRIGHT$
  20  *
  21  * Additional copyrights may follow
  22  *
  23  * $HEADER$
  24  */
  25 /**
  26  * @file
  27  */
  28 #ifndef MCA_PML_BASE_SEND_REQUEST_H
  29 #define MCA_PML_BASE_SEND_REQUEST_H
  30 
  31 #include "ompi_config.h"
  32 #include "ompi/mca/pml/pml.h"
  33 #include "ompi/mca/pml/base/pml_base_request.h"
  34 #include "opal/datatype/opal_convertor.h"
  35 #include "ompi/peruse/peruse-internal.h"
  36 
  37 BEGIN_C_DECLS
  38 
  39 /**
  40  * Base type for send requests
  41  */
  42 struct mca_pml_base_send_request_t {
  43     mca_pml_base_request_t req_base;         /**< base request type - common data structure for use by wait/test */
  44     const void *req_addr;                    /**< pointer to send buffer - may not be application buffer */
  45     size_t req_bytes_packed;                 /**< packed size of a message given the datatype and count */
  46     mca_pml_base_send_mode_t req_send_mode;  /**< type of send */
  47 };
  48 typedef struct mca_pml_base_send_request_t mca_pml_base_send_request_t;
  49 
  50 OMPI_DECLSPEC OBJ_CLASS_DECLARATION( mca_pml_base_send_request_t );
  51 
  52 /**
  53  * Initialize a send request with call parameters.
  54  *
  55  * @param request (IN)         Send request
  56  * @param addr (IN)            User buffer
  57  * @param count (IN)           Number of elements of indicated datatype.
  58  * @param datatype (IN)        User defined datatype
  59  * @param peer (IN)            Destination rank
  60  * @param tag (IN)             User defined tag
  61  * @param comm (IN)            Communicator
  62  * @param mode (IN)            Send mode (STANDARD,BUFFERED,SYNCHRONOUS,READY)
  63  * @param persistent (IN)      Is request persistent.
  64  * @param convertor_flags (IN) Flags to pass to convertor
  65  *
  66  * Perform a any one-time initialization. Note that per-use initialization
  67  * is done in the send request start routine.
  68  */
  69 
  70 #define MCA_PML_BASE_SEND_REQUEST_INIT( request,                          \
  71                                         addr,                             \
  72                                         count,                            \
  73                                         datatype,                         \
  74                                         peer,                             \
  75                                         tag,                              \
  76                                         comm,                             \
  77                                         mode,                             \
  78                                         persistent,                       \
  79                                         convertor_flags)                  \
  80    {                                                                      \
  81       /* increment reference counts */                                    \
  82       OBJ_RETAIN(comm);                                                   \
  83                                                                           \
  84       OMPI_REQUEST_INIT(&(request)->req_base.req_ompi, persistent);       \
  85       (request)->req_base.req_ompi.req_mpi_object.comm = comm;            \
  86       (request)->req_addr = addr;                                         \
  87       (request)->req_send_mode = mode;                                    \
  88       (request)->req_base.req_addr = (void *)addr;                        \
  89       (request)->req_base.req_count = count;                              \
  90       (request)->req_base.req_datatype = datatype;                        \
  91       (request)->req_base.req_peer = (int32_t)peer;                       \
  92       (request)->req_base.req_tag = (int32_t)tag;                         \
  93       (request)->req_base.req_comm = comm;                                \
  94       /* (request)->req_base.req_proc is set on request allocation */     \
  95       (request)->req_base.req_pml_complete = false;                       \
  96       (request)->req_base.req_free_called = false;                        \
  97       (request)->req_base.req_ompi.req_status._cancelled = 0;             \
  98       (request)->req_bytes_packed = 0;                                    \
  99                                                                           \
 100       /* initialize datatype convertor for this request */                \
 101       if( count > 0 ) {                                                   \
 102           OMPI_DATATYPE_RETAIN(datatype);                                 \
 103          /* We will create a convertor specialized for the        */      \
 104          /* remote architecture and prepared with the datatype.   */      \
 105          opal_convertor_copy_and_prepare_for_send(                        \
 106                             (request)->req_base.req_proc->super.proc_convertor, \
 107                             &((request)->req_base.req_datatype->super),   \
 108                             (request)->req_base.req_count,                \
 109                             (request)->req_base.req_addr,                 \
 110                             convertor_flags,                              \
 111                             &(request)->req_base.req_convertor );         \
 112          opal_convertor_get_packed_size( &(request)->req_base.req_convertor, \
 113                                          &((request)->req_bytes_packed) );\
 114       }                                                                   \
 115    }
 116 
 117 #define MCA_PML_BASE_SEND_REQUEST_RESET(request)                        \
 118     if ((request)->req_bytes_packed > 0) {                              \
 119         size_t cnt = 0;                                                 \
 120         opal_convertor_set_position(&(sendreq)->req_send.req_base.req_convertor, \
 121                                     &cnt);                      \
 122     }
 123 
 124 /**
 125  * Mark the request as started from the PML base point of view.
 126  *
 127  *  @param request (IN)    The send request.
 128  */
 129 
 130 #define MCA_PML_BASE_SEND_START( request )                    \
 131     do {                                                      \
 132         (request)->req_base.req_pml_complete = false;         \
 133         (request)->req_base.req_ompi.req_complete = REQUEST_PENDING;    \
 134         (request)->req_base.req_ompi.req_state = OMPI_REQUEST_ACTIVE;   \
 135         (request)->req_base.req_ompi.req_status._cancelled = 0;         \
 136         MCA_PML_BASE_SEND_REQUEST_RESET(request);             \
 137     } while (0)
 138 
 139 /**
 140  *  Release the ref counts on the communicator and datatype.
 141  *
 142  *  @param request (IN)    The send request.
 143  */
 144 
 145 #define MCA_PML_BASE_SEND_REQUEST_FINI( request )                         \
 146     do {                                                                  \
 147         OMPI_REQUEST_FINI(&(request)->req_base.req_ompi);                 \
 148         OBJ_RELEASE((request)->req_base.req_comm);                        \
 149         if( 0 != (request)->req_base.req_count )                          \
 150             OMPI_DATATYPE_RELEASE((request)->req_base.req_datatype);      \
 151         opal_convertor_cleanup( &((request)->req_base.req_convertor) );   \
 152     } while (0)
 153 
 154 
 155 END_C_DECLS
 156 
 157 #endif

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