Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
1ab9eaed215ba02649d057cbfa1433d6d5eb3ebc
[simgrid.git] / src / smpi / smpi_comm.cpp
1 /* Copyright (c) 2010-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <stdlib.h>
8 #include <limits.h>
9
10 #include <xbt/dict.h>
11 #include <xbt/ex.h>
12 #include <xbt/ex.hpp>
13
14 #include <simgrid/s4u/host.hpp>
15 #include <src/smpi/smpi_group.hpp>
16
17 #include "private.h"
18 #include "smpi_mpi_dt_private.h"
19 #include "src/simix/smx_private.h"
20 #include "colls/colls.h"
21
22 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_comm, smpi, "Logging specific to SMPI (comm)");
23
24 xbt_dict_t smpi_comm_keyvals = nullptr;
25 int comm_keyval_id = 0;//avoid collisions
26
27 /* Support for cartesian topology was added, but there are 2 other types of topology, graph et dist graph. In order to
28  * support them, we have to add a field MPIR_Topo_type, and replace the MPI_Topology field by an union. */
29
30 typedef struct s_smpi_mpi_communicator {
31   MPI_Group group;
32   MPIR_Topo_type topoType; 
33   MPI_Topology topo; // to be replaced by an union
34   int refcount;
35   MPI_Comm leaders_comm;//inter-node communicator
36   MPI_Comm intra_comm;//intra-node communicator . For MPI_COMM_WORLD this can't be used, as var is global.
37   //use an intracomm stored in the process data instead
38   int* leaders_map; //who is the leader of each process
39   int is_uniform;
40   int* non_uniform_map; //set if smp nodes have a different number of processes allocated
41   int is_blocked;// are ranks allocated on the same smp node contiguous ?
42   xbt_dict_t attributes;
43 } s_smpi_mpi_communicator_t;
44
45 static int smpi_compare_rankmap(const void *a, const void *b)
46 {
47   const int* x = static_cast<const int*>(a);
48   const int* y = static_cast<const int*>(b);
49
50   if (x[1] < y[1]) {
51     return -1;
52   }
53   if (x[1] == y[1]) {
54     if (x[0] < y[0]) {
55       return -1;
56     }
57     if (x[0] == y[0]) {
58       return 0;
59     }
60     return 1;
61   }
62   return 1;
63 }
64
65 MPI_Comm smpi_comm_new(MPI_Group group, MPI_Topology topo)
66 {
67   MPI_Comm comm;
68
69   comm = xbt_new(s_smpi_mpi_communicator_t, 1);
70   comm->group = group;
71   comm->refcount=1;
72   comm->topoType = MPI_INVALID_TOPO;
73   comm->topo = topo;
74   comm->intra_comm = MPI_COMM_NULL;
75   comm->leaders_comm = MPI_COMM_NULL;
76   comm->is_uniform=1;
77   comm->non_uniform_map = nullptr;
78   comm->leaders_map = nullptr;
79   comm->is_blocked=0;
80   comm->attributes=nullptr;
81   return comm;
82 }
83
84 void smpi_comm_destroy(MPI_Comm comm)
85 {
86   if (comm == MPI_COMM_UNINITIALIZED)
87     comm = smpi_process_comm_world();
88   smpi_topo_destroy(comm->topo); // there's no use count on topos
89   smpi_comm_unuse(comm);
90 }
91
92 int smpi_comm_dup(MPI_Comm comm, MPI_Comm* newcomm){
93   if(smpi_privatize_global_variables){ //we need to switch as the called function may silently touch global variables
94      smpi_switch_data_segment(smpi_process_index());
95    }
96   MPI_Group cp=new simgrid::SMPI::Group(smpi_comm_group(comm));
97   (*newcomm) = smpi_comm_new(cp, smpi_comm_topo(comm));
98   int ret = MPI_SUCCESS;
99
100   if(comm->attributes !=nullptr){
101     (*newcomm)->attributes   = xbt_dict_new_homogeneous(nullptr);
102     xbt_dict_cursor_t cursor = nullptr;
103     char* key;
104     int flag;
105     void* value_in;
106     void* value_out;
107     xbt_dict_foreach (comm->attributes, cursor, key, value_in) {
108       smpi_comm_key_elem elem =
109           static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, key, sizeof(int)));
110       if (elem != nullptr && elem->copy_fn != MPI_NULL_COPY_FN) {
111         ret = elem->copy_fn(comm, atoi(key), nullptr, value_in, &value_out, &flag);
112         if (ret != MPI_SUCCESS) {
113           smpi_comm_destroy(*newcomm);
114           *newcomm = MPI_COMM_NULL;
115           xbt_dict_cursor_free(&cursor);
116           return ret;
117         }
118         if (flag)
119           xbt_dict_set_ext((*newcomm)->attributes, key, sizeof(int), value_out, nullptr);
120       }
121       }
122     }
123   return ret;
124 }
125
126 MPI_Group smpi_comm_group(MPI_Comm comm)
127 {
128   if (comm == MPI_COMM_UNINITIALIZED)
129     comm = smpi_process_comm_world();
130   return comm->group;
131 }
132
133 MPI_Topology smpi_comm_topo(MPI_Comm comm) {
134   if (comm != MPI_COMM_NULL)
135     return comm->topo;
136   return nullptr;
137 }
138
139 int smpi_comm_size(MPI_Comm comm)
140 {
141   if (comm == MPI_COMM_UNINITIALIZED)
142     comm = smpi_process_comm_world();
143   return smpi_comm_group(comm)->getsize();
144 }
145
146 int smpi_comm_rank(MPI_Comm comm)
147 {
148   if (comm == MPI_COMM_UNINITIALIZED)
149     comm = smpi_process_comm_world();
150   return smpi_comm_group(comm)->rank(smpi_process_index());
151 }
152
153 void smpi_comm_get_name (MPI_Comm comm, char* name, int* len)
154 {
155   if (comm == MPI_COMM_UNINITIALIZED)
156     comm = smpi_process_comm_world();
157   if(comm == MPI_COMM_WORLD) {
158     strncpy(name, "WORLD",5);
159     *len = 5;
160   } else {
161     *len = snprintf(name, MPI_MAX_NAME_STRING, "%p", comm);
162   }
163 }
164
165 void smpi_comm_set_leaders_comm(MPI_Comm comm, MPI_Comm leaders){
166   if (comm == MPI_COMM_UNINITIALIZED)
167     comm = smpi_process_comm_world();
168   comm->leaders_comm=leaders;
169 }
170
171 void smpi_comm_set_intra_comm(MPI_Comm comm, MPI_Comm leaders){
172   comm->intra_comm=leaders;
173 }
174
175 int* smpi_comm_get_non_uniform_map(MPI_Comm comm){
176   if (comm == MPI_COMM_UNINITIALIZED)
177     comm = smpi_process_comm_world();
178   return comm->non_uniform_map;
179 }
180
181 int* smpi_comm_get_leaders_map(MPI_Comm comm){
182   if (comm == MPI_COMM_UNINITIALIZED)
183     comm = smpi_process_comm_world();
184   return comm->leaders_map;
185 }
186
187 MPI_Comm smpi_comm_get_leaders_comm(MPI_Comm comm){
188   if (comm == MPI_COMM_UNINITIALIZED)
189     comm = smpi_process_comm_world();
190   return comm->leaders_comm;
191 }
192
193 MPI_Comm smpi_comm_get_intra_comm(MPI_Comm comm){
194   if (comm == MPI_COMM_UNINITIALIZED || comm==MPI_COMM_WORLD) 
195     return smpi_process_get_comm_intra();
196   else return comm->intra_comm;
197 }
198
199 int smpi_comm_is_uniform(MPI_Comm comm){
200   if (comm == MPI_COMM_UNINITIALIZED)
201     comm = smpi_process_comm_world();
202   return comm->is_uniform;
203 }
204
205 int smpi_comm_is_blocked(MPI_Comm comm){
206   if (comm == MPI_COMM_UNINITIALIZED)
207     comm = smpi_process_comm_world();
208   return comm->is_blocked;
209 }
210
211 MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key)
212 {
213   if (comm == MPI_COMM_UNINITIALIZED)
214     comm = smpi_process_comm_world();
215   int system_tag = 123;
216   int* recvbuf;
217
218   MPI_Group group_root = nullptr;
219   MPI_Group group_out  = nullptr;
220   MPI_Group group      = smpi_comm_group(comm);
221   int rank             = smpi_comm_rank(comm);
222   int size             = smpi_comm_size(comm);
223   /* Gather all colors and keys on rank 0 */
224   int* sendbuf = xbt_new(int, 2);
225   sendbuf[0] = color;
226   sendbuf[1] = key;
227   if(rank == 0) {
228     recvbuf = xbt_new(int, 2 * size);
229   } else {
230     recvbuf = nullptr;
231   }
232   smpi_mpi_gather(sendbuf, 2, MPI_INT, recvbuf, 2, MPI_INT, 0, comm);
233   xbt_free(sendbuf);
234   /* Do the actual job */
235   if(rank == 0) {
236     MPI_Group* group_snd = xbt_new(MPI_Group, size);
237     int* rankmap         = xbt_new(int, 2 * size);
238     for (int i = 0; i < size; i++) {
239       if (recvbuf[2 * i] != MPI_UNDEFINED) {
240         int count = 0;
241         for (int j = i + 1; j < size; j++) {
242           if(recvbuf[2 * i] == recvbuf[2 * j]) {
243             recvbuf[2 * j] = MPI_UNDEFINED;
244             rankmap[2 * count] = j;
245             rankmap[2 * count + 1] = recvbuf[2 * j + 1];
246             count++;
247           }
248         }
249         /* Add self in the group */
250         recvbuf[2 * i] = MPI_UNDEFINED;
251         rankmap[2 * count] = i;
252         rankmap[2 * count + 1] = recvbuf[2 * i + 1];
253         count++;
254         qsort(rankmap, count, 2 * sizeof(int), &smpi_compare_rankmap);
255         group_out = new simgrid::SMPI::Group(count);
256         if (i == 0) {
257           group_root = group_out; /* Save root's group */
258         }
259         for (int j = 0; j < count; j++) {
260           int index = group->index(rankmap[2 * j]);
261           group_out->set_mapping(index, j);
262         }
263         MPI_Request* requests = xbt_new(MPI_Request, count);
264         int reqs              = 0;
265         for (int j = 0; j < count; j++) {
266           if(rankmap[2 * j] != 0) {
267             group_snd[reqs]=new simgrid::SMPI::Group(group_out);
268             requests[reqs] = smpi_mpi_isend(&(group_snd[reqs]), 1, MPI_PTR, rankmap[2 * j], system_tag, comm);
269             reqs++;
270           }
271         }
272         if(i != 0) {
273           group_out->destroy();
274         }
275         smpi_mpi_waitall(reqs, requests, MPI_STATUS_IGNORE);
276         xbt_free(requests);
277       }
278     }
279     xbt_free(recvbuf);
280     xbt_free(rankmap);
281     xbt_free(group_snd);
282     group_out = group_root; /* exit with root's group */
283   } else {
284     if(color != MPI_UNDEFINED) {
285       smpi_mpi_recv(&group_out, 1, MPI_PTR, 0, system_tag, comm, MPI_STATUS_IGNORE);
286     } /* otherwise, exit with group_out == nullptr */
287   }
288   return group_out!=nullptr ? smpi_comm_new(group_out, nullptr) : MPI_COMM_NULL;
289 }
290
291 void smpi_comm_use(MPI_Comm comm){
292   if (comm == MPI_COMM_UNINITIALIZED)
293     comm = smpi_process_comm_world();
294   comm->group->use();
295   comm->refcount++;
296 }
297
298 void smpi_comm_cleanup_attributes(MPI_Comm comm){
299   if(comm->attributes !=nullptr){
300     xbt_dict_cursor_t cursor = nullptr;
301     char* key;
302     void* value;
303     int flag;
304     xbt_dict_foreach (comm->attributes, cursor, key, value) {
305       smpi_comm_key_elem elem = static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null(smpi_comm_keyvals, key));
306       if (elem != nullptr && elem->delete_fn != nullptr)
307         elem->delete_fn(comm, atoi(key), value, &flag);
308     }
309     xbt_dict_free(&comm->attributes);
310   }
311 }
312
313 void smpi_comm_cleanup_smp(MPI_Comm comm){
314   if (comm->intra_comm != MPI_COMM_NULL)
315     smpi_comm_unuse(comm->intra_comm);
316   if (comm->leaders_comm != MPI_COMM_NULL)
317     smpi_comm_unuse(comm->leaders_comm);
318   if (comm->non_uniform_map != nullptr)
319     xbt_free(comm->non_uniform_map);
320   if (comm->leaders_map != nullptr)
321     xbt_free(comm->leaders_map);
322 }
323
324 void smpi_comm_unuse(MPI_Comm comm){
325   if (comm == MPI_COMM_UNINITIALIZED)
326     comm = smpi_process_comm_world();
327   comm->refcount--;
328   comm->group->unuse();
329
330   if(comm->refcount==0){
331     smpi_comm_cleanup_smp(comm);
332     smpi_comm_cleanup_attributes(comm);
333     xbt_free(comm);
334   }
335 }
336
337 static int compare_ints (const void *a, const void *b)
338 {
339   const int *da = static_cast<const int *>(a);
340   const int *db = static_cast<const int *>(b);
341
342   return static_cast<int>(*da > *db) - static_cast<int>(*da < *db);
343 }
344
345 void smpi_comm_init_smp(MPI_Comm comm){
346   int leader = -1;
347
348   if (comm == MPI_COMM_UNINITIALIZED)
349     comm = smpi_process_comm_world();
350
351   int comm_size =smpi_comm_size(comm);
352   
353   // If we are in replay - perform an ugly hack  
354   // tell SimGrid we are not in replay for a while, because we need the buffers to be copied for the following calls
355   bool replaying = false; //cache data to set it back again after
356   if(smpi_process_get_replaying()){
357    replaying=true;
358    smpi_process_set_replaying(false);
359   }
360
361   if(smpi_privatize_global_variables){ //we need to switch as the called function may silently touch global variables
362      smpi_switch_data_segment(smpi_process_index());
363    }
364   //identify neighbours in comm
365   //get the indexes of all processes sharing the same simix host
366   xbt_swag_t process_list = SIMIX_host_self()->processes();
367   int intra_comm_size = 0;
368   int i =0;
369   int min_index=INT_MAX;//the minimum index will be the leader
370   smx_actor_t process = nullptr;
371   xbt_swag_foreach(process, process_list) {
372     int index = process->pid -1;
373
374     if(smpi_comm_group(comm)->rank(index)!=MPI_UNDEFINED){
375         intra_comm_size++;
376       //the process is in the comm
377       if(index < min_index)
378         min_index=index;
379       i++;
380     }
381   }
382   XBT_DEBUG("number of processes deployed on my node : %d", intra_comm_size);
383   MPI_Group group_intra = new simgrid::SMPI::Group(intra_comm_size);
384   i=0;
385   process = nullptr;
386   xbt_swag_foreach(process, process_list) {
387     int index = process->pid -1;
388     if(smpi_comm_group(comm)->rank(index)!=MPI_UNDEFINED){
389       group_intra->set_mapping(index, i);
390       i++;
391     }
392   }
393
394   MPI_Comm comm_intra = smpi_comm_new(group_intra, nullptr);
395   leader=min_index;
396
397   int * leaders_map= static_cast<int*>(xbt_malloc0(sizeof(int)*comm_size));
398   int * leader_list= static_cast<int*>(xbt_malloc0(sizeof(int)*comm_size));
399   for(i=0; i<comm_size; i++){
400       leader_list[i]=-1;
401   }
402
403   smpi_coll_tuned_allgather_mpich(&leader, 1, MPI_INT , leaders_map, 1, MPI_INT, comm);
404
405   if(smpi_privatize_global_variables){ //we need to switch as the called function may silently touch global variables
406      smpi_switch_data_segment(smpi_process_index());
407    }
408
409   if(comm->leaders_map==nullptr){
410     comm->leaders_map= leaders_map;
411   }else{
412     xbt_free(leaders_map);
413   }
414   int j=0;
415   int leader_group_size = 0;
416   for(i=0; i<comm_size; i++){
417       int already_done=0;
418       for(j=0;j<leader_group_size; j++){
419         if(comm->leaders_map[i]==leader_list[j]){
420             already_done=1;
421         }
422       }
423       if(already_done==0){
424         leader_list[leader_group_size]=comm->leaders_map[i];
425         leader_group_size++;
426       }
427   }
428   qsort(leader_list, leader_group_size, sizeof(int),compare_ints);
429
430   MPI_Group leaders_group = new simgrid::SMPI::Group(leader_group_size);
431
432   MPI_Comm leader_comm = MPI_COMM_NULL;
433   if(MPI_COMM_WORLD!=MPI_COMM_UNINITIALIZED && comm!=MPI_COMM_WORLD){
434     //create leader_communicator
435     for (i=0; i< leader_group_size;i++)
436       leaders_group->set_mapping(leader_list[i], i);
437     leader_comm = smpi_comm_new(leaders_group, nullptr);
438     smpi_comm_set_leaders_comm(comm, leader_comm);
439     smpi_comm_set_intra_comm(comm, comm_intra);
440
441    //create intracommunicator
442   }else{
443     for (i=0; i< leader_group_size;i++)
444       leaders_group->set_mapping(leader_list[i], i);
445
446     if(smpi_comm_get_leaders_comm(comm)==MPI_COMM_NULL){
447       leader_comm = smpi_comm_new(leaders_group, nullptr);
448       smpi_comm_set_leaders_comm(comm, leader_comm);
449     }else{
450       leader_comm=smpi_comm_get_leaders_comm(comm);
451       leaders_group->unuse();
452     }
453     smpi_process_set_comm_intra(comm_intra);
454   }
455
456   int is_uniform = 1;
457
458   // Are the nodes uniform ? = same number of process/node
459   int my_local_size=smpi_comm_size(comm_intra);
460   if(smpi_comm_rank(comm_intra)==0) {
461     int* non_uniform_map = xbt_new0(int,leader_group_size);
462     smpi_coll_tuned_allgather_mpich(&my_local_size, 1, MPI_INT,
463         non_uniform_map, 1, MPI_INT, leader_comm);
464     for(i=0; i < leader_group_size; i++) {
465       if(non_uniform_map[0] != non_uniform_map[i]) {
466         is_uniform = 0;
467         break;
468       }
469     }
470     if(is_uniform==0 && smpi_comm_is_uniform(comm)!=0){
471         comm->non_uniform_map= non_uniform_map;
472     }else{
473         xbt_free(non_uniform_map);
474     }
475     comm->is_uniform=is_uniform;
476   }
477   smpi_coll_tuned_bcast_mpich(&(comm->is_uniform),1, MPI_INT, 0, comm_intra );
478
479   if(smpi_privatize_global_variables){ //we need to switch as the called function may silently touch global variables
480      smpi_switch_data_segment(smpi_process_index());
481    }
482   // Are the ranks blocked ? = allocated contiguously on the SMP nodes
483   int is_blocked=1;
484   int prev=smpi_comm_group(comm)->rank(smpi_comm_group(comm_intra)->index(0));
485     for (i=1; i<my_local_size; i++){
486       int that=smpi_comm_group(comm)->rank(smpi_comm_group(comm_intra)->index(i));
487       if(that!=prev+1){
488         is_blocked=0;
489         break;
490       }
491       prev = that;
492   }
493
494   int global_blocked;
495   smpi_mpi_allreduce(&is_blocked, &(global_blocked), 1, MPI_INT, MPI_LAND, comm);
496
497   if(MPI_COMM_WORLD==MPI_COMM_UNINITIALIZED || comm==MPI_COMM_WORLD){
498     if(smpi_comm_rank(comm)==0){
499         comm->is_blocked=global_blocked;
500     }
501   }else{
502     comm->is_blocked=global_blocked;
503   }
504   xbt_free(leader_list);
505   
506   if(replaying)
507     smpi_process_set_replaying(true); 
508 }
509
510 int smpi_comm_attr_delete(MPI_Comm comm, int keyval){
511   smpi_comm_key_elem elem =
512      static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
513   if(elem==nullptr)
514     return MPI_ERR_ARG;
515   if(elem->delete_fn!=MPI_NULL_DELETE_FN){
516     void* value = nullptr;
517     int flag;
518     if(smpi_comm_attr_get(comm, keyval, &value, &flag)==MPI_SUCCESS){
519       int ret = elem->delete_fn(comm, keyval, value, &flag);
520       if(ret!=MPI_SUCCESS) 
521         return ret;
522     }
523   }
524   if(comm->attributes==nullptr)
525     return MPI_ERR_ARG;
526
527   xbt_dict_remove_ext(comm->attributes, reinterpret_cast<const char*>(&keyval), sizeof(int));
528   return MPI_SUCCESS;
529 }
530
531 int smpi_comm_attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag){
532   smpi_comm_key_elem elem =
533     static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
534   if(elem==nullptr)
535     return MPI_ERR_ARG;
536   if(comm->attributes==nullptr){
537     *flag=0;
538     return MPI_SUCCESS;
539   }
540   try {
541     *static_cast<void**>(attr_value) =
542         xbt_dict_get_ext(comm->attributes, reinterpret_cast<const char*>(&keyval), sizeof(int));
543     *flag=1;
544   }
545   catch (xbt_ex& ex) {
546     *flag=0;
547   }
548   return MPI_SUCCESS;
549 }
550
551 int smpi_comm_attr_put(MPI_Comm comm, int keyval, void* attr_value){
552   if(smpi_comm_keyvals==nullptr)
553     smpi_comm_keyvals = xbt_dict_new_homogeneous(nullptr);
554   smpi_comm_key_elem elem =
555     static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals,  reinterpret_cast<const char*>(&keyval), sizeof(int)));
556   if(elem==nullptr)
557     return MPI_ERR_ARG;
558   int flag;
559   void* value = nullptr;
560   smpi_comm_attr_get(comm, keyval, &value, &flag);
561   if(flag!=0 && elem->delete_fn!=MPI_NULL_DELETE_FN){
562     int ret = elem->delete_fn(comm, keyval, value, &flag);
563     if(ret!=MPI_SUCCESS) 
564       return ret;
565   }
566   if(comm->attributes==nullptr)
567     comm->attributes = xbt_dict_new_homogeneous(nullptr);
568
569   xbt_dict_set_ext(comm->attributes,  reinterpret_cast<const char*>(&keyval), sizeof(int), attr_value, nullptr);
570   return MPI_SUCCESS;
571 }
572
573 int smpi_comm_keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval,
574                             void* extra_state){
575   if(smpi_comm_keyvals==nullptr)
576     smpi_comm_keyvals = xbt_dict_new_homogeneous(nullptr);
577
578   smpi_comm_key_elem value = static_cast<smpi_comm_key_elem>(xbt_new0(s_smpi_mpi_comm_key_elem_t,1));
579
580   value->copy_fn=copy_fn;
581   value->delete_fn=delete_fn;
582
583   *keyval = comm_keyval_id;
584   xbt_dict_set_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(keyval), sizeof(int),static_cast<void*>(value), nullptr);
585   comm_keyval_id++;
586   return MPI_SUCCESS;
587 }
588
589 int smpi_comm_keyval_free(int* keyval){
590   smpi_comm_key_elem elem =
591      static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals,  reinterpret_cast<const char*>(keyval), sizeof(int)));
592   if(elem==nullptr)
593     return MPI_ERR_ARG;
594   xbt_dict_remove_ext(smpi_comm_keyvals,  reinterpret_cast<const char*>(keyval), sizeof(int));
595   xbt_free(elem);
596   return MPI_SUCCESS;
597 }