Multi-ApplicationOnlineProfiling  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
MALP_Config.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 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <unistd.h>
23 
24 
25 #ifndef MALP_CONFIG_H
26 #define MALP_CONFIG_H
27 
32 typedef enum {
33  //GLOBAL CONFIG
36 
37 
38  //VERBOSITY
43 
44  //INSTRUMENTATION
52 
53  // SAMPLE ANALYSIS
54 
57 
58  // OTF2 ANALYSIS
59 
64 
65  //END
67 
69 
70 
71 static const char * const TA_Conf_key_lablel[TA_CONF_KEY_COUNT] = {
72  //GLOBAL CONFIG
73  "TA_CONF_GLOBAL_HEADER",
74  "TA_CONF_THREAD_PER_TASK",
75 
76 
77  //VERBOSITY
78  "TA_CONF_VERBOSITY_HEADER",
79  "TA_CONF_DISPLAY_BANNER",
80  "TA_CONF_DISPLAY_BB_LOAD",
81  "TA_CONF_VERBOSE_OUTPUT",
82 
83  //INSTRUMENTATION
84  "TA_CONF_INSTRUMENT_HEADER",
85  "TA_CONF_INSTRUMENT_MPI",
86  "TA_CONF_INSTRUMENT_POSIX",
87  "TA_CONF_INSTRUMENT_MPI_OTF",
88  "TA_CONF_INSTRUMENT_POSIX_OTF",
89  "TA_CONF_INSTRUMENT_POSIX_PROFILE",
90  "TA_CONF_INSTRUMENT_POSIX_PROFILE_DUMP",
91 
92  // SAMPLE ANALYSIS
93 
94  "TA_CONF_SAMPLE_ANALYSIS_HEADER",
95  "TA_CONF_SAMPLE_ANALYSIS_ENABLED",
96 
97  // OTF2 ANALYSIS
98 
99  "TA_CONF_OTF2_ANALYSIS_HEADER",
100  "TA_CONF_OTF2_ANALYSIS_ENABLED",
101  "TA_CONF_OTF2_TRACE_PATH",
102  "TA_CONF_OTF2_TRACE_NAME"
103 
104 };
105 
110 typedef enum {
116 } TA_Conf_type;
117 
118 
124  char desc[500];
127  //Embeds all types for better efficiency
128  char c_value[1000];
129  float d_value;
130  int i_value;
132 };
133 
143 void TA_Conf_entry_init( TA_Conf_key_t key, char *desc, TA_Conf_type type, char *value );
144 
154 int TA_Conf_entry_update( struct TA_Conf_entry *entry, char *value );
155 
163 int TA_Conf_update( char *key_name, char *val );
164 
169 void TA_Conf_init_default();
170 
175 void TA_Conf_init_from_env();
176 
183 void TA_Conf_dispatch();
184 
190 void TA_Conf_dump( char *dest );
191 
197 void TA_Conf_load( char *source );
198 
200 
201 
210 static inline int TA_Conf_get_key_int( TA_Conf_key_t key )
211 {
212  if( ( key < TA_CONF_KEY_COUNT ) ) {
213  if( TA_Conf_entries[key].type == TA_CONF_INT ) {
214  return TA_Conf_entries[key].i_value;
215  } else {
216  printf("Bad config type\n");
217  abort();
218  }
219  } else {
220  printf("Bad config key\n");
221  abort();
222  }
223 }
224 
233 static inline int TA_Conf_get_key_bool( TA_Conf_key_t key )
234 {
235  if( ( key < TA_CONF_KEY_COUNT ) )
236  {
237  if( TA_Conf_entries[key].type == TA_CONF_BOOL )
238  {
239  return TA_Conf_entries[key].i_value & 0x1;
240  } else {
241  printf("Bad config type for key %s\n", TA_Conf_key_lablel[key]);
242  abort();
243  }
244  } else {
245  printf("Bad config key\n");
246  abort();
247  }
248 }
249 
258 static inline double TA_Conf_get_key_double( TA_Conf_key_t key )
259 {
260  if( ( key < TA_CONF_KEY_COUNT ) ) {
261  if( TA_Conf_entries[key].type == TA_CONF_DOUBLE ) {
262  return TA_Conf_entries[key].d_value;
263  } else {
264  printf("Bad config type for key %s\n", TA_Conf_key_lablel[key]);
265  abort();
266  }
267  } else {
268  printf("Bad config key\n");
269  abort();
270  }
271 }
272 
281 static inline char * TA_Conf_get_key_string( TA_Conf_key_t key )
282 {
283  if( ( key < TA_CONF_KEY_COUNT ) ) {
284  if( TA_Conf_entries[key].type == TA_CONF_STRING ) {
285  return TA_Conf_entries[key].c_value;
286  } else {
287  printf("Bad config type for key %s\n", TA_Conf_key_lablel[key]);
288  abort();
289  }
290  } else {
291  printf("Bad config key\n");
292  abort();
293  }
294 }
295 
296 
297 #define TA_Conf_dispatch() do{int ___ret = PMPI_Bcast( (char*)TA_Conf_entries,\
298  sizeof(struct TA_Conf_entry) * TA_CONF_KEY_COUNT,\
299  MPI_CHAR, 0, VMPI_Get_partition_comm());\
300  if( ___ret != MPI_SUCCESS ) {\
301  printf("Failled to dispatch configuration \n");\
302  abort();\
303  }}while(0)
304 
305 
306 
307 
308 #endif
static const char *const TA_Conf_key_lablel[TA_CONF_KEY_COUNT]
Definition: MALP_Config.h:71
static int TA_Conf_get_key_bool(TA_Conf_key_t key)
Get a configuration parameter value of type bool.
Definition: MALP_Config.h:233
void TA_Conf_load(char *source)
Load and use a file to set the Analyzer configuration.
Definition: MALP_Config.c:285
TA_Conf_type
Possible types for the Analyzer configuration parameter values.
Definition: MALP_Config.h:110
static double TA_Conf_get_key_double(TA_Conf_key_t key)
Get a configuration parameter value of type double.
Definition: MALP_Config.h:258
struct TA_Conf_entry TA_Conf_entries[TA_CONF_KEY_COUNT]
Definition: MALP_Config.c:25
TA_Conf_type type
Type of a configuration parameter value.
Definition: MALP_Config.h:125
No defined type.
Definition: MALP_Config.h:111
Boolean.
Definition: MALP_Config.h:113
static int TA_Conf_get_key_int(TA_Conf_key_t key)
Get a configuration parameter value of type int.
Definition: MALP_Config.h:210
char desc[500]
Descriptor of a configuration parameter.
Definition: MALP_Config.h:124
void TA_Conf_dump(char *dest)
Save the Analyzer_ configuration in the destination file in argument.
Definition: MALP_Config.c:262
Define a configuration entry structure, which contain a descritpion buffer, the entry type and variab...
Definition: MALP_Config.h:123
int TA_Conf_entry_update(struct TA_Conf_entry *entry, char *value)
Update the value for a configuration parameter after control of the value's content and type...
Definition: MALP_Config.c:56
#define TA_Conf_dispatch()
Start broadcasting for the analyzer.
Definition: MALP_Config.h:297
static char * TA_Conf_get_key_string(TA_Conf_key_t key)
Get a configuration parameter value of type string.
Definition: MALP_Config.h:281
int TA_Conf_update(char *key_name, char *val)
Update the value for a configuration option with control of the value name.
Definition: MALP_Config.c:116
int i_value
integer variable for the configuration parameter value
Definition: MALP_Config.h:130
char c_value[1000]
char* buffer for the configuration parameter value
Definition: MALP_Config.h:128
void TA_Conf_init_from_env()
Initialisation of config from environment.
Definition: MALP_Config.c:131
TA_Conf_key_t
Enumeration of the configuration parameter keys for MALP.
Definition: MALP_Config.h:32
void TA_Conf_init_default()
Initialisation of the Trace_Collector with default options.
Definition: MALP_Config.c:152
Integer.
Definition: MALP_Config.h:112
float d_value
float variable for the configuration parameter value
Definition: MALP_Config.h:129
void TA_Conf_entry_init(TA_Conf_key_t key, char *desc, TA_Conf_type type, char *value)
Initialisation of the Analyzer configuration parameter's type, description and value.
Definition: MALP_Config.c:30