2004-06-29 08:50:40 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-06-29 08:50:40 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
2004-08-19 03:15:48 +04:00
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
#include "orte_config.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/constants.h"
|
2004-08-19 03:15:48 +04:00
|
|
|
|
2004-06-29 08:50:40 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2004-06-29 08:50:40 +04:00
|
|
|
#include <unistd.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
2004-06-29 11:02:57 +04:00
|
|
|
#include <sys/types.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
2004-06-29 08:50:40 +04:00
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal/mca/base/base.h"
|
|
|
|
#include "opal/mca/base/mca_base_param.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "opal/util/output.h"
|
|
|
|
|
|
|
|
#include "orte/runtime/orte_globals.h"
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte/util/proc_info.h"
|
2004-06-29 08:50:40 +04:00
|
|
|
|
2006-08-20 19:54:04 +04:00
|
|
|
ORTE_DECLSPEC orte_proc_info_t orte_process_info = {
|
2008-02-28 04:57:57 +03:00
|
|
|
/* .my_name = */ {ORTE_JOBID_INVALID, ORTE_VPID_INVALID},
|
|
|
|
/* .my_daemon = */ {ORTE_JOBID_INVALID, ORTE_VPID_INVALID},
|
|
|
|
/* .my_daemon_uri = */ NULL,
|
|
|
|
/* .my_hnp = */ {0, 0},
|
|
|
|
/* .my_hnp_uri = */ NULL,
|
2008-03-06 18:30:44 +03:00
|
|
|
/* .lifeline = */ NULL,
|
2008-02-28 04:57:57 +03:00
|
|
|
/* .hnp_pid = */ 0,
|
2006-12-07 06:11:20 +03:00
|
|
|
/* ,app_num = */ -1,
|
2007-07-02 05:33:35 +04:00
|
|
|
/* ,universe_size = */ -1,
|
2005-03-14 23:57:21 +03:00
|
|
|
/* .num_procs = */ 1,
|
Compute and pass the local_rank and local number of procs (in that proc's job) on the node.
To be precise, given this hypothetical launching pattern:
host1: vpids 0, 2, 4, 6
host2: vpids 1, 3, 5, 7
The local_rank for these procs would be:
host1: vpids 0->local_rank 0, v2->lr1, v4->lr2, v6->lr3
host2: vpids 1->local_rank 0, v3->lr1, v5->lr2, v7->lr3
and the number of local procs on each node would be four. If vpid=0 then does a comm_spawn of one process on host1, the values of the parent job would remain unchanged. The local_rank of the child process would be 0 and its num_local_procs would be 1 since it is in a separate jobid.
I have verified this functionality for the rsh case - need to verify that slurm and other cases also get the right values. Some consolidation of common code is probably going to occur in the SDS components to make this simpler and more maintainable in the future.
This commit was SVN r14706.
2007-05-21 18:30:10 +04:00
|
|
|
/* .local_rank = */ ORTE_VPID_INVALID,
|
|
|
|
/* .num_local_procs = */ 0,
|
2004-06-29 08:50:40 +04:00
|
|
|
/* .pid = */ 0,
|
2008-02-28 04:57:57 +03:00
|
|
|
/* .singleton = */ false,
|
2005-03-14 23:57:21 +03:00
|
|
|
/* .daemon = */ false,
|
2008-02-28 04:57:57 +03:00
|
|
|
/* .hnp = */ false,
|
|
|
|
/* .tool = */ false,
|
2004-08-24 01:39:22 +04:00
|
|
|
/* .tmpdir_base = */ NULL,
|
2004-08-29 20:37:02 +04:00
|
|
|
/* .top_session_dir = */ NULL,
|
2004-06-29 08:50:40 +04:00
|
|
|
/* .job_session_dir = */ NULL,
|
|
|
|
/* .proc_session_dir = */ NULL,
|
|
|
|
/* .sock_stdin = */ NULL,
|
|
|
|
/* .sock_stdout = */ NULL,
|
2005-05-22 07:11:33 +04:00
|
|
|
/* .sock_stderr = */ NULL
|
|
|
|
};
|
2004-06-29 08:50:40 +04:00
|
|
|
|
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
int orte_proc_info(void)
|
2004-06-29 08:50:40 +04:00
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
int tmp;
|
|
|
|
char *uri, *ptr;
|
|
|
|
size_t len, i;
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
mca_base_param_reg_string_name("orte", "hnp_uri",
|
|
|
|
"HNP contact info",
|
|
|
|
true, false, NULL, &uri);
|
|
|
|
if (NULL != uri) {
|
|
|
|
/* the uri value passed to us will have quote marks around it to protect
|
|
|
|
* the value if passed on the command line. We must remove those
|
|
|
|
* to have a correct uri string
|
|
|
|
*/
|
|
|
|
if ('"' == uri[0]) {
|
|
|
|
/* if the first char is a quote, then so will the last one be */
|
|
|
|
ptr = &uri[1];
|
|
|
|
len = strlen(ptr) - 1;
|
|
|
|
} else {
|
|
|
|
ptr = &uri[0];
|
|
|
|
len = strlen(uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we have to copy the string by hand as strndup is a GNU extension
|
|
|
|
* and may not be generally available
|
|
|
|
*/
|
|
|
|
orte_process_info.my_hnp_uri = (char*)malloc(len+1);
|
|
|
|
for (i=0; i < len; i++) {
|
|
|
|
orte_process_info.my_hnp_uri[i] = ptr[i];
|
|
|
|
}
|
|
|
|
orte_process_info.my_hnp_uri[len] = '\0'; /* NULL terminate */
|
|
|
|
free(uri);
|
2004-07-14 22:08:34 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
mca_base_param_reg_string_name("orte", "local_daemon_uri",
|
|
|
|
"Daemon contact info",
|
|
|
|
true, false, NULL, &(orte_process_info.my_daemon_uri));
|
|
|
|
|
|
|
|
OPAL_OUTPUT_VERBOSE((1, orte_debug_output,
|
|
|
|
"proc_info: hnp_uri %s\n\tdaemon uri %s",
|
|
|
|
(NULL == orte_process_info.my_hnp_uri) ? "NULL" : orte_process_info.my_hnp_uri,
|
|
|
|
(NULL == orte_process_info.my_daemon_uri) ? "NULL" : orte_process_info.my_daemon_uri));
|
|
|
|
|
|
|
|
mca_base_param_reg_int_name("orte", "app_num",
|
|
|
|
"Index of the app_context that defines this proc",
|
|
|
|
true, false, -1, &tmp);
|
2006-12-07 06:11:20 +03:00
|
|
|
orte_process_info.app_num = tmp;
|
2008-02-28 04:57:57 +03:00
|
|
|
|
|
|
|
mca_base_param_reg_int_name("orte", "universe_size",
|
|
|
|
"Total number of process slots allocated to this job",
|
|
|
|
true, false, -1, &tmp);
|
2007-07-02 05:33:35 +04:00
|
|
|
orte_process_info.universe_size = tmp;
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
mca_base_param_reg_string_name("tmpdir", "base",
|
|
|
|
"Base of the session directory tree",
|
|
|
|
false, false, NULL, &(orte_process_info.tmpdir_base));
|
2004-07-14 22:08:34 +04:00
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
/* get the process id */
|
|
|
|
orte_process_info.pid = getpid();
|
2004-07-14 22:08:34 +04:00
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
return ORTE_SUCCESS;
|
2004-06-29 08:50:40 +04:00
|
|
|
}
|
2005-03-19 02:40:08 +03:00
|
|
|
|
|
|
|
|
|
|
|
int orte_proc_info_finalize(void)
|
|
|
|
{
|
|
|
|
if (NULL != orte_process_info.tmpdir_base) {
|
|
|
|
free(orte_process_info.tmpdir_base);
|
2005-05-22 07:11:33 +04:00
|
|
|
orte_process_info.tmpdir_base = NULL;
|
2005-03-19 02:40:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != orte_process_info.top_session_dir) {
|
|
|
|
free(orte_process_info.top_session_dir);
|
2005-05-22 07:11:33 +04:00
|
|
|
orte_process_info.top_session_dir = NULL;
|
2005-03-19 02:40:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != orte_process_info.job_session_dir) {
|
|
|
|
free(orte_process_info.job_session_dir);
|
2005-05-22 07:11:33 +04:00
|
|
|
orte_process_info.job_session_dir = NULL;
|
2005-03-19 02:40:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != orte_process_info.proc_session_dir) {
|
|
|
|
free(orte_process_info.proc_session_dir);
|
2005-05-22 07:11:33 +04:00
|
|
|
orte_process_info.proc_session_dir = NULL;
|
2005-03-19 02:40:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != orte_process_info.sock_stdin) {
|
|
|
|
free(orte_process_info.sock_stdin);
|
2005-05-22 07:11:33 +04:00
|
|
|
orte_process_info.sock_stdin = NULL;
|
2005-03-19 02:40:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != orte_process_info.sock_stdout) {
|
|
|
|
free(orte_process_info.sock_stdout);
|
2005-05-22 07:11:33 +04:00
|
|
|
orte_process_info.sock_stdout = NULL;
|
2005-03-19 02:40:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL != orte_process_info.sock_stderr) {
|
|
|
|
free(orte_process_info.sock_stderr);
|
2005-05-22 07:11:33 +04:00
|
|
|
orte_process_info.sock_stderr = NULL;
|
2005-03-19 02:40:08 +03:00
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
orte_process_info.hnp = false;
|
2005-05-24 17:39:15 +04:00
|
|
|
orte_process_info.singleton = false;
|
2005-05-22 07:11:33 +04:00
|
|
|
orte_process_info.daemon = false;
|
|
|
|
|
2005-03-19 02:40:08 +03:00
|
|
|
return ORTE_SUCCESS;
|
2005-03-22 03:31:17 +03:00
|
|
|
}
|