Update orte-ps to add parseable output - not fully tested because I couldn't get other parts of the system to work.
This commit was SVN r24927.
Этот коммит содержится в:
родитель
869024f1c6
Коммит
00647fa342
@ -57,7 +57,6 @@
|
||||
#include "opal/util/cmd_line.h"
|
||||
#include "opal/util/output.h"
|
||||
#include "opal/util/opal_environ.h"
|
||||
#include "opal/util/opal_sos.h"
|
||||
#include "opal/mca/base/base.h"
|
||||
#include "opal/mca/base/mca_base_param.h"
|
||||
#include "opal/runtime/opal.h"
|
||||
@ -66,6 +65,7 @@
|
||||
#endif
|
||||
|
||||
#include "orte/runtime/runtime.h"
|
||||
#include "orte/util/error_strings.h"
|
||||
#include "orte/util/hnp_contact.h"
|
||||
#include "orte/util/name_fns.h"
|
||||
#include "orte/util/show_help.h"
|
||||
@ -84,7 +84,7 @@ struct orte_ps_mpirun_info_t {
|
||||
|
||||
/* HNP info */
|
||||
orte_hnp_contact_t *hnp;
|
||||
|
||||
|
||||
/* array of jobs */
|
||||
orte_std_cntr_t num_jobs;
|
||||
orte_job_t **jobs;
|
||||
@ -145,8 +145,8 @@ static int pretty_print_vpids(orte_job_t *job);
|
||||
static void pretty_print_dashed_line(int len);
|
||||
|
||||
static char *pretty_node_state(orte_node_state_t state);
|
||||
static char *pretty_job_state(orte_job_state_t state);
|
||||
static char *pretty_vpid_state(orte_proc_state_t state);
|
||||
|
||||
static int parseable_print(orte_ps_mpirun_info_t *hnpinfo);
|
||||
|
||||
/*****************************************
|
||||
* Global Vars for Command line Arguments
|
||||
@ -154,12 +154,12 @@ static char *pretty_vpid_state(orte_proc_state_t state);
|
||||
typedef struct {
|
||||
bool help;
|
||||
bool verbose;
|
||||
bool parseable;
|
||||
orte_jobid_t jobid;
|
||||
orte_vpid_t vpid;
|
||||
orte_epoch_t epoch;
|
||||
bool nodes;
|
||||
bool daemons;
|
||||
int output;
|
||||
pid_t pid;
|
||||
} orte_ps_globals_t;
|
||||
|
||||
orte_ps_globals_t orte_ps_globals;
|
||||
@ -177,6 +177,12 @@ opal_cmd_line_init_t cmd_line_opts[] = {
|
||||
&orte_ps_globals.verbose, OPAL_CMD_LINE_TYPE_BOOL,
|
||||
"Be Verbose" },
|
||||
|
||||
{ NULL, NULL, NULL,
|
||||
'\0', NULL, "parseable",
|
||||
0,
|
||||
&orte_ps_globals.parseable, OPAL_CMD_LINE_TYPE_BOOL,
|
||||
"Provide parseable output" },
|
||||
|
||||
{ NULL, NULL, NULL,
|
||||
'\0', NULL, "daemons",
|
||||
0,
|
||||
@ -187,14 +193,13 @@ opal_cmd_line_init_t cmd_line_opts[] = {
|
||||
'j', NULL, "jobid",
|
||||
1,
|
||||
&orte_ps_globals.jobid, OPAL_CMD_LINE_TYPE_INT,
|
||||
"Specify a specific jobid" },
|
||||
#if 0
|
||||
"Specify a local jobid for the given mpirun - a value from 0 to N" },
|
||||
|
||||
{ NULL, NULL, NULL,
|
||||
'p', NULL, "vpid",
|
||||
'p', NULL, "pid",
|
||||
1,
|
||||
&orte_ps_globals.vpid, OPAL_CMD_LINE_TYPE_INT,
|
||||
"Specify a specific vpid. Must specify a --jobid as well" },
|
||||
#endif
|
||||
&orte_ps_globals.pid, OPAL_CMD_LINE_TYPE_INT,
|
||||
"Specify mpirun pid" },
|
||||
|
||||
{ NULL, NULL, NULL,
|
||||
'n', NULL, "nodes",
|
||||
@ -239,6 +244,10 @@ main(int argc, char *argv[])
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
opal_output_verbose(10, orte_ps_globals.output,
|
||||
"orte_ps: Found %d HNPs\n",
|
||||
(int)opal_list_get_size(&hnp_list));
|
||||
|
||||
/*
|
||||
* For each hnp in the listing
|
||||
*/
|
||||
@ -246,6 +255,15 @@ main(int argc, char *argv[])
|
||||
orte_hnp_contact_t *hnp = (orte_hnp_contact_t*)item;
|
||||
hnpinfo.hnp = hnp;
|
||||
|
||||
opal_output_verbose(10, orte_ps_globals.output,
|
||||
"orte_ps: Processing HNP %lu\n",
|
||||
(unsigned long)hnpinfo.hnp->pid);
|
||||
|
||||
if (0 < orte_ps_globals.pid &&
|
||||
hnpinfo.hnp->pid != orte_ps_globals.pid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gather the information
|
||||
*/
|
||||
@ -258,7 +276,7 @@ main(int argc, char *argv[])
|
||||
/* this could be due to a stale session directory - if so,
|
||||
* just skip this entry, but don't abort
|
||||
*/
|
||||
if (ORTE_ERR_SILENT == OPAL_SOS_GET_ERROR_CODE(ret)) {
|
||||
if (ORTE_ERR_SILENT == ret) {
|
||||
orte_show_help("help-orte-ps.txt", "stale-hnp", true,
|
||||
ORTE_NAME_PRINT(&(hnpinfo.hnp->name)));
|
||||
continue;
|
||||
@ -266,12 +284,17 @@ main(int argc, char *argv[])
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the information
|
||||
*/
|
||||
if(ORTE_SUCCESS != (ret = pretty_print(&hnpinfo)) ) {
|
||||
exit_status = ret;
|
||||
goto cleanup;
|
||||
/* Print the information */
|
||||
if (orte_ps_globals.parseable) {
|
||||
if (ORTE_SUCCESS != (ret = parseable_print(&hnpinfo))) {
|
||||
exit_status = ret;
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
if(ORTE_SUCCESS != (ret = pretty_print(&hnpinfo)) ) {
|
||||
exit_status = ret;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,12 +312,12 @@ static int parse_args(int argc, char *argv[]) {
|
||||
opal_cmd_line_t cmd_line;
|
||||
orte_ps_globals_t tmp = { false, /* help */
|
||||
false, /* verbose */
|
||||
false, /* parseable */
|
||||
ORTE_JOBID_WILDCARD, /* jobid */
|
||||
ORTE_VPID_WILDCARD, /* vpid */
|
||||
ORTE_EPOCH_WILDCARD, /* epoch */
|
||||
false, /* nodes */
|
||||
false, /* daemons */
|
||||
-1}; /* output */
|
||||
-1, /* output */
|
||||
0}; /* pid */
|
||||
|
||||
orte_ps_globals = tmp;
|
||||
|
||||
@ -318,18 +341,17 @@ static int parse_args(int argc, char *argv[]) {
|
||||
return ORTE_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* If they specify a vpid, they must specify a jobid
|
||||
*/
|
||||
#if 0
|
||||
if( ORTE_VPID_WILDCARD != orte_ps_globals.vpid) {
|
||||
if( ORTE_JOBID_WILDCARD == orte_ps_globals.jobid) {
|
||||
orte_show_help("help-orte-ps.txt", "vpid-usage", true,
|
||||
orte_ps_globals.vpid);
|
||||
return ORTE_ERROR;
|
||||
}
|
||||
/* if the jobid is given, then we need a pid */
|
||||
if (ORTE_JOBID_WILDCARD != orte_ps_globals.jobid &&
|
||||
0 == orte_ps_globals.pid) {
|
||||
char *args = NULL;
|
||||
args = opal_cmd_line_get_usage_msg(&cmd_line);
|
||||
orte_show_help("help-orte-ps.txt", "usage", true,
|
||||
args);
|
||||
free(args);
|
||||
return ORTE_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
|
||||
@ -518,9 +540,9 @@ static int pretty_print_jobs(orte_job_t **jobs, orte_std_cntr_t num_jobs) {
|
||||
* Caculate segment lengths
|
||||
*/
|
||||
len_jobid = strlen(jobstr);;
|
||||
len_state = (int) (strlen(pretty_job_state(job->state)) < strlen("State") ?
|
||||
len_state = (int) (strlen(orte_job_state_to_str(job->state)) < strlen("State") ?
|
||||
strlen("State") :
|
||||
strlen(pretty_job_state(job->state)));
|
||||
strlen(orte_job_state_to_str(job->state)));
|
||||
len_slots = 6;
|
||||
len_vpid_r = (int) strlen("Num Procs");
|
||||
#if OPAL_ENABLE_FT_CR == 1
|
||||
@ -573,7 +595,7 @@ static int pretty_print_jobs(orte_job_t **jobs, orte_std_cntr_t num_jobs) {
|
||||
* Print Info
|
||||
*/
|
||||
printf("%*s | ", len_jobid , ORTE_JOBID_PRINT(job->jobid));
|
||||
printf("%*s | ", len_state , pretty_job_state(job->state));
|
||||
printf("%*s | ", len_state , orte_job_state_to_str(job->state));
|
||||
printf("%*d | ", len_slots , (uint)job->total_slots_alloc);
|
||||
printf("%*d | ", len_vpid_r, job->num_procs);
|
||||
#if OPAL_ENABLE_FT_CR == 1
|
||||
@ -675,8 +697,8 @@ static int pretty_print_vpids(orte_job_t *job) {
|
||||
len_node = strlen("Unknown");
|
||||
}
|
||||
|
||||
if( (int)strlen(pretty_vpid_state(vpid->state)) > len_state)
|
||||
len_state = strlen(pretty_vpid_state(vpid->state));
|
||||
if( (int)strlen(orte_proc_state_to_str(vpid->state)) > len_state)
|
||||
len_state = strlen(orte_proc_state_to_str(vpid->state));
|
||||
|
||||
#if OPAL_ENABLE_FT_CR == 1
|
||||
orte_snapc_ckpt_state_str(&state_str, vpid->ckpt_state);
|
||||
@ -755,7 +777,7 @@ static int pretty_print_vpids(orte_job_t *job) {
|
||||
printf("%*u | ", len_rank , (uint)vpid->local_rank);
|
||||
printf("%*d | ", len_pid , vpid->pid);
|
||||
printf("%*s | ", len_node , (NULL == vpid->nodename) ? "Unknown" : vpid->nodename);
|
||||
printf("%*s | ", len_state , pretty_vpid_state(vpid->state));
|
||||
printf("%*s | ", len_state , orte_proc_state_to_str(vpid->state));
|
||||
|
||||
#if OPAL_ENABLE_FT_CR == 1
|
||||
printf("%*s | ", len_ckpt_s, state_str);
|
||||
@ -847,7 +869,7 @@ static int gather_vpid_info(orte_ps_mpirun_info_t *hnpinfo) {
|
||||
|
||||
/* query the HNP for info on the procs in this job */
|
||||
if (ORTE_SUCCESS != (ret = orte_util_comm_query_proc_info(&(hnpinfo->hnp->name), job->jobid,
|
||||
orte_ps_globals.vpid, ORTE_EPOCH_WILDCARD, &cnt, &procs))) {
|
||||
ORTE_VPID_WILDCARD, ORTE_EPOCH_WILDCARD, &cnt, &procs))) {
|
||||
ORTE_ERROR_LOG(ret);
|
||||
}
|
||||
job->procs->addr = (void**)procs;
|
||||
@ -858,75 +880,6 @@ static int gather_vpid_info(orte_ps_mpirun_info_t *hnpinfo) {
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
|
||||
static char *pretty_job_state(orte_job_state_t state) {
|
||||
switch(state) {
|
||||
case ORTE_JOB_STATE_UNDEF:
|
||||
return strdup("Undef");
|
||||
break;
|
||||
case ORTE_JOB_STATE_INIT:
|
||||
return strdup("Init");
|
||||
break;
|
||||
case ORTE_JOB_STATE_LAUNCHED:
|
||||
return strdup("Launched");
|
||||
break;
|
||||
case ORTE_JOB_STATE_RUNNING:
|
||||
return strdup("Running");
|
||||
break;
|
||||
case ORTE_JOB_STATE_TERMINATED:
|
||||
return strdup("Terminated");
|
||||
break;
|
||||
case ORTE_JOB_STATE_ABORTED:
|
||||
return strdup("Aborted");
|
||||
break;
|
||||
case ORTE_JOB_STATE_FAILED_TO_START:
|
||||
return strdup("Failed to start");
|
||||
break;
|
||||
case ORTE_JOB_STATE_ABORTED_BY_SIG:
|
||||
return strdup("Aborted by signal");
|
||||
break;
|
||||
case ORTE_JOB_STATE_ABORT_ORDERED:
|
||||
return strdup("Aborted ordered");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return strdup("");
|
||||
}
|
||||
|
||||
static char *pretty_vpid_state(orte_proc_state_t state) {
|
||||
switch(state) {
|
||||
case ORTE_PROC_STATE_UNDEF:
|
||||
return strdup("Undef");
|
||||
break;
|
||||
case ORTE_PROC_STATE_INIT:
|
||||
return strdup("Init");
|
||||
break;
|
||||
case ORTE_PROC_STATE_LAUNCHED:
|
||||
return strdup("Launched");
|
||||
break;
|
||||
case ORTE_PROC_STATE_RUNNING:
|
||||
return strdup("Running");
|
||||
break;
|
||||
case ORTE_PROC_STATE_TERMINATED:
|
||||
return strdup("Terminated");
|
||||
break;
|
||||
case ORTE_PROC_STATE_ABORTED:
|
||||
return strdup("Aborted");
|
||||
break;
|
||||
case ORTE_PROC_STATE_FAILED_TO_START:
|
||||
return strdup("Failed to start");
|
||||
break;
|
||||
case ORTE_PROC_STATE_ABORTED_BY_SIG:
|
||||
return strdup("Aborted by signal");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return strdup("");
|
||||
}
|
||||
|
||||
static char *pretty_node_state(orte_node_state_t state) {
|
||||
switch(state) {
|
||||
case ORTE_NODE_STATE_DOWN:
|
||||
@ -944,3 +897,52 @@ static char *pretty_node_state(orte_node_state_t state) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int parseable_print(orte_ps_mpirun_info_t *hnpinfo)
|
||||
{
|
||||
orte_job_t **jobs;
|
||||
orte_node_t **nodes;
|
||||
orte_proc_t *proc;
|
||||
char *loc;
|
||||
int i, j;
|
||||
|
||||
printf("mpirun:%lu:num nodes:%d:num jobs:%d\n",
|
||||
(unsigned long)hnpinfo->hnp->pid, hnpinfo->num_nodes, hnpinfo->num_jobs);
|
||||
|
||||
if (orte_ps_globals.nodes) {
|
||||
nodes = hnpinfo->nodes;
|
||||
for (i=0; i < hnpinfo->num_nodes; i++) {
|
||||
printf("node:%s:state:%s:slots:%d:in use:%d\n",
|
||||
nodes[i]->name, pretty_node_state(nodes[i]->state),
|
||||
nodes[i]->slots, nodes[i]->slots_inuse);
|
||||
}
|
||||
}
|
||||
|
||||
jobs = hnpinfo->jobs;
|
||||
for (i=0; i < hnpinfo->num_jobs; i++) {
|
||||
printf("jobid:%d:state:%s:slots:%d:num procs:%d\n",
|
||||
ORTE_LOCAL_JOBID(jobs[i]->jobid),
|
||||
orte_job_state_to_str(jobs[i]->state),
|
||||
jobs[i]->total_slots_alloc,
|
||||
jobs[i]->num_procs);
|
||||
/* print the proc info */
|
||||
for (j=0; j < jobs[i]->procs->size; j++) {
|
||||
if (NULL == (proc = (orte_proc_t*)opal_pointer_array_get_item(jobs[i]->procs, j))) {
|
||||
continue;
|
||||
}
|
||||
if (NULL == proc->node) {
|
||||
loc = "unassigned";
|
||||
} else if (NULL == proc->node->name) {
|
||||
loc = "unknown";
|
||||
} else {
|
||||
loc = proc->node->name;
|
||||
}
|
||||
printf("process_name:%s:rank:%s:pid:%lu:node:%s:state:%s\n",
|
||||
ORTE_NAME_PRINT(&proc->name), ORTE_VPID_PRINT(proc->name.vpid),
|
||||
(unsigned long)proc->pid, loc,
|
||||
orte_proc_state_to_str(proc->state));
|
||||
}
|
||||
}
|
||||
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user