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);
30 smpi_process_mark_as_initialized();
32 int rank = smpi_process_index();
33 TRACE_smpi_init(rank);
35 TRACE_smpi_computing_init(rank);
41 int PMPI_Finalize(void)
43 smpi_process_finalize();
46 int rank = smpi_process_index();
47 TRACE_smpi_computing_out(rank);
48 TRACE_smpi_finalize(smpi_process_index());
50 smpi_process_destroy();
54 int PMPI_Finalized(int* flag)
56 *flag=smpi_process_finalized();
60 int PMPI_Get_version (int *version,int *subversion){
61 *version = MPI_VERSION;
62 *subversion= MPI_SUBVERSION;
66 int PMPI_Get_library_version (char *version,int *len){
67 int retval = MPI_SUCCESS;
69 snprintf(version,MPI_MAX_LIBRARY_VERSION_STRING,"SMPI Version %d.%d. Copyright The Simgrid Team 2007-2013",SIMGRID_VERSION_MAJOR,
70 SIMGRID_VERSION_MINOR);
71 *len = strlen(version) > MPI_MAX_LIBRARY_VERSION_STRING ? MPI_MAX_LIBRARY_VERSION_STRING : strlen(version);
76 int PMPI_Init_thread(int *argc, char ***argv, int required, int *provided)
78 if (provided != NULL) {
79 *provided = MPI_THREAD_MULTIPLE;
81 return MPI_Init(argc, argv);
84 int PMPI_Query_thread(int *provided)
89 if (provided == NULL) {
92 *provided = MPI_THREAD_MULTIPLE;
99 int PMPI_Is_thread_main(int *flag)
105 retval = MPI_ERR_ARG;
107 *flag = smpi_process_index() == 0;
108 retval = MPI_SUCCESS;
114 int PMPI_Abort(MPI_Comm comm, int errorcode)
117 smpi_process_destroy();
119 int rank = smpi_process_index();
120 TRACE_smpi_computing_out(rank);
122 // FIXME: should kill all processes in comm instead
123 simcall_process_kill(SIMIX_process_self());
127 double PMPI_Wtime(void)
132 time = SIMIX_get_clock();
136 extern double sg_maxmin_precision;
137 double PMPI_Wtick(void)
139 return sg_maxmin_precision;
142 int PMPI_Address(void *location, MPI_Aint * address)
148 retval = MPI_ERR_ARG;
150 *address = (MPI_Aint) location;
151 retval = MPI_SUCCESS;
157 int PMPI_Get_address(void *location, MPI_Aint * address)
159 return PMPI_Address(location, address);
162 int PMPI_Type_free(MPI_Datatype * datatype)
168 retval = MPI_ERR_ARG;
170 smpi_datatype_free(datatype);
171 retval = MPI_SUCCESS;
177 int PMPI_Type_size(MPI_Datatype datatype, int *size)
182 if (datatype == MPI_DATATYPE_NULL) {
183 retval = MPI_ERR_TYPE;
184 } else if (size == NULL) {
185 retval = MPI_ERR_ARG;
187 *size = (int) smpi_datatype_size(datatype);
188 retval = MPI_SUCCESS;
194 int PMPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
199 if (datatype == MPI_DATATYPE_NULL) {
200 retval = MPI_ERR_TYPE;
201 } else if (lb == NULL || extent == NULL) {
202 retval = MPI_ERR_ARG;
204 retval = smpi_datatype_extent(datatype, lb, extent);
210 int PMPI_Type_get_true_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
212 return PMPI_Type_get_extent(datatype, lb, extent);
215 int PMPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent)
220 if (datatype == MPI_DATATYPE_NULL) {
221 retval = MPI_ERR_TYPE;
222 } else if (extent == NULL) {
223 retval = MPI_ERR_ARG;
225 *extent = smpi_datatype_get_extent(datatype);
226 retval = MPI_SUCCESS;
232 int PMPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp)
237 if (datatype == MPI_DATATYPE_NULL) {
238 retval = MPI_ERR_TYPE;
239 } else if (disp == NULL) {
240 retval = MPI_ERR_ARG;
242 *disp = smpi_datatype_lb(datatype);
243 retval = MPI_SUCCESS;
249 int PMPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp)
254 if (datatype == MPI_DATATYPE_NULL) {
255 retval = MPI_ERR_TYPE;
256 } else if (disp == NULL) {
257 retval = MPI_ERR_ARG;
259 *disp = smpi_datatype_ub(datatype);
260 retval = MPI_SUCCESS;
266 int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
271 if (function == NULL || op == NULL) {
272 retval = MPI_ERR_ARG;
274 *op = smpi_op_new(function, commute);
275 retval = MPI_SUCCESS;
281 int PMPI_Op_free(MPI_Op * op)
287 retval = MPI_ERR_ARG;
288 } else if (*op == MPI_OP_NULL) {
291 smpi_op_destroy(*op);
293 retval = MPI_SUCCESS;
299 int PMPI_Group_free(MPI_Group * group)
305 retval = MPI_ERR_ARG;
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 retval = MPI_SUCCESS;
428 int PMPI_Group_intersection(MPI_Group group1, MPI_Group group2,
429 MPI_Group * newgroup)
431 int retval, i, proc1, proc2, size;
434 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
435 retval = MPI_ERR_GROUP;
436 } else if (newgroup == NULL) {
437 retval = MPI_ERR_ARG;
439 size = smpi_group_size(group2);
440 for (i = 0; i < size; i++) {
441 proc2 = smpi_group_index(group2, i);
442 proc1 = smpi_group_rank(group1, proc2);
443 if (proc1 == MPI_UNDEFINED) {
448 *newgroup = MPI_GROUP_EMPTY;
450 *newgroup = smpi_group_new(size);
452 for (i = 0; i < smpi_group_size(group2); i++) {
453 proc2 = smpi_group_index(group2, i);
454 proc1 = smpi_group_rank(group1, proc2);
455 if (proc1 != MPI_UNDEFINED) {
456 smpi_group_set_mapping(*newgroup, proc2, j);
461 retval = MPI_SUCCESS;
467 int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgroup)
469 int retval, i, proc1, proc2, size, size2;
472 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
473 retval = MPI_ERR_GROUP;
474 } else if (newgroup == NULL) {
475 retval = MPI_ERR_ARG;
477 size = size2 = smpi_group_size(group1);
478 for (i = 0; i < size2; i++) {
479 proc1 = smpi_group_index(group1, i);
480 proc2 = smpi_group_rank(group2, proc1);
481 if (proc2 != MPI_UNDEFINED) {
486 *newgroup = MPI_GROUP_EMPTY;
488 *newgroup = smpi_group_new(size);
489 for (i = 0; i < size2; i++) {
490 proc1 = smpi_group_index(group1, i);
491 proc2 = smpi_group_rank(group2, proc1);
492 if (proc2 == MPI_UNDEFINED) {
493 smpi_group_set_mapping(*newgroup, proc1, i);
497 retval = MPI_SUCCESS;
503 int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
505 int retval, i, index;
508 if (group == MPI_GROUP_NULL) {
509 retval = MPI_ERR_GROUP;
510 } else if (newgroup == NULL) {
511 retval = MPI_ERR_ARG;
514 *newgroup = MPI_GROUP_EMPTY;
515 } else if (n == smpi_group_size(group)) {
517 if(group!= smpi_comm_group(MPI_COMM_WORLD)
518 && group != MPI_GROUP_NULL
519 && group != smpi_comm_group(MPI_COMM_SELF)
520 && group != MPI_GROUP_EMPTY)
521 smpi_group_use(group);
523 *newgroup = smpi_group_new(n);
524 for (i = 0; i < n; i++) {
525 index = smpi_group_index(group, ranks[i]);
526 smpi_group_set_mapping(*newgroup, index, i);
529 retval = MPI_SUCCESS;
535 int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
537 int retval, i, j, newsize, oldsize, index;
540 if (group == MPI_GROUP_NULL) {
541 retval = MPI_ERR_GROUP;
542 } else if (newgroup == NULL) {
543 retval = MPI_ERR_ARG;
547 if(group!= smpi_comm_group(MPI_COMM_WORLD)
548 && group != MPI_GROUP_NULL
549 && group != smpi_comm_group(MPI_COMM_SELF)
550 && group != MPI_GROUP_EMPTY)
551 smpi_group_use(group);
552 } else if (n == smpi_group_size(group)) {
553 *newgroup = MPI_GROUP_EMPTY;
555 oldsize=smpi_group_size(group);
556 newsize = oldsize - n;
557 *newgroup = smpi_group_new(newsize);
559 int* to_exclude=xbt_new(int, smpi_group_size(group));
560 for(i=0; i<oldsize; i++)
563 to_exclude[ranks[i]]=1;
566 for(i=0; i<oldsize; i++){
567 if(to_exclude[i]==0){
568 index = smpi_group_index(group, i);
569 smpi_group_set_mapping(*newgroup, index, j);
574 xbt_free(to_exclude);
576 retval = MPI_SUCCESS;
582 int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
583 MPI_Group * newgroup)
585 int retval, i, j, rank, size, index;
588 if (group == MPI_GROUP_NULL) {
589 retval = MPI_ERR_GROUP;
590 } else if (newgroup == NULL) {
591 retval = MPI_ERR_ARG;
594 *newgroup = MPI_GROUP_EMPTY;
597 for (i = 0; i < n; i++) {
598 for (rank = ranges[i][0]; /* First */
599 rank >= 0; /* Last */
603 rank += ranges[i][2]; /* Stride */
604 if (ranges[i][0]<ranges[i][1]){
605 if(rank > ranges[i][1])
608 if(rank < ranges[i][1])
614 *newgroup = smpi_group_new(size);
616 for (i = 0; i < n; i++) {
617 for (rank = ranges[i][0]; /* First */
618 rank >= 0; /* Last */
620 index = smpi_group_index(group, rank);
621 smpi_group_set_mapping(*newgroup, index, j);
623 rank += ranges[i][2]; /* Stride */
624 if (ranges[i][0]<ranges[i][1]){
625 if(rank > ranges[i][1])
628 if(rank < ranges[i][1])
634 retval = MPI_SUCCESS;
640 int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
641 MPI_Group * newgroup)
643 int retval, i, rank, newrank,oldrank, size, index, add;
646 if (group == MPI_GROUP_NULL) {
647 retval = MPI_ERR_GROUP;
648 } else if (newgroup == NULL) {
649 retval = MPI_ERR_ARG;
653 if(group!= smpi_comm_group(MPI_COMM_WORLD)
654 && group != MPI_GROUP_NULL
655 && group != smpi_comm_group(MPI_COMM_SELF)
656 && group != MPI_GROUP_EMPTY)
657 smpi_group_use(group);
659 size = smpi_group_size(group);
660 for (i = 0; i < n; i++) {
661 for (rank = ranges[i][0]; /* First */
662 rank >= 0; /* Last */
666 rank += ranges[i][2]; /* Stride */
667 if (ranges[i][0]<ranges[i][1]){
668 if(rank > ranges[i][1])
671 if(rank < ranges[i][1])
677 *newgroup = MPI_GROUP_EMPTY;
679 *newgroup = smpi_group_new(size);
682 while (newrank < size) {
684 for (i = 0; i < n; i++) {
685 for (rank = ranges[i][0];rank >= 0;){
691 rank += ranges[i][2]; /* Stride */
693 if (ranges[i][0]<ranges[i][1]){
694 if(rank > ranges[i][1])
697 if(rank < ranges[i][1])
703 index = smpi_group_index(group, oldrank);
704 smpi_group_set_mapping(*newgroup, index, newrank);
712 retval = MPI_SUCCESS;
718 int PMPI_Comm_rank(MPI_Comm comm, int *rank)
723 if (comm == MPI_COMM_NULL) {
724 retval = MPI_ERR_COMM;
725 } else if (rank == NULL) {
726 retval = MPI_ERR_ARG;
728 *rank = smpi_comm_rank(comm);
729 retval = MPI_SUCCESS;
735 int PMPI_Comm_size(MPI_Comm comm, int *size)
740 if (comm == MPI_COMM_NULL) {
741 retval = MPI_ERR_COMM;
742 } else if (size == NULL) {
743 retval = MPI_ERR_ARG;
745 *size = smpi_comm_size(comm);
746 retval = MPI_SUCCESS;
752 int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len)
757 if (comm == MPI_COMM_NULL) {
758 retval = MPI_ERR_COMM;
759 } else if (name == NULL || len == NULL) {
760 retval = MPI_ERR_ARG;
762 smpi_comm_get_name(comm, name, len);
763 retval = MPI_SUCCESS;
769 int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
774 if (comm == MPI_COMM_NULL) {
775 retval = MPI_ERR_COMM;
776 } else if (group == NULL) {
777 retval = MPI_ERR_ARG;
779 *group = smpi_comm_group(comm);
780 if(*group!= smpi_comm_group(MPI_COMM_WORLD)
781 && *group != MPI_GROUP_NULL
782 && *group != smpi_comm_group(MPI_COMM_SELF)
783 && *group != MPI_GROUP_EMPTY)
784 smpi_group_use(*group);
785 retval = MPI_SUCCESS;
791 int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
796 if (comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) {
797 retval = MPI_ERR_COMM;
798 } else if (result == NULL) {
799 retval = MPI_ERR_ARG;
801 if (comm1 == comm2) { /* Same communicators means same groups */
805 smpi_group_compare(smpi_comm_group(comm1),
806 smpi_comm_group(comm2));
807 if (*result == MPI_IDENT) {
808 *result = MPI_CONGRUENT;
811 retval = MPI_SUCCESS;
817 int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm)
822 if (comm == MPI_COMM_NULL) {
823 retval = MPI_ERR_COMM;
824 } else if (newcomm == NULL) {
825 retval = MPI_ERR_ARG;
827 *newcomm = smpi_comm_new(smpi_comm_group(comm));
828 retval = MPI_SUCCESS;
834 int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
839 if (comm == MPI_COMM_NULL) {
840 retval = MPI_ERR_COMM;
841 } else if (group == MPI_GROUP_NULL) {
842 retval = MPI_ERR_GROUP;
843 } else if (newcomm == NULL) {
844 retval = MPI_ERR_ARG;
845 } else if(smpi_group_rank(group,smpi_process_index())==MPI_UNDEFINED){
846 *newcomm= MPI_COMM_NULL;
847 retval = MPI_SUCCESS;
850 *newcomm = smpi_comm_new(group);
851 retval = MPI_SUCCESS;
857 int PMPI_Comm_free(MPI_Comm * comm)
863 retval = MPI_ERR_ARG;
864 } else if (*comm == MPI_COMM_NULL) {
865 retval = MPI_ERR_COMM;
867 smpi_comm_destroy(*comm);
868 *comm = MPI_COMM_NULL;
869 retval = MPI_SUCCESS;
875 int PMPI_Comm_disconnect(MPI_Comm * comm)
877 /* TODO: wait until all communication in comm are done */
882 retval = MPI_ERR_ARG;
883 } else if (*comm == MPI_COMM_NULL) {
884 retval = MPI_ERR_COMM;
886 smpi_comm_destroy(*comm);
887 *comm = MPI_COMM_NULL;
888 retval = MPI_SUCCESS;
894 int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out)
899 if (comm_out == NULL) {
900 retval = MPI_ERR_ARG;
901 } else if (comm == MPI_COMM_NULL) {
902 retval = MPI_ERR_COMM;
904 *comm_out = smpi_comm_split(comm, color, key);
905 retval = MPI_SUCCESS;
911 int PMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst,
912 int tag, MPI_Comm comm, MPI_Request * request)
917 if (request == NULL) {
918 retval = MPI_ERR_ARG;
919 } else if (comm == MPI_COMM_NULL) {
920 retval = MPI_ERR_COMM;
921 } else if (dst == MPI_PROC_NULL) {
922 retval = MPI_SUCCESS;
924 *request = smpi_mpi_send_init(buf, count, datatype, dst, tag, comm);
925 retval = MPI_SUCCESS;
931 int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src,
932 int tag, MPI_Comm comm, MPI_Request * request)
937 if (request == NULL) {
938 retval = MPI_ERR_ARG;
939 } else if (comm == MPI_COMM_NULL) {
940 retval = MPI_ERR_COMM;
941 } else if (src == MPI_PROC_NULL) {
942 retval = MPI_SUCCESS;
944 *request = smpi_mpi_recv_init(buf, count, datatype, src, tag, comm);
945 retval = MPI_SUCCESS;
951 int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) {
955 if (request == NULL) {
956 retval = MPI_ERR_ARG;
957 } else if (comm == MPI_COMM_NULL) {
958 retval = MPI_ERR_COMM;
959 } else if (dst == MPI_PROC_NULL) {
960 retval = MPI_SUCCESS;
962 *request = smpi_mpi_ssend_init(buf, count, datatype, dst, tag, comm);
963 retval = MPI_SUCCESS;
969 int PMPI_Start(MPI_Request * request)
974 if (request == NULL || *request == MPI_REQUEST_NULL) {
975 retval = MPI_ERR_ARG;
977 smpi_mpi_start(*request);
978 retval = MPI_SUCCESS;
984 int PMPI_Startall(int count, MPI_Request * requests)
989 if (requests == NULL) {
990 retval = MPI_ERR_ARG;
992 smpi_mpi_startall(count, requests);
993 retval = MPI_SUCCESS;
999 int PMPI_Request_free(MPI_Request * request)
1004 if (*request == MPI_REQUEST_NULL) {
1005 retval = MPI_ERR_ARG;
1007 if((*request)->flags & PERSISTENT)(*request)->refcount--;
1008 smpi_mpi_request_free(request);
1009 retval = MPI_SUCCESS;
1015 int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src,
1016 int tag, MPI_Comm comm, MPI_Request * request)
1022 if (request == NULL) {
1023 retval = MPI_ERR_ARG;
1024 } else if (comm == MPI_COMM_NULL) {
1025 retval = MPI_ERR_COMM;
1026 } else if (src == MPI_PROC_NULL) {
1027 *request = MPI_REQUEST_NULL;
1028 retval = MPI_SUCCESS;
1029 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
1030 retval = MPI_ERR_COMM;
1031 } else if (count < 0) {
1032 retval = MPI_ERR_COUNT;
1033 } else if (buf==NULL && count > 0) {
1034 retval = MPI_ERR_COUNT;
1035 } else if (datatype == MPI_DATATYPE_NULL){
1036 retval = MPI_ERR_TYPE;
1037 } else if(tag<0 && tag != MPI_ANY_TAG){
1038 retval = MPI_ERR_TAG;
1042 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1043 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1044 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
1047 *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm);
1048 retval = MPI_SUCCESS;
1051 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1052 (*request)->recv = 1;
1061 int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
1062 int tag, MPI_Comm comm, MPI_Request * request)
1067 if (request == NULL) {
1068 retval = MPI_ERR_ARG;
1069 } else if (comm == MPI_COMM_NULL) {
1070 retval = MPI_ERR_COMM;
1071 } else if (dst == MPI_PROC_NULL) {
1072 *request = MPI_REQUEST_NULL;
1073 retval = MPI_SUCCESS;
1074 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1075 retval = MPI_ERR_RANK;
1076 } else if (count < 0) {
1077 retval = MPI_ERR_COUNT;
1078 } else if (buf==NULL && count > 0) {
1079 retval = MPI_ERR_COUNT;
1080 } else if (datatype == MPI_DATATYPE_NULL){
1081 retval = MPI_ERR_TYPE;
1082 } else if(tag<0 && tag != MPI_ANY_TAG){
1083 retval = MPI_ERR_TAG;
1087 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1088 TRACE_smpi_computing_out(rank);
1089 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1090 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1091 TRACE_smpi_send(rank, rank, dst_traced);
1094 *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm);
1095 retval = MPI_SUCCESS;
1098 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1099 (*request)->send = 1;
1100 TRACE_smpi_computing_in(rank);
1108 int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) {
1112 if (request == NULL) {
1113 retval = MPI_ERR_ARG;
1114 } else if (comm == MPI_COMM_NULL) {
1115 retval = MPI_ERR_COMM;
1116 } else if (dst == MPI_PROC_NULL) {
1117 *request = MPI_REQUEST_NULL;
1118 retval = MPI_SUCCESS;
1119 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1120 retval = MPI_ERR_RANK;
1121 } else if (count < 0) {
1122 retval = MPI_ERR_COUNT;
1123 } else if (buf==NULL && count > 0) {
1124 retval = MPI_ERR_COUNT;
1125 } else if (datatype == MPI_DATATYPE_NULL){
1126 retval = MPI_ERR_TYPE;
1127 } else if(tag<0 && tag != MPI_ANY_TAG){
1128 retval = MPI_ERR_TAG;
1132 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1133 TRACE_smpi_computing_out(rank);
1134 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1135 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1136 TRACE_smpi_send(rank, rank, dst_traced);
1139 *request = smpi_mpi_issend(buf, count, datatype, dst, tag, comm);
1140 retval = MPI_SUCCESS;
1143 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1144 (*request)->send = 1;
1145 TRACE_smpi_computing_in(rank);
1153 int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
1154 MPI_Comm comm, MPI_Status * status)
1159 if (comm == MPI_COMM_NULL) {
1160 retval = MPI_ERR_COMM;
1161 } else if (src == MPI_PROC_NULL) {
1162 smpi_empty_status(status);
1163 status->MPI_SOURCE = MPI_PROC_NULL;
1164 retval = MPI_SUCCESS;
1165 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
1166 retval = MPI_ERR_RANK;
1167 } else if (count < 0) {
1168 retval = MPI_ERR_COUNT;
1169 } else if (buf==NULL && count > 0) {
1170 retval = MPI_ERR_COUNT;
1171 } else if (datatype == MPI_DATATYPE_NULL){
1172 retval = MPI_ERR_TYPE;
1173 } else if(tag<0 && tag != MPI_ANY_TAG){
1174 retval = MPI_ERR_TAG;
1177 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1178 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1179 TRACE_smpi_computing_out(rank);
1181 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
1184 smpi_mpi_recv(buf, count, datatype, src, tag, comm, status);
1185 retval = MPI_SUCCESS;
1188 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1189 if(status!=MPI_STATUS_IGNORE)src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
1190 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1191 TRACE_smpi_recv(rank, src_traced, rank);
1192 TRACE_smpi_computing_in(rank);
1200 int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
1207 if (comm == MPI_COMM_NULL) {
1208 retval = MPI_ERR_COMM;
1209 } else if (dst == MPI_PROC_NULL) {
1210 retval = MPI_SUCCESS;
1211 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1212 retval = MPI_ERR_RANK;
1213 } else if (count < 0) {
1214 retval = MPI_ERR_COUNT;
1215 } else if (buf==NULL && count > 0) {
1216 retval = MPI_ERR_COUNT;
1217 } else if (datatype == MPI_DATATYPE_NULL){
1218 retval = MPI_ERR_TYPE;
1219 } else if(tag<0 && tag != MPI_ANY_TAG){
1220 retval = MPI_ERR_TAG;
1224 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1225 TRACE_smpi_computing_out(rank);
1226 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1227 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1228 TRACE_smpi_send(rank, rank, dst_traced);
1231 smpi_mpi_send(buf, count, datatype, dst, tag, comm);
1232 retval = MPI_SUCCESS;
1235 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1236 TRACE_smpi_computing_in(rank);
1246 int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
1251 if (comm == MPI_COMM_NULL) {
1252 retval = MPI_ERR_COMM;
1253 } else if (dst == MPI_PROC_NULL) {
1254 retval = MPI_SUCCESS;
1255 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1256 retval = MPI_ERR_RANK;
1257 } else if (count < 0) {
1258 retval = MPI_ERR_COUNT;
1259 } else if (buf==NULL && count > 0) {
1260 retval = MPI_ERR_COUNT;
1261 } else if (datatype == MPI_DATATYPE_NULL){
1262 retval = MPI_ERR_TYPE;
1263 } else if(tag<0 && tag != MPI_ANY_TAG){
1264 retval = MPI_ERR_TAG;
1268 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1269 TRACE_smpi_computing_out(rank);
1270 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1271 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1272 TRACE_smpi_send(rank, rank, dst_traced);
1275 smpi_mpi_ssend(buf, count, datatype, dst, tag, comm);
1276 retval = MPI_SUCCESS;
1279 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1280 TRACE_smpi_computing_in(rank);
1288 int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1289 int dst, int sendtag, void *recvbuf, int recvcount,
1290 MPI_Datatype recvtype, int src, int recvtag,
1291 MPI_Comm comm, MPI_Status * status)
1297 if (comm == MPI_COMM_NULL) {
1298 retval = MPI_ERR_COMM;
1299 } else if (sendtype == MPI_DATATYPE_NULL
1300 || recvtype == MPI_DATATYPE_NULL) {
1301 retval = MPI_ERR_TYPE;
1302 } else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
1303 smpi_empty_status(status);
1304 status->MPI_SOURCE = MPI_PROC_NULL;
1305 retval = MPI_SUCCESS;
1306 }else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0 ||
1307 (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0))){
1308 retval = MPI_ERR_RANK;
1309 } else if (sendcount < 0 || recvcount<0) {
1310 retval = MPI_ERR_COUNT;
1311 } else if ((sendbuf==NULL && sendcount > 0)||(recvbuf==NULL && recvcount>0)) {
1312 retval = MPI_ERR_COUNT;
1313 } else if((sendtag<0 && sendtag != MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){
1314 retval = MPI_ERR_TAG;
1318 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1319 TRACE_smpi_computing_out(rank);
1320 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1321 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1322 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
1323 TRACE_smpi_send(rank, rank, dst_traced);
1327 smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf,
1328 recvcount, recvtype, src, recvtag, comm, status);
1329 retval = MPI_SUCCESS;
1332 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1333 TRACE_smpi_recv(rank, src_traced, rank);
1334 TRACE_smpi_computing_in(rank);
1343 int PMPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
1344 int dst, int sendtag, int src, int recvtag,
1345 MPI_Comm comm, MPI_Status * status)
1347 //TODO: suboptimal implementation
1350 if (datatype == MPI_DATATYPE_NULL) {
1351 retval = MPI_ERR_TYPE;
1352 } else if (count < 0) {
1353 retval = MPI_ERR_COUNT;
1355 int size = smpi_datatype_get_extent(datatype) * count;
1356 recvbuf = xbt_new(char, size);
1358 MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
1359 datatype, src, recvtag, comm, status);
1360 if(retval==MPI_SUCCESS){
1361 smpi_datatype_copy(recvbuf, count, datatype, buf, count, datatype);
1369 int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
1374 if (request == MPI_REQUEST_NULL || flag == NULL) {
1375 retval = MPI_ERR_ARG;
1376 } else if (*request == MPI_REQUEST_NULL) {
1378 retval = MPI_ERR_REQUEST;
1380 *flag = smpi_mpi_test(request, status);
1381 retval = MPI_SUCCESS;
1387 int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
1388 MPI_Status * status)
1393 if (index == NULL || flag == NULL) {
1394 retval = MPI_ERR_ARG;
1396 *flag = smpi_mpi_testany(count, requests, index, status);
1397 retval = MPI_SUCCESS;
1403 int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses)
1409 retval = MPI_ERR_ARG;
1411 *flag = smpi_mpi_testall(count, requests, statuses);
1412 retval = MPI_SUCCESS;
1418 int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) {
1422 if (status == NULL) {
1423 retval = MPI_ERR_ARG;
1424 } else if (comm == MPI_COMM_NULL) {
1425 retval = MPI_ERR_COMM;
1426 } else if (source == MPI_PROC_NULL) {
1427 smpi_empty_status(status);
1428 status->MPI_SOURCE = MPI_PROC_NULL;
1429 retval = MPI_SUCCESS;
1431 smpi_mpi_probe(source, tag, comm, status);
1432 retval = MPI_SUCCESS;
1439 int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status) {
1444 retval = MPI_ERR_ARG;
1445 } else if (status == NULL) {
1446 retval = MPI_ERR_ARG;
1447 } else if (comm == MPI_COMM_NULL) {
1448 retval = MPI_ERR_COMM;
1449 } else if (source == MPI_PROC_NULL) {
1451 smpi_empty_status(status);
1452 status->MPI_SOURCE = MPI_PROC_NULL;
1453 retval = MPI_SUCCESS;
1455 smpi_mpi_iprobe(source, tag, comm, flag, status);
1456 retval = MPI_SUCCESS;
1462 int PMPI_Wait(MPI_Request * request, MPI_Status * status)
1468 if (request == NULL) {
1469 retval = MPI_ERR_ARG;
1470 } else if (*request == MPI_REQUEST_NULL) {
1471 retval = MPI_ERR_REQUEST;
1475 int rank = request && (*request)->comm != MPI_COMM_NULL
1476 ? smpi_process_index()
1478 TRACE_smpi_computing_out(rank);
1480 int src_traced = (*request)->src;
1481 int dst_traced = (*request)->dst;
1482 int is_wait_for_receive = (*request)->recv;
1483 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
1486 smpi_mpi_wait(request, status);
1487 retval = MPI_SUCCESS;
1490 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1491 if (is_wait_for_receive) {
1492 TRACE_smpi_recv(rank, src_traced, dst_traced);
1494 TRACE_smpi_computing_in(rank);
1503 int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * status)
1509 //save requests information for tracing
1511 int *srcs = xbt_new(int, count);
1512 int *dsts = xbt_new(int, count);
1513 int *recvs = xbt_new(int, count);
1514 for (i = 0; i < count; i++) {
1515 MPI_Request req = requests[i]; //already received requests are no longer valid
1519 recvs[i] = req->recv;
1522 int rank_traced = smpi_process_index();
1523 TRACE_smpi_computing_out(rank_traced);
1525 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
1528 if (index == NULL) {
1529 retval = MPI_ERR_ARG;
1531 *index = smpi_mpi_waitany(count, requests, status);
1532 retval = MPI_SUCCESS;
1535 if(*index!=MPI_UNDEFINED){
1536 int src_traced = srcs[*index];
1537 int dst_traced = dsts[*index];
1538 int is_wait_for_receive = recvs[*index];
1539 if (is_wait_for_receive) {
1540 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1542 TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__);
1547 TRACE_smpi_computing_in(rank_traced);
1553 int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
1558 //save information from requests
1560 int *srcs = xbt_new(int, count);
1561 int *dsts = xbt_new(int, count);
1562 int *recvs = xbt_new(int, count);
1563 int valid_count = 0;
1564 for (i = 0; i < count; i++) {
1565 MPI_Request req = requests[i];
1566 if(req!=MPI_REQUEST_NULL){
1567 srcs[valid_count] = req->src;
1568 dsts[valid_count] = req->dst;
1569 recvs[valid_count] = req->recv;
1573 int rank_traced = smpi_process_index();
1574 TRACE_smpi_computing_out(rank_traced);
1576 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
1578 int retval = smpi_mpi_waitall(count, requests, status);
1580 for (i = 0; i < valid_count; i++) {
1581 int src_traced = srcs[i];
1582 int dst_traced = dsts[i];
1583 int is_wait_for_receive = recvs[i];
1584 if (is_wait_for_receive) {
1585 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1588 TRACE_smpi_ptp_out(rank_traced, -1, -1, __FUNCTION__);
1592 TRACE_smpi_computing_in(rank_traced);
1598 int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
1599 int *indices, MPI_Status status[])
1604 if (outcount == NULL) {
1605 retval = MPI_ERR_ARG;
1607 *outcount = smpi_mpi_waitsome(incount, requests, indices, status);
1608 retval = MPI_SUCCESS;
1614 int PMPI_Testsome(int incount, MPI_Request requests[], int* outcount,
1615 int* indices, MPI_Status status[])
1620 if (outcount == NULL) {
1621 retval = MPI_ERR_ARG;
1623 *outcount = smpi_mpi_testsome(incount, requests, indices, status);
1624 retval = MPI_SUCCESS;
1631 int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
1637 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1638 TRACE_smpi_computing_out(rank);
1639 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1640 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1642 if (comm == MPI_COMM_NULL) {
1643 retval = MPI_ERR_COMM;
1645 mpi_coll_bcast_fun(buf, count, datatype, root, comm);
1646 retval = MPI_SUCCESS;
1649 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1650 TRACE_smpi_computing_in(rank);
1656 int PMPI_Barrier(MPI_Comm comm)
1662 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1663 TRACE_smpi_computing_out(rank);
1664 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1666 if (comm == MPI_COMM_NULL) {
1667 retval = MPI_ERR_COMM;
1669 mpi_coll_barrier_fun(comm);
1670 retval = MPI_SUCCESS;
1673 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1674 TRACE_smpi_computing_in(rank);
1680 int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1681 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1682 int root, MPI_Comm comm)
1688 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1689 TRACE_smpi_computing_out(rank);
1690 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1691 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1693 if (comm == MPI_COMM_NULL) {
1694 retval = MPI_ERR_COMM;
1695 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1696 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1697 retval = MPI_ERR_TYPE;
1698 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1699 ((smpi_comm_rank(comm) == root) && (recvcount <0))){
1700 retval = MPI_ERR_COUNT;
1703 char* sendtmpbuf = (char*) sendbuf;
1704 int sendtmpcount = sendcount;
1705 MPI_Datatype sendtmptype = sendtype;
1706 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1708 sendtmptype=recvtype;
1711 mpi_coll_gather_fun(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcount,
1712 recvtype, root, comm);
1715 retval = MPI_SUCCESS;
1718 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1719 TRACE_smpi_computing_in(rank);
1725 int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1726 void *recvbuf, int *recvcounts, int *displs,
1727 MPI_Datatype recvtype, int root, MPI_Comm comm)
1733 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1734 TRACE_smpi_computing_out(rank);
1735 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1736 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1738 if (comm == MPI_COMM_NULL) {
1739 retval = MPI_ERR_COMM;
1740 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1741 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1742 retval = MPI_ERR_TYPE;
1743 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1744 retval = MPI_ERR_COUNT;
1745 } else if (recvcounts == NULL || displs == NULL) {
1746 retval = MPI_ERR_ARG;
1749 char* sendtmpbuf = (char*) sendbuf;
1750 int sendtmpcount = sendcount;
1751 MPI_Datatype sendtmptype = sendtype;
1752 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1754 sendtmptype=recvtype;
1757 smpi_mpi_gatherv(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcounts,
1758 displs, recvtype, root, comm);
1759 retval = MPI_SUCCESS;
1762 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1763 TRACE_smpi_computing_in(rank);
1769 int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1770 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1777 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1778 TRACE_smpi_computing_out(rank);
1779 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1781 if (comm == MPI_COMM_NULL) {
1782 retval = MPI_ERR_COMM;
1783 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1784 (recvtype == MPI_DATATYPE_NULL)){
1785 retval = MPI_ERR_TYPE;
1786 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1788 retval = MPI_ERR_COUNT;
1791 if(sendbuf == MPI_IN_PLACE) {
1792 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*recvcount*smpi_comm_rank(comm);
1793 sendcount=recvcount;
1797 mpi_coll_allgather_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1799 retval = MPI_SUCCESS;
1802 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1808 int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1809 void *recvbuf, int *recvcounts, int *displs,
1810 MPI_Datatype recvtype, MPI_Comm comm)
1816 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1817 TRACE_smpi_computing_out(rank);
1818 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1820 if (comm == MPI_COMM_NULL) {
1821 retval = MPI_ERR_COMM;
1822 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1823 (recvtype == MPI_DATATYPE_NULL)){
1824 retval = MPI_ERR_TYPE;
1825 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1826 retval = MPI_ERR_COUNT;
1827 } else if (recvcounts == NULL || displs == NULL) {
1828 retval = MPI_ERR_ARG;
1831 if(sendbuf == MPI_IN_PLACE) {
1832 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*displs[smpi_comm_rank(comm)];
1833 sendcount=recvcounts[smpi_comm_rank(comm)];
1837 mpi_coll_allgatherv_fun(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
1838 displs, recvtype, comm);
1839 retval = MPI_SUCCESS;
1842 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1843 TRACE_smpi_computing_in(rank);
1849 int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1850 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1851 int root, MPI_Comm comm)
1857 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1858 TRACE_smpi_computing_out(rank);
1859 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1861 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1863 if (comm == MPI_COMM_NULL) {
1864 retval = MPI_ERR_COMM;
1865 } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
1866 || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
1867 retval = MPI_ERR_TYPE;
1869 if (recvbuf == MPI_IN_PLACE) {
1871 recvcount=sendcount;
1873 mpi_coll_scatter_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1874 recvtype, root, comm);
1875 retval = MPI_SUCCESS;
1878 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1879 TRACE_smpi_computing_in(rank);
1885 int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
1886 MPI_Datatype sendtype, void *recvbuf, int recvcount,
1887 MPI_Datatype recvtype, int root, MPI_Comm comm)
1893 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1894 TRACE_smpi_computing_out(rank);
1895 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1896 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1898 if (comm == MPI_COMM_NULL) {
1899 retval = MPI_ERR_COMM;
1900 } else if (sendcounts == NULL || displs == NULL) {
1901 retval = MPI_ERR_ARG;
1902 } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
1903 || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
1904 retval = MPI_ERR_TYPE;
1906 if (recvbuf == MPI_IN_PLACE) {
1908 recvcount=sendcounts[smpi_comm_rank(comm)];
1910 smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
1911 recvcount, recvtype, root, comm);
1912 retval = MPI_SUCCESS;
1915 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1916 TRACE_smpi_computing_in(rank);
1922 int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
1923 MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
1929 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1930 TRACE_smpi_computing_out(rank);
1931 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1932 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1934 if (comm == MPI_COMM_NULL) {
1935 retval = MPI_ERR_COMM;
1936 } else if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
1937 retval = MPI_ERR_ARG;
1940 mpi_coll_reduce_fun(sendbuf, recvbuf, count, datatype, op, root, comm);
1942 retval = MPI_SUCCESS;
1945 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1946 TRACE_smpi_computing_in(rank);
1952 int PMPI_Reduce_local(void *inbuf, void *inoutbuf, int count,
1953 MPI_Datatype datatype, MPI_Op op){
1957 if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
1958 retval = MPI_ERR_ARG;
1960 smpi_op_apply(op, inbuf, inoutbuf, &count, &datatype);
1967 int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
1968 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
1974 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1975 TRACE_smpi_computing_out(rank);
1976 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1978 if (comm == MPI_COMM_NULL) {
1979 retval = MPI_ERR_COMM;
1980 } else if (datatype == MPI_DATATYPE_NULL) {
1981 retval = MPI_ERR_TYPE;
1982 } else if (op == MPI_OP_NULL) {
1983 retval = MPI_ERR_OP;
1986 char* sendtmpbuf = (char*) sendbuf;
1987 if( sendbuf == MPI_IN_PLACE ) {
1988 sendtmpbuf = (char *)xbt_malloc(count*smpi_datatype_get_extent(datatype));
1989 smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
1992 mpi_coll_allreduce_fun(sendtmpbuf, recvbuf, count, datatype, op, comm);
1994 if( sendbuf == MPI_IN_PLACE ) {
1995 xbt_free(sendtmpbuf);
1998 retval = MPI_SUCCESS;
2002 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2003 TRACE_smpi_computing_in(rank);
2009 int PMPI_Scan(void *sendbuf, void *recvbuf, int count,
2010 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2016 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2017 TRACE_smpi_computing_out(rank);
2018 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2020 if (comm == MPI_COMM_NULL) {
2021 retval = MPI_ERR_COMM;
2022 } else if (datatype == MPI_DATATYPE_NULL) {
2023 retval = MPI_ERR_TYPE;
2024 } else if (op == MPI_OP_NULL) {
2025 retval = MPI_ERR_OP;
2027 smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm);
2028 retval = MPI_SUCCESS;
2031 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2032 TRACE_smpi_computing_in(rank);
2038 int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
2039 MPI_Op op, MPI_Comm comm){
2044 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2045 TRACE_smpi_computing_out(rank);
2046 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2048 if (comm == MPI_COMM_NULL) {
2049 retval = MPI_ERR_COMM;
2050 } else if (datatype == MPI_DATATYPE_NULL) {
2051 retval = MPI_ERR_TYPE;
2052 } else if (op == MPI_OP_NULL) {
2053 retval = MPI_ERR_OP;
2055 smpi_mpi_exscan(sendbuf, recvbuf, count, datatype, op, comm);
2056 retval = MPI_SUCCESS;
2059 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2060 TRACE_smpi_computing_in(rank);
2066 int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
2067 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2072 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2073 TRACE_smpi_computing_out(rank);
2074 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2076 if (comm == MPI_COMM_NULL) {
2077 retval = MPI_ERR_COMM;
2078 } else if (datatype == MPI_DATATYPE_NULL) {
2079 retval = MPI_ERR_TYPE;
2080 } else if (op == MPI_OP_NULL) {
2081 retval = MPI_ERR_OP;
2082 } else if (recvcounts == NULL) {
2083 retval = MPI_ERR_ARG;
2085 void* sendtmpbuf=sendbuf;
2086 if(sendbuf==MPI_IN_PLACE){
2090 mpi_coll_reduce_scatter_fun(sendtmpbuf, recvbuf, recvcounts,
2091 datatype, op, comm);
2092 retval = MPI_SUCCESS;
2095 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2096 TRACE_smpi_computing_in(rank);
2102 int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
2103 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2108 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2109 TRACE_smpi_computing_out(rank);
2110 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2112 if (comm == MPI_COMM_NULL) {
2113 retval = MPI_ERR_COMM;
2114 } else if (datatype == MPI_DATATYPE_NULL) {
2115 retval = MPI_ERR_TYPE;
2116 } else if (op == MPI_OP_NULL) {
2117 retval = MPI_ERR_OP;
2118 } else if (recvcount < 0) {
2119 retval = MPI_ERR_ARG;
2121 int count=smpi_comm_size(comm);
2122 int* recvcounts=(int*)xbt_malloc(count);
2123 for (i=0; i<count;i++)recvcounts[i]=recvcount;
2124 mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts,
2125 datatype, op, comm);
2126 xbt_free(recvcounts);
2127 retval = MPI_SUCCESS;
2130 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2131 TRACE_smpi_computing_in(rank);
2137 int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
2138 void *recvbuf, int recvcount, MPI_Datatype recvtype,
2145 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2146 TRACE_smpi_computing_out(rank);
2147 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2149 if (comm == MPI_COMM_NULL) {
2150 retval = MPI_ERR_COMM;
2151 } else if (sendtype == MPI_DATATYPE_NULL
2152 || recvtype == MPI_DATATYPE_NULL) {
2153 retval = MPI_ERR_TYPE;
2155 retval = mpi_coll_alltoall_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
2158 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2159 TRACE_smpi_computing_in(rank);
2165 int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
2166 MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
2167 int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
2173 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2174 TRACE_smpi_computing_out(rank);
2175 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2177 if (comm == MPI_COMM_NULL) {
2178 retval = MPI_ERR_COMM;
2179 } else if (sendtype == MPI_DATATYPE_NULL
2180 || recvtype == MPI_DATATYPE_NULL) {
2181 retval = MPI_ERR_TYPE;
2182 } else if (sendcounts == NULL || senddisps == NULL || recvcounts == NULL
2183 || recvdisps == NULL) {
2184 retval = MPI_ERR_ARG;
2187 mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, sendtype,
2188 recvbuf, recvcounts, recvdisps, recvtype,
2192 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2193 TRACE_smpi_computing_in(rank);
2200 int PMPI_Get_processor_name(char *name, int *resultlen)
2202 int retval = MPI_SUCCESS;
2205 strncpy(name, SIMIX_host_get_name(SIMIX_host_self()),
2206 strlen(SIMIX_host_get_name(SIMIX_host_self())) < MPI_MAX_PROCESSOR_NAME - 1 ?
2207 strlen(SIMIX_host_get_name(SIMIX_host_self())) +1 :
2208 MPI_MAX_PROCESSOR_NAME - 1 );
2211 MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
2217 int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
2219 int retval = MPI_SUCCESS;
2223 if (status == NULL || count == NULL) {
2224 retval = MPI_ERR_ARG;
2225 } else if (datatype == MPI_DATATYPE_NULL) {
2226 retval = MPI_ERR_TYPE;
2228 size = smpi_datatype_size(datatype);
2231 } else if (status->count % size != 0) {
2232 retval = MPI_UNDEFINED;
2234 *count = smpi_mpi_get_count(status, datatype);
2241 int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type) {
2245 if (old_type == MPI_DATATYPE_NULL) {
2246 retval = MPI_ERR_TYPE;
2247 } else if (count<0){
2248 retval = MPI_ERR_COUNT;
2250 retval = smpi_datatype_contiguous(count, old_type, new_type, 0);
2256 int PMPI_Type_commit(MPI_Datatype* datatype) {
2260 if (datatype == MPI_DATATYPE_NULL) {
2261 retval = MPI_ERR_TYPE;
2263 smpi_datatype_commit(datatype);
2264 retval = MPI_SUCCESS;
2271 int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2275 if (old_type == MPI_DATATYPE_NULL) {
2276 retval = MPI_ERR_TYPE;
2277 } else if (count<0 || blocklen<0){
2278 retval = MPI_ERR_COUNT;
2280 retval = smpi_datatype_vector(count, blocklen, stride, old_type, new_type);
2286 int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2290 if (old_type == MPI_DATATYPE_NULL) {
2291 retval = MPI_ERR_TYPE;
2292 } else if (count<0 || blocklen<0){
2293 retval = MPI_ERR_COUNT;
2295 retval = smpi_datatype_hvector(count, blocklen, stride, old_type, new_type);
2301 int PMPI_Type_create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2302 return MPI_Type_hvector(count, blocklen, stride, old_type, new_type);
2305 int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2309 if (old_type == MPI_DATATYPE_NULL) {
2310 retval = MPI_ERR_TYPE;
2311 } else if (count<0){
2312 retval = MPI_ERR_COUNT;
2314 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2320 int PMPI_Type_create_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2324 if (old_type == MPI_DATATYPE_NULL) {
2325 retval = MPI_ERR_TYPE;
2326 } else if (count<0){
2327 retval = MPI_ERR_COUNT;
2329 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2335 int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2339 if (old_type == MPI_DATATYPE_NULL) {
2340 retval = MPI_ERR_TYPE;
2341 } else if (count<0){
2342 retval = MPI_ERR_COUNT;
2344 int* blocklens=(int*)xbt_malloc(blocklength*count);
2345 for (i=0; i<count;i++)blocklens[i]=blocklength;
2346 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2347 xbt_free(blocklens);
2354 int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2358 if (old_type == MPI_DATATYPE_NULL) {
2359 retval = MPI_ERR_TYPE;
2360 } else if (count<0){
2361 retval = MPI_ERR_COUNT;
2363 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2369 int PMPI_Type_create_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2370 return PMPI_Type_hindexed(count, blocklens,indices,old_type,new_type);
2373 int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2377 if (old_type == MPI_DATATYPE_NULL) {
2378 retval = MPI_ERR_TYPE;
2379 } else if (count<0){
2380 retval = MPI_ERR_COUNT;
2382 int* blocklens=(int*)xbt_malloc(blocklength*count);
2383 for (i=0; i<count;i++)blocklens[i]=blocklength;
2384 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2385 xbt_free(blocklens);
2392 int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2397 retval = MPI_ERR_COUNT;
2399 retval = smpi_datatype_struct(count, blocklens, indices, old_types, new_type);
2405 int PMPI_Type_create_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2406 return PMPI_Type_struct(count, blocklens, indices, old_types, new_type);
2410 int PMPI_Error_class(int errorcode, int* errorclass) {
2411 // assume smpi uses only standard mpi error codes
2412 *errorclass=errorcode;
2417 int PMPI_Initialized(int* flag) {
2418 *flag=smpi_process_initialized();
2422 /* The following calls are not yet implemented and will fail at runtime. */
2423 /* Once implemented, please move them above this notice. */
2425 #define NOT_YET_IMPLEMENTED {\
2426 XBT_WARN("Not yet implemented : %s. Please contact the Simgrid team if support is needed", __FUNCTION__);\
2427 return MPI_SUCCESS;\
2431 int PMPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype){
2435 int PMPI_Type_set_name(MPI_Datatype datatype, char * name)
2440 int PMPI_Type_get_name(MPI_Datatype datatype, char * name, int* len)
2445 int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
2449 int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) {
2453 int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periods, int reorder, MPI_Comm* comm_cart) {
2457 int PMPI_Cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) {
2461 int PMPI_Cart_map(MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank) {
2465 int PMPI_Cart_rank(MPI_Comm comm, int* coords, int* rank) {
2469 int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* dest) {
2473 int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
2477 int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) {
2481 int PMPI_Graph_create(MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder, MPI_Comm* comm_graph) {
2485 int PMPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int* index, int* edges) {
2489 int PMPI_Graph_map(MPI_Comm comm_old, int nnodes, int* index, int* edges, int* newrank) {
2493 int PMPI_Graph_neighbors(MPI_Comm comm, int rank, int maxneighbors, int* neighbors) {
2497 int PMPI_Graph_neighbors_count(MPI_Comm comm, int rank, int* nneighbors) {
2501 int PMPI_Graphdims_get(MPI_Comm comm, int* nnodes, int* nedges) {
2505 int PMPI_Topo_test(MPI_Comm comm, int* top_type) {
2509 int PMPI_Errhandler_create(MPI_Handler_function* function, MPI_Errhandler* errhandler) {
2513 int PMPI_Errhandler_free(MPI_Errhandler* errhandler) {
2517 int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler* errhandler) {
2521 int PMPI_Error_string(int errorcode, char* string, int* resultlen) {
2525 int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler) {
2529 int PMPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler) {
2533 int PMPI_Cancel(MPI_Request* request) {
2537 int PMPI_Buffer_attach(void* buffer, int size) {
2541 int PMPI_Buffer_detach(void* buffer, int* size) {
2545 int PMPI_Comm_test_inter(MPI_Comm comm, int* flag) {
2549 int PMPI_Comm_get_attr (MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag)
2554 int PMPI_Comm_set_attr (MPI_Comm comm, int comm_keyval, void *attribute_val)
2559 int PMPI_Comm_delete_attr (MPI_Comm comm, int comm_keyval)
2564 int PMPI_Comm_create_keyval(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state)
2569 int PMPI_Comm_free_keyval(int* keyval) {
2573 int PMPI_Pcontrol(const int level )
2578 int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
2582 int PMPI_Type_get_attr (MPI_Datatype type, int type_keyval, void *attribute_val, int* flag)
2587 int PMPI_Type_set_attr (MPI_Datatype type, int type_keyval, void *attribute_val)
2592 int PMPI_Type_delete_attr (MPI_Datatype type, int comm_keyval)
2597 int PMPI_Type_create_keyval(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state)
2602 int PMPI_Type_free_keyval(int* keyval) {
2606 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
2610 int PMPI_Intercomm_merge(MPI_Comm comm, int high, MPI_Comm* comm_out) {
2614 int PMPI_Bsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2618 int PMPI_Bsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2622 int PMPI_Ibsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2626 int PMPI_Comm_remote_group(MPI_Comm comm, MPI_Group* group) {
2630 int PMPI_Comm_remote_size(MPI_Comm comm, int* size) {
2634 int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
2638 int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) {
2642 int PMPI_Attr_put(MPI_Comm comm, int keyval, void* attr_value) {
2646 int PMPI_Rsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2650 int PMPI_Rsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2654 int PMPI_Irsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2658 int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
2662 int PMPI_Keyval_free(int* keyval) {
2666 int PMPI_Test_cancelled(MPI_Status* status, int* flag) {
2670 int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
2674 int PMPI_Pack_external_size(char *datarep, int incount, MPI_Datatype datatype, MPI_Aint *size){
2678 int PMPI_Pack_external(char *datarep, void *inbuf, int incount, MPI_Datatype datatype, void *outbuf, MPI_Aint outcount, MPI_Aint *position){
2682 int PMPI_Unpack_external( char *datarep, void *inbuf, MPI_Aint insize, MPI_Aint *position, void *outbuf, int outcount, MPI_Datatype datatype){
2686 int PMPI_Get_elements(MPI_Status* status, MPI_Datatype datatype, int* elements) {
2690 int PMPI_Dims_create(int nnodes, int ndims, int* dims) {
2694 int PMPI_Win_fence( int assert, MPI_Win win){
2698 int PMPI_Win_free( MPI_Win* win){
2702 int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win){
2706 int PMPI_Info_create( MPI_Info *info){
2710 int PMPI_Info_set( MPI_Info info, char *key, char *value){
2714 int PMPI_Info_free( MPI_Info *info){
2718 int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2719 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
2723 int PMPI_Type_get_envelope( MPI_Datatype datatype, int *num_integers,
2724 int *num_addresses, int *num_datatypes, int *combiner){
2728 int PMPI_Type_get_contents(MPI_Datatype datatype, int max_integers, int max_addresses,
2729 int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses,
2730 MPI_Datatype* array_of_datatypes){
2734 int PMPI_Type_create_darray(int size, int rank, int ndims, int* array_of_gsizes,
2735 int* array_of_distribs, int* array_of_dargs, int* array_of_psizes,
2736 int order, MPI_Datatype oldtype, MPI_Datatype *newtype) {
2740 int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype){
2744 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){
2748 int PMPI_Type_match_size(int typeclass,int size,MPI_Datatype *datatype){
2752 int PMPI_Alltoallw( void *sendbuf, int *sendcnts, int *sdispls, MPI_Datatype *sendtypes,
2753 void *recvbuf, int *recvcnts, int *rdispls, MPI_Datatype *recvtypes,
2758 int PMPI_Comm_set_name(MPI_Comm comm, char* name){
2762 int PMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm * newcomm){
2766 int PMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm){
2770 int PMPI_Comm_set_info (MPI_Comm comm, MPI_Info info){
2774 int PMPI_Comm_get_info (MPI_Comm comm, MPI_Info* info){
2778 int PMPI_Info_get(MPI_Info info,char *key,int valuelen, char *value, int *flag){
2782 int PMPI_Comm_create_errhandler( MPI_Comm_errhandler_fn *function, MPI_Errhandler *errhandler){
2786 int PMPI_Add_error_class( int *errorclass){
2790 int PMPI_Add_error_code( int errorclass, int *errorcode){
2794 int PMPI_Add_error_string( int errorcode, char *string){
2798 int PMPI_Comm_call_errhandler(MPI_Comm comm,int errorcode){
2802 int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo){
2806 int PMPI_Info_delete(MPI_Info info, char *key){
2810 int PMPI_Info_get_nkeys( MPI_Info info, int *nkeys){
2814 int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){
2818 int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){
2822 int PMPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){
2826 int MPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){
2830 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){
2834 int PMPI_Grequest_complete( MPI_Request request){
2838 int PMPI_Status_set_cancelled(MPI_Status *status,int flag){
2842 int PMPI_Status_set_elements( MPI_Status *status, MPI_Datatype datatype, int count){
2846 int PMPI_Comm_connect( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
2850 int PMPI_Publish_name( char *service_name, MPI_Info info, char *port_name){
2854 int PMPI_Unpublish_name( char *service_name, MPI_Info info, char *port_name){
2858 int PMPI_Lookup_name( char *service_name, MPI_Info info, char *port_name){
2862 int PMPI_Comm_join( int fd, MPI_Comm *intercomm){
2866 int PMPI_Open_port( MPI_Info info, char *port_name){
2870 int PMPI_Close_port(char *port_name){
2874 int PMPI_Comm_accept( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
2878 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){
2882 int PMPI_Comm_spawn_multiple( int count, char **array_of_commands, char*** array_of_argv,
2883 int* array_of_maxprocs, MPI_Info* array_of_info, int root,
2884 MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes){
2888 int PMPI_Comm_get_parent( MPI_Comm *parent){