1
1

- Sanity check initialization and finalization of PERUSE.

This commit was SVN r22390.
Этот коммит содержится в:
Rainer Keller 2010-01-12 16:36:24 +00:00
родитель 48486df4fe
Коммит 3adde52707
3 изменённых файлов: 48 добавлений и 21 удалений

Просмотреть файл

@ -50,6 +50,13 @@ enum {
PERUSE_TYPE_WIN PERUSE_TYPE_WIN
}; };
extern int ompi_peruse_initialized;
extern int ompi_peruse_finalized;
#define OMPI_ERR_PERUSE_INIT_FINALIZE \
if( OPAL_UNLIKELY(!ompi_peruse_initialized || ompi_peruse_finalized) ) { \
return PERUSE_ERR_INIT; \
}
/* /*
* Module internal function declarations * Module internal function declarations
@ -57,7 +64,6 @@ enum {
int ompi_peruse_init (void); int ompi_peruse_init (void);
int ompi_peruse_finalize (void); int ompi_peruse_finalize (void);
/* /*
* Global macros * Global macros
*/ */

Просмотреть файл

@ -149,6 +149,8 @@ int PERUSE_Event_comm_register( int event,
{ {
ompi_peruse_handle_t * handle; ompi_peruse_handle_t * handle;
if (MPI_PARAM_CHECK) { if (MPI_PARAM_CHECK) {
OMPI_ERR_PERUSE_INIT_FINALIZE;
if( (event < 0) || (event > PERUSE_num_events) || if( (event < 0) || (event > PERUSE_num_events) ||
(NULL == PERUSE_events[event].name) ) (NULL == PERUSE_events[event].name) )
return PERUSE_ERR_EVENT; return PERUSE_ERR_EVENT;
@ -196,6 +198,8 @@ int PERUSE_Event_activate (peruse_event_h event_h)
ompi_peruse_handle_t* handle = (ompi_peruse_handle_t*)event_h; ompi_peruse_handle_t* handle = (ompi_peruse_handle_t*)event_h;
if (MPI_PARAM_CHECK) { if (MPI_PARAM_CHECK) {
OMPI_ERR_PERUSE_INIT_FINALIZE;
if (PERUSE_EVENT_HANDLE_NULL == event_h) if (PERUSE_EVENT_HANDLE_NULL == event_h)
return PERUSE_ERR_EVENT_HANDLE; return PERUSE_ERR_EVENT_HANDLE;
} }
@ -213,6 +217,8 @@ int PERUSE_Event_deactivate (peruse_event_h event_h)
ompi_peruse_handle_t* handle = (ompi_peruse_handle_t*)event_h; ompi_peruse_handle_t* handle = (ompi_peruse_handle_t*)event_h;
if (MPI_PARAM_CHECK) { if (MPI_PARAM_CHECK) {
OMPI_ERR_PERUSE_INIT_FINALIZE;
if (PERUSE_EVENT_HANDLE_NULL == event_h) if (PERUSE_EVENT_HANDLE_NULL == event_h)
return PERUSE_ERR_EVENT_HANDLE; return PERUSE_ERR_EVENT_HANDLE;
} }
@ -228,6 +234,8 @@ int PERUSE_Event_deactivate (peruse_event_h event_h)
int PERUSE_Event_release (peruse_event_h * event_h) int PERUSE_Event_release (peruse_event_h * event_h)
{ {
if (MPI_PARAM_CHECK) { if (MPI_PARAM_CHECK) {
OMPI_ERR_PERUSE_INIT_FINALIZE;
if (PERUSE_EVENT_HANDLE_NULL == event_h) if (PERUSE_EVENT_HANDLE_NULL == event_h)
return PERUSE_ERR_EVENT_HANDLE; return PERUSE_ERR_EVENT_HANDLE;
} }
@ -240,6 +248,8 @@ int PERUSE_Event_release (peruse_event_h * event_h)
#define PERUSE_MPI_PARAM_CHECK(obj_upper,obj_lower ) \ #define PERUSE_MPI_PARAM_CHECK(obj_upper,obj_lower ) \
if (MPI_PARAM_CHECK) { \ if (MPI_PARAM_CHECK) { \
OMPI_ERR_PERUSE_INIT_FINALIZE; \
\
if (PERUSE_EVENT_HANDLE_NULL == event_h || \ if (PERUSE_EVENT_HANDLE_NULL == event_h || \
((ompi_peruse_handle_t*)event_h)->active || \ ((ompi_peruse_handle_t*)event_h)->active || \
((ompi_peruse_handle_t*)event_h)->type != \ ((ompi_peruse_handle_t*)event_h)->type != \
@ -249,7 +259,7 @@ int PERUSE_Event_release (peruse_event_h * event_h)
if (NULL == callback_fn) \ if (NULL == callback_fn) \
return PERUSE_ERR_PARAMETER; \ return PERUSE_ERR_PARAMETER; \
/* \ /* \
* XXX whethter the underlying MPI-object has been freed!?? \ * XXX whether the underlying MPI-object has been freed!?? \
if (ompi_ ## obj_lower ## _invalid ( \ if (ompi_ ## obj_lower ## _invalid ( \
((ompi_peruse_handle_t*)event_h)->obj_lower)) \ ((ompi_peruse_handle_t*)event_h)->obj_lower)) \
return PERUSE_ERR_MPI_OBJECT; \ return PERUSE_ERR_MPI_OBJECT; \
@ -294,6 +304,8 @@ int PERUSE_Event_comm_callback_get( peruse_event_h event_h,
int PERUSE_Event_get (peruse_event_h event_h, int* event) int PERUSE_Event_get (peruse_event_h event_h, int* event)
{ {
if (MPI_PARAM_CHECK) { if (MPI_PARAM_CHECK) {
OMPI_ERR_PERUSE_INIT_FINALIZE;
if (NULL == event_h) if (NULL == event_h)
return PERUSE_ERR_EVENT_HANDLE; return PERUSE_ERR_EVENT_HANDLE;
@ -312,12 +324,15 @@ int PERUSE_Event_object_get( peruse_event_h event_h, void** mpi_object )
ompi_peruse_handle_t* p = (ompi_peruse_handle_t*)event_h; ompi_peruse_handle_t* p = (ompi_peruse_handle_t*)event_h;
if (MPI_PARAM_CHECK) { if (MPI_PARAM_CHECK) {
OMPI_ERR_PERUSE_INIT_FINALIZE;
if (NULL == event_h) if (NULL == event_h)
return PERUSE_ERR_EVENT_HANDLE; return PERUSE_ERR_EVENT_HANDLE;
if (NULL == mpi_object) if (NULL == mpi_object)
return PERUSE_ERR_PARAMETER; return PERUSE_ERR_PARAMETER;
} }
switch (p->type) { switch (p->type) {
case PERUSE_TYPE_COMM: case PERUSE_TYPE_COMM:
*mpi_object = p->comm; *mpi_object = p->comm;
@ -327,7 +342,7 @@ int PERUSE_Event_object_get( peruse_event_h event_h, void** mpi_object )
} }
/* Propagaiont mode */ /* Propagation mode */
int PERUSE_Event_propagate (peruse_event_h event_h, int mode) int PERUSE_Event_propagate (peruse_event_h event_h, int mode)
{ {
return PERUSE_SUCCESS; return PERUSE_SUCCESS;

Просмотреть файл

@ -23,7 +23,8 @@
static opal_list_t peruse_handle_list; static opal_list_t peruse_handle_list;
static opal_mutex_t peruse_handle_list_lock; static opal_mutex_t peruse_handle_list_lock;
static int ompi_peruse_initialized = 0; int ompi_peruse_initialized = 0;
int ompi_peruse_finalized = 0;
static void ompi_peruse_handle_construct (ompi_peruse_handle_t* p) static void ompi_peruse_handle_construct (ompi_peruse_handle_t* p)
{ {
@ -73,6 +74,11 @@ int ompi_peruse_init (void)
int ompi_peruse_finalize (void) int ompi_peruse_finalize (void)
{ {
if (!ompi_peruse_initialized)
return OMPI_SUCCESS;
ompi_peruse_finalized = 1;
OBJ_DESTRUCT (&peruse_handle_list); OBJ_DESTRUCT (&peruse_handle_list);
OBJ_DESTRUCT (&peruse_handle_list_lock); OBJ_DESTRUCT (&peruse_handle_list_lock);