2011-10-20 00:18:14 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2011 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
|
2012-04-06 18:23:13 +04:00
|
|
|
* Copyright (c) 2011-2012 Los Alamos National Security, LLC.
|
|
|
|
* All rights reserved.
|
2011-10-20 00:18:14 +04:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "orte_config.h"
|
|
|
|
#include "orte/constants.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "opal/util/output.h"
|
|
|
|
#include "opal/mca/paffinity/paffinity.h"
|
|
|
|
|
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
|
|
|
#include "orte/util/name_fns.h"
|
|
|
|
#include "orte/util/nidmap.h"
|
|
|
|
#include "orte/util/proc_info.h"
|
|
|
|
#include "orte/runtime/orte_globals.h"
|
|
|
|
|
|
|
|
#include "orte/mca/ess/base/base.h"
|
|
|
|
|
2012-04-29 04:10:01 +04:00
|
|
|
static orte_proc_t* find_proc(orte_process_name_t *proc) /* used by daemons */
|
|
|
|
{
|
|
|
|
orte_job_t *jdata;
|
|
|
|
|
|
|
|
if (NULL == (jdata = orte_get_job_data_object(proc->jobid))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (orte_proc_t*)opal_pointer_array_get_item(jdata->procs, proc->vpid);
|
|
|
|
}
|
|
|
|
|
2011-10-20 00:18:14 +04:00
|
|
|
opal_paffinity_locality_t orte_ess_base_proc_get_locality(orte_process_name_t *proc)
|
|
|
|
{
|
|
|
|
orte_pmap_t *pmap;
|
|
|
|
|
|
|
|
if (NULL == (pmap = orte_util_lookup_pmap(proc))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
|
2012-04-06 18:23:13 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((5, orte_ess_base_output,
|
|
|
|
"%s LOOKING FOR PROC %s",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
ORTE_NAME_PRINT(proc)));
|
2011-10-20 00:18:14 +04:00
|
|
|
return OPAL_PROC_NON_LOCAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pmap->locality;
|
|
|
|
}
|
|
|
|
|
|
|
|
orte_vpid_t orte_ess_base_proc_get_daemon(orte_process_name_t *proc)
|
|
|
|
{
|
|
|
|
orte_nid_t *nid;
|
2012-04-29 04:10:01 +04:00
|
|
|
orte_proc_t *pdata;
|
|
|
|
orte_vpid_t vpid;
|
|
|
|
|
|
|
|
if (NULL == proc) {
|
|
|
|
return ORTE_VPID_INVALID;
|
|
|
|
}
|
2011-10-20 00:18:14 +04:00
|
|
|
|
2012-04-29 04:10:01 +04:00
|
|
|
if (ORTE_JOBID_IS_DAEMON(proc->jobid)) {
|
2011-10-20 00:18:14 +04:00
|
|
|
return proc->vpid;
|
|
|
|
}
|
|
|
|
|
2012-04-29 04:10:01 +04:00
|
|
|
if (ORTE_PROC_IS_APP) {
|
|
|
|
if (NULL == (nid = orte_util_lookup_nid(proc))) {
|
|
|
|
return ORTE_VPID_INVALID;
|
|
|
|
}
|
|
|
|
vpid = nid->daemon;
|
|
|
|
} else {
|
|
|
|
/* get the job data */
|
|
|
|
if (NULL == (pdata = find_proc(proc))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
|
|
|
|
return ORTE_VPID_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL == pdata->node || NULL == pdata->node->daemon) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
|
|
|
|
return ORTE_VPID_INVALID;
|
|
|
|
}
|
|
|
|
vpid = pdata->node->daemon->name.vpid;
|
2011-10-20 00:18:14 +04:00
|
|
|
}
|
2012-04-29 04:10:01 +04:00
|
|
|
|
2011-10-20 00:18:14 +04:00
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((5, orte_ess_base_output,
|
|
|
|
"%s ess:base: proc %s is hosted by daemon %s",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
ORTE_NAME_PRINT(proc),
|
2012-04-29 04:10:01 +04:00
|
|
|
ORTE_VPID_PRINT(vpid)));
|
2011-10-20 00:18:14 +04:00
|
|
|
|
2012-04-29 04:10:01 +04:00
|
|
|
return vpid;
|
2011-10-20 00:18:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
char* orte_ess_base_proc_get_hostname(orte_process_name_t *proc)
|
|
|
|
{
|
|
|
|
orte_nid_t *nid;
|
2012-04-29 04:10:01 +04:00
|
|
|
orte_proc_t *pdata;
|
|
|
|
char *hostname;
|
|
|
|
|
|
|
|
if (NULL == proc) {
|
2011-10-20 00:18:14 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
2012-04-29 04:10:01 +04:00
|
|
|
|
|
|
|
if (ORTE_PROC_IS_APP) {
|
|
|
|
if (NULL == (nid = orte_util_lookup_nid(proc))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
|
|
|
|
OPAL_OUTPUT_VERBOSE((5, orte_ess_base_output,
|
|
|
|
"%s LOOKING FOR PROC %s",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
ORTE_NAME_PRINT(proc)));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
hostname = nid->name;
|
|
|
|
} else {
|
|
|
|
if (NULL == (pdata = find_proc(proc))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
hostname = pdata->node->name;
|
|
|
|
}
|
2011-10-20 00:18:14 +04:00
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((5, orte_ess_base_output,
|
|
|
|
"%s ess:base: proc %s is on host %s",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
ORTE_NAME_PRINT(proc),
|
2012-04-29 04:10:01 +04:00
|
|
|
hostname));
|
2011-10-20 00:18:14 +04:00
|
|
|
|
2012-04-29 04:10:01 +04:00
|
|
|
return hostname;
|
2011-10-20 00:18:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
orte_local_rank_t orte_ess_base_proc_get_local_rank(orte_process_name_t *proc)
|
|
|
|
{
|
|
|
|
orte_pmap_t *pmap;
|
2012-04-29 04:10:01 +04:00
|
|
|
orte_proc_t *pdata;
|
|
|
|
orte_local_rank_t lrank;
|
|
|
|
|
|
|
|
if (NULL == proc) {
|
2011-10-20 00:18:14 +04:00
|
|
|
return ORTE_LOCAL_RANK_INVALID;
|
2012-04-29 04:10:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ORTE_PROC_IS_APP) {
|
|
|
|
if (NULL == (pmap = orte_util_lookup_pmap(proc))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
|
|
|
|
return ORTE_LOCAL_RANK_INVALID;
|
|
|
|
}
|
|
|
|
lrank = pmap->local_rank;
|
|
|
|
} else {
|
|
|
|
if (NULL == (pdata = find_proc(proc))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
|
|
|
|
return ORTE_LOCAL_RANK_INVALID;
|
|
|
|
}
|
|
|
|
lrank = pdata->local_rank;
|
|
|
|
}
|
|
|
|
|
2011-10-20 00:18:14 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((5, orte_ess_base_output,
|
|
|
|
"%s ess:base: proc %s has local rank %d",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
ORTE_NAME_PRINT(proc),
|
2012-04-29 04:10:01 +04:00
|
|
|
(int)lrank));
|
2011-10-20 00:18:14 +04:00
|
|
|
|
2012-04-29 04:10:01 +04:00
|
|
|
return lrank;
|
2011-10-20 00:18:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
orte_node_rank_t orte_ess_base_proc_get_node_rank(orte_process_name_t *proc)
|
|
|
|
{
|
|
|
|
orte_pmap_t *pmap;
|
2012-04-29 04:10:01 +04:00
|
|
|
orte_proc_t *pdata;
|
|
|
|
orte_node_rank_t nrank;
|
2011-10-20 00:18:14 +04:00
|
|
|
|
2012-04-29 04:10:01 +04:00
|
|
|
if (NULL == proc) {
|
2011-10-20 00:18:14 +04:00
|
|
|
return ORTE_NODE_RANK_INVALID;
|
2012-04-29 04:10:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ORTE_PROC_IS_APP) {
|
|
|
|
/* is this me? */
|
|
|
|
if (proc->jobid == ORTE_PROC_MY_NAME->jobid &&
|
|
|
|
proc->vpid == ORTE_PROC_MY_NAME->vpid) {
|
|
|
|
/* yes it is - reply with my rank. This is necessary
|
|
|
|
* because the pidmap will not have arrived when I
|
|
|
|
* am starting up, and if we use static ports, then
|
|
|
|
* I need to know my node rank during init
|
|
|
|
*/
|
|
|
|
return orte_process_info.my_node_rank;
|
|
|
|
}
|
|
|
|
if (NULL == (pmap = orte_util_lookup_pmap(proc))) {
|
|
|
|
return ORTE_NODE_RANK_INVALID;
|
|
|
|
}
|
|
|
|
nrank = pmap->node_rank;
|
|
|
|
} else {
|
|
|
|
if (NULL == (pdata = find_proc(proc))) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_NOT_FOUND);
|
|
|
|
return ORTE_NODE_RANK_INVALID;
|
|
|
|
}
|
|
|
|
nrank = pdata->node_rank;
|
|
|
|
}
|
2011-10-20 00:18:14 +04:00
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((5, orte_ess_base_output,
|
|
|
|
"%s ess:base: proc %s has node rank %d",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
ORTE_NAME_PRINT(proc),
|
2012-04-29 04:10:01 +04:00
|
|
|
(int)nrank));
|
2011-10-20 00:18:14 +04:00
|
|
|
|
2012-04-29 04:10:01 +04:00
|
|
|
return nrank;
|
2011-10-20 00:18:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int orte_ess_base_update_pidmap(opal_byte_object_t *bo)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((2, orte_ess_base_output,
|
|
|
|
"%s ess:base: updating pidmap",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
|
|
|
|
|
|
|
|
/* build the pmap */
|
2012-04-29 04:10:01 +04:00
|
|
|
if (ORTE_PROC_IS_APP) {
|
|
|
|
if (ORTE_SUCCESS != (ret = orte_util_decode_pidmap(bo))) {
|
|
|
|
ORTE_ERROR_LOG(ret);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ORTE_SUCCESS != (ret = orte_util_decode_daemon_pidmap(bo))) {
|
|
|
|
ORTE_ERROR_LOG(ret);
|
|
|
|
}
|
2011-10-20 00:18:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int orte_ess_base_update_nidmap(opal_byte_object_t *bo)
|
|
|
|
{
|
|
|
|
int rc;
|
2012-04-29 04:10:01 +04:00
|
|
|
|
2011-10-20 00:18:14 +04:00
|
|
|
/* decode the nidmap - the util will know what to do */
|
2012-04-29 04:10:01 +04:00
|
|
|
if (ORTE_PROC_IS_APP) {
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_util_decode_nodemap(bo))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ORTE_SUCCESS != (rc = orte_util_decode_daemon_nodemap(bo))) {
|
|
|
|
ORTE_ERROR_LOG(rc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-20 00:18:14 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|