1 /* Copyright (c) 2007-2013. The SimGrid Team.
2 * All rights reserved. */
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. */
8 #include "smpi_mpi_dt_private.h"
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_pmpi, smpi,
11 "Logging specific to SMPI (pmpi)");
14 //this function need to be here because of the calls to smpi_bench
15 void TRACE_smpi_set_category(const char *category)
17 //need to end bench otherwise categories for execution tasks are wrong
19 TRACE_internal_smpi_set_category (category);
20 //begin bench after changing process's category
25 /* PMPI User level calls */
27 int PMPI_Init(int *argc, char ***argv)
29 smpi_process_init(argc, argv);
30 smpi_process_mark_as_initialized();
32 int rank = smpi_process_index();
33 TRACE_smpi_init(rank);
35 TRACE_smpi_computing_init(rank);
41 int PMPI_Finalize(void)
43 smpi_process_finalize();
46 int rank = smpi_process_index();
47 TRACE_smpi_computing_out(rank);
48 TRACE_smpi_finalize(smpi_process_index());
50 smpi_process_destroy();
54 int PMPI_Finalized(int* flag)
56 *flag=smpi_process_finalized();
60 int PMPI_Get_version (int *version,int *subversion){
61 *version = MPI_VERSION;
62 *subversion= MPI_SUBVERSION;
66 int PMPI_Get_library_version (char *version,int *len){
67 int retval = MPI_SUCCESS;
69 snprintf(version,MPI_MAX_LIBRARY_VERSION_STRING,"SMPI Version %d.%d. Copyright The Simgrid Team 2007-2013",SIMGRID_VERSION_MAJOR,
70 SIMGRID_VERSION_MINOR);
71 *len = strlen(version) > MPI_MAX_LIBRARY_VERSION_STRING ? MPI_MAX_LIBRARY_VERSION_STRING : strlen(version);
76 int PMPI_Init_thread(int *argc, char ***argv, int required, int *provided)
78 if (provided != NULL) {
79 *provided = MPI_THREAD_MULTIPLE;
81 return MPI_Init(argc, argv);
84 int PMPI_Query_thread(int *provided)
89 if (provided == NULL) {
92 *provided = MPI_THREAD_MULTIPLE;
99 int PMPI_Is_thread_main(int *flag)
105 retval = MPI_ERR_ARG;
107 *flag = smpi_process_index() == 0;
108 retval = MPI_SUCCESS;
114 int PMPI_Abort(MPI_Comm comm, int errorcode)
117 smpi_process_destroy();
119 int rank = smpi_process_index();
120 TRACE_smpi_computing_out(rank);
122 // FIXME: should kill all processes in comm instead
123 simcall_process_kill(SIMIX_process_self());
127 double PMPI_Wtime(void)
130 if (smpi_process_initialized() && !smpi_process_finalized() && !smpi_sample_is_running) {
132 time = SIMIX_get_clock();
135 time = SIMIX_get_clock();
140 extern double sg_maxmin_precision;
141 double PMPI_Wtick(void)
143 return sg_maxmin_precision;
146 int PMPI_Address(void *location, MPI_Aint * address)
152 retval = MPI_ERR_ARG;
154 *address = (MPI_Aint) location;
155 retval = MPI_SUCCESS;
161 int PMPI_Get_address(void *location, MPI_Aint * address)
163 return PMPI_Address(location, address);
166 int PMPI_Type_free(MPI_Datatype * datatype)
172 retval = MPI_ERR_ARG;
174 smpi_datatype_free(datatype);
175 retval = MPI_SUCCESS;
181 int PMPI_Type_size(MPI_Datatype datatype, int *size)
186 if (datatype == MPI_DATATYPE_NULL) {
187 retval = MPI_ERR_TYPE;
188 } else if (size == NULL) {
189 retval = MPI_ERR_ARG;
191 *size = (int) smpi_datatype_size(datatype);
192 retval = MPI_SUCCESS;
198 int PMPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
203 if (datatype == MPI_DATATYPE_NULL) {
204 retval = MPI_ERR_TYPE;
205 } else if (lb == NULL || extent == NULL) {
206 retval = MPI_ERR_ARG;
208 retval = smpi_datatype_extent(datatype, lb, extent);
214 int PMPI_Type_get_true_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
216 return PMPI_Type_get_extent(datatype, lb, extent);
219 int PMPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent)
224 if (datatype == MPI_DATATYPE_NULL) {
225 retval = MPI_ERR_TYPE;
226 } else if (extent == NULL) {
227 retval = MPI_ERR_ARG;
229 *extent = smpi_datatype_get_extent(datatype);
230 retval = MPI_SUCCESS;
236 int PMPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp)
241 if (datatype == MPI_DATATYPE_NULL) {
242 retval = MPI_ERR_TYPE;
243 } else if (disp == NULL) {
244 retval = MPI_ERR_ARG;
246 *disp = smpi_datatype_lb(datatype);
247 retval = MPI_SUCCESS;
253 int PMPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp)
258 if (datatype == MPI_DATATYPE_NULL) {
259 retval = MPI_ERR_TYPE;
260 } else if (disp == NULL) {
261 retval = MPI_ERR_ARG;
263 *disp = smpi_datatype_ub(datatype);
264 retval = MPI_SUCCESS;
270 int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
275 if (function == NULL || op == NULL) {
276 retval = MPI_ERR_ARG;
278 *op = smpi_op_new(function, commute);
279 retval = MPI_SUCCESS;
285 int PMPI_Op_free(MPI_Op * op)
291 retval = MPI_ERR_ARG;
292 } else if (*op == MPI_OP_NULL) {
295 smpi_op_destroy(*op);
297 retval = MPI_SUCCESS;
303 int PMPI_Group_free(MPI_Group * group)
309 retval = MPI_ERR_ARG;
311 smpi_group_destroy(*group);
312 *group = MPI_GROUP_NULL;
313 retval = MPI_SUCCESS;
319 int PMPI_Group_size(MPI_Group group, int *size)
324 if (group == MPI_GROUP_NULL) {
325 retval = MPI_ERR_GROUP;
326 } else if (size == NULL) {
327 retval = MPI_ERR_ARG;
329 *size = smpi_group_size(group);
330 retval = MPI_SUCCESS;
336 int PMPI_Group_rank(MPI_Group group, int *rank)
341 if (group == MPI_GROUP_NULL) {
342 retval = MPI_ERR_GROUP;
343 } else if (rank == NULL) {
344 retval = MPI_ERR_ARG;
346 *rank = smpi_group_rank(group, smpi_process_index());
347 retval = MPI_SUCCESS;
353 int PMPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
354 MPI_Group group2, int *ranks2)
356 int retval, i, index;
358 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
359 retval = MPI_ERR_GROUP;
361 for (i = 0; i < n; i++) {
362 if(ranks1[i]==MPI_PROC_NULL){
363 ranks2[i]=MPI_PROC_NULL;
365 index = smpi_group_index(group1, ranks1[i]);
366 ranks2[i] = smpi_group_rank(group2, index);
369 retval = MPI_SUCCESS;
375 int PMPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result)
380 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
381 retval = MPI_ERR_GROUP;
382 } else if (result == NULL) {
383 retval = MPI_ERR_ARG;
385 *result = smpi_group_compare(group1, group2);
386 retval = MPI_SUCCESS;
392 int PMPI_Group_union(MPI_Group group1, MPI_Group group2,
393 MPI_Group * newgroup)
395 int retval, i, proc1, proc2, size, size2;
398 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
399 retval = MPI_ERR_GROUP;
400 } else if (newgroup == NULL) {
401 retval = MPI_ERR_ARG;
403 size = smpi_group_size(group1);
404 size2 = smpi_group_size(group2);
405 for (i = 0; i < size2; i++) {
406 proc2 = smpi_group_index(group2, i);
407 proc1 = smpi_group_rank(group1, proc2);
408 if (proc1 == MPI_UNDEFINED) {
413 *newgroup = MPI_GROUP_EMPTY;
415 *newgroup = smpi_group_new(size);
416 size2 = smpi_group_size(group1);
417 for (i = 0; i < size2; i++) {
418 proc1 = smpi_group_index(group1, i);
419 smpi_group_set_mapping(*newgroup, proc1, i);
421 for (i = size2; i < size; i++) {
422 proc2 = smpi_group_index(group2, i - size2);
423 smpi_group_set_mapping(*newgroup, proc2, i);
426 retval = MPI_SUCCESS;
432 int PMPI_Group_intersection(MPI_Group group1, MPI_Group group2,
433 MPI_Group * newgroup)
435 int retval, i, proc1, proc2, size;
438 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
439 retval = MPI_ERR_GROUP;
440 } else if (newgroup == NULL) {
441 retval = MPI_ERR_ARG;
443 size = smpi_group_size(group2);
444 for (i = 0; i < size; i++) {
445 proc2 = smpi_group_index(group2, i);
446 proc1 = smpi_group_rank(group1, proc2);
447 if (proc1 == MPI_UNDEFINED) {
452 *newgroup = MPI_GROUP_EMPTY;
454 *newgroup = smpi_group_new(size);
456 for (i = 0; i < smpi_group_size(group2); i++) {
457 proc2 = smpi_group_index(group2, i);
458 proc1 = smpi_group_rank(group1, proc2);
459 if (proc1 != MPI_UNDEFINED) {
460 smpi_group_set_mapping(*newgroup, proc2, j);
465 retval = MPI_SUCCESS;
471 int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgroup)
473 int retval, i, proc1, proc2, size, size2;
476 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
477 retval = MPI_ERR_GROUP;
478 } else if (newgroup == NULL) {
479 retval = MPI_ERR_ARG;
481 size = size2 = smpi_group_size(group1);
482 for (i = 0; i < size2; i++) {
483 proc1 = smpi_group_index(group1, i);
484 proc2 = smpi_group_rank(group2, proc1);
485 if (proc2 != MPI_UNDEFINED) {
490 *newgroup = MPI_GROUP_EMPTY;
492 *newgroup = smpi_group_new(size);
493 for (i = 0; i < size2; i++) {
494 proc1 = smpi_group_index(group1, i);
495 proc2 = smpi_group_rank(group2, proc1);
496 if (proc2 == MPI_UNDEFINED) {
497 smpi_group_set_mapping(*newgroup, proc1, i);
501 retval = MPI_SUCCESS;
507 int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
509 int retval, i, index;
512 if (group == MPI_GROUP_NULL) {
513 retval = MPI_ERR_GROUP;
514 } else if (newgroup == NULL) {
515 retval = MPI_ERR_ARG;
518 *newgroup = MPI_GROUP_EMPTY;
519 } else if (n == smpi_group_size(group)) {
521 if(group!= smpi_comm_group(MPI_COMM_WORLD)
522 && group != MPI_GROUP_NULL
523 && group != smpi_comm_group(MPI_COMM_SELF)
524 && group != MPI_GROUP_EMPTY)
525 smpi_group_use(group);
527 *newgroup = smpi_group_new(n);
528 for (i = 0; i < n; i++) {
529 index = smpi_group_index(group, ranks[i]);
530 smpi_group_set_mapping(*newgroup, index, i);
533 retval = MPI_SUCCESS;
539 int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
541 int retval, i, j, newsize, oldsize, index;
544 if (group == MPI_GROUP_NULL) {
545 retval = MPI_ERR_GROUP;
546 } else if (newgroup == NULL) {
547 retval = MPI_ERR_ARG;
551 if(group!= smpi_comm_group(MPI_COMM_WORLD)
552 && group != MPI_GROUP_NULL
553 && group != smpi_comm_group(MPI_COMM_SELF)
554 && group != MPI_GROUP_EMPTY)
555 smpi_group_use(group);
556 } else if (n == smpi_group_size(group)) {
557 *newgroup = MPI_GROUP_EMPTY;
559 oldsize=smpi_group_size(group);
560 newsize = oldsize - n;
561 *newgroup = smpi_group_new(newsize);
563 int* to_exclude=xbt_new(int, smpi_group_size(group));
564 for(i=0; i<oldsize; i++)
567 to_exclude[ranks[i]]=1;
570 for(i=0; i<oldsize; i++){
571 if(to_exclude[i]==0){
572 index = smpi_group_index(group, i);
573 smpi_group_set_mapping(*newgroup, index, j);
578 xbt_free(to_exclude);
580 retval = MPI_SUCCESS;
586 int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
587 MPI_Group * newgroup)
589 int retval, i, j, rank, size, index;
592 if (group == MPI_GROUP_NULL) {
593 retval = MPI_ERR_GROUP;
594 } else if (newgroup == NULL) {
595 retval = MPI_ERR_ARG;
598 *newgroup = MPI_GROUP_EMPTY;
601 for (i = 0; i < n; i++) {
602 for (rank = ranges[i][0]; /* First */
603 rank >= 0; /* Last */
607 rank += ranges[i][2]; /* Stride */
608 if (ranges[i][0]<ranges[i][1]){
609 if(rank > ranges[i][1])
612 if(rank < ranges[i][1])
618 *newgroup = smpi_group_new(size);
620 for (i = 0; i < n; i++) {
621 for (rank = ranges[i][0]; /* First */
622 rank >= 0; /* Last */
624 index = smpi_group_index(group, rank);
625 smpi_group_set_mapping(*newgroup, index, j);
627 rank += ranges[i][2]; /* Stride */
628 if (ranges[i][0]<ranges[i][1]){
629 if(rank > ranges[i][1])
632 if(rank < ranges[i][1])
638 retval = MPI_SUCCESS;
644 int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
645 MPI_Group * newgroup)
647 int retval, i, rank, newrank,oldrank, size, index, add;
650 if (group == MPI_GROUP_NULL) {
651 retval = MPI_ERR_GROUP;
652 } else if (newgroup == NULL) {
653 retval = MPI_ERR_ARG;
657 if(group!= smpi_comm_group(MPI_COMM_WORLD)
658 && group != MPI_GROUP_NULL
659 && group != smpi_comm_group(MPI_COMM_SELF)
660 && group != MPI_GROUP_EMPTY)
661 smpi_group_use(group);
663 size = smpi_group_size(group);
664 for (i = 0; i < n; i++) {
665 for (rank = ranges[i][0]; /* First */
666 rank >= 0; /* Last */
670 rank += ranges[i][2]; /* Stride */
671 if (ranges[i][0]<ranges[i][1]){
672 if(rank > ranges[i][1])
675 if(rank < ranges[i][1])
681 *newgroup = MPI_GROUP_EMPTY;
683 *newgroup = smpi_group_new(size);
686 while (newrank < size) {
688 for (i = 0; i < n; i++) {
689 for (rank = ranges[i][0];rank >= 0;){
695 rank += ranges[i][2]; /* Stride */
697 if (ranges[i][0]<ranges[i][1]){
698 if(rank > ranges[i][1])
701 if(rank < ranges[i][1])
707 index = smpi_group_index(group, oldrank);
708 smpi_group_set_mapping(*newgroup, index, newrank);
716 retval = MPI_SUCCESS;
722 int PMPI_Comm_rank(MPI_Comm comm, int *rank)
727 if (comm == MPI_COMM_NULL) {
728 retval = MPI_ERR_COMM;
729 } else if (rank == NULL) {
730 retval = MPI_ERR_ARG;
732 *rank = smpi_comm_rank(comm);
733 retval = MPI_SUCCESS;
739 int PMPI_Comm_size(MPI_Comm comm, int *size)
744 if (comm == MPI_COMM_NULL) {
745 retval = MPI_ERR_COMM;
746 } else if (size == NULL) {
747 retval = MPI_ERR_ARG;
749 *size = smpi_comm_size(comm);
750 retval = MPI_SUCCESS;
756 int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len)
761 if (comm == MPI_COMM_NULL) {
762 retval = MPI_ERR_COMM;
763 } else if (name == NULL || len == NULL) {
764 retval = MPI_ERR_ARG;
766 smpi_comm_get_name(comm, name, len);
767 retval = MPI_SUCCESS;
773 int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
778 if (comm == MPI_COMM_NULL) {
779 retval = MPI_ERR_COMM;
780 } else if (group == NULL) {
781 retval = MPI_ERR_ARG;
783 *group = smpi_comm_group(comm);
784 if(*group!= smpi_comm_group(MPI_COMM_WORLD)
785 && *group != MPI_GROUP_NULL
786 && *group != smpi_comm_group(MPI_COMM_SELF)
787 && *group != MPI_GROUP_EMPTY)
788 smpi_group_use(*group);
789 retval = MPI_SUCCESS;
795 int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
800 if (comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) {
801 retval = MPI_ERR_COMM;
802 } else if (result == NULL) {
803 retval = MPI_ERR_ARG;
805 if (comm1 == comm2) { /* Same communicators means same groups */
809 smpi_group_compare(smpi_comm_group(comm1),
810 smpi_comm_group(comm2));
811 if (*result == MPI_IDENT) {
812 *result = MPI_CONGRUENT;
815 retval = MPI_SUCCESS;
821 int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm)
826 if (comm == MPI_COMM_NULL) {
827 retval = MPI_ERR_COMM;
828 } else if (newcomm == NULL) {
829 retval = MPI_ERR_ARG;
831 *newcomm = smpi_comm_new(smpi_comm_group(comm));
832 retval = MPI_SUCCESS;
838 int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
843 if (comm == MPI_COMM_NULL) {
844 retval = MPI_ERR_COMM;
845 } else if (group == MPI_GROUP_NULL) {
846 retval = MPI_ERR_GROUP;
847 } else if (newcomm == NULL) {
848 retval = MPI_ERR_ARG;
849 } else if(smpi_group_rank(group,smpi_process_index())==MPI_UNDEFINED){
850 *newcomm= MPI_COMM_NULL;
851 retval = MPI_SUCCESS;
854 *newcomm = smpi_comm_new(group);
855 retval = MPI_SUCCESS;
861 int PMPI_Comm_free(MPI_Comm * comm)
867 retval = MPI_ERR_ARG;
868 } else if (*comm == MPI_COMM_NULL) {
869 retval = MPI_ERR_COMM;
871 smpi_comm_destroy(*comm);
872 *comm = MPI_COMM_NULL;
873 retval = MPI_SUCCESS;
879 int PMPI_Comm_disconnect(MPI_Comm * comm)
881 /* TODO: wait until all communication in comm are done */
886 retval = MPI_ERR_ARG;
887 } else if (*comm == MPI_COMM_NULL) {
888 retval = MPI_ERR_COMM;
890 smpi_comm_destroy(*comm);
891 *comm = MPI_COMM_NULL;
892 retval = MPI_SUCCESS;
898 int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out)
903 if (comm_out == NULL) {
904 retval = MPI_ERR_ARG;
905 } else if (comm == MPI_COMM_NULL) {
906 retval = MPI_ERR_COMM;
908 *comm_out = smpi_comm_split(comm, color, key);
909 retval = MPI_SUCCESS;
915 int PMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst,
916 int tag, MPI_Comm comm, MPI_Request * request)
921 if (request == NULL) {
922 retval = MPI_ERR_ARG;
923 } else if (comm == MPI_COMM_NULL) {
924 retval = MPI_ERR_COMM;
925 } else if (dst == MPI_PROC_NULL) {
926 retval = MPI_SUCCESS;
928 *request = smpi_mpi_send_init(buf, count, datatype, dst, tag, comm);
929 retval = MPI_SUCCESS;
932 if (retval != MPI_SUCCESS && request)
933 *request = MPI_REQUEST_NULL;
937 int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src,
938 int tag, MPI_Comm comm, MPI_Request * request)
943 if (request == NULL) {
944 retval = MPI_ERR_ARG;
945 } else if (comm == MPI_COMM_NULL) {
946 retval = MPI_ERR_COMM;
947 } else if (src == MPI_PROC_NULL) {
948 retval = MPI_SUCCESS;
950 *request = smpi_mpi_recv_init(buf, count, datatype, src, tag, comm);
951 retval = MPI_SUCCESS;
954 if (retval != MPI_SUCCESS && request)
955 *request = MPI_REQUEST_NULL;
959 int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype,
960 int dst, int tag, MPI_Comm comm, MPI_Request* request)
965 if (request == NULL) {
966 retval = MPI_ERR_ARG;
967 } else if (comm == MPI_COMM_NULL) {
968 retval = MPI_ERR_COMM;
969 } else if (dst == MPI_PROC_NULL) {
970 retval = MPI_SUCCESS;
972 *request = smpi_mpi_ssend_init(buf, count, datatype, dst, tag, comm);
973 retval = MPI_SUCCESS;
976 if (retval != MPI_SUCCESS && request)
977 *request = MPI_REQUEST_NULL;
981 int PMPI_Start(MPI_Request * request)
986 if (request == NULL || *request == MPI_REQUEST_NULL) {
987 retval = MPI_ERR_ARG;
989 smpi_mpi_start(*request);
990 retval = MPI_SUCCESS;
996 int PMPI_Startall(int count, MPI_Request * requests)
1001 if (requests == NULL) {
1002 retval = MPI_ERR_ARG;
1004 smpi_mpi_startall(count, requests);
1005 retval = MPI_SUCCESS;
1011 int PMPI_Request_free(MPI_Request * request)
1016 if (*request == MPI_REQUEST_NULL) {
1017 retval = MPI_ERR_ARG;
1019 if((*request)->flags & PERSISTENT)(*request)->refcount--;
1020 smpi_mpi_request_free(request);
1021 retval = MPI_SUCCESS;
1027 int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src,
1028 int tag, MPI_Comm comm, MPI_Request * request)
1034 if (request == NULL) {
1035 retval = MPI_ERR_ARG;
1036 } else if (comm == MPI_COMM_NULL) {
1037 retval = MPI_ERR_COMM;
1038 } else if (src == MPI_PROC_NULL) {
1039 *request = MPI_REQUEST_NULL;
1040 retval = MPI_SUCCESS;
1041 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
1042 retval = MPI_ERR_COMM;
1043 } else if (count < 0) {
1044 retval = MPI_ERR_COUNT;
1045 } else if (buf==NULL && count > 0) {
1046 retval = MPI_ERR_COUNT;
1047 } else if (datatype == MPI_DATATYPE_NULL){
1048 retval = MPI_ERR_TYPE;
1049 } else if(tag<0 && tag != MPI_ANY_TAG){
1050 retval = MPI_ERR_TAG;
1054 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1055 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1056 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, count*smpi_datatype_size(datatype));
1059 *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm);
1060 retval = MPI_SUCCESS;
1063 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1064 (*request)->recv = 1;
1069 if (retval != MPI_SUCCESS && request)
1070 *request = MPI_REQUEST_NULL;
1075 int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
1076 int tag, MPI_Comm comm, MPI_Request * request)
1081 if (request == NULL) {
1082 retval = MPI_ERR_ARG;
1083 } else if (comm == MPI_COMM_NULL) {
1084 retval = MPI_ERR_COMM;
1085 } else if (dst == MPI_PROC_NULL) {
1086 *request = MPI_REQUEST_NULL;
1087 retval = MPI_SUCCESS;
1088 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1089 retval = MPI_ERR_RANK;
1090 } else if (count < 0) {
1091 retval = MPI_ERR_COUNT;
1092 } else if (buf==NULL && count > 0) {
1093 retval = MPI_ERR_COUNT;
1094 } else if (datatype == MPI_DATATYPE_NULL){
1095 retval = MPI_ERR_TYPE;
1096 } else if(tag<0 && tag != MPI_ANY_TAG){
1097 retval = MPI_ERR_TAG;
1101 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1102 TRACE_smpi_computing_out(rank);
1103 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1104 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype));
1105 TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype));
1108 *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm);
1109 retval = MPI_SUCCESS;
1112 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1113 (*request)->send = 1;
1114 TRACE_smpi_computing_in(rank);
1119 if (retval != MPI_SUCCESS && request)
1120 *request = MPI_REQUEST_NULL;
1124 int PMPI_Issend(void* buf, int count, MPI_Datatype datatype,
1125 int dst, int tag, MPI_Comm comm, MPI_Request* request)
1130 if (request == NULL) {
1131 retval = MPI_ERR_ARG;
1132 } else if (comm == MPI_COMM_NULL) {
1133 retval = MPI_ERR_COMM;
1134 } else if (dst == MPI_PROC_NULL) {
1135 *request = MPI_REQUEST_NULL;
1136 retval = MPI_SUCCESS;
1137 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1138 retval = MPI_ERR_RANK;
1139 } else if (count < 0) {
1140 retval = MPI_ERR_COUNT;
1141 } else if (buf==NULL && count > 0) {
1142 retval = MPI_ERR_COUNT;
1143 } else if (datatype == MPI_DATATYPE_NULL){
1144 retval = MPI_ERR_TYPE;
1145 } else if(tag<0 && tag != MPI_ANY_TAG){
1146 retval = MPI_ERR_TAG;
1150 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1151 TRACE_smpi_computing_out(rank);
1152 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1153 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype));
1154 TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype));
1157 *request = smpi_mpi_issend(buf, count, datatype, dst, tag, comm);
1158 retval = MPI_SUCCESS;
1161 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1162 (*request)->send = 1;
1163 TRACE_smpi_computing_in(rank);
1168 if (retval != MPI_SUCCESS && request)
1169 *request = MPI_REQUEST_NULL;
1173 int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
1174 MPI_Comm comm, MPI_Status * status)
1179 if (comm == MPI_COMM_NULL) {
1180 retval = MPI_ERR_COMM;
1181 } else if (src == MPI_PROC_NULL) {
1182 smpi_empty_status(status);
1183 status->MPI_SOURCE = MPI_PROC_NULL;
1184 retval = MPI_SUCCESS;
1185 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
1186 retval = MPI_ERR_RANK;
1187 } else if (count < 0) {
1188 retval = MPI_ERR_COUNT;
1189 } else if (buf==NULL && count > 0) {
1190 retval = MPI_ERR_COUNT;
1191 } else if (datatype == MPI_DATATYPE_NULL){
1192 retval = MPI_ERR_TYPE;
1193 } else if(tag<0 && tag != MPI_ANY_TAG){
1194 retval = MPI_ERR_TAG;
1197 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1198 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1199 TRACE_smpi_computing_out(rank);
1200 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, count*smpi_datatype_size(datatype));
1203 smpi_mpi_recv(buf, count, datatype, src, tag, comm, status);
1204 retval = MPI_SUCCESS;
1207 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1208 if(status!=MPI_STATUS_IGNORE)src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
1209 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1210 TRACE_smpi_recv(rank, src_traced, rank);
1211 TRACE_smpi_computing_in(rank);
1219 int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
1226 if (comm == MPI_COMM_NULL) {
1227 retval = MPI_ERR_COMM;
1228 } else if (dst == MPI_PROC_NULL) {
1229 retval = MPI_SUCCESS;
1230 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1231 retval = MPI_ERR_RANK;
1232 } else if (count < 0) {
1233 retval = MPI_ERR_COUNT;
1234 } else if (buf==NULL && count > 0) {
1235 retval = MPI_ERR_COUNT;
1236 } else if (datatype == MPI_DATATYPE_NULL){
1237 retval = MPI_ERR_TYPE;
1238 } else if(tag<0 && tag != MPI_ANY_TAG){
1239 retval = MPI_ERR_TAG;
1243 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1244 TRACE_smpi_computing_out(rank);
1245 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1246 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype));
1247 TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype));
1250 smpi_mpi_send(buf, count, datatype, dst, tag, comm);
1251 retval = MPI_SUCCESS;
1254 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1255 TRACE_smpi_computing_in(rank);
1265 int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
1270 if (comm == MPI_COMM_NULL) {
1271 retval = MPI_ERR_COMM;
1272 } else if (dst == MPI_PROC_NULL) {
1273 retval = MPI_SUCCESS;
1274 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1275 retval = MPI_ERR_RANK;
1276 } else if (count < 0) {
1277 retval = MPI_ERR_COUNT;
1278 } else if (buf==NULL && count > 0) {
1279 retval = MPI_ERR_COUNT;
1280 } else if (datatype == MPI_DATATYPE_NULL){
1281 retval = MPI_ERR_TYPE;
1282 } else if(tag<0 && tag != MPI_ANY_TAG){
1283 retval = MPI_ERR_TAG;
1287 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1288 TRACE_smpi_computing_out(rank);
1289 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1290 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype));
1291 TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype));
1294 smpi_mpi_ssend(buf, count, datatype, dst, tag, comm);
1295 retval = MPI_SUCCESS;
1298 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1299 TRACE_smpi_computing_in(rank);
1307 int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1308 int dst, int sendtag, void *recvbuf, int recvcount,
1309 MPI_Datatype recvtype, int src, int recvtag,
1310 MPI_Comm comm, MPI_Status * status)
1316 if (comm == MPI_COMM_NULL) {
1317 retval = MPI_ERR_COMM;
1318 } else if (sendtype == MPI_DATATYPE_NULL
1319 || recvtype == MPI_DATATYPE_NULL) {
1320 retval = MPI_ERR_TYPE;
1321 } else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
1322 smpi_empty_status(status);
1323 status->MPI_SOURCE = MPI_PROC_NULL;
1324 retval = MPI_SUCCESS;
1325 }else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0 ||
1326 (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0))){
1327 retval = MPI_ERR_RANK;
1328 } else if (sendcount < 0 || recvcount<0) {
1329 retval = MPI_ERR_COUNT;
1330 } else if ((sendbuf==NULL && sendcount > 0)||(recvbuf==NULL && recvcount>0)) {
1331 retval = MPI_ERR_COUNT;
1332 } else if((sendtag<0 && sendtag != MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){
1333 retval = MPI_ERR_TAG;
1337 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1338 TRACE_smpi_computing_out(rank);
1339 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1340 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1341 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, sendcount*smpi_datatype_size(sendtype));
1342 TRACE_smpi_send(rank, rank, dst_traced,sendcount*smpi_datatype_size(sendtype));
1346 smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf,
1347 recvcount, recvtype, src, recvtag, comm, status);
1348 retval = MPI_SUCCESS;
1351 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1352 TRACE_smpi_recv(rank, src_traced, rank);
1353 TRACE_smpi_computing_in(rank);
1362 int PMPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
1363 int dst, int sendtag, int src, int recvtag,
1364 MPI_Comm comm, MPI_Status * status)
1366 //TODO: suboptimal implementation
1369 if (datatype == MPI_DATATYPE_NULL) {
1370 retval = MPI_ERR_TYPE;
1371 } else if (count < 0) {
1372 retval = MPI_ERR_COUNT;
1374 int size = smpi_datatype_get_extent(datatype) * count;
1375 recvbuf = xbt_new(char, size);
1377 MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
1378 datatype, src, recvtag, comm, status);
1379 if(retval==MPI_SUCCESS){
1380 smpi_datatype_copy(recvbuf, count, datatype, buf, count, datatype);
1388 int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
1393 if (request == NULL || flag == NULL) {
1394 retval = MPI_ERR_ARG;
1395 } else if (*request == MPI_REQUEST_NULL) {
1397 smpi_empty_status(status);
1398 retval = MPI_ERR_REQUEST;
1400 *flag = smpi_mpi_test(request, status);
1401 retval = MPI_SUCCESS;
1407 int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
1408 MPI_Status * status)
1413 if (index == NULL || flag == NULL) {
1414 retval = MPI_ERR_ARG;
1416 *flag = smpi_mpi_testany(count, requests, index, status);
1417 retval = MPI_SUCCESS;
1423 int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses)
1429 retval = MPI_ERR_ARG;
1431 *flag = smpi_mpi_testall(count, requests, statuses);
1432 retval = MPI_SUCCESS;
1438 int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) {
1442 if (status == NULL) {
1443 retval = MPI_ERR_ARG;
1444 } else if (comm == MPI_COMM_NULL) {
1445 retval = MPI_ERR_COMM;
1446 } else if (source == MPI_PROC_NULL) {
1447 smpi_empty_status(status);
1448 status->MPI_SOURCE = MPI_PROC_NULL;
1449 retval = MPI_SUCCESS;
1451 smpi_mpi_probe(source, tag, comm, status);
1452 retval = MPI_SUCCESS;
1459 int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status) {
1464 retval = MPI_ERR_ARG;
1465 } else if (status == NULL) {
1466 retval = MPI_ERR_ARG;
1467 } else if (comm == MPI_COMM_NULL) {
1468 retval = MPI_ERR_COMM;
1469 } else if (source == MPI_PROC_NULL) {
1471 smpi_empty_status(status);
1472 status->MPI_SOURCE = MPI_PROC_NULL;
1473 retval = MPI_SUCCESS;
1475 smpi_mpi_iprobe(source, tag, comm, flag, status);
1476 retval = MPI_SUCCESS;
1482 int PMPI_Wait(MPI_Request * request, MPI_Status * status)
1488 smpi_empty_status(status);
1490 if (request == NULL) {
1491 retval = MPI_ERR_ARG;
1492 } else if (*request == MPI_REQUEST_NULL) {
1493 retval = MPI_ERR_REQUEST;
1497 int rank = request && (*request)->comm != MPI_COMM_NULL
1498 ? smpi_process_index()
1500 TRACE_smpi_computing_out(rank);
1502 int src_traced = (*request)->src;
1503 int dst_traced = (*request)->dst;
1504 MPI_Comm comm = (*request)->comm;
1505 int is_wait_for_receive = (*request)->recv;
1506 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__,-1);
1509 smpi_mpi_wait(request, status);
1510 retval = MPI_SUCCESS;
1513 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1514 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1515 if (is_wait_for_receive) {
1516 if(src_traced==MPI_ANY_SOURCE)
1517 src_traced = (status!=MPI_STATUS_IGNORE) ?
1518 smpi_group_rank(smpi_comm_group(comm), status->MPI_SOURCE) :
1520 TRACE_smpi_recv(rank, src_traced, dst_traced);
1522 TRACE_smpi_computing_in(rank);
1531 int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * status)
1537 //save requests information for tracing
1539 int *srcs = xbt_new(int, count);
1540 int *dsts = xbt_new(int, count);
1541 int *recvs = xbt_new(int, count);
1542 MPI_Comm *comms = xbt_new(MPI_Comm, count);
1544 for (i = 0; i < count; i++) {
1545 MPI_Request req = requests[i]; //already received requests are no longer valid
1549 recvs[i] = req->recv;
1550 comms[i] = req->comm;
1553 int rank_traced = smpi_process_index();
1554 TRACE_smpi_computing_out(rank_traced);
1556 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,count);
1559 if (index == NULL) {
1560 retval = MPI_ERR_ARG;
1562 *index = smpi_mpi_waitany(count, requests, status);
1563 retval = MPI_SUCCESS;
1566 if(*index!=MPI_UNDEFINED){
1567 int src_traced = srcs[*index];
1568 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1569 int dst_traced = dsts[*index];
1570 int is_wait_for_receive = recvs[*index];
1571 if (is_wait_for_receive) {
1572 if(srcs[*index]==MPI_ANY_SOURCE)
1573 src_traced = (status!=MPI_STATUSES_IGNORE) ?
1574 smpi_group_rank(smpi_comm_group(comms[*index]), status->MPI_SOURCE) :
1576 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1578 TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__);
1585 TRACE_smpi_computing_in(rank_traced);
1591 int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
1596 //save information from requests
1598 int *srcs = xbt_new(int, count);
1599 int *dsts = xbt_new(int, count);
1600 int *recvs = xbt_new(int, count);
1601 int *valid = xbt_new(int, count);
1602 MPI_Comm *comms = xbt_new(MPI_Comm, count);
1604 //int valid_count = 0;
1605 for (i = 0; i < count; i++) {
1606 MPI_Request req = requests[i];
1607 if(req!=MPI_REQUEST_NULL){
1610 recvs[i] = req->recv;
1611 comms[i] = req->comm;
1617 int rank_traced = smpi_process_index();
1618 TRACE_smpi_computing_out(rank_traced);
1620 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,count);
1622 int retval = smpi_mpi_waitall(count, requests, status);
1624 for (i = 0; i < count; i++) {
1626 //int src_traced = srcs[*index];
1627 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1628 int src_traced = srcs[i];
1629 int dst_traced = dsts[i];
1630 int is_wait_for_receive = recvs[i];
1631 if (is_wait_for_receive) {
1632 if(src_traced==MPI_ANY_SOURCE)
1633 src_traced = (status!=MPI_STATUSES_IGNORE) ?
1634 smpi_group_rank(smpi_comm_group(comms[i]), status[i].MPI_SOURCE) :
1636 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1640 TRACE_smpi_ptp_out(rank_traced, -1, -1, __FUNCTION__);
1647 TRACE_smpi_computing_in(rank_traced);
1653 int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
1654 int *indices, MPI_Status status[])
1659 if (outcount == NULL) {
1660 retval = MPI_ERR_ARG;
1662 *outcount = smpi_mpi_waitsome(incount, requests, indices, status);
1663 retval = MPI_SUCCESS;
1669 int PMPI_Testsome(int incount, MPI_Request requests[], int* outcount,
1670 int* indices, MPI_Status status[])
1675 if (outcount == NULL) {
1676 retval = MPI_ERR_ARG;
1678 *outcount = smpi_mpi_testsome(incount, requests, indices, status);
1679 retval = MPI_SUCCESS;
1686 int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
1692 if (comm == MPI_COMM_NULL) {
1693 retval = MPI_ERR_COMM;
1696 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1697 TRACE_smpi_computing_out(rank);
1698 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1699 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, count*smpi_datatype_size(datatype));
1701 mpi_coll_bcast_fun(buf, count, datatype, root, comm);
1702 retval = MPI_SUCCESS;
1704 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1705 TRACE_smpi_computing_in(rank);
1713 int PMPI_Barrier(MPI_Comm comm)
1719 if (comm == MPI_COMM_NULL) {
1720 retval = MPI_ERR_COMM;
1723 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1724 TRACE_smpi_computing_out(rank);
1725 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, smpi_comm_size(comm));
1727 mpi_coll_barrier_fun(comm);
1728 retval = MPI_SUCCESS;
1730 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1731 TRACE_smpi_computing_in(rank);
1739 int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1740 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1741 int root, MPI_Comm comm)
1747 if (comm == MPI_COMM_NULL) {
1748 retval = MPI_ERR_COMM;
1749 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1750 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1751 retval = MPI_ERR_TYPE;
1752 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1753 ((smpi_comm_rank(comm) == root) && (recvcount <0))){
1754 retval = MPI_ERR_COUNT;
1757 char* sendtmpbuf = (char*) sendbuf;
1758 int sendtmpcount = sendcount;
1759 MPI_Datatype sendtmptype = sendtype;
1760 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1762 sendtmptype=recvtype;
1765 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1766 TRACE_smpi_computing_out(rank);
1767 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1768 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,sendcount*smpi_datatype_size(sendtmptype));
1770 mpi_coll_gather_fun(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcount,
1771 recvtype, root, comm);
1774 retval = MPI_SUCCESS;
1776 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1777 TRACE_smpi_computing_in(rank);
1785 int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1786 void *recvbuf, int *recvcounts, int *displs,
1787 MPI_Datatype recvtype, int root, MPI_Comm comm)
1793 if (comm == MPI_COMM_NULL) {
1794 retval = MPI_ERR_COMM;
1795 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1796 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1797 retval = MPI_ERR_TYPE;
1798 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1799 retval = MPI_ERR_COUNT;
1800 } else if (recvcounts == NULL || displs == NULL) {
1801 retval = MPI_ERR_ARG;
1803 char* sendtmpbuf = (char*) sendbuf;
1804 int sendtmpcount = sendcount;
1805 MPI_Datatype sendtmptype = sendtype;
1806 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1808 sendtmptype=recvtype;
1812 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1813 TRACE_smpi_computing_out(rank);
1814 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1815 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,sendcount*smpi_datatype_size(sendtmptype));
1817 smpi_mpi_gatherv(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcounts,
1818 displs, recvtype, root, comm);
1819 retval = MPI_SUCCESS;
1821 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1822 TRACE_smpi_computing_in(rank);
1830 int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1831 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1838 if (comm == MPI_COMM_NULL) {
1839 retval = MPI_ERR_COMM;
1840 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1841 (recvtype == MPI_DATATYPE_NULL)){
1842 retval = MPI_ERR_TYPE;
1843 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1845 retval = MPI_ERR_COUNT;
1847 if(sendbuf == MPI_IN_PLACE) {
1848 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*recvcount*smpi_comm_rank(comm);
1849 sendcount=recvcount;
1853 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1854 TRACE_smpi_computing_out(rank);
1855 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,sendcount*smpi_datatype_size(sendtype));
1857 mpi_coll_allgather_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1859 retval = MPI_SUCCESS;
1862 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1869 int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1870 void *recvbuf, int *recvcounts, int *displs,
1871 MPI_Datatype recvtype, MPI_Comm comm)
1877 if (comm == MPI_COMM_NULL) {
1878 retval = MPI_ERR_COMM;
1879 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1880 (recvtype == MPI_DATATYPE_NULL)){
1881 retval = MPI_ERR_TYPE;
1882 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1883 retval = MPI_ERR_COUNT;
1884 } else if (recvcounts == NULL || displs == NULL) {
1885 retval = MPI_ERR_ARG;
1888 if(sendbuf == MPI_IN_PLACE) {
1889 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*displs[smpi_comm_rank(comm)];
1890 sendcount=recvcounts[smpi_comm_rank(comm)];
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__,sendcount*smpi_datatype_size(sendtype));
1898 mpi_coll_allgatherv_fun(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
1899 displs, recvtype, comm);
1900 retval = MPI_SUCCESS;
1902 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1903 TRACE_smpi_computing_in(rank);
1911 int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1912 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1913 int root, MPI_Comm comm)
1919 if (comm == MPI_COMM_NULL) {
1920 retval = MPI_ERR_COMM;
1921 } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
1922 || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
1923 retval = MPI_ERR_TYPE;
1926 if (recvbuf == MPI_IN_PLACE) {
1928 recvcount=sendcount;
1931 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1932 TRACE_smpi_computing_out(rank);
1933 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1935 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,sendcount*smpi_datatype_size(recvtype));
1937 mpi_coll_scatter_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1938 recvtype, root, comm);
1939 retval = MPI_SUCCESS;
1941 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1942 TRACE_smpi_computing_in(rank);
1950 int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
1951 MPI_Datatype sendtype, void *recvbuf, int recvcount,
1952 MPI_Datatype recvtype, int root, MPI_Comm comm)
1958 if (comm == MPI_COMM_NULL) {
1959 retval = MPI_ERR_COMM;
1960 } else if (sendcounts == NULL || displs == NULL) {
1961 retval = MPI_ERR_ARG;
1962 } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
1963 || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
1964 retval = MPI_ERR_TYPE;
1966 if (recvbuf == MPI_IN_PLACE) {
1968 recvcount=sendcounts[smpi_comm_rank(comm)];
1971 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1972 TRACE_smpi_computing_out(rank);
1973 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1975 for(i=0; i<smpi_comm_size(comm);i++)count+=sendcounts[i];
1976 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, count*smpi_datatype_size(sendtype));
1978 smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
1979 recvcount, recvtype, root, comm);
1980 retval = MPI_SUCCESS;
1982 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1983 TRACE_smpi_computing_in(rank);
1991 int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
1992 MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
1998 if (comm == MPI_COMM_NULL) {
1999 retval = MPI_ERR_COMM;
2000 } else if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
2001 retval = MPI_ERR_ARG;
2004 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2005 TRACE_smpi_computing_out(rank);
2006 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
2007 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, count*smpi_datatype_size(datatype));
2009 mpi_coll_reduce_fun(sendbuf, recvbuf, count, datatype, op, root, comm);
2011 retval = MPI_SUCCESS;
2013 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
2014 TRACE_smpi_computing_in(rank);
2022 int PMPI_Reduce_local(void *inbuf, void *inoutbuf, int count,
2023 MPI_Datatype datatype, MPI_Op op){
2027 if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
2028 retval = MPI_ERR_ARG;
2030 smpi_op_apply(op, inbuf, inoutbuf, &count, &datatype);
2037 int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
2038 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2044 if (comm == MPI_COMM_NULL) {
2045 retval = MPI_ERR_COMM;
2046 } else if (datatype == MPI_DATATYPE_NULL) {
2047 retval = MPI_ERR_TYPE;
2048 } else if (op == MPI_OP_NULL) {
2049 retval = MPI_ERR_OP;
2052 char* sendtmpbuf = (char*) sendbuf;
2053 if( sendbuf == MPI_IN_PLACE ) {
2054 sendtmpbuf = (char *)xbt_malloc(count*smpi_datatype_get_extent(datatype));
2055 smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
2058 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2059 TRACE_smpi_computing_out(rank);
2060 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, count*smpi_datatype_size(datatype));
2062 mpi_coll_allreduce_fun(sendtmpbuf, recvbuf, count, datatype, op, comm);
2064 if( sendbuf == MPI_IN_PLACE ) {
2065 xbt_free(sendtmpbuf);
2068 retval = MPI_SUCCESS;
2070 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2071 TRACE_smpi_computing_in(rank);
2079 int PMPI_Scan(void *sendbuf, void *recvbuf, int count,
2080 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2086 if (comm == MPI_COMM_NULL) {
2087 retval = MPI_ERR_COMM;
2088 } else if (datatype == MPI_DATATYPE_NULL) {
2089 retval = MPI_ERR_TYPE;
2090 } else if (op == MPI_OP_NULL) {
2091 retval = MPI_ERR_OP;
2094 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2095 TRACE_smpi_computing_out(rank);
2096 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, count*smpi_datatype_size(datatype));
2098 smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm);
2099 retval = MPI_SUCCESS;
2101 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2102 TRACE_smpi_computing_in(rank);
2110 int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
2111 MPI_Op op, MPI_Comm comm){
2116 if (comm == MPI_COMM_NULL) {
2117 retval = MPI_ERR_COMM;
2118 } else if (datatype == MPI_DATATYPE_NULL) {
2119 retval = MPI_ERR_TYPE;
2120 } else if (op == MPI_OP_NULL) {
2121 retval = MPI_ERR_OP;
2124 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2125 TRACE_smpi_computing_out(rank);
2126 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, count*smpi_datatype_size(datatype));
2128 smpi_mpi_exscan(sendbuf, recvbuf, count, datatype, op, comm);
2129 retval = MPI_SUCCESS;
2131 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2132 TRACE_smpi_computing_in(rank);
2140 int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
2141 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2146 if (comm == MPI_COMM_NULL) {
2147 retval = MPI_ERR_COMM;
2148 } else if (datatype == MPI_DATATYPE_NULL) {
2149 retval = MPI_ERR_TYPE;
2150 } else if (op == MPI_OP_NULL) {
2151 retval = MPI_ERR_OP;
2152 } else if (recvcounts == NULL) {
2153 retval = MPI_ERR_ARG;
2156 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2157 TRACE_smpi_computing_out(rank);
2159 for(i=0; i<smpi_comm_size(comm);i++)count+=recvcounts[i];
2160 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, count*smpi_datatype_size(datatype));
2162 void* sendtmpbuf=sendbuf;
2163 if(sendbuf==MPI_IN_PLACE){
2167 mpi_coll_reduce_scatter_fun(sendtmpbuf, recvbuf, recvcounts,
2168 datatype, op, comm);
2169 retval = MPI_SUCCESS;
2171 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2172 TRACE_smpi_computing_in(rank);
2180 int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
2181 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2186 if (comm == MPI_COMM_NULL) {
2187 retval = MPI_ERR_COMM;
2188 } else if (datatype == MPI_DATATYPE_NULL) {
2189 retval = MPI_ERR_TYPE;
2190 } else if (op == MPI_OP_NULL) {
2191 retval = MPI_ERR_OP;
2192 } else if (recvcount < 0) {
2193 retval = MPI_ERR_ARG;
2196 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2197 TRACE_smpi_computing_out(rank);
2198 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, recvcount*smpi_comm_size(comm)*smpi_datatype_size(datatype));
2200 int count=smpi_comm_size(comm);
2201 int* recvcounts=(int*)xbt_malloc(count);
2202 for (i=0; i<count;i++)recvcounts[i]=recvcount;
2203 mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts,
2204 datatype, op, comm);
2205 xbt_free(recvcounts);
2206 retval = MPI_SUCCESS;
2208 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2209 TRACE_smpi_computing_in(rank);
2217 int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
2218 void *recvbuf, int recvcount, MPI_Datatype recvtype,
2225 if (comm == MPI_COMM_NULL) {
2226 retval = MPI_ERR_COMM;
2227 } else if (sendtype == MPI_DATATYPE_NULL
2228 || recvtype == MPI_DATATYPE_NULL) {
2229 retval = MPI_ERR_TYPE;
2232 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2233 TRACE_smpi_computing_out(rank);
2234 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, sendcount*smpi_datatype_size(sendtype));
2236 retval = mpi_coll_alltoall_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
2238 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2239 TRACE_smpi_computing_in(rank);
2247 int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
2248 MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
2249 int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
2255 if (comm == MPI_COMM_NULL) {
2256 retval = MPI_ERR_COMM;
2257 } else if (sendtype == MPI_DATATYPE_NULL
2258 || recvtype == MPI_DATATYPE_NULL) {
2259 retval = MPI_ERR_TYPE;
2260 } else if (sendcounts == NULL || senddisps == NULL || recvcounts == NULL
2261 || recvdisps == NULL) {
2262 retval = MPI_ERR_ARG;
2265 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2266 TRACE_smpi_computing_out(rank);
2268 for(i=0; i< smpi_comm_size(comm);i++)size+=sendcounts[i];
2269 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, size*smpi_datatype_size(sendtype));
2272 mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, sendtype,
2273 recvbuf, recvcounts, recvdisps, recvtype,
2276 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2277 TRACE_smpi_computing_in(rank);
2286 int PMPI_Get_processor_name(char *name, int *resultlen)
2288 int retval = MPI_SUCCESS;
2291 strncpy(name, SIMIX_host_get_name(SIMIX_host_self()),
2292 strlen(SIMIX_host_get_name(SIMIX_host_self())) < MPI_MAX_PROCESSOR_NAME - 1 ?
2293 strlen(SIMIX_host_get_name(SIMIX_host_self())) +1 :
2294 MPI_MAX_PROCESSOR_NAME - 1 );
2297 MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
2303 int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
2305 int retval = MPI_SUCCESS;
2309 if (status == NULL || count == NULL) {
2310 retval = MPI_ERR_ARG;
2311 } else if (datatype == MPI_DATATYPE_NULL) {
2312 retval = MPI_ERR_TYPE;
2314 size = smpi_datatype_size(datatype);
2317 } else if (status->count % size != 0) {
2318 retval = MPI_UNDEFINED;
2320 *count = smpi_mpi_get_count(status, datatype);
2327 int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type) {
2331 if (old_type == MPI_DATATYPE_NULL) {
2332 retval = MPI_ERR_TYPE;
2333 } else if (count<0){
2334 retval = MPI_ERR_COUNT;
2336 retval = smpi_datatype_contiguous(count, old_type, new_type, 0);
2342 int PMPI_Type_commit(MPI_Datatype* datatype) {
2346 if (datatype == NULL || *datatype == MPI_DATATYPE_NULL) {
2347 retval = MPI_ERR_TYPE;
2349 smpi_datatype_commit(datatype);
2350 retval = MPI_SUCCESS;
2357 int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2361 if (old_type == MPI_DATATYPE_NULL) {
2362 retval = MPI_ERR_TYPE;
2363 } else if (count<0 || blocklen<0){
2364 retval = MPI_ERR_COUNT;
2366 retval = smpi_datatype_vector(count, blocklen, stride, old_type, new_type);
2372 int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2376 if (old_type == MPI_DATATYPE_NULL) {
2377 retval = MPI_ERR_TYPE;
2378 } else if (count<0 || blocklen<0){
2379 retval = MPI_ERR_COUNT;
2381 retval = smpi_datatype_hvector(count, blocklen, stride, old_type, new_type);
2387 int PMPI_Type_create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2388 return MPI_Type_hvector(count, blocklen, stride, old_type, new_type);
2391 int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2395 if (old_type == MPI_DATATYPE_NULL) {
2396 retval = MPI_ERR_TYPE;
2397 } else if (count<0){
2398 retval = MPI_ERR_COUNT;
2400 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2406 int PMPI_Type_create_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2410 if (old_type == MPI_DATATYPE_NULL) {
2411 retval = MPI_ERR_TYPE;
2412 } else if (count<0){
2413 retval = MPI_ERR_COUNT;
2415 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2421 int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2425 if (old_type == MPI_DATATYPE_NULL) {
2426 retval = MPI_ERR_TYPE;
2427 } else if (count<0){
2428 retval = MPI_ERR_COUNT;
2430 int* blocklens=(int*)xbt_malloc(blocklength*count);
2431 for (i=0; i<count;i++)blocklens[i]=blocklength;
2432 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2433 xbt_free(blocklens);
2440 int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2444 if (old_type == MPI_DATATYPE_NULL) {
2445 retval = MPI_ERR_TYPE;
2446 } else if (count<0){
2447 retval = MPI_ERR_COUNT;
2449 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2455 int PMPI_Type_create_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2456 return PMPI_Type_hindexed(count, blocklens,indices,old_type,new_type);
2459 int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2463 if (old_type == MPI_DATATYPE_NULL) {
2464 retval = MPI_ERR_TYPE;
2465 } else if (count<0){
2466 retval = MPI_ERR_COUNT;
2468 int* blocklens=(int*)xbt_malloc(blocklength*count);
2469 for (i=0; i<count;i++)blocklens[i]=blocklength;
2470 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2471 xbt_free(blocklens);
2478 int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2483 retval = MPI_ERR_COUNT;
2485 retval = smpi_datatype_struct(count, blocklens, indices, old_types, new_type);
2491 int PMPI_Type_create_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2492 return PMPI_Type_struct(count, blocklens, indices, old_types, new_type);
2496 int PMPI_Error_class(int errorcode, int* errorclass) {
2497 // assume smpi uses only standard mpi error codes
2498 *errorclass=errorcode;
2503 int PMPI_Initialized(int* flag) {
2504 *flag=smpi_process_initialized();
2508 /* The following calls are not yet implemented and will fail at runtime. */
2509 /* Once implemented, please move them above this notice. */
2511 #define NOT_YET_IMPLEMENTED {\
2512 XBT_WARN("Not yet implemented : %s. Please contact the Simgrid team if support is needed", __FUNCTION__);\
2513 return MPI_SUCCESS;\
2517 int PMPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype){
2521 int PMPI_Type_set_name(MPI_Datatype datatype, char * name)
2526 int PMPI_Type_get_name(MPI_Datatype datatype, char * name, int* len)
2531 int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
2535 int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) {
2539 int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periods, int reorder, MPI_Comm* comm_cart) {
2543 int PMPI_Cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) {
2547 int PMPI_Cart_map(MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank) {
2551 int PMPI_Cart_rank(MPI_Comm comm, int* coords, int* rank) {
2555 int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* dest) {
2559 int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
2563 int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) {
2567 int PMPI_Graph_create(MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder, MPI_Comm* comm_graph) {
2571 int PMPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int* index, int* edges) {
2575 int PMPI_Graph_map(MPI_Comm comm_old, int nnodes, int* index, int* edges, int* newrank) {
2579 int PMPI_Graph_neighbors(MPI_Comm comm, int rank, int maxneighbors, int* neighbors) {
2583 int PMPI_Graph_neighbors_count(MPI_Comm comm, int rank, int* nneighbors) {
2587 int PMPI_Graphdims_get(MPI_Comm comm, int* nnodes, int* nedges) {
2591 int PMPI_Topo_test(MPI_Comm comm, int* top_type) {
2595 int PMPI_Errhandler_create(MPI_Handler_function* function, MPI_Errhandler* errhandler) {
2599 int PMPI_Errhandler_free(MPI_Errhandler* errhandler) {
2603 int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler* errhandler) {
2607 int PMPI_Error_string(int errorcode, char* string, int* resultlen) {
2611 int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler) {
2615 int PMPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler) {
2619 int PMPI_Comm_get_errhandler(MPI_Comm comm, MPI_Errhandler* errhandler) {
2623 int PMPI_Cancel(MPI_Request* request) {
2627 int PMPI_Buffer_attach(void* buffer, int size) {
2631 int PMPI_Buffer_detach(void* buffer, int* size) {
2635 int PMPI_Comm_test_inter(MPI_Comm comm, int* flag) {
2639 int PMPI_Comm_get_attr (MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag)
2644 int PMPI_Comm_set_attr (MPI_Comm comm, int comm_keyval, void *attribute_val)
2649 int PMPI_Comm_delete_attr (MPI_Comm comm, int comm_keyval)
2654 int PMPI_Comm_create_keyval(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state)
2659 int PMPI_Comm_free_keyval(int* keyval) {
2663 int PMPI_Pcontrol(const int level )
2668 int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
2672 int PMPI_Type_get_attr (MPI_Datatype type, int type_keyval, void *attribute_val, int* flag)
2677 int PMPI_Type_set_attr (MPI_Datatype type, int type_keyval, void *attribute_val)
2682 int PMPI_Type_delete_attr (MPI_Datatype type, int comm_keyval)
2687 int PMPI_Type_create_keyval(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state)
2692 int PMPI_Type_free_keyval(int* keyval) {
2696 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
2700 int PMPI_Intercomm_merge(MPI_Comm comm, int high, MPI_Comm* comm_out) {
2704 int PMPI_Bsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2708 int PMPI_Bsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2712 int PMPI_Ibsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2716 int PMPI_Comm_remote_group(MPI_Comm comm, MPI_Group* group) {
2720 int PMPI_Comm_remote_size(MPI_Comm comm, int* size) {
2724 int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
2728 int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) {
2732 int PMPI_Attr_put(MPI_Comm comm, int keyval, void* attr_value) {
2736 int PMPI_Rsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2740 int PMPI_Rsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2744 int PMPI_Irsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2748 int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
2752 int PMPI_Keyval_free(int* keyval) {
2756 int PMPI_Test_cancelled(MPI_Status* status, int* flag) {
2760 int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
2764 int PMPI_Pack_external_size(char *datarep, int incount, MPI_Datatype datatype, MPI_Aint *size){
2768 int PMPI_Pack_external(char *datarep, void *inbuf, int incount, MPI_Datatype datatype, void *outbuf, MPI_Aint outcount, MPI_Aint *position){
2772 int PMPI_Unpack_external( char *datarep, void *inbuf, MPI_Aint insize, MPI_Aint *position, void *outbuf, int outcount, MPI_Datatype datatype){
2776 int PMPI_Get_elements(MPI_Status* status, MPI_Datatype datatype, int* elements) {
2780 int PMPI_Dims_create(int nnodes, int ndims, int* dims) {
2784 int PMPI_Win_fence( int assert, MPI_Win win){
2788 int PMPI_Win_free( MPI_Win* win){
2792 int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win){
2796 int PMPI_Info_create( MPI_Info *info){
2800 int PMPI_Info_set( MPI_Info info, char *key, char *value){
2804 int PMPI_Info_free( MPI_Info *info){
2808 int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2809 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
2813 int PMPI_Type_get_envelope( MPI_Datatype datatype, int *num_integers,
2814 int *num_addresses, int *num_datatypes, int *combiner){
2818 int PMPI_Type_get_contents(MPI_Datatype datatype, int max_integers, int max_addresses,
2819 int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses,
2820 MPI_Datatype* array_of_datatypes){
2824 int PMPI_Type_create_darray(int size, int rank, int ndims, int* array_of_gsizes,
2825 int* array_of_distribs, int* array_of_dargs, int* array_of_psizes,
2826 int order, MPI_Datatype oldtype, MPI_Datatype *newtype) {
2830 int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype){
2834 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){
2838 int PMPI_Type_match_size(int typeclass,int size,MPI_Datatype *datatype){
2842 int PMPI_Alltoallw( void *sendbuf, int *sendcnts, int *sdispls, MPI_Datatype *sendtypes,
2843 void *recvbuf, int *recvcnts, int *rdispls, MPI_Datatype *recvtypes,
2848 int PMPI_Comm_set_name(MPI_Comm comm, char* name){
2852 int PMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm * newcomm){
2856 int PMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm){
2860 int PMPI_Comm_set_info (MPI_Comm comm, MPI_Info info){
2864 int PMPI_Comm_get_info (MPI_Comm comm, MPI_Info* info){
2868 int PMPI_Info_get(MPI_Info info,char *key,int valuelen, char *value, int *flag){
2872 int PMPI_Comm_create_errhandler( MPI_Comm_errhandler_fn *function, MPI_Errhandler *errhandler){
2876 int PMPI_Add_error_class( int *errorclass){
2880 int PMPI_Add_error_code( int errorclass, int *errorcode){
2884 int PMPI_Add_error_string( int errorcode, char *string){
2888 int PMPI_Comm_call_errhandler(MPI_Comm comm,int errorcode){
2892 int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo){
2896 int PMPI_Info_delete(MPI_Info info, char *key){
2900 int PMPI_Info_get_nkeys( MPI_Info info, int *nkeys){
2904 int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){
2908 int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){
2912 int PMPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){
2916 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){
2920 int PMPI_Grequest_complete( MPI_Request request){
2924 int PMPI_Status_set_cancelled(MPI_Status *status,int flag){
2928 int PMPI_Status_set_elements( MPI_Status *status, MPI_Datatype datatype, int count){
2932 int PMPI_Comm_connect( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
2936 int PMPI_Publish_name( char *service_name, MPI_Info info, char *port_name){
2940 int PMPI_Unpublish_name( char *service_name, MPI_Info info, char *port_name){
2944 int PMPI_Lookup_name( char *service_name, MPI_Info info, char *port_name){
2948 int PMPI_Comm_join( int fd, MPI_Comm *intercomm){
2952 int PMPI_Open_port( MPI_Info info, char *port_name){
2956 int PMPI_Close_port(char *port_name){
2960 int PMPI_Comm_accept( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
2964 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){
2968 int PMPI_Comm_spawn_multiple( int count, char **array_of_commands, char*** array_of_argv,
2969 int* array_of_maxprocs, MPI_Info* array_of_info, int root,
2970 MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes){
2974 int PMPI_Comm_get_parent( MPI_Comm *parent){