root/orte/mca/ess/lsf/ess_lsf_module.c

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

DEFINITIONS

This source file includes following definitions.
  1. rte_init
  2. rte_finalize
  3. lsf_set_name

   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2011 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-2011 Cisco Systems, Inc.  All rights reserved.
  13  * Copyright (c) 2013-2018 Intel, Inc.  All rights reserved.
  14  * Copyright (c) 2016      Research Organization for Information Science
  15  *                         and Technology (RIST). All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  *
  22  */
  23 
  24 #include "orte_config.h"
  25 #include "orte/constants.h"
  26 
  27 #ifdef HAVE_UNISTD_H
  28 #include <unistd.h>
  29 #endif  /* HAVE_UNISTD_H */
  30 #include <string.h>
  31 #include <ctype.h>
  32 
  33 #include <lsf/lsbatch.h>
  34 
  35 #include "opal/util/opal_environ.h"
  36 #include "opal/util/argv.h"
  37 
  38 #include "orte/util/show_help.h"
  39 #include "orte/util/name_fns.h"
  40 #include "orte/util/proc_info.h"
  41 #include "orte/runtime/orte_globals.h"
  42 #include "orte/mca/errmgr/errmgr.h"
  43 
  44 #include "orte/mca/ess/ess.h"
  45 #include "orte/mca/ess/base/base.h"
  46 #include "orte/mca/ess/lsf/ess_lsf.h"
  47 
  48 static int lsf_set_name(void);
  49 
  50 static int rte_init(void);
  51 static int rte_finalize(void);
  52 
  53 orte_ess_base_module_t orte_ess_lsf_module = {
  54     rte_init,
  55     rte_finalize,
  56     NULL,
  57     NULL /* ft_event */
  58 };
  59 
  60 /*
  61  * Local variables
  62  */
  63 static orte_node_rank_t my_node_rank=ORTE_NODE_RANK_INVALID;
  64 
  65 
  66 static int rte_init(void)
  67 {
  68     int ret;
  69     char *error = NULL;
  70 
  71     /* run the prolog */
  72     if (ORTE_SUCCESS != (ret = orte_ess_base_std_prolog())) {
  73         error = "orte_ess_base_std_prolog";
  74         goto error;
  75     }
  76 
  77     /* Start by getting a unique name */
  78     lsf_set_name();
  79 
  80     /* if I am a daemon, complete my setup using the
  81      * default procedure
  82      */
  83     if (ORTE_PROC_IS_DAEMON) {
  84         if (ORTE_SUCCESS != (ret = orte_ess_base_orted_setup())) {
  85             ORTE_ERROR_LOG(ret);
  86             error = "orte_ess_base_orted_setup";
  87             goto error;
  88         }
  89         return ORTE_SUCCESS;
  90     }
  91 
  92     if (ORTE_PROC_IS_TOOL) {
  93         /* otherwise, if I am a tool proc, use that procedure */
  94         if (ORTE_SUCCESS != (ret = orte_ess_base_tool_setup(NULL))) {
  95             ORTE_ERROR_LOG(ret);
  96             error = "orte_ess_base_tool_setup";
  97             goto error;
  98         }
  99         return ORTE_SUCCESS;
 100 
 101     }
 102 
 103     return ORTE_SUCCESS;
 104 
 105 error:
 106     if (ORTE_ERR_SILENT != ret && !orte_report_silent_errors) {
 107         orte_show_help("help-orte-runtime.txt",
 108                        "orte_init:startup:internal-failure",
 109                        true, error, ORTE_ERROR_NAME(ret), ret);
 110     }
 111 
 112     return ret;
 113 }
 114 
 115 static int rte_finalize(void)
 116 {
 117     int ret;
 118 
 119     /* if I am a daemon, finalize using the default procedure */
 120     if (ORTE_PROC_IS_DAEMON) {
 121         if (ORTE_SUCCESS != (ret = orte_ess_base_orted_finalize())) {
 122             ORTE_ERROR_LOG(ret);
 123             return ret;
 124         }
 125     } else if (ORTE_PROC_IS_TOOL) {
 126         /* otherwise, if I am a tool proc, use that procedure */
 127         if (ORTE_SUCCESS != (ret = orte_ess_base_tool_finalize())) {
 128             ORTE_ERROR_LOG(ret);
 129         }
 130         return ret;
 131     }
 132 
 133     return ORTE_SUCCESS;;
 134 }
 135 
 136 static int lsf_set_name(void)
 137 {
 138     int rc;
 139     int lsf_nodeid;
 140     orte_jobid_t jobid;
 141     orte_vpid_t vpid;
 142 
 143     if (NULL ==orte_ess_base_jobid) {
 144         ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
 145         return ORTE_ERR_NOT_FOUND;
 146     }
 147     if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_jobid(&jobid, orte_ess_base_jobid))) {
 148         ORTE_ERROR_LOG(rc);
 149         return(rc);
 150     }
 151     ORTE_PROC_MY_NAME->jobid = jobid;
 152 
 153     /* get the vpid from the nodeid */
 154     if (NULL == orte_ess_base_vpid) {
 155         ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
 156         return ORTE_ERR_NOT_FOUND;
 157     }
 158     if (ORTE_SUCCESS != (rc = orte_util_convert_string_to_vpid(&vpid, orte_ess_base_vpid))) {
 159         ORTE_ERROR_LOG(rc);
 160         return(rc);
 161     }
 162     lsf_nodeid = atoi(getenv("LSF_PM_TASKID"));
 163     opal_output_verbose(1, orte_ess_base_framework.framework_output,
 164                         "ess:lsf found LSF_PM_TASKID set to %d",
 165                         lsf_nodeid);
 166     ORTE_PROC_MY_NAME->vpid = vpid + lsf_nodeid - 1;
 167 
 168     /* get the non-name common environmental variables */
 169     if (ORTE_SUCCESS != (rc = orte_ess_env_get())) {
 170         ORTE_ERROR_LOG(rc);
 171         return rc;
 172     }
 173 
 174     return ORTE_SUCCESS;
 175 }

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