Multi-ApplicationOnlineProfiling  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
OTF_Event_forge.c
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 #include "OTF_Event_forge.h"
20 #include <stdio.h>
21 #include <stdlib.h>
22 
24 
25 uint64_t OTF_Event_resolve_str_id( MALP_Trace_event_type type, uint64_t subtype )
26 {
27  uint64_t base_index = 0;
28 
29  switch( type )
30  {
31  case MALP_EVENT_OTF:
32  base_index = 0;
33  break;
34  case MALP_EVENT_MPI:
35  base_index = MALP_OTF_ANALYSER_INFO_COUNT;
36  break;
37  case MALP_EVENT_WRAPPED:
39  break;
40  default:
41  return -1;
42  }
43 
44  return base_index + subtype;
45 }
46 
47 
48 
49 char * OTF_Event_resolve( uint64_t str_id )
50 {
51  if( (MALP_OTF_ANALYSER_INFO_COUNT < str_id) && ( str_id < OTF_EVENT_COUNT ) )
52  return OTF_Str_ids[ str_id ];
53 
54  return NULL;
55 }
56 
57 int OTF_Event_set( uint64_t str_id , char * data )
58 {
59 
60  if( (str_id <= MALP_OTF_ANALYSER_INFO_COUNT) || ( OTF_EVENT_COUNT <= str_id ) )
61  return 1;
62 
63 
64  if( data )
65  {
66  OTF_Str_ids[ str_id ] = strdup(data);
67  }
68  else
69  {
70  free( OTF_Str_ids[ str_id ] );
71  OTF_Str_ids[ str_id ] = NULL;
72  }
73 }
74 
75 
77 {
78  int i;
79 
80  /* Fill in OTF related Events */
81  for( i = 0 ; i < MALP_OTF_ANALYSER_INFO_COUNT; i++ )
82  {
84  }
85 
86  /* Fill in MPI events */
87  for( i = 0 ; i < T_MPI_COUNT; i++ )
88  {
90  }
91 
92  /* Fill in POSIX events */
93  for( i = 0 ; i < T_POSIX_COUNT; i++ )
94  {
96  }
97 
98 }
99 
100 
101 
103 {
104  int i;
105 
106  /* Clear event names */
107  for( i = 0 ; i < OTF_EVENT_COUNT; i++ )
108  {
109  OTF_Event_set( i , NULL );
110  }
111 
112 
113 }
114 
115 
116 int OTF_Event_forge( struct MALP_Trace_Event *event, OTF_Event_type enterleave,
117  MALP_Trace_event_type type, uint64_t subtype )
118 {
119  /* First make sure this is an OTF event */
120  event->type = MALP_EVENT_OTF;
121 
122  struct OTF_Event *otf_event = &event->event.otf;
123 
124  otf_event->type = enterleave;
125 
126  if( type == MALP_EVENT_MPI )
127  {
128  otf_event->category = OTF_EVENT_MPI;
129  }
130  else if( type == MALP_EVENT_WRAPPED )
131  {
132  otf_event->category = OTF_EVENT_POSIX;
133  }
134  else
135  {
136  otf_event->category = OTF_EVENT_OTHER;
137  }
138 
139  otf_event->str_id = OTF_Event_resolve_str_id( type, subtype );
140 
141  if( otf_event->str_id < 0 )
142  {
143  printf("Failed to resolve an event in %s\n", __FUNCTION__);
144  return 1;
145  }
146 
147  otf_event->src_tid = 0;
148  otf_event->dest_tid = 0;
149  otf_event->comm_id = 0;
150 
151  return 0;
152 }
153 
154 void OTF_Event_print( struct MALP_Trace_Event *event)
155 {
156  if( event->type != MALP_EVENT_OTF )
157  {
158  printf("Not an OTF event\n");
159  return;
160  }
161 
162  struct OTF_Event *otf_event = &event->event.otf;
163 
164  printf("================\n");
165  printf("TYPE : %s\n", (otf_event->type==OTF_EVENT_ENTER)?"ENTER":"LEAVE" );
166  printf("FCT : %s(%d)\n", OTF_Event_resolve( otf_event->str_id ), otf_event->str_id );
167  printf("TID : %ld\n", event->tid );
168  printf("TS : %ld\n", event->timestamp );
169 
170  printf("================\n");
171 
172 
173 }
174 
#define OTF_EVENT_COUNT
static const char *const OTF_Event_names[MALP_OTF_ANALYSER_INFO_COUNT]
static const char *const MPI_Event_names[T_MPI_COUNT]
Definition: MPI_Events.h:629
int OTF_Event_forge(struct MALP_Trace_Event *event, OTF_Event_type enterleave, MALP_Trace_event_type type, uint64_t subtype)
uint64_t dest_tid
Definition: OTF_Event.h:51
void OTF_Event_print(struct MALP_Trace_Event *event)
char * OTF_Event_resolve(uint64_t str_id)
uint64_t src_tid
Definition: OTF_Event.h:50
void OTF_Event_forge_init()
Struct defining an event.
Definition: Event_Desc.h:82
uint64_t comm_id
Definition: OTF_Event.h:52
MALP_Trace_event_type type
The type of the event.
Definition: Event_Desc.h:85
int64_t str_id
Definition: OTF_Event.h:48
The event contains wrapped function informations.
Definition: Event_Desc.h:46
uint64_t tid
The stream unique id.
Definition: Event_Desc.h:88
MALP_Trace_event_type
enum defining event types
Definition: Event_Desc.h:41
uint64_t OTF_Event_resolve_str_id(MALP_Trace_event_type type, uint64_t subtype)
uint64_t timestamp
Creation date.
Definition: Event_Desc.h:86
char * OTF_Str_ids[OTF_EVENT_COUNT]
Enter + Leave events for OTF2 compatibility.
Definition: Event_Desc.h:47
OTF_Event_type
Definition: OTF_Event.h:29
The event contains MPI informations.
Definition: Event_Desc.h:45
static const char *const Wrapped_symbol_names[T_POSIX_COUNT]
Array containing wrapped symbols names.
void OTF_Event_forge_release()
OTF_Event_category category
Definition: OTF_Event.h:46
int OTF_Event_set(uint64_t str_id, char *data)
OTF_Event_type type
Definition: OTF_Event.h:45