Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a huge variety of not yet impelmented functions, to compile MPICH3 test suite...
[simgrid.git] / src / smpi / smpi_pmpi.c
1 /* Copyright (c) 2007, 2008, 2009, 2010. 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 "private.h"
8 #include "smpi_mpi_dt_private.h"
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_pmpi, smpi,
11                                 "Logging specific to SMPI (pmpi)");
12
13 #ifdef HAVE_TRACING
14 //this function need to be here because of the calls to smpi_bench
15 void TRACE_smpi_set_category(const char *category)
16 {
17   //need to end bench otherwise categories for execution tasks are wrong
18   smpi_bench_end();
19   TRACE_internal_smpi_set_category (category);
20   //begin bench after changing process's category
21   smpi_bench_begin();
22 }
23 #endif
24
25 /* PMPI User level calls */
26
27 int PMPI_Init(int *argc, char ***argv)
28 {
29   smpi_process_init(argc, argv);
30 #ifdef HAVE_TRACING
31   int rank = smpi_process_index();
32   TRACE_smpi_init(rank);
33
34   TRACE_smpi_computing_init(rank);
35 #endif
36   smpi_bench_begin();
37   return MPI_SUCCESS;
38 }
39
40 int PMPI_Finalize(void)
41 {
42   smpi_process_finalize();
43   smpi_bench_end();
44 #ifdef HAVE_TRACING
45   int rank = smpi_process_index();
46   TRACE_smpi_computing_out(rank);
47   TRACE_smpi_finalize(smpi_process_index());
48 #endif
49   smpi_process_destroy();
50   return MPI_SUCCESS;
51 }
52
53 int PMPI_Finalized(int* flag)
54 {
55   *flag=smpi_process_finalized();
56   return MPI_SUCCESS;
57 }
58
59 int PMPI_Get_version (int *version,int *subversion){
60   *version = MPI_VERSION;
61   *subversion= MPI_SUBVERSION;
62   return MPI_SUCCESS;
63 }
64
65 int PMPI_Get_library_version (char *version,int *len){
66   int retval = MPI_SUCCESS;
67   smpi_bench_end();
68   snprintf(version,MPI_MAX_LIBRARY_VERSION_STRING,"SMPI Version %d.%d. Copyright The Simgrid Team 2007-2013",SIMGRID_VERSION_MAJOR,
69           SIMGRID_VERSION_MINOR);
70   *len = strlen(version) > MPI_MAX_LIBRARY_VERSION_STRING ? MPI_MAX_LIBRARY_VERSION_STRING : strlen(version);
71   smpi_bench_begin();
72   return retval;
73 }
74
75 int PMPI_Init_thread(int *argc, char ***argv, int required, int *provided)
76 {
77   if (provided != NULL) {
78     *provided = MPI_THREAD_MULTIPLE;
79   }
80   return MPI_Init(argc, argv);
81 }
82
83 int PMPI_Query_thread(int *provided)
84 {
85   int retval;
86
87   smpi_bench_end();
88   if (provided == NULL) {
89     retval = MPI_ERR_ARG;
90   } else {
91     *provided = MPI_THREAD_MULTIPLE;
92     retval = MPI_SUCCESS;
93   }
94   smpi_bench_begin();
95   return retval;
96 }
97
98 int PMPI_Is_thread_main(int *flag)
99 {
100   int retval;
101
102   smpi_bench_end();
103   if (flag == NULL) {
104     retval = MPI_ERR_ARG;
105   } else {
106     *flag = smpi_process_index() == 0;
107     retval = MPI_SUCCESS;
108   }
109   smpi_bench_begin();
110   return retval;
111 }
112
113 int PMPI_Abort(MPI_Comm comm, int errorcode)
114 {
115   smpi_bench_end();
116   smpi_process_destroy();
117 #ifdef HAVE_TRACING
118   int rank = smpi_process_index();
119   TRACE_smpi_computing_out(rank);
120 #endif
121   // FIXME: should kill all processes in comm instead
122   simcall_process_kill(SIMIX_process_self());
123   return MPI_SUCCESS;
124 }
125
126 double PMPI_Wtime(void)
127 {
128   double time;
129
130   smpi_bench_end();
131   time = SIMIX_get_clock();
132   smpi_bench_begin();
133   return time;
134 }
135 extern double sg_maxmin_precision;
136 double PMPI_Wtick(void)
137 {
138   return sg_maxmin_precision;
139 }
140
141 int PMPI_Address(void *location, MPI_Aint * address)
142 {
143   int retval;
144
145   smpi_bench_end();
146   if (!address) {
147     retval = MPI_ERR_ARG;
148   } else {
149     *address = (MPI_Aint) location;
150     retval = MPI_SUCCESS;
151   }
152   smpi_bench_begin();
153   return retval;
154 }
155
156 int PMPI_Get_address(void *location, MPI_Aint * address)
157 {
158   return PMPI_Address(location, address);
159 }
160
161 int PMPI_Type_free(MPI_Datatype * datatype)
162 {
163   int retval;
164
165   smpi_bench_end();
166   if (!datatype) {
167     retval = MPI_ERR_ARG;
168   } else {
169     smpi_datatype_free(datatype);
170     retval = MPI_SUCCESS;
171   }
172   smpi_bench_begin();
173   return retval;
174 }
175
176 int PMPI_Type_size(MPI_Datatype datatype, int *size)
177 {
178   int retval;
179
180   smpi_bench_end();
181   if (datatype == MPI_DATATYPE_NULL) {
182     retval = MPI_ERR_TYPE;
183   } else if (size == NULL) {
184     retval = MPI_ERR_ARG;
185   } else {
186     *size = (int) smpi_datatype_size(datatype);
187     retval = MPI_SUCCESS;
188   }
189   smpi_bench_begin();
190   return retval;
191 }
192
193 int PMPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
194 {
195   int retval;
196
197   smpi_bench_end();
198   if (datatype == MPI_DATATYPE_NULL) {
199     retval = MPI_ERR_TYPE;
200   } else if (lb == NULL || extent == NULL) {
201     retval = MPI_ERR_ARG;
202   } else {
203     retval = smpi_datatype_extent(datatype, lb, extent);
204   }
205   smpi_bench_begin();
206   return retval;
207 }
208
209 int PMPI_Type_get_true_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
210 {
211   return PMPI_Type_get_extent(datatype, lb, extent);
212 }
213
214 int PMPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent)
215 {
216   int retval;
217
218   smpi_bench_end();
219   if (datatype == MPI_DATATYPE_NULL) {
220     retval = MPI_ERR_TYPE;
221   } else if (extent == NULL) {
222     retval = MPI_ERR_ARG;
223   } else {
224     *extent = smpi_datatype_get_extent(datatype);
225     retval = MPI_SUCCESS;
226   }
227   smpi_bench_begin();
228   return retval;
229 }
230
231 int PMPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp)
232 {
233   int retval;
234
235   smpi_bench_end();
236   if (datatype == MPI_DATATYPE_NULL) {
237     retval = MPI_ERR_TYPE;
238   } else if (disp == NULL) {
239     retval = MPI_ERR_ARG;
240   } else {
241     *disp = smpi_datatype_lb(datatype);
242     retval = MPI_SUCCESS;
243   }
244   smpi_bench_begin();
245   return retval;
246 }
247
248 int PMPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp)
249 {
250   int retval;
251
252   smpi_bench_end();
253   if (datatype == MPI_DATATYPE_NULL) {
254     retval = MPI_ERR_TYPE;
255   } else if (disp == NULL) {
256     retval = MPI_ERR_ARG;
257   } else {
258     *disp = smpi_datatype_ub(datatype);
259     retval = MPI_SUCCESS;
260   }
261   smpi_bench_begin();
262   return retval;
263 }
264
265 int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
266 {
267   int retval;
268
269   smpi_bench_end();
270   if (function == NULL || op == NULL) {
271     retval = MPI_ERR_ARG;
272   } else {
273     *op = smpi_op_new(function, commute);
274     retval = MPI_SUCCESS;
275   }
276   smpi_bench_begin();
277   return retval;
278 }
279
280 int PMPI_Op_free(MPI_Op * op)
281 {
282   int retval;
283
284   smpi_bench_end();
285   if (op == NULL) {
286     retval = MPI_ERR_ARG;
287   } else if (*op == MPI_OP_NULL) {
288     retval = MPI_ERR_OP;
289   } else {
290     smpi_op_destroy(*op);
291     *op = MPI_OP_NULL;
292     retval = MPI_SUCCESS;
293   }
294   smpi_bench_begin();
295   return retval;
296 }
297
298 int PMPI_Group_free(MPI_Group * group)
299 {
300   int retval;
301
302   smpi_bench_end();
303   if (group == NULL) {
304     retval = MPI_ERR_ARG;
305   } else {
306     if(*group!= smpi_comm_group(MPI_COMM_WORLD))// do not free the group of the comm_world
307     smpi_group_destroy(*group);
308     *group = MPI_GROUP_NULL;
309     retval = MPI_SUCCESS;
310   }
311   smpi_bench_begin();
312   return retval;
313 }
314
315 int PMPI_Group_size(MPI_Group group, int *size)
316 {
317   int retval;
318
319   smpi_bench_end();
320   if (group == MPI_GROUP_NULL) {
321     retval = MPI_ERR_GROUP;
322   } else if (size == NULL) {
323     retval = MPI_ERR_ARG;
324   } else {
325     *size = smpi_group_size(group);
326     retval = MPI_SUCCESS;
327   }
328   smpi_bench_begin();
329   return retval;
330 }
331
332 int PMPI_Group_rank(MPI_Group group, int *rank)
333 {
334   int retval;
335
336   smpi_bench_end();
337   if (group == MPI_GROUP_NULL) {
338     retval = MPI_ERR_GROUP;
339   } else if (rank == NULL) {
340     retval = MPI_ERR_ARG;
341   } else {
342     *rank = smpi_group_rank(group, smpi_process_index());
343     retval = MPI_SUCCESS;
344   }
345   smpi_bench_begin();
346   return retval;
347 }
348
349 int PMPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
350                               MPI_Group group2, int *ranks2)
351 {
352   int retval, i, index;
353
354   smpi_bench_end();
355   if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
356     retval = MPI_ERR_GROUP;
357   } else {
358     for (i = 0; i < n; i++) {
359       index = smpi_group_index(group1, ranks1[i]);
360       ranks2[i] = smpi_group_rank(group2, index);
361     }
362     retval = MPI_SUCCESS;
363   }
364   smpi_bench_begin();
365   return retval;
366 }
367
368 int PMPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result)
369 {
370   int retval;
371
372   smpi_bench_end();
373   if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
374     retval = MPI_ERR_GROUP;
375   } else if (result == NULL) {
376     retval = MPI_ERR_ARG;
377   } else {
378     *result = smpi_group_compare(group1, group2);
379     retval = MPI_SUCCESS;
380   }
381   smpi_bench_begin();
382   return retval;
383 }
384
385 int PMPI_Group_union(MPI_Group group1, MPI_Group group2,
386                     MPI_Group * newgroup)
387 {
388   int retval, i, proc1, proc2, size, size2;
389
390   smpi_bench_end();
391   if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
392     retval = MPI_ERR_GROUP;
393   } else if (newgroup == NULL) {
394     retval = MPI_ERR_ARG;
395   } else {
396     size = smpi_group_size(group1);
397     size2 = smpi_group_size(group2);
398     for (i = 0; i < size2; i++) {
399       proc2 = smpi_group_index(group2, i);
400       proc1 = smpi_group_rank(group1, proc2);
401       if (proc1 == MPI_UNDEFINED) {
402         size++;
403       }
404     }
405     if (size == 0) {
406       *newgroup = MPI_GROUP_EMPTY;
407     } else {
408       *newgroup = smpi_group_new(size);
409       size2 = smpi_group_size(group1);
410       for (i = 0; i < size2; i++) {
411         proc1 = smpi_group_index(group1, i);
412         smpi_group_set_mapping(*newgroup, proc1, i);
413       }
414       for (i = size2; i < size; i++) {
415         proc2 = smpi_group_index(group2, i - size2);
416         smpi_group_set_mapping(*newgroup, proc2, i);
417       }
418     }
419     smpi_group_use(*newgroup);
420     retval = MPI_SUCCESS;
421   }
422   smpi_bench_begin();
423   return retval;
424 }
425
426 int PMPI_Group_intersection(MPI_Group group1, MPI_Group group2,
427                            MPI_Group * newgroup)
428 {
429   int retval, i, proc1, proc2, size;
430
431   smpi_bench_end();
432   if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
433     retval = MPI_ERR_GROUP;
434   } else if (newgroup == NULL) {
435     retval = MPI_ERR_ARG;
436   } else {
437     size = smpi_group_size(group2);
438     for (i = 0; i < size; i++) {
439       proc2 = smpi_group_index(group2, i);
440       proc1 = smpi_group_rank(group1, proc2);
441       if (proc1 == MPI_UNDEFINED) {
442         size--;
443       }
444     }
445     if (size == 0) {
446       *newgroup = MPI_GROUP_EMPTY;
447     } else {
448       *newgroup = smpi_group_new(size);
449       int j=0;
450       for (i = 0; i < smpi_group_size(group2); i++) {
451         proc2 = smpi_group_index(group2, i);
452         proc1 = smpi_group_rank(group1, proc2);
453         if (proc1 != MPI_UNDEFINED) {
454           smpi_group_set_mapping(*newgroup, proc2, j);
455           j++;
456         }
457       }
458     }
459     smpi_group_use(*newgroup);
460     retval = MPI_SUCCESS;
461   }
462   smpi_bench_begin();
463   return retval;
464 }
465
466 int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgroup)
467 {
468   int retval, i, proc1, proc2, size, size2;
469
470   smpi_bench_end();
471   if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
472     retval = MPI_ERR_GROUP;
473   } else if (newgroup == NULL) {
474     retval = MPI_ERR_ARG;
475   } else {
476     size = size2 = smpi_group_size(group1);
477     for (i = 0; i < size2; i++) {
478       proc1 = smpi_group_index(group1, i);
479       proc2 = smpi_group_rank(group2, proc1);
480       if (proc2 != MPI_UNDEFINED) {
481         size--;
482       }
483     }
484     if (size == 0) {
485       *newgroup = MPI_GROUP_EMPTY;
486     } else {
487       *newgroup = smpi_group_new(size);
488       for (i = 0; i < size2; i++) {
489         proc1 = smpi_group_index(group1, i);
490         proc2 = smpi_group_rank(group2, proc1);
491         if (proc2 == MPI_UNDEFINED) {
492           smpi_group_set_mapping(*newgroup, proc1, i);
493         }
494       }
495     }
496     smpi_group_use(*newgroup);
497     retval = MPI_SUCCESS;
498   }
499   smpi_bench_begin();
500   return retval;
501 }
502
503 int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
504 {
505   int retval, i, index;
506
507   smpi_bench_end();
508   if (group == MPI_GROUP_NULL) {
509     retval = MPI_ERR_GROUP;
510   } else if (newgroup == NULL) {
511     retval = MPI_ERR_ARG;
512   } else {
513     if (n == 0) {
514       *newgroup = MPI_GROUP_EMPTY;
515     } else if (n == smpi_group_size(group)) {
516       *newgroup = group;
517     } else {
518       *newgroup = smpi_group_new(n);
519       for (i = 0; i < n; i++) {
520         index = smpi_group_index(group, ranks[i]);
521         smpi_group_set_mapping(*newgroup, index, i);
522       }
523     }
524     smpi_group_use(*newgroup);
525     retval = MPI_SUCCESS;
526   }
527   smpi_bench_begin();
528   return retval;
529 }
530
531 int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
532 {
533   int retval, i, j, newsize, oldsize, index;
534
535   smpi_bench_end();
536   if (group == MPI_GROUP_NULL) {
537     retval = MPI_ERR_GROUP;
538   } else if (newgroup == NULL) {
539     retval = MPI_ERR_ARG;
540   } else {
541     if (n == 0) {
542       *newgroup = group;
543     } else if (n == smpi_group_size(group)) {
544       *newgroup = MPI_GROUP_EMPTY;
545     } else {
546       oldsize=smpi_group_size(group);
547       newsize = oldsize - n;
548       *newgroup = smpi_group_new(newsize);
549
550       int* to_exclude=xbt_new(int, smpi_group_size(group));
551       for(i=0; i<oldsize; i++)
552         to_exclude[i]=0;
553       for(i=0; i<n; i++)
554         to_exclude[ranks[i]]=1;
555
556       j=0;
557       for(i=0; i<oldsize; i++){
558         if(to_exclude[i]==0){
559           index = smpi_group_index(group, i);
560           smpi_group_set_mapping(*newgroup, index, j);
561           j++;
562         }
563       }
564
565       xbt_free(to_exclude);
566     }
567     smpi_group_use(*newgroup);
568     retval = MPI_SUCCESS;
569   }
570   smpi_bench_begin();
571   return retval;
572 }
573
574 int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
575                          MPI_Group * newgroup)
576 {
577   int retval, i, j, rank, size, index;
578
579   smpi_bench_end();
580   if (group == MPI_GROUP_NULL) {
581     retval = MPI_ERR_GROUP;
582   } else if (newgroup == NULL) {
583     retval = MPI_ERR_ARG;
584   } else {
585     if (n == 0) {
586       *newgroup = MPI_GROUP_EMPTY;
587     } else {
588       size = 0;
589       for (i = 0; i < n; i++) {
590         for (rank = ranges[i][0];       /* First */
591              rank >= 0 && rank <= ranges[i][1]; /* Last */
592              rank += ranges[i][2] /* Stride */ ) {
593           size++;
594         }
595       }
596       if (size == smpi_group_size(group)) {
597         *newgroup = group;
598       } else {
599         *newgroup = smpi_group_new(size);
600         j = 0;
601         for (i = 0; i < n; i++) {
602           for (rank = ranges[i][0];     /* First */
603                rank >= 0 && rank <= ranges[i][1];       /* Last */
604                rank += ranges[i][2] /* Stride */ ) {
605             index = smpi_group_index(group, rank);
606             smpi_group_set_mapping(*newgroup, index, j);
607             j++;
608           }
609         }
610       }
611     }
612     smpi_group_use(*newgroup);
613     retval = MPI_SUCCESS;
614   }
615   smpi_bench_begin();
616   return retval;
617 }
618
619 int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
620                          MPI_Group * newgroup)
621 {
622   int retval, i, newrank, rank, size, index, add;
623
624   smpi_bench_end();
625   if (group == MPI_GROUP_NULL) {
626     retval = MPI_ERR_GROUP;
627   } else if (newgroup == NULL) {
628     retval = MPI_ERR_ARG;
629   } else {
630     if (n == 0) {
631       *newgroup = group;
632     } else {
633       size = smpi_group_size(group);
634       for (i = 0; i < n; i++) {
635         for (rank = ranges[i][0];       /* First */
636              rank >= 0 && rank <= ranges[i][1]; /* Last */
637              rank += ranges[i][2] /* Stride */ ) {
638           size--;
639         }
640       }
641       if (size == 0) {
642         *newgroup = MPI_GROUP_EMPTY;
643       } else {
644         *newgroup = smpi_group_new(size);
645         newrank = 0;
646         while (newrank < size) {
647           for (i = 0; i < n; i++) {
648             add = 1;
649             for (rank = ranges[i][0];   /* First */
650                  rank >= 0 && rank <= ranges[i][1];     /* Last */
651                  rank += ranges[i][2] /* Stride */ ) {
652               if (rank == newrank) {
653                 add = 0;
654                 break;
655               }
656             }
657             if (add == 1) {
658               index = smpi_group_index(group, newrank);
659               smpi_group_set_mapping(*newgroup, index, newrank);
660             }
661           }
662           newrank++; //added to avoid looping, need to be checked ..
663         }
664       }
665     }
666     smpi_group_use(*newgroup);
667     retval = MPI_SUCCESS;
668   }
669   smpi_bench_begin();
670   return retval;
671 }
672
673 int PMPI_Comm_rank(MPI_Comm comm, int *rank)
674 {
675   int retval;
676
677   smpi_bench_end();
678   if (comm == MPI_COMM_NULL) {
679     retval = MPI_ERR_COMM;
680   } else if (rank == NULL) {
681     retval = MPI_ERR_ARG;
682   } else {
683     *rank = smpi_comm_rank(comm);
684     retval = MPI_SUCCESS;
685   }
686   smpi_bench_begin();
687   return retval;
688 }
689
690 int PMPI_Comm_size(MPI_Comm comm, int *size)
691 {
692   int retval;
693
694   smpi_bench_end();
695   if (comm == MPI_COMM_NULL) {
696     retval = MPI_ERR_COMM;
697   } else if (size == NULL) {
698     retval = MPI_ERR_ARG;
699   } else {
700     *size = smpi_comm_size(comm);
701     retval = MPI_SUCCESS;
702   }
703   smpi_bench_begin();
704   return retval;
705 }
706
707 int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len)
708 {
709   int retval;
710
711   smpi_bench_end();
712   if (comm == MPI_COMM_NULL)  {
713     retval = MPI_ERR_COMM;
714   } else if (name == NULL || len == NULL)  {
715     retval = MPI_ERR_ARG;
716   } else {
717     smpi_comm_get_name(comm, name, len);
718     retval = MPI_SUCCESS;
719   }
720   smpi_bench_begin();
721   return retval;
722 }
723
724 int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
725 {
726   int retval;
727
728   smpi_bench_end();
729   if (comm == MPI_COMM_NULL) {
730     retval = MPI_ERR_COMM;
731   } else if (group == NULL) {
732     retval = MPI_ERR_ARG;
733   } else {
734     *group = smpi_comm_group(comm);
735     retval = MPI_SUCCESS;
736   }
737   smpi_bench_begin();
738   return retval;
739 }
740
741 int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
742 {
743   int retval;
744
745   smpi_bench_end();
746   if (comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) {
747     retval = MPI_ERR_COMM;
748   } else if (result == NULL) {
749     retval = MPI_ERR_ARG;
750   } else {
751     if (comm1 == comm2) {       /* Same communicators means same groups */
752       *result = MPI_IDENT;
753     } else {
754       *result =
755           smpi_group_compare(smpi_comm_group(comm1),
756                              smpi_comm_group(comm2));
757       if (*result == MPI_IDENT) {
758         *result = MPI_CONGRUENT;
759       }
760     }
761     retval = MPI_SUCCESS;
762   }
763   smpi_bench_begin();
764   return retval;
765 }
766
767 int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm)
768 {
769   int retval;
770
771   smpi_bench_end();
772   if (comm == MPI_COMM_NULL) {
773     retval = MPI_ERR_COMM;
774   } else if (newcomm == NULL) {
775     retval = MPI_ERR_ARG;
776   } else {
777     *newcomm = smpi_comm_new(smpi_comm_group(comm));
778     retval = MPI_SUCCESS;
779   }
780   smpi_bench_begin();
781   return retval;
782 }
783
784 int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
785 {
786   int retval;
787
788   smpi_bench_end();
789   if (comm == MPI_COMM_NULL) {
790     retval = MPI_ERR_COMM;
791   } else if (group == MPI_GROUP_NULL) {
792     retval = MPI_ERR_GROUP;
793   } else if (newcomm == NULL) {
794     retval = MPI_ERR_ARG;
795   } else {
796     *newcomm = smpi_comm_new(group);
797     retval = MPI_SUCCESS;
798   }
799   smpi_bench_begin();
800   return retval;
801 }
802
803 int PMPI_Comm_free(MPI_Comm * comm)
804 {
805   int retval;
806
807   smpi_bench_end();
808   if (comm == NULL) {
809     retval = MPI_ERR_ARG;
810   } else if (*comm == MPI_COMM_NULL) {
811     retval = MPI_ERR_COMM;
812   } else {
813     smpi_comm_destroy(*comm);
814     *comm = MPI_COMM_NULL;
815     retval = MPI_SUCCESS;
816   }
817   smpi_bench_begin();
818   return retval;
819 }
820
821 int PMPI_Comm_disconnect(MPI_Comm * comm)
822 {
823   /* TODO: wait until all communication in comm are done */
824   int retval;
825
826   smpi_bench_end();
827   if (comm == NULL) {
828     retval = MPI_ERR_ARG;
829   } else if (*comm == MPI_COMM_NULL) {
830     retval = MPI_ERR_COMM;
831   } else {
832     smpi_comm_destroy(*comm);
833     *comm = MPI_COMM_NULL;
834     retval = MPI_SUCCESS;
835   }
836   smpi_bench_begin();
837   return retval;
838 }
839
840 int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out)
841 {
842   int retval;
843
844   smpi_bench_end();
845   if (comm_out == NULL) {
846     retval = MPI_ERR_ARG;
847   } else if (comm == MPI_COMM_NULL) {
848     retval = MPI_ERR_COMM;
849   } else {
850     *comm_out = smpi_comm_split(comm, color, key);
851     retval = MPI_SUCCESS;
852   }
853   smpi_bench_begin();
854   return retval;
855 }
856
857 int PMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst,
858                   int tag, MPI_Comm comm, MPI_Request * request)
859 {
860   int retval;
861
862   smpi_bench_end();
863   if (request == NULL) {
864     retval = MPI_ERR_ARG;
865   } else if (comm == MPI_COMM_NULL) {
866     retval = MPI_ERR_COMM;
867   } else if (dst == MPI_PROC_NULL) {
868     retval = MPI_SUCCESS;
869   } else {
870     *request = smpi_mpi_send_init(buf, count, datatype, dst, tag, comm);
871     retval = MPI_SUCCESS;
872   }
873   smpi_bench_begin();
874   return retval;
875 }
876
877 int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src,
878                   int tag, MPI_Comm comm, MPI_Request * request)
879 {
880   int retval;
881
882   smpi_bench_end();
883   if (request == NULL) {
884     retval = MPI_ERR_ARG;
885   } else if (comm == MPI_COMM_NULL) {
886     retval = MPI_ERR_COMM;
887   } else if (src == MPI_PROC_NULL) {
888       retval = MPI_SUCCESS;
889   } else {
890     *request = smpi_mpi_recv_init(buf, count, datatype, src, tag, comm);
891     retval = MPI_SUCCESS;
892   }
893   smpi_bench_begin();
894   return retval;
895 }
896
897 int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) {
898   int retval;
899
900     smpi_bench_end();
901     if (request == NULL) {
902       retval = MPI_ERR_ARG;
903     } else if (comm == MPI_COMM_NULL) {
904       retval = MPI_ERR_COMM;
905     } else if (dst == MPI_PROC_NULL) {
906       retval = MPI_SUCCESS;
907     } else {
908       *request = smpi_mpi_ssend_init(buf, count, datatype, dst, tag, comm);
909       retval = MPI_SUCCESS;
910     }
911     smpi_bench_begin();
912     return retval;
913 }
914
915 int PMPI_Start(MPI_Request * request)
916 {
917   int retval;
918
919   smpi_bench_end();
920   if (request == NULL || *request == MPI_REQUEST_NULL) {
921     retval = MPI_ERR_ARG;
922   } else {
923     smpi_mpi_start(*request);
924     retval = MPI_SUCCESS;
925   }
926   smpi_bench_begin();
927   return retval;
928 }
929
930 int PMPI_Startall(int count, MPI_Request * requests)
931 {
932   int retval;
933
934   smpi_bench_end();
935   if (requests == NULL) {
936     retval = MPI_ERR_ARG;
937   } else {
938     smpi_mpi_startall(count, requests);
939     retval = MPI_SUCCESS;
940   }
941   smpi_bench_begin();
942   return retval;
943 }
944
945 int PMPI_Request_free(MPI_Request * request)
946 {
947   int retval;
948
949   smpi_bench_end();
950   if (*request == MPI_REQUEST_NULL) {
951     retval = MPI_ERR_ARG;
952   } else {
953     if((*request)->flags & PERSISTENT)(*request)->refcount--;
954     smpi_mpi_request_free(request);
955     retval = MPI_SUCCESS;
956   }
957   smpi_bench_begin();
958   return retval;
959 }
960
961 int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src,
962               int tag, MPI_Comm comm, MPI_Request * request)
963 {
964   int retval;
965
966   smpi_bench_end();
967
968   if (request == NULL) {
969     retval = MPI_ERR_ARG;
970   } else if (comm == MPI_COMM_NULL) {
971     retval = MPI_ERR_COMM;
972   } else if (src == MPI_PROC_NULL) {
973     *request = MPI_REQUEST_NULL;
974     retval = MPI_SUCCESS;
975   } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
976     retval = MPI_ERR_COMM;
977   } else if (count < 0) {
978     retval = MPI_ERR_COUNT;
979   } else if (buf==NULL && count > 0) {
980     retval = MPI_ERR_COUNT;
981   } else if (datatype == MPI_DATATYPE_NULL){
982     retval = MPI_ERR_TYPE;
983   } else if(tag<0 && tag !=  MPI_ANY_TAG){
984     retval = MPI_ERR_TAG;
985   } else {
986
987 #ifdef HAVE_TRACING
988   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
989   int src_traced = smpi_group_index(smpi_comm_group(comm), src);
990   TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
991 #endif
992
993     *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm);
994     retval = MPI_SUCCESS;
995
996 #ifdef HAVE_TRACING
997   TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
998   (*request)->recv = 1;
999 #endif
1000   }
1001
1002   smpi_bench_begin();
1003   return retval;
1004 }
1005
1006
1007 int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
1008               int tag, MPI_Comm comm, MPI_Request * request)
1009 {
1010   int retval;
1011
1012   smpi_bench_end();
1013   if (request == NULL) {
1014     retval = MPI_ERR_ARG;
1015   } else if (comm == MPI_COMM_NULL) {
1016     retval = MPI_ERR_COMM;
1017   } else if (dst == MPI_PROC_NULL) {
1018     *request = MPI_REQUEST_NULL;
1019     retval = MPI_SUCCESS;
1020   } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1021     retval = MPI_ERR_RANK;
1022   } else if (count < 0) {
1023     retval = MPI_ERR_COUNT;
1024   } else if (buf==NULL && count > 0) {
1025     retval = MPI_ERR_COUNT;
1026   } else if (datatype == MPI_DATATYPE_NULL){
1027     retval = MPI_ERR_TYPE;
1028   } else if(tag<0 && tag !=  MPI_ANY_TAG){
1029     retval = MPI_ERR_TAG;
1030   } else {
1031
1032 #ifdef HAVE_TRACING
1033   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1034   TRACE_smpi_computing_out(rank);
1035   int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1036   TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1037   TRACE_smpi_send(rank, rank, dst_traced);
1038 #endif
1039
1040     *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm);
1041     retval = MPI_SUCCESS;
1042
1043 #ifdef HAVE_TRACING
1044   TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1045   (*request)->send = 1;
1046   TRACE_smpi_computing_in(rank);
1047 #endif
1048   }
1049
1050   smpi_bench_begin();
1051   return retval;
1052 }
1053
1054 int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) {
1055   int retval;
1056
1057   smpi_bench_end();
1058   if (request == NULL) {
1059     retval = MPI_ERR_ARG;
1060   } else if (comm == MPI_COMM_NULL) {
1061     retval = MPI_ERR_COMM;
1062   } else if (dst == MPI_PROC_NULL) {
1063     *request = MPI_REQUEST_NULL;
1064     retval = MPI_SUCCESS;
1065   } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1066     retval = MPI_ERR_RANK;
1067   } else if (count < 0) {
1068     retval = MPI_ERR_COUNT;
1069   } else if (buf==NULL && count > 0) {
1070     retval = MPI_ERR_COUNT;
1071   } else if (datatype == MPI_DATATYPE_NULL){
1072     retval = MPI_ERR_TYPE;
1073   } else if(tag<0 && tag !=  MPI_ANY_TAG){
1074     retval = MPI_ERR_TAG;
1075   } else {
1076
1077 #ifdef HAVE_TRACING
1078   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1079   TRACE_smpi_computing_out(rank);
1080   int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1081   TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1082   TRACE_smpi_send(rank, rank, dst_traced);
1083 #endif
1084
1085     *request = smpi_mpi_issend(buf, count, datatype, dst, tag, comm);
1086     retval = MPI_SUCCESS;
1087
1088 #ifdef HAVE_TRACING
1089   TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1090   (*request)->send = 1;
1091   TRACE_smpi_computing_in(rank);
1092 #endif
1093   }
1094
1095   smpi_bench_begin();
1096   return retval;
1097 }
1098
1099 int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
1100              MPI_Comm comm, MPI_Status * status)
1101 {
1102   int retval;
1103
1104   smpi_bench_end();
1105   if (comm == MPI_COMM_NULL) {
1106     retval = MPI_ERR_COMM;
1107   } else if (src == MPI_PROC_NULL) {
1108     smpi_empty_status(status);
1109     status->MPI_SOURCE = MPI_PROC_NULL;
1110     retval = MPI_SUCCESS;
1111   } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
1112     retval = MPI_ERR_RANK;
1113   } else if (count < 0) {
1114     retval = MPI_ERR_COUNT;
1115   } else if (buf==NULL && count > 0) {
1116     retval = MPI_ERR_COUNT;
1117   } else if (datatype == MPI_DATATYPE_NULL){
1118     retval = MPI_ERR_TYPE;
1119   } else if(tag<0 && tag !=  MPI_ANY_TAG){
1120     retval = MPI_ERR_TAG;
1121   } else {
1122 #ifdef HAVE_TRACING
1123   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1124   int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1125   TRACE_smpi_computing_out(rank);
1126
1127   TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
1128 #endif
1129
1130     smpi_mpi_recv(buf, count, datatype, src, tag, comm, status);
1131     retval = MPI_SUCCESS;
1132
1133 #ifdef HAVE_TRACING
1134   //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1135   if(status!=MPI_STATUS_IGNORE)src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
1136   TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1137   TRACE_smpi_recv(rank, src_traced, rank);
1138   TRACE_smpi_computing_in(rank);
1139 #endif
1140   }
1141
1142   smpi_bench_begin();
1143   return retval;
1144 }
1145
1146 int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
1147              MPI_Comm comm)
1148 {
1149   int retval;
1150
1151   smpi_bench_end();
1152
1153   if (comm == MPI_COMM_NULL) {
1154     retval = MPI_ERR_COMM;
1155   } else if (dst == MPI_PROC_NULL) {
1156     retval = MPI_SUCCESS;
1157   } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1158     retval = MPI_ERR_RANK;
1159   } else if (count < 0) {
1160     retval = MPI_ERR_COUNT;
1161   } else if (buf==NULL && count > 0) {
1162     retval = MPI_ERR_COUNT;
1163   } else if (datatype == MPI_DATATYPE_NULL){
1164     retval = MPI_ERR_TYPE;
1165   } else if(tag<0 && tag !=  MPI_ANY_TAG){
1166     retval = MPI_ERR_TAG;
1167   } else {
1168
1169 #ifdef HAVE_TRACING
1170   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1171   TRACE_smpi_computing_out(rank);
1172   int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1173   TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1174   TRACE_smpi_send(rank, rank, dst_traced);
1175 #endif
1176
1177     smpi_mpi_send(buf, count, datatype, dst, tag, comm);
1178     retval = MPI_SUCCESS;
1179
1180 #ifdef HAVE_TRACING
1181   TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1182   TRACE_smpi_computing_in(rank);
1183 #endif
1184   }
1185
1186   smpi_bench_begin();
1187   return retval;
1188 }
1189
1190
1191
1192 int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
1193   int retval;
1194
1195    smpi_bench_end();
1196
1197    if (comm == MPI_COMM_NULL) {
1198      retval = MPI_ERR_COMM;
1199    } else if (dst == MPI_PROC_NULL) {
1200      retval = MPI_SUCCESS;
1201    } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1202      retval = MPI_ERR_RANK;
1203    } else if (count < 0) {
1204      retval = MPI_ERR_COUNT;
1205    } else if (buf==NULL && count > 0) {
1206      retval = MPI_ERR_COUNT;
1207    } else if (datatype == MPI_DATATYPE_NULL){
1208      retval = MPI_ERR_TYPE;
1209    } else if(tag<0 && tag !=  MPI_ANY_TAG){
1210      retval = MPI_ERR_TAG;
1211    } else {
1212
1213  #ifdef HAVE_TRACING
1214    int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1215    TRACE_smpi_computing_out(rank);
1216    int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1217    TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1218    TRACE_smpi_send(rank, rank, dst_traced);
1219  #endif
1220
1221      smpi_mpi_ssend(buf, count, datatype, dst, tag, comm);
1222      retval = MPI_SUCCESS;
1223
1224  #ifdef HAVE_TRACING
1225    TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1226    TRACE_smpi_computing_in(rank);
1227  #endif
1228    }
1229
1230    smpi_bench_begin();
1231    return retval;}
1232
1233
1234 int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1235                  int dst, int sendtag, void *recvbuf, int recvcount,
1236                  MPI_Datatype recvtype, int src, int recvtag,
1237                  MPI_Comm comm, MPI_Status * status)
1238 {
1239   int retval;
1240
1241   smpi_bench_end();
1242
1243   if (comm == MPI_COMM_NULL) {
1244     retval = MPI_ERR_COMM;
1245   } else if (sendtype == MPI_DATATYPE_NULL
1246              || recvtype == MPI_DATATYPE_NULL) {
1247     retval = MPI_ERR_TYPE;
1248   } else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
1249       smpi_empty_status(status);
1250       status->MPI_SOURCE = MPI_PROC_NULL;
1251       retval = MPI_SUCCESS;
1252   }else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0 ||
1253       (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0))){
1254     retval = MPI_ERR_RANK;
1255   } else if (sendcount < 0 || recvcount<0) {
1256       retval = MPI_ERR_COUNT;
1257   } else if ((sendbuf==NULL && sendcount > 0)||(recvbuf==NULL && recvcount>0)) {
1258     retval = MPI_ERR_COUNT;
1259   } else if((sendtag<0 && sendtag !=  MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){
1260     retval = MPI_ERR_TAG;
1261   } else {
1262
1263 #ifdef HAVE_TRACING
1264   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1265   TRACE_smpi_computing_out(rank);
1266   int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1267   int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1268   TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
1269   TRACE_smpi_send(rank, rank, dst_traced);
1270 #endif
1271
1272
1273     smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf,
1274                       recvcount, recvtype, src, recvtag, comm, status);
1275     retval = MPI_SUCCESS;
1276
1277 #ifdef HAVE_TRACING
1278   TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1279   TRACE_smpi_recv(rank, src_traced, rank);
1280   TRACE_smpi_computing_in(rank);
1281 #endif
1282
1283   }
1284
1285   smpi_bench_begin();
1286   return retval;
1287 }
1288
1289 int PMPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
1290                          int dst, int sendtag, int src, int recvtag,
1291                          MPI_Comm comm, MPI_Status * status)
1292 {
1293   //TODO: suboptimal implementation
1294   void *recvbuf;
1295   int retval;
1296   if (datatype == MPI_DATATYPE_NULL) {
1297       retval = MPI_ERR_TYPE;
1298   } else if (count < 0) {
1299       retval = MPI_ERR_COUNT;
1300   } else {
1301     int size = smpi_datatype_get_extent(datatype) * count;
1302     recvbuf = xbt_new(char, size);
1303     retval =
1304         MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
1305                      datatype, src, recvtag, comm, status);
1306     if(retval==MPI_SUCCESS){
1307         smpi_datatype_copy(recvbuf, count, datatype, buf, count, datatype);
1308     }
1309     xbt_free(recvbuf);
1310
1311   }
1312   return retval;
1313 }
1314
1315 int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
1316 {
1317   int retval;
1318
1319   smpi_bench_end();
1320   if (request == MPI_REQUEST_NULL || flag == NULL) {
1321     retval = MPI_ERR_ARG;
1322   } else if (*request == MPI_REQUEST_NULL) {
1323     *flag= TRUE;
1324     retval = MPI_ERR_REQUEST;
1325   } else {
1326     *flag = smpi_mpi_test(request, status);
1327     retval = MPI_SUCCESS;
1328   }
1329   smpi_bench_begin();
1330   return retval;
1331 }
1332
1333 int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
1334                 MPI_Status * status)
1335 {
1336   int retval;
1337
1338   smpi_bench_end();
1339   if (index == NULL || flag == NULL) {
1340     retval = MPI_ERR_ARG;
1341   } else {
1342     *flag = smpi_mpi_testany(count, requests, index, status);
1343     retval = MPI_SUCCESS;
1344   }
1345   smpi_bench_begin();
1346   return retval;
1347 }
1348
1349 int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses)
1350 {
1351   int retval;
1352
1353   smpi_bench_end();
1354   if (flag == NULL) {
1355     retval = MPI_ERR_ARG;
1356   } else {
1357     *flag = smpi_mpi_testall(count, requests, statuses);
1358     retval = MPI_SUCCESS;
1359   }
1360   smpi_bench_begin();
1361   return retval;
1362 }
1363
1364 int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) {
1365   int retval;
1366   smpi_bench_end();
1367
1368   if (status == NULL) {
1369     retval = MPI_ERR_ARG;
1370   } else if (comm == MPI_COMM_NULL) {
1371     retval = MPI_ERR_COMM;
1372   } else if (source == MPI_PROC_NULL) {
1373     smpi_empty_status(status);
1374     status->MPI_SOURCE = MPI_PROC_NULL;
1375     retval = MPI_SUCCESS;
1376   } else {
1377     smpi_mpi_probe(source, tag, comm, status);
1378     retval = MPI_SUCCESS;
1379   }
1380   smpi_bench_begin();
1381   return retval;
1382 }
1383
1384
1385 int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status) {
1386   int retval;
1387   smpi_bench_end();
1388
1389   if (flag == NULL) {
1390     retval = MPI_ERR_ARG;
1391   } else if (status == NULL) {
1392     retval = MPI_ERR_ARG;
1393   } else if (comm == MPI_COMM_NULL) {
1394     retval = MPI_ERR_COMM;
1395   } else if (source == MPI_PROC_NULL) {
1396     smpi_empty_status(status);
1397     status->MPI_SOURCE = MPI_PROC_NULL;
1398     retval = MPI_SUCCESS;
1399   } else {
1400     smpi_mpi_iprobe(source, tag, comm, flag, status);
1401     retval = MPI_SUCCESS;
1402   }
1403   smpi_bench_begin();
1404   return retval;
1405 }
1406
1407 int PMPI_Wait(MPI_Request * request, MPI_Status * status)
1408 {
1409   int retval;
1410
1411   smpi_bench_end();
1412
1413   if (request == NULL) {
1414     retval = MPI_ERR_ARG;
1415   } else if (*request == MPI_REQUEST_NULL) {
1416     retval = MPI_ERR_REQUEST;
1417   } else {
1418
1419 #ifdef HAVE_TRACING
1420   int rank = request && (*request)->comm != MPI_COMM_NULL
1421       ? smpi_process_index()
1422       : -1;
1423   TRACE_smpi_computing_out(rank);
1424
1425   int src_traced = (*request)->src;
1426   int dst_traced = (*request)->dst;
1427   int is_wait_for_receive = (*request)->recv;
1428   TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
1429 #endif
1430
1431     smpi_mpi_wait(request, status);
1432     retval = MPI_SUCCESS;
1433
1434 #ifdef HAVE_TRACING
1435   TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1436   if (is_wait_for_receive) {
1437     TRACE_smpi_recv(rank, src_traced, dst_traced);
1438   }
1439   TRACE_smpi_computing_in(rank);
1440 #endif
1441
1442   }
1443
1444   smpi_bench_begin();
1445   return retval;
1446 }
1447
1448 int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * status)
1449 {
1450   int retval;
1451
1452   smpi_bench_end();
1453 #ifdef HAVE_TRACING
1454   //save requests information for tracing
1455   int i;
1456   int *srcs = xbt_new(int, count);
1457   int *dsts = xbt_new(int, count);
1458   int *recvs = xbt_new(int, count);
1459   for (i = 0; i < count; i++) {
1460     MPI_Request req = requests[i];      //already received requests are no longer valid
1461     if (req) {
1462       srcs[i] = req->src;
1463       dsts[i] = req->dst;
1464       recvs[i] = req->recv;
1465     }
1466   }
1467   int rank_traced = smpi_process_index();
1468   TRACE_smpi_computing_out(rank_traced);
1469
1470   TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
1471
1472 #endif
1473   if (index == NULL) {
1474     retval = MPI_ERR_ARG;
1475   } else {
1476     *index = smpi_mpi_waitany(count, requests, status);
1477     retval = MPI_SUCCESS;
1478   }
1479 #ifdef HAVE_TRACING
1480   if(*index!=MPI_UNDEFINED){
1481     int src_traced = srcs[*index];
1482     int dst_traced = dsts[*index];
1483     int is_wait_for_receive = recvs[*index];
1484     if (is_wait_for_receive) {
1485       TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1486     }
1487     TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__);
1488     xbt_free(srcs);
1489     xbt_free(dsts);
1490     xbt_free(recvs);
1491   }
1492   TRACE_smpi_computing_in(rank_traced);
1493 #endif
1494   smpi_bench_begin();
1495   return retval;
1496 }
1497
1498 int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
1499 {
1500
1501   smpi_bench_end();
1502 #ifdef HAVE_TRACING
1503   //save information from requests
1504   int i;
1505   int *srcs = xbt_new(int, count);
1506   int *dsts = xbt_new(int, count);
1507   int *recvs = xbt_new(int, count);
1508   int valid_count = 0;
1509   for (i = 0; i < count; i++) {
1510     MPI_Request req = requests[i];
1511     if(req!=MPI_REQUEST_NULL){
1512       srcs[valid_count] = req->src;
1513       dsts[valid_count] = req->dst;
1514       recvs[valid_count] = req->recv;
1515       valid_count++;
1516     }
1517   }
1518   int rank_traced = smpi_process_index();
1519   TRACE_smpi_computing_out(rank_traced);
1520
1521   TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
1522 #endif
1523   int retval = smpi_mpi_waitall(count, requests, status);
1524 #ifdef HAVE_TRACING
1525   for (i = 0; i < valid_count; i++) {
1526     int src_traced = srcs[i];
1527     int dst_traced = dsts[i];
1528     int is_wait_for_receive = recvs[i];
1529     if (is_wait_for_receive) {
1530       TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1531     }
1532   }
1533   TRACE_smpi_ptp_out(rank_traced, -1, -1, __FUNCTION__);
1534   xbt_free(srcs);
1535   xbt_free(dsts);
1536   xbt_free(recvs);
1537   TRACE_smpi_computing_in(rank_traced);
1538 #endif
1539   smpi_bench_begin();
1540   return retval;
1541 }
1542
1543 int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
1544                  int *indices, MPI_Status status[])
1545 {
1546   int retval;
1547
1548   smpi_bench_end();
1549   if (outcount == NULL || indices == NULL) {
1550     retval = MPI_ERR_ARG;
1551   } else {
1552     *outcount = smpi_mpi_waitsome(incount, requests, indices, status);
1553     retval = MPI_SUCCESS;
1554   }
1555   smpi_bench_begin();
1556   return retval;
1557 }
1558
1559 int PMPI_Testsome(int incount, MPI_Request requests[], int* outcount,
1560                  int* indices, MPI_Status status[])
1561 {
1562   int retval;
1563
1564    smpi_bench_end();
1565    if (outcount == NULL || indices == NULL) {
1566      retval = MPI_ERR_ARG;
1567    } else {
1568      *outcount = smpi_mpi_testsome(incount, requests, indices, status);
1569      retval = MPI_SUCCESS;
1570    }
1571    smpi_bench_begin();
1572    return retval;
1573 }
1574
1575
1576 int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
1577 {
1578   int retval;
1579
1580   smpi_bench_end();
1581 #ifdef HAVE_TRACING
1582   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1583   TRACE_smpi_computing_out(rank);
1584   int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1585   TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1586 #endif
1587   if (comm == MPI_COMM_NULL) {
1588     retval = MPI_ERR_COMM;
1589   } else {
1590     mpi_coll_bcast_fun(buf, count, datatype, root, comm);
1591     retval = MPI_SUCCESS;
1592   }
1593 #ifdef HAVE_TRACING
1594   TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1595   TRACE_smpi_computing_in(rank);
1596 #endif
1597   smpi_bench_begin();
1598   return retval;
1599 }
1600
1601 int PMPI_Barrier(MPI_Comm comm)
1602 {
1603   int retval;
1604
1605   smpi_bench_end();
1606 #ifdef HAVE_TRACING
1607   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1608   TRACE_smpi_computing_out(rank);
1609   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1610 #endif
1611   if (comm == MPI_COMM_NULL) {
1612     retval = MPI_ERR_COMM;
1613   } else {
1614     mpi_coll_barrier_fun(comm);
1615     retval = MPI_SUCCESS;
1616   }
1617 #ifdef HAVE_TRACING
1618   TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1619   TRACE_smpi_computing_in(rank);
1620 #endif
1621   smpi_bench_begin();
1622   return retval;
1623 }
1624
1625 int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1626                void *recvbuf, int recvcount, MPI_Datatype recvtype,
1627                int root, MPI_Comm comm)
1628 {
1629   int retval;
1630
1631   smpi_bench_end();
1632 #ifdef HAVE_TRACING
1633   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1634   TRACE_smpi_computing_out(rank);
1635   int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1636   TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1637 #endif
1638   if (comm == MPI_COMM_NULL) {
1639     retval = MPI_ERR_COMM;
1640   } else if (sendtype == MPI_DATATYPE_NULL
1641              || recvtype == MPI_DATATYPE_NULL) {
1642     retval = MPI_ERR_TYPE;
1643   } else {
1644     mpi_coll_gather_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1645                     recvtype, root, comm);
1646     retval = MPI_SUCCESS;
1647   }
1648 #ifdef HAVE_TRACING
1649   TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1650   TRACE_smpi_computing_in(rank);
1651 #endif
1652   smpi_bench_begin();
1653   return retval;
1654 }
1655
1656 int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1657                 void *recvbuf, int *recvcounts, int *displs,
1658                 MPI_Datatype recvtype, int root, MPI_Comm comm)
1659 {
1660   int retval;
1661
1662   smpi_bench_end();
1663 #ifdef HAVE_TRACING
1664   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1665   TRACE_smpi_computing_out(rank);
1666   int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1667   TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1668 #endif
1669   if (comm == MPI_COMM_NULL) {
1670     retval = MPI_ERR_COMM;
1671   } else if (sendtype == MPI_DATATYPE_NULL
1672              || recvtype == MPI_DATATYPE_NULL) {
1673     retval = MPI_ERR_TYPE;
1674   } else if (recvcounts == NULL || displs == NULL) {
1675     retval = MPI_ERR_ARG;
1676   } else {
1677     smpi_mpi_gatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
1678                      displs, recvtype, root, comm);
1679     retval = MPI_SUCCESS;
1680   }
1681 #ifdef HAVE_TRACING
1682   TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1683   TRACE_smpi_computing_in(rank);
1684 #endif
1685   smpi_bench_begin();
1686   return retval;
1687 }
1688
1689 int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1690                   void *recvbuf, int recvcount, MPI_Datatype recvtype,
1691                   MPI_Comm comm)
1692 {
1693   int retval;
1694
1695   smpi_bench_end();
1696 #ifdef HAVE_TRACING
1697   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1698   TRACE_smpi_computing_out(rank);
1699   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1700 #endif
1701   if (comm == MPI_COMM_NULL) {
1702     retval = MPI_ERR_COMM;
1703   } else if (sendtype == MPI_DATATYPE_NULL
1704              || recvtype == MPI_DATATYPE_NULL) {
1705     retval = MPI_ERR_TYPE;
1706   } else {
1707     mpi_coll_allgather_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1708                            recvtype, comm);
1709     retval = MPI_SUCCESS;
1710   }
1711 #ifdef HAVE_TRACING
1712   TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1713 #endif
1714   smpi_bench_begin();
1715   return retval;
1716 }
1717
1718 int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1719                    void *recvbuf, int *recvcounts, int *displs,
1720                    MPI_Datatype recvtype, MPI_Comm comm)
1721 {
1722   int retval;
1723
1724   smpi_bench_end();
1725 #ifdef HAVE_TRACING
1726   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1727   TRACE_smpi_computing_out(rank);
1728   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1729 #endif
1730   if (comm == MPI_COMM_NULL) {
1731     retval = MPI_ERR_COMM;
1732   } else if (sendtype == MPI_DATATYPE_NULL
1733              || recvtype == MPI_DATATYPE_NULL) {
1734     retval = MPI_ERR_TYPE;
1735   } else if (recvcounts == NULL || displs == NULL) {
1736     retval = MPI_ERR_ARG;
1737   } else {
1738     mpi_coll_allgatherv_fun(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
1739                         displs, recvtype, comm);
1740     retval = MPI_SUCCESS;
1741   }
1742 #ifdef HAVE_TRACING
1743   TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1744   TRACE_smpi_computing_in(rank);
1745 #endif
1746   smpi_bench_begin();
1747   return retval;
1748 }
1749
1750 int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1751                 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1752                 int root, MPI_Comm comm)
1753 {
1754   int retval;
1755
1756   smpi_bench_end();
1757 #ifdef HAVE_TRACING
1758   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1759   TRACE_smpi_computing_out(rank);
1760   int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1761
1762   TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1763 #endif
1764   if (comm == MPI_COMM_NULL) {
1765     retval = MPI_ERR_COMM;
1766   } else if (sendtype == MPI_DATATYPE_NULL
1767              || recvtype == MPI_DATATYPE_NULL) {
1768     retval = MPI_ERR_TYPE;
1769   } else {
1770     mpi_coll_scatter_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1771                      recvtype, root, comm);
1772     retval = MPI_SUCCESS;
1773   }
1774 #ifdef HAVE_TRACING
1775   TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1776   TRACE_smpi_computing_in(rank);
1777 #endif
1778   smpi_bench_begin();
1779   return retval;
1780 }
1781
1782 int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
1783                  MPI_Datatype sendtype, void *recvbuf, int recvcount,
1784                  MPI_Datatype recvtype, int root, MPI_Comm comm)
1785 {
1786   int retval;
1787
1788   smpi_bench_end();
1789 #ifdef HAVE_TRACING
1790   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1791   TRACE_smpi_computing_out(rank);
1792   int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1793   TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1794 #endif
1795   if (comm == MPI_COMM_NULL) {
1796     retval = MPI_ERR_COMM;
1797   } else if (sendtype == MPI_DATATYPE_NULL
1798              || recvtype == MPI_DATATYPE_NULL) {
1799     retval = MPI_ERR_TYPE;
1800   } else if (sendcounts == NULL || displs == NULL) {
1801     retval = MPI_ERR_ARG;
1802   } else {
1803     smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
1804                       recvcount, recvtype, root, comm);
1805     retval = MPI_SUCCESS;
1806   }
1807 #ifdef HAVE_TRACING
1808   TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1809   TRACE_smpi_computing_in(rank);
1810 #endif
1811   smpi_bench_begin();
1812   return retval;
1813 }
1814
1815 int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
1816                MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
1817 {
1818   int retval;
1819
1820   smpi_bench_end();
1821 #ifdef HAVE_TRACING
1822   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1823   TRACE_smpi_computing_out(rank);
1824   int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1825   TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1826 #endif
1827   if (comm == MPI_COMM_NULL) {
1828     retval = MPI_ERR_COMM;
1829   } else if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
1830     retval = MPI_ERR_ARG;
1831   } else {
1832     mpi_coll_reduce_fun(sendbuf, recvbuf, count, datatype, op, root, comm);
1833     retval = MPI_SUCCESS;
1834   }
1835 #ifdef HAVE_TRACING
1836   TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1837   TRACE_smpi_computing_in(rank);
1838 #endif
1839   smpi_bench_begin();
1840   return retval;
1841 }
1842
1843 int PMPI_Reduce_local(void *inbuf, void *inoutbuf, int count,
1844     MPI_Datatype datatype, MPI_Op op){
1845   int retval;
1846
1847     smpi_bench_end();
1848     if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
1849       retval = MPI_ERR_ARG;
1850     } else {
1851       smpi_op_apply(op, inbuf, inoutbuf, &count, &datatype);
1852       retval=MPI_SUCCESS;
1853     }
1854     smpi_bench_begin();
1855     return retval;
1856 }
1857
1858 int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
1859                   MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
1860 {
1861   int retval;
1862
1863   smpi_bench_end();
1864 #ifdef HAVE_TRACING
1865   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1866   TRACE_smpi_computing_out(rank);
1867   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1868 #endif
1869   if (comm == MPI_COMM_NULL) {
1870     retval = MPI_ERR_COMM;
1871   } else if (datatype == MPI_DATATYPE_NULL) {
1872     retval = MPI_ERR_TYPE;
1873   } else if (op == MPI_OP_NULL) {
1874     retval = MPI_ERR_OP;
1875   } else {
1876       mpi_coll_allreduce_fun(sendbuf, recvbuf, count, datatype, op, comm);
1877     retval = MPI_SUCCESS;
1878   }
1879 #ifdef HAVE_TRACING
1880   TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1881   TRACE_smpi_computing_in(rank);
1882 #endif
1883   smpi_bench_begin();
1884   return retval;
1885 }
1886
1887 int PMPI_Scan(void *sendbuf, void *recvbuf, int count,
1888              MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
1889 {
1890   int retval;
1891
1892   smpi_bench_end();
1893 #ifdef HAVE_TRACING
1894   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1895   TRACE_smpi_computing_out(rank);
1896   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1897 #endif
1898   if (comm == MPI_COMM_NULL) {
1899     retval = MPI_ERR_COMM;
1900   } else if (datatype == MPI_DATATYPE_NULL) {
1901     retval = MPI_ERR_TYPE;
1902   } else if (op == MPI_OP_NULL) {
1903     retval = MPI_ERR_OP;
1904   } else {
1905     smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm);
1906     retval = MPI_SUCCESS;
1907   }
1908 #ifdef HAVE_TRACING
1909   TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1910   TRACE_smpi_computing_in(rank);
1911 #endif
1912   smpi_bench_begin();
1913   return retval;
1914 }
1915
1916 int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
1917                        MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
1918 {
1919   int retval;
1920   smpi_bench_end();
1921 #ifdef HAVE_TRACING
1922   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1923   TRACE_smpi_computing_out(rank);
1924   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1925 #endif
1926   if (comm == MPI_COMM_NULL) {
1927     retval = MPI_ERR_COMM;
1928   } else if (datatype == MPI_DATATYPE_NULL) {
1929     retval = MPI_ERR_TYPE;
1930   } else if (op == MPI_OP_NULL) {
1931     retval = MPI_ERR_OP;
1932   } else if (recvcounts == NULL) {
1933     retval = MPI_ERR_ARG;
1934   } else {
1935
1936     mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts,
1937                        datatype,  op, comm);
1938     retval = MPI_SUCCESS;
1939   }
1940 #ifdef HAVE_TRACING
1941   TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1942   TRACE_smpi_computing_in(rank);
1943 #endif
1944   smpi_bench_begin();
1945   return retval;
1946 }
1947
1948 int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
1949                        MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
1950 {
1951   int retval,i;
1952   smpi_bench_end();
1953 #ifdef HAVE_TRACING
1954   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1955   TRACE_smpi_computing_out(rank);
1956   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1957 #endif
1958   if (comm == MPI_COMM_NULL) {
1959     retval = MPI_ERR_COMM;
1960   } else if (datatype == MPI_DATATYPE_NULL) {
1961     retval = MPI_ERR_TYPE;
1962   } else if (op == MPI_OP_NULL) {
1963     retval = MPI_ERR_OP;
1964   } else if (recvcount < 0) {
1965     retval = MPI_ERR_ARG;
1966   } else {
1967     int count=smpi_comm_size(comm);
1968     int* recvcounts=(int*)xbt_malloc(count);
1969     for (i=0; i<count;i++)recvcounts[i]=recvcount;
1970     mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts,
1971                        datatype,  op, comm);
1972     xbt_free(recvcounts);
1973     retval = MPI_SUCCESS;
1974   }
1975 #ifdef HAVE_TRACING
1976   TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1977   TRACE_smpi_computing_in(rank);
1978 #endif
1979   smpi_bench_begin();
1980   return retval;
1981 }
1982
1983 int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1984                  void *recvbuf, int recvcount, MPI_Datatype recvtype,
1985                  MPI_Comm comm)
1986 {
1987   int retval;
1988
1989   smpi_bench_end();
1990 #ifdef HAVE_TRACING
1991   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1992   TRACE_smpi_computing_out(rank);
1993   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1994 #endif
1995   if (comm == MPI_COMM_NULL) {
1996     retval = MPI_ERR_COMM;
1997   } else if (sendtype == MPI_DATATYPE_NULL
1998              || recvtype == MPI_DATATYPE_NULL) {
1999     retval = MPI_ERR_TYPE;
2000   } else {
2001     retval = mpi_coll_alltoall_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
2002   }
2003 #ifdef HAVE_TRACING
2004   TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2005   TRACE_smpi_computing_in(rank);
2006 #endif
2007   smpi_bench_begin();
2008   return retval;
2009 }
2010
2011 int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
2012                   MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
2013                   int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
2014 {
2015   int retval;
2016
2017   smpi_bench_end();
2018 #ifdef HAVE_TRACING
2019   int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2020   TRACE_smpi_computing_out(rank);
2021   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2022 #endif
2023   if (comm == MPI_COMM_NULL) {
2024     retval = MPI_ERR_COMM;
2025   } else if (sendtype == MPI_DATATYPE_NULL
2026              || recvtype == MPI_DATATYPE_NULL) {
2027     retval = MPI_ERR_TYPE;
2028   } else if (sendcounts == NULL || senddisps == NULL || recvcounts == NULL
2029              || recvdisps == NULL) {
2030     retval = MPI_ERR_ARG;
2031   } else {
2032     retval =
2033         mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, sendtype,
2034                                   recvbuf, recvcounts, recvdisps, recvtype,
2035                                   comm);
2036   }
2037 #ifdef HAVE_TRACING
2038   TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2039   TRACE_smpi_computing_in(rank);
2040 #endif
2041   smpi_bench_begin();
2042   return retval;
2043 }
2044
2045
2046 int PMPI_Get_processor_name(char *name, int *resultlen)
2047 {
2048   int retval = MPI_SUCCESS;
2049
2050   smpi_bench_end();
2051   strncpy(name, SIMIX_host_get_name(SIMIX_host_self()),
2052           strlen(SIMIX_host_get_name(SIMIX_host_self())) < MPI_MAX_PROCESSOR_NAME - 1 ?
2053           strlen(SIMIX_host_get_name(SIMIX_host_self())) +1 :
2054           MPI_MAX_PROCESSOR_NAME - 1 );
2055   *resultlen =
2056       strlen(name) >
2057       MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
2058
2059   smpi_bench_begin();
2060   return retval;
2061 }
2062
2063 int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
2064 {
2065   int retval = MPI_SUCCESS;
2066   size_t size;
2067
2068   smpi_bench_end();
2069   if (status == NULL || count == NULL) {
2070     retval = MPI_ERR_ARG;
2071   } else if (datatype == MPI_DATATYPE_NULL) {
2072     retval = MPI_ERR_TYPE;
2073   } else {
2074     size = smpi_datatype_size(datatype);
2075     if (size == 0) {
2076       *count = 0;
2077     } else if (status->count % size != 0) {
2078       retval = MPI_UNDEFINED;
2079     } else {
2080       *count = smpi_mpi_get_count(status, datatype);
2081     }
2082   }
2083   smpi_bench_begin();
2084   return retval;
2085 }
2086
2087 int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type) {
2088   int retval;
2089
2090   smpi_bench_end();
2091   if (old_type == MPI_DATATYPE_NULL) {
2092     retval = MPI_ERR_TYPE;
2093   } else if (count<0){
2094     retval = MPI_ERR_COUNT;
2095   } else {
2096     retval = smpi_datatype_contiguous(count, old_type, new_type, 0);
2097   }
2098   smpi_bench_begin();
2099   return retval;
2100 }
2101
2102 int PMPI_Type_commit(MPI_Datatype* datatype) {
2103   int retval;
2104
2105   smpi_bench_end();
2106   if (datatype == MPI_DATATYPE_NULL) {
2107     retval = MPI_ERR_TYPE;
2108   } else {
2109     smpi_datatype_commit(datatype);
2110     retval = MPI_SUCCESS;
2111   }
2112   smpi_bench_begin();
2113   return retval;
2114 }
2115
2116
2117 int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2118   int retval;
2119
2120   smpi_bench_end();
2121   if (old_type == MPI_DATATYPE_NULL) {
2122     retval = MPI_ERR_TYPE;
2123   } else if (count<0 || blocklen<0){
2124     retval = MPI_ERR_COUNT;
2125   } else {
2126     retval = smpi_datatype_vector(count, blocklen, stride, old_type, new_type);
2127   }
2128   smpi_bench_begin();
2129   return retval;
2130 }
2131
2132 int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2133   int retval;
2134
2135   smpi_bench_end();
2136   if (old_type == MPI_DATATYPE_NULL) {
2137     retval = MPI_ERR_TYPE;
2138   } else if (count<0 || blocklen<0){
2139     retval = MPI_ERR_COUNT;
2140   } else {
2141     retval = smpi_datatype_hvector(count, blocklen, stride, old_type, new_type);
2142   }
2143   smpi_bench_begin();
2144   return retval;
2145 }
2146
2147 int PMPI_Type_create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2148   return MPI_Type_hvector(count, blocklen, stride, old_type, new_type);
2149 }
2150
2151 int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2152   int retval;
2153
2154   smpi_bench_end();
2155   if (old_type == MPI_DATATYPE_NULL) {
2156     retval = MPI_ERR_TYPE;
2157   } else if (count<0){
2158     retval = MPI_ERR_COUNT;
2159   } else {
2160     retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2161   }
2162   smpi_bench_begin();
2163   return retval;
2164 }
2165
2166 int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2167   int retval,i;
2168
2169   smpi_bench_end();
2170   if (old_type == MPI_DATATYPE_NULL) {
2171     retval = MPI_ERR_TYPE;
2172   } else if (count<0){
2173     retval = MPI_ERR_COUNT;
2174   } else {
2175     int* blocklens=(int*)xbt_malloc(blocklength*count);
2176     for (i=0; i<count;i++)blocklens[i]=blocklength;
2177     retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2178     xbt_free(blocklens);
2179   }
2180   smpi_bench_begin();
2181   return retval;
2182 }
2183
2184
2185 int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2186   int retval;
2187
2188   smpi_bench_end();
2189   if (old_type == MPI_DATATYPE_NULL) {
2190     retval = MPI_ERR_TYPE;
2191   } else if (count<0){
2192     retval = MPI_ERR_COUNT;
2193   } else {
2194     retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2195   }
2196   smpi_bench_begin();
2197   return retval;
2198 }
2199
2200 int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2201   int retval,i;
2202
2203   smpi_bench_end();
2204   if (old_type == MPI_DATATYPE_NULL) {
2205     retval = MPI_ERR_TYPE;
2206   } else if (count<0){
2207     retval = MPI_ERR_COUNT;
2208   } else {
2209     int* blocklens=(int*)xbt_malloc(blocklength*count);
2210     for (i=0; i<count;i++)blocklens[i]=blocklength;
2211     retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2212     xbt_free(blocklens);
2213   }
2214   smpi_bench_begin();
2215   return retval;
2216 }
2217
2218
2219 int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2220   int retval;
2221
2222   smpi_bench_end();
2223   if (count<0){
2224     retval = MPI_ERR_COUNT;
2225   } else {
2226     retval = smpi_datatype_struct(count, blocklens, indices, old_types, new_type);
2227   }
2228   smpi_bench_begin();
2229   return retval;
2230 }
2231
2232 int PMPI_Type_create_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2233   return PMPI_Type_struct(count, blocklens, indices, old_types, new_type);
2234 }
2235
2236
2237 int PMPI_Error_class(int errorcode, int* errorclass) {
2238   // assume smpi uses only standard mpi error codes
2239   *errorclass=errorcode;
2240   return MPI_SUCCESS;
2241 }
2242
2243
2244 int PMPI_Initialized(int* flag) {
2245    *flag=(smpi_process_data()!=NULL);
2246    return MPI_SUCCESS;
2247 }
2248
2249 /* The following calls are not yet implemented and will fail at runtime. */
2250 /* Once implemented, please move them above this notice. */
2251
2252 static inline int not_yet_implemented(void) {
2253           XBT_WARN("Not yet implemented : line %d in %s", __LINE__, __FUNCTION__);
2254    return MPI_SUCCESS;
2255 }
2256
2257
2258 int PMPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype){
2259   return not_yet_implemented();
2260 }
2261
2262 int PMPI_Type_set_name(MPI_Datatype  datatype, char * name)
2263 {
2264   return not_yet_implemented();
2265 }
2266
2267 int PMPI_Type_get_name(MPI_Datatype  datatype, char * name, int* len)
2268 {
2269   return not_yet_implemented();
2270 }
2271
2272 int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
2273    return not_yet_implemented();
2274 }
2275
2276 int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) {
2277    return not_yet_implemented();
2278 }
2279
2280 int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periods, int reorder, MPI_Comm* comm_cart) {
2281    return not_yet_implemented();
2282 }
2283
2284 int PMPI_Cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) {
2285    return not_yet_implemented();
2286 }
2287
2288 int PMPI_Cart_map(MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank) {
2289    return not_yet_implemented();
2290 }
2291
2292 int PMPI_Cart_rank(MPI_Comm comm, int* coords, int* rank) {
2293    return not_yet_implemented();
2294 }
2295
2296 int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* dest) {
2297    return not_yet_implemented();
2298 }
2299
2300 int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
2301    return not_yet_implemented();
2302 }
2303
2304 int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) {
2305    return not_yet_implemented();
2306 }
2307
2308 int PMPI_Graph_create(MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder, MPI_Comm* comm_graph) {
2309    return not_yet_implemented();
2310 }
2311
2312 int PMPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int* index, int* edges) {
2313    return not_yet_implemented();
2314 }
2315
2316 int PMPI_Graph_map(MPI_Comm comm_old, int nnodes, int* index, int* edges, int* newrank) {
2317    return not_yet_implemented();
2318 }
2319
2320 int PMPI_Graph_neighbors(MPI_Comm comm, int rank, int maxneighbors, int* neighbors) {
2321    return not_yet_implemented();
2322 }
2323
2324 int PMPI_Graph_neighbors_count(MPI_Comm comm, int rank, int* nneighbors) {
2325    return not_yet_implemented();
2326 }
2327
2328 int PMPI_Graphdims_get(MPI_Comm comm, int* nnodes, int* nedges) {
2329    return not_yet_implemented();
2330 }
2331
2332 int PMPI_Topo_test(MPI_Comm comm, int* top_type) {
2333    return not_yet_implemented();
2334 }
2335
2336 int PMPI_Errhandler_create(MPI_Handler_function* function, MPI_Errhandler* errhandler) {
2337    return not_yet_implemented();
2338 }
2339
2340 int PMPI_Errhandler_free(MPI_Errhandler* errhandler) {
2341    return not_yet_implemented();
2342 }
2343
2344 int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler* errhandler) {
2345    return not_yet_implemented();
2346 }
2347
2348 int PMPI_Error_string(int errorcode, char* string, int* resultlen) {
2349    return not_yet_implemented();
2350 }
2351
2352 int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler) {
2353    return not_yet_implemented();
2354 }
2355
2356 int PMPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler) {
2357    return not_yet_implemented();
2358 }
2359
2360 int PMPI_Cancel(MPI_Request* request) {
2361    return not_yet_implemented();
2362 }
2363
2364 int PMPI_Buffer_attach(void* buffer, int size) {
2365    return not_yet_implemented();
2366 }
2367
2368 int PMPI_Buffer_detach(void* buffer, int* size) {
2369    return not_yet_implemented();
2370 }
2371
2372 int PMPI_Comm_test_inter(MPI_Comm comm, int* flag) {
2373    return not_yet_implemented();
2374 }
2375
2376 int PMPI_Comm_get_attr (MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag)
2377 {
2378    return not_yet_implemented();
2379 }
2380
2381 int PMPI_Comm_set_attr (MPI_Comm comm, int comm_keyval, void *attribute_val)
2382 {
2383    return not_yet_implemented();
2384 }
2385
2386 int PMPI_Comm_delete_attr (MPI_Comm comm, int comm_keyval)
2387 {
2388    return not_yet_implemented();
2389 }
2390
2391 int PMPI_Comm_create_keyval(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state)
2392 {
2393    return not_yet_implemented();
2394 }
2395
2396 int PMPI_Comm_free_keyval(int* keyval) {
2397    return not_yet_implemented();
2398 }
2399
2400 int PMPI_Pcontrol(const int level )
2401 {
2402    return not_yet_implemented();
2403 }
2404
2405 int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
2406    return not_yet_implemented();
2407 }
2408
2409 int PMPI_Type_get_attr (MPI_Datatype type, int type_keyval, void *attribute_val, int* flag)
2410 {
2411   return not_yet_implemented();
2412 }
2413
2414 int PMPI_Type_set_attr (MPI_Datatype type, int type_keyval, void *attribute_val)
2415 {
2416   return not_yet_implemented();
2417 }
2418
2419 int PMPI_Type_delete_attr (MPI_Datatype type, int comm_keyval)
2420 {
2421   return not_yet_implemented();
2422 }
2423
2424 int PMPI_Type_create_keyval(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state)
2425 {
2426   return not_yet_implemented();
2427 }
2428
2429 int PMPI_Type_free_keyval(int* keyval) {
2430   return not_yet_implemented();
2431 }
2432
2433 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
2434    return not_yet_implemented();
2435 }
2436
2437 int PMPI_Intercomm_merge(MPI_Comm comm, int high, MPI_Comm* comm_out) {
2438    return not_yet_implemented();
2439 }
2440
2441 int PMPI_Bsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2442    return not_yet_implemented();
2443 }
2444
2445 int PMPI_Bsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2446    return not_yet_implemented();
2447 }
2448
2449 int PMPI_Ibsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2450    return not_yet_implemented();
2451 }
2452
2453 int PMPI_Comm_remote_group(MPI_Comm comm, MPI_Group* group) {
2454    return not_yet_implemented();
2455 }
2456
2457 int PMPI_Comm_remote_size(MPI_Comm comm, int* size) {
2458    return not_yet_implemented();
2459 }
2460
2461 int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
2462    return not_yet_implemented();
2463 }
2464
2465 int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) {
2466    return not_yet_implemented();
2467 }
2468
2469 int PMPI_Attr_put(MPI_Comm comm, int keyval, void* attr_value) {
2470    return not_yet_implemented();
2471 }
2472
2473 int PMPI_Rsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2474    return not_yet_implemented();
2475 }
2476
2477 int PMPI_Rsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2478    return not_yet_implemented();
2479 }
2480
2481 int PMPI_Irsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2482    return not_yet_implemented();
2483 }
2484
2485 int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
2486    return not_yet_implemented();
2487 }
2488
2489 int PMPI_Keyval_free(int* keyval) {
2490    return not_yet_implemented();
2491 }
2492
2493 int PMPI_Test_cancelled(MPI_Status* status, int* flag) {
2494    return not_yet_implemented();
2495 }
2496
2497 int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
2498    return not_yet_implemented();
2499 }
2500
2501 int PMPI_Pack_external_size(char *datarep, int incount, MPI_Datatype datatype, MPI_Aint *size){
2502   return not_yet_implemented();
2503 }
2504
2505 int PMPI_Pack_external(char *datarep, void *inbuf, int incount, MPI_Datatype datatype, void *outbuf, MPI_Aint outcount, MPI_Aint *position){
2506   return not_yet_implemented();
2507 }
2508
2509 int PMPI_Unpack_external( char *datarep, void *inbuf, MPI_Aint insize, MPI_Aint *position, void *outbuf, int outcount, MPI_Datatype datatype){
2510   return not_yet_implemented();
2511 }
2512
2513 int PMPI_Get_elements(MPI_Status* status, MPI_Datatype datatype, int* elements) {
2514    return not_yet_implemented();
2515 }
2516
2517 int PMPI_Dims_create(int nnodes, int ndims, int* dims) {
2518    return not_yet_implemented();
2519 }
2520
2521 int PMPI_Win_fence( int assert,  MPI_Win win){
2522    return not_yet_implemented();
2523 }
2524
2525 int PMPI_Win_free( MPI_Win* win){
2526    return not_yet_implemented();
2527 }
2528
2529 int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win){
2530   return not_yet_implemented();
2531 }
2532
2533 int PMPI_Info_create( MPI_Info *info){
2534   return not_yet_implemented();
2535 }
2536
2537 int PMPI_Info_set( MPI_Info info, char *key, char *value){
2538   return not_yet_implemented();
2539 }
2540
2541 int PMPI_Info_free( MPI_Info *info){
2542   return not_yet_implemented();
2543 }
2544
2545 int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2546     MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
2547   return not_yet_implemented();
2548 }
2549
2550 int PMPI_Type_get_envelope( MPI_Datatype datatype, int *num_integers,
2551                           int *num_addresses, int *num_datatypes, int *combiner){
2552   return not_yet_implemented();
2553 }
2554
2555 int PMPI_Type_get_contents(MPI_Datatype datatype, int max_integers, int max_addresses,
2556                           int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses,
2557                           MPI_Datatype* array_of_datatypes){
2558   return not_yet_implemented();
2559 }
2560
2561 int PMPI_Type_create_darray(int size, int rank, int ndims, int* array_of_gsizes,
2562                             int* array_of_distribs, int* array_of_dargs, int* array_of_psizes,
2563                             int order, MPI_Datatype oldtype, MPI_Datatype *newtype) {
2564   return not_yet_implemented();
2565 }
2566
2567 int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype){
2568   return not_yet_implemented();
2569 }
2570
2571 int PMPI_Type_create_subarray(int ndims,int *array_of_sizes, int *array_of_subsizes, int *array_of_starts, int order, MPI_Datatype oldtype, MPI_Datatype *newtype){
2572   return not_yet_implemented();
2573 }
2574
2575 int PMPI_Type_match_size(int typeclass,int size,MPI_Datatype *datatype){
2576   return not_yet_implemented();
2577 }
2578
2579 int PMPI_Alltoallw( void *sendbuf, int *sendcnts, int *sdispls, MPI_Datatype *sendtypes,
2580                    void *recvbuf, int *recvcnts, int *rdispls, MPI_Datatype *recvtypes,
2581                    MPI_Comm comm){
2582   return not_yet_implemented();
2583 }
2584
2585 int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
2586                 MPI_Op op, MPI_Comm comm){
2587   return not_yet_implemented();
2588 }
2589
2590 int PMPI_Comm_set_name(MPI_Comm comm, char* name){
2591   return not_yet_implemented();
2592 }
2593
2594 int PMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm * newcomm){
2595   return not_yet_implemented();
2596 }
2597
2598 int PMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm){
2599   return not_yet_implemented();
2600 }
2601
2602 int PMPI_Comm_set_info (MPI_Comm comm, MPI_Info info){
2603   return not_yet_implemented();
2604 }
2605
2606 int PMPI_Comm_get_info (MPI_Comm comm, MPI_Info* info){
2607   return not_yet_implemented();
2608 }
2609
2610 int PMPI_Info_get(MPI_Info info,char *key,int valuelen, char *value, int *flag){
2611   return not_yet_implemented();
2612 }
2613
2614 int PMPI_Comm_create_errhandler( MPI_Comm_errhandler_fn *function, MPI_Errhandler *errhandler){
2615   return not_yet_implemented();
2616 }
2617
2618 int PMPI_Add_error_class( int *errorclass){
2619   return not_yet_implemented();
2620 }
2621
2622 int PMPI_Add_error_code(  int errorclass, int *errorcode){
2623   return not_yet_implemented();
2624 }
2625
2626 int PMPI_Add_error_string( int errorcode, char *string){
2627   return not_yet_implemented();
2628 }
2629
2630 int PMPI_Comm_call_errhandler(MPI_Comm comm,int errorcode){
2631   return not_yet_implemented();
2632 }
2633
2634 int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo){
2635   return not_yet_implemented();
2636 }
2637
2638 int PMPI_Info_delete(MPI_Info info, char *key){
2639   return not_yet_implemented();
2640 }
2641
2642 int PMPI_Info_get_nkeys( MPI_Info info, int *nkeys){
2643   return not_yet_implemented();
2644 }
2645
2646 int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){
2647   return not_yet_implemented();
2648 }
2649
2650 int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){
2651   return not_yet_implemented();
2652 }
2653
2654 int PMPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){
2655   return not_yet_implemented();
2656 }
2657
2658 int MPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){
2659   return not_yet_implemented();
2660 }
2661
2662 int PMPI_Grequest_start( MPI_Grequest_query_function *query_fn, MPI_Grequest_free_function *free_fn, MPI_Grequest_cancel_function *cancel_fn, void *extra_state, MPI_Request *request){
2663   return not_yet_implemented();
2664 }
2665
2666 int PMPI_Grequest_complete( MPI_Request request){
2667   return not_yet_implemented();
2668 }
2669
2670 int PMPI_Status_set_cancelled(MPI_Status *status,int flag){
2671   return not_yet_implemented();
2672 }
2673
2674 int PMPI_Status_set_elements( MPI_Status *status, MPI_Datatype datatype, int count){
2675   return not_yet_implemented();
2676 }
2677
2678 int PMPI_Comm_connect( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
2679   return not_yet_implemented();
2680 }
2681
2682 int PMPI_Publish_name( char *service_name, MPI_Info info, char *port_name){
2683   return not_yet_implemented();
2684 }
2685
2686 int PMPI_Unpublish_name( char *service_name, MPI_Info info, char *port_name){
2687   return not_yet_implemented();
2688 }
2689
2690 int PMPI_Lookup_name( char *service_name, MPI_Info info, char *port_name){
2691   return not_yet_implemented();
2692 }
2693
2694 int PMPI_Comm_join( int fd, MPI_Comm *intercomm){
2695   return not_yet_implemented();
2696 }
2697
2698 int PMPI_Open_port( MPI_Info info, char *port_name){
2699   return not_yet_implemented();
2700 }
2701
2702 int PMPI_Close_port(char *port_name){
2703   return not_yet_implemented();
2704 }
2705
2706 int PMPI_Comm_accept( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
2707   return not_yet_implemented();
2708 }
2709
2710 int PMPI_Comm_spawn( char *command, char **argv, int maxprocs, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes){
2711   return not_yet_implemented();
2712 }
2713
2714 int PMPI_Comm_spawn_multiple( int count, char **array_of_commands, char*** array_of_argv,
2715                              int* array_of_maxprocs, MPI_Info* array_of_info, int root,
2716                              MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes){
2717   return not_yet_implemented();
2718 }
2719
2720 int PMPI_Comm_get_parent( MPI_Comm *parent){
2721   return not_yet_implemented();
2722 }