2005-03-14 20:57:21 +00:00
/*
2005-11-05 19:57:48 +00: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 .
2005-03-14 20:57:21 +00:00
* Copyright ( c ) 2004 - 2005 High Performance Computing Center Stuttgart ,
* University of Stuttgart . All rights reserved .
2005-03-24 12:43:37 +00:00
* Copyright ( c ) 2004 - 2005 The Regents of the University of California .
* All rights reserved .
2006-07-04 20:12:35 +00:00
* Copyright ( c ) 2006 Cisco Systems , Inc . All rights reserved .
2005-03-14 20:57:21 +00:00
* $ COPYRIGHT $
*
* Additional copyrights may follow
*
* $ HEADER $
*/
# include "orte_config.h"
2006-02-12 01:33:29 +00:00
# include "orte/orte_constants.h"
2005-03-14 20:57:21 +00:00
2006-02-12 01:33:29 +00:00
# include "opal/mca/mca.h"
# include "opal/mca/base/base.h"
# include "opal/mca/base/mca_base_param.h"
2005-07-03 23:31:27 +00:00
# include "opal/util/output.h"
2005-03-14 20:57:21 +00:00
2006-02-12 01:33:29 +00:00
# include "orte/mca/rmaps/base/base.h"
2005-03-14 20:57:21 +00:00
/*
* The following file was created by configure . It contains extern
* statements and the definition of an array of pointers to each
* component ' s public mca_base_component_t struct .
*/
2005-07-04 18:24:58 +00:00
# include "orte/mca/rmaps/base/static-components.h"
2005-03-14 20:57:21 +00:00
/*
* Local functions
*/
static void cmp_constructor ( orte_rmaps_base_cmp_t * cmp ) ;
static void cmp_destructor ( orte_rmaps_base_cmp_t * cmp ) ;
2005-07-03 16:22:16 +00:00
static int compare ( opal_list_item_t * * a , opal_list_item_t * * b ) ;
2005-03-14 20:57:21 +00:00
/*
* Global variables
*/
orte_rmaps_base_t orte_rmaps_base ;
2005-07-03 16:22:16 +00:00
OBJ_CLASS_INSTANCE ( orte_rmaps_base_cmp_t , opal_list_item_t ,
2005-03-14 20:57:21 +00:00
cmp_constructor , cmp_destructor ) ;
/**
* Function for finding and opening either all MCA components , or the one
* that was specifically requested via a MCA parameter .
*/
int orte_rmaps_base_open ( void )
{
2005-07-03 16:22:16 +00:00
opal_list_item_t * item ;
2005-03-14 20:57:21 +00:00
mca_base_component_list_item_t * cli ;
orte_rmaps_base_component_t * component ;
orte_rmaps_base_module_t * module ;
int param , priority , value ;
orte_rmaps_base_cmp_t * cmp ;
2005-10-07 22:24:52 +00:00
char * policy ;
2005-03-14 20:57:21 +00:00
/* Debugging / verbose output */
2006-07-04 20:12:35 +00:00
param = mca_base_param_reg_int_name ( " rmaps " , " base_verbose " ,
2005-08-15 18:25:35 +00:00
" Verbosity level for the rmaps framework " ,
false , false , 0 , & value ) ;
2005-03-14 20:57:21 +00:00
if ( value ! = 0 ) {
2005-07-03 23:31:27 +00:00
orte_rmaps_base . rmaps_output = opal_output_open ( NULL ) ;
2005-03-14 20:57:21 +00:00
} else {
orte_rmaps_base . rmaps_output = - 1 ;
}
2005-10-07 22:24:52 +00:00
/* Are we scheduling by node or by slot? */
2006-07-04 20:12:35 +00:00
param = mca_base_param_reg_string_name ( " rmaps " , " base_schedule_policy " ,
2005-10-07 22:24:52 +00:00
" Scheduling Policy for RMAPS. [slot | node] " ,
false , false , " slot " , & policy ) ;
if ( 0 = = strcmp ( policy , " node " ) ) {
mca_base_param_set_string ( param , " node " ) ;
}
2006-07-04 20:12:35 +00:00
/* Should we schedule on the local node or not? */
mca_base_param_reg_int_name ( " rmaps " , " base_schedule_local " ,
" If nonzero, allow scheduling MPI applications on the same node as mpirun (default). If zero, do not schedule any MPI applications on the same node as mpirun " ,
false , false , 1 , & value ) ;
2006-07-10 14:10:21 +00:00
/* Should we oversubscribe or not? */
mca_base_param_reg_int_name ( " rmaps " , " base_no_oversubscribe " ,
" If nonzero, then do not allow oversubscription of nodes - mpirun will return an error if there aren't enough nodes to launch all processes without oversubscribing " ,
false , false , 0 , & value ) ;
2006-07-10 21:25:33 +00:00
if ( ( int ) false = = value ) {
orte_rmaps_base . oversubscribe = true ; /** default condition that allows oversubscription */
2006-07-10 14:10:21 +00:00
} else {
orte_rmaps_base . oversubscribe = false ;
}
2005-03-14 20:57:21 +00:00
/* Open up all the components that we can find */
if ( ORTE_SUCCESS ! =
2005-08-15 18:25:35 +00:00
mca_base_components_open ( " rmaps " , orte_rmaps_base . rmaps_output ,
mca_rmaps_base_static_components ,
2005-04-13 03:19:48 +00:00
& orte_rmaps_base . rmaps_opened , true ) ) {
2005-03-14 20:57:21 +00:00
return ORTE_ERROR ;
}
/* Query all the opened components and see if they want to run */
2005-07-03 16:22:16 +00:00
OBJ_CONSTRUCT ( & orte_rmaps_base . rmaps_available , opal_list_t ) ;
for ( item = opal_list_get_first ( & orte_rmaps_base . rmaps_opened ) ;
opal_list_get_end ( & orte_rmaps_base . rmaps_opened ) ! = item ;
item = opal_list_get_next ( item ) ) {
2005-03-14 20:57:21 +00:00
cli = ( mca_base_component_list_item_t * ) item ;
component = ( orte_rmaps_base_component_t * ) cli - > cli_component ;
2005-07-03 23:31:27 +00:00
opal_output ( orte_rmaps_base . rmaps_output ,
2005-03-14 20:57:21 +00:00
" orte:base:open: querying component %s " ,
component - > rmaps_version . mca_component_name ) ;
/* Call the component's init function and see if it wants to be
selected */
module = component - > rmaps_init ( & priority ) ;
/* If we got a non-NULL module back, then the component wants
to be considered for selection */
if ( NULL ! = module ) {
2005-07-03 23:31:27 +00:00
opal_output ( orte_rmaps_base . rmaps_output ,
2005-03-14 20:57:21 +00:00
" orte:base:open: component %s returns priority %d " ,
component - > rmaps_version . mca_component_name ,
priority ) ;
cmp = OBJ_NEW ( orte_rmaps_base_cmp_t ) ;
cmp - > component = component ;
cmp - > module = module ;
cmp - > priority = priority ;
2005-07-03 16:22:16 +00:00
opal_list_append ( & orte_rmaps_base . rmaps_available , & cmp - > super ) ;
2005-03-14 20:57:21 +00:00
} else {
2005-07-03 23:31:27 +00:00
opal_output ( orte_rmaps_base . rmaps_output ,
2005-03-14 20:57:21 +00:00
" orte:base:open: component %s does NOT want to be considered for selection " ,
component - > rmaps_version . mca_component_name ) ;
}
}
/* Sort the resulting available list in priority order */
2005-07-03 16:22:16 +00:00
opal_list_sort ( & orte_rmaps_base . rmaps_available , compare ) ;
2005-03-14 20:57:21 +00:00
/* All done */
return ORTE_SUCCESS ;
}
static void cmp_constructor ( orte_rmaps_base_cmp_t * cmp )
{
cmp - > component = NULL ;
cmp - > module = NULL ;
cmp - > priority = - 1 ;
}
static void cmp_destructor ( orte_rmaps_base_cmp_t * cmp )
{
cmp_constructor ( cmp ) ;
}
2005-07-03 16:22:16 +00:00
static int compare ( opal_list_item_t * * a , opal_list_item_t * * b )
2005-03-14 20:57:21 +00:00
{
orte_rmaps_base_cmp_t * aa = * ( ( orte_rmaps_base_cmp_t * * ) a ) ;
orte_rmaps_base_cmp_t * bb = * ( ( orte_rmaps_base_cmp_t * * ) b ) ;
if ( aa - > priority > bb - > priority ) {
return 1 ;
} else if ( aa - > priority = = bb - > priority ) {
return 0 ;
} else {
return - 1 ;
}
}