Multi-ApplicationOnlineProfiling  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Stream_MGR.h
Go to the documentation of this file.
1 /* ############################ MALP License ############################## */
2 /* # Fri Jan 18 14:00:00 CET 2013 # */
3 /* # Copyright or (C) or Copr. Commissariat a l'Energie Atomique # */
4 /* # # */
5 /* # This software is governed by the CeCILL-C license under French law # */
6 /* # and abiding by the rules of distribution of free software. You can # */
7 /* # use, modify and/ or redistribute the software under the terms of # */
8 /* # the CeCILL-C license as circulated by CEA, CNRS and INRIA at the # */
9 /* # following URL http://www.cecill.info. # */
10 /* # # */
11 /* # The fact that you are presently reading this means that you have # */
12 /* # had knowledge of the CeCILL-C license and that you accept its # */
13 /* # terms. # */
14 /* # # */
15 /* # Authors: # */
16 /* # - BESNARD Jean-Baptiste jean-baptiste.besnard@cea.fr # */
17 /* # # */
18 /* ######################################################################## */
19 
20 #ifndef STREAM_MGT_H
21 #define STREAM_MGT_H
22 
29 #include <stdint.h>
30 
31 #include "VMPI.h"
32 #include "Posix_Wrapp.h"
33 
34 #include "Event_Desc.h"
35 #include "Spinlock.h"
36 #include "Chained_List.h"
37 #include "Buffered_FIFO.h"
38 
43 {
45  uint64_t current_id;
46  uint64_t partition_id;
47  int rank;
49 };
50 
55 
60 static inline struct Stream_Manager * Stream_Manager()
61 {
63 }
64 
68 void Stream_Manager_init();
69 
74 
83 struct Stream_Infos * Stream_MGR_new_stream( struct Stream_Descriptor *parent, Stream_type type );
84 
89 
93 #define MAX_PENDING_EVENT 4096
94 
102 {
104  volatile uint8_t is_in_mpi_call;
106 };
107 
112 void Stream_Infos_init( struct Stream_Infos *info );
113 
118 void Stream_Infos_release( struct Stream_Infos *info );
119 
123 extern __thread struct Stream_Infos * __trace_module;
124 
129 static inline struct Stream_Infos * Stream_infos_get()
130 {
131  return __trace_module;
132 }
133 
138 static inline void Stream_infos_set(struct Stream_Infos *sd)
139 {
140  __trace_module = sd;
141 }
142 
147 static inline struct Stream_Descriptor * Stream_desc_get()
148 {
149  return &__trace_module->infos;
150 }
151 
155 static inline void Stream_Infos_enter_mpi()
156 {
157  if( !__trace_module )
158  return;
159 
160  __trace_module->is_in_mpi_call = 1;
161 }
162 
166 static inline void Stream_Infos_leave_mpi()
167 {
168  if( !__trace_module)
169  return;
170 
171  __trace_module->is_in_mpi_call = 0;
172 }
173 
178 static inline int Stream_Infos_is_in_mpi()
179 {
180  if( !__trace_module )
181  return 0;
182 
183  return __trace_module->is_in_mpi_call;
184 }
185 
186 static inline void MALP_Trace_Event_fill( struct MALP_Trace_Event *event,
188  uint64_t timestamp,
189  uint64_t duration )
190 {
191  struct Stream_Descriptor *stream_infos = Stream_desc_get();
192 
193  event->type = type;
194  event->timestamp = timestamp;
195  event->duration = duration;
196 
197  event->partition_id = VMPI_Get_partition_id();
198 
199  if( !stream_infos )
200  {
201  event->tid = 0; /* Undefined IDS are set to 0 */
202  return;
203  }
204 
205  event->tid = stream_infos->tid;
206 
207  event->rank = stream_infos->mpi_rank;
208 }
209 
210 
215 #endif /* STREAM_MGT_H */
struct Stream_Descriptor infos
The stream descriptor.
Definition: Stream_MGR.h:103
uint64_t partition_id
The id of the partition.
Definition: Stream_MGR.h:46
struct Chained_List streams
The list of managed streams.
Definition: Stream_MGR.h:44
static struct Stream_Manager * Stream_Manager()
A getter for the stream manager.
Definition: Stream_MGR.h:60
static struct Stream_Descriptor * Stream_desc_get()
Getter on the current Stream_Descriptor.
Definition: Stream_MGR.h:147
void Stream_Infos_release(struct Stream_Infos *info)
Releases a Stream_Infos.
Definition: Stream_MGR.c:82
volatile uint8_t is_in_mpi_call
1 if we are in a MPI call
Definition: Stream_MGR.h:104
uint64_t tid
id of the stream (see Stream_MGR_gen_id())
Stream_type
enum defining the type of the source of the stream
Struct defining a stream manager.
Definition: Stream_MGR.h:42
This is a struct defining a FIFO It is composed of several Buffered_FIFO_chunk.
Structure containing data related to a stream and intended to be sent as an event (see MALP_Trace_Eve...
static void MALP_Trace_Event_fill(struct MALP_Trace_Event *event, MALP_Trace_event_type type, uint64_t timestamp, uint64_t duration)
Definition: Stream_MGR.h:186
static void Stream_Infos_leave_mpi()
Indicates to the current Stream_Infos (if any) that we are leaving a MPI call.
Definition: Stream_MGR.h:166
struct Stream_Infos * Stream_MGR_new_stream(struct Stream_Descriptor *parent, Stream_type type)
Adds a stream into the current stream manager.
Definition: Stream_MGR.c:89
struct Stream_Infos * __trace_module
This is a global Stream_Infos (not shared between threads)
Definition: Stream_MGR.c:33
Struct defining an event.
Definition: Event_Desc.h:82
This a structure wrapps the use of chained_list This is the main chain list structure to use...
Definition: Chained_List.h:273
static int Stream_Infos_is_in_mpi()
Checks if we are currently inside a MPI call.
Definition: Stream_MGR.h:178
Structure describing a stream.
Definition: Stream_MGR.h:101
uint64_t mpi_rank
mpi rank of the source of the stream
struct Buffered_FIFO mpi_wrapped_event_buffer
FIFO of events for MPI calls.
Definition: Stream_MGR.h:105
MALP_Spinlock lock
the lock for concurrent access
Definition: Stream_MGR.h:48
static struct Stream_Infos * Stream_infos_get()
Getter on the current Stream_Infos.
Definition: Stream_MGR.h:129
void Stream_Manager_init()
Initialises the manager for current MPI process.
Definition: Stream_MGR.c:56
struct Stream_Manager __stream_Stream_Manager
The stream manager for current MPI process.
Definition: Stream_MGR.c:35
MALP_Trace_event_type
enum defining event types
Definition: Event_Desc.h:41
Stream_type type
the type of the source of the steram
void Stream_MGR_end_stream()
Signals end of stream.
Definition: Stream_MGR.c:138
volatile unsigned int MALP_Spinlock
The type of spinlocks in MALP.
Definition: Spinlock.h:63
int rank
the rank (within the partition
Definition: Stream_MGR.h:47
static void Stream_Infos_enter_mpi()
Indicates to the current Stream_Infos (if any) that we are enterning a MPI call.
Definition: Stream_MGR.h:155
static int VMPI_Get_partition_id()
Returns the unique ID of the current partition.
Definition: VMPI.h:142
void Stream_Infos_init(struct Stream_Infos *info)
Initializes a Stream_Infos.
Definition: Stream_MGR.c:76
static void Stream_infos_set(struct Stream_Infos *sd)
Setter on the current Stream_Infos.
Definition: Stream_MGR.h:138
void Stream_Manager_release()
Releases the manager for current MPI process (including all streams )
Definition: Stream_MGR.c:66
uint64_t current_id
a globally unique id for the streams
Definition: Stream_MGR.h:45