1
1

First cut of PERUSE. Right now we support all the Peruse definitions from the

version 1.12. As in the 2.0 everything related to windows and files has been removed
I prefer to add the complete files, so I have a trace in the SN for later.

This commit was SVN r9373.
Этот коммит содержится в:
George Bosilca 2006-03-23 05:00:55 +00:00
родитель aef1358808
Коммит 686cc9ef54
8 изменённых файлов: 948 добавлений и 0 удалений

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

@ -113,6 +113,9 @@ include file/Makefile.am
include group/Makefile.am
include info/Makefile.am
include op/Makefile.am
if WANT_PERUSE
include peruse/Makefile.am
endif
include proc/Makefile.am
include request/Makefile.am
include runtime/Makefile.am

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

@ -293,6 +293,10 @@ static void ompi_comm_construct(ompi_communicator_t* comm)
comm->c_coll_basic_data = NULL;
comm->errhandler_type = OMPI_ERRHANDLER_TYPE_COMM;
#ifdef OMPI_WANT_PERUSE
comm->c_peruse_handles = NULL;
#endif
return;
}

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

@ -121,6 +121,13 @@ struct ompi_communicator_t {
int c_f_to_c_index;
#ifdef OMPI_WANT_PERUSE
/*
* Place holder for the PERUSE events.
*/
struct ompi_peruse_handle_t** c_peruse_handles;
#endif
/* Error handling. This field does not have the "c_" prefix so
that the OMPI_ERRHDL_* macros can find it, regardless of whether
it's a comm, window, or file. */

23
ompi/peruse/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,23 @@
# -*- makefile -*-
#
# Copyright (c) 2004-2006 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# This makefile.am does not stand on its own - it is included from ompi/Makefile.am
headers += peruse/peruse_internal.h \
peruse/peruse.h
libmpi_la_SOURCES += \
peruse/peruse.c \
peruse/peruse_module.c

121
ompi/peruse/peruse-internal.h Обычный файл
Просмотреть файл

@ -0,0 +1,121 @@
/*
* 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.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef _PERUSE_INTERNAL_H_
#define _PERUSE_INTERNAL_H_
#include "ompi/peruse/peruse.h"
#include "opal/class/opal_list.h"
#include "ompi/communicator/communicator.h"
#include "ompi/file/file.h"
#include "ompi/win/win.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
typedef int (ompi_peruse_callback_f)(peruse_event_h event_h,
MPI_Aint unique_id, void * spec, void * param);
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(ompi_peruse_t);
struct ompi_peruse_handle_t {
opal_list_item_t super; /**< Allow handle to be placed on a list */
opal_mutex_t lock; /**< Lock protecting the entry XXX needed?*/
int active; /**< Whether this handle has been activated */
int event; /**< Event being watched */
int type; /**< Object-type this event is registered on */
ompi_communicator_t* comm; /**< Corresponding communicicator */
ompi_file_t* file; /**< Corresponding file */
ompi_win_t* win; /**< Corresponding window, in case we have support */
ompi_peruse_callback_f* fn; /**< Callback function specified by user */
void * param; /**< Parameters being passed to callback */
};
typedef struct ompi_peruse_handle_t ompi_peruse_handle_t;
OMPI_DECLSPEC extern opal_class_t ompi_peruse_handle_t_class;
enum {
PERUSE_TYPE_INVALID=-1,
PERUSE_TYPE_COMM,
PERUSE_TYPE_FILE,
PERUSE_TYPE_WIN
};
/*
* Module internal function declarations
*/
int ompi_peruse_init (void);
int ompi_peruse_finalize (void);
/*
* Global macros
*/
#define PERUSE_ENABLED 1 /* XXX */
#ifdef OMPI_WANT_PERUSE
#define PERUSE_TRACE_COMM_EVENT(event, base_req, op) \
do { \
if( NULL != (base_req)->req_comm->c_peruse_handles ) { \
ompi_peruse_handle_t * _ptr = (base_req)->req_comm->c_peruse_handles[(event)]; \
if (NULL != _ptr && _ptr->active) { \
peruse_comm_spec_t _comm_spec; \
_comm_spec.comm = (base_req)->req_comm; \
_comm_spec.buf = (base_req)->req_addr; \
_comm_spec.count = (base_req)->req_count; \
_comm_spec.datatype = (base_req)->req_datatype; \
_comm_spec.peer = (base_req)->req_peer; \
_comm_spec.tag = (base_req)->req_tag; \
_comm_spec.operation = (op); \
_ptr->fn(_ptr, (MPI_Aint)(base_req), &_comm_spec, _ptr->param); \
} \
} \
} while(0)
#define PERUSE_TRACE_MSG_EVENT(event, comm_ptr, hdr_peer, hdr_tag, op) \
do { \
if( NULL != (comm_ptr)->c_peruse_handles ) { \
ompi_peruse_handle_t * _ptr = (comm_ptr)->c_peruse_handles[(event)]; \
if (NULL != _ptr && _ptr->active) { \
peruse_comm_spec_t _comm_spec; \
_comm_spec.comm = (ompi_communicator_t*) (comm_ptr); \
_comm_spec.buf = NULL; \
_comm_spec.count = 0; \
_comm_spec.datatype = MPI_DATATYPE_NULL; \
_comm_spec.peer = (hdr_peer); \
_comm_spec.tag = (hdr_tag); \
_comm_spec.operation = (op); \
_ptr->fn (_ptr, (MPI_Aint)/* unique_id */ 0, &_comm_spec, _ptr->param); \
} \
} \
} while(0)
#else
#define PERUSE_TRACE_COMM_EVENT(event, base_req, op)
#define PERUSE_TRACE_MSG_EVENT(event, comm_ptr, hdr_peer, hdr_tag, op)
#endif
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* _PERUSE_INTERNAL_H_ */

466
ompi/peruse/peruse.c Обычный файл
Просмотреть файл

@ -0,0 +1,466 @@
/*
* 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.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include "mpi.h"
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#include "ompi/peruse/peruse.h"
#include "ompi/peruse/peruse-internal.h"
#include "opal/class/opal_hash_table.h"
#include "ompi/communicator/communicator.h"
#include "ompi/file/file.h"
OMPI_DECLSPEC extern bool ompi_mpi_param_check;
/*
* Data
*/
/*
* This array has to match the array in peruse.h
* and the PERUSE_events -array below.
*/
const char * PERUSE_event_names[] = {
/* Point-to-point request events */
"PERUSE_COMM_REQ_ACTIVATE",
"PERUSE_COMM_REQ_MATCH_UNEX",
"PERUSE_COMM_REQ_INSERT_IN_POSTED_Q",
"PERUSE_COMM_REQ_REMOVE_FROM_POSTED_Q",
"PERUSE_COMM_REQ_XFER_BEGIN",
"PERUSE_COMM_REQ_XFER_END",
"PERUSE_COMM_REQ_COMPLETE",
"PERUSE_COMM_REQ_NOTIFY",
"PERUSE_COMM_MSG_ARRIVED",
"PERUSE_COMM_MSG_INSERT_IN_UNEX_Q",
"PERUSE_COMM_MSG_REMOVE_FROM_UNEX_Q",
"PERUSE_COMM_MSG_MATCH_POSTED_REQ",
/* Queue events*/
"PERUSE_COMM_SEARCH_POSTED_Q_BEGIN",
"PERUSE_COMM_SEARCH_POSTED_Q_END",
"PERUSE_COMM_SEARCH_UNEX_Q_BEGIN", /* XXX Devation from 1.11 */
"PERUSE_COMM_SEARCH_UNEX_Q_END"
};
const int PERUSE_events[] = {
/* Point-to-point request events */
PERUSE_COMM_REQ_ACTIVATE,
PERUSE_COMM_REQ_MATCH_UNEX,
PERUSE_COMM_REQ_INSERT_IN_POSTED_Q,
PERUSE_COMM_REQ_REMOVE_FROM_POSTED_Q,
PERUSE_COMM_REQ_XFER_BEGIN,
PERUSE_COMM_REQ_XFER_END,
PERUSE_COMM_REQ_COMPLETE,
PERUSE_COMM_REQ_NOTIFY,
PERUSE_COMM_MSG_ARRIVED,
PERUSE_COMM_MSG_INSERT_IN_UNEX_Q,
PERUSE_COMM_MSG_REMOVE_FROM_UNEX_Q,
PERUSE_COMM_MSG_MATCH_POSTED_REQ,
/* Queue events*/
PERUSE_COMM_SEARCH_POSTED_Q_BEGIN,
PERUSE_COMM_SEARCH_POSTED_Q_END,
PERUSE_COMM_SEARCH_UNEX_Q_BEGIN,
PERUSE_COMM_SEARCH_UNEX_Q_END
};
const int PERUSE_num_events = (sizeof (PERUSE_events) / sizeof (PERUSE_events[0]));
/*
* PERUSE user-callable function
*/
int PERUSE_Init (void)
{
ompi_peruse_init ();
return PERUSE_SUCCESS;
}
/* Query all implemented events */
int PERUSE_Query_supported_events (
int * num_supported,
char *** event_names,
int ** events)
{
int i;
*num_supported = PERUSE_num_events;
/*
* Play save and copy all values.
*/
*event_names = (char**) malloc (PERUSE_num_events * sizeof (char *));
*events = (int*) malloc (PERUSE_num_events * sizeof (int));
for (i = 0; i < PERUSE_num_events; i++) {
(*event_names)[i] = strdup (PERUSE_event_names[i]);
(*events)[i] = PERUSE_events[i];
}
return PERUSE_SUCCESS;
}
/* Query supported events */
int PERUSE_Query_event (const char * event_name, int *event)
{
int i;
for (i = 0; i < PERUSE_num_events; i++) {
if (!strcmp (event_name, PERUSE_event_names[i]))
break;
}
if (i == PERUSE_num_events)
return PERUSE_ERR_EVENT;
*event = PERUSE_events[i];
return PERUSE_SUCCESS;
}
/* Query event name */
int PERUSE_Query_event_name (int event, char ** event_name)
{
if (event < 0 || event > PERUSE_num_events ||
NULL == PERUSE_event_names[event])
return PERUSE_EVENT_INVALID;
*event_name = strdup (PERUSE_event_names[event]);
return PERUSE_SUCCESS;
}
/* Get environment variables that affect MPI library behavior */
int PERUSE_Query_environment (int * env_size, char *** env)
{
/* XXX tbd */
return PERUSE_SUCCESS;
}
/* Query the scope of queue metrics - global or per communicator */
int PERUSE_Query_queue_event_scope (int * scope)
{
*scope = PERUSE_PER_COMM; /* XXX; not yet realized */
return PERUSE_SUCCESS;
}
/*
* II. Events, objects initialization and manipulation
*/
/* Initialize event associated with an MPI communicator */
int PERUSE_Event_comm_register (
int event,
MPI_Comm comm,
peruse_comm_callback_f * callback_fn,
void * param,
peruse_event_h * event_h)
{
ompi_peruse_handle_t * handle;
if (MPI_PARAM_CHECK) {
if (event < 0 || event > PERUSE_num_events ||
NULL == PERUSE_event_names[event])
return PERUSE_ERR_EVENT;
if (MPI_COMM_NULL == comm || ompi_comm_invalid (comm))
return PERUSE_ERR_COMM;
if (NULL == callback_fn)
return PERUSE_ERR_GENERIC;
if (NULL == event_h)
return PERUSE_ERR_EVENT_HANDLE;
}
handle = OBJ_NEW (ompi_peruse_handle_t);
/*
* Initialize the newly created handle to the default inactive state.
*/
handle->active = 0;
handle->event = event;
handle->type = PERUSE_TYPE_COMM;
handle->comm = comm;
handle->fn = (ompi_peruse_callback_f*) callback_fn;
handle->param = param;
/*
* Update the information on the handle on the communicator
*/
OPAL_THREAD_LOCK (&comm->c_lock);
if( NULL == comm->c_peruse_handles ) {
comm->c_peruse_handles = malloc( PERUSE_num_events * sizeof(ompi_peruse_handle_t*) );
}
OPAL_THREAD_UNLOCK (&comm->c_lock);
comm->c_peruse_handles[event] = handle;
*event_h = handle;
return PERUSE_SUCCESS;
}
/* Start collecting data (activate event) */
int PERUSE_Event_activate (peruse_event_h event_h)
{
ompi_peruse_handle_t* handle = (ompi_peruse_handle_t*)event_h;
if (MPI_PARAM_CHECK) {
if (PERUSE_EVENT_HANDLE_NULL == event_h)
return PERUSE_ERR_EVENT_HANDLE;
}
OPAL_THREAD_LOCK (&handle->lock);
handle->active = 1;
OPAL_THREAD_UNLOCK (&handle->lock);
return PERUSE_SUCCESS;
}
/* Stop collecting data (deactivate event) */
int PERUSE_Event_deactivate (peruse_event_h event_h)
{
ompi_peruse_handle_t* handle = (ompi_peruse_handle_t*)event_h;
if (MPI_PARAM_CHECK) {
if (PERUSE_EVENT_HANDLE_NULL == event_h)
return PERUSE_ERR_EVENT_HANDLE;
}
OPAL_THREAD_LOCK (&handle->lock);
handle->active = 0;
OPAL_THREAD_UNLOCK (&handle->lock);
return PERUSE_SUCCESS;
}
/* Free event handle */
int PERUSE_Event_release (peruse_event_h * event_h)
{
if (MPI_PARAM_CHECK) {
if (PERUSE_EVENT_HANDLE_NULL == event_h)
return PERUSE_ERR_EVENT_HANDLE;
}
/*
* XXX
*/
*event_h = PERUSE_EVENT_HANDLE_NULL;
return PERUSE_SUCCESS;
}
#undef PERUSE_MPI_PARAM_CHECK
#define PERUSE_MPI_PARAM_CHECK(obj_upper,obj_lower ) \
if (MPI_PARAM_CHECK) { \
if (PERUSE_EVENT_HANDLE_NULL == event_h || \
((ompi_peruse_handle_t*)event_h)->active || \
((ompi_peruse_handle_t*)event_h)->type != \
PERUSE_TYPE_ ## obj_upper) \
return PERUSE_ERR_EVENT_HANDLE; \
\
if (NULL == callback_fn) \
return PERUSE_ERR_PARAMETER; \
/* \
* XXX whethter the underlying MPI-object has been freed!?? \
if (ompi_ ## obj_lower ## _invalid ( \
((ompi_peruse_handle_t*)event_h)->obj_lower)) \
return PERUSE_ERR_MPI_OBJECT; \
*/ \
} \
/* Set a new comm callback */
int PERUSE_Event_comm_callback_set (
peruse_event_h event_h,
peruse_comm_callback_f * callback_fn,
void * param)
{
ompi_peruse_handle_t* handle = (ompi_peruse_handle_t*)event_h;
PERUSE_MPI_PARAM_CHECK (COMM, comm);
OPAL_THREAD_LOCK (&handle->lock);
handle->fn = (ompi_peruse_callback_f*) callback_fn;
handle->param = param;
OPAL_THREAD_UNLOCK (&handle->lock);
return PERUSE_SUCCESS;
}
/* Set a new file callback */
int PERUSE_Event_file_callback_set (
peruse_event_h event_h,
peruse_file_callback_f * callback_fn,
void * param)
{
ompi_peruse_handle_t* handle = (ompi_peruse_handle_t*)event_h;
PERUSE_MPI_PARAM_CHECK (FILE, file);
OPAL_THREAD_LOCK (&handle->lock);
handle->fn = (ompi_peruse_callback_f*) callback_fn;
handle->param = param;
OPAL_THREAD_UNLOCK (&handle->lock);
return PERUSE_SUCCESS;
}
/* Set a new win callback */
int PERUSE_Event_win_callback_set (
peruse_event_h event_h,
peruse_win_callback_f * callback_fn,
void * param)
{
ompi_peruse_handle_t* handle = (ompi_peruse_handle_t*)event_h;
PERUSE_MPI_PARAM_CHECK (WIN, win);
OPAL_THREAD_LOCK (&handle->lock);
handle->fn = (ompi_peruse_callback_f*) callback_fn;
handle->param = param;
OPAL_THREAD_UNLOCK (&handle->lock);
return PERUSE_SUCCESS;
}
#undef PERUSE_MPI_PARAM_CHECK
#define PERUSE_MPI_PARAM_CHECK(obj_upper,obj_lower ) \
if (MPI_PARAM_CHECK) { \
if (PERUSE_EVENT_HANDLE_NULL == event_h || \
((ompi_peruse_handle_t*)event_h)->active || \
((ompi_peruse_handle_t*)event_h)->type != \
PERUSE_TYPE_ ## obj_upper) \
return PERUSE_ERR_EVENT_HANDLE; \
\
if (NULL == callback_fn || NULL == param) \
return PERUSE_ERR_PARAMETER; \
/* \
* XXX whethter the underlying MPI-object has been freed!?? \
if (ompi_ ## obj_lower ## _invalid ( \
((ompi_peruse_handle_t*)event_h)->obj_lower)) \
return PERUSE_ERR_MPI_OBJECT; \
*/ \
} \
/* Get the current comm callback */
int PERUSE_Event_comm_callback_get (
peruse_event_h event_h,
peruse_comm_callback_f ** callback_fn,
void ** param)
{
ompi_peruse_handle_t* handle = (ompi_peruse_handle_t*)event_h;
PERUSE_MPI_PARAM_CHECK (COMM, comm);
OPAL_THREAD_LOCK (&handle->lock);
*callback_fn = (peruse_comm_callback_f*) handle->fn;
*param = handle->param;
OPAL_THREAD_UNLOCK (&handle->lock);
return PERUSE_SUCCESS;
}
/* Get the current ile callback */
int PERUSE_Event_file_callback_get (
peruse_event_h event_h,
peruse_file_callback_f ** callback_fn,
void ** param)
{
ompi_peruse_handle_t* handle = (ompi_peruse_handle_t*)event_h;
PERUSE_MPI_PARAM_CHECK (FILE, file);
OPAL_THREAD_LOCK (&handle->lock);
*callback_fn = (peruse_file_callback_f*) handle->fn;
*param = handle->param;
OPAL_THREAD_UNLOCK (&handle->lock);
return PERUSE_SUCCESS;
}
/* Get the current win callback */
int PERUSE_Event_win_callback_get (
peruse_event_h event_h,
peruse_win_callback_f ** callback_fn,
void ** param)
{
ompi_peruse_handle_t* handle = (ompi_peruse_handle_t*)event_h;
PERUSE_MPI_PARAM_CHECK (WIN, win);
OPAL_THREAD_LOCK (&handle->lock);
*callback_fn = (peruse_win_callback_f*) handle->fn;
*param = handle->param;
OPAL_THREAD_UNLOCK (&handle->lock);
return PERUSE_SUCCESS;
}
/* Obtain event descriptor from an event handle (reverse lookup) */
int PERUSE_Event_get (peruse_event_h event_h, int * event)
{
if (MPI_PARAM_CHECK) {
if (NULL == event_h)
return PERUSE_ERR_EVENT_HANDLE;
if (NULL == event)
return PERUSE_ERR_PARAMETER;
}
*event = ((ompi_peruse_handle_t*)event_h)->event;
return PERUSE_SUCCESS;
}
/* Obtain MPI object associated with event handle */
/* XXX Shouldn't we have 3 different functions to obtain a specific object Comm/File/Win */
int PERUSE_Event_object_get (peruse_event_h event_h, void ** mpi_object)
{
ompi_peruse_handle_t * p = event_h;
if (MPI_PARAM_CHECK) {
if (NULL == event_h)
return PERUSE_ERR_EVENT_HANDLE;
if (NULL == mpi_object)
return PERUSE_ERR_PARAMETER;
}
switch (p->type) {
case PERUSE_TYPE_INVALID:
return PERUSE_ERR_GENERIC;
case PERUSE_TYPE_COMM:
*mpi_object = p->comm;
break;
case PERUSE_TYPE_FILE:
*mpi_object = p->file;
break;
case PERUSE_TYPE_WIN:
*mpi_object = p->win;
break;
}
return PERUSE_SUCCESS;
}
/* Propagaiont mode */
int PERUSE_Event_propagate (peruse_event_h event_h, int mode)
{
return PERUSE_SUCCESS;
}

240
ompi/peruse/peruse.h Обычный файл
Просмотреть файл

@ -0,0 +1,240 @@
/*
* 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.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef _PERUSE_H_
#define _PERUSE_H_
#include "mpi.h"
/* PERUSE type declarations */
typedef void* peruse_event_h; /* Opaque event handle XXX */
typedef struct _peruse_comm_spec_t {
MPI_Comm comm;
void * buf;
int count;
MPI_Datatype datatype;
int peer;
int tag;
int operation;
} peruse_comm_spec_t;
typedef struct _peruse_file_spec_t {
MPI_File file;
void * buf;
int count;
MPI_Datatype datatype;
MPI_Offset offset;
int operation;
} peruse_file_spec_t;
typedef struct _peruse_win_spec_t {
MPI_Win win;
void * o_buf;
int o_count;
MPI_Datatype o_datatype;
void * t_buf;
int t_count;
MPI_Datatype t_datatype;
MPI_Op acc_op;
int peer;
int operation;
} peruse_win_spec_t;
typedef int (peruse_comm_callback_f)(peruse_event_h event_h,
MPI_Aint unique_id, peruse_comm_spec_t * spec, void * param);
typedef int (peruse_file_callback_f)(peruse_event_h event_h,
MPI_Aint unique_id, peruse_file_spec_t * spec, void * param);
typedef int (peruse_win_callback_f)(peruse_event_h event_h,
MPI_Aint unique_id, peruse_win_spec_t * spec, void * param);
/* PERUSE constants */
enum {
PERUSE_SUCCESS = 0, /* Success *//* XXX Devation from 1.11 */
PERUSE_ERR_INIT, /* PERUSE initialization failure */
PERUSE_ERR_GENERIC, /* Generic unspecified error */
PERUSE_ERR_MALLOC, /* Memory-related error */
PERUSE_ERR_EVENT, /* Invalid event descriptor */
PERUSE_ERR_EVENT_HANDLE, /* Invalid event handle */
PERUSE_ERR_PARAMETER, /* Invalid input parameter */
PERUSE_ERR_MPI_INIT, /* MPI has not been initialized */
PERUSE_ERR_COMM, /* MPI_ERR_COMM class */
PERUSE_ERR_FILE, /* MPI_ERR_FILE class */
PERUSE_ERR_WIN, /* MPI_ERR_WIN class */
PERUSE_ERR_MPI_OBJECT /* Error with associated MPI object */
};
enum {
PERUSE_EVENT_INVALID = -1, /* Must differ in value from PERUSE_SUCCESS. Devation from 1.11 */
/* Point-to-point request events */
PERUSE_COMM_REQ_ACTIVATE,
PERUSE_COMM_REQ_MATCH_UNEX,
PERUSE_COMM_REQ_INSERT_IN_POSTED_Q,
PERUSE_COMM_REQ_REMOVE_FROM_POSTED_Q,
PERUSE_COMM_REQ_XFER_BEGIN,
PERUSE_COMM_REQ_XFER_END,
PERUSE_COMM_REQ_COMPLETE,
PERUSE_COMM_REQ_NOTIFY,
PERUSE_COMM_MSG_ARRIVED,
PERUSE_COMM_MSG_INSERT_IN_UNEX_Q,
PERUSE_COMM_MSG_REMOVE_FROM_UNEX_Q,
PERUSE_COMM_MSG_MATCH_POSTED_REQ,
/* Queue events*/
PERUSE_COMM_SEARCH_POSTED_Q_BEGIN,
PERUSE_COMM_SEARCH_POSTED_Q_END,
PERUSE_COMM_SEARCH_UNEX_Q_BEGIN, /* XXX Devation from 1.11 */
PERUSE_COMM_SEARCH_UNEX_Q_END,
/* Collective events */
/* IO events */
/* One-sided events */
PERUSE_CUSTOM_EVENT
};
/* Scope of message queues */
enum {
PERUSE_PER_COMM=0, /* XXX Devation from 1.11 */
PERUSE_GLOBAL
};
/* Operation values */
enum {
PERUSE_SEND=0, /* XXX Devation from 1.11 */
PERUSE_RECV,
PERUSE_PUT,
PERUSE_GET,
PERUSE_ACC,
PERUSE_IO_READ,
PERUSE_IO_WRITE
};
#define PERUSE_EVENT_HANDLE_NULL ((peruse_event_h)0)
/*
* I. Environment
*/
/* PERUSE initialization */
int PERUSE_Init (void);
/* Query all implemented events */
int PERUSE_Query_supported_events (
int * num_supported,
char *** event_names,
int ** events);
/* Query supported events */
int PERUSE_Query_event (const char * event_name, int *event);
/* Query event name */
int PERUSE_Query_event_name (int event, char ** event_name);
/* Get environment variables that affect MPI library behavior */
int PERUSE_Query_environment (int * env_size, char *** env);
/* Query the scope of queue metrics - global or per communicator */
int PERUSE_Query_queue_event_scope (int * scope);
/*
* II. Events, objects initialization and manipulation
*/
/* Initialize event associated with an MPI communicator */
int PERUSE_Event_comm_register (
int event,
MPI_Comm comm,
peruse_comm_callback_f * callback_fn,
void * param,
peruse_event_h * event_h);
/* Initialize event associated with an MPI file */
int PERUSE_Event_file_register (
int event,
MPI_File file,
peruse_file_callback_f * callback_fn,
void * param,
peruse_event_h * event_h);
/* Initialize event associated with an MPI window */
int PERUSE_Event_win_register (
int event,
MPI_Win win,
peruse_win_callback_f * callback_fn,
void * param,
peruse_event_h * event_h);
/* Start collecting data (activate event) */
int PERUSE_Event_activate (peruse_event_h event_h);
/* Stop collecting data (deactivate event) */
int PERUSE_Event_deactivate (peruse_event_h event_h);
/* Free event handle */
int PERUSE_Event_release (peruse_event_h * event_h);
/* Set a new comm callback */
int PERUSE_Event_comm_callback_set (
peruse_event_h event_h,
peruse_comm_callback_f * callback_fn,
void * param);
/* Set a new file callback */
int PERUSE_Event_file_callback_set (
peruse_event_h event_h,
peruse_file_callback_f * callback_fn,
void * param);
/* Set a new win callback */
int PERUSE_Event_win_callback_set (
peruse_event_h event_h,
peruse_win_callback_f * callback_fn,
void * param);
/* Get the current comm callback */
int PERUSE_Event_comm_callback_get (
peruse_event_h event_h,
peruse_comm_callback_f ** callback_fn,
void ** param);
/* Get the current ile callback */
int PERUSE_Event_file_callback_get (
peruse_event_h event_h,
peruse_file_callback_f ** callback_fn,
void ** param);
/* Get the current win callback */
int PERUSE_Event_win_callback_get (
peruse_event_h event_h,
peruse_win_callback_f ** callback_fn,
void ** param);
/* Obtain event descriptor from an event handle (reverse lookup) */
int PERUSE_Event_get (peruse_event_h event_h, int * event);
/* Obtain MPI object associated with event handle */
/* XXX Shouldn't we have 3 different functions to obtain a specific object Comm/File/Win */
int PERUSE_Event_object_get (peruse_event_h event_h, void ** mpi_object);
/* Propagaiont mode */
int PERUSE_Event_propagate (peruse_event_h event_h, int mode);
#endif

84
ompi/peruse/peruse_module.c Обычный файл
Просмотреть файл

@ -0,0 +1,84 @@
/*
* 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.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include <stdlib.h>
#include "mpi.h"
#include "ompi/peruse/peruse.h"
#include "ompi/peruse/peruse-internal.h"
#include "ompi/constants.h"
#include "class/ompi_pointer_array.h"
void ompi_peruse_handle_construct (ompi_peruse_handle_t* p);
void ompi_peruse_handle_destruct (ompi_peruse_handle_t* p);
static opal_list_t peruse_handle_list;
static int ompi_peruse_initialized = 0;
OBJ_CLASS_INSTANCE(
ompi_peruse_handle_t,
opal_list_item_t,
ompi_peruse_handle_construct,
ompi_peruse_handle_destruct);
void ompi_peruse_handle_construct (ompi_peruse_handle_t* p)
{
OBJ_CONSTRUCT (&(p->lock), opal_mutex_t);
p->active = 0;
p->event = PERUSE_EVENT_INVALID;
p->type = PERUSE_TYPE_INVALID;
p->comm = MPI_COMM_NULL;
/* p->win = MPI_WIN_NULL; */
/* p->file = MPI_FILE_NULL */
p->fn = NULL;
p->param = NULL;
OPAL_THREAD_LOCK (&peruse_handle_list_lock);
opal_list_append (&peruse_handle_list, (opal_list_item_t*)p);
OPAL_THREAD_UNLOCK (&peruse_handle_list_lock);
}
void ompi_peruse_handle_destruct (ompi_peruse_handle_t* p)
{
OPAL_THREAD_LOCK (&peruse_handle_list_lock);
opal_list_remove_item (&peruse_handle_list, (opal_list_item_t*)p);
OPAL_THREAD_UNLOCK (&peruse_handle_list_lock);
OBJ_DESTRUCT (&(p->lock));
}
int ompi_peruse_init (void)
{
if (ompi_peruse_initialized)
return OMPI_SUCCESS;
ompi_peruse_initialized = 1;
OBJ_CONSTRUCT (&peruse_handle_list, opal_list_t);
return OMPI_SUCCESS;
}
int ompi_peruse_finalize (void)
{
OBJ_DESTRUCT (&peruse_handle_list);
return OMPI_SUCCESS;
}