root/ompi/mca/mtl/psm2/mtl_psm2_send.c

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

DEFINITIONS

This source file includes following definitions.
  1. ompi_mtl_psm2_send
  2. ompi_mtl_psm2_isend

   1 /*
   2  * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2005 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2006 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2006      QLogic Corporation. All rights reserved.
  13  * Copyright (c) 2013-2015 Intel, Inc. All rights reserved
  14  * $COPYRIGHT$
  15  *
  16  * Additional copyrights may follow
  17  *
  18  * $HEADER$
  19  */
  20 
  21 #include "ompi_config.h"
  22 #include "ompi/mca/pml/pml.h"
  23 #include "ompi/communicator/communicator.h"
  24 #include "opal/datatype/opal_convertor.h"
  25 #include "opal/util/show_help.h"
  26 
  27 #include "mtl_psm2.h"
  28 #include "mtl_psm2_types.h"
  29 #include "mtl_psm2_request.h"
  30 #include "ompi/mca/mtl/base/mtl_base_datatype.h"
  31 
  32 int
  33 ompi_mtl_psm2_send(struct mca_mtl_base_module_t* mtl,
  34                  struct ompi_communicator_t* comm,
  35                  int dest,
  36                  int tag,
  37                  struct opal_convertor_t *convertor,
  38                  mca_pml_base_send_mode_t mode)
  39 {
  40     psm2_error_t err;
  41     mca_mtl_psm2_request_t mtl_psm2_request;
  42     psm2_mq_tag_t mqtag;
  43     uint32_t flags = 0;
  44     int ret;
  45     size_t length;
  46     ompi_proc_t* ompi_proc = ompi_comm_peer_lookup( comm, dest );
  47     mca_mtl_psm2_endpoint_t* psm2_endpoint = ompi_mtl_psm2_get_endpoint (mtl, ompi_proc);
  48 
  49     assert(mtl == &ompi_mtl_psm2.super);
  50 
  51     PSM2_MAKE_MQTAG(comm->c_contextid, comm->c_my_rank, tag, mqtag);
  52 
  53     ret = ompi_mtl_datatype_pack(convertor,
  54                                  &mtl_psm2_request.buf,
  55                                  &length,
  56                                  &mtl_psm2_request.free_after);
  57 
  58     if (length >= 1ULL << sizeof(uint32_t) * 8) {
  59             opal_show_help("help-mtl-psm2.txt",
  60                     "message too big", false,
  61                     length, 1ULL << sizeof(uint32_t) * 8);
  62             return OMPI_ERROR;
  63     }
  64 
  65     mtl_psm2_request.length = length;
  66     mtl_psm2_request.convertor = convertor;
  67     mtl_psm2_request.type = OMPI_mtl_psm2_ISEND;
  68 
  69     if (OMPI_SUCCESS != ret) return ret;
  70 
  71     if (mode == MCA_PML_BASE_SEND_SYNCHRONOUS)
  72         flags |= PSM2_MQ_FLAG_SENDSYNC;
  73 
  74     err = psm2_mq_send2(ompi_mtl_psm2.mq,
  75                       psm2_endpoint->peer_addr,
  76                       flags,
  77                       &mqtag,
  78                       mtl_psm2_request.buf,
  79                       length);
  80 
  81     if (mtl_psm2_request.free_after) {
  82         free(mtl_psm2_request.buf);
  83     }
  84 
  85     return err == PSM2_OK ? OMPI_SUCCESS : OMPI_ERROR;
  86 }
  87 
  88 int
  89 ompi_mtl_psm2_isend(struct mca_mtl_base_module_t* mtl,
  90                   struct ompi_communicator_t* comm,
  91                   int dest,
  92                   int tag,
  93                   struct opal_convertor_t *convertor,
  94                   mca_pml_base_send_mode_t mode,
  95                   bool blocking,
  96                   mca_mtl_request_t * mtl_request)
  97 {
  98     psm2_error_t psm2_error;
  99     psm2_mq_tag_t mqtag;
 100     uint32_t flags = 0;
 101     int ret;
 102     mca_mtl_psm2_request_t * mtl_psm2_request = (mca_mtl_psm2_request_t*) mtl_request;
 103     size_t length;
 104     ompi_proc_t* ompi_proc = ompi_comm_peer_lookup( comm, dest );
 105     mca_mtl_psm2_endpoint_t* psm2_endpoint = ompi_mtl_psm2_get_endpoint (mtl, ompi_proc);
 106 
 107     assert(mtl == &ompi_mtl_psm2.super);
 108 
 109     PSM2_MAKE_MQTAG(comm->c_contextid, comm->c_my_rank, tag, mqtag);
 110 
 111 
 112     ret = ompi_mtl_datatype_pack(convertor,
 113                                  &mtl_psm2_request->buf,
 114                                  &length,
 115                                  &mtl_psm2_request->free_after);
 116 
 117     if (length >= 1ULL << sizeof(uint32_t) * 8) {
 118             opal_show_help("help-mtl-psm2.txt",
 119                     "message too big", false,
 120                     length, 1ULL << sizeof(uint32_t) * 8);
 121             return OMPI_ERROR;
 122     }
 123 
 124     mtl_psm2_request->length= length;
 125     mtl_psm2_request->convertor = convertor;
 126     mtl_psm2_request->type = OMPI_mtl_psm2_ISEND;
 127 
 128     if (OMPI_SUCCESS != ret) return ret;
 129 
 130     if (mode == MCA_PML_BASE_SEND_SYNCHRONOUS)
 131         flags |= PSM2_MQ_FLAG_SENDSYNC;
 132 
 133     psm2_error = psm2_mq_isend2(ompi_mtl_psm2.mq,
 134                              psm2_endpoint->peer_addr,
 135                              flags,
 136                              &mqtag,
 137                              mtl_psm2_request->buf,
 138                              length,
 139                              mtl_psm2_request,
 140                              &mtl_psm2_request->psm2_request);
 141 
 142     return psm2_error == PSM2_OK ? OMPI_SUCCESS : OMPI_ERROR;
 143 }

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