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);
34 TRACE_smpi_computing_init(rank);
35 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,0);
36 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
42 int PMPI_Finalize(void)
46 int rank = smpi_process_index();
47 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,0);
49 smpi_process_finalize();
51 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
52 TRACE_smpi_finalize(smpi_process_index());
54 smpi_process_destroy();
58 int PMPI_Finalized(int* flag)
60 *flag=smpi_process_finalized();
64 int PMPI_Get_version (int *version,int *subversion){
65 *version = MPI_VERSION;
66 *subversion= MPI_SUBVERSION;
70 int PMPI_Get_library_version (char *version,int *len){
71 int retval = MPI_SUCCESS;
73 snprintf(version,MPI_MAX_LIBRARY_VERSION_STRING,"SMPI Version %d.%d. Copyright The Simgrid Team 2007-2013",SIMGRID_VERSION_MAJOR,
74 SIMGRID_VERSION_MINOR);
75 *len = strlen(version) > MPI_MAX_LIBRARY_VERSION_STRING ? MPI_MAX_LIBRARY_VERSION_STRING : strlen(version);
80 int PMPI_Init_thread(int *argc, char ***argv, int required, int *provided)
82 if (provided != NULL) {
83 *provided = MPI_THREAD_MULTIPLE;
85 return MPI_Init(argc, argv);
88 int PMPI_Query_thread(int *provided)
93 if (provided == NULL) {
96 *provided = MPI_THREAD_MULTIPLE;
103 int PMPI_Is_thread_main(int *flag)
109 retval = MPI_ERR_ARG;
111 *flag = smpi_process_index() == 0;
112 retval = MPI_SUCCESS;
118 int PMPI_Abort(MPI_Comm comm, int errorcode)
121 smpi_process_destroy();
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 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1103 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype));
1104 TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype));
1107 *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm);
1108 retval = MPI_SUCCESS;
1111 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1112 (*request)->send = 1;
1117 if (retval != MPI_SUCCESS && request)
1118 *request = MPI_REQUEST_NULL;
1122 int PMPI_Issend(void* buf, int count, MPI_Datatype datatype,
1123 int dst, int tag, MPI_Comm comm, MPI_Request* request)
1128 if (request == NULL) {
1129 retval = MPI_ERR_ARG;
1130 } else if (comm == MPI_COMM_NULL) {
1131 retval = MPI_ERR_COMM;
1132 } else if (dst == MPI_PROC_NULL) {
1133 *request = MPI_REQUEST_NULL;
1134 retval = MPI_SUCCESS;
1135 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1136 retval = MPI_ERR_RANK;
1137 } else if (count < 0) {
1138 retval = MPI_ERR_COUNT;
1139 } else if (buf==NULL && count > 0) {
1140 retval = MPI_ERR_COUNT;
1141 } else if (datatype == MPI_DATATYPE_NULL){
1142 retval = MPI_ERR_TYPE;
1143 } else if(tag<0 && tag != MPI_ANY_TAG){
1144 retval = MPI_ERR_TAG;
1148 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1149 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1150 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype));
1151 TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype));
1154 *request = smpi_mpi_issend(buf, count, datatype, dst, tag, comm);
1155 retval = MPI_SUCCESS;
1158 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1159 (*request)->send = 1;
1164 if (retval != MPI_SUCCESS && request)
1165 *request = MPI_REQUEST_NULL;
1169 int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
1170 MPI_Comm comm, MPI_Status * status)
1175 if (comm == MPI_COMM_NULL) {
1176 retval = MPI_ERR_COMM;
1177 } else if (src == MPI_PROC_NULL) {
1178 smpi_empty_status(status);
1179 status->MPI_SOURCE = MPI_PROC_NULL;
1180 retval = MPI_SUCCESS;
1181 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
1182 retval = MPI_ERR_RANK;
1183 } else if (count < 0) {
1184 retval = MPI_ERR_COUNT;
1185 } else if (buf==NULL && count > 0) {
1186 retval = MPI_ERR_COUNT;
1187 } else if (datatype == MPI_DATATYPE_NULL){
1188 retval = MPI_ERR_TYPE;
1189 } else if(tag<0 && tag != MPI_ANY_TAG){
1190 retval = MPI_ERR_TAG;
1193 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1194 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1195 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, count*smpi_datatype_size(datatype));
1198 smpi_mpi_recv(buf, count, datatype, src, tag, comm, status);
1199 retval = MPI_SUCCESS;
1202 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1203 if(status!=MPI_STATUS_IGNORE)src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
1204 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1205 TRACE_smpi_recv(rank, src_traced, rank);
1213 int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
1220 if (comm == MPI_COMM_NULL) {
1221 retval = MPI_ERR_COMM;
1222 } else if (dst == MPI_PROC_NULL) {
1223 retval = MPI_SUCCESS;
1224 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1225 retval = MPI_ERR_RANK;
1226 } else if (count < 0) {
1227 retval = MPI_ERR_COUNT;
1228 } else if (buf==NULL && count > 0) {
1229 retval = MPI_ERR_COUNT;
1230 } else if (datatype == MPI_DATATYPE_NULL){
1231 retval = MPI_ERR_TYPE;
1232 } else if(tag<0 && tag != MPI_ANY_TAG){
1233 retval = MPI_ERR_TAG;
1237 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1238 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1239 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype));
1240 TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype));
1243 smpi_mpi_send(buf, count, datatype, dst, tag, comm);
1244 retval = MPI_SUCCESS;
1247 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1257 int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
1262 if (comm == MPI_COMM_NULL) {
1263 retval = MPI_ERR_COMM;
1264 } else if (dst == MPI_PROC_NULL) {
1265 retval = MPI_SUCCESS;
1266 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1267 retval = MPI_ERR_RANK;
1268 } else if (count < 0) {
1269 retval = MPI_ERR_COUNT;
1270 } else if (buf==NULL && count > 0) {
1271 retval = MPI_ERR_COUNT;
1272 } else if (datatype == MPI_DATATYPE_NULL){
1273 retval = MPI_ERR_TYPE;
1274 } else if(tag<0 && tag != MPI_ANY_TAG){
1275 retval = MPI_ERR_TAG;
1279 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1280 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1281 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype));
1282 TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype));
1285 smpi_mpi_ssend(buf, count, datatype, dst, tag, comm);
1286 retval = MPI_SUCCESS;
1289 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1297 int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1298 int dst, int sendtag, void *recvbuf, int recvcount,
1299 MPI_Datatype recvtype, int src, int recvtag,
1300 MPI_Comm comm, MPI_Status * status)
1306 if (comm == MPI_COMM_NULL) {
1307 retval = MPI_ERR_COMM;
1308 } else if (sendtype == MPI_DATATYPE_NULL
1309 || recvtype == MPI_DATATYPE_NULL) {
1310 retval = MPI_ERR_TYPE;
1311 } else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
1312 smpi_empty_status(status);
1313 status->MPI_SOURCE = MPI_PROC_NULL;
1314 retval = MPI_SUCCESS;
1315 }else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0 ||
1316 (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0))){
1317 retval = MPI_ERR_RANK;
1318 } else if (sendcount < 0 || recvcount<0) {
1319 retval = MPI_ERR_COUNT;
1320 } else if ((sendbuf==NULL && sendcount > 0)||(recvbuf==NULL && recvcount>0)) {
1321 retval = MPI_ERR_COUNT;
1322 } else if((sendtag<0 && sendtag != MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){
1323 retval = MPI_ERR_TAG;
1327 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1328 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1329 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1330 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, sendcount*smpi_datatype_size(sendtype));
1331 TRACE_smpi_send(rank, rank, dst_traced,sendcount*smpi_datatype_size(sendtype));
1335 smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf,
1336 recvcount, recvtype, src, recvtag, comm, status);
1337 retval = MPI_SUCCESS;
1340 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1341 TRACE_smpi_recv(rank, src_traced, rank);
1350 int PMPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
1351 int dst, int sendtag, int src, int recvtag,
1352 MPI_Comm comm, MPI_Status * status)
1354 //TODO: suboptimal implementation
1357 if (datatype == MPI_DATATYPE_NULL) {
1358 retval = MPI_ERR_TYPE;
1359 } else if (count < 0) {
1360 retval = MPI_ERR_COUNT;
1362 int size = smpi_datatype_get_extent(datatype) * count;
1363 recvbuf = xbt_new(char, size);
1365 MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
1366 datatype, src, recvtag, comm, status);
1367 if(retval==MPI_SUCCESS){
1368 smpi_datatype_copy(recvbuf, count, datatype, buf, count, datatype);
1376 int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
1381 if (request == NULL || flag == NULL) {
1382 retval = MPI_ERR_ARG;
1383 } else if (*request == MPI_REQUEST_NULL) {
1385 smpi_empty_status(status);
1386 retval = MPI_ERR_REQUEST;
1388 *flag = smpi_mpi_test(request, status);
1389 retval = MPI_SUCCESS;
1395 int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
1396 MPI_Status * status)
1401 if (index == NULL || flag == NULL) {
1402 retval = MPI_ERR_ARG;
1404 *flag = smpi_mpi_testany(count, requests, index, status);
1405 retval = MPI_SUCCESS;
1411 int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses)
1417 retval = MPI_ERR_ARG;
1419 *flag = smpi_mpi_testall(count, requests, statuses);
1420 retval = MPI_SUCCESS;
1426 int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) {
1430 if (status == NULL) {
1431 retval = MPI_ERR_ARG;
1432 } else if (comm == MPI_COMM_NULL) {
1433 retval = MPI_ERR_COMM;
1434 } else if (source == MPI_PROC_NULL) {
1435 smpi_empty_status(status);
1436 status->MPI_SOURCE = MPI_PROC_NULL;
1437 retval = MPI_SUCCESS;
1439 smpi_mpi_probe(source, tag, comm, status);
1440 retval = MPI_SUCCESS;
1447 int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status) {
1452 retval = MPI_ERR_ARG;
1453 } else if (status == NULL) {
1454 retval = MPI_ERR_ARG;
1455 } else if (comm == MPI_COMM_NULL) {
1456 retval = MPI_ERR_COMM;
1457 } else if (source == MPI_PROC_NULL) {
1459 smpi_empty_status(status);
1460 status->MPI_SOURCE = MPI_PROC_NULL;
1461 retval = MPI_SUCCESS;
1463 smpi_mpi_iprobe(source, tag, comm, flag, status);
1464 retval = MPI_SUCCESS;
1470 int PMPI_Wait(MPI_Request * request, MPI_Status * status)
1476 smpi_empty_status(status);
1478 if (request == NULL) {
1479 retval = MPI_ERR_ARG;
1480 } else if (*request == MPI_REQUEST_NULL) {
1481 retval = MPI_ERR_REQUEST;
1485 int rank = request && (*request)->comm != MPI_COMM_NULL
1486 ? smpi_process_index()
1489 int src_traced = (*request)->src;
1490 int dst_traced = (*request)->dst;
1491 MPI_Comm comm = (*request)->comm;
1492 int is_wait_for_receive = (*request)->recv;
1493 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__,-1);
1496 smpi_mpi_wait(request, status);
1497 retval = MPI_SUCCESS;
1500 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1501 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1502 if (is_wait_for_receive) {
1503 if(src_traced==MPI_ANY_SOURCE)
1504 src_traced = (status!=MPI_STATUS_IGNORE) ?
1505 smpi_group_rank(smpi_comm_group(comm), status->MPI_SOURCE) :
1507 TRACE_smpi_recv(rank, src_traced, dst_traced);
1517 int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * status)
1523 //save requests information for tracing
1525 int *srcs = xbt_new(int, count);
1526 int *dsts = xbt_new(int, count);
1527 int *recvs = xbt_new(int, count);
1528 MPI_Comm *comms = xbt_new(MPI_Comm, count);
1530 for (i = 0; i < count; i++) {
1531 MPI_Request req = requests[i]; //already received requests are no longer valid
1535 recvs[i] = req->recv;
1536 comms[i] = req->comm;
1539 int rank_traced = smpi_process_index();
1541 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,count);
1544 if (index == NULL) {
1545 retval = MPI_ERR_ARG;
1547 *index = smpi_mpi_waitany(count, requests, status);
1548 retval = MPI_SUCCESS;
1551 if(*index!=MPI_UNDEFINED){
1552 int src_traced = srcs[*index];
1553 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1554 int dst_traced = dsts[*index];
1555 int is_wait_for_receive = recvs[*index];
1556 if (is_wait_for_receive) {
1557 if(srcs[*index]==MPI_ANY_SOURCE)
1558 src_traced = (status!=MPI_STATUSES_IGNORE) ?
1559 smpi_group_rank(smpi_comm_group(comms[*index]), status->MPI_SOURCE) :
1561 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1563 TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__);
1575 int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
1580 //save information from requests
1582 int *srcs = xbt_new(int, count);
1583 int *dsts = xbt_new(int, count);
1584 int *recvs = xbt_new(int, count);
1585 int *valid = xbt_new(int, count);
1586 MPI_Comm *comms = xbt_new(MPI_Comm, count);
1588 //int valid_count = 0;
1589 for (i = 0; i < count; i++) {
1590 MPI_Request req = requests[i];
1591 if(req!=MPI_REQUEST_NULL){
1594 recvs[i] = req->recv;
1595 comms[i] = req->comm;
1601 int rank_traced = smpi_process_index();
1603 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,count);
1605 int retval = smpi_mpi_waitall(count, requests, status);
1607 for (i = 0; i < count; i++) {
1609 //int src_traced = srcs[*index];
1610 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1611 int src_traced = srcs[i];
1612 int dst_traced = dsts[i];
1613 int is_wait_for_receive = recvs[i];
1614 if (is_wait_for_receive) {
1615 if(src_traced==MPI_ANY_SOURCE)
1616 src_traced = (status!=MPI_STATUSES_IGNORE) ?
1617 smpi_group_rank(smpi_comm_group(comms[i]), status[i].MPI_SOURCE) :
1619 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1623 TRACE_smpi_ptp_out(rank_traced, -1, -1, __FUNCTION__);
1635 int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
1636 int *indices, MPI_Status status[])
1641 if (outcount == NULL) {
1642 retval = MPI_ERR_ARG;
1644 *outcount = smpi_mpi_waitsome(incount, requests, indices, status);
1645 retval = MPI_SUCCESS;
1651 int PMPI_Testsome(int incount, MPI_Request requests[], int* outcount,
1652 int* indices, MPI_Status status[])
1657 if (outcount == NULL) {
1658 retval = MPI_ERR_ARG;
1660 *outcount = smpi_mpi_testsome(incount, requests, indices, status);
1661 retval = MPI_SUCCESS;
1668 int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
1674 if (comm == MPI_COMM_NULL) {
1675 retval = MPI_ERR_COMM;
1678 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1679 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1680 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, count*smpi_datatype_size(datatype));
1682 mpi_coll_bcast_fun(buf, count, datatype, root, comm);
1683 retval = MPI_SUCCESS;
1685 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1693 int PMPI_Barrier(MPI_Comm comm)
1699 if (comm == MPI_COMM_NULL) {
1700 retval = MPI_ERR_COMM;
1703 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1704 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, smpi_comm_size(comm));
1706 mpi_coll_barrier_fun(comm);
1707 retval = MPI_SUCCESS;
1709 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1717 int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1718 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1719 int root, MPI_Comm comm)
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 ((smpi_comm_rank(comm) == root) && (recvcount <0))){
1732 retval = MPI_ERR_COUNT;
1735 char* sendtmpbuf = (char*) sendbuf;
1736 int sendtmpcount = sendcount;
1737 MPI_Datatype sendtmptype = sendtype;
1738 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1740 sendtmptype=recvtype;
1743 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1744 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1745 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,sendcount*smpi_datatype_size(sendtmptype));
1747 mpi_coll_gather_fun(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcount,
1748 recvtype, root, comm);
1751 retval = MPI_SUCCESS;
1753 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1761 int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1762 void *recvbuf, int *recvcounts, int *displs,
1763 MPI_Datatype recvtype, int root, MPI_Comm comm)
1769 if (comm == MPI_COMM_NULL) {
1770 retval = MPI_ERR_COMM;
1771 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1772 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1773 retval = MPI_ERR_TYPE;
1774 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1775 retval = MPI_ERR_COUNT;
1776 } else if (recvcounts == NULL || displs == NULL) {
1777 retval = MPI_ERR_ARG;
1779 char* sendtmpbuf = (char*) sendbuf;
1780 int sendtmpcount = sendcount;
1781 MPI_Datatype sendtmptype = sendtype;
1782 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1784 sendtmptype=recvtype;
1788 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1789 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1790 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,sendcount*smpi_datatype_size(sendtmptype));
1792 smpi_mpi_gatherv(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcounts,
1793 displs, recvtype, root, comm);
1794 retval = MPI_SUCCESS;
1796 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1804 int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1805 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1812 if (comm == MPI_COMM_NULL) {
1813 retval = MPI_ERR_COMM;
1814 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1815 (recvtype == MPI_DATATYPE_NULL)){
1816 retval = MPI_ERR_TYPE;
1817 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1819 retval = MPI_ERR_COUNT;
1821 if(sendbuf == MPI_IN_PLACE) {
1822 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*recvcount*smpi_comm_rank(comm);
1823 sendcount=recvcount;
1827 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1828 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,sendcount*smpi_datatype_size(sendtype));
1830 mpi_coll_allgather_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1832 retval = MPI_SUCCESS;
1835 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1842 int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1843 void *recvbuf, int *recvcounts, int *displs,
1844 MPI_Datatype recvtype, MPI_Comm comm)
1850 if (comm == MPI_COMM_NULL) {
1851 retval = MPI_ERR_COMM;
1852 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1853 (recvtype == MPI_DATATYPE_NULL)){
1854 retval = MPI_ERR_TYPE;
1855 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1856 retval = MPI_ERR_COUNT;
1857 } else if (recvcounts == NULL || displs == NULL) {
1858 retval = MPI_ERR_ARG;
1861 if(sendbuf == MPI_IN_PLACE) {
1862 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*displs[smpi_comm_rank(comm)];
1863 sendcount=recvcounts[smpi_comm_rank(comm)];
1867 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1868 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,sendcount*smpi_datatype_size(sendtype));
1870 mpi_coll_allgatherv_fun(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
1871 displs, recvtype, comm);
1872 retval = MPI_SUCCESS;
1874 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1882 int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1883 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1884 int root, MPI_Comm comm)
1890 if (comm == MPI_COMM_NULL) {
1891 retval = MPI_ERR_COMM;
1892 } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
1893 || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
1894 retval = MPI_ERR_TYPE;
1897 if (recvbuf == MPI_IN_PLACE) {
1899 recvcount=sendcount;
1902 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1903 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1905 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,sendcount*smpi_datatype_size(recvtype));
1907 mpi_coll_scatter_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1908 recvtype, root, comm);
1909 retval = MPI_SUCCESS;
1911 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1919 int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
1920 MPI_Datatype sendtype, void *recvbuf, int recvcount,
1921 MPI_Datatype recvtype, int root, MPI_Comm comm)
1927 if (comm == MPI_COMM_NULL) {
1928 retval = MPI_ERR_COMM;
1929 } else if (sendcounts == NULL || displs == NULL) {
1930 retval = MPI_ERR_ARG;
1931 } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
1932 || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
1933 retval = MPI_ERR_TYPE;
1935 if (recvbuf == MPI_IN_PLACE) {
1937 recvcount=sendcounts[smpi_comm_rank(comm)];
1940 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1941 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1943 for(i=0; i<smpi_comm_size(comm);i++)count+=sendcounts[i];
1944 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, count*smpi_datatype_size(sendtype));
1946 smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
1947 recvcount, recvtype, root, comm);
1948 retval = MPI_SUCCESS;
1950 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1958 int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
1959 MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
1965 if (comm == MPI_COMM_NULL) {
1966 retval = MPI_ERR_COMM;
1967 } else if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
1968 retval = MPI_ERR_ARG;
1971 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1972 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1973 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, count*smpi_datatype_size(datatype));
1975 mpi_coll_reduce_fun(sendbuf, recvbuf, count, datatype, op, root, comm);
1977 retval = MPI_SUCCESS;
1979 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1987 int PMPI_Reduce_local(void *inbuf, void *inoutbuf, int count,
1988 MPI_Datatype datatype, MPI_Op op){
1992 if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
1993 retval = MPI_ERR_ARG;
1995 smpi_op_apply(op, inbuf, inoutbuf, &count, &datatype);
2002 int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
2003 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2009 if (comm == MPI_COMM_NULL) {
2010 retval = MPI_ERR_COMM;
2011 } else if (datatype == MPI_DATATYPE_NULL) {
2012 retval = MPI_ERR_TYPE;
2013 } else if (op == MPI_OP_NULL) {
2014 retval = MPI_ERR_OP;
2017 char* sendtmpbuf = (char*) sendbuf;
2018 if( sendbuf == MPI_IN_PLACE ) {
2019 sendtmpbuf = (char *)xbt_malloc(count*smpi_datatype_get_extent(datatype));
2020 smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
2023 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2024 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, count*smpi_datatype_size(datatype));
2026 mpi_coll_allreduce_fun(sendtmpbuf, recvbuf, count, datatype, op, comm);
2028 if( sendbuf == MPI_IN_PLACE ) {
2029 xbt_free(sendtmpbuf);
2032 retval = MPI_SUCCESS;
2034 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2042 int PMPI_Scan(void *sendbuf, void *recvbuf, int count,
2043 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2049 if (comm == MPI_COMM_NULL) {
2050 retval = MPI_ERR_COMM;
2051 } else if (datatype == MPI_DATATYPE_NULL) {
2052 retval = MPI_ERR_TYPE;
2053 } else if (op == MPI_OP_NULL) {
2054 retval = MPI_ERR_OP;
2057 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2058 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, count*smpi_datatype_size(datatype));
2060 smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm);
2061 retval = MPI_SUCCESS;
2063 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2071 int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
2072 MPI_Op op, MPI_Comm comm){
2077 if (comm == MPI_COMM_NULL) {
2078 retval = MPI_ERR_COMM;
2079 } else if (datatype == MPI_DATATYPE_NULL) {
2080 retval = MPI_ERR_TYPE;
2081 } else if (op == MPI_OP_NULL) {
2082 retval = MPI_ERR_OP;
2085 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2086 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, count*smpi_datatype_size(datatype));
2088 smpi_mpi_exscan(sendbuf, recvbuf, count, datatype, op, comm);
2089 retval = MPI_SUCCESS;
2091 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2099 int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
2100 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2105 if (comm == MPI_COMM_NULL) {
2106 retval = MPI_ERR_COMM;
2107 } else if (datatype == MPI_DATATYPE_NULL) {
2108 retval = MPI_ERR_TYPE;
2109 } else if (op == MPI_OP_NULL) {
2110 retval = MPI_ERR_OP;
2111 } else if (recvcounts == NULL) {
2112 retval = MPI_ERR_ARG;
2115 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2117 for(i=0; i<smpi_comm_size(comm);i++)count+=recvcounts[i];
2118 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, count*smpi_datatype_size(datatype));
2120 void* sendtmpbuf=sendbuf;
2121 if(sendbuf==MPI_IN_PLACE){
2125 mpi_coll_reduce_scatter_fun(sendtmpbuf, recvbuf, recvcounts,
2126 datatype, op, comm);
2127 retval = MPI_SUCCESS;
2129 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2137 int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
2138 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2143 if (comm == MPI_COMM_NULL) {
2144 retval = MPI_ERR_COMM;
2145 } else if (datatype == MPI_DATATYPE_NULL) {
2146 retval = MPI_ERR_TYPE;
2147 } else if (op == MPI_OP_NULL) {
2148 retval = MPI_ERR_OP;
2149 } else if (recvcount < 0) {
2150 retval = MPI_ERR_ARG;
2153 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2154 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, recvcount*smpi_comm_size(comm)*smpi_datatype_size(datatype));
2156 int count=smpi_comm_size(comm);
2157 int* recvcounts=(int*)xbt_malloc(count);
2158 for (i=0; i<count;i++)recvcounts[i]=recvcount;
2159 mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts,
2160 datatype, op, comm);
2161 xbt_free(recvcounts);
2162 retval = MPI_SUCCESS;
2164 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2172 int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
2173 void *recvbuf, int recvcount, MPI_Datatype recvtype,
2180 if (comm == MPI_COMM_NULL) {
2181 retval = MPI_ERR_COMM;
2182 } else if (sendtype == MPI_DATATYPE_NULL
2183 || recvtype == MPI_DATATYPE_NULL) {
2184 retval = MPI_ERR_TYPE;
2187 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2188 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, sendcount*smpi_datatype_size(sendtype));
2190 retval = mpi_coll_alltoall_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
2192 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2200 int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
2201 MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
2202 int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
2208 if (comm == MPI_COMM_NULL) {
2209 retval = MPI_ERR_COMM;
2210 } else if (sendtype == MPI_DATATYPE_NULL
2211 || recvtype == MPI_DATATYPE_NULL) {
2212 retval = MPI_ERR_TYPE;
2213 } else if (sendcounts == NULL || senddisps == NULL || recvcounts == NULL
2214 || recvdisps == NULL) {
2215 retval = MPI_ERR_ARG;
2218 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2220 for(i=0; i< smpi_comm_size(comm);i++)size+=sendcounts[i];
2221 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, size*smpi_datatype_size(sendtype));
2224 mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, sendtype,
2225 recvbuf, recvcounts, recvdisps, recvtype,
2228 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2237 int PMPI_Get_processor_name(char *name, int *resultlen)
2239 int retval = MPI_SUCCESS;
2242 strncpy(name, SIMIX_host_get_name(SIMIX_host_self()),
2243 strlen(SIMIX_host_get_name(SIMIX_host_self())) < MPI_MAX_PROCESSOR_NAME - 1 ?
2244 strlen(SIMIX_host_get_name(SIMIX_host_self())) +1 :
2245 MPI_MAX_PROCESSOR_NAME - 1 );
2248 MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
2254 int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
2256 int retval = MPI_SUCCESS;
2260 if (status == NULL || count == NULL) {
2261 retval = MPI_ERR_ARG;
2262 } else if (datatype == MPI_DATATYPE_NULL) {
2263 retval = MPI_ERR_TYPE;
2265 size = smpi_datatype_size(datatype);
2268 } else if (status->count % size != 0) {
2269 retval = MPI_UNDEFINED;
2271 *count = smpi_mpi_get_count(status, datatype);
2278 int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type) {
2282 if (old_type == MPI_DATATYPE_NULL) {
2283 retval = MPI_ERR_TYPE;
2284 } else if (count<0){
2285 retval = MPI_ERR_COUNT;
2287 retval = smpi_datatype_contiguous(count, old_type, new_type, 0);
2293 int PMPI_Type_commit(MPI_Datatype* datatype) {
2297 if (datatype == NULL || *datatype == MPI_DATATYPE_NULL) {
2298 retval = MPI_ERR_TYPE;
2300 smpi_datatype_commit(datatype);
2301 retval = MPI_SUCCESS;
2308 int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2312 if (old_type == MPI_DATATYPE_NULL) {
2313 retval = MPI_ERR_TYPE;
2314 } else if (count<0 || blocklen<0){
2315 retval = MPI_ERR_COUNT;
2317 retval = smpi_datatype_vector(count, blocklen, stride, old_type, new_type);
2323 int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2327 if (old_type == MPI_DATATYPE_NULL) {
2328 retval = MPI_ERR_TYPE;
2329 } else if (count<0 || blocklen<0){
2330 retval = MPI_ERR_COUNT;
2332 retval = smpi_datatype_hvector(count, blocklen, stride, old_type, new_type);
2338 int PMPI_Type_create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2339 return MPI_Type_hvector(count, blocklen, stride, old_type, new_type);
2342 int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2346 if (old_type == MPI_DATATYPE_NULL) {
2347 retval = MPI_ERR_TYPE;
2348 } else if (count<0){
2349 retval = MPI_ERR_COUNT;
2351 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2357 int PMPI_Type_create_indexed(int count, int* blocklens, int* indices, 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){
2364 retval = MPI_ERR_COUNT;
2366 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2372 int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, 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){
2379 retval = MPI_ERR_COUNT;
2381 int* blocklens=(int*)xbt_malloc(blocklength*count);
2382 for (i=0; i<count;i++)blocklens[i]=blocklength;
2383 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2384 xbt_free(blocklens);
2391 int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* 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_hindexed(count, blocklens, indices, old_type, new_type);
2406 int PMPI_Type_create_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2407 return PMPI_Type_hindexed(count, blocklens,indices,old_type,new_type);
2410 int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2414 if (old_type == MPI_DATATYPE_NULL) {
2415 retval = MPI_ERR_TYPE;
2416 } else if (count<0){
2417 retval = MPI_ERR_COUNT;
2419 int* blocklens=(int*)xbt_malloc(blocklength*count);
2420 for (i=0; i<count;i++)blocklens[i]=blocklength;
2421 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2422 xbt_free(blocklens);
2429 int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2434 retval = MPI_ERR_COUNT;
2436 retval = smpi_datatype_struct(count, blocklens, indices, old_types, new_type);
2442 int PMPI_Type_create_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2443 return PMPI_Type_struct(count, blocklens, indices, old_types, new_type);
2447 int PMPI_Error_class(int errorcode, int* errorclass) {
2448 // assume smpi uses only standard mpi error codes
2449 *errorclass=errorcode;
2454 int PMPI_Initialized(int* flag) {
2455 *flag=smpi_process_initialized();
2459 /* The following calls are not yet implemented and will fail at runtime. */
2460 /* Once implemented, please move them above this notice. */
2462 #define NOT_YET_IMPLEMENTED {\
2463 XBT_WARN("Not yet implemented : %s. Please contact the Simgrid team if support is needed", __FUNCTION__);\
2464 return MPI_SUCCESS;\
2468 int PMPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype){
2472 int PMPI_Type_set_name(MPI_Datatype datatype, char * name)
2477 int PMPI_Type_get_name(MPI_Datatype datatype, char * name, int* len)
2482 int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
2486 int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) {
2490 int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periods, int reorder, MPI_Comm* comm_cart) {
2494 int PMPI_Cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) {
2498 int PMPI_Cart_map(MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank) {
2502 int PMPI_Cart_rank(MPI_Comm comm, int* coords, int* rank) {
2506 int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* dest) {
2510 int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
2514 int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) {
2518 int PMPI_Graph_create(MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder, MPI_Comm* comm_graph) {
2522 int PMPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int* index, int* edges) {
2526 int PMPI_Graph_map(MPI_Comm comm_old, int nnodes, int* index, int* edges, int* newrank) {
2530 int PMPI_Graph_neighbors(MPI_Comm comm, int rank, int maxneighbors, int* neighbors) {
2534 int PMPI_Graph_neighbors_count(MPI_Comm comm, int rank, int* nneighbors) {
2538 int PMPI_Graphdims_get(MPI_Comm comm, int* nnodes, int* nedges) {
2542 int PMPI_Topo_test(MPI_Comm comm, int* top_type) {
2546 int PMPI_Errhandler_create(MPI_Handler_function* function, MPI_Errhandler* errhandler) {
2550 int PMPI_Errhandler_free(MPI_Errhandler* errhandler) {
2554 int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler* errhandler) {
2558 int PMPI_Error_string(int errorcode, char* string, int* resultlen) {
2562 int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler) {
2566 int PMPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler) {
2570 int PMPI_Comm_get_errhandler(MPI_Comm comm, MPI_Errhandler* errhandler) {
2574 int PMPI_Cancel(MPI_Request* request) {
2578 int PMPI_Buffer_attach(void* buffer, int size) {
2582 int PMPI_Buffer_detach(void* buffer, int* size) {
2586 int PMPI_Comm_test_inter(MPI_Comm comm, int* flag) {
2590 int PMPI_Comm_get_attr (MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag)
2595 int PMPI_Comm_set_attr (MPI_Comm comm, int comm_keyval, void *attribute_val)
2600 int PMPI_Comm_delete_attr (MPI_Comm comm, int comm_keyval)
2605 int PMPI_Comm_create_keyval(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state)
2610 int PMPI_Comm_free_keyval(int* keyval) {
2614 int PMPI_Pcontrol(const int level )
2619 int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
2623 int PMPI_Type_get_attr (MPI_Datatype type, int type_keyval, void *attribute_val, int* flag)
2628 int PMPI_Type_set_attr (MPI_Datatype type, int type_keyval, void *attribute_val)
2633 int PMPI_Type_delete_attr (MPI_Datatype type, int comm_keyval)
2638 int PMPI_Type_create_keyval(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state)
2643 int PMPI_Type_free_keyval(int* keyval) {
2647 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
2651 int PMPI_Intercomm_merge(MPI_Comm comm, int high, MPI_Comm* comm_out) {
2655 int PMPI_Bsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2659 int PMPI_Bsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2663 int PMPI_Ibsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2667 int PMPI_Comm_remote_group(MPI_Comm comm, MPI_Group* group) {
2671 int PMPI_Comm_remote_size(MPI_Comm comm, int* size) {
2675 int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
2679 int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) {
2683 int PMPI_Attr_put(MPI_Comm comm, int keyval, void* attr_value) {
2687 int PMPI_Rsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2691 int PMPI_Rsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2695 int PMPI_Irsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2699 int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
2703 int PMPI_Keyval_free(int* keyval) {
2707 int PMPI_Test_cancelled(MPI_Status* status, int* flag) {
2711 int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
2715 int PMPI_Pack_external_size(char *datarep, int incount, MPI_Datatype datatype, MPI_Aint *size){
2719 int PMPI_Pack_external(char *datarep, void *inbuf, int incount, MPI_Datatype datatype, void *outbuf, MPI_Aint outcount, MPI_Aint *position){
2723 int PMPI_Unpack_external( char *datarep, void *inbuf, MPI_Aint insize, MPI_Aint *position, void *outbuf, int outcount, MPI_Datatype datatype){
2727 int PMPI_Get_elements(MPI_Status* status, MPI_Datatype datatype, int* elements) {
2731 int PMPI_Dims_create(int nnodes, int ndims, int* dims) {
2735 int PMPI_Win_fence( int assert, MPI_Win win){
2739 int PMPI_Win_free( MPI_Win* win){
2743 int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win){
2747 int PMPI_Info_create( MPI_Info *info){
2751 int PMPI_Info_set( MPI_Info info, char *key, char *value){
2755 int PMPI_Info_free( MPI_Info *info){
2759 int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2760 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
2764 int PMPI_Type_get_envelope( MPI_Datatype datatype, int *num_integers,
2765 int *num_addresses, int *num_datatypes, int *combiner){
2769 int PMPI_Type_get_contents(MPI_Datatype datatype, int max_integers, int max_addresses,
2770 int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses,
2771 MPI_Datatype* array_of_datatypes){
2775 int PMPI_Type_create_darray(int size, int rank, int ndims, int* array_of_gsizes,
2776 int* array_of_distribs, int* array_of_dargs, int* array_of_psizes,
2777 int order, MPI_Datatype oldtype, MPI_Datatype *newtype) {
2781 int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype){
2785 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){
2789 int PMPI_Type_match_size(int typeclass,int size,MPI_Datatype *datatype){
2793 int PMPI_Alltoallw( void *sendbuf, int *sendcnts, int *sdispls, MPI_Datatype *sendtypes,
2794 void *recvbuf, int *recvcnts, int *rdispls, MPI_Datatype *recvtypes,
2799 int PMPI_Comm_set_name(MPI_Comm comm, char* name){
2803 int PMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm * newcomm){
2807 int PMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm){
2811 int PMPI_Comm_set_info (MPI_Comm comm, MPI_Info info){
2815 int PMPI_Comm_get_info (MPI_Comm comm, MPI_Info* info){
2819 int PMPI_Info_get(MPI_Info info,char *key,int valuelen, char *value, int *flag){
2823 int PMPI_Comm_create_errhandler( MPI_Comm_errhandler_fn *function, MPI_Errhandler *errhandler){
2827 int PMPI_Add_error_class( int *errorclass){
2831 int PMPI_Add_error_code( int errorclass, int *errorcode){
2835 int PMPI_Add_error_string( int errorcode, char *string){
2839 int PMPI_Comm_call_errhandler(MPI_Comm comm,int errorcode){
2843 int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo){
2847 int PMPI_Info_delete(MPI_Info info, char *key){
2851 int PMPI_Info_get_nkeys( MPI_Info info, int *nkeys){
2855 int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){
2859 int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){
2863 int PMPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){
2867 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){
2871 int PMPI_Grequest_complete( MPI_Request request){
2875 int PMPI_Status_set_cancelled(MPI_Status *status,int flag){
2879 int PMPI_Status_set_elements( MPI_Status *status, MPI_Datatype datatype, int count){
2883 int PMPI_Comm_connect( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
2887 int PMPI_Publish_name( char *service_name, MPI_Info info, char *port_name){
2891 int PMPI_Unpublish_name( char *service_name, MPI_Info info, char *port_name){
2895 int PMPI_Lookup_name( char *service_name, MPI_Info info, char *port_name){
2899 int PMPI_Comm_join( int fd, MPI_Comm *intercomm){
2903 int PMPI_Open_port( MPI_Info info, char *port_name){
2907 int PMPI_Close_port(char *port_name){
2911 int PMPI_Comm_accept( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
2915 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){
2919 int PMPI_Comm_spawn_multiple( int count, char **array_of_commands, char*** array_of_argv,
2920 int* array_of_maxprocs, MPI_Info* array_of_info, int root,
2921 MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes){
2925 int PMPI_Comm_get_parent( MPI_Comm *parent){