Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions ompi/communicator/comm_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2017 The University of Tennessee and The University
* Copyright (c) 2004-2020 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
Expand Down Expand Up @@ -135,8 +135,8 @@ int ompi_comm_init(void)
ompi_mpi_comm_world.comm.c_remote_group = group;
OBJ_RETAIN(ompi_mpi_comm_world.comm.c_remote_group);
ompi_mpi_comm_world.comm.c_cube_dim = opal_cube_dim((int)size);
ompi_mpi_comm_world.comm.error_handler = &ompi_mpi_errors_are_fatal.eh;
OBJ_RETAIN( &ompi_mpi_errors_are_fatal.eh );
ompi_mpi_comm_world.comm.error_handler = ompi_initial_error_handler_eh;
OBJ_RETAIN( ompi_mpi_comm_world.comm.error_handler );
OMPI_COMM_SET_PML_ADDED(&ompi_mpi_comm_world.comm);
opal_pointer_array_set_item (&ompi_mpi_communicators, 0, &ompi_mpi_comm_world);

Expand Down Expand Up @@ -188,8 +188,8 @@ int ompi_comm_init(void)
ompi_mpi_comm_self.comm.c_local_group = group;
ompi_mpi_comm_self.comm.c_remote_group = group;
OBJ_RETAIN(ompi_mpi_comm_self.comm.c_remote_group);
ompi_mpi_comm_self.comm.error_handler = &ompi_mpi_errors_are_fatal.eh;
OBJ_RETAIN( &ompi_mpi_errors_are_fatal.eh );
ompi_mpi_comm_self.comm.error_handler = ompi_initial_error_handler_eh;
OBJ_RETAIN( ompi_mpi_comm_self.comm.error_handler );
OMPI_COMM_SET_PML_ADDED(&ompi_mpi_comm_self.comm);
opal_pointer_array_set_item (&ompi_mpi_communicators, 1, &ompi_mpi_comm_self);

Expand All @@ -214,8 +214,10 @@ int ompi_comm_init(void)
ompi_mpi_comm_null.comm.c_contextid = 2;
ompi_mpi_comm_null.comm.c_my_rank = MPI_PROC_NULL;

/* unlike world, self, and parent, comm_null does not inherit the initial error
* handler */
ompi_mpi_comm_null.comm.error_handler = &ompi_mpi_errors_are_fatal.eh;
OBJ_RETAIN( &ompi_mpi_errors_are_fatal.eh );
OBJ_RETAIN( ompi_mpi_comm_null.comm.error_handler );
opal_pointer_array_set_item (&ompi_mpi_communicators, 2, &ompi_mpi_comm_null);

opal_string_copy(ompi_mpi_comm_null.comm.c_name, "MPI_COMM_NULL",
Expand All @@ -228,6 +230,8 @@ int ompi_comm_init(void)
OBJ_RETAIN(&ompi_mpi_comm_null);
OBJ_RETAIN(&ompi_mpi_group_null.group);
OBJ_RETAIN(&ompi_mpi_errors_are_fatal.eh);
/* During dyn_init, the comm_parent error handler will be set to the same
* as comm_world (thus, the initial error handler). */

/* initialize communicator requests (for ompi_comm_idup) */
ompi_comm_request_init ();
Expand Down
11 changes: 11 additions & 0 deletions ompi/dpm/dpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
int flag=0;
char cwd[OPAL_PATH_MAX];
char host[OPAL_MAX_INFO_VAL]; /*** should define OMPI_HOST_MAX ***/
char init_errh[OPAL_MAX_INFO_VAL];
char prefix[OPAL_MAX_INFO_VAL];
char stdin_target[OPAL_MAX_INFO_VAL];
char params[OPAL_MAX_INFO_VAL];
Expand Down Expand Up @@ -814,6 +815,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
- "file": filename, where additional information is provided.
- "soft": see page 92 of MPI-2.
- "host": desired host where to spawn the processes
- "mpi_initial_errhandler": the error handler attached to predefined communicators.
Non-standard keys:
- "hostfile": hostfile containing hosts where procs are
to be spawned
Expand Down Expand Up @@ -968,6 +970,15 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[],
}
#endif

/* check for 'mpi_initial_errhandler' */
ompi_info_get (array_of_info[i], "mpi_initial_errhandler", sizeof(init_errh) - 1, init_errh, &flag);
if ( flag ) {
/* this is set as an environment because it must be available
* before pmix_init */
opal_setenv("OMPI_MCA_mpi_initial_errhandler", init_errh, true, &app->env);
continue;
}

/* 'path', 'arch', 'file', 'soft' -- to be implemented */

/* non-standard keys
Expand Down
13 changes: 13 additions & 0 deletions ompi/errhandler/errcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,17 @@ do { \
opal_pointer_array_set_item(&ompi_mpi_errcodes, (ERRCODE), &(VAR)); \
} while (0)

static opal_mutex_t errcode_init_lock = OPAL_MUTEX_STATIC_INIT;

int ompi_mpi_errcode_init (void)
{
opal_mutex_lock(&errcode_init_lock);
if ( 0 != ompi_mpi_errcode_lastpredefined ) {
/* Already initialized (presumably by an API call before MPI_init */
opal_mutex_unlock(&errcode_init_lock);
return OMPI_SUCCESS;
}

/* Initialize the pointer array, which will hold the references to
the error objects */
OBJ_CONSTRUCT(&ompi_mpi_errcodes, opal_pointer_array_t);
Expand Down Expand Up @@ -223,6 +232,7 @@ int ompi_mpi_errcode_init (void)
MPI_ERR_LASTCODE. So just start it as == MPI_ERR_LASTCODE. */
ompi_mpi_errcode_lastused = MPI_ERR_LASTCODE;
ompi_mpi_errcode_lastpredefined = MPI_ERR_LASTCODE;
opal_mutex_unlock(&errcode_init_lock);
return OMPI_SUCCESS;
}

Expand All @@ -231,6 +241,7 @@ int ompi_mpi_errcode_finalize(void)
int i;
ompi_mpi_errcode_t *errc;

opal_mutex_lock(&errcode_init_lock);
for (i=ompi_mpi_errcode_lastpredefined+1; i<=ompi_mpi_errcode_lastused; i++) {
/*
* there are some user defined error-codes, which
Expand Down Expand Up @@ -317,6 +328,8 @@ int ompi_mpi_errcode_finalize(void)
OBJ_DESTRUCT(&ompi_t_err_invalid_name);

OBJ_DESTRUCT(&ompi_mpi_errcodes);
ompi_mpi_errcode_lastpredefined = 0;
opal_mutex_unlock(&errcode_init_lock);
return OMPI_SUCCESS;
}

Expand Down
152 changes: 86 additions & 66 deletions ompi/errhandler/errcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2007 The University of Tennessee and The University
* Copyright (c) 2004-2020 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
Expand Down Expand Up @@ -55,11 +55,68 @@ OMPI_DECLSPEC extern int ompi_mpi_errcode_lastpredefined;

OMPI_DECLSPEC extern ompi_mpi_errcode_t ompi_err_unknown;

/**
* Initialize the error codes
*
* @returns OMPI_SUCCESS Upon success
* @returns OMPI_ERROR Otherwise
*
* Invoked from ompi_mpi_init(); sets up all static MPI error codes,
*/
int ompi_mpi_errcode_init(void);

/**
* Finalize the error codes.
*
* @returns OMPI_SUCCESS Always
*
* Invokes from ompi_mpi_finalize(); tears down the error code array.
*/
int ompi_mpi_errcode_finalize(void);

/**
* Add an error code
*
* @param: error class to which this new error code belongs to
*
* @returns the new error code on SUCCESS (>0)
* @returns OMPI_ERROR otherwise
*
*/
int ompi_mpi_errcode_add (int errclass);

/**
* Add an error class
*
* @param: none
*
* @returns the new error class on SUCCESS (>0)
* @returns OMPI_ERROR otherwise
*
*/
int ompi_mpi_errclass_add (void);

/**
* Add an error string to an error code
*
* @param: error code for which the string is defined
* @param: error string to add
* @param: length of the string
*
* @returns OMPI_SUCCESS on success
* @returns OMPI_ERROR on error
*/
int ompi_mpi_errnum_add_string (int errnum, const char* string, int len);

/**
* Check for a valid error code
*/
static inline bool ompi_mpi_errcode_is_invalid(int errcode)
{
if (OPAL_UNLIKELY( 0 == ompi_mpi_errcode_lastpredefined )) {
ompi_mpi_errcode_init();
}

if ( errcode >= 0 && errcode <= ompi_mpi_errcode_lastused )
return 0;
else
Expand All @@ -73,23 +130,31 @@ static inline int ompi_mpi_errcode_get_class (int errcode)
{
ompi_mpi_errcode_t *err = NULL;

if (OPAL_UNLIKELY( 0 == ompi_mpi_errcode_lastpredefined )) {
ompi_mpi_errcode_init();
}

if (errcode >= 0) {
err = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errcode);
/* If we get a bogus errcode, return MPI_ERR_UNKNOWN */
}

if (NULL != err) {
if ( err->code != MPI_UNDEFINED ) {
return err->cls;
}
if ( err->code != MPI_UNDEFINED ) {
return err->cls;
}
}
return ompi_err_unknown.cls;
}

static inline int ompi_mpi_errcode_is_predefined ( int errcode )
{
if (OPAL_UNLIKELY( 0 == ompi_mpi_errcode_lastpredefined )) {
ompi_mpi_errcode_init();
}

if ( errcode >= 0 && errcode <= ompi_mpi_errcode_lastpredefined )
return true;
return true;

return false;
}
Expand All @@ -98,23 +163,27 @@ static inline int ompi_mpi_errnum_is_class ( int errnum )
{
ompi_mpi_errcode_t *err;

if (OPAL_UNLIKELY( 0 == ompi_mpi_errcode_lastpredefined )) {
ompi_mpi_errcode_init();
}

if (errnum < 0) {
return false;
}

if ( errnum <= ompi_mpi_errcode_lastpredefined ) {
/* Predefined error values represent an error code and
an error class at the same time */
return true;
/* Predefined error values represent an error code and
an error class at the same time */
return true;
}

err = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errnum);
if (NULL != err) {
if ( MPI_UNDEFINED == err->code) {
/* Distinction between error class and error code is that for the
first one the code section is set to MPI_UNDEFINED */
return true;
}
if ( MPI_UNDEFINED == err->code) {
/* Distinction between error class and error code is that for the
first one the code section is set to MPI_UNDEFINED */
return true;
}
}

return false;
Expand All @@ -128,6 +197,10 @@ static inline char* ompi_mpi_errnum_get_string (int errnum)
{
ompi_mpi_errcode_t *err = NULL;

if (OPAL_UNLIKELY( 0 == ompi_mpi_errcode_lastpredefined )) {
ompi_mpi_errcode_init();
}

if (errnum >= 0) {
err = (ompi_mpi_errcode_t *)opal_pointer_array_get_item(&ompi_mpi_errcodes, errnum);
/* If we get a bogus errcode, return a string indicating that this
Expand All @@ -142,59 +215,6 @@ static inline char* ompi_mpi_errnum_get_string (int errnum)
}


/**
* Initialize the error codes
*
* @returns OMPI_SUCCESS Upon success
* @returns OMPI_ERROR Otherwise
*
* Invoked from ompi_mpi_init(); sets up all static MPI error codes,
*/
int ompi_mpi_errcode_init(void);

/**
* Finalize the error codes.
*
* @returns OMPI_SUCCESS Always
*
* Invokes from ompi_mpi_finalize(); tears down the error code array.
*/
int ompi_mpi_errcode_finalize(void);

/**
* Add an error code
*
* @param: error class to which this new error code belongs to
*
* @returns the new error code on SUCCESS (>0)
* @returns OMPI_ERROR otherwise
*
*/
int ompi_mpi_errcode_add (int errclass);

/**
* Add an error class
*
* @param: none
*
* @returns the new error class on SUCCESS (>0)
* @returns OMPI_ERROR otherwise
*
*/
int ompi_mpi_errclass_add (void);

/**
* Add an error string to an error code
*
* @param: error code for which the string is defined
* @param: error string to add
* @param: length of the string
*
* @returns OMPI_SUCCESS on success
* @returns OMPI_ERROR on error
*/
int ompi_mpi_errnum_add_string (int errnum, const char* string, int len);

END_C_DECLS

#endif /* OMPI_MPI_ERRCODE_H */
Loading