2007-07-20 21:36:11 +00:00
/*
2007-07-25 22:28:04 +00:00
* Copyright ( c ) 2004 - 2007 The Trustees of the University of Tennessee .
2007-07-20 21:36:11 +00:00
* All rights reserved .
* $ COPYRIGHT $
*
* Additional copyrights may follow
*
* $ HEADER $
*/
# include "ompi_config.h"
# include "opal/mca/mca.h"
# include "opal/mca/base/mca_base_param.h"
# include "vprotocol_pessimist.h"
static inline int mca_param_register_int ( const char * param_name , int default_value ) ;
2007-07-31 17:12:21 +00:00
static inline char * mca_param_register_string ( const char * param_name , char * default_value ) ;
2007-07-20 21:36:11 +00:00
static int mca_vprotocol_pessimist_component_open ( void ) ;
static int mca_vprotocol_pessimist_component_close ( void ) ;
2007-08-16 05:52:30 +00:00
static mca_vprotocol_base_module_t * mca_vprotocol_pessimist_component_init ( int * priority , bool , bool ) ;
2007-07-20 21:36:11 +00:00
static int mca_vprotocol_pessimist_component_finalize ( void ) ;
static int _priority ;
static int _free_list_num ;
static int _free_list_max ;
static int _free_list_inc ;
static int _sender_based_size ;
static int _event_buffer_size ;
static char * _mmap_file_name ;
2008-07-28 22:40:57 +00:00
mca_vprotocol_base_component_2_0_0_t mca_vprotocol_pessimist_component =
2007-07-20 21:36:11 +00:00
{
2007-07-31 17:12:21 +00:00
/* First, the mca_base_component_t struct containing meta
* information about the component itself */
{
2008-07-28 22:40:57 +00:00
MCA_VPROTOCOL_BASE_VERSION_2_0_0 ,
2007-07-31 17:12:21 +00:00
" pessimist " , /* MCA component name */
2008-07-22 21:10:51 +00:00
OMPI_MAJOR_VERSION , /* MCA component major version */
OMPI_MINOR_VERSION , /* MCA component minor version */
OMPI_RELEASE_VERSION , /* MCA component release version */
2007-07-31 17:12:21 +00:00
mca_vprotocol_pessimist_component_open , /* component open */
mca_vprotocol_pessimist_component_close /* component close */
} ,
{
2008-07-28 22:40:57 +00:00
/* component is not checkpointable */
MCA_BASE_METADATA_PARAM_NONE
2007-07-31 17:12:21 +00:00
} ,
mca_vprotocol_pessimist_component_init , /* component init */
mca_vprotocol_pessimist_component_finalize /* component finalize */
2007-07-20 21:36:11 +00:00
} ;
/** MCA level functions
*/
static int mca_vprotocol_pessimist_component_open ( void )
{
2007-09-12 20:47:17 +00:00
_priority = mca_param_register_int ( " priority " , 30 ) ;
2007-07-31 17:12:21 +00:00
_free_list_num = mca_param_register_int ( " free_list_num " , 16 ) ;
_free_list_max = mca_param_register_int ( " free_list_max " , - 1 ) ;
_free_list_inc = mca_param_register_int ( " free_list_inc " , 64 ) ;
2007-09-12 20:47:17 +00:00
_sender_based_size = mca_param_register_int ( " sender_based_chunk " , 256 * 1024 * 1024 ) ;
2007-07-31 17:12:21 +00:00
_event_buffer_size = mca_param_register_int ( " event_buffer_size " , 1024 ) ;
_mmap_file_name = mca_param_register_string ( " sender_based_file " , " vprotocol_pessimist-senderbased " ) ;
2007-08-16 05:52:30 +00:00
V_OUTPUT_VERBOSE ( 500 , " vprotocol_pessimist: component_open: read priority %d " , _priority ) ;
2007-07-20 21:36:11 +00:00
return OMPI_SUCCESS ;
}
static int mca_vprotocol_pessimist_component_close ( void )
{
2007-08-16 05:52:30 +00:00
V_OUTPUT_VERBOSE ( 500 , " vprotocol_pessimist: component_close " ) ;
2007-07-31 17:12:21 +00:00
return OMPI_SUCCESS ;
2007-07-20 21:36:11 +00:00
}
/** VPROTOCOL level functions (same as PML one)
*/
2007-08-16 05:52:30 +00:00
static mca_vprotocol_base_module_t * mca_vprotocol_pessimist_component_init ( int * priority ,
2007-07-20 21:36:11 +00:00
bool enable_progress_threads ,
bool enable_mpi_threads )
{
2007-07-31 17:12:21 +00:00
V_OUTPUT_VERBOSE ( 500 , " vprotocol_pessimist: component_init " ) ;
* priority = _priority ;
/* sanity check */
if ( enable_mpi_threads )
{
2008-06-09 14:53:58 +00:00
opal_output ( 0 , " vprotocol_pessimist: component_init: threads are enabled, and not supported by vprotocol pessimist fault tolerant layer, will not load " ) ;
2007-07-31 17:12:21 +00:00
return NULL ;
}
mca_vprotocol_pessimist . clock = 1 ;
mca_vprotocol_pessimist . replay = false ;
OBJ_CONSTRUCT ( & mca_vprotocol_pessimist . replay_events , opal_list_t ) ;
OBJ_CONSTRUCT ( & mca_vprotocol_pessimist . pending_events , opal_list_t ) ;
OBJ_CONSTRUCT ( & mca_vprotocol_pessimist . events_pool , ompi_free_list_t ) ;
2007-11-01 23:38:50 +00:00
ompi_free_list_init_new ( & mca_vprotocol_pessimist . events_pool ,
2007-07-31 17:12:21 +00:00
sizeof ( mca_vprotocol_pessimist_event_t ) ,
2010-07-06 14:33:36 +00:00
opal_cache_line_size ,
2007-07-31 17:12:21 +00:00
OBJ_CLASS ( mca_vprotocol_pessimist_event_t ) ,
2010-07-06 14:33:36 +00:00
0 , opal_cache_line_size ,
2007-07-31 17:12:21 +00:00
_free_list_num ,
_free_list_max ,
_free_list_inc ,
NULL ) ;
mca_vprotocol_pessimist . event_buffer_max_length =
_event_buffer_size / sizeof ( vprotocol_pessimist_mem_event_t ) ;
mca_vprotocol_pessimist . event_buffer_length = 0 ;
mca_vprotocol_pessimist . event_buffer =
( vprotocol_pessimist_mem_event_t * ) malloc ( _event_buffer_size ) ;
2008-10-01 18:42:43 +00:00
mca_vprotocol_pessimist . el_comm = MPI_COMM_NULL ;
2007-07-31 17:12:21 +00:00
return & mca_vprotocol_pessimist . super ;
2007-07-20 21:36:11 +00:00
}
static int mca_vprotocol_pessimist_component_finalize ( void )
{
2007-07-31 17:12:21 +00:00
V_OUTPUT_VERBOSE ( 500 , " vprotocol_pessimist_finalize " ) ;
free ( mca_vprotocol_pessimist . event_buffer ) ;
2007-09-20 21:57:21 +00:00
OBJ_DESTRUCT ( & mca_vprotocol_pessimist . replay_events ) ;
OBJ_DESTRUCT ( & mca_vprotocol_pessimist . pending_events ) ;
OBJ_DESTRUCT ( & mca_vprotocol_pessimist . events_pool ) ;
2007-07-31 17:12:21 +00:00
return OMPI_SUCCESS ;
2007-07-20 21:36:11 +00:00
}
2007-09-20 21:57:21 +00:00
int mca_vprotocol_pessimist_enable ( bool enable ) {
if ( enable ) {
2008-10-01 18:42:43 +00:00
int ret ;
2007-09-20 21:57:21 +00:00
if ( ( ret = vprotocol_pessimist_sender_based_init ( _mmap_file_name ,
2008-10-01 18:42:43 +00:00
_sender_based_size ) ) ! = OMPI_SUCCESS )
2007-09-20 21:57:21 +00:00
return ret ;
}
else {
vprotocol_pessimist_sender_based_finalize ( ) ;
2008-10-02 00:22:41 +00:00
vprotocol_pessimist_event_logger_disconnect ( mca_vprotocol_pessimist . el_comm ) ;
2007-09-20 21:57:21 +00:00
}
2007-09-21 03:24:08 +00:00
return OMPI_SUCCESS ;
2007-09-20 21:57:21 +00:00
}
2007-07-20 21:36:11 +00:00
static inline int mca_param_register_int ( const char * param_name ,
int default_value )
{
2007-07-31 17:12:21 +00:00
int id = mca_base_param_register_int ( " vprotocol " , " pessimist " , param_name , NULL , default_value ) ;
int param_value = default_value ;
mca_base_param_lookup_int ( id , & param_value ) ;
return param_value ;
2007-07-20 21:36:11 +00:00
}
2007-07-31 17:12:21 +00:00
static inline char * mca_param_register_string ( const char * param_name ,
char * default_value )
{
int id = mca_base_param_register_string ( " vprotocol " , " pessimist " , param_name , NULL , default_value ) ;
char * param_value = default_value ;
mca_base_param_lookup_string ( id , & param_value ) ;
return param_value ;
}