OpenMPI  0.1.1
peruse-internal.h
1 /*
2  * Copyright (c) 2004-2006 The University of Tennessee and The University
3  * of Tennessee Research Foundation. All rights
4  * reserved.
5  * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
6  * University of Stuttgart. All rights reserved.
7  * $COPYRIGHT$
8  *
9  * Additional copyrights may follow
10  *
11  * $HEADER$
12  */
13 #ifndef _PERUSE_INTERNAL_H_
14 #define _PERUSE_INTERNAL_H_
15 
16 #include "ompi_config.h"
17 #include "ompi/peruse/peruse.h"
18 #include "opal/class/opal_list.h"
19 #include "ompi/communicator/communicator.h"
20 #include "ompi/file/file.h"
21 #include "ompi/win/win.h"
22 
23 BEGIN_C_DECLS
24 
25 typedef int (ompi_peruse_callback_f)(peruse_event_h event_h,
26  MPI_Aint unique_id, void * spec, void * param);
27 
28 OMPI_DECLSPEC OBJ_CLASS_DECLARATION(ompi_peruse_t);
29 
31  opal_list_item_t super; /**< Allow handle to be placed on a list */
32  opal_mutex_t lock; /**< Lock protecting the entry XXX needed?*/
33  int active; /**< Whether this handle has been activated */
34  int event; /**< Event being watched */
35  int type; /**< Object-type this event is registered on */
36  ompi_communicator_t* comm; /**< Corresponding communicator */
37  ompi_file_t* file; /**< Corresponding file */
38  ompi_win_t* win; /**< Corresponding window, in case we have support */
39  ompi_peruse_callback_f* fn; /**< Callback function specified by user */
40  void * param; /**< Parameters being passed to callback */
41 };
42 
45 
46 enum {
47  PERUSE_TYPE_INVALID=-1,
48  PERUSE_TYPE_COMM,
49  PERUSE_TYPE_FILE,
50  PERUSE_TYPE_WIN
51 };
52 
53 extern int ompi_peruse_initialized;
54 extern int ompi_peruse_finalized;
55 
56 #define OMPI_ERR_PERUSE_INIT_FINALIZE \
57  if( OPAL_UNLIKELY(!ompi_peruse_initialized || ompi_peruse_finalized) ) { \
58  return PERUSE_ERR_INIT; \
59  }
60 
61 /*
62  * Module internal function declarations
63  */
64 int ompi_peruse_init (void);
65 int ompi_peruse_finalize (void);
66 
67 /*
68  * Global macros
69  */
70 
71 #if OMPI_WANT_PERUSE
72 #define PERUSE_TRACE_COMM_EVENT(event, base_req, op) \
73 do { \
74  if( NULL != (base_req)->req_comm->c_peruse_handles ) { \
75  ompi_peruse_handle_t * _ptr = (base_req)->req_comm->c_peruse_handles[(event)]; \
76  if (NULL != _ptr && _ptr->active) { \
77  peruse_comm_spec_t _comm_spec; \
78  _comm_spec.comm = (base_req)->req_comm; \
79  _comm_spec.buf = (base_req)->req_addr; \
80  _comm_spec.count = (base_req)->req_count; \
81  _comm_spec.datatype = (base_req)->req_datatype; \
82  _comm_spec.peer = (base_req)->req_peer; \
83  _comm_spec.tag = (base_req)->req_tag; \
84  _comm_spec.operation = (op); \
85  _ptr->fn(_ptr, (MPI_Aint)(base_req), &_comm_spec, _ptr->param); \
86  } \
87  } \
88 } while(0)
89 
90 #define PERUSE_TRACE_COMM_OMPI_EVENT(event, base_req, size, op) \
91 do { \
92  if( NULL != (base_req)->req_comm->c_peruse_handles ) { \
93  ompi_peruse_handle_t * _ptr = (base_req)->req_comm->c_peruse_handles[(event)]; \
94  if (NULL != _ptr && _ptr->active) { \
95  peruse_comm_spec_t _comm_spec; \
96  _comm_spec.comm = (base_req)->req_comm; \
97  _comm_spec.buf = (base_req)->req_addr; \
98  _comm_spec.count = size; \
99  _comm_spec.datatype = MPI_PACKED; \
100  _comm_spec.peer = (base_req)->req_peer; \
101  _comm_spec.tag = (base_req)->req_tag; \
102  _comm_spec.operation = (op); \
103  _ptr->fn(_ptr, (MPI_Aint)(base_req), &_comm_spec, _ptr->param); \
104  } \
105  } \
106 } while(0)
107 
108 #define PERUSE_TRACE_MSG_EVENT(event, comm_ptr, hdr_peer, hdr_tag, op) \
109  do { \
110  if( NULL != (comm_ptr)->c_peruse_handles ) { \
111  ompi_peruse_handle_t * _ptr = (comm_ptr)->c_peruse_handles[(event)]; \
112  if (NULL != _ptr && _ptr->active) { \
113  peruse_comm_spec_t _comm_spec; \
114  _comm_spec.comm = (ompi_communicator_t*) (comm_ptr); \
115  _comm_spec.buf = NULL; \
116  _comm_spec.count = 0; \
117  _comm_spec.datatype = MPI_DATATYPE_NULL; \
118  _comm_spec.peer = (hdr_peer); \
119  _comm_spec.tag = (hdr_tag); \
120  _comm_spec.operation = (op); \
121  _ptr->fn (_ptr, (MPI_Aint)/*(unique_id)*/0, &_comm_spec, _ptr->param); \
122  } \
123  } \
124  } while(0)
125 
126 #else
127 
128 #define PERUSE_TRACE_COMM_EVENT(event, base_req, op)
129 #define PERUSE_TRACE_COMM_OMPI_EVENT(event, base_req, size, op)
130 #define PERUSE_TRACE_MSG_EVENT(event, comm_ptr, hdr_peer, hdr_tag, op)
131 
132 #endif
133 
134 END_C_DECLS
135 
136 #endif /* _PERUSE_INTERNAL_H_ */
Definition: win.h:53
ompi_peruse_callback_f * fn
Callback function specified by user.
Definition: peruse-internal.h:39
ompi_communicator_t * comm
Corresponding communicator.
Definition: peruse-internal.h:36
Definition: peruse-internal.h:30
Definition: mutex_unix.h:53
int type
Object-type this event is registered on.
Definition: peruse-internal.h:35
The opal_list_t interface is used to provide a generic doubly-linked list container for Open MPI...
opal_mutex_t lock
Lock protecting the entry XXX needed?
Definition: peruse-internal.h:32
int active
Whether this handle has been activated.
Definition: peruse-internal.h:33
Definition: opal_list.h:98
Back-end structure for MPI_File.
Definition: file.h:42
ompi_win_t * win
Corresponding window, in case we have support.
Definition: peruse-internal.h:38
int event
Event being watched.
Definition: peruse-internal.h:34
opal_list_item_t super
Allow handle to be placed on a list.
Definition: peruse-internal.h:31
ompi_file_t * file
Corresponding file.
Definition: peruse-internal.h:37
void * param
Parameters being passed to callback.
Definition: peruse-internal.h:40
Definition: communicator.h:118
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236