2006-06-29 02:06:13 +04:00
|
|
|
/*
|
2010-03-13 02:57:50 +03:00
|
|
|
* Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
|
2006-06-29 02:06:13 +04:00
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2011-06-24 00:38:02 +04:00
|
|
|
* Copyright (c) 2004-2011 The University of Tennessee and The University
|
2006-06-29 02:06:13 +04:00
|
|
|
* 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.
|
2013-05-18 01:45:49 +04:00
|
|
|
* Copyright (c) 2006-2013 Cisco Systems, Inc. All rights reserved.
|
2007-01-05 00:48:34 +03:00
|
|
|
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
2007-06-05 07:03:59 +04:00
|
|
|
* Copyright (c) 2007 Los Alamos National Security, LLC. All rights
|
|
|
|
* reserved.
|
2010-11-19 21:12:46 +03:00
|
|
|
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
|
2006-06-29 02:06:13 +04:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2007-03-17 02:11:45 +03:00
|
|
|
/**
|
|
|
|
* @fie
|
|
|
|
* ORTE PS command
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-06-29 02:06:13 +04:00
|
|
|
#include "orte_config.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/constants.h"
|
2006-06-29 02:06:13 +04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
2007-04-01 20:16:54 +04:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2006-06-29 02:06:13 +04:00
|
|
|
#include <unistd.h>
|
2007-04-01 20:16:54 +04:00
|
|
|
#endif /* HAVE_UNISTD_H */
|
2006-06-29 02:06:13 +04:00
|
|
|
#ifdef HAVE_STDLIB_H
|
|
|
|
#include <stdlib.h>
|
|
|
|
#endif /* HAVE_STDLIB_H */
|
|
|
|
#ifdef HAVE_SYS_STAT_H
|
|
|
|
#include <sys/stat.h>
|
2007-04-01 20:16:54 +04:00
|
|
|
#endif /* HAVE_SYS_STAT_H */
|
2006-06-29 02:06:13 +04:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
#include <sys/types.h>
|
2007-04-01 20:16:54 +04:00
|
|
|
#endif /* HAVE_SYS_TYPES_H */
|
2006-06-29 02:06:13 +04:00
|
|
|
#ifdef HAVE_SYS_WAIT_H
|
|
|
|
#include <sys/wait.h>
|
2007-04-01 20:16:54 +04:00
|
|
|
#endif /* HAVE_SYS_WAIT_H */
|
2006-06-29 02:06:13 +04:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
#include <string.h>
|
|
|
|
#endif /* HAVE_STRING_H */
|
2007-04-01 20:16:54 +04:00
|
|
|
#ifdef HAVE_DIRENT_H
|
2007-03-17 02:11:45 +03:00
|
|
|
#include <dirent.h>
|
2007-04-01 20:16:54 +04:00
|
|
|
#endif /* HAVE_DIRENT_H */
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2011-07-24 02:23:24 +04:00
|
|
|
#include "opal/util/basename.h"
|
2006-06-29 02:06:13 +04:00
|
|
|
#include "opal/util/cmd_line.h"
|
2009-02-14 05:26:12 +03:00
|
|
|
#include "opal/util/output.h"
|
2006-06-29 02:06:13 +04:00
|
|
|
#include "opal/util/opal_environ.h"
|
2012-02-29 21:52:38 +04:00
|
|
|
#include "opal/util/show_help.h"
|
2006-06-29 02:06:13 +04:00
|
|
|
#include "opal/mca/base/base.h"
|
2007-03-17 02:11:45 +03:00
|
|
|
#include "opal/runtime/opal.h"
|
2010-03-13 02:57:50 +03:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2007-03-17 02:11:45 +03:00
|
|
|
#include "opal/runtime/opal_cr.h"
|
|
|
|
#endif
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2007-03-17 02:11:45 +03:00
|
|
|
#include "orte/runtime/runtime.h"
|
2011-07-24 00:20:31 +04:00
|
|
|
#include "orte/util/error_strings.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/util/hnp_contact.h"
|
|
|
|
#include "orte/util/name_fns.h"
|
2008-06-09 18:53:58 +04:00
|
|
|
#include "orte/util/show_help.h"
|
2009-05-04 15:07:40 +04:00
|
|
|
#include "orte/util/proc_info.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
|
|
|
#include "orte/util/comm/comm.h"
|
2007-03-17 02:11:45 +03:00
|
|
|
#include "orte/mca/ras/ras_types.h"
|
2010-03-13 02:57:50 +03:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/mca/snapc/base/base.h"
|
2007-03-17 02:11:45 +03:00
|
|
|
#endif
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/runtime/orte_globals.h"
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
struct orte_ps_mpirun_info_t {
|
2006-06-29 02:06:13 +04:00
|
|
|
/** This is an object, so it must have a super */
|
|
|
|
opal_list_item_t super;
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
/* HNP info */
|
|
|
|
orte_hnp_contact_t *hnp;
|
2011-07-24 00:20:31 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
/* array of jobs */
|
|
|
|
orte_std_cntr_t num_jobs;
|
|
|
|
orte_job_t **jobs;
|
2006-07-03 21:11:02 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
/* array of nodes */
|
|
|
|
orte_std_cntr_t num_nodes;
|
|
|
|
orte_node_t **nodes;
|
2006-06-29 02:06:13 +04:00
|
|
|
};
|
2008-02-28 04:57:57 +03:00
|
|
|
typedef struct orte_ps_mpirun_info_t orte_ps_mpirun_info_t;
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
static void orte_ps_mpirun_info_construct(orte_ps_mpirun_info_t *ptr)
|
|
|
|
{
|
|
|
|
ptr->hnp = NULL;
|
|
|
|
ptr->num_jobs = 0;
|
|
|
|
ptr->jobs = NULL;
|
|
|
|
ptr->num_nodes = 0;
|
|
|
|
ptr->nodes = NULL;
|
|
|
|
}
|
|
|
|
static void orte_ps_mpirun_info_destruct(orte_ps_mpirun_info_t *ptr)
|
|
|
|
{
|
|
|
|
orte_std_cntr_t i;
|
|
|
|
|
|
|
|
if (NULL != ptr->hnp) OBJ_RELEASE(ptr->hnp);
|
|
|
|
if (NULL != ptr->jobs) {
|
|
|
|
for (i=0; i < ptr->num_jobs; i++) {
|
|
|
|
OBJ_RELEASE(ptr->jobs[i]);
|
|
|
|
}
|
|
|
|
free(ptr->jobs);
|
|
|
|
}
|
|
|
|
if (NULL != ptr->nodes) {
|
|
|
|
for (i=0; i < ptr->num_nodes; i++) {
|
|
|
|
OBJ_RELEASE(ptr->nodes[i]);
|
|
|
|
}
|
|
|
|
free(ptr->nodes);
|
|
|
|
}
|
|
|
|
}
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
OBJ_CLASS_INSTANCE(orte_ps_mpirun_info_t,
|
2006-06-29 02:06:13 +04:00
|
|
|
opal_list_item_t,
|
2008-02-28 04:57:57 +03:00
|
|
|
orte_ps_mpirun_info_construct,
|
|
|
|
orte_ps_mpirun_info_destruct);
|
2006-06-29 02:06:13 +04:00
|
|
|
|
|
|
|
/******************
|
|
|
|
* Local Functions
|
|
|
|
******************/
|
2007-03-17 02:11:45 +03:00
|
|
|
static int orte_ps_init(int argc, char *argv[]);
|
2006-06-29 02:06:13 +04:00
|
|
|
static int parse_args(int argc, char *argv[]);
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
static int gather_information(orte_ps_mpirun_info_t *hnpinfo);
|
|
|
|
static int gather_active_jobs(orte_ps_mpirun_info_t *hnpinfo);
|
|
|
|
static int gather_nodes(orte_ps_mpirun_info_t *hnpinfo);
|
|
|
|
static int gather_vpid_info(orte_ps_mpirun_info_t *hnpinfo);
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
static int pretty_print(orte_ps_mpirun_info_t *hnpinfo);
|
|
|
|
static int pretty_print_nodes(orte_node_t **nodes, orte_std_cntr_t num_nodes);
|
|
|
|
static int pretty_print_jobs(orte_job_t **jobs, orte_std_cntr_t num_jobs);
|
|
|
|
static int pretty_print_vpids(orte_job_t *job);
|
2009-03-03 16:09:19 +03:00
|
|
|
static void pretty_print_dashed_line(int len);
|
2006-07-03 21:11:02 +04:00
|
|
|
|
|
|
|
static char *pretty_node_state(orte_node_state_t state);
|
2011-07-24 00:20:31 +04:00
|
|
|
|
|
|
|
static int parseable_print(orte_ps_mpirun_info_t *hnpinfo);
|
2006-06-29 02:06:13 +04:00
|
|
|
|
|
|
|
/*****************************************
|
|
|
|
* Global Vars for Command line Arguments
|
|
|
|
*****************************************/
|
|
|
|
typedef struct {
|
|
|
|
bool help;
|
|
|
|
bool verbose;
|
2011-07-24 00:20:31 +04:00
|
|
|
bool parseable;
|
2010-11-19 21:12:46 +03:00
|
|
|
orte_jobid_t jobid;
|
2006-07-03 21:11:02 +04:00
|
|
|
bool nodes;
|
2008-02-28 04:57:57 +03:00
|
|
|
bool daemons;
|
2007-03-17 02:11:45 +03:00
|
|
|
int output;
|
2011-07-24 00:20:31 +04:00
|
|
|
pid_t pid;
|
2006-06-29 02:06:13 +04:00
|
|
|
} orte_ps_globals_t;
|
|
|
|
|
|
|
|
orte_ps_globals_t orte_ps_globals;
|
|
|
|
|
|
|
|
opal_cmd_line_init_t cmd_line_opts[] = {
|
2012-10-30 23:45:18 +04:00
|
|
|
{ NULL,
|
2006-06-29 02:06:13 +04:00
|
|
|
'h', NULL, "help",
|
|
|
|
0,
|
|
|
|
&orte_ps_globals.help, OPAL_CMD_LINE_TYPE_BOOL,
|
|
|
|
"This help message" },
|
|
|
|
|
2012-10-30 23:45:18 +04:00
|
|
|
{ NULL,
|
2006-06-29 02:06:13 +04:00
|
|
|
'v', NULL, "verbose",
|
|
|
|
0,
|
|
|
|
&orte_ps_globals.verbose, OPAL_CMD_LINE_TYPE_BOOL,
|
|
|
|
"Be Verbose" },
|
|
|
|
|
2012-10-30 23:45:18 +04:00
|
|
|
{ NULL,
|
2011-07-24 00:20:31 +04:00
|
|
|
'\0', NULL, "parseable",
|
|
|
|
0,
|
|
|
|
&orte_ps_globals.parseable, OPAL_CMD_LINE_TYPE_BOOL,
|
|
|
|
"Provide parseable output" },
|
|
|
|
|
2012-10-30 23:45:18 +04:00
|
|
|
{ NULL,
|
2008-02-28 04:57:57 +03:00
|
|
|
'\0', NULL, "daemons",
|
2006-06-29 02:06:13 +04:00
|
|
|
0,
|
2008-02-28 04:57:57 +03:00
|
|
|
&orte_ps_globals.daemons, OPAL_CMD_LINE_TYPE_INT,
|
|
|
|
"Display daemon job information" },
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2012-10-30 23:45:18 +04:00
|
|
|
{ NULL,
|
2006-06-29 02:06:13 +04:00
|
|
|
'j', NULL, "jobid",
|
|
|
|
1,
|
|
|
|
&orte_ps_globals.jobid, OPAL_CMD_LINE_TYPE_INT,
|
2011-07-24 00:20:31 +04:00
|
|
|
"Specify a local jobid for the given mpirun - a value from 0 to N" },
|
|
|
|
|
2012-10-30 23:45:18 +04:00
|
|
|
{ NULL,
|
2011-07-24 00:20:31 +04:00
|
|
|
'p', NULL, "pid",
|
2006-06-29 02:06:13 +04:00
|
|
|
1,
|
2011-07-24 00:20:31 +04:00
|
|
|
&orte_ps_globals.pid, OPAL_CMD_LINE_TYPE_INT,
|
|
|
|
"Specify mpirun pid" },
|
2011-06-24 00:38:02 +04:00
|
|
|
|
2012-10-30 23:45:18 +04:00
|
|
|
{ NULL,
|
2006-07-03 21:11:02 +04:00
|
|
|
'n', NULL, "nodes",
|
|
|
|
0,
|
|
|
|
&orte_ps_globals.nodes, OPAL_CMD_LINE_TYPE_INT,
|
2008-02-28 04:57:57 +03:00
|
|
|
"Display Node Information" },
|
2006-07-03 21:11:02 +04:00
|
|
|
|
2006-06-29 02:06:13 +04:00
|
|
|
/* End of list */
|
2012-10-30 23:45:18 +04:00
|
|
|
{ NULL,
|
2006-06-29 02:06:13 +04:00
|
|
|
'\0', NULL, NULL,
|
|
|
|
0,
|
|
|
|
NULL, OPAL_CMD_LINE_TYPE_NULL,
|
|
|
|
NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
2006-06-30 18:22:58 +04:00
|
|
|
int ret, exit_status = ORTE_SUCCESS;
|
2008-02-28 04:57:57 +03:00
|
|
|
opal_list_t hnp_list;
|
2006-06-29 02:06:13 +04:00
|
|
|
opal_list_item_t* item = NULL;
|
2008-02-28 04:57:57 +03:00
|
|
|
orte_ps_mpirun_info_t hnpinfo;
|
2013-12-19 07:28:05 +04:00
|
|
|
bool reported = false;
|
|
|
|
|
2006-06-29 02:06:13 +04:00
|
|
|
/***************
|
|
|
|
* Initialize
|
|
|
|
***************/
|
2008-02-28 04:57:57 +03:00
|
|
|
OBJ_CONSTRUCT(&hnp_list, opal_list_t);
|
2006-07-17 23:21:10 +04:00
|
|
|
|
2007-03-17 02:11:45 +03:00
|
|
|
if (ORTE_SUCCESS != (ret = orte_ps_init(argc, argv))) {
|
2006-06-29 02:06:13 +04:00
|
|
|
exit_status = ret;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the directory listing
|
|
|
|
*/
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output_verbose(10, orte_ps_globals.output,
|
2008-12-10 20:10:39 +03:00
|
|
|
"orte_ps: Acquiring list of HNPs and setting contact info into RML...\n");
|
2007-03-17 02:11:45 +03:00
|
|
|
|
2008-12-10 20:10:39 +03:00
|
|
|
if (ORTE_SUCCESS != (ret = orte_list_local_hnps(&hnp_list, true) ) ) {
|
2006-06-29 02:06:13 +04:00
|
|
|
exit_status = ret;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-07-24 00:20:31 +04:00
|
|
|
opal_output_verbose(10, orte_ps_globals.output,
|
|
|
|
"orte_ps: Found %d HNPs\n",
|
|
|
|
(int)opal_list_get_size(&hnp_list));
|
|
|
|
|
2006-06-29 02:06:13 +04:00
|
|
|
/*
|
2008-02-28 04:57:57 +03:00
|
|
|
* For each hnp in the listing
|
2006-06-29 02:06:13 +04:00
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
while (NULL != (item = opal_list_remove_first(&hnp_list))) {
|
|
|
|
orte_hnp_contact_t *hnp = (orte_hnp_contact_t*)item;
|
|
|
|
hnpinfo.hnp = hnp;
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2011-07-24 00:20:31 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-06-29 02:06:13 +04:00
|
|
|
/*
|
|
|
|
* Gather the information
|
|
|
|
*/
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output_verbose(10, orte_ps_globals.output,
|
2008-02-28 04:57:57 +03:00
|
|
|
"orte_ps: Gathering Information for HNP: %s:%d\n",
|
2009-03-06 00:50:47 +03:00
|
|
|
ORTE_NAME_PRINT(&(hnpinfo.hnp->name)),
|
2008-02-28 04:57:57 +03:00
|
|
|
hnpinfo.hnp->pid);
|
|
|
|
|
|
|
|
if( ORTE_SUCCESS != (ret = gather_information(&hnpinfo)) ) {
|
2009-05-15 17:21:18 +04:00
|
|
|
/* this could be due to a stale session directory - if so,
|
|
|
|
* just skip this entry, but don't abort
|
|
|
|
*/
|
2013-12-19 07:28:05 +04:00
|
|
|
if (!reported && ORTE_ERR_SILENT == ret) {
|
2009-05-15 17:21:18 +04:00
|
|
|
orte_show_help("help-orte-ps.txt", "stale-hnp", true,
|
|
|
|
ORTE_NAME_PRINT(&(hnpinfo.hnp->name)));
|
2013-12-19 07:28:05 +04:00
|
|
|
reported = true;
|
2009-05-15 17:21:18 +04:00
|
|
|
continue;
|
|
|
|
}
|
2006-06-29 02:06:13 +04:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-07-24 00:20:31 +04:00
|
|
|
/* 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;
|
|
|
|
}
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************
|
|
|
|
* Cleanup
|
|
|
|
***************/
|
|
|
|
cleanup:
|
2008-02-28 04:57:57 +03:00
|
|
|
orte_finalize();
|
2006-06-29 02:06:13 +04:00
|
|
|
|
|
|
|
return exit_status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parse_args(int argc, char *argv[]) {
|
2008-02-28 04:57:57 +03:00
|
|
|
int ret;
|
2006-06-29 02:06:13 +04:00
|
|
|
opal_cmd_line_t cmd_line;
|
2009-05-15 17:21:18 +04:00
|
|
|
orte_ps_globals_t tmp = { false, /* help */
|
|
|
|
false, /* verbose */
|
2011-07-24 00:20:31 +04:00
|
|
|
false, /* parseable */
|
2009-05-15 17:21:18 +04:00
|
|
|
ORTE_JOBID_WILDCARD, /* jobid */
|
|
|
|
false, /* nodes */
|
|
|
|
false, /* daemons */
|
2011-07-24 00:20:31 +04:00
|
|
|
-1, /* output */
|
|
|
|
0}; /* pid */
|
2006-06-29 02:06:13 +04:00
|
|
|
|
|
|
|
orte_ps_globals = tmp;
|
2007-03-17 02:11:45 +03:00
|
|
|
|
|
|
|
/* Parse the command line options */
|
2006-06-29 02:06:13 +04:00
|
|
|
opal_cmd_line_create(&cmd_line, cmd_line_opts);
|
|
|
|
|
|
|
|
mca_base_open();
|
|
|
|
mca_base_cmd_line_setup(&cmd_line);
|
2012-02-29 21:52:38 +04:00
|
|
|
ret = opal_cmd_line_parse(&cmd_line, false, argc, argv);
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2012-02-29 21:52:38 +04:00
|
|
|
if (OPAL_SUCCESS != ret) {
|
|
|
|
if (OPAL_ERR_SILENT != ret) {
|
|
|
|
fprintf(stderr, "%s: command line error (%s)\n", argv[0],
|
|
|
|
opal_strerror(ret));
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-06-29 02:06:13 +04:00
|
|
|
/**
|
|
|
|
* Now start parsing our specific arguments
|
|
|
|
*/
|
2012-02-29 21:52:38 +04:00
|
|
|
if (orte_ps_globals.help) {
|
|
|
|
char *str, *args = NULL;
|
2006-06-29 02:06:13 +04:00
|
|
|
args = opal_cmd_line_get_usage_msg(&cmd_line);
|
2012-02-29 21:52:38 +04:00
|
|
|
str = opal_show_help_string("help-orte-ps.txt", "usage", true,
|
|
|
|
args);
|
|
|
|
if (NULL != str) {
|
|
|
|
printf("%s", str);
|
|
|
|
free(str);
|
|
|
|
}
|
2006-06-29 02:06:13 +04:00
|
|
|
free(args);
|
2012-02-29 21:52:38 +04:00
|
|
|
/* If we show the help message, that should be all we do */
|
|
|
|
exit(0);
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
|
|
|
|
2011-07-24 00:20:31 +04:00
|
|
|
/* if the jobid is given, then we need a pid */
|
|
|
|
if (ORTE_JOBID_WILDCARD != orte_ps_globals.jobid &&
|
|
|
|
0 == orte_ps_globals.pid) {
|
2012-02-29 21:52:38 +04:00
|
|
|
orte_show_help("help-orte-ps.txt", "need-vpid", true,
|
|
|
|
orte_ps_globals.jobid);
|
2011-07-24 00:20:31 +04:00
|
|
|
return ORTE_ERROR;
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
2011-07-24 00:20:31 +04:00
|
|
|
|
2006-06-29 02:06:13 +04:00
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-03-17 02:11:45 +03:00
|
|
|
static int orte_ps_init(int argc, char *argv[]) {
|
2008-02-28 04:57:57 +03:00
|
|
|
int ret;
|
2013-05-18 01:45:49 +04:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2008-04-23 04:17:12 +04:00
|
|
|
char * tmp_env_var = NULL;
|
2013-05-18 01:45:49 +04:00
|
|
|
#endif
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2007-04-22 02:38:15 +04:00
|
|
|
/*
|
|
|
|
* Make sure to init util before parse_args
|
|
|
|
* to ensure installdirs is setup properly
|
|
|
|
* before calling mca_base_open();
|
|
|
|
*/
|
2009-12-04 03:51:15 +03:00
|
|
|
if( ORTE_SUCCESS != (ret = opal_init_util(&argc, &argv)) ) {
|
2007-04-22 02:38:15 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-03-17 02:11:45 +03:00
|
|
|
/*
|
|
|
|
* Parse Command Line Arguments
|
|
|
|
*/
|
|
|
|
if (ORTE_SUCCESS != (ret = parse_args(argc, argv))) {
|
2008-02-28 04:57:57 +03:00
|
|
|
return ret;
|
2007-03-17 02:11:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup OPAL Output handle from the verbose argument
|
|
|
|
*/
|
|
|
|
if( orte_ps_globals.verbose ) {
|
2008-06-09 18:53:58 +04:00
|
|
|
orte_ps_globals.output = opal_output_open(NULL);
|
|
|
|
opal_output_set_verbosity(orte_ps_globals.output, 10);
|
2007-03-17 02:11:45 +03:00
|
|
|
} else {
|
This commit represents a bunch of work on a Mercurial side branch. As
such, the commit message back to the master SVN repository is fairly
long.
= ORTE Job-Level Output Messages =
Add two new interfaces that should be used for all new code throughout
the ORTE and OMPI layers (we already make the search-and-replace on
the existing ORTE / OMPI layers):
* orte_output(): (and corresponding friends ORTE_OUTPUT,
orte_output_verbose, etc.) This function sends the output directly
to the HNP for processing as part of a job-specific output
channel. It supports all the same outputs as opal_output()
(syslog, file, stdout, stderr), but for stdout/stderr, the output
is sent to the HNP for processing and output. More on this below.
* orte_show_help(): This function is a drop-in-replacement for
opal_show_help(), with two differences in functionality:
1. the rendered text help message output is sent to the HNP for
display (rather than outputting directly into the process' stderr
stream)
1. the HNP detects duplicate help messages and does not display them
(so that you don't see the same error message N times, once from
each of your N MPI processes); instead, it counts "new" instances
of the help message and displays a message every ~5 seconds when
there are new ones ("I got X new copies of the help message...")
opal_show_help and opal_output still exist, but they only output in
the current process. The intent for the new orte_* functions is that
they can apply job-level intelligence to the output. As such, we
recommend that all new ORTE and OMPI code use the new orte_*
functions, not thei opal_* functions.
=== New code ===
For ORTE and OMPI programmers, here's what you need to do differently
in new code:
* Do not include opal/util/show_help.h or opal/util/output.h.
Instead, include orte/util/output.h (this one header file has
declarations for both the orte_output() series of functions and
orte_show_help()).
* Effectively s/opal_output/orte_output/gi throughout your code.
Note that orte_output_open() takes a slightly different argument
list (as a way to pass data to the filtering stream -- see below),
so you if explicitly call opal_output_open(), you'll need to
slightly adapt to the new signature of orte_output_open().
* Literally s/opal_show_help/orte_show_help/. The function signature
is identical.
=== Notes ===
* orte_output'ing to stream 0 will do similar to what
opal_output'ing did, so leaving a hard-coded "0" as the first
argument is safe.
* For systems that do not use ORTE's RML or the HNP, the effect of
orte_output_* and orte_show_help will be identical to their opal
counterparts (the additional information passed to
orte_output_open() will be lost!). Indeed, the orte_* functions
simply become trivial wrappers to their opal_* counterparts. Note
that we have not tested this; the code is simple but it is quite
possible that we mucked something up.
= Filter Framework =
Messages sent view the new orte_* functions described above and
messages output via the IOF on the HNP will now optionally be passed
through a new "filter" framework before being output to
stdout/stderr. The "filter" OPAL MCA framework is intended to allow
preprocessing to messages before they are sent to their final
destinations. The first component that was written in the filter
framework was to create an XML stream, segregating all the messages
into different XML tags, etc. This will allow 3rd party tools to read
the stdout/stderr from the HNP and be able to know exactly what each
text message is (e.g., a help message, another OMPI infrastructure
message, stdout from the user process, stderr from the user process,
etc.).
Filtering is not active by default. Filter components must be
specifically requested, such as:
{{{
$ mpirun --mca filter xml ...
}}}
There can only be one filter component active.
= New MCA Parameters =
The new functionality described above introduces two new MCA
parameters:
* '''orte_base_help_aggregate''': Defaults to 1 (true), meaning that
help messages will be aggregated, as described above. If set to 0,
all help messages will be displayed, even if they are duplicates
(i.e., the original behavior).
* '''orte_base_show_output_recursions''': An MCA parameter to help
debug one of the known issues, described below. It is likely that
this MCA parameter will disappear before v1.3 final.
= Known Issues =
* The XML filter component is not complete. The current output from
this component is preliminary and not real XML. A bit more work
needs to be done to configure.m4 search for an appropriate XML
library/link it in/use it at run time.
* There are possible recursion loops in the orte_output() and
orte_show_help() functions -- e.g., if RML send calls orte_output()
or orte_show_help(). We have some ideas how to fix these, but
figured that it was ok to commit before feature freeze with known
issues. The code currently contains sub-optimal workarounds so
that this will not be a problem, but it would be good to actually
solve the problem rather than have hackish workarounds before v1.3 final.
This commit was SVN r18434.
2008-05-14 00:00:55 +04:00
|
|
|
orte_ps_globals.output = 0; /* Default=STDERR */
|
2007-03-17 02:11:45 +03:00
|
|
|
}
|
|
|
|
|
2010-03-13 02:57:50 +03:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2007-03-17 02:11:45 +03:00
|
|
|
/* Disable the checkpoint notification routine for this
|
|
|
|
* tool. As we will never need to checkpoint this tool.
|
|
|
|
* Note: This must happen before opal_init().
|
|
|
|
*/
|
|
|
|
opal_cr_set_enabled(false);
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2007-03-17 02:11:45 +03:00
|
|
|
/* Select the none component, since we don't actually use a checkpointer */
|
2013-03-28 01:09:41 +04:00
|
|
|
(void) mca_base_var_env_name("crs", &tmp_env_var);
|
2008-04-23 04:17:12 +04:00
|
|
|
opal_setenv(tmp_env_var,
|
2007-03-17 02:11:45 +03:00
|
|
|
"none",
|
|
|
|
true, &environ);
|
2008-04-23 04:17:12 +04:00
|
|
|
free(tmp_env_var);
|
|
|
|
tmp_env_var = NULL;
|
|
|
|
|
2013-03-28 01:09:41 +04:00
|
|
|
(void) mca_base_var_env_name("opal_cr_is_tool", &tmp_env_var);
|
2008-04-23 04:17:12 +04:00
|
|
|
opal_setenv(tmp_env_var,
|
2008-02-28 04:57:57 +03:00
|
|
|
"1",
|
|
|
|
true, &environ);
|
2008-04-23 04:17:12 +04:00
|
|
|
free(tmp_env_var);
|
2010-03-13 02:57:50 +03:00
|
|
|
#endif
|
2008-04-23 04:17:12 +04:00
|
|
|
|
2006-06-29 02:06:13 +04:00
|
|
|
/***************************
|
2008-02-28 04:57:57 +03:00
|
|
|
* We need all of OPAL and the TOOL portion of ORTE
|
2006-06-29 02:06:13 +04:00
|
|
|
***************************/
|
2009-12-04 03:51:15 +03:00
|
|
|
ret = orte_init(&argc, &argv, ORTE_PROC_TOOL);
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
return ret;
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
static int pretty_print(orte_ps_mpirun_info_t *hnpinfo) {
|
|
|
|
char *header;
|
2009-03-03 16:09:19 +03:00
|
|
|
int len_hdr;
|
2008-02-28 04:57:57 +03:00
|
|
|
|
2006-07-03 21:11:02 +04:00
|
|
|
/*
|
2009-03-03 16:09:19 +03:00
|
|
|
* Print header and remember header length
|
2006-07-03 21:11:02 +04:00
|
|
|
*/
|
2009-03-06 00:50:47 +03:00
|
|
|
len_hdr = asprintf(&header, "Information from mpirun %s", ORTE_JOBID_PRINT(hnpinfo->hnp->name.jobid));
|
2008-02-28 04:57:57 +03:00
|
|
|
|
2009-03-03 16:09:19 +03:00
|
|
|
printf("\n\n%s\n", header);
|
2009-03-03 15:33:43 +03:00
|
|
|
free(header);
|
2009-03-03 16:09:19 +03:00
|
|
|
pretty_print_dashed_line(len_hdr);
|
2008-02-28 04:57:57 +03:00
|
|
|
|
2006-07-03 21:11:02 +04:00
|
|
|
/*
|
|
|
|
* Print Node Information
|
|
|
|
*/
|
|
|
|
if( orte_ps_globals.nodes )
|
2008-02-28 04:57:57 +03:00
|
|
|
pretty_print_nodes(hnpinfo->nodes, hnpinfo->num_nodes);
|
2006-07-03 21:11:02 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Print Job Information
|
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
pretty_print_jobs(hnpinfo->jobs, hnpinfo->num_jobs);
|
2006-07-03 21:11:02 +04:00
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
static int pretty_print_nodes(orte_node_t **nodes, orte_std_cntr_t num_nodes) {
|
|
|
|
int line_len;
|
2006-07-03 21:11:02 +04:00
|
|
|
int len_name = 0,
|
|
|
|
len_state = 0,
|
|
|
|
len_slots = 0,
|
|
|
|
len_slots_i = 0,
|
|
|
|
len_slots_m = 0;
|
2008-02-28 04:57:57 +03:00
|
|
|
orte_node_t *node;
|
|
|
|
orte_std_cntr_t i;
|
2006-07-03 21:11:02 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Caculate segment lengths
|
|
|
|
*/
|
|
|
|
len_name = (int) strlen("Node Name");
|
|
|
|
len_state = (int) strlen("State");
|
|
|
|
len_slots = (int) strlen("Slots");
|
|
|
|
len_slots_i = (int) strlen("Slots In Use");
|
|
|
|
len_slots_m = (int) strlen("Slots Max");
|
2007-03-17 02:11:45 +03:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
for(i=0; i < num_nodes; i++) {
|
|
|
|
node = nodes[i];
|
2006-07-03 21:11:02 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
if( NULL != node->name &&
|
|
|
|
(int)strlen(node->name) > len_name)
|
|
|
|
len_name = (int) strlen(node->name);
|
2008-04-30 23:49:53 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
if( (int)strlen(pretty_node_state(node->state)) > len_state )
|
|
|
|
len_state = (int)strlen(pretty_node_state(node->state));
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
2008-02-28 04:57:57 +03:00
|
|
|
|
2006-07-03 21:11:02 +04:00
|
|
|
line_len = (len_name + 3 +
|
|
|
|
len_state + 3 +
|
|
|
|
len_slots + 3 +
|
|
|
|
len_slots_i + 3 +
|
2007-03-17 02:11:45 +03:00
|
|
|
len_slots_m) + 2;
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2006-07-03 21:11:02 +04:00
|
|
|
/*
|
|
|
|
* Print the header
|
|
|
|
*/
|
|
|
|
printf("%*s | ", len_name, "Node Name");
|
|
|
|
printf("%*s | ", len_state, "State");
|
|
|
|
printf("%*s | ", len_slots, "Slots");
|
|
|
|
printf("%*s | ", len_slots_m, "Slots Max");
|
|
|
|
printf("%*s | ", len_slots_i, "Slots In Use");
|
2006-06-29 02:06:13 +04:00
|
|
|
printf("\n");
|
|
|
|
|
2009-03-03 16:09:19 +03:00
|
|
|
pretty_print_dashed_line(line_len);
|
2006-07-03 21:11:02 +04:00
|
|
|
|
2006-06-29 02:06:13 +04:00
|
|
|
/*
|
2006-07-03 21:11:02 +04:00
|
|
|
* Print Info
|
2006-06-29 02:06:13 +04:00
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
for(i=0; i < num_nodes; i++) {
|
|
|
|
node = nodes[i];
|
|
|
|
|
|
|
|
printf("%*s | ", len_name, node->name);
|
|
|
|
printf("%*s | ", len_state, pretty_node_state(node->state));
|
|
|
|
printf("%*d | ", len_slots, (uint)node->slots);
|
|
|
|
printf("%*d | ", len_slots_m, (uint)node->slots_max);
|
|
|
|
printf("%*d | ", len_slots_i, (uint)node->slots_inuse);
|
2006-07-03 21:11:02 +04:00
|
|
|
printf("\n");
|
2008-02-28 04:57:57 +03:00
|
|
|
|
2006-07-03 21:11:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
static int pretty_print_jobs(orte_job_t **jobs, orte_std_cntr_t num_jobs) {
|
2006-07-03 21:11:02 +04:00
|
|
|
int len_jobid = 0,
|
|
|
|
len_state = 0,
|
|
|
|
len_slots = 0,
|
|
|
|
len_vpid_r = 0,
|
|
|
|
len_ckpt_s = 0,
|
|
|
|
len_ckpt_r = 0,
|
|
|
|
len_ckpt_l = 0;
|
2008-02-28 04:57:57 +03:00
|
|
|
int line_len;
|
|
|
|
orte_job_t *job;
|
2009-03-03 16:09:19 +03:00
|
|
|
orte_std_cntr_t i;
|
2008-02-28 04:57:57 +03:00
|
|
|
char *jobstr;
|
|
|
|
orte_jobid_t mask=0x0000ffff;
|
2013-05-18 01:45:49 +04:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2009-04-30 20:55:39 +04:00
|
|
|
char * state_str = NULL;
|
2013-05-18 01:45:49 +04:00
|
|
|
#endif
|
2006-07-03 21:11:02 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
for(i=0; i < num_jobs; i++) {
|
|
|
|
job = jobs[i];
|
|
|
|
|
|
|
|
/* check the jobid to see if this is the daemons' job */
|
|
|
|
if ((0 == (mask & job->jobid)) && !orte_ps_globals.daemons) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
/* setup the printed name - do -not- free this! */
|
2009-03-06 00:50:47 +03:00
|
|
|
jobstr = ORTE_JOBID_PRINT(job->jobid);
|
2008-02-28 04:57:57 +03:00
|
|
|
|
2006-07-03 21:11:02 +04:00
|
|
|
/*
|
|
|
|
* Caculate segment lengths
|
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
len_jobid = strlen(jobstr);;
|
2011-07-24 00:20:31 +04:00
|
|
|
len_state = (int) (strlen(orte_job_state_to_str(job->state)) < strlen("State") ?
|
2006-07-03 21:11:02 +04:00
|
|
|
strlen("State") :
|
2011-07-24 00:20:31 +04:00
|
|
|
strlen(orte_job_state_to_str(job->state)));
|
2006-07-03 21:11:02 +04:00
|
|
|
len_slots = 6;
|
2008-02-28 04:57:57 +03:00
|
|
|
len_vpid_r = (int) strlen("Num Procs");
|
2010-03-13 02:57:50 +03:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2009-04-30 20:55:39 +04:00
|
|
|
orte_snapc_ckpt_state_str(&state_str, job->ckpt_state);
|
|
|
|
len_ckpt_s = (int) (strlen(state_str) < strlen("Ckpt State") ?
|
2007-03-17 02:11:45 +03:00
|
|
|
strlen("Ckpt State") :
|
2009-04-30 20:55:39 +04:00
|
|
|
strlen(state_str) );
|
2008-02-28 04:57:57 +03:00
|
|
|
len_ckpt_r = (int) (NULL == job->ckpt_snapshot_ref ? strlen("Ckpt Ref") :
|
|
|
|
(strlen(job->ckpt_snapshot_ref) < strlen("Ckpt Ref") ?
|
2007-03-17 02:11:45 +03:00
|
|
|
strlen("Ckpt Ref") :
|
2008-02-28 04:57:57 +03:00
|
|
|
strlen(job->ckpt_snapshot_ref) ) );
|
|
|
|
len_ckpt_l = (int) (NULL == job->ckpt_snapshot_loc ? strlen("Ckpt Loc") :
|
|
|
|
(strlen(job->ckpt_snapshot_loc) < strlen("Ckpt Loc") ?
|
2007-03-17 02:11:45 +03:00
|
|
|
strlen("Ckpt Loc") :
|
2008-02-28 04:57:57 +03:00
|
|
|
strlen(job->ckpt_snapshot_loc) ) );
|
2007-03-17 02:11:45 +03:00
|
|
|
#else
|
|
|
|
len_ckpt_s = -3;
|
|
|
|
len_ckpt_r = -3;
|
2008-02-28 04:57:57 +03:00
|
|
|
len_ckpt_l = -3;
|
2007-03-17 02:11:45 +03:00
|
|
|
#endif
|
2008-02-28 04:57:57 +03:00
|
|
|
|
2006-07-03 21:11:02 +04:00
|
|
|
line_len = (len_jobid + 3 +
|
|
|
|
len_state + 3 +
|
|
|
|
len_slots + 3 +
|
|
|
|
len_vpid_r + 3 +
|
|
|
|
len_ckpt_s + 3 +
|
|
|
|
len_ckpt_r + 3 +
|
2007-03-17 02:11:45 +03:00
|
|
|
len_ckpt_l)
|
|
|
|
+ 2;
|
|
|
|
|
2006-07-03 21:11:02 +04:00
|
|
|
/*
|
|
|
|
* Print Header
|
|
|
|
*/
|
2006-06-29 02:06:13 +04:00
|
|
|
printf("\n");
|
2006-07-03 21:11:02 +04:00
|
|
|
printf("%*s | ", len_jobid , "JobID");
|
|
|
|
printf("%*s | ", len_state , "State");
|
|
|
|
printf("%*s | ", len_slots , "Slots");
|
2008-02-28 04:57:57 +03:00
|
|
|
printf("%*s | ", len_vpid_r , "Num Procs");
|
2010-03-13 02:57:50 +03:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2007-03-17 02:11:45 +03:00
|
|
|
printf("%*s | ", len_ckpt_s , "Ckpt State");
|
|
|
|
printf("%*s | ", len_ckpt_r , "Ckpt Ref");
|
|
|
|
printf("%*s |", len_ckpt_l , "Ckpt Loc");
|
|
|
|
#endif
|
2006-07-03 21:11:02 +04:00
|
|
|
printf("\n");
|
|
|
|
|
2009-03-03 16:09:19 +03:00
|
|
|
pretty_print_dashed_line(line_len);
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2006-07-03 21:11:02 +04:00
|
|
|
/*
|
|
|
|
* Print Info
|
2008-02-28 04:57:57 +03:00
|
|
|
*/
|
2009-03-06 00:50:47 +03:00
|
|
|
printf("%*s | ", len_jobid , ORTE_JOBID_PRINT(job->jobid));
|
2011-07-24 00:20:31 +04:00
|
|
|
printf("%*s | ", len_state , orte_job_state_to_str(job->state));
|
2008-02-28 04:57:57 +03:00
|
|
|
printf("%*d | ", len_slots , (uint)job->total_slots_alloc);
|
|
|
|
printf("%*d | ", len_vpid_r, job->num_procs);
|
2010-03-13 02:57:50 +03:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2009-04-30 20:55:39 +04:00
|
|
|
printf("%*s | ", len_ckpt_s, state_str);
|
2008-02-28 04:57:57 +03:00
|
|
|
printf("%*s | ", len_ckpt_r, (NULL == job->ckpt_snapshot_ref ?
|
2007-03-17 02:11:45 +03:00
|
|
|
"" :
|
2008-02-28 04:57:57 +03:00
|
|
|
job->ckpt_snapshot_ref) );
|
|
|
|
printf("%*s |", len_ckpt_l, (NULL == job->ckpt_snapshot_loc ?
|
2007-03-17 02:11:45 +03:00
|
|
|
"" :
|
2008-02-28 04:57:57 +03:00
|
|
|
job->ckpt_snapshot_loc) );
|
2007-03-17 02:11:45 +03:00
|
|
|
#endif
|
2006-06-29 02:06:13 +04:00
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
|
2006-07-03 21:11:02 +04:00
|
|
|
pretty_print_vpids(job);
|
2008-02-28 04:57:57 +03:00
|
|
|
printf("\n\n"); /* give a little room between job outputs */
|
2006-07-03 21:11:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
static int pretty_print_vpids(orte_job_t *job) {
|
2006-07-03 21:11:02 +04:00
|
|
|
int len_o_proc_name = 0,
|
|
|
|
len_proc_name = 0,
|
|
|
|
len_rank = 0,
|
|
|
|
len_pid = 0,
|
|
|
|
len_state = 0,
|
|
|
|
len_node = 0,
|
|
|
|
len_ckpt_s = 0,
|
|
|
|
len_ckpt_r = 0,
|
2012-04-06 18:23:13 +04:00
|
|
|
len_ckpt_l = 0;
|
2006-07-03 21:11:02 +04:00
|
|
|
int i, line_len;
|
2008-02-28 04:57:57 +03:00
|
|
|
orte_vpid_t v;
|
|
|
|
orte_proc_t *vpid;
|
|
|
|
orte_app_context_t *app;
|
|
|
|
char *o_proc_name;
|
2013-05-18 01:45:49 +04:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2009-04-30 20:55:39 +04:00
|
|
|
char *state_str = NULL;
|
2013-05-18 01:45:49 +04:00
|
|
|
#endif
|
2006-07-03 21:11:02 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Caculate segment lengths
|
|
|
|
*/
|
2006-08-23 06:35:00 +04:00
|
|
|
len_o_proc_name = (int)strlen("ORTE Name");
|
|
|
|
len_proc_name = (int)strlen("Process Name");
|
2008-02-28 04:57:57 +03:00
|
|
|
len_rank = (int)strlen("Local Rank");
|
2006-07-03 21:11:02 +04:00
|
|
|
len_pid = 6;
|
|
|
|
len_state = 0;
|
|
|
|
len_node = 0;
|
2010-03-13 02:57:50 +03:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2007-03-17 02:11:45 +03:00
|
|
|
len_ckpt_s = strlen("Ckpt State");
|
|
|
|
len_ckpt_r = strlen("Ckpt Ref");
|
|
|
|
len_ckpt_l = strlen("Ckpt Loc");
|
|
|
|
#else
|
|
|
|
len_ckpt_s = -3;
|
|
|
|
len_ckpt_r = -3;
|
2008-02-28 04:57:57 +03:00
|
|
|
len_ckpt_l = -3;
|
2007-03-17 02:11:45 +03:00
|
|
|
#endif
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
for(v=0; v < job->num_procs; v++) {
|
|
|
|
char *rankstr;
|
|
|
|
vpid = (orte_proc_t*)job->procs->addr[v];
|
2006-07-03 21:11:02 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Find my app context
|
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
if( 0 >= (int)job->num_apps ) {
|
|
|
|
if( 0 == vpid->name.vpid ) {
|
|
|
|
if( (int)strlen("orterun") > len_proc_name)
|
|
|
|
len_proc_name = strlen("orterun");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if( (int)strlen("orted") > len_proc_name)
|
|
|
|
len_proc_name = strlen("orted");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for( i = 0; i < (int)job->num_apps; ++i) {
|
|
|
|
app = (orte_app_context_t*)job->apps->addr[i];
|
|
|
|
if( app->idx == vpid->app_idx ) {
|
|
|
|
if( (int)strlen(app->app) > len_proc_name)
|
|
|
|
len_proc_name = strlen(app->app);
|
2006-07-03 21:11:02 +04:00
|
|
|
break;
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
2006-07-03 21:11:02 +04:00
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
o_proc_name = orte_util_print_name_args(&vpid->name);
|
|
|
|
if ((int)strlen(o_proc_name) > len_o_proc_name)
|
|
|
|
len_o_proc_name = strlen(o_proc_name);
|
|
|
|
|
|
|
|
asprintf(&rankstr, "%u", (uint)vpid->local_rank);
|
|
|
|
if ((int)strlen(rankstr) > len_rank)
|
|
|
|
len_rank = strlen(rankstr);
|
|
|
|
free(rankstr);
|
|
|
|
|
|
|
|
if( NULL != vpid->nodename && (int)strlen(vpid->nodename) > len_node) {
|
|
|
|
len_node = strlen(vpid->nodename);
|
|
|
|
} else if ((int)strlen("Unknown") > len_node) {
|
|
|
|
len_node = strlen("Unknown");
|
|
|
|
}
|
|
|
|
|
2011-07-24 00:20:31 +04:00
|
|
|
if( (int)strlen(orte_proc_state_to_str(vpid->state)) > len_state)
|
|
|
|
len_state = strlen(orte_proc_state_to_str(vpid->state));
|
2006-07-03 21:11:02 +04:00
|
|
|
|
2010-03-13 02:57:50 +03:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2009-04-30 20:55:39 +04:00
|
|
|
orte_snapc_ckpt_state_str(&state_str, vpid->ckpt_state);
|
|
|
|
if( (int)strlen(state_str) > len_ckpt_s)
|
|
|
|
len_ckpt_s = strlen(state_str);
|
2007-03-17 02:11:45 +03:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
if( NULL != vpid->ckpt_snapshot_ref &&
|
|
|
|
(int)strlen(vpid->ckpt_snapshot_ref) > len_ckpt_r)
|
|
|
|
len_ckpt_r = strlen(vpid->ckpt_snapshot_ref);
|
2007-03-17 02:11:45 +03:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
if( NULL != vpid->ckpt_snapshot_loc &&
|
|
|
|
(int)strlen(vpid->ckpt_snapshot_loc) > len_ckpt_l)
|
|
|
|
len_ckpt_l = strlen(vpid->ckpt_snapshot_loc);
|
2007-03-17 02:11:45 +03:00
|
|
|
#endif
|
2006-07-03 21:11:02 +04:00
|
|
|
}
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2006-07-03 21:11:02 +04:00
|
|
|
line_len = (len_o_proc_name + 3 +
|
|
|
|
len_proc_name + 3 +
|
|
|
|
len_rank + 3 +
|
|
|
|
len_pid + 3 +
|
|
|
|
len_state + 3 +
|
|
|
|
len_node + 3 +
|
|
|
|
len_ckpt_s + 3 +
|
|
|
|
len_ckpt_r + 3 +
|
2007-03-17 02:11:45 +03:00
|
|
|
len_ckpt_l)
|
|
|
|
+ 2;
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2006-07-03 21:11:02 +04:00
|
|
|
/*
|
|
|
|
* Print Header
|
|
|
|
*/
|
|
|
|
printf("\t");
|
|
|
|
printf("%*s | ", len_proc_name , "Process Name");
|
|
|
|
printf("%*s | ", len_o_proc_name , "ORTE Name");
|
2008-02-28 04:57:57 +03:00
|
|
|
printf("%*s | ", len_rank , "Local Rank");
|
2006-07-03 21:11:02 +04:00
|
|
|
printf("%*s | ", len_pid , "PID");
|
|
|
|
printf("%*s | ", len_node , "Node");
|
|
|
|
printf("%*s | ", len_state , "State");
|
2010-03-13 02:57:50 +03:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2007-03-17 02:11:45 +03:00
|
|
|
printf("%*s | ", len_ckpt_s , "Ckpt State");
|
|
|
|
printf("%*s | ", len_ckpt_r , "Ckpt Ref");
|
|
|
|
printf("%*s |", len_ckpt_l , "Ckpt Loc");
|
|
|
|
#endif
|
2006-07-03 21:11:02 +04:00
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
printf("\t");
|
2009-03-03 16:09:19 +03:00
|
|
|
pretty_print_dashed_line(line_len);
|
2006-07-03 21:11:02 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Print Info
|
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
for(v=0; v < job->num_procs; v++) {
|
|
|
|
vpid = (orte_proc_t*)job->procs->addr[v];
|
2006-07-03 21:11:02 +04:00
|
|
|
|
2006-06-29 02:06:13 +04:00
|
|
|
printf("\t");
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
if( 0 >= (int)job->num_apps ) {
|
|
|
|
if( 0 == vpid->name.vpid ) {
|
|
|
|
printf("%*s | ", len_proc_name, "orterun");
|
|
|
|
} else {
|
|
|
|
printf("%*s | ", len_proc_name, "orted");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for( i = 0; i < (int)job->num_apps; ++i) {
|
|
|
|
app = (orte_app_context_t*)job->apps->addr[i];
|
|
|
|
if( app->idx == vpid->app_idx ) {
|
|
|
|
printf("%*s | ", len_proc_name, app->app);
|
2006-07-03 21:11:02 +04:00
|
|
|
break;
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
2006-07-03 21:11:02 +04:00
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
o_proc_name = orte_util_print_name_args(&vpid->name);
|
|
|
|
|
|
|
|
printf("%*s | ", len_o_proc_name, o_proc_name);
|
|
|
|
printf("%*u | ", len_rank , (uint)vpid->local_rank);
|
2006-07-03 21:11:02 +04:00
|
|
|
printf("%*d | ", len_pid , vpid->pid);
|
2008-02-28 04:57:57 +03:00
|
|
|
printf("%*s | ", len_node , (NULL == vpid->nodename) ? "Unknown" : vpid->nodename);
|
2011-07-24 00:20:31 +04:00
|
|
|
printf("%*s | ", len_state , orte_proc_state_to_str(vpid->state));
|
2007-03-17 02:11:45 +03:00
|
|
|
|
2010-03-13 02:57:50 +03:00
|
|
|
#if OPAL_ENABLE_FT_CR == 1
|
2009-04-30 20:55:39 +04:00
|
|
|
printf("%*s | ", len_ckpt_s, state_str);
|
2008-02-28 04:57:57 +03:00
|
|
|
printf("%*s | ", len_ckpt_r, (NULL == vpid->ckpt_snapshot_ref ?
|
2007-03-17 02:11:45 +03:00
|
|
|
"" :
|
2008-02-28 04:57:57 +03:00
|
|
|
vpid->ckpt_snapshot_ref));
|
|
|
|
printf("%*s |", len_ckpt_l, (NULL == vpid->ckpt_snapshot_loc ?
|
2007-03-17 02:11:45 +03:00
|
|
|
"" :
|
2008-02-28 04:57:57 +03:00
|
|
|
vpid->ckpt_snapshot_loc));
|
2007-03-17 02:11:45 +03:00
|
|
|
#endif
|
2006-07-03 21:11:02 +04:00
|
|
|
printf("\n");
|
|
|
|
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
2006-07-03 21:11:02 +04:00
|
|
|
|
2006-06-29 02:06:13 +04:00
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-03-03 16:09:19 +03:00
|
|
|
static void pretty_print_dashed_line(int len) {
|
2009-03-06 16:27:38 +03:00
|
|
|
static const char dashes[9] = "--------";
|
2009-03-03 16:09:19 +03:00
|
|
|
|
|
|
|
while (len >= 8) {
|
|
|
|
printf("%8.8s", dashes);
|
|
|
|
len -= 8;
|
|
|
|
}
|
|
|
|
printf("%*.*s\n", len, len, dashes);
|
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
static int gather_information(orte_ps_mpirun_info_t *hnpinfo) {
|
|
|
|
int ret;
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
if( ORTE_SUCCESS != (ret = gather_active_jobs(hnpinfo) )) {
|
2006-06-29 02:06:13 +04:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
if( ORTE_SUCCESS != (ret = gather_nodes(hnpinfo) )) {
|
2006-06-29 02:06:13 +04:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
if( ORTE_SUCCESS != (ret = gather_vpid_info(hnpinfo) )) {
|
2006-06-29 02:06:13 +04:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
2008-02-28 04:57:57 +03:00
|
|
|
return ret;
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
static int gather_active_jobs(orte_ps_mpirun_info_t *hnpinfo) {
|
|
|
|
int ret;
|
2006-06-29 02:06:13 +04:00
|
|
|
|
2009-05-15 17:21:18 +04:00
|
|
|
if (ORTE_SUCCESS != (ret = orte_util_comm_query_job_info(&(hnpinfo->hnp->name), orte_ps_globals.jobid,
|
2008-02-28 04:57:57 +03:00
|
|
|
&hnpinfo->num_jobs, &hnpinfo->jobs))) {
|
|
|
|
ORTE_ERROR_LOG(ret);
|
2006-07-03 21:11:02 +04:00
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
return ret;
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
static int gather_nodes(orte_ps_mpirun_info_t *hnpinfo) {
|
|
|
|
int ret;
|
|
|
|
|
2008-04-30 23:49:53 +04:00
|
|
|
if (ORTE_SUCCESS != (ret = orte_util_comm_query_node_info(&(hnpinfo->hnp->name), NULL,
|
2008-02-28 04:57:57 +03:00
|
|
|
&hnpinfo->num_nodes, &hnpinfo->nodes))) {
|
|
|
|
ORTE_ERROR_LOG(ret);
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
2013-12-20 00:42:20 +04:00
|
|
|
opal_output(0, "RECEIVED %d NODES", hnpinfo->num_nodes);
|
2008-02-28 04:57:57 +03:00
|
|
|
return ret;
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
static int gather_vpid_info(orte_ps_mpirun_info_t *hnpinfo) {
|
|
|
|
int ret;
|
|
|
|
orte_std_cntr_t i;
|
|
|
|
int cnt;
|
|
|
|
orte_job_t *job;
|
|
|
|
orte_proc_t **procs;
|
2006-06-29 02:06:13 +04:00
|
|
|
|
|
|
|
/*
|
2008-02-28 04:57:57 +03:00
|
|
|
* For each Job in the HNP
|
2006-06-29 02:06:13 +04:00
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
for(i=0; i < hnpinfo->num_jobs; i++) {
|
|
|
|
job = hnpinfo->jobs[i];
|
2006-06-29 02:06:13 +04:00
|
|
|
|
|
|
|
/*
|
2008-02-28 04:57:57 +03:00
|
|
|
* Skip getting the vpid's for the HNP, unless asked to do so
|
|
|
|
* The HNP is always the first in the array
|
2006-06-29 02:06:13 +04:00
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
if( 0 == i && !orte_ps_globals.daemons) {
|
2006-06-29 02:06:13 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
/* query the HNP for info on the procs in this job */
|
2011-08-27 02:16:14 +04:00
|
|
|
if (ORTE_SUCCESS != (ret = orte_util_comm_query_proc_info(&(hnpinfo->hnp->name),
|
|
|
|
job->jobid,
|
|
|
|
ORTE_VPID_WILDCARD,
|
|
|
|
&cnt,
|
|
|
|
&procs))) {
|
2008-02-28 04:57:57 +03:00
|
|
|
ORTE_ERROR_LOG(ret);
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
2008-02-28 04:57:57 +03:00
|
|
|
job->procs->addr = (void**)procs;
|
|
|
|
job->procs->size = cnt;
|
|
|
|
job->num_procs = cnt;
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
return ORTE_SUCCESS;
|
2006-06-29 02:06:13 +04:00
|
|
|
}
|
|
|
|
|
2006-07-03 21:11:02 +04:00
|
|
|
static char *pretty_node_state(orte_node_state_t state) {
|
|
|
|
switch(state) {
|
|
|
|
case ORTE_NODE_STATE_DOWN:
|
|
|
|
return strdup("Down");
|
|
|
|
break;
|
|
|
|
case ORTE_NODE_STATE_UP:
|
|
|
|
return strdup("Up");
|
|
|
|
break;
|
|
|
|
case ORTE_NODE_STATE_REBOOT:
|
|
|
|
return strdup("Reboot");
|
|
|
|
break;
|
|
|
|
case ORTE_NODE_STATE_UNKNOWN:
|
|
|
|
default:
|
2007-03-17 02:11:45 +03:00
|
|
|
return strdup("Unknown");
|
2006-07-03 21:11:02 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-07-24 00:20:31 +04:00
|
|
|
|
|
|
|
static int parseable_print(orte_ps_mpirun_info_t *hnpinfo)
|
|
|
|
{
|
|
|
|
orte_job_t **jobs;
|
|
|
|
orte_node_t **nodes;
|
|
|
|
orte_proc_t *proc;
|
2011-07-24 02:23:24 +04:00
|
|
|
orte_app_context_t *app;
|
|
|
|
char *appname;
|
2011-07-24 00:20:31 +04:00
|
|
|
int i, j;
|
|
|
|
|
2011-07-26 00:44:08 +04:00
|
|
|
/* don't include the daemon job in the number of jobs reported */
|
2011-07-24 00:20:31 +04:00
|
|
|
printf("mpirun:%lu:num nodes:%d:num jobs:%d\n",
|
2011-07-26 00:44:08 +04:00
|
|
|
(unsigned long)hnpinfo->hnp->pid, hnpinfo->num_nodes, hnpinfo->num_jobs-1);
|
2011-07-24 00:20:31 +04:00
|
|
|
|
|
|
|
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;
|
2011-07-26 00:44:08 +04:00
|
|
|
/* skip job=0 as that's the daemon job */
|
|
|
|
for (i=1; i < hnpinfo->num_jobs; i++) {
|
2011-07-24 00:20:31 +04:00
|
|
|
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;
|
|
|
|
}
|
2011-07-24 02:23:24 +04:00
|
|
|
app = (orte_app_context_t*)opal_pointer_array_get_item(jobs[i]->apps, proc->app_idx);
|
|
|
|
if (NULL == app) {
|
|
|
|
appname = strdup("NULL");
|
2011-07-24 00:20:31 +04:00
|
|
|
} else {
|
2011-07-24 02:23:24 +04:00
|
|
|
appname = opal_basename(app->app);
|
2011-07-24 00:20:31 +04:00
|
|
|
}
|
2011-07-24 02:23:24 +04:00
|
|
|
printf("process:%s:rank:%s:pid:%lu:node:%s:state:%s\n",
|
|
|
|
appname, ORTE_VPID_PRINT(proc->name.vpid),
|
|
|
|
(unsigned long)proc->pid,
|
|
|
|
(NULL == proc->nodename) ? "unknown" : proc->nodename,
|
2011-07-24 00:20:31 +04:00
|
|
|
orte_proc_state_to_str(proc->state));
|
2011-07-24 02:23:24 +04:00
|
|
|
free(appname);
|
2011-07-24 00:20:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|