root/orte/mca/plm/base/plm_base_jobid.c

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

DEFINITIONS

This source file includes following definitions.
  1. orte_plm_base_set_hnp_name
  2. orte_plm_base_create_jobid

   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) 2016      Intel, Inc. All rights reserved.
  13  * $COPYRIGHT$
  14  *
  15  * Additional copyrights may follow
  16  *
  17  * $HEADER$
  18  */
  19 
  20 #include "orte_config.h"
  21 #include "orte/constants.h"
  22 
  23 #include <stdio.h>
  24 
  25 #include "opal/hash_string.h"
  26 
  27 #include "orte/mca/errmgr/errmgr.h"
  28 #include "orte/util/proc_info.h"
  29 #include "orte/util/name_fns.h"
  30 #include "orte/runtime/orte_globals.h"
  31 
  32 #include "orte/mca/plm/base/plm_private.h"
  33 
  34 /*
  35  * attempt to create a globally unique name - do a hash
  36  * of the hostname plus pid
  37  */
  38 int orte_plm_base_set_hnp_name(void)
  39 {
  40     uint16_t jobfam;
  41     uint32_t hash32;
  42     uint32_t bias;
  43 
  44     /* hash the nodename */
  45     OPAL_HASH_STR(orte_process_info.nodename, hash32);
  46 
  47     bias = (uint32_t)orte_process_info.pid;
  48 
  49     OPAL_OUTPUT_VERBOSE((5, orte_plm_base_framework.framework_output,
  50                          "plm:base:set_hnp_name: initial bias %ld nodename hash %lu",
  51                          (long)bias, (unsigned long)hash32));
  52 
  53     /* fold in the bias */
  54     hash32 = hash32 ^ bias;
  55 
  56     /* now compress to 16-bits */
  57     jobfam = (uint16_t)(((0x0000ffff & (0xffff0000 & hash32) >> 16)) ^ (0x0000ffff & hash32));
  58 
  59     OPAL_OUTPUT_VERBOSE((5, orte_plm_base_framework.framework_output,
  60                          "plm:base:set_hnp_name: final jobfam %lu",
  61                          (unsigned long)jobfam));
  62 
  63     /* set the name */
  64     ORTE_PROC_MY_NAME->jobid = 0xffff0000 & ((uint32_t)jobfam << 16);
  65     ORTE_PROC_MY_NAME->vpid = 0;
  66 
  67     /* copy it to the HNP field */
  68     ORTE_PROC_MY_HNP->jobid = ORTE_PROC_MY_NAME->jobid;
  69     ORTE_PROC_MY_HNP->vpid = ORTE_PROC_MY_NAME->vpid;
  70 
  71     /* done */
  72     return ORTE_SUCCESS;
  73 }
  74 
  75 /*
  76  * Create a jobid
  77  */
  78 int orte_plm_base_create_jobid(orte_job_t *jdata)
  79 {
  80     if (ORTE_FLAG_TEST(jdata, ORTE_JOB_FLAG_RESTART)) {
  81         /* this job is being restarted - do not assign it
  82          * a new jobid
  83          */
  84         return ORTE_SUCCESS;
  85     }
  86 
  87     if (UINT16_MAX == orte_plm_globals.next_jobid) {
  88         /* if we get here, then no local jobids are available */
  89         ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
  90         jdata->jobid = ORTE_JOBID_INVALID;
  91         return ORTE_ERR_OUT_OF_RESOURCE;
  92     }
  93 
  94     /* take the next jobid */
  95     jdata->jobid =  ORTE_CONSTRUCT_LOCAL_JOBID(ORTE_PROC_MY_NAME->jobid, orte_plm_globals.next_jobid);
  96     orte_plm_globals.next_jobid++;
  97     return ORTE_SUCCESS;
  98 }

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