2007-01-09 03:19:52 +03:00
/*
2007-03-17 02:11:45 +03:00
* Copyright ( c ) 2004 - 2007 The Trustees of Indiana University and Indiana
2007-01-09 03:19:52 +03:00
* University Research and Technology
* Corporation . All rights reserved .
* Copyright ( c ) 2004 - 2006 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 .
2007-06-05 07:03:59 +04:00
* Copyright ( c ) 2007 Los Alamos National Security , LLC . All rights
* reserved .
2007-01-09 03:19:52 +03:00
* $ COPYRIGHT $
*
* Additional copyrights may follow
*
* $ HEADER $
*
* These symbols are in a file by themselves to provide nice linker
* semantics . Since linkers generally pull in symbols by object
* files , keeping these symbols as the only symbols in this file
* prevents utility programs such as " ompi_info " from having to import
* entire components just to query their version and parameters .
*/
# include "orte_config.h"
2008-02-28 04:57:57 +03:00
# include "orte/constants.h"
2007-01-09 03:19:52 +03:00
# include <stdlib.h>
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
# include <ctype.h>
# include "opal/util/argv.h"
# include "opal/util/path.h"
# include "opal/util/basename.h"
# include "opal/util/show_help.h"
2007-06-05 07:03:59 +04:00
# include "opal/util/opal_environ.h"
2007-01-09 03:19:52 +03:00
# include "opal/mca/base/mca_base_param.h"
# include "orte/mca/errmgr/errmgr.h"
# include "orte/mca/rml/rml.h"
2008-02-28 04:57:57 +03:00
# include "orte/mca/plm/plm.h"
# include "orte/mca/plm/base/plm_private.h"
# include "orte/mca/plm/process/plm_process.h"
2007-01-09 03:19:52 +03:00
/*
* Local function
*/
static char * * search ( const char * agent_list ) ;
/*
2008-02-28 04:57:57 +03:00
* Public string showing the plm ompi_process component version number
2007-01-09 03:19:52 +03:00
*/
2008-02-28 04:57:57 +03:00
const char * mca_plm_process_component_version_string =
" Open MPI process plm MCA component version " ORTE_VERSION ;
2007-01-09 03:19:52 +03:00
/*
* Instantiate the public struct with all of our public information
* and pointers to our public functions in it
*/
2008-02-28 04:57:57 +03:00
orte_plm_process_component_t mca_plm_process_component = {
2007-01-09 03:19:52 +03:00
{
/* First, the mca_component_t struct containing meta information
about the component itself */
{
2008-02-28 04:57:57 +03:00
/* Indicate that we are a plm v1.0.0 component (which also
2007-01-09 03:19:52 +03:00
implies a specific MCA version ) */
2008-02-28 04:57:57 +03:00
ORTE_PLM_BASE_VERSION_1_0_0 ,
2007-01-09 03:19:52 +03:00
/* Component name and version */
" process " ,
ORTE_MAJOR_VERSION ,
ORTE_MINOR_VERSION ,
ORTE_RELEASE_VERSION ,
/* Component open and close functions */
2008-02-28 04:57:57 +03:00
orte_plm_process_component_open ,
orte_plm_process_component_close
2007-01-09 03:19:52 +03:00
} ,
/* Next the MCA v1.0.0 component meta data */
{
2007-03-17 02:11:45 +03:00
/* This component is not checkpointable */
MCA_BASE_METADATA_PARAM_NONE
2007-01-09 03:19:52 +03:00
} ,
/* Initialization / querying functions */
2008-02-28 04:57:57 +03:00
orte_plm_process_component_init
2007-01-09 03:19:52 +03:00
}
} ;
2008-02-28 04:57:57 +03:00
int orte_plm_process_component_open ( void )
2007-01-09 03:19:52 +03:00
{
int tmp , value ;
2008-02-28 04:57:57 +03:00
mca_base_component_t * c = & mca_plm_process_component . super . plm_version ;
2007-01-09 03:19:52 +03:00
/* initialize globals */
2008-02-28 04:57:57 +03:00
OBJ_CONSTRUCT ( & mca_plm_process_component . lock , opal_mutex_t ) ;
OBJ_CONSTRUCT ( & mca_plm_process_component . cond , opal_condition_t ) ;
mca_plm_process_component . num_children = 0 ;
2007-01-09 03:19:52 +03:00
/* lookup parameters */
mca_base_param_reg_int ( c , " num_concurrent " ,
2008-02-28 04:57:57 +03:00
" How many plm_process_agent instances to invoke concurrently (must be > 0) " ,
2007-01-09 03:19:52 +03:00
false , false , 128 , & tmp ) ;
if ( tmp < = 0 ) {
2008-02-28 04:57:57 +03:00
opal_show_help ( " help-plm-process.txt " , " concurrency-less-than-zero " ,
2007-01-09 03:19:52 +03:00
true , tmp ) ;
tmp = 1 ;
}
2008-02-28 04:57:57 +03:00
mca_plm_process_component . num_concurrent = tmp ;
2007-01-09 03:19:52 +03:00
mca_base_param_reg_int ( c , " force_process " ,
" Force the launcher to always use process, even for local daemons " ,
false , false , false , & tmp ) ;
2008-02-28 04:57:57 +03:00
mca_plm_process_component . force_process = OPAL_INT_TO_BOOL ( tmp ) ;
2007-01-09 03:19:52 +03:00
tmp = mca_base_param_reg_int_name ( " orte " , " timing " ,
" Request that critical timing loops be measured " ,
false , false , 0 , & value ) ;
if ( value ! = 0 ) {
2008-02-28 04:57:57 +03:00
mca_plm_process_component . timing = true ;
2007-01-09 03:19:52 +03:00
} else {
2008-02-28 04:57:57 +03:00
mca_plm_process_component . timing = false ;
2007-01-09 03:19:52 +03:00
}
mca_base_param_reg_string ( c , " orted " ,
2008-02-28 04:57:57 +03:00
" The command name that the process plm component will invoke for the ORTE daemon " ,
2007-01-25 03:17:54 +03:00
false , false , " orted.exe " ,
2008-02-28 04:57:57 +03:00
& mca_plm_process_component . orted ) ;
2007-01-09 03:19:52 +03:00
mca_base_param_reg_int ( c , " priority " ,
2008-02-28 04:57:57 +03:00
" Priority of the process plm component " ,
2007-01-09 03:19:52 +03:00
false , false , 10 ,
2008-02-28 04:57:57 +03:00
& mca_plm_process_component . priority ) ;
2007-01-09 03:19:52 +03:00
mca_base_param_reg_int ( c , " delay " ,
" Delay (in seconds) between invocations of the remote agent, but only used when the \" debug \" MCA parameter is true, or the top-level MCA debugging is enabled (otherwise this value is ignored) " ,
false , false , 1 ,
2008-02-28 04:57:57 +03:00
& mca_plm_process_component . delay ) ;
2007-01-09 03:19:52 +03:00
mca_base_param_reg_int ( c , " reap " ,
" If set to 1, wait for all the processes to complete before exiting. Otherwise, quit immediately -- without waiting for confirmation that all other processes in the job have completed. " ,
false , false , 1 , & tmp ) ;
2008-02-28 04:57:57 +03:00
mca_plm_process_component . reap = OPAL_INT_TO_BOOL ( tmp ) ;
2007-01-09 03:19:52 +03:00
mca_base_param_reg_int ( c , " assume_same_shell " ,
" If set to 1, assume that the shell on the remote node is the same as the shell on the local node. Otherwise, probe for what the remote shell. " ,
false , false , 1 , & tmp ) ;
2008-02-28 04:57:57 +03:00
mca_plm_process_component . assume_same_shell = OPAL_INT_TO_BOOL ( tmp ) ;
2007-01-09 03:19:52 +03:00
return ORTE_SUCCESS ;
}
2008-02-28 04:57:57 +03:00
orte_plm_base_module_t * orte_plm_process_component_init ( int * priority )
2007-01-09 03:19:52 +03:00
{
2008-02-28 04:57:57 +03:00
* priority = mca_plm_process_component . priority ;
2007-01-09 03:19:52 +03:00
2008-02-28 04:57:57 +03:00
return & orte_plm_process_module ;
2007-01-09 03:19:52 +03:00
}
2008-02-28 04:57:57 +03:00
int orte_plm_process_component_close ( void )
2007-01-09 03:19:52 +03:00
{
/* cleanup state */
2008-02-28 04:57:57 +03:00
OBJ_DESTRUCT ( & mca_plm_process_component . lock ) ;
OBJ_DESTRUCT ( & mca_plm_process_component . cond ) ;
if ( NULL ! = mca_plm_process_component . orted ) {
free ( mca_plm_process_component . orted ) ;
2007-01-09 03:19:52 +03:00
}
return ORTE_SUCCESS ;
}
/*
* Take a colon - delimited list of agents and locate the first one that
* we are able to find in the PATH . Split that one into argv and
* return it . If nothing found , then return NULL .
*/
static char * * search ( const char * agent_list )
{
int i , j ;
char * line , * * lines = opal_argv_split ( agent_list , ' : ' ) ;
char * * tokens , * tmp ;
char cwd [ PATH_MAX ] ;
getcwd ( cwd , PATH_MAX ) ;
for ( i = 0 ; NULL ! = lines [ i ] ; + + i ) {
line = lines [ i ] ;
/* Trim whitespace at the beginning and end of the line */
for ( j = 0 ; ' \0 ' ! = line [ j ] & & isspace ( line [ j ] ) ; + + line ) {
continue ;
}
2007-01-24 03:52:08 +03:00
for ( j = ( int ) strlen ( line ) - 2 ; j > 0 & & isspace ( line [ j ] ) ; + + j ) {
2007-01-09 03:19:52 +03:00
line [ j ] = ' \0 ' ;
}
if ( strlen ( line ) < = 0 ) {
continue ;
}
/* Split it */
tokens = opal_argv_split ( line , ' ' ) ;
/* Look for the first token in the PATH */
tmp = opal_path_findv ( tokens [ 0 ] , X_OK , environ , cwd ) ;
if ( NULL ! = tmp ) {
free ( tokens [ 0 ] ) ;
tokens [ 0 ] = tmp ;
opal_argv_free ( lines ) ;
return tokens ;
}
/* Didn't find it */
opal_argv_free ( tokens ) ;
}
/* Doh -- didn't find anything */
opal_argv_free ( lines ) ;
return NULL ;
}