2005-05-19 17:33:55 +04:00
|
|
|
/*
|
2007-03-17 02:11:45 +03:00
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
2005-11-05 22:57:48 +03:00
|
|
|
* 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-09-07 22:52:28 +04:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2005-05-19 17:33:55 +04:00
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2007-04-21 04:15:05 +04:00
|
|
|
* Copyright (c) 2007 Cisco, Inc. All rights reserved.
|
2007-11-03 05:40:22 +03:00
|
|
|
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
2005-05-19 17:33:55 +04:00
|
|
|
* $COPYRIGHT$
|
2005-09-07 22:52:28 +04:00
|
|
|
*
|
2005-05-19 17:33:55 +04:00
|
|
|
* Additional copyrights may follow
|
2005-09-07 22:52:28 +04:00
|
|
|
*
|
2005-05-19 17:33:55 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file **/
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal_config.h"
|
2005-05-22 22:40:03 +04:00
|
|
|
|
2005-07-04 05:36:20 +04:00
|
|
|
#include "opal/util/malloc.h"
|
2005-07-04 03:31:27 +04:00
|
|
|
#include "opal/util/output.h"
|
2005-09-07 22:52:28 +04:00
|
|
|
#include "opal/util/trace.h"
|
2005-10-05 17:56:35 +04:00
|
|
|
#include "opal/util/show_help.h"
|
2005-11-11 03:26:27 +03:00
|
|
|
#include "opal/memoryhooks/memory.h"
|
2005-08-13 00:46:25 +04:00
|
|
|
#include "opal/mca/base/base.h"
|
|
|
|
#include "opal/runtime/opal.h"
|
2007-07-19 00:25:01 +04:00
|
|
|
#include "opal/util/net.h"
|
2007-04-21 04:15:05 +04:00
|
|
|
#include "opal/mca/installdirs/base/base.h"
|
2005-08-14 21:23:34 +04:00
|
|
|
#include "opal/mca/memory/base/base.h"
|
2006-04-05 09:57:51 +04:00
|
|
|
#include "opal/mca/memcpy/base/base.h"
|
2005-08-16 20:15:53 +04:00
|
|
|
#include "opal/mca/paffinity/base/base.h"
|
2005-08-18 09:34:22 +04:00
|
|
|
#include "opal/mca/timer/base/base.h"
|
2008-02-12 11:46:27 +03:00
|
|
|
#include "opal/mca/memchecker/base/base.h"
|
2007-03-17 02:11:45 +03:00
|
|
|
|
|
|
|
#include "opal/runtime/opal_cr.h"
|
|
|
|
#include "opal/mca/crs/base/base.h"
|
|
|
|
|
|
|
|
#include "opal/runtime/opal_progress.h"
|
|
|
|
#include "opal/event/event.h"
|
2006-09-26 03:41:06 +04:00
|
|
|
#include "opal/mca/backtrace/base/base.h"
|
2007-03-17 02:11:45 +03:00
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal/constants.h"
|
2005-08-22 07:05:39 +04:00
|
|
|
#include "opal/util/error.h"
|
2006-01-11 07:36:39 +03:00
|
|
|
#include "opal/util/stacktrace.h"
|
2006-01-16 04:48:03 +03:00
|
|
|
#include "opal/util/keyval_parse.h"
|
2007-04-23 22:53:47 +04:00
|
|
|
#include "opal/util/sys_limits.h"
|
2005-09-07 22:52:28 +04:00
|
|
|
|
2007-11-03 05:40:22 +03:00
|
|
|
#if OMPI_CC_USE_PRAGMA_IDENT
|
|
|
|
#pragma ident OPAL_IDENT_STRING
|
|
|
|
#elif OMPI_CC_USE_IDENT
|
|
|
|
#ident OPAL_IDENT_STRING
|
|
|
|
#else
|
|
|
|
static const char ident[] = OPAL_IDENT_STRING;
|
|
|
|
#endif
|
2007-03-17 02:11:45 +03:00
|
|
|
|
2006-08-22 00:07:38 +04:00
|
|
|
int opal_initialized = 0;
|
2007-07-19 00:28:19 +04:00
|
|
|
int opal_util_initialized = 0;
|
2006-08-22 00:07:38 +04:00
|
|
|
|
2005-08-22 07:05:39 +04:00
|
|
|
static const char *
|
|
|
|
opal_err2str(int errnum)
|
|
|
|
{
|
|
|
|
const char *retval;
|
|
|
|
|
|
|
|
switch (errnum) {
|
|
|
|
case OPAL_SUCCESS:
|
|
|
|
retval = "Success";
|
|
|
|
break;
|
|
|
|
case OPAL_ERROR:
|
|
|
|
retval = "Error";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_OUT_OF_RESOURCE:
|
|
|
|
retval = "Out of resource";
|
|
|
|
break;
|
2005-12-21 09:27:34 +03:00
|
|
|
case OPAL_ERR_TEMP_OUT_OF_RESOURCE:
|
|
|
|
retval = "Temporarily out of resource";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_RESOURCE_BUSY:
|
|
|
|
retval = "Resource busy";
|
2005-08-22 07:05:39 +04:00
|
|
|
break;
|
|
|
|
case OPAL_ERR_BAD_PARAM:
|
|
|
|
retval = "Bad parameter";
|
|
|
|
break;
|
2005-12-21 09:27:34 +03:00
|
|
|
case OPAL_ERR_FATAL:
|
|
|
|
retval = "Fatal";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_NOT_IMPLEMENTED:
|
|
|
|
retval = "Not implemented";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_NOT_SUPPORTED:
|
|
|
|
retval = "Not supported";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_INTERUPTED:
|
|
|
|
retval = "Interupted";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_WOULD_BLOCK:
|
|
|
|
retval = "Would block";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_IN_ERRNO:
|
|
|
|
retval = "In errno";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_UNREACH:
|
|
|
|
retval = "Unreachable";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_NOT_FOUND:
|
|
|
|
retval = "Not found";
|
|
|
|
break;
|
|
|
|
case OPAL_EXISTS:
|
|
|
|
retval = "Exists";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_TIMEOUT:
|
|
|
|
retval = "Timeout";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_NOT_AVAILABLE:
|
|
|
|
retval = "Not available";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_PERM:
|
|
|
|
retval = "No permission";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_VALUE_OUT_OF_BOUNDS:
|
|
|
|
retval = "Value out of bounds";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_FILE_READ_FAILURE:
|
|
|
|
retval = "File read failure";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_FILE_WRITE_FAILURE:
|
|
|
|
retval = "File write failure";
|
|
|
|
break;
|
|
|
|
case OPAL_ERR_FILE_OPEN_FAILURE:
|
|
|
|
retval = "File open failure";
|
|
|
|
break;
|
2005-09-07 22:52:28 +04:00
|
|
|
default:
|
2005-08-22 07:05:39 +04:00
|
|
|
retval = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
2005-08-18 09:34:22 +04:00
|
|
|
|
2005-05-19 17:33:55 +04:00
|
|
|
|
2006-01-16 04:48:03 +03:00
|
|
|
int
|
|
|
|
opal_init_util(void)
|
2005-05-22 22:40:03 +04:00
|
|
|
{
|
2005-10-05 17:56:35 +04:00
|
|
|
int ret;
|
|
|
|
char *error = NULL;
|
|
|
|
|
2007-07-19 00:28:19 +04:00
|
|
|
if( ++opal_util_initialized != 1 ) {
|
|
|
|
if( opal_util_initialized < 1 ) {
|
|
|
|
return OPAL_ERROR;
|
|
|
|
}
|
|
|
|
return OPAL_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-05-22 22:40:03 +04:00
|
|
|
/* initialize the memory allocator */
|
2005-07-04 05:36:20 +04:00
|
|
|
opal_malloc_init();
|
2005-05-22 22:40:03 +04:00
|
|
|
|
|
|
|
/* initialize the output system */
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output_init();
|
2005-08-22 07:05:39 +04:00
|
|
|
|
|
|
|
/* register handler for errnum -> string converstion */
|
2007-08-04 04:44:23 +04:00
|
|
|
if (OPAL_SUCCESS !=
|
|
|
|
(ret = opal_error_register("OPAL",
|
|
|
|
OPAL_ERR_BASE, OPAL_ERR_MAX, opal_err2str))) {
|
2005-10-05 17:56:35 +04:00
|
|
|
error = "opal_error_register";
|
2005-11-27 00:18:47 +03:00
|
|
|
goto return_error;
|
2005-10-05 17:56:35 +04:00
|
|
|
}
|
2005-08-25 00:19:36 +04:00
|
|
|
|
2007-04-21 04:15:05 +04:00
|
|
|
/* initialize install dirs code */
|
|
|
|
if (OPAL_SUCCESS != (ret = opal_installdirs_base_open())) {
|
|
|
|
fprintf(stderr, "opal_installdirs_base_open() failed -- process will likely abort (%s:%d, returned %d instead of OPAL_INIT)\n",
|
|
|
|
__FILE__, __LINE__, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* init the trace function */
|
|
|
|
opal_trace_init();
|
|
|
|
|
2006-01-16 04:48:03 +03:00
|
|
|
/* keyval lex-based parser */
|
|
|
|
if (OPAL_SUCCESS != (ret = opal_util_keyval_parse_init())) {
|
|
|
|
error = "opal_util_keyval_parse_init";
|
|
|
|
goto return_error;
|
|
|
|
}
|
|
|
|
|
2007-07-19 00:25:01 +04:00
|
|
|
if (OPAL_SUCCESS != (ret = opal_net_init())) {
|
|
|
|
error = "opal_net_init";
|
|
|
|
goto return_error;
|
|
|
|
}
|
|
|
|
|
2006-01-16 04:48:03 +03:00
|
|
|
/* Setup the parameter system */
|
|
|
|
if (OPAL_SUCCESS != (ret = mca_base_param_init())) {
|
|
|
|
error = "mca_base_param_init";
|
2005-11-27 00:18:47 +03:00
|
|
|
goto return_error;
|
2005-10-05 17:56:35 +04:00
|
|
|
}
|
2005-05-19 17:33:55 +04:00
|
|
|
|
2006-01-11 07:36:39 +03:00
|
|
|
/* register params for opal */
|
2007-11-07 04:52:23 +03:00
|
|
|
if (OPAL_SUCCESS != (ret = opal_register_params())) {
|
2006-01-11 07:36:39 +03:00
|
|
|
error = "opal_register_params";
|
|
|
|
goto return_error;
|
|
|
|
}
|
|
|
|
|
2006-01-16 04:48:03 +03:00
|
|
|
/* pretty-print stack handlers */
|
2006-12-03 16:59:23 +03:00
|
|
|
if (OPAL_SUCCESS != (ret = opal_util_register_stackhandlers())) {
|
|
|
|
error = "opal_util_register_stackhandlers";
|
2006-01-16 04:48:03 +03:00
|
|
|
goto return_error;
|
|
|
|
}
|
|
|
|
|
2007-04-23 22:53:47 +04:00
|
|
|
if (OPAL_SUCCESS != (ret = opal_util_init_sys_limits())) {
|
|
|
|
error = "opal_util_init_sys_limits";
|
|
|
|
goto return_error;
|
|
|
|
}
|
2007-08-04 04:44:23 +04:00
|
|
|
|
2006-01-16 04:48:03 +03:00
|
|
|
return OPAL_SUCCESS;
|
|
|
|
|
|
|
|
return_error:
|
|
|
|
opal_show_help( "help-opal-runtime",
|
|
|
|
"opal_init:startup:internal-failure", true,
|
|
|
|
error, ret );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
opal_init(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
char *error = NULL;
|
|
|
|
|
2007-06-01 06:43:46 +04:00
|
|
|
if( ++opal_initialized != 1 ) {
|
|
|
|
if( opal_initialized < 1 ) {
|
|
|
|
return OPAL_ERROR;
|
|
|
|
}
|
|
|
|
return OPAL_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-01-16 04:48:03 +03:00
|
|
|
/* initialize util code */
|
|
|
|
if (OPAL_SUCCESS != (ret = opal_init_util())) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize the mca */
|
|
|
|
if (OPAL_SUCCESS != (ret = mca_base_open())) {
|
|
|
|
error = "mca_base_open";
|
|
|
|
goto return_error;
|
|
|
|
}
|
|
|
|
|
2005-08-16 20:15:53 +04:00
|
|
|
/* open the processor affinity base */
|
2005-10-05 22:08:06 +04:00
|
|
|
opal_paffinity_base_open();
|
|
|
|
opal_paffinity_base_select();
|
2005-08-16 20:15:53 +04:00
|
|
|
|
2006-04-05 09:57:51 +04:00
|
|
|
/* the memcpy component should be one of the first who get
|
|
|
|
* loaded in order to make sure we ddo have all the available
|
|
|
|
* versions of memcpy correctly configured.
|
|
|
|
*/
|
|
|
|
if( OPAL_SUCCESS != (ret = opal_memcpy_base_open()) ) {
|
|
|
|
error = "opal_memcpy_base_open";
|
|
|
|
goto return_error;
|
|
|
|
}
|
|
|
|
|
2005-08-14 21:23:34 +04:00
|
|
|
/* open the memory manager components. Memory hooks may be
|
|
|
|
triggered before this (any time after mem_free_init(),
|
|
|
|
actually). This is a hook available for memory manager hooks
|
|
|
|
without good initialization routine support */
|
2005-10-05 17:56:35 +04:00
|
|
|
if (OPAL_SUCCESS != (ret = opal_memory_base_open())) {
|
|
|
|
error = "opal_memory_base_open";
|
2005-11-27 00:18:47 +03:00
|
|
|
goto return_error;
|
2005-10-05 17:56:35 +04:00
|
|
|
}
|
2005-08-14 21:23:34 +04:00
|
|
|
|
2005-09-27 00:20:20 +04:00
|
|
|
/* initialize the memory manager / tracker */
|
2005-11-29 07:46:14 +03:00
|
|
|
if (OPAL_SUCCESS != opal_mem_hooks_init()) {
|
2006-12-03 16:59:23 +03:00
|
|
|
error = "opal_mem_hooks_init";
|
2005-11-27 00:18:47 +03:00
|
|
|
goto return_error;
|
2005-10-05 17:56:35 +04:00
|
|
|
}
|
2005-09-27 00:20:20 +04:00
|
|
|
|
2008-02-12 11:46:27 +03:00
|
|
|
/* initialize the memory checker, to allow early support for annotation */
|
|
|
|
if (OPAL_SUCCESS != opal_memchecker_base_open()) {
|
|
|
|
error = "opal_memchecker_base_open";
|
|
|
|
goto return_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* select the memory checker */
|
|
|
|
if (OPAL_SUCCESS != opal_memchecker_base_select()) {
|
|
|
|
error = "opal_memchecker_base_select";
|
|
|
|
goto return_error;
|
|
|
|
}
|
|
|
|
|
2006-09-26 03:41:06 +04:00
|
|
|
if (OPAL_SUCCESS != (ret = opal_backtrace_base_open())) {
|
|
|
|
error = "opal_backtrace_base_open";
|
|
|
|
goto return_error;
|
|
|
|
}
|
|
|
|
|
2005-10-05 17:56:35 +04:00
|
|
|
if (OPAL_SUCCESS != (ret = opal_timer_base_open())) {
|
|
|
|
error = "opal_timer_base_open";
|
2005-11-27 00:18:47 +03:00
|
|
|
goto return_error;
|
2005-10-05 17:56:35 +04:00
|
|
|
}
|
2006-01-11 07:36:39 +03:00
|
|
|
|
2007-05-25 01:54:58 +04:00
|
|
|
/*
|
|
|
|
* Need to start the event and progress engines if noone else is.
|
|
|
|
* opal_cr_init uses the progress engine, so it is lumped together
|
|
|
|
* into this set as well.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Initialize the event library
|
|
|
|
*/
|
|
|
|
if (OPAL_SUCCESS != (ret = opal_event_init())) {
|
|
|
|
error = "opal_event_init";
|
|
|
|
goto return_error;
|
|
|
|
}
|
2007-03-17 02:11:45 +03:00
|
|
|
|
2007-05-25 01:54:58 +04:00
|
|
|
/*
|
2008-02-12 19:59:59 +03:00
|
|
|
* Initialize the general progress engine
|
2007-05-25 01:54:58 +04:00
|
|
|
*/
|
|
|
|
if (OPAL_SUCCESS != (ret = opal_progress_init())) {
|
|
|
|
error = "opal_progress_init";
|
|
|
|
goto return_error;
|
|
|
|
}
|
|
|
|
/* we want to tick the event library whenever possible */
|
|
|
|
opal_progress_event_users_increment();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initalize the checkpoint/restart functionality
|
|
|
|
* Note: Always do this so we can detect if the user
|
|
|
|
* attempts to checkpoint a non checkpointable job,
|
|
|
|
* otherwise the tools may hang or not clean up properly.
|
|
|
|
*/
|
|
|
|
if (OPAL_SUCCESS != (ret = opal_cr_init() ) ) {
|
|
|
|
error = "opal_cr_init() failed";
|
|
|
|
goto return_error;
|
2007-03-17 02:11:45 +03:00
|
|
|
}
|
|
|
|
|
2005-11-27 00:18:47 +03:00
|
|
|
return OPAL_SUCCESS;
|
2005-08-18 09:34:22 +04:00
|
|
|
|
2005-11-27 00:18:47 +03:00
|
|
|
return_error:
|
|
|
|
opal_show_help( "help-opal-runtime",
|
|
|
|
"opal_init:startup:internal-failure", true,
|
|
|
|
error, ret );
|
2005-10-05 17:56:35 +04:00
|
|
|
return ret;
|
2005-05-22 22:40:03 +04:00
|
|
|
}
|
2005-06-08 23:03:29 +04:00
|
|
|
|