1 /* Copyright (c) 2007, 2008, 2009, 2010. 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);
31 int rank = smpi_process_index();
32 TRACE_smpi_init(rank);
34 TRACE_smpi_computing_init(rank);
40 int PMPI_Finalize(void)
42 smpi_process_finalize();
45 int rank = smpi_process_index();
46 TRACE_smpi_computing_out(rank);
47 TRACE_smpi_finalize(smpi_process_index());
49 smpi_process_destroy();
53 int PMPI_Finalized(int* flag)
55 *flag=smpi_process_finalized();
59 int PMPI_Get_version (int *version,int *subversion){
60 *version = MPI_VERSION;
61 *subversion= MPI_SUBVERSION;
65 int PMPI_Get_library_version (char *version,int *len){
66 int retval = MPI_SUCCESS;
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);
75 int PMPI_Init_thread(int *argc, char ***argv, int required, int *provided)
77 if (provided != NULL) {
78 *provided = MPI_THREAD_MULTIPLE;
80 return MPI_Init(argc, argv);
83 int PMPI_Query_thread(int *provided)
88 if (provided == NULL) {
91 *provided = MPI_THREAD_MULTIPLE;
98 int PMPI_Is_thread_main(int *flag)
104 retval = MPI_ERR_ARG;
106 *flag = smpi_process_index() == 0;
107 retval = MPI_SUCCESS;
113 int PMPI_Abort(MPI_Comm comm, int errorcode)
116 smpi_process_destroy();
118 int rank = smpi_process_index();
119 TRACE_smpi_computing_out(rank);
121 // FIXME: should kill all processes in comm instead
122 simcall_process_kill(SIMIX_process_self());
126 double PMPI_Wtime(void)
131 time = SIMIX_get_clock();
135 extern double sg_maxmin_precision;
136 double PMPI_Wtick(void)
138 return sg_maxmin_precision;
141 int PMPI_Address(void *location, MPI_Aint * address)
147 retval = MPI_ERR_ARG;
149 *address = (MPI_Aint) location;
150 retval = MPI_SUCCESS;
156 int PMPI_Get_address(void *location, MPI_Aint * address)
158 return PMPI_Address(location, address);
161 int PMPI_Type_free(MPI_Datatype * datatype)
167 retval = MPI_ERR_ARG;
169 smpi_datatype_free(datatype);
170 retval = MPI_SUCCESS;
176 int PMPI_Type_size(MPI_Datatype datatype, int *size)
181 if (datatype == MPI_DATATYPE_NULL) {
182 retval = MPI_ERR_TYPE;
183 } else if (size == NULL) {
184 retval = MPI_ERR_ARG;
186 *size = (int) smpi_datatype_size(datatype);
187 retval = MPI_SUCCESS;
193 int PMPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
198 if (datatype == MPI_DATATYPE_NULL) {
199 retval = MPI_ERR_TYPE;
200 } else if (lb == NULL || extent == NULL) {
201 retval = MPI_ERR_ARG;
203 retval = smpi_datatype_extent(datatype, lb, extent);
209 int PMPI_Type_get_true_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
211 return PMPI_Type_get_extent(datatype, lb, extent);
214 int PMPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent)
219 if (datatype == MPI_DATATYPE_NULL) {
220 retval = MPI_ERR_TYPE;
221 } else if (extent == NULL) {
222 retval = MPI_ERR_ARG;
224 *extent = smpi_datatype_get_extent(datatype);
225 retval = MPI_SUCCESS;
231 int PMPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp)
236 if (datatype == MPI_DATATYPE_NULL) {
237 retval = MPI_ERR_TYPE;
238 } else if (disp == NULL) {
239 retval = MPI_ERR_ARG;
241 *disp = smpi_datatype_lb(datatype);
242 retval = MPI_SUCCESS;
248 int PMPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp)
253 if (datatype == MPI_DATATYPE_NULL) {
254 retval = MPI_ERR_TYPE;
255 } else if (disp == NULL) {
256 retval = MPI_ERR_ARG;
258 *disp = smpi_datatype_ub(datatype);
259 retval = MPI_SUCCESS;
265 int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
270 if (function == NULL || op == NULL) {
271 retval = MPI_ERR_ARG;
273 *op = smpi_op_new(function, commute);
274 retval = MPI_SUCCESS;
280 int PMPI_Op_free(MPI_Op * op)
286 retval = MPI_ERR_ARG;
287 } else if (*op == MPI_OP_NULL) {
290 smpi_op_destroy(*op);
292 retval = MPI_SUCCESS;
298 int PMPI_Group_free(MPI_Group * group)
304 retval = MPI_ERR_ARG;
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;
315 int PMPI_Group_size(MPI_Group group, int *size)
320 if (group == MPI_GROUP_NULL) {
321 retval = MPI_ERR_GROUP;
322 } else if (size == NULL) {
323 retval = MPI_ERR_ARG;
325 *size = smpi_group_size(group);
326 retval = MPI_SUCCESS;
332 int PMPI_Group_rank(MPI_Group group, int *rank)
337 if (group == MPI_GROUP_NULL) {
338 retval = MPI_ERR_GROUP;
339 } else if (rank == NULL) {
340 retval = MPI_ERR_ARG;
342 *rank = smpi_group_rank(group, smpi_process_index());
343 retval = MPI_SUCCESS;
349 int PMPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
350 MPI_Group group2, int *ranks2)
352 int retval, i, index;
354 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
355 retval = MPI_ERR_GROUP;
357 for (i = 0; i < n; i++) {
358 if(ranks1[i]==MPI_PROC_NULL){
359 ranks2[i]=MPI_PROC_NULL;
361 index = smpi_group_index(group1, ranks1[i]);
362 ranks2[i] = smpi_group_rank(group2, index);
365 retval = MPI_SUCCESS;
371 int PMPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result)
376 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
377 retval = MPI_ERR_GROUP;
378 } else if (result == NULL) {
379 retval = MPI_ERR_ARG;
381 *result = smpi_group_compare(group1, group2);
382 retval = MPI_SUCCESS;
388 int PMPI_Group_union(MPI_Group group1, MPI_Group group2,
389 MPI_Group * newgroup)
391 int retval, i, proc1, proc2, size, size2;
394 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
395 retval = MPI_ERR_GROUP;
396 } else if (newgroup == NULL) {
397 retval = MPI_ERR_ARG;
399 size = smpi_group_size(group1);
400 size2 = smpi_group_size(group2);
401 for (i = 0; i < size2; i++) {
402 proc2 = smpi_group_index(group2, i);
403 proc1 = smpi_group_rank(group1, proc2);
404 if (proc1 == MPI_UNDEFINED) {
409 *newgroup = MPI_GROUP_EMPTY;
411 *newgroup = smpi_group_new(size);
412 size2 = smpi_group_size(group1);
413 for (i = 0; i < size2; i++) {
414 proc1 = smpi_group_index(group1, i);
415 smpi_group_set_mapping(*newgroup, proc1, i);
417 for (i = size2; i < size; i++) {
418 proc2 = smpi_group_index(group2, i - size2);
419 smpi_group_set_mapping(*newgroup, proc2, i);
422 smpi_group_use(*newgroup);
423 retval = MPI_SUCCESS;
429 int PMPI_Group_intersection(MPI_Group group1, MPI_Group group2,
430 MPI_Group * newgroup)
432 int retval, i, proc1, proc2, size;
435 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
436 retval = MPI_ERR_GROUP;
437 } else if (newgroup == NULL) {
438 retval = MPI_ERR_ARG;
440 size = smpi_group_size(group2);
441 for (i = 0; i < size; i++) {
442 proc2 = smpi_group_index(group2, i);
443 proc1 = smpi_group_rank(group1, proc2);
444 if (proc1 == MPI_UNDEFINED) {
449 *newgroup = MPI_GROUP_EMPTY;
451 *newgroup = smpi_group_new(size);
453 for (i = 0; i < smpi_group_size(group2); i++) {
454 proc2 = smpi_group_index(group2, i);
455 proc1 = smpi_group_rank(group1, proc2);
456 if (proc1 != MPI_UNDEFINED) {
457 smpi_group_set_mapping(*newgroup, proc2, j);
462 smpi_group_use(*newgroup);
463 retval = MPI_SUCCESS;
469 int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgroup)
471 int retval, i, proc1, proc2, size, size2;
474 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
475 retval = MPI_ERR_GROUP;
476 } else if (newgroup == NULL) {
477 retval = MPI_ERR_ARG;
479 size = size2 = smpi_group_size(group1);
480 for (i = 0; i < size2; i++) {
481 proc1 = smpi_group_index(group1, i);
482 proc2 = smpi_group_rank(group2, proc1);
483 if (proc2 != MPI_UNDEFINED) {
488 *newgroup = MPI_GROUP_EMPTY;
490 *newgroup = smpi_group_new(size);
491 for (i = 0; i < size2; i++) {
492 proc1 = smpi_group_index(group1, i);
493 proc2 = smpi_group_rank(group2, proc1);
494 if (proc2 == MPI_UNDEFINED) {
495 smpi_group_set_mapping(*newgroup, proc1, i);
499 smpi_group_use(*newgroup);
500 retval = MPI_SUCCESS;
506 int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
508 int retval, i, index;
511 if (group == MPI_GROUP_NULL) {
512 retval = MPI_ERR_GROUP;
513 } else if (newgroup == NULL) {
514 retval = MPI_ERR_ARG;
517 *newgroup = MPI_GROUP_EMPTY;
518 } else if (n == smpi_group_size(group)) {
521 *newgroup = smpi_group_new(n);
522 for (i = 0; i < n; i++) {
523 index = smpi_group_index(group, ranks[i]);
524 smpi_group_set_mapping(*newgroup, index, i);
527 smpi_group_use(*newgroup);
528 retval = MPI_SUCCESS;
534 int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
536 int retval, i, j, newsize, oldsize, index;
539 if (group == MPI_GROUP_NULL) {
540 retval = MPI_ERR_GROUP;
541 } else if (newgroup == NULL) {
542 retval = MPI_ERR_ARG;
546 } else if (n == smpi_group_size(group)) {
547 *newgroup = MPI_GROUP_EMPTY;
549 oldsize=smpi_group_size(group);
550 newsize = oldsize - n;
551 *newgroup = smpi_group_new(newsize);
553 int* to_exclude=xbt_new(int, smpi_group_size(group));
554 for(i=0; i<oldsize; i++)
557 to_exclude[ranks[i]]=1;
560 for(i=0; i<oldsize; i++){
561 if(to_exclude[i]==0){
562 index = smpi_group_index(group, i);
563 smpi_group_set_mapping(*newgroup, index, j);
568 xbt_free(to_exclude);
570 smpi_group_use(*newgroup);
571 retval = MPI_SUCCESS;
577 int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
578 MPI_Group * newgroup)
580 int retval, i, j, rank, size, index;
583 if (group == MPI_GROUP_NULL) {
584 retval = MPI_ERR_GROUP;
585 } else if (newgroup == NULL) {
586 retval = MPI_ERR_ARG;
589 *newgroup = MPI_GROUP_EMPTY;
592 for (i = 0; i < n; i++) {
593 for (rank = ranges[i][0]; /* First */
594 rank >= 0; /* Last */
598 rank += ranges[i][2]; /* Stride */
599 if (ranges[i][0]<ranges[i][1]){
600 if(rank > ranges[i][1])
603 if(rank < ranges[i][1])
609 *newgroup = smpi_group_new(size);
611 for (i = 0; i < n; i++) {
612 for (rank = ranges[i][0]; /* First */
613 rank >= 0; /* Last */
615 index = smpi_group_index(group, rank);
616 smpi_group_set_mapping(*newgroup, index, j);
618 rank += ranges[i][2]; /* Stride */
619 if (ranges[i][0]<ranges[i][1]){
620 if(rank > ranges[i][1])
623 if(rank < ranges[i][1])
629 smpi_group_use(*newgroup);
630 retval = MPI_SUCCESS;
636 int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
637 MPI_Group * newgroup)
639 int retval, i, rank, newrank,oldrank, size, index, add;
642 if (group == MPI_GROUP_NULL) {
643 retval = MPI_ERR_GROUP;
644 } else if (newgroup == NULL) {
645 retval = MPI_ERR_ARG;
650 size = smpi_group_size(group);
651 for (i = 0; i < n; i++) {
652 for (rank = ranges[i][0]; /* First */
653 rank >= 0; /* Last */
657 rank += ranges[i][2]; /* Stride */
658 if (ranges[i][0]<ranges[i][1]){
659 if(rank > ranges[i][1])
662 if(rank < ranges[i][1])
668 *newgroup = MPI_GROUP_EMPTY;
670 *newgroup = smpi_group_new(size);
673 while (newrank < size) {
675 for (i = 0; i < n; i++) {
676 for (rank = ranges[i][0];rank >= 0;){
682 rank += ranges[i][2]; /* Stride */
684 if (ranges[i][0]<ranges[i][1]){
685 if(rank > ranges[i][1])
688 if(rank < ranges[i][1])
694 index = smpi_group_index(group, oldrank);
695 smpi_group_set_mapping(*newgroup, index, newrank);
702 smpi_group_use(*newgroup);
704 retval = MPI_SUCCESS;
710 int PMPI_Comm_rank(MPI_Comm comm, int *rank)
715 if (comm == MPI_COMM_NULL) {
716 retval = MPI_ERR_COMM;
717 } else if (rank == NULL) {
718 retval = MPI_ERR_ARG;
720 *rank = smpi_comm_rank(comm);
721 retval = MPI_SUCCESS;
727 int PMPI_Comm_size(MPI_Comm comm, int *size)
732 if (comm == MPI_COMM_NULL) {
733 retval = MPI_ERR_COMM;
734 } else if (size == NULL) {
735 retval = MPI_ERR_ARG;
737 *size = smpi_comm_size(comm);
738 retval = MPI_SUCCESS;
744 int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len)
749 if (comm == MPI_COMM_NULL) {
750 retval = MPI_ERR_COMM;
751 } else if (name == NULL || len == NULL) {
752 retval = MPI_ERR_ARG;
754 smpi_comm_get_name(comm, name, len);
755 retval = MPI_SUCCESS;
761 int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
766 if (comm == MPI_COMM_NULL) {
767 retval = MPI_ERR_COMM;
768 } else if (group == NULL) {
769 retval = MPI_ERR_ARG;
771 *group = smpi_comm_group(comm);
772 retval = MPI_SUCCESS;
778 int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
783 if (comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) {
784 retval = MPI_ERR_COMM;
785 } else if (result == NULL) {
786 retval = MPI_ERR_ARG;
788 if (comm1 == comm2) { /* Same communicators means same groups */
792 smpi_group_compare(smpi_comm_group(comm1),
793 smpi_comm_group(comm2));
794 if (*result == MPI_IDENT) {
795 *result = MPI_CONGRUENT;
798 retval = MPI_SUCCESS;
804 int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm)
809 if (comm == MPI_COMM_NULL) {
810 retval = MPI_ERR_COMM;
811 } else if (newcomm == NULL) {
812 retval = MPI_ERR_ARG;
814 *newcomm = smpi_comm_new(smpi_comm_group(comm));
815 retval = MPI_SUCCESS;
821 int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
826 if (comm == MPI_COMM_NULL) {
827 retval = MPI_ERR_COMM;
828 } else if (group == MPI_GROUP_NULL) {
829 retval = MPI_ERR_GROUP;
830 } else if (newcomm == NULL) {
831 retval = MPI_ERR_ARG;
832 } else if(smpi_group_rank(group,smpi_process_index())==MPI_UNDEFINED){
833 *newcomm= MPI_COMM_NULL;
834 retval = MPI_SUCCESS;
837 *newcomm = smpi_comm_new(group);
838 retval = MPI_SUCCESS;
844 int PMPI_Comm_free(MPI_Comm * comm)
850 retval = MPI_ERR_ARG;
851 } else if (*comm == MPI_COMM_NULL) {
852 retval = MPI_ERR_COMM;
854 smpi_comm_destroy(*comm);
855 *comm = MPI_COMM_NULL;
856 retval = MPI_SUCCESS;
862 int PMPI_Comm_disconnect(MPI_Comm * comm)
864 /* TODO: wait until all communication in comm are done */
869 retval = MPI_ERR_ARG;
870 } else if (*comm == MPI_COMM_NULL) {
871 retval = MPI_ERR_COMM;
873 smpi_comm_destroy(*comm);
874 *comm = MPI_COMM_NULL;
875 retval = MPI_SUCCESS;
881 int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out)
886 if (comm_out == NULL) {
887 retval = MPI_ERR_ARG;
888 } else if (comm == MPI_COMM_NULL) {
889 retval = MPI_ERR_COMM;
891 *comm_out = smpi_comm_split(comm, color, key);
892 retval = MPI_SUCCESS;
898 int PMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst,
899 int tag, MPI_Comm comm, MPI_Request * request)
904 if (request == NULL) {
905 retval = MPI_ERR_ARG;
906 } else if (comm == MPI_COMM_NULL) {
907 retval = MPI_ERR_COMM;
908 } else if (dst == MPI_PROC_NULL) {
909 retval = MPI_SUCCESS;
911 *request = smpi_mpi_send_init(buf, count, datatype, dst, tag, comm);
912 retval = MPI_SUCCESS;
918 int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src,
919 int tag, MPI_Comm comm, MPI_Request * request)
924 if (request == NULL) {
925 retval = MPI_ERR_ARG;
926 } else if (comm == MPI_COMM_NULL) {
927 retval = MPI_ERR_COMM;
928 } else if (src == MPI_PROC_NULL) {
929 retval = MPI_SUCCESS;
931 *request = smpi_mpi_recv_init(buf, count, datatype, src, tag, comm);
932 retval = MPI_SUCCESS;
938 int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) {
942 if (request == NULL) {
943 retval = MPI_ERR_ARG;
944 } else if (comm == MPI_COMM_NULL) {
945 retval = MPI_ERR_COMM;
946 } else if (dst == MPI_PROC_NULL) {
947 retval = MPI_SUCCESS;
949 *request = smpi_mpi_ssend_init(buf, count, datatype, dst, tag, comm);
950 retval = MPI_SUCCESS;
956 int PMPI_Start(MPI_Request * request)
961 if (request == NULL || *request == MPI_REQUEST_NULL) {
962 retval = MPI_ERR_ARG;
964 smpi_mpi_start(*request);
965 retval = MPI_SUCCESS;
971 int PMPI_Startall(int count, MPI_Request * requests)
976 if (requests == NULL) {
977 retval = MPI_ERR_ARG;
979 smpi_mpi_startall(count, requests);
980 retval = MPI_SUCCESS;
986 int PMPI_Request_free(MPI_Request * request)
991 if (*request == MPI_REQUEST_NULL) {
992 retval = MPI_ERR_ARG;
994 if((*request)->flags & PERSISTENT)(*request)->refcount--;
995 smpi_mpi_request_free(request);
996 retval = MPI_SUCCESS;
1002 int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src,
1003 int tag, MPI_Comm comm, MPI_Request * request)
1009 if (request == NULL) {
1010 retval = MPI_ERR_ARG;
1011 } else if (comm == MPI_COMM_NULL) {
1012 retval = MPI_ERR_COMM;
1013 } else if (src == MPI_PROC_NULL) {
1014 *request = MPI_REQUEST_NULL;
1015 retval = MPI_SUCCESS;
1016 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
1017 retval = MPI_ERR_COMM;
1018 } else if (count < 0) {
1019 retval = MPI_ERR_COUNT;
1020 } else if (buf==NULL && count > 0) {
1021 retval = MPI_ERR_COUNT;
1022 } else if (datatype == MPI_DATATYPE_NULL){
1023 retval = MPI_ERR_TYPE;
1024 } else if(tag<0 && tag != MPI_ANY_TAG){
1025 retval = MPI_ERR_TAG;
1029 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1030 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1031 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
1034 *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm);
1035 retval = MPI_SUCCESS;
1038 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1039 (*request)->recv = 1;
1048 int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
1049 int tag, MPI_Comm comm, MPI_Request * request)
1054 if (request == NULL) {
1055 retval = MPI_ERR_ARG;
1056 } else if (comm == MPI_COMM_NULL) {
1057 retval = MPI_ERR_COMM;
1058 } else if (dst == MPI_PROC_NULL) {
1059 *request = MPI_REQUEST_NULL;
1060 retval = MPI_SUCCESS;
1061 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1062 retval = MPI_ERR_RANK;
1063 } else if (count < 0) {
1064 retval = MPI_ERR_COUNT;
1065 } else if (buf==NULL && count > 0) {
1066 retval = MPI_ERR_COUNT;
1067 } else if (datatype == MPI_DATATYPE_NULL){
1068 retval = MPI_ERR_TYPE;
1069 } else if(tag<0 && tag != MPI_ANY_TAG){
1070 retval = MPI_ERR_TAG;
1074 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1075 TRACE_smpi_computing_out(rank);
1076 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1077 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1078 TRACE_smpi_send(rank, rank, dst_traced);
1081 *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm);
1082 retval = MPI_SUCCESS;
1085 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1086 (*request)->send = 1;
1087 TRACE_smpi_computing_in(rank);
1095 int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) {
1099 if (request == NULL) {
1100 retval = MPI_ERR_ARG;
1101 } else if (comm == MPI_COMM_NULL) {
1102 retval = MPI_ERR_COMM;
1103 } else if (dst == MPI_PROC_NULL) {
1104 *request = MPI_REQUEST_NULL;
1105 retval = MPI_SUCCESS;
1106 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1107 retval = MPI_ERR_RANK;
1108 } else if (count < 0) {
1109 retval = MPI_ERR_COUNT;
1110 } else if (buf==NULL && count > 0) {
1111 retval = MPI_ERR_COUNT;
1112 } else if (datatype == MPI_DATATYPE_NULL){
1113 retval = MPI_ERR_TYPE;
1114 } else if(tag<0 && tag != MPI_ANY_TAG){
1115 retval = MPI_ERR_TAG;
1119 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1120 TRACE_smpi_computing_out(rank);
1121 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1122 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1123 TRACE_smpi_send(rank, rank, dst_traced);
1126 *request = smpi_mpi_issend(buf, count, datatype, dst, tag, comm);
1127 retval = MPI_SUCCESS;
1130 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1131 (*request)->send = 1;
1132 TRACE_smpi_computing_in(rank);
1140 int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
1141 MPI_Comm comm, MPI_Status * status)
1146 if (comm == MPI_COMM_NULL) {
1147 retval = MPI_ERR_COMM;
1148 } else if (src == MPI_PROC_NULL) {
1149 smpi_empty_status(status);
1150 status->MPI_SOURCE = MPI_PROC_NULL;
1151 retval = MPI_SUCCESS;
1152 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
1153 retval = MPI_ERR_RANK;
1154 } else if (count < 0) {
1155 retval = MPI_ERR_COUNT;
1156 } else if (buf==NULL && count > 0) {
1157 retval = MPI_ERR_COUNT;
1158 } else if (datatype == MPI_DATATYPE_NULL){
1159 retval = MPI_ERR_TYPE;
1160 } else if(tag<0 && tag != MPI_ANY_TAG){
1161 retval = MPI_ERR_TAG;
1164 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1165 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1166 TRACE_smpi_computing_out(rank);
1168 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
1171 smpi_mpi_recv(buf, count, datatype, src, tag, comm, status);
1172 retval = MPI_SUCCESS;
1175 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1176 if(status!=MPI_STATUS_IGNORE)src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
1177 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1178 TRACE_smpi_recv(rank, src_traced, rank);
1179 TRACE_smpi_computing_in(rank);
1187 int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
1194 if (comm == MPI_COMM_NULL) {
1195 retval = MPI_ERR_COMM;
1196 } else if (dst == MPI_PROC_NULL) {
1197 retval = MPI_SUCCESS;
1198 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1199 retval = MPI_ERR_RANK;
1200 } else if (count < 0) {
1201 retval = MPI_ERR_COUNT;
1202 } else if (buf==NULL && count > 0) {
1203 retval = MPI_ERR_COUNT;
1204 } else if (datatype == MPI_DATATYPE_NULL){
1205 retval = MPI_ERR_TYPE;
1206 } else if(tag<0 && tag != MPI_ANY_TAG){
1207 retval = MPI_ERR_TAG;
1211 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1212 TRACE_smpi_computing_out(rank);
1213 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1214 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1215 TRACE_smpi_send(rank, rank, dst_traced);
1218 smpi_mpi_send(buf, count, datatype, dst, tag, comm);
1219 retval = MPI_SUCCESS;
1222 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1223 TRACE_smpi_computing_in(rank);
1233 int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
1238 if (comm == MPI_COMM_NULL) {
1239 retval = MPI_ERR_COMM;
1240 } else if (dst == MPI_PROC_NULL) {
1241 retval = MPI_SUCCESS;
1242 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1243 retval = MPI_ERR_RANK;
1244 } else if (count < 0) {
1245 retval = MPI_ERR_COUNT;
1246 } else if (buf==NULL && count > 0) {
1247 retval = MPI_ERR_COUNT;
1248 } else if (datatype == MPI_DATATYPE_NULL){
1249 retval = MPI_ERR_TYPE;
1250 } else if(tag<0 && tag != MPI_ANY_TAG){
1251 retval = MPI_ERR_TAG;
1255 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1256 TRACE_smpi_computing_out(rank);
1257 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1258 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1259 TRACE_smpi_send(rank, rank, dst_traced);
1262 smpi_mpi_ssend(buf, count, datatype, dst, tag, comm);
1263 retval = MPI_SUCCESS;
1266 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1267 TRACE_smpi_computing_in(rank);
1275 int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1276 int dst, int sendtag, void *recvbuf, int recvcount,
1277 MPI_Datatype recvtype, int src, int recvtag,
1278 MPI_Comm comm, MPI_Status * status)
1284 if (comm == MPI_COMM_NULL) {
1285 retval = MPI_ERR_COMM;
1286 } else if (sendtype == MPI_DATATYPE_NULL
1287 || recvtype == MPI_DATATYPE_NULL) {
1288 retval = MPI_ERR_TYPE;
1289 } else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
1290 smpi_empty_status(status);
1291 status->MPI_SOURCE = MPI_PROC_NULL;
1292 retval = MPI_SUCCESS;
1293 }else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0 ||
1294 (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0))){
1295 retval = MPI_ERR_RANK;
1296 } else if (sendcount < 0 || recvcount<0) {
1297 retval = MPI_ERR_COUNT;
1298 } else if ((sendbuf==NULL && sendcount > 0)||(recvbuf==NULL && recvcount>0)) {
1299 retval = MPI_ERR_COUNT;
1300 } else if((sendtag<0 && sendtag != MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){
1301 retval = MPI_ERR_TAG;
1305 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1306 TRACE_smpi_computing_out(rank);
1307 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1308 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1309 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
1310 TRACE_smpi_send(rank, rank, dst_traced);
1314 smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf,
1315 recvcount, recvtype, src, recvtag, comm, status);
1316 retval = MPI_SUCCESS;
1319 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1320 TRACE_smpi_recv(rank, src_traced, rank);
1321 TRACE_smpi_computing_in(rank);
1330 int PMPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
1331 int dst, int sendtag, int src, int recvtag,
1332 MPI_Comm comm, MPI_Status * status)
1334 //TODO: suboptimal implementation
1337 if (datatype == MPI_DATATYPE_NULL) {
1338 retval = MPI_ERR_TYPE;
1339 } else if (count < 0) {
1340 retval = MPI_ERR_COUNT;
1342 int size = smpi_datatype_get_extent(datatype) * count;
1343 recvbuf = xbt_new(char, size);
1345 MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
1346 datatype, src, recvtag, comm, status);
1347 if(retval==MPI_SUCCESS){
1348 smpi_datatype_copy(recvbuf, count, datatype, buf, count, datatype);
1356 int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
1361 if (request == MPI_REQUEST_NULL || flag == NULL) {
1362 retval = MPI_ERR_ARG;
1363 } else if (*request == MPI_REQUEST_NULL) {
1365 retval = MPI_ERR_REQUEST;
1367 *flag = smpi_mpi_test(request, status);
1368 retval = MPI_SUCCESS;
1374 int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
1375 MPI_Status * status)
1380 if (index == NULL || flag == NULL) {
1381 retval = MPI_ERR_ARG;
1383 *flag = smpi_mpi_testany(count, requests, index, status);
1384 retval = MPI_SUCCESS;
1390 int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses)
1396 retval = MPI_ERR_ARG;
1398 *flag = smpi_mpi_testall(count, requests, statuses);
1399 retval = MPI_SUCCESS;
1405 int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) {
1409 if (status == NULL) {
1410 retval = MPI_ERR_ARG;
1411 } else if (comm == MPI_COMM_NULL) {
1412 retval = MPI_ERR_COMM;
1413 } else if (source == MPI_PROC_NULL) {
1414 smpi_empty_status(status);
1415 status->MPI_SOURCE = MPI_PROC_NULL;
1416 retval = MPI_SUCCESS;
1418 smpi_mpi_probe(source, tag, comm, status);
1419 retval = MPI_SUCCESS;
1426 int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status) {
1431 retval = MPI_ERR_ARG;
1432 } else if (status == NULL) {
1433 retval = MPI_ERR_ARG;
1434 } else if (comm == MPI_COMM_NULL) {
1435 retval = MPI_ERR_COMM;
1436 } else if (source == MPI_PROC_NULL) {
1438 smpi_empty_status(status);
1439 status->MPI_SOURCE = MPI_PROC_NULL;
1440 retval = MPI_SUCCESS;
1442 smpi_mpi_iprobe(source, tag, comm, flag, status);
1443 retval = MPI_SUCCESS;
1449 int PMPI_Wait(MPI_Request * request, MPI_Status * status)
1455 if (request == NULL) {
1456 retval = MPI_ERR_ARG;
1457 } else if (*request == MPI_REQUEST_NULL) {
1458 retval = MPI_ERR_REQUEST;
1462 int rank = request && (*request)->comm != MPI_COMM_NULL
1463 ? smpi_process_index()
1465 TRACE_smpi_computing_out(rank);
1467 int src_traced = (*request)->src;
1468 int dst_traced = (*request)->dst;
1469 int is_wait_for_receive = (*request)->recv;
1470 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
1473 smpi_mpi_wait(request, status);
1474 retval = MPI_SUCCESS;
1477 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1478 if (is_wait_for_receive) {
1479 TRACE_smpi_recv(rank, src_traced, dst_traced);
1481 TRACE_smpi_computing_in(rank);
1490 int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * status)
1496 //save requests information for tracing
1498 int *srcs = xbt_new(int, count);
1499 int *dsts = xbt_new(int, count);
1500 int *recvs = xbt_new(int, count);
1501 for (i = 0; i < count; i++) {
1502 MPI_Request req = requests[i]; //already received requests are no longer valid
1506 recvs[i] = req->recv;
1509 int rank_traced = smpi_process_index();
1510 TRACE_smpi_computing_out(rank_traced);
1512 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
1515 if (index == NULL) {
1516 retval = MPI_ERR_ARG;
1518 *index = smpi_mpi_waitany(count, requests, status);
1519 retval = MPI_SUCCESS;
1522 if(*index!=MPI_UNDEFINED){
1523 int src_traced = srcs[*index];
1524 int dst_traced = dsts[*index];
1525 int is_wait_for_receive = recvs[*index];
1526 if (is_wait_for_receive) {
1527 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1529 TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__);
1534 TRACE_smpi_computing_in(rank_traced);
1540 int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
1545 //save information from requests
1547 int *srcs = xbt_new(int, count);
1548 int *dsts = xbt_new(int, count);
1549 int *recvs = xbt_new(int, count);
1550 int valid_count = 0;
1551 for (i = 0; i < count; i++) {
1552 MPI_Request req = requests[i];
1553 if(req!=MPI_REQUEST_NULL){
1554 srcs[valid_count] = req->src;
1555 dsts[valid_count] = req->dst;
1556 recvs[valid_count] = req->recv;
1560 int rank_traced = smpi_process_index();
1561 TRACE_smpi_computing_out(rank_traced);
1563 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
1565 int retval = smpi_mpi_waitall(count, requests, status);
1567 for (i = 0; i < valid_count; i++) {
1568 int src_traced = srcs[i];
1569 int dst_traced = dsts[i];
1570 int is_wait_for_receive = recvs[i];
1571 if (is_wait_for_receive) {
1572 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1575 TRACE_smpi_ptp_out(rank_traced, -1, -1, __FUNCTION__);
1579 TRACE_smpi_computing_in(rank_traced);
1585 int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
1586 int *indices, MPI_Status status[])
1591 if (outcount == NULL) {
1592 retval = MPI_ERR_ARG;
1594 *outcount = smpi_mpi_waitsome(incount, requests, indices, status);
1595 retval = MPI_SUCCESS;
1601 int PMPI_Testsome(int incount, MPI_Request requests[], int* outcount,
1602 int* indices, MPI_Status status[])
1607 if (outcount == NULL) {
1608 retval = MPI_ERR_ARG;
1610 *outcount = smpi_mpi_testsome(incount, requests, indices, status);
1611 retval = MPI_SUCCESS;
1618 int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
1624 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1625 TRACE_smpi_computing_out(rank);
1626 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1627 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1629 if (comm == MPI_COMM_NULL) {
1630 retval = MPI_ERR_COMM;
1632 mpi_coll_bcast_fun(buf, count, datatype, root, comm);
1633 retval = MPI_SUCCESS;
1636 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1637 TRACE_smpi_computing_in(rank);
1643 int PMPI_Barrier(MPI_Comm comm)
1649 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1650 TRACE_smpi_computing_out(rank);
1651 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1653 if (comm == MPI_COMM_NULL) {
1654 retval = MPI_ERR_COMM;
1656 mpi_coll_barrier_fun(comm);
1657 retval = MPI_SUCCESS;
1660 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1661 TRACE_smpi_computing_in(rank);
1667 int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1668 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1669 int root, MPI_Comm comm)
1675 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1676 TRACE_smpi_computing_out(rank);
1677 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1678 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1680 if (comm == MPI_COMM_NULL) {
1681 retval = MPI_ERR_COMM;
1682 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1683 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1684 retval = MPI_ERR_TYPE;
1685 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1686 ((smpi_comm_rank(comm) == root) && (recvcount <0))){
1687 retval = MPI_ERR_COUNT;
1690 char* sendtmpbuf = (char*) sendbuf;
1691 int sendtmpcount = sendcount;
1692 MPI_Datatype sendtmptype = sendtype;
1693 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1695 sendtmptype=recvtype;
1698 mpi_coll_gather_fun(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcount,
1699 recvtype, root, comm);
1702 retval = MPI_SUCCESS;
1705 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1706 TRACE_smpi_computing_in(rank);
1712 int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1713 void *recvbuf, int *recvcounts, int *displs,
1714 MPI_Datatype recvtype, int root, MPI_Comm comm)
1720 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1721 TRACE_smpi_computing_out(rank);
1722 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1723 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1725 if (comm == MPI_COMM_NULL) {
1726 retval = MPI_ERR_COMM;
1727 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1728 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1729 retval = MPI_ERR_TYPE;
1730 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1731 retval = MPI_ERR_COUNT;
1732 } else if (recvcounts == NULL || displs == NULL) {
1733 retval = MPI_ERR_ARG;
1736 char* sendtmpbuf = (char*) sendbuf;
1737 int sendtmpcount = sendcount;
1738 MPI_Datatype sendtmptype = sendtype;
1739 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1741 sendtmptype=recvtype;
1744 smpi_mpi_gatherv(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcounts,
1745 displs, recvtype, root, comm);
1746 retval = MPI_SUCCESS;
1749 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1750 TRACE_smpi_computing_in(rank);
1756 int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1757 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1764 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1765 TRACE_smpi_computing_out(rank);
1766 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1768 if (comm == MPI_COMM_NULL) {
1769 retval = MPI_ERR_COMM;
1770 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1771 (recvtype == MPI_DATATYPE_NULL)){
1772 retval = MPI_ERR_TYPE;
1773 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1775 retval = MPI_ERR_COUNT;
1778 if(sendbuf == MPI_IN_PLACE) {
1779 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*recvcount*smpi_comm_rank(comm);
1780 sendcount=recvcount;
1784 mpi_coll_allgather_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1786 retval = MPI_SUCCESS;
1789 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1795 int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1796 void *recvbuf, int *recvcounts, int *displs,
1797 MPI_Datatype recvtype, MPI_Comm comm)
1803 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1804 TRACE_smpi_computing_out(rank);
1805 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1807 if (comm == MPI_COMM_NULL) {
1808 retval = MPI_ERR_COMM;
1809 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1810 (recvtype == MPI_DATATYPE_NULL)){
1811 retval = MPI_ERR_TYPE;
1812 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1813 retval = MPI_ERR_COUNT;
1814 } else if (recvcounts == NULL || displs == NULL) {
1815 retval = MPI_ERR_ARG;
1818 if(sendbuf == MPI_IN_PLACE) {
1819 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*displs[smpi_comm_rank(comm)];
1820 sendcount=recvcounts[smpi_comm_rank(comm)];
1824 mpi_coll_allgatherv_fun(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
1825 displs, recvtype, comm);
1826 retval = MPI_SUCCESS;
1829 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1830 TRACE_smpi_computing_in(rank);
1836 int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1837 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1838 int root, MPI_Comm comm)
1844 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1845 TRACE_smpi_computing_out(rank);
1846 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1848 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1850 if (comm == MPI_COMM_NULL) {
1851 retval = MPI_ERR_COMM;
1852 } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
1853 || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
1854 retval = MPI_ERR_TYPE;
1857 if(recvbuf==MPI_IN_PLACE){
1860 mpi_coll_scatter_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1861 recvtype, root, comm);
1862 retval = MPI_SUCCESS;
1865 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1866 TRACE_smpi_computing_in(rank);
1872 int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
1873 MPI_Datatype sendtype, void *recvbuf, int recvcount,
1874 MPI_Datatype recvtype, int root, MPI_Comm comm)
1880 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1881 TRACE_smpi_computing_out(rank);
1882 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1883 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1885 if (comm == MPI_COMM_NULL) {
1886 retval = MPI_ERR_COMM;
1887 } else if (sendcounts == NULL || displs == NULL) {
1888 retval = MPI_ERR_ARG;
1889 } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
1890 || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
1891 retval = MPI_ERR_TYPE;
1894 if(recvbuf==MPI_IN_PLACE){
1898 smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
1899 recvcount, recvtype, root, comm);
1900 retval = MPI_SUCCESS;
1903 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1904 TRACE_smpi_computing_in(rank);
1910 int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
1911 MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
1917 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1918 TRACE_smpi_computing_out(rank);
1919 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1920 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1922 if (comm == MPI_COMM_NULL) {
1923 retval = MPI_ERR_COMM;
1924 } else if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
1925 retval = MPI_ERR_ARG;
1928 char* sendtmpbuf = (char*) sendbuf;
1929 if( sendbuf == MPI_IN_PLACE ) {
1930 sendtmpbuf = (char *)xbt_malloc(count*smpi_datatype_get_extent(datatype));
1931 smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
1934 mpi_coll_reduce_fun(sendtmpbuf, recvbuf, count, datatype, op, root, comm);
1936 if( sendbuf == MPI_IN_PLACE ) {
1937 xbt_free(sendtmpbuf);
1940 retval = MPI_SUCCESS;
1943 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1944 TRACE_smpi_computing_in(rank);
1950 int PMPI_Reduce_local(void *inbuf, void *inoutbuf, int count,
1951 MPI_Datatype datatype, MPI_Op op){
1955 if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
1956 retval = MPI_ERR_ARG;
1958 smpi_op_apply(op, inbuf, inoutbuf, &count, &datatype);
1965 int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
1966 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
1972 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1973 TRACE_smpi_computing_out(rank);
1974 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1976 if (comm == MPI_COMM_NULL) {
1977 retval = MPI_ERR_COMM;
1978 } else if (datatype == MPI_DATATYPE_NULL) {
1979 retval = MPI_ERR_TYPE;
1980 } else if (op == MPI_OP_NULL) {
1981 retval = MPI_ERR_OP;
1984 char* sendtmpbuf = (char*) sendbuf;
1985 if( sendbuf == MPI_IN_PLACE ) {
1986 sendtmpbuf = (char *)xbt_malloc(count*smpi_datatype_get_extent(datatype));
1987 smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
1990 mpi_coll_allreduce_fun(sendtmpbuf, recvbuf, count, datatype, op, comm);
1992 if( sendbuf == MPI_IN_PLACE ) {
1993 xbt_free(sendtmpbuf);
1996 retval = MPI_SUCCESS;
2000 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2001 TRACE_smpi_computing_in(rank);
2007 int PMPI_Scan(void *sendbuf, void *recvbuf, int count,
2008 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2014 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2015 TRACE_smpi_computing_out(rank);
2016 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2018 if (comm == MPI_COMM_NULL) {
2019 retval = MPI_ERR_COMM;
2020 } else if (datatype == MPI_DATATYPE_NULL) {
2021 retval = MPI_ERR_TYPE;
2022 } else if (op == MPI_OP_NULL) {
2023 retval = MPI_ERR_OP;
2025 smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm);
2026 retval = MPI_SUCCESS;
2029 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2030 TRACE_smpi_computing_in(rank);
2036 int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
2037 MPI_Op op, MPI_Comm comm){
2042 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2043 TRACE_smpi_computing_out(rank);
2044 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2046 if (comm == MPI_COMM_NULL) {
2047 retval = MPI_ERR_COMM;
2048 } else if (datatype == MPI_DATATYPE_NULL) {
2049 retval = MPI_ERR_TYPE;
2050 } else if (op == MPI_OP_NULL) {
2051 retval = MPI_ERR_OP;
2053 smpi_mpi_exscan(sendbuf, recvbuf, count, datatype, op, comm);
2054 retval = MPI_SUCCESS;
2057 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2058 TRACE_smpi_computing_in(rank);
2064 int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
2065 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2070 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2071 TRACE_smpi_computing_out(rank);
2072 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2074 if (comm == MPI_COMM_NULL) {
2075 retval = MPI_ERR_COMM;
2076 } else if (datatype == MPI_DATATYPE_NULL) {
2077 retval = MPI_ERR_TYPE;
2078 } else if (op == MPI_OP_NULL) {
2079 retval = MPI_ERR_OP;
2080 } else if (recvcounts == NULL) {
2081 retval = MPI_ERR_ARG;
2083 void* sendtmpbuf=sendbuf;
2084 if(sendbuf==MPI_IN_PLACE){
2088 mpi_coll_reduce_scatter_fun(sendtmpbuf, recvbuf, recvcounts,
2089 datatype, op, comm);
2090 retval = MPI_SUCCESS;
2093 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2094 TRACE_smpi_computing_in(rank);
2100 int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
2101 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2106 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2107 TRACE_smpi_computing_out(rank);
2108 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2110 if (comm == MPI_COMM_NULL) {
2111 retval = MPI_ERR_COMM;
2112 } else if (datatype == MPI_DATATYPE_NULL) {
2113 retval = MPI_ERR_TYPE;
2114 } else if (op == MPI_OP_NULL) {
2115 retval = MPI_ERR_OP;
2116 } else if (recvcount < 0) {
2117 retval = MPI_ERR_ARG;
2119 int count=smpi_comm_size(comm);
2120 int* recvcounts=(int*)xbt_malloc(count);
2121 for (i=0; i<count;i++)recvcounts[i]=recvcount;
2122 mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts,
2123 datatype, op, comm);
2124 xbt_free(recvcounts);
2125 retval = MPI_SUCCESS;
2128 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2129 TRACE_smpi_computing_in(rank);
2135 int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
2136 void *recvbuf, int recvcount, MPI_Datatype recvtype,
2143 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2144 TRACE_smpi_computing_out(rank);
2145 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2147 if (comm == MPI_COMM_NULL) {
2148 retval = MPI_ERR_COMM;
2149 } else if (sendtype == MPI_DATATYPE_NULL
2150 || recvtype == MPI_DATATYPE_NULL) {
2151 retval = MPI_ERR_TYPE;
2153 retval = mpi_coll_alltoall_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
2156 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2157 TRACE_smpi_computing_in(rank);
2163 int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
2164 MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
2165 int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
2171 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2172 TRACE_smpi_computing_out(rank);
2173 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2175 if (comm == MPI_COMM_NULL) {
2176 retval = MPI_ERR_COMM;
2177 } else if (sendtype == MPI_DATATYPE_NULL
2178 || recvtype == MPI_DATATYPE_NULL) {
2179 retval = MPI_ERR_TYPE;
2180 } else if (sendcounts == NULL || senddisps == NULL || recvcounts == NULL
2181 || recvdisps == NULL) {
2182 retval = MPI_ERR_ARG;
2185 mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, sendtype,
2186 recvbuf, recvcounts, recvdisps, recvtype,
2190 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2191 TRACE_smpi_computing_in(rank);
2198 int PMPI_Get_processor_name(char *name, int *resultlen)
2200 int retval = MPI_SUCCESS;
2203 strncpy(name, SIMIX_host_get_name(SIMIX_host_self()),
2204 strlen(SIMIX_host_get_name(SIMIX_host_self())) < MPI_MAX_PROCESSOR_NAME - 1 ?
2205 strlen(SIMIX_host_get_name(SIMIX_host_self())) +1 :
2206 MPI_MAX_PROCESSOR_NAME - 1 );
2209 MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
2215 int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
2217 int retval = MPI_SUCCESS;
2221 if (status == NULL || count == NULL) {
2222 retval = MPI_ERR_ARG;
2223 } else if (datatype == MPI_DATATYPE_NULL) {
2224 retval = MPI_ERR_TYPE;
2226 size = smpi_datatype_size(datatype);
2229 } else if (status->count % size != 0) {
2230 retval = MPI_UNDEFINED;
2232 *count = smpi_mpi_get_count(status, datatype);
2239 int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type) {
2243 if (old_type == MPI_DATATYPE_NULL) {
2244 retval = MPI_ERR_TYPE;
2245 } else if (count<0){
2246 retval = MPI_ERR_COUNT;
2248 retval = smpi_datatype_contiguous(count, old_type, new_type, 0);
2254 int PMPI_Type_commit(MPI_Datatype* datatype) {
2258 if (datatype == MPI_DATATYPE_NULL) {
2259 retval = MPI_ERR_TYPE;
2261 smpi_datatype_commit(datatype);
2262 retval = MPI_SUCCESS;
2269 int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2273 if (old_type == MPI_DATATYPE_NULL) {
2274 retval = MPI_ERR_TYPE;
2275 } else if (count<0 || blocklen<0){
2276 retval = MPI_ERR_COUNT;
2278 retval = smpi_datatype_vector(count, blocklen, stride, old_type, new_type);
2284 int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2288 if (old_type == MPI_DATATYPE_NULL) {
2289 retval = MPI_ERR_TYPE;
2290 } else if (count<0 || blocklen<0){
2291 retval = MPI_ERR_COUNT;
2293 retval = smpi_datatype_hvector(count, blocklen, stride, old_type, new_type);
2299 int PMPI_Type_create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2300 return MPI_Type_hvector(count, blocklen, stride, old_type, new_type);
2303 int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2307 if (old_type == MPI_DATATYPE_NULL) {
2308 retval = MPI_ERR_TYPE;
2309 } else if (count<0){
2310 retval = MPI_ERR_COUNT;
2312 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2318 int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2322 if (old_type == MPI_DATATYPE_NULL) {
2323 retval = MPI_ERR_TYPE;
2324 } else if (count<0){
2325 retval = MPI_ERR_COUNT;
2327 int* blocklens=(int*)xbt_malloc(blocklength*count);
2328 for (i=0; i<count;i++)blocklens[i]=blocklength;
2329 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2330 xbt_free(blocklens);
2337 int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2341 if (old_type == MPI_DATATYPE_NULL) {
2342 retval = MPI_ERR_TYPE;
2343 } else if (count<0){
2344 retval = MPI_ERR_COUNT;
2346 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2352 int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2356 if (old_type == MPI_DATATYPE_NULL) {
2357 retval = MPI_ERR_TYPE;
2358 } else if (count<0){
2359 retval = MPI_ERR_COUNT;
2361 int* blocklens=(int*)xbt_malloc(blocklength*count);
2362 for (i=0; i<count;i++)blocklens[i]=blocklength;
2363 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2364 xbt_free(blocklens);
2371 int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2376 retval = MPI_ERR_COUNT;
2378 retval = smpi_datatype_struct(count, blocklens, indices, old_types, new_type);
2384 int PMPI_Type_create_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2385 return PMPI_Type_struct(count, blocklens, indices, old_types, new_type);
2389 int PMPI_Error_class(int errorcode, int* errorclass) {
2390 // assume smpi uses only standard mpi error codes
2391 *errorclass=errorcode;
2396 int PMPI_Initialized(int* flag) {
2397 *flag=(smpi_process_data()!=NULL);
2401 /* The following calls are not yet implemented and will fail at runtime. */
2402 /* Once implemented, please move them above this notice. */
2404 #define NOT_YET_IMPLEMENTED {\
2405 XBT_WARN("Not yet implemented : %s. Please contact the Simgrid team if support is needed", __FUNCTION__);\
2406 return MPI_SUCCESS;\
2410 int PMPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype){
2414 int PMPI_Type_set_name(MPI_Datatype datatype, char * name)
2419 int PMPI_Type_get_name(MPI_Datatype datatype, char * name, int* len)
2424 int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
2428 int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) {
2432 int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periods, int reorder, MPI_Comm* comm_cart) {
2436 int PMPI_Cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) {
2440 int PMPI_Cart_map(MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank) {
2444 int PMPI_Cart_rank(MPI_Comm comm, int* coords, int* rank) {
2448 int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* dest) {
2452 int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
2456 int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) {
2460 int PMPI_Graph_create(MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder, MPI_Comm* comm_graph) {
2464 int PMPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int* index, int* edges) {
2468 int PMPI_Graph_map(MPI_Comm comm_old, int nnodes, int* index, int* edges, int* newrank) {
2472 int PMPI_Graph_neighbors(MPI_Comm comm, int rank, int maxneighbors, int* neighbors) {
2476 int PMPI_Graph_neighbors_count(MPI_Comm comm, int rank, int* nneighbors) {
2480 int PMPI_Graphdims_get(MPI_Comm comm, int* nnodes, int* nedges) {
2484 int PMPI_Topo_test(MPI_Comm comm, int* top_type) {
2488 int PMPI_Errhandler_create(MPI_Handler_function* function, MPI_Errhandler* errhandler) {
2492 int PMPI_Errhandler_free(MPI_Errhandler* errhandler) {
2496 int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler* errhandler) {
2500 int PMPI_Error_string(int errorcode, char* string, int* resultlen) {
2504 int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler) {
2508 int PMPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler) {
2512 int PMPI_Cancel(MPI_Request* request) {
2516 int PMPI_Buffer_attach(void* buffer, int size) {
2520 int PMPI_Buffer_detach(void* buffer, int* size) {
2524 int PMPI_Comm_test_inter(MPI_Comm comm, int* flag) {
2528 int PMPI_Comm_get_attr (MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag)
2533 int PMPI_Comm_set_attr (MPI_Comm comm, int comm_keyval, void *attribute_val)
2538 int PMPI_Comm_delete_attr (MPI_Comm comm, int comm_keyval)
2543 int PMPI_Comm_create_keyval(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state)
2548 int PMPI_Comm_free_keyval(int* keyval) {
2552 int PMPI_Pcontrol(const int level )
2557 int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
2561 int PMPI_Type_get_attr (MPI_Datatype type, int type_keyval, void *attribute_val, int* flag)
2566 int PMPI_Type_set_attr (MPI_Datatype type, int type_keyval, void *attribute_val)
2571 int PMPI_Type_delete_attr (MPI_Datatype type, int comm_keyval)
2576 int PMPI_Type_create_keyval(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state)
2581 int PMPI_Type_free_keyval(int* keyval) {
2585 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
2589 int PMPI_Intercomm_merge(MPI_Comm comm, int high, MPI_Comm* comm_out) {
2593 int PMPI_Bsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2597 int PMPI_Bsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2601 int PMPI_Ibsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2605 int PMPI_Comm_remote_group(MPI_Comm comm, MPI_Group* group) {
2609 int PMPI_Comm_remote_size(MPI_Comm comm, int* size) {
2613 int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
2617 int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) {
2621 int PMPI_Attr_put(MPI_Comm comm, int keyval, void* attr_value) {
2625 int PMPI_Rsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2629 int PMPI_Rsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2633 int PMPI_Irsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2637 int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
2641 int PMPI_Keyval_free(int* keyval) {
2645 int PMPI_Test_cancelled(MPI_Status* status, int* flag) {
2649 int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
2653 int PMPI_Pack_external_size(char *datarep, int incount, MPI_Datatype datatype, MPI_Aint *size){
2657 int PMPI_Pack_external(char *datarep, void *inbuf, int incount, MPI_Datatype datatype, void *outbuf, MPI_Aint outcount, MPI_Aint *position){
2661 int PMPI_Unpack_external( char *datarep, void *inbuf, MPI_Aint insize, MPI_Aint *position, void *outbuf, int outcount, MPI_Datatype datatype){
2665 int PMPI_Get_elements(MPI_Status* status, MPI_Datatype datatype, int* elements) {
2669 int PMPI_Dims_create(int nnodes, int ndims, int* dims) {
2673 int PMPI_Win_fence( int assert, MPI_Win win){
2677 int PMPI_Win_free( MPI_Win* win){
2681 int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win){
2685 int PMPI_Info_create( MPI_Info *info){
2689 int PMPI_Info_set( MPI_Info info, char *key, char *value){
2693 int PMPI_Info_free( MPI_Info *info){
2697 int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2698 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
2702 int PMPI_Type_get_envelope( MPI_Datatype datatype, int *num_integers,
2703 int *num_addresses, int *num_datatypes, int *combiner){
2707 int PMPI_Type_get_contents(MPI_Datatype datatype, int max_integers, int max_addresses,
2708 int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses,
2709 MPI_Datatype* array_of_datatypes){
2713 int PMPI_Type_create_darray(int size, int rank, int ndims, int* array_of_gsizes,
2714 int* array_of_distribs, int* array_of_dargs, int* array_of_psizes,
2715 int order, MPI_Datatype oldtype, MPI_Datatype *newtype) {
2719 int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype){
2723 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){
2727 int PMPI_Type_match_size(int typeclass,int size,MPI_Datatype *datatype){
2731 int PMPI_Alltoallw( void *sendbuf, int *sendcnts, int *sdispls, MPI_Datatype *sendtypes,
2732 void *recvbuf, int *recvcnts, int *rdispls, MPI_Datatype *recvtypes,
2737 int PMPI_Comm_set_name(MPI_Comm comm, char* name){
2741 int PMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm * newcomm){
2745 int PMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm){
2749 int PMPI_Comm_set_info (MPI_Comm comm, MPI_Info info){
2753 int PMPI_Comm_get_info (MPI_Comm comm, MPI_Info* info){
2757 int PMPI_Info_get(MPI_Info info,char *key,int valuelen, char *value, int *flag){
2761 int PMPI_Comm_create_errhandler( MPI_Comm_errhandler_fn *function, MPI_Errhandler *errhandler){
2765 int PMPI_Add_error_class( int *errorclass){
2769 int PMPI_Add_error_code( int errorclass, int *errorcode){
2773 int PMPI_Add_error_string( int errorcode, char *string){
2777 int PMPI_Comm_call_errhandler(MPI_Comm comm,int errorcode){
2781 int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo){
2785 int PMPI_Info_delete(MPI_Info info, char *key){
2789 int PMPI_Info_get_nkeys( MPI_Info info, int *nkeys){
2793 int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){
2797 int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){
2801 int PMPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){
2805 int MPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){
2809 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){
2813 int PMPI_Grequest_complete( MPI_Request request){
2817 int PMPI_Status_set_cancelled(MPI_Status *status,int flag){
2821 int PMPI_Status_set_elements( MPI_Status *status, MPI_Datatype datatype, int count){
2825 int PMPI_Comm_connect( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
2829 int PMPI_Publish_name( char *service_name, MPI_Info info, char *port_name){
2833 int PMPI_Unpublish_name( char *service_name, MPI_Info info, char *port_name){
2837 int PMPI_Lookup_name( char *service_name, MPI_Info info, char *port_name){
2841 int PMPI_Comm_join( int fd, MPI_Comm *intercomm){
2845 int PMPI_Open_port( MPI_Info info, char *port_name){
2849 int PMPI_Close_port(char *port_name){
2853 int PMPI_Comm_accept( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
2857 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){
2861 int PMPI_Comm_spawn_multiple( int count, char **array_of_commands, char*** array_of_argv,
2862 int* array_of_maxprocs, MPI_Info* array_of_info, int root,
2863 MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes){
2867 int PMPI_Comm_get_parent( MPI_Comm *parent){