root/orte/mca/iof/hnp/iof_hnp_send.c

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

DEFINITIONS

This source file includes following definitions.
  1. orte_iof_hnp_send_data_to_endpoint

   1 /*
   2  * Copyright (c) 2004-2007 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-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2007      Cisco Systems, Inc.  All rights reserved.
  13  * Copyright (c) 2012      Los Alamos National Security, LLC
  14  *                         All rights reserved
  15  * Copyright (c) 2014-2019 Intel, Inc.  All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  */
  22 
  23 #include "orte_config.h"
  24 #include "orte/constants.h"
  25 
  26 #include <errno.h>
  27 #ifdef HAVE_UNISTD_H
  28 #include <unistd.h>
  29 #endif  /* HAVE_UNISTD_H */
  30 #include <string.h>
  31 
  32 #include "opal/dss/dss.h"
  33 
  34 #include "orte/mca/rml/rml.h"
  35 #include "orte/mca/rml/rml_types.h"
  36 #include "orte/mca/errmgr/errmgr.h"
  37 #include "orte/runtime/orte_globals.h"
  38 #include "orte/mca/grpcomm/grpcomm.h"
  39 #include "orte/util/name_fns.h"
  40 
  41 #include "orte/mca/iof/iof.h"
  42 #include "orte/mca/iof/base/base.h"
  43 
  44 #include "iof_hnp.h"
  45 
  46 int orte_iof_hnp_send_data_to_endpoint(orte_process_name_t *host,
  47                                        orte_process_name_t *target,
  48                                        orte_iof_tag_t tag,
  49                                        unsigned char *data, int numbytes)
  50 {
  51     opal_buffer_t *buf;
  52     int rc;
  53     orte_grpcomm_signature_t *sig;
  54 
  55     /* if the host is a daemon and we are in the process of aborting,
  56      * then ignore this request. We leave it alone if the host is not
  57      * a daemon because it might be a tool that wants to watch the
  58      * output from an abort procedure
  59      */
  60     if (ORTE_JOB_FAMILY(host->jobid) == ORTE_JOB_FAMILY(ORTE_PROC_MY_NAME->jobid)
  61         && orte_job_term_ordered) {
  62         return ORTE_SUCCESS;
  63     }
  64 
  65     buf = OBJ_NEW(opal_buffer_t);
  66 
  67     /* pack the tag - we do this first so that flow control messages can
  68      * consist solely of the tag
  69      */
  70     if (ORTE_SUCCESS != (rc = opal_dss.pack(buf, &tag, 1, ORTE_IOF_TAG))) {
  71         ORTE_ERROR_LOG(rc);
  72         OBJ_RELEASE(buf);
  73         return rc;
  74     }
  75     /* pack the name of the target - this is either the intended
  76      * recipient (if the tag is stdin and we are sending to a daemon),
  77      * or the source (if we are sending to anyone else)
  78      */
  79     if (ORTE_SUCCESS != (rc = opal_dss.pack(buf, target, 1, ORTE_NAME))) {
  80         ORTE_ERROR_LOG(rc);
  81         OBJ_RELEASE(buf);
  82         return rc;
  83     }
  84 
  85     /* if data is NULL, then we are done */
  86     if (NULL != data) {
  87         /* pack the data - if numbytes is zero, we will pack zero bytes */
  88         if (ORTE_SUCCESS != (rc = opal_dss.pack(buf, data, numbytes, OPAL_BYTE))) {
  89             ORTE_ERROR_LOG(rc);
  90             OBJ_RELEASE(buf);
  91             return rc;
  92         }
  93     }
  94 
  95     /* if the target is wildcard, then this needs to go to everyone - xcast it */
  96     if (ORTE_PROC_MY_NAME->jobid == host->jobid &&
  97         ORTE_VPID_WILDCARD == host->vpid) {
  98         /* xcast this to everyone - the local daemons will know how to handle it */
  99         sig = OBJ_NEW(orte_grpcomm_signature_t);
 100         sig->signature = (orte_process_name_t*)malloc(sizeof(orte_process_name_t));
 101         sig->signature[0].jobid = ORTE_PROC_MY_NAME->jobid;
 102         sig->signature[0].vpid = ORTE_VPID_WILDCARD;
 103         (void)orte_grpcomm.xcast(sig, ORTE_RML_TAG_IOF_PROXY, buf);
 104         OBJ_RELEASE(buf);
 105         OBJ_RELEASE(sig);
 106         return ORTE_SUCCESS;
 107     }
 108 
 109     /* send the buffer to the host - this is either a daemon or
 110      * a tool that requested IOF
 111      */
 112     if (0 > (rc = orte_rml.send_buffer_nb(host, buf, ORTE_RML_TAG_IOF_PROXY,
 113                                           orte_rml_send_callback, NULL))) {
 114         ORTE_ERROR_LOG(rc);
 115         return rc;
 116     }
 117 
 118     return ORTE_SUCCESS;
 119 }

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