Multi-ApplicationOnlineProfiling  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
VMPI.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 VMPI
21 #define VMPI
22 
23 
24 #include <mpi.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include <limits.h>
31 #include <string.h>
32 #include <stdio.h>
33 
38 #define VMPI_NG_ARBITRARY_VALUE 0x1234567llu
39 
43 #define VMPI_NG_MAXIMUM_TAGS 1000000
44 
48 #define MPI_COMM_UNIVERSE ((MPI_Comm)VMPI_NG_ARBITRARY_VALUE)
49 
55 {
58  VMPI_MEM=-1,
60 };
61 
67 int VMPI_Enabled();
68 
76 int VMPI_Init(int * argc, char ***argv);
77 
83 int VMPI_Release();
84 
89 #define VMPI_PNAME_LEN 200
90 
94 #define VMPI_COMMAND_LEN 1024
95 
100 typedef struct
101 {
102  int id;
103  int root_id;
104  int size;
105  char name[200];
106  char program_name[VMPI_PNAME_LEN];
107  char command_line[VMPI_COMMAND_LEN];
108  MPI_Comm partition_comm;
110 
111 
117 {
120  int (*vmpi_trampoline)( int argc, char **argv );
122  char partition_name[200];
125  MPI_Comm vmpi_communicator;
127 };
128 
133 extern struct VMPI_Status __vmpi_status;
134 
142 static inline int VMPI_Get_partition_id()
143 {
144  return __vmpi_status.mypartition;
145 }
146 
147 
154 {
155  int id = VMPI_Get_partition_id();
156  return &__vmpi_status.partition_descs[id];
157 }
158 
159 
165 static inline int VMPI_Get_partition_count()
166 {
168 }
169 
175 static inline MPI_Comm VMPI_Get_partition_comm()
176 {
177  return VMPI_Get_desc()->partition_comm;
178 }
179 
189 static inline int VMPI_Set_partition_name( char *name )
190 {
191  snprintf(__vmpi_status.partition_name, 200, "%s" , name );
192  return VMPI_SUCCESS;
193 }
194 
195 
196 static inline int VMPI_Set_trace_trampoline( char *trampoline_partition,
197  int (*vmpi_trampoline)( int argc, char **argv ) )
198 {
199  if( !vmpi_trampoline || !trampoline_partition )
200  return 1;
201 
202 
203  strncpy( __vmpi_status.trampoline_partition_name, trampoline_partition, 200 );
205 
206  return 0;
207 }
208 
209 static inline int VMPI_In_trampoline()
210 {
211  if( __vmpi_status.vmpi_trampoline != NULL )
212  {
213  if( VMPI_Get_partition_id() == 1 )
214  return 1;
215  }
216 
217  return 0;
218 }
219 
220 
221 
228 static inline VMPI_Partition_desc *VMPI_Get_desc_by_name(char *name)
229 {
230  int i;
231 
232  for( i = 0 ; i < VMPI_Get_partition_count() ; i++ )
233  {
234  if( !strcmp( __vmpi_status.partition_descs[i].name, name ) )
235  return &__vmpi_status.partition_descs[i];
236  }
237 
238  return NULL;
239 }
240 
248 {
249  if( VMPI_Get_partition_count() <= id )
250  return NULL;
251 
252  return &__vmpi_status.partition_descs[id];
253 
254 }
255 
256 
257 
264 
269 void VMPI_Display_descs();
270 
275 typedef enum
276 {
281 
282 
287 typedef struct
288 {
289  int count;
290  int *ranks;
291 }VMPI_Map;
292 
300 static inline void VMPI_Map_clear( VMPI_Map *map )
301 {
302  map->count = 0;
303  map->ranks = NULL;
304 }
305 
317 int VMPI_Map_partitions( int target_partition, VMPI_Map_mode mode, VMPI_Map *map );
318 void VMPI_Print_map( VMPI_Map *map );
323 static inline MPI_Comm VMPI_Get_vmpi_comm()
324 {
325  if( !VMPI_Enabled())
326  return MPI_COMM_WORLD;
327 
329 }
330 
331 
337 int VMPI_get_new_tag();
338 
339 #include "VMPI_stream.h"
340 
341 #ifdef __cplusplus
342 }
343 #endif
344 
345 #endif /*VMPI*/
All OK.
Definition: VMPI.h:59
#define VMPI_COMMAND_LEN
Maximum command line name.
Definition: VMPI.h:94
int vmpi_enabled
VMPI is enabled.
Definition: VMPI.h:124
static int VMPI_Set_trace_trampoline(char *trampoline_partition, int(*vmpi_trampoline)(int argc, char **argv))
Definition: VMPI.h:196
Defines a map.
Definition: VMPI.h:287
int numpartitions
Partitions number.
Definition: VMPI.h:119
int * ranks
Target ranks.
Definition: VMPI.h:290
int VMPI_get_new_tag()
Book a tag on VMPI's communicator for this process.
Definition: VMPI.c:32
char name[200]
Name of the partition (could be NONE)
Definition: VMPI.h:105
static MPI_Comm VMPI_Get_vmpi_comm()
Get VMPI's copy of MPI_COMM_WORLD.
Definition: VMPI.h:323
int VMPI_Release()
Releases VMPI.
Definition: VMPI.c:840
int mypartition
Current partition id.
Definition: VMPI.h:118
Something went wrong.
Definition: VMPI.h:57
static MPI_Comm VMPI_Get_partition_comm()
Returns current partition's communicator.
Definition: VMPI.h:175
int current_tag
Counter for local process tags.
Definition: VMPI.h:123
Map processes in a round robin fashion.
Definition: VMPI.h:279
static VMPI_Partition_desc * VMPI_Get_desc_by_name(char *name)
Find a descriptions by its name.
Definition: VMPI.h:228
static void VMPI_Map_clear(VMPI_Map *map)
Clears a map.
Definition: VMPI.h:300
int VMPI_Map_partitions(int target_partition, VMPI_Map_mode mode, VMPI_Map *map)
Map to another partition (can be additive)
Definition: VMPI.c:94
static int VMPI_Get_partition_count()
Return the number of partitions.
Definition: VMPI.h:165
Global status handling.
Definition: VMPI.h:116
int size
Number of tasks involved in the partition.
Definition: VMPI.h:104
void VMPI_Print_map(VMPI_Map *map)
Definition: VMPI.c:80
Structure holding partitions descriptions.
Definition: VMPI.h:100
VMPI_Return_Status
Enum for error handling.
Definition: VMPI.h:54
int root_id
Identifier of the root of the partition.
Definition: VMPI.h:103
char partition_name[200]
Current partition name.
Definition: VMPI.h:122
MPI_Comm partition_comm
The communicator of the partition.
Definition: VMPI.h:108
void VMPI_Display_descs()
Display all the partitions descriptions in order.
Definition: VMPI.c:69
VMPI_Partition_desc * partition_descs
Partitions descriptions.
Definition: VMPI.h:126
static int VMPI_Set_partition_name(char *name)
Used to setup partition name for a given executable.
Definition: VMPI.h:189
Randomly associates processes.
Definition: VMPI.h:278
MPI_Comm vmpi_communicator
current MPI communicator
Definition: VMPI.h:125
static VMPI_Partition_desc * VMPI_Get_desc_by_id(int id)
Find a descriptions by its ID.
Definition: VMPI.h:247
void VMPI_Display_desc(VMPI_Partition_desc *desc)
Prints all the fields of a partition descriptions.
Definition: VMPI.c:56
int id
Unique identifier of the partition.
Definition: VMPI.h:102
int(* vmpi_trampoline)(int argc, char **argv)
Definition: VMPI.h:120
Failed to allocate some memory.
Definition: VMPI.h:58
#define VMPI_PNAME_LEN
Maximum size of a program name.
Definition: VMPI.h:89
Associates each process to one process.
Definition: VMPI.h:277
static int VMPI_Get_partition_id()
Returns the unique ID of the current partition.
Definition: VMPI.h:142
The call cannot pursue retry.
Definition: VMPI.h:56
static VMPI_Partition_desc * VMPI_Get_desc()
Returns current partition's descriptions.
Definition: VMPI.h:153
struct VMPI_Status __vmpi_status
global VMPI status
Definition: VMPI.c:30
static int VMPI_In_trampoline()
Definition: VMPI.h:209
int VMPI_Enabled()
indicates if VMPI is enabled
Definition: VMPI.c:50
int VMPI_Init(int *argc, char ***argv)
Initializes VMPI.
Definition: VMPI.c:758
char trampoline_partition_name[200]
Definition: VMPI.h:121
int count
Number of ranks.
Definition: VMPI.h:289
VMPI_Map_mode
Defines mapping method.
Definition: VMPI.h:275