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

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

DEFINITIONS

This source file includes following definitions.
  1. ompi_mtl_psm2_iprobe
  2. ompi_mtl_psm2_improbe

   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-2010 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) 2006-2007 Los Alamos National Security, LLC.  All rights
  14  *                         reserved.
  15  * Copyright (c) 2013-2015 Intel, Inc. All rights reserved
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  */
  22 
  23 #include "ompi_config.h"
  24 #include "mtl_psm2.h"
  25 #include "mtl_psm2_types.h"
  26 #include "psm2.h"
  27 #include "ompi/communicator/communicator.h"
  28 #include "ompi/message/message.h"
  29 
  30 
  31 int ompi_mtl_psm2_iprobe(struct mca_mtl_base_module_t* mtl,
  32                               struct ompi_communicator_t *comm,
  33                               int src,
  34                               int tag,
  35                               int *flag,
  36                               struct ompi_status_public_t *status)
  37 {
  38     psm2_mq_tag_t mqtag, tagsel;
  39     psm2_mq_status2_t mqstat;
  40     psm2_error_t err;
  41 
  42     PSM2_MAKE_TAGSEL(src, tag, comm->c_contextid, mqtag, tagsel);
  43 
  44     err = psm2_mq_iprobe2(ompi_mtl_psm2.mq,
  45             PSM2_MQ_ANY_ADDR, &mqtag, &tagsel, &mqstat);
  46     if (err == PSM2_OK) {
  47         *flag = 1;
  48         if(MPI_STATUS_IGNORE != status) {
  49             status->MPI_SOURCE = mqstat.msg_tag.tag1;
  50             status->MPI_TAG = mqstat.msg_tag.tag0;
  51             status->_ucount = mqstat.nbytes;
  52 
  53             switch (mqstat.error_code) {
  54             case PSM2_OK:
  55                 status->MPI_ERROR = OMPI_SUCCESS;
  56                 break;
  57             case PSM2_MQ_TRUNCATION:
  58                 status->MPI_ERROR = MPI_ERR_TRUNCATE;
  59                 break;
  60             default:
  61                 status->MPI_ERROR = MPI_ERR_INTERN;
  62             }
  63         }
  64 
  65         return OMPI_SUCCESS;
  66     }
  67     else if (err == PSM2_MQ_INCOMPLETE) {
  68         *flag = 0;
  69         return OMPI_SUCCESS;
  70     }
  71     else
  72         return OMPI_ERROR;
  73 }
  74 
  75 
  76 int
  77 ompi_mtl_psm2_improbe(struct mca_mtl_base_module_t *mtl,
  78                      struct ompi_communicator_t *comm,
  79                      int src,
  80                      int tag,
  81                      int *matched,
  82                      struct ompi_message_t **message,
  83                      struct ompi_status_public_t *status)
  84 {
  85     struct ompi_message_t* msg;
  86     psm2_mq_tag_t mqtag, tagsel;
  87     psm2_mq_status2_t mqstat;
  88     psm2_mq_req_t mqreq;
  89     psm2_error_t err;
  90 
  91     PSM2_MAKE_TAGSEL(src, tag, comm->c_contextid, mqtag, tagsel);
  92 
  93     err = psm2_mq_improbe2(ompi_mtl_psm2.mq,
  94             PSM2_MQ_ANY_ADDR, &mqtag, &tagsel, &mqreq, &mqstat);
  95     if (err == PSM2_OK) {
  96 
  97         if(MPI_STATUS_IGNORE != status) {
  98             status->MPI_SOURCE = mqstat.msg_tag.tag1;
  99             status->MPI_TAG = mqstat.msg_tag.tag0;
 100             status->_ucount = mqstat.nbytes;
 101 
 102             switch (mqstat.error_code) {
 103             case PSM2_OK:
 104                 status->MPI_ERROR = OMPI_SUCCESS;
 105                 break;
 106             case PSM2_MQ_TRUNCATION:
 107                 status->MPI_ERROR = MPI_ERR_TRUNCATE;
 108                 break;
 109             default:
 110                 status->MPI_ERROR = MPI_ERR_INTERN;
 111             }
 112         }
 113 
 114         msg = ompi_message_alloc();
 115         if(NULL == msg) {
 116             return OMPI_ERR_OUT_OF_RESOURCE;
 117         }
 118 
 119         msg->comm = comm;
 120         msg->req_ptr = mqreq;
 121         msg->peer = mqstat.msg_tag.tag1;
 122         msg->count = mqstat.nbytes;
 123 
 124         *message = msg;
 125         *matched = 1;
 126         return OMPI_SUCCESS;
 127     } else if(err == PSM2_MQ_INCOMPLETE) {
 128         *matched = 0;
 129         *message = MPI_MESSAGE_NULL;
 130         return OMPI_SUCCESS;
 131     } else {
 132         return OMPI_ERROR;
 133     }
 134 }

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