2 /* Copyright (c) 2007-2014. The SimGrid Team.
3 * All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #include "smpi_mpi_dt_private.h"
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_pmpi, smpi,
12 "Logging specific to SMPI (pmpi)");
15 //this function need to be here because of the calls to smpi_bench
16 void TRACE_smpi_set_category(const char *category)
18 //need to end bench otherwise categories for execution tasks are wrong
20 TRACE_internal_smpi_set_category (category);
21 //begin bench after changing process's category
26 /* PMPI User level calls */
28 int PMPI_Init(int *argc, char ***argv)
30 smpi_process_init(argc, argv);
31 smpi_process_mark_as_initialized();
33 int rank = smpi_process_index();
34 TRACE_smpi_init(rank);
35 TRACE_smpi_computing_init(rank);
36 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
37 extra->type = TRACING_INIT;
38 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
39 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
45 int PMPI_Finalize(void)
49 int rank = smpi_process_index();
50 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
51 extra->type = TRACING_FINALIZE;
52 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
54 smpi_process_finalize();
56 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
57 TRACE_smpi_finalize(smpi_process_index());
59 smpi_process_destroy();
63 int PMPI_Finalized(int* flag)
65 *flag=smpi_process_finalized();
69 int PMPI_Get_version (int *version,int *subversion){
70 *version = MPI_VERSION;
71 *subversion= MPI_SUBVERSION;
75 int PMPI_Get_library_version (char *version,int *len){
76 int retval = MPI_SUCCESS;
78 snprintf(version,MPI_MAX_LIBRARY_VERSION_STRING,"SMPI Version %d.%d. Copyright The Simgrid Team 2007-2014",SIMGRID_VERSION_MAJOR,
79 SIMGRID_VERSION_MINOR);
80 *len = strlen(version) > MPI_MAX_LIBRARY_VERSION_STRING ? MPI_MAX_LIBRARY_VERSION_STRING : strlen(version);
85 int PMPI_Init_thread(int *argc, char ***argv, int required, int *provided)
87 if (provided != NULL) {
88 *provided = MPI_THREAD_MULTIPLE;
90 return MPI_Init(argc, argv);
93 int PMPI_Query_thread(int *provided)
97 if (provided == NULL) {
100 *provided = MPI_THREAD_MULTIPLE;
101 retval = MPI_SUCCESS;
106 int PMPI_Is_thread_main(int *flag)
111 retval = MPI_ERR_ARG;
113 *flag = smpi_process_index() == 0;
114 retval = MPI_SUCCESS;
119 int PMPI_Abort(MPI_Comm comm, int errorcode)
122 smpi_process_destroy();
123 // FIXME: should kill all processes in comm instead
124 simcall_process_kill(SIMIX_process_self());
128 double PMPI_Wtime(void)
130 return smpi_mpi_wtime();
133 extern double sg_maxmin_precision;
134 double PMPI_Wtick(void)
136 return sg_maxmin_precision;
139 int PMPI_Address(void *location, MPI_Aint * address)
144 retval = MPI_ERR_ARG;
146 *address = (MPI_Aint) location;
147 retval = MPI_SUCCESS;
152 int PMPI_Get_address(void *location, MPI_Aint * address)
154 return PMPI_Address(location, address);
157 int PMPI_Type_free(MPI_Datatype * datatype)
160 /* Free a predefined datatype is an error according to the standard, and
161 should be checked for */
162 if (*datatype == MPI_DATATYPE_NULL) {
163 retval = MPI_ERR_ARG;
165 smpi_datatype_free(datatype);
166 retval = MPI_SUCCESS;
171 int PMPI_Type_size(MPI_Datatype datatype, int *size)
175 if (datatype == MPI_DATATYPE_NULL) {
176 retval = MPI_ERR_TYPE;
177 } else if (size == NULL) {
178 retval = MPI_ERR_ARG;
180 *size = (int) smpi_datatype_size(datatype);
181 retval = MPI_SUCCESS;
186 int PMPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
190 if (datatype == MPI_DATATYPE_NULL) {
191 retval = MPI_ERR_TYPE;
192 } else if (lb == NULL || extent == NULL) {
193 retval = MPI_ERR_ARG;
195 retval = smpi_datatype_extent(datatype, lb, extent);
200 int PMPI_Type_get_true_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
202 return PMPI_Type_get_extent(datatype, lb, extent);
205 int PMPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent)
209 if (datatype == MPI_DATATYPE_NULL) {
210 retval = MPI_ERR_TYPE;
211 } else if (extent == NULL) {
212 retval = MPI_ERR_ARG;
214 *extent = smpi_datatype_get_extent(datatype);
215 retval = MPI_SUCCESS;
220 int PMPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp)
224 if (datatype == MPI_DATATYPE_NULL) {
225 retval = MPI_ERR_TYPE;
226 } else if (disp == NULL) {
227 retval = MPI_ERR_ARG;
229 *disp = smpi_datatype_lb(datatype);
230 retval = MPI_SUCCESS;
235 int PMPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp)
239 if (datatype == MPI_DATATYPE_NULL) {
240 retval = MPI_ERR_TYPE;
241 } else if (disp == NULL) {
242 retval = MPI_ERR_ARG;
244 *disp = smpi_datatype_ub(datatype);
245 retval = MPI_SUCCESS;
250 int PMPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype){
253 if (datatype == MPI_DATATYPE_NULL) {
254 retval = MPI_ERR_TYPE;
256 *newtype = smpi_datatype_dup(datatype);
257 retval = MPI_SUCCESS;
262 int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
266 if (function == NULL || op == NULL) {
267 retval = MPI_ERR_ARG;
269 *op = smpi_op_new(function, commute);
270 retval = MPI_SUCCESS;
275 int PMPI_Op_free(MPI_Op * op)
280 retval = MPI_ERR_ARG;
281 } else if (*op == MPI_OP_NULL) {
284 smpi_op_destroy(*op);
286 retval = MPI_SUCCESS;
291 int PMPI_Group_free(MPI_Group * group)
296 retval = MPI_ERR_ARG;
298 smpi_group_destroy(*group);
299 *group = MPI_GROUP_NULL;
300 retval = MPI_SUCCESS;
305 int PMPI_Group_size(MPI_Group group, int *size)
309 if (group == MPI_GROUP_NULL) {
310 retval = MPI_ERR_GROUP;
311 } else if (size == NULL) {
312 retval = MPI_ERR_ARG;
314 *size = smpi_group_size(group);
315 retval = MPI_SUCCESS;
320 int PMPI_Group_rank(MPI_Group group, int *rank)
324 if (group == MPI_GROUP_NULL) {
325 retval = MPI_ERR_GROUP;
326 } else if (rank == NULL) {
327 retval = MPI_ERR_ARG;
329 *rank = smpi_group_rank(group, smpi_process_index());
330 retval = MPI_SUCCESS;
335 int PMPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
336 MPI_Group group2, int *ranks2)
338 int retval, i, index;
339 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
340 retval = MPI_ERR_GROUP;
342 for (i = 0; i < n; i++) {
343 if(ranks1[i]==MPI_PROC_NULL){
344 ranks2[i]=MPI_PROC_NULL;
346 index = smpi_group_index(group1, ranks1[i]);
347 ranks2[i] = smpi_group_rank(group2, index);
350 retval = MPI_SUCCESS;
355 int PMPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result)
359 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
360 retval = MPI_ERR_GROUP;
361 } else if (result == NULL) {
362 retval = MPI_ERR_ARG;
364 *result = smpi_group_compare(group1, group2);
365 retval = MPI_SUCCESS;
370 int PMPI_Group_union(MPI_Group group1, MPI_Group group2,
371 MPI_Group * newgroup)
373 int retval, i, proc1, proc2, size, size2;
375 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
376 retval = MPI_ERR_GROUP;
377 } else if (newgroup == NULL) {
378 retval = MPI_ERR_ARG;
380 size = smpi_group_size(group1);
381 size2 = smpi_group_size(group2);
382 for (i = 0; i < size2; i++) {
383 proc2 = smpi_group_index(group2, i);
384 proc1 = smpi_group_rank(group1, proc2);
385 if (proc1 == MPI_UNDEFINED) {
390 *newgroup = MPI_GROUP_EMPTY;
392 *newgroup = smpi_group_new(size);
393 size2 = smpi_group_size(group1);
394 for (i = 0; i < size2; i++) {
395 proc1 = smpi_group_index(group1, i);
396 smpi_group_set_mapping(*newgroup, proc1, i);
398 for (i = size2; i < size; i++) {
399 proc2 = smpi_group_index(group2, i - size2);
400 smpi_group_set_mapping(*newgroup, proc2, i);
403 retval = MPI_SUCCESS;
408 int PMPI_Group_intersection(MPI_Group group1, MPI_Group group2,
409 MPI_Group * newgroup)
411 int retval, i, proc1, proc2, size;
413 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
414 retval = MPI_ERR_GROUP;
415 } else if (newgroup == NULL) {
416 retval = MPI_ERR_ARG;
418 size = smpi_group_size(group2);
419 for (i = 0; i < size; i++) {
420 proc2 = smpi_group_index(group2, i);
421 proc1 = smpi_group_rank(group1, proc2);
422 if (proc1 == MPI_UNDEFINED) {
427 *newgroup = MPI_GROUP_EMPTY;
429 *newgroup = smpi_group_new(size);
431 for (i = 0; i < smpi_group_size(group2); i++) {
432 proc2 = smpi_group_index(group2, i);
433 proc1 = smpi_group_rank(group1, proc2);
434 if (proc1 != MPI_UNDEFINED) {
435 smpi_group_set_mapping(*newgroup, proc2, j);
440 retval = MPI_SUCCESS;
445 int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgroup)
447 int retval, i, proc1, proc2, size, size2;
449 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
450 retval = MPI_ERR_GROUP;
451 } else if (newgroup == NULL) {
452 retval = MPI_ERR_ARG;
454 size = size2 = smpi_group_size(group1);
455 for (i = 0; i < size2; i++) {
456 proc1 = smpi_group_index(group1, i);
457 proc2 = smpi_group_rank(group2, proc1);
458 if (proc2 != MPI_UNDEFINED) {
463 *newgroup = MPI_GROUP_EMPTY;
465 *newgroup = smpi_group_new(size);
466 for (i = 0; i < size2; i++) {
467 proc1 = smpi_group_index(group1, i);
468 proc2 = smpi_group_rank(group2, proc1);
469 if (proc2 == MPI_UNDEFINED) {
470 smpi_group_set_mapping(*newgroup, proc1, i);
474 retval = MPI_SUCCESS;
479 int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
483 if (group == MPI_GROUP_NULL) {
484 retval = MPI_ERR_GROUP;
485 } else if (newgroup == NULL) {
486 retval = MPI_ERR_ARG;
488 retval = smpi_group_incl(group, n, ranks, newgroup);
493 int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
495 int retval, i, j, newsize, oldsize, index;
497 if (group == MPI_GROUP_NULL) {
498 retval = MPI_ERR_GROUP;
499 } else if (newgroup == NULL) {
500 retval = MPI_ERR_ARG;
504 if(group!= smpi_comm_group(MPI_COMM_WORLD)
505 && group != MPI_GROUP_NULL
506 && group != smpi_comm_group(MPI_COMM_SELF)
507 && group != MPI_GROUP_EMPTY)
508 smpi_group_use(group);
509 } else if (n == smpi_group_size(group)) {
510 *newgroup = MPI_GROUP_EMPTY;
512 oldsize=smpi_group_size(group);
513 newsize = oldsize - n;
514 *newgroup = smpi_group_new(newsize);
516 int* to_exclude=xbt_new0(int, smpi_group_size(group));
517 for(i=0; i<oldsize; i++)
520 to_exclude[ranks[i]]=1;
523 for(i=0; i<oldsize; i++){
524 if(to_exclude[i]==0){
525 index = smpi_group_index(group, i);
526 smpi_group_set_mapping(*newgroup, index, j);
531 xbt_free(to_exclude);
533 retval = MPI_SUCCESS;
538 int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
539 MPI_Group * newgroup)
541 int retval, i, j, rank, size, index;
543 if (group == MPI_GROUP_NULL) {
544 retval = MPI_ERR_GROUP;
545 } else if (newgroup == NULL) {
546 retval = MPI_ERR_ARG;
549 *newgroup = MPI_GROUP_EMPTY;
552 for (i = 0; i < n; i++) {
553 for (rank = ranges[i][0]; /* First */
554 rank >= 0 && rank < smpi_group_size(group); /* Last */
557 if(rank == ranges[i][1]){/*already last ?*/
560 rank += ranges[i][2]; /* Stride */
561 if (ranges[i][0]<ranges[i][1]){
562 if(rank > ranges[i][1])
565 if(rank < ranges[i][1])
571 *newgroup = smpi_group_new(size);
573 for (i = 0; i < n; i++) {
574 for (rank = ranges[i][0]; /* First */
575 rank >= 0 && rank < smpi_group_size(group); /* Last */
577 index = smpi_group_index(group, rank);
578 smpi_group_set_mapping(*newgroup, index, j);
580 if(rank == ranges[i][1]){/*already last ?*/
583 rank += ranges[i][2]; /* Stride */
584 if (ranges[i][0]<ranges[i][1]){
585 if(rank > ranges[i][1])
588 if(rank < ranges[i][1])
594 retval = MPI_SUCCESS;
599 int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
600 MPI_Group * newgroup)
602 int retval, i, rank, newrank,oldrank, size, index, add;
604 if (group == MPI_GROUP_NULL) {
605 retval = MPI_ERR_GROUP;
606 } else if (newgroup == NULL) {
607 retval = MPI_ERR_ARG;
611 if(group!= smpi_comm_group(MPI_COMM_WORLD)
612 && group != MPI_GROUP_NULL
613 && group != smpi_comm_group(MPI_COMM_SELF)
614 && group != MPI_GROUP_EMPTY)
615 smpi_group_use(group);
617 size = smpi_group_size(group);
618 for (i = 0; i < n; i++) {
619 for (rank = ranges[i][0]; /* First */
620 rank >= 0 && rank < smpi_group_size(group); /* Last */
623 if(rank == ranges[i][1]){/*already last ?*/
626 rank += ranges[i][2]; /* Stride */
627 if (ranges[i][0]<ranges[i][1]){
628 if(rank > ranges[i][1])
631 if(rank < ranges[i][1])
637 *newgroup = MPI_GROUP_EMPTY;
639 *newgroup = smpi_group_new(size);
642 while (newrank < size) {
644 for (i = 0; i < n; i++) {
645 for (rank = ranges[i][0];
646 rank >= 0 && rank < smpi_group_size(group);
652 if(rank == ranges[i][1]){/*already last ?*/
655 rank += ranges[i][2]; /* Stride */
656 if (ranges[i][0]<ranges[i][1]){
657 if(rank > ranges[i][1])
660 if(rank < ranges[i][1])
666 index = smpi_group_index(group, oldrank);
667 smpi_group_set_mapping(*newgroup, index, newrank);
675 retval = MPI_SUCCESS;
680 int PMPI_Comm_rank(MPI_Comm comm, int *rank)
683 if (comm == MPI_COMM_NULL) {
684 retval = MPI_ERR_COMM;
685 } else if (rank == NULL) {
686 retval = MPI_ERR_ARG;
688 *rank = smpi_comm_rank(comm);
689 retval = MPI_SUCCESS;
694 int PMPI_Comm_size(MPI_Comm comm, int *size)
697 if (comm == MPI_COMM_NULL) {
698 retval = MPI_ERR_COMM;
699 } else if (size == NULL) {
700 retval = MPI_ERR_ARG;
702 *size = smpi_comm_size(comm);
703 retval = MPI_SUCCESS;
708 int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len)
712 if (comm == MPI_COMM_NULL) {
713 retval = MPI_ERR_COMM;
714 } else if (name == NULL || len == NULL) {
715 retval = MPI_ERR_ARG;
717 smpi_comm_get_name(comm, name, len);
718 retval = MPI_SUCCESS;
723 int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
727 if (comm == MPI_COMM_NULL) {
728 retval = MPI_ERR_COMM;
729 } else if (group == NULL) {
730 retval = MPI_ERR_ARG;
732 *group = smpi_comm_group(comm);
733 if(*group!= smpi_comm_group(MPI_COMM_WORLD)
734 && *group != MPI_GROUP_NULL
735 && *group != smpi_comm_group(MPI_COMM_SELF)
736 && *group != MPI_GROUP_EMPTY)
737 smpi_group_use(*group);
738 retval = MPI_SUCCESS;
743 int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
747 if (comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) {
748 retval = MPI_ERR_COMM;
749 } else if (result == NULL) {
750 retval = MPI_ERR_ARG;
752 if (comm1 == comm2) { /* Same communicators means same groups */
756 smpi_group_compare(smpi_comm_group(comm1),
757 smpi_comm_group(comm2));
758 if (*result == MPI_IDENT) {
759 *result = MPI_CONGRUENT;
762 retval = MPI_SUCCESS;
767 int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm)
771 if (comm == MPI_COMM_NULL) {
772 retval = MPI_ERR_COMM;
773 } else if (newcomm == NULL) {
774 retval = MPI_ERR_ARG;
776 *newcomm = smpi_comm_new(smpi_comm_group(comm), smpi_comm_topo(comm));
777 retval = MPI_SUCCESS;
782 int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
786 if (comm == MPI_COMM_NULL) {
787 retval = MPI_ERR_COMM;
788 } else if (group == MPI_GROUP_NULL) {
789 retval = MPI_ERR_GROUP;
790 } else if (newcomm == NULL) {
791 retval = MPI_ERR_ARG;
792 } else if(smpi_group_rank(group,smpi_process_index())==MPI_UNDEFINED){
793 *newcomm= MPI_COMM_NULL;
794 retval = MPI_SUCCESS;
797 *newcomm = smpi_comm_new(group, NULL);
798 retval = MPI_SUCCESS;
803 int PMPI_Comm_free(MPI_Comm * comm)
808 retval = MPI_ERR_ARG;
809 } else if (*comm == MPI_COMM_NULL) {
810 retval = MPI_ERR_COMM;
812 smpi_comm_destroy(*comm);
813 *comm = MPI_COMM_NULL;
814 retval = MPI_SUCCESS;
819 int PMPI_Comm_disconnect(MPI_Comm * comm)
821 /* TODO: wait until all communication in comm are done */
825 retval = MPI_ERR_ARG;
826 } else if (*comm == MPI_COMM_NULL) {
827 retval = MPI_ERR_COMM;
829 smpi_comm_destroy(*comm);
830 *comm = MPI_COMM_NULL;
831 retval = MPI_SUCCESS;
836 int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out)
841 if (comm_out == NULL) {
842 retval = MPI_ERR_ARG;
843 } else if (comm == MPI_COMM_NULL) {
844 retval = MPI_ERR_COMM;
846 *comm_out = smpi_comm_split(comm, color, key);
847 retval = MPI_SUCCESS;
854 int PMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst,
855 int tag, MPI_Comm comm, MPI_Request * request)
860 if (request == NULL) {
861 retval = MPI_ERR_ARG;
862 } else if (comm == MPI_COMM_NULL) {
863 retval = MPI_ERR_COMM;
864 } else if (!is_datatype_valid(datatype)) {
865 retval = MPI_ERR_TYPE;
866 } else if (dst == MPI_PROC_NULL) {
867 retval = MPI_SUCCESS;
869 *request = smpi_mpi_send_init(buf, count, datatype, dst, tag, comm);
870 retval = MPI_SUCCESS;
873 if (retval != MPI_SUCCESS && request)
874 *request = MPI_REQUEST_NULL;
878 int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src,
879 int tag, MPI_Comm comm, MPI_Request * request)
884 if (request == NULL) {
885 retval = MPI_ERR_ARG;
886 } else if (comm == MPI_COMM_NULL) {
887 retval = MPI_ERR_COMM;
888 } else if (!is_datatype_valid(datatype)) {
889 retval = MPI_ERR_TYPE;
890 } else if (src == MPI_PROC_NULL) {
891 retval = MPI_SUCCESS;
893 *request = smpi_mpi_recv_init(buf, count, datatype, src, tag, comm);
894 retval = MPI_SUCCESS;
897 if (retval != MPI_SUCCESS && request)
898 *request = MPI_REQUEST_NULL;
902 int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype,
903 int dst, int tag, MPI_Comm comm, MPI_Request* request)
908 if (request == NULL) {
909 retval = MPI_ERR_ARG;
910 } else if (comm == MPI_COMM_NULL) {
911 retval = MPI_ERR_COMM;
912 } else if (!is_datatype_valid(datatype)) {
913 retval = MPI_ERR_TYPE;
914 } else if (dst == MPI_PROC_NULL) {
915 retval = MPI_SUCCESS;
917 *request = smpi_mpi_ssend_init(buf, count, datatype, dst, tag, comm);
918 retval = MPI_SUCCESS;
921 if (retval != MPI_SUCCESS && request)
922 *request = MPI_REQUEST_NULL;
926 int PMPI_Start(MPI_Request * request)
931 if (request == NULL || *request == MPI_REQUEST_NULL) {
932 retval = MPI_ERR_REQUEST;
934 smpi_mpi_start(*request);
935 retval = MPI_SUCCESS;
941 int PMPI_Startall(int count, MPI_Request * requests)
946 if (requests == NULL) {
947 retval = MPI_ERR_ARG;
949 retval = MPI_SUCCESS;
950 for (i = 0 ; i < count ; i++) {
951 if(requests[i] == MPI_REQUEST_NULL) {
952 retval = MPI_ERR_REQUEST;
955 if(retval != MPI_ERR_REQUEST) {
956 smpi_mpi_startall(count, requests);
963 int PMPI_Request_free(MPI_Request * request)
968 if (*request == MPI_REQUEST_NULL) {
969 retval = MPI_ERR_ARG;
971 smpi_mpi_request_free(request);
972 retval = MPI_SUCCESS;
978 int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src,
979 int tag, MPI_Comm comm, MPI_Request * request)
985 if (request == NULL) {
986 retval = MPI_ERR_ARG;
987 } else if (comm == MPI_COMM_NULL) {
988 retval = MPI_ERR_COMM;
989 } else if (src == MPI_PROC_NULL) {
990 *request = MPI_REQUEST_NULL;
991 retval = MPI_SUCCESS;
992 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
993 retval = MPI_ERR_RANK;
994 } else if (count < 0) {
995 retval = MPI_ERR_COUNT;
996 } else if (buf==NULL && count > 0) {
997 retval = MPI_ERR_COUNT;
998 } else if (!is_datatype_valid(datatype)) {
999 retval = MPI_ERR_TYPE;
1000 } else if(tag<0 && tag != MPI_ANY_TAG){
1001 retval = MPI_ERR_TAG;
1005 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1006 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1008 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1009 extra->type = TRACING_IRECV;
1010 extra->send_size = count;
1011 extra->src = src_traced;
1013 extra->datatype1 = encode_datatype(datatype);
1014 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
1017 *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm);
1018 retval = MPI_SUCCESS;
1021 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1022 (*request)->recv = 1;
1027 if (retval != MPI_SUCCESS && request)
1028 *request = MPI_REQUEST_NULL;
1033 int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
1034 int tag, MPI_Comm comm, MPI_Request * request)
1039 if (request == NULL) {
1040 retval = MPI_ERR_ARG;
1041 } else if (comm == MPI_COMM_NULL) {
1042 retval = MPI_ERR_COMM;
1043 } else if (dst == MPI_PROC_NULL) {
1044 *request = MPI_REQUEST_NULL;
1045 retval = MPI_SUCCESS;
1046 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1047 retval = MPI_ERR_RANK;
1048 } else if (count < 0) {
1049 retval = MPI_ERR_COUNT;
1050 } else if (buf==NULL && count > 0) {
1051 retval = MPI_ERR_COUNT;
1052 } else if (!is_datatype_valid(datatype)) {
1053 retval = MPI_ERR_TYPE;
1054 } else if(tag<0 && tag != MPI_ANY_TAG){
1055 retval = MPI_ERR_TAG;
1059 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1060 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1062 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1063 extra->type = TRACING_ISEND;
1064 extra->send_size = count;
1066 extra->dst = dst_traced;
1067 extra->datatype1 = encode_datatype(datatype);
1068 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
1069 TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype));
1072 *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm);
1073 retval = MPI_SUCCESS;
1076 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1077 (*request)->send = 1;
1082 if (retval != MPI_SUCCESS && request)
1083 *request = MPI_REQUEST_NULL;
1087 int PMPI_Issend(void* buf, int count, MPI_Datatype datatype,
1088 int dst, int tag, MPI_Comm comm, MPI_Request* request)
1093 if (request == NULL) {
1094 retval = MPI_ERR_ARG;
1095 } else if (comm == MPI_COMM_NULL) {
1096 retval = MPI_ERR_COMM;
1097 } else if (dst == MPI_PROC_NULL) {
1098 *request = MPI_REQUEST_NULL;
1099 retval = MPI_SUCCESS;
1100 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1101 retval = MPI_ERR_RANK;
1102 } else if (count < 0) {
1103 retval = MPI_ERR_COUNT;
1104 } else if (buf==NULL && count > 0) {
1105 retval = MPI_ERR_COUNT;
1106 } else if (!is_datatype_valid(datatype)) {
1107 retval = MPI_ERR_TYPE;
1108 } else if(tag<0 && tag != MPI_ANY_TAG){
1109 retval = MPI_ERR_TAG;
1113 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1114 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1115 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1116 extra->type = TRACING_ISSEND;
1117 extra->send_size = count;
1119 extra->dst = dst_traced;
1120 extra->datatype1 = encode_datatype(datatype);
1121 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
1122 TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype));
1125 *request = smpi_mpi_issend(buf, count, datatype, dst, tag, comm);
1126 retval = MPI_SUCCESS;
1129 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1130 (*request)->send = 1;
1135 if (retval != MPI_SUCCESS && request)
1136 *request = MPI_REQUEST_NULL;
1140 int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
1141 MPI_Comm comm, MPI_Status * status)
1146 if (comm == MPI_COMM_NULL) {
1147 retval = MPI_ERR_COMM;
1148 } else if (src == MPI_PROC_NULL) {
1149 smpi_empty_status(status);
1150 status->MPI_SOURCE = MPI_PROC_NULL;
1151 retval = MPI_SUCCESS;
1152 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
1153 retval = MPI_ERR_RANK;
1154 } else if (count < 0) {
1155 retval = MPI_ERR_COUNT;
1156 } else if (buf==NULL && count > 0) {
1157 retval = MPI_ERR_COUNT;
1158 } else if (!is_datatype_valid(datatype)) {
1159 retval = MPI_ERR_TYPE;
1160 } else if(tag<0 && tag != MPI_ANY_TAG){
1161 retval = MPI_ERR_TAG;
1164 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1165 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1166 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1167 extra->type = TRACING_RECV;
1168 extra->send_size = count;
1169 extra->src = src_traced;
1171 extra->datatype1 = encode_datatype(datatype);
1172 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
1175 smpi_mpi_recv(buf, count, datatype, src, tag, comm, status);
1176 retval = MPI_SUCCESS;
1179 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1180 if(status!=MPI_STATUS_IGNORE){
1181 src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
1182 TRACE_smpi_recv(rank, src_traced, rank);
1184 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1192 int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
1199 if (comm == MPI_COMM_NULL) {
1200 retval = MPI_ERR_COMM;
1201 } else if (dst == MPI_PROC_NULL) {
1202 retval = MPI_SUCCESS;
1203 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1204 retval = MPI_ERR_RANK;
1205 } else if (count < 0) {
1206 retval = MPI_ERR_COUNT;
1207 } else if (buf==NULL && count > 0) {
1208 retval = MPI_ERR_COUNT;
1209 } else if (!is_datatype_valid(datatype)) {
1210 retval = MPI_ERR_TYPE;
1211 } else if(tag<0 && tag != MPI_ANY_TAG){
1212 retval = MPI_ERR_TAG;
1216 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1217 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1218 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1219 extra->type = TRACING_SEND;
1220 extra->send_size = count;
1222 extra->dst = dst_traced;
1223 extra->datatype1 = encode_datatype(datatype);
1224 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
1225 TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype));
1228 smpi_mpi_send(buf, count, datatype, dst, tag, comm);
1229 retval = MPI_SUCCESS;
1232 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1242 int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
1247 if (comm == MPI_COMM_NULL) {
1248 retval = MPI_ERR_COMM;
1249 } else if (dst == MPI_PROC_NULL) {
1250 retval = MPI_SUCCESS;
1251 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1252 retval = MPI_ERR_RANK;
1253 } else if (count < 0) {
1254 retval = MPI_ERR_COUNT;
1255 } else if (buf==NULL && count > 0) {
1256 retval = MPI_ERR_COUNT;
1257 } else if (!is_datatype_valid(datatype)){
1258 retval = MPI_ERR_TYPE;
1259 } else if(tag<0 && tag != MPI_ANY_TAG){
1260 retval = MPI_ERR_TAG;
1264 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1265 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1266 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1267 extra->type = TRACING_SSEND;
1268 extra->send_size = count;
1270 extra->dst = dst_traced;
1271 extra->datatype1 = encode_datatype(datatype);
1272 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra); TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype));
1275 smpi_mpi_ssend(buf, count, datatype, dst, tag, comm);
1276 retval = MPI_SUCCESS;
1279 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1287 int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1288 int dst, int sendtag, void *recvbuf, int recvcount,
1289 MPI_Datatype recvtype, int src, int recvtag,
1290 MPI_Comm comm, MPI_Status * status)
1296 if (comm == MPI_COMM_NULL) {
1297 retval = MPI_ERR_COMM;
1298 } else if (!is_datatype_valid(sendtype)
1299 || !is_datatype_valid(recvtype)) {
1300 retval = MPI_ERR_TYPE;
1301 } else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
1302 smpi_empty_status(status);
1303 status->MPI_SOURCE = MPI_PROC_NULL;
1304 retval = MPI_SUCCESS;
1305 }else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0 ||
1306 (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0))){
1307 retval = MPI_ERR_RANK;
1308 } else if (sendcount < 0 || recvcount<0) {
1309 retval = MPI_ERR_COUNT;
1310 } else if ((sendbuf==NULL && sendcount > 0)||(recvbuf==NULL && recvcount>0)) {
1311 retval = MPI_ERR_COUNT;
1312 } else if((sendtag<0 && sendtag != MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){
1313 retval = MPI_ERR_TAG;
1317 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1318 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1319 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1320 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1321 extra->type = TRACING_SENDRECV;
1322 extra->send_size = sendcount;
1323 extra->recv_size = recvcount;
1324 extra->src = src_traced;
1325 extra->dst = dst_traced;
1326 extra->datatype1 = encode_datatype(sendtype);
1327 extra->datatype2 = encode_datatype(recvtype);
1329 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, extra);
1330 TRACE_smpi_send(rank, rank, dst_traced,sendcount*smpi_datatype_size(sendtype));
1334 smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf,
1335 recvcount, recvtype, src, recvtag, comm, status);
1336 retval = MPI_SUCCESS;
1339 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1340 TRACE_smpi_recv(rank, src_traced, rank);
1349 int PMPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
1350 int dst, int sendtag, int src, int recvtag,
1351 MPI_Comm comm, MPI_Status * status)
1353 //TODO: suboptimal implementation
1356 if (!is_datatype_valid(datatype)) {
1357 retval = MPI_ERR_TYPE;
1358 } else if (count < 0) {
1359 retval = MPI_ERR_COUNT;
1361 int size = smpi_datatype_get_extent(datatype) * count;
1362 recvbuf = xbt_new0(char, size);
1364 MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
1365 datatype, src, recvtag, comm, status);
1366 if(retval==MPI_SUCCESS){
1367 smpi_datatype_copy(recvbuf, count, datatype, buf, count, datatype);
1375 int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
1379 if (request == NULL || flag == NULL) {
1380 retval = MPI_ERR_ARG;
1381 } else if (*request == MPI_REQUEST_NULL) {
1383 smpi_empty_status(status);
1384 retval = MPI_ERR_REQUEST;
1387 int rank = request && (*request)->comm != MPI_COMM_NULL
1388 ? smpi_process_index()
1391 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1392 extra->type = TRACING_TEST;
1393 TRACE_smpi_testing_in(rank, extra);
1395 *flag = smpi_mpi_test(request, status);
1397 TRACE_smpi_testing_out(rank);
1399 retval = MPI_SUCCESS;
1405 int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
1406 MPI_Status * status)
1411 if (index == NULL || flag == NULL) {
1412 retval = MPI_ERR_ARG;
1414 *flag = smpi_mpi_testany(count, requests, index, status);
1415 retval = MPI_SUCCESS;
1421 int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses)
1427 retval = MPI_ERR_ARG;
1429 *flag = smpi_mpi_testall(count, requests, statuses);
1430 retval = MPI_SUCCESS;
1436 int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) {
1440 if (status == NULL) {
1441 retval = MPI_ERR_ARG;
1442 } else if (comm == MPI_COMM_NULL) {
1443 retval = MPI_ERR_COMM;
1444 } else if (source == MPI_PROC_NULL) {
1445 smpi_empty_status(status);
1446 status->MPI_SOURCE = MPI_PROC_NULL;
1447 retval = MPI_SUCCESS;
1449 smpi_mpi_probe(source, tag, comm, status);
1450 retval = MPI_SUCCESS;
1457 int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status) {
1462 retval = MPI_ERR_ARG;
1463 } else if (status == NULL) {
1464 retval = MPI_ERR_ARG;
1465 } else if (comm == MPI_COMM_NULL) {
1466 retval = MPI_ERR_COMM;
1467 } else if (source == MPI_PROC_NULL) {
1469 smpi_empty_status(status);
1470 status->MPI_SOURCE = MPI_PROC_NULL;
1471 retval = MPI_SUCCESS;
1473 smpi_mpi_iprobe(source, tag, comm, flag, status);
1474 retval = MPI_SUCCESS;
1480 int PMPI_Wait(MPI_Request * request, MPI_Status * status)
1486 smpi_empty_status(status);
1488 if (request == NULL) {
1489 retval = MPI_ERR_ARG;
1490 } else if (*request == MPI_REQUEST_NULL) {
1491 retval = MPI_ERR_REQUEST;
1495 int rank = request && (*request)->comm != MPI_COMM_NULL
1496 ? smpi_process_index()
1499 int src_traced = (*request)->src;
1500 int dst_traced = (*request)->dst;
1501 MPI_Comm comm = (*request)->comm;
1502 int is_wait_for_receive = (*request)->recv;
1503 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1504 extra->type = TRACING_WAIT;
1505 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, extra);
1508 smpi_mpi_wait(request, status);
1509 retval = MPI_SUCCESS;
1512 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1513 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1514 if (is_wait_for_receive) {
1515 if(src_traced==MPI_ANY_SOURCE)
1516 src_traced = (status!=MPI_STATUS_IGNORE) ?
1517 smpi_group_rank(smpi_comm_group(comm), status->MPI_SOURCE) :
1519 TRACE_smpi_recv(rank, src_traced, dst_traced);
1529 int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * status)
1536 //save requests information for tracing
1538 int *srcs = xbt_new0(int, count);
1539 int *dsts = xbt_new0(int, count);
1540 int *recvs = xbt_new0(int, count);
1541 MPI_Comm *comms = xbt_new0(MPI_Comm, count);
1543 for (i = 0; i < count; i++) {
1544 MPI_Request req = requests[i]; //already received requests are no longer valid
1548 recvs[i] = req->recv;
1549 comms[i] = req->comm;
1552 int rank_traced = smpi_process_index();
1553 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1554 extra->type = TRACING_WAITANY;
1555 extra->send_size=count;
1556 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,extra);
1559 *index = smpi_mpi_waitany(count, requests, status);
1561 if(*index!=MPI_UNDEFINED){
1562 int src_traced = srcs[*index];
1563 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1564 int dst_traced = dsts[*index];
1565 int is_wait_for_receive = recvs[*index];
1566 if (is_wait_for_receive) {
1567 if(srcs[*index]==MPI_ANY_SOURCE)
1568 src_traced = (status!=MPI_STATUSES_IGNORE) ?
1569 smpi_group_rank(smpi_comm_group(comms[*index]), status->MPI_SOURCE) :
1571 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1573 TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__);
1585 int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
1590 //save information from requests
1592 int *srcs = xbt_new0(int, count);
1593 int *dsts = xbt_new0(int, count);
1594 int *recvs = xbt_new0(int, count);
1595 int *valid = xbt_new0(int, count);
1596 MPI_Comm *comms = xbt_new0(MPI_Comm, count);
1598 //int valid_count = 0;
1599 for (i = 0; i < count; i++) {
1600 MPI_Request req = requests[i];
1601 if(req!=MPI_REQUEST_NULL){
1604 recvs[i] = req->recv;
1605 comms[i] = req->comm;
1611 int rank_traced = smpi_process_index();
1612 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1613 extra->type = TRACING_WAITALL;
1614 extra->send_size=count;
1615 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,extra);
1617 int retval = smpi_mpi_waitall(count, requests, status);
1619 for (i = 0; i < count; i++) {
1621 //int src_traced = srcs[*index];
1622 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1623 int src_traced = srcs[i];
1624 int dst_traced = dsts[i];
1625 int is_wait_for_receive = recvs[i];
1626 if (is_wait_for_receive) {
1627 if(src_traced==MPI_ANY_SOURCE)
1628 src_traced = (status!=MPI_STATUSES_IGNORE) ?
1629 smpi_group_rank(smpi_comm_group(comms[i]), status[i].MPI_SOURCE) :
1631 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1635 TRACE_smpi_ptp_out(rank_traced, -1, -1, __FUNCTION__);
1647 int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
1648 int *indices, MPI_Status status[])
1653 if (outcount == NULL) {
1654 retval = MPI_ERR_ARG;
1656 *outcount = smpi_mpi_waitsome(incount, requests, indices, status);
1657 retval = MPI_SUCCESS;
1663 int PMPI_Testsome(int incount, MPI_Request requests[], int* outcount,
1664 int* indices, MPI_Status status[])
1669 if (outcount == NULL) {
1670 retval = MPI_ERR_ARG;
1672 *outcount = smpi_mpi_testsome(incount, requests, indices, status);
1673 retval = MPI_SUCCESS;
1680 int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
1686 if (comm == MPI_COMM_NULL) {
1687 retval = MPI_ERR_COMM;
1688 } else if (!is_datatype_valid(datatype)) {
1689 retval = MPI_ERR_ARG;
1692 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1693 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1695 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1696 extra->type = TRACING_BCAST;
1697 extra->send_size = count;
1698 extra->root = root_traced;
1699 extra->datatype1 = encode_datatype(datatype);
1700 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
1703 mpi_coll_bcast_fun(buf, count, datatype, root, comm);
1704 retval = MPI_SUCCESS;
1706 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1714 int PMPI_Barrier(MPI_Comm comm)
1720 if (comm == MPI_COMM_NULL) {
1721 retval = MPI_ERR_COMM;
1724 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1725 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1726 extra->type = TRACING_BARRIER;
1727 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
1729 mpi_coll_barrier_fun(comm);
1730 retval = MPI_SUCCESS;
1732 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1740 int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1741 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1742 int root, MPI_Comm comm)
1748 if (comm == MPI_COMM_NULL) {
1749 retval = MPI_ERR_COMM;
1750 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1751 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1752 retval = MPI_ERR_TYPE;
1753 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1754 ((smpi_comm_rank(comm) == root) && (recvcount <0))){
1755 retval = MPI_ERR_COUNT;
1758 char* sendtmpbuf = (char*) sendbuf;
1759 int sendtmpcount = sendcount;
1760 MPI_Datatype sendtmptype = sendtype;
1761 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1763 sendtmptype=recvtype;
1766 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1767 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1768 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1769 extra->type = TRACING_GATHER;
1770 extra->send_size = sendtmpcount;
1771 extra->recv_size = recvcount;
1772 extra->root = root_traced;
1773 extra->datatype1 = encode_datatype(sendtmptype);
1774 extra->datatype2 = encode_datatype(recvtype);
1776 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
1778 mpi_coll_gather_fun(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcount,
1779 recvtype, root, comm);
1782 retval = MPI_SUCCESS;
1784 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1792 int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1793 void *recvbuf, int *recvcounts, int *displs,
1794 MPI_Datatype recvtype, int root, MPI_Comm comm)
1800 if (comm == MPI_COMM_NULL) {
1801 retval = MPI_ERR_COMM;
1802 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1803 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1804 retval = MPI_ERR_TYPE;
1805 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1806 retval = MPI_ERR_COUNT;
1807 } else if (recvcounts == NULL || displs == NULL) {
1808 retval = MPI_ERR_ARG;
1810 char* sendtmpbuf = (char*) sendbuf;
1811 int sendtmpcount = sendcount;
1812 MPI_Datatype sendtmptype = sendtype;
1813 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1815 sendtmptype=recvtype;
1819 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1820 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1822 int size = smpi_comm_size(comm);
1823 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1824 extra->type = TRACING_GATHERV;
1825 extra->send_size = sendtmpcount;
1826 extra->recvcounts= xbt_malloc(size*sizeof(int));
1827 for(i=0; i< size; i++)//copy data to avoid bad free
1828 extra->recvcounts[i] = recvcounts[i];
1829 extra->num_processes = size;
1830 extra->root = root_traced;
1831 extra->datatype1 = encode_datatype(sendtmptype);
1832 extra->datatype2 = encode_datatype(recvtype);
1834 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
1836 smpi_mpi_gatherv(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcounts,
1837 displs, recvtype, root, comm);
1838 retval = MPI_SUCCESS;
1840 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1848 int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1849 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1856 if (comm == MPI_COMM_NULL) {
1857 retval = MPI_ERR_COMM;
1858 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1859 (recvtype == MPI_DATATYPE_NULL)){
1860 retval = MPI_ERR_TYPE;
1861 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1863 retval = MPI_ERR_COUNT;
1865 if(sendbuf == MPI_IN_PLACE) {
1866 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*recvcount*smpi_comm_rank(comm);
1867 sendcount=recvcount;
1871 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1872 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1873 extra->type = TRACING_ALLGATHER;
1874 extra->send_size = sendcount;
1875 extra->recv_size = recvcount;
1876 extra->datatype1 = encode_datatype(sendtype);
1877 extra->datatype2 = encode_datatype(recvtype);
1879 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
1881 mpi_coll_allgather_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1883 retval = MPI_SUCCESS;
1886 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1893 int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1894 void *recvbuf, int *recvcounts, int *displs,
1895 MPI_Datatype recvtype, MPI_Comm comm)
1901 if (comm == MPI_COMM_NULL) {
1902 retval = MPI_ERR_COMM;
1903 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1904 (recvtype == MPI_DATATYPE_NULL)){
1905 retval = MPI_ERR_TYPE;
1906 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1907 retval = MPI_ERR_COUNT;
1908 } else if (recvcounts == NULL || displs == NULL) {
1909 retval = MPI_ERR_ARG;
1912 if(sendbuf == MPI_IN_PLACE) {
1913 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*displs[smpi_comm_rank(comm)];
1914 sendcount=recvcounts[smpi_comm_rank(comm)];
1918 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1920 int size = smpi_comm_size(comm);
1921 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1922 extra->type = TRACING_ALLGATHERV;
1923 extra->send_size = sendcount;
1924 extra->recvcounts= xbt_malloc(size*sizeof(int));
1925 for(i=0; i< size; i++)//copy data to avoid bad free
1926 extra->recvcounts[i] = recvcounts[i];
1927 extra->num_processes = size;
1928 extra->datatype1 = encode_datatype(sendtype);
1929 extra->datatype2 = encode_datatype(recvtype);
1931 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
1933 mpi_coll_allgatherv_fun(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
1934 displs, recvtype, comm);
1935 retval = MPI_SUCCESS;
1937 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1945 int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1946 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1947 int root, MPI_Comm comm)
1953 if (comm == MPI_COMM_NULL) {
1954 retval = MPI_ERR_COMM;
1955 } else if (((smpi_comm_rank(comm)==root) && (!is_datatype_valid(sendtype)))
1956 || ((recvbuf !=MPI_IN_PLACE) && (!is_datatype_valid(recvtype)))){
1957 retval = MPI_ERR_TYPE;
1958 } else if ((sendbuf == recvbuf) ||
1959 ((smpi_comm_rank(comm)==root) && sendcount>0 && (sendbuf == NULL))){
1960 retval = MPI_ERR_BUFFER;
1963 if (recvbuf == MPI_IN_PLACE) {
1965 recvcount=sendcount;
1968 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1969 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1970 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1971 extra->type = TRACING_SCATTER;
1972 extra->send_size = sendcount;
1973 extra->recv_size= recvcount;
1974 extra->root = root_traced;
1975 extra->datatype1 = encode_datatype(sendtype);
1976 extra->datatype2 = encode_datatype(recvtype);
1978 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
1980 mpi_coll_scatter_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1981 recvtype, root, comm);
1982 retval = MPI_SUCCESS;
1984 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1992 int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
1993 MPI_Datatype sendtype, void *recvbuf, int recvcount,
1994 MPI_Datatype recvtype, int root, MPI_Comm comm)
2000 if (comm == MPI_COMM_NULL) {
2001 retval = MPI_ERR_COMM;
2002 } else if (sendcounts == NULL || displs == NULL) {
2003 retval = MPI_ERR_ARG;
2004 } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
2005 || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
2006 retval = MPI_ERR_TYPE;
2008 if (recvbuf == MPI_IN_PLACE) {
2010 recvcount=sendcounts[smpi_comm_rank(comm)];
2013 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2014 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
2016 int size = smpi_comm_size(comm);
2017 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2018 extra->type = TRACING_SCATTERV;
2019 extra->recv_size = recvcount;
2020 extra->sendcounts= xbt_malloc(size*sizeof(int));
2021 for(i=0; i< size; i++)//copy data to avoid bad free
2022 extra->sendcounts[i] = sendcounts[i];
2023 extra->num_processes = size;
2024 extra->root = root_traced;
2025 extra->datatype1 = encode_datatype(sendtype);
2026 extra->datatype2 = encode_datatype(recvtype);
2028 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
2031 smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
2032 recvcount, recvtype, root, comm);
2033 retval = MPI_SUCCESS;
2035 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
2043 int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
2044 MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
2050 if (comm == MPI_COMM_NULL) {
2051 retval = MPI_ERR_COMM;
2052 } else if (!is_datatype_valid(datatype) || op == MPI_OP_NULL) {
2053 retval = MPI_ERR_ARG;
2056 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2057 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
2058 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2059 extra->type = TRACING_REDUCE;
2060 extra->send_size = count;
2061 extra->datatype1 = encode_datatype(datatype);
2062 extra->root = root_traced;
2064 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
2066 mpi_coll_reduce_fun(sendbuf, recvbuf, count, datatype, op, root, comm);
2068 retval = MPI_SUCCESS;
2070 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
2078 int PMPI_Reduce_local(void *inbuf, void *inoutbuf, int count,
2079 MPI_Datatype datatype, MPI_Op op){
2083 if (!is_datatype_valid(datatype) || op == MPI_OP_NULL) {
2084 retval = MPI_ERR_ARG;
2086 smpi_op_apply(op, inbuf, inoutbuf, &count, &datatype);
2093 int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
2094 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2100 if (comm == MPI_COMM_NULL) {
2101 retval = MPI_ERR_COMM;
2102 } else if (!is_datatype_valid(datatype)) {
2103 retval = MPI_ERR_TYPE;
2104 } else if (op == MPI_OP_NULL) {
2105 retval = MPI_ERR_OP;
2108 char* sendtmpbuf = (char*) sendbuf;
2109 if( sendbuf == MPI_IN_PLACE ) {
2110 sendtmpbuf = (char *)xbt_malloc(count*smpi_datatype_get_extent(datatype));
2111 smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
2114 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2115 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2116 extra->type = TRACING_ALLREDUCE;
2117 extra->send_size = count;
2118 extra->datatype1 = encode_datatype(datatype);
2120 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2122 mpi_coll_allreduce_fun(sendtmpbuf, recvbuf, count, datatype, op, comm);
2124 if( sendbuf == MPI_IN_PLACE ) {
2125 xbt_free(sendtmpbuf);
2128 retval = MPI_SUCCESS;
2130 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2138 int PMPI_Scan(void *sendbuf, void *recvbuf, int count,
2139 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2145 if (comm == MPI_COMM_NULL) {
2146 retval = MPI_ERR_COMM;
2147 } else if (!is_datatype_valid(datatype)) {
2148 retval = MPI_ERR_TYPE;
2149 } else if (op == MPI_OP_NULL) {
2150 retval = MPI_ERR_OP;
2153 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2154 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2155 extra->type = TRACING_SCAN;
2156 extra->send_size = count;
2157 extra->datatype1 = encode_datatype(datatype);
2159 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2161 smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm);
2162 retval = MPI_SUCCESS;
2164 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2172 int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
2173 MPI_Op op, MPI_Comm comm){
2178 if (comm == MPI_COMM_NULL) {
2179 retval = MPI_ERR_COMM;
2180 } else if (!is_datatype_valid(datatype)) {
2181 retval = MPI_ERR_TYPE;
2182 } else if (op == MPI_OP_NULL) {
2183 retval = MPI_ERR_OP;
2186 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2187 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2188 extra->type = TRACING_EXSCAN;
2189 extra->send_size = count;
2190 extra->datatype1 = encode_datatype(datatype);
2192 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2194 smpi_mpi_exscan(sendbuf, recvbuf, count, datatype, op, comm);
2195 retval = MPI_SUCCESS;
2197 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2205 int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
2206 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2211 if (comm == MPI_COMM_NULL) {
2212 retval = MPI_ERR_COMM;
2213 } else if (!is_datatype_valid(datatype)) {
2214 retval = MPI_ERR_TYPE;
2215 } else if (op == MPI_OP_NULL) {
2216 retval = MPI_ERR_OP;
2217 } else if (recvcounts == NULL) {
2218 retval = MPI_ERR_ARG;
2221 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2223 int size = smpi_comm_size(comm);
2224 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2225 extra->type = TRACING_REDUCE_SCATTER;
2226 extra->send_size = 0;
2227 extra->recvcounts= xbt_malloc(size*sizeof(int));
2228 for(i=0; i< size; i++)//copy data to avoid bad free
2229 extra->recvcounts[i] = recvcounts[i];
2230 extra->num_processes = size;
2231 extra->datatype1 = encode_datatype(datatype);
2233 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2235 void* sendtmpbuf=sendbuf;
2236 if(sendbuf==MPI_IN_PLACE){
2240 mpi_coll_reduce_scatter_fun(sendtmpbuf, recvbuf, recvcounts,
2241 datatype, op, comm);
2242 retval = MPI_SUCCESS;
2244 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2252 int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
2253 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2258 if (comm == MPI_COMM_NULL) {
2259 retval = MPI_ERR_COMM;
2260 } else if (!is_datatype_valid(datatype)) {
2261 retval = MPI_ERR_TYPE;
2262 } else if (op == MPI_OP_NULL) {
2263 retval = MPI_ERR_OP;
2264 } else if (recvcount < 0) {
2265 retval = MPI_ERR_ARG;
2267 int count=smpi_comm_size(comm);
2270 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2271 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2272 extra->type = TRACING_REDUCE_SCATTER;
2273 extra->send_size = 0;
2274 extra->recvcounts= xbt_malloc(count*sizeof(int));
2275 for(i=0; i< count; i++)//copy data to avoid bad free
2276 extra->recvcounts[i] = recvcount;
2277 extra->num_processes = count;
2278 extra->datatype1 = encode_datatype(datatype);
2280 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2282 int* recvcounts=(int*)xbt_malloc(count);
2283 for (i=0; i<count;i++)recvcounts[i]=recvcount;
2284 mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts,
2285 datatype, op, comm);
2286 xbt_free(recvcounts);
2287 retval = MPI_SUCCESS;
2289 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2297 int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
2298 void *recvbuf, int recvcount, MPI_Datatype recvtype,
2305 if (comm == MPI_COMM_NULL) {
2306 retval = MPI_ERR_COMM;
2307 } else if (sendtype == MPI_DATATYPE_NULL
2308 || recvtype == MPI_DATATYPE_NULL) {
2309 retval = MPI_ERR_TYPE;
2312 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2313 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2314 extra->type = TRACING_ALLTOALL;
2315 extra->send_size = sendcount;
2316 extra->recv_size = recvcount;
2317 extra->datatype1 = encode_datatype(sendtype);
2318 extra->datatype2 = encode_datatype(recvtype);
2320 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2322 retval = mpi_coll_alltoall_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
2324 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2332 int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
2333 MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
2334 int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
2340 if (comm == MPI_COMM_NULL) {
2341 retval = MPI_ERR_COMM;
2342 } else if (sendtype == MPI_DATATYPE_NULL
2343 || recvtype == MPI_DATATYPE_NULL) {
2344 retval = MPI_ERR_TYPE;
2345 } else if (sendcounts == NULL || senddisps == NULL || recvcounts == NULL
2346 || recvdisps == NULL) {
2347 retval = MPI_ERR_ARG;
2350 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2352 int size = smpi_comm_size(comm);
2353 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2354 extra->type = TRACING_ALLTOALLV;
2355 extra->send_size = 0;
2356 extra->recv_size = 0;
2357 extra->recvcounts= xbt_malloc(size*sizeof(int));
2358 extra->sendcounts= xbt_malloc(size*sizeof(int));
2360 for(i=0; i< size; i++){//copy data to avoid bad free
2361 extra->send_size += sendcounts[i];
2362 extra->recv_size += recvcounts[i];
2364 extra->sendcounts[i] = sendcounts[i];
2365 extra->recvcounts[i] = recvcounts[i];
2367 extra->num_processes = size;
2369 extra->datatype1 = encode_datatype(sendtype);
2370 extra->datatype2 = encode_datatype(recvtype);
2372 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2375 mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, sendtype,
2376 recvbuf, recvcounts, recvdisps, recvtype,
2379 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2388 int PMPI_Get_processor_name(char *name, int *resultlen)
2390 int retval = MPI_SUCCESS;
2392 strncpy(name, SIMIX_host_get_name(SIMIX_host_self()),
2393 strlen(SIMIX_host_get_name(SIMIX_host_self())) < MPI_MAX_PROCESSOR_NAME - 1 ?
2394 strlen(SIMIX_host_get_name(SIMIX_host_self())) +1 :
2395 MPI_MAX_PROCESSOR_NAME - 1 );
2398 MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
2403 int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
2405 int retval = MPI_SUCCESS;
2408 if (status == NULL || count == NULL) {
2409 retval = MPI_ERR_ARG;
2410 } else if (!is_datatype_valid(datatype)) {
2411 retval = MPI_ERR_TYPE;
2413 size = smpi_datatype_size(datatype);
2416 } else if (status->count % size != 0) {
2417 retval = MPI_UNDEFINED;
2419 *count = smpi_mpi_get_count(status, datatype);
2425 int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type) {
2428 if (old_type == MPI_DATATYPE_NULL) {
2429 retval = MPI_ERR_TYPE;
2430 } else if (count<0){
2431 retval = MPI_ERR_COUNT;
2433 retval = smpi_datatype_contiguous(count, old_type, new_type, 0);
2438 int PMPI_Type_commit(MPI_Datatype* datatype) {
2441 if (datatype == NULL || *datatype == MPI_DATATYPE_NULL) {
2442 retval = MPI_ERR_TYPE;
2444 smpi_datatype_commit(datatype);
2445 retval = MPI_SUCCESS;
2451 int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2454 if (old_type == MPI_DATATYPE_NULL) {
2455 retval = MPI_ERR_TYPE;
2456 } else if (count<0 || blocklen<0){
2457 retval = MPI_ERR_COUNT;
2459 retval = smpi_datatype_vector(count, blocklen, stride, old_type, new_type);
2464 int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2467 if (old_type == MPI_DATATYPE_NULL) {
2468 retval = MPI_ERR_TYPE;
2469 } else if (count<0 || blocklen<0){
2470 retval = MPI_ERR_COUNT;
2472 retval = smpi_datatype_hvector(count, blocklen, stride, old_type, new_type);
2477 int PMPI_Type_create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2478 return MPI_Type_hvector(count, blocklen, stride, old_type, new_type);
2481 int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2484 if (old_type == MPI_DATATYPE_NULL) {
2485 retval = MPI_ERR_TYPE;
2486 } else if (count<0){
2487 retval = MPI_ERR_COUNT;
2489 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2494 int PMPI_Type_create_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2497 if (old_type == MPI_DATATYPE_NULL) {
2498 retval = MPI_ERR_TYPE;
2499 } else if (count<0){
2500 retval = MPI_ERR_COUNT;
2502 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2507 int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2510 if (old_type == MPI_DATATYPE_NULL) {
2511 retval = MPI_ERR_TYPE;
2512 } else if (count<0){
2513 retval = MPI_ERR_COUNT;
2515 int* blocklens=(int*)xbt_malloc(blocklength*count);
2516 for (i=0; i<count;i++)blocklens[i]=blocklength;
2517 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2518 xbt_free(blocklens);
2524 int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2527 if (old_type == MPI_DATATYPE_NULL) {
2528 retval = MPI_ERR_TYPE;
2529 } else if (count<0){
2530 retval = MPI_ERR_COUNT;
2532 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2537 int PMPI_Type_create_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2538 return PMPI_Type_hindexed(count, blocklens,indices,old_type,new_type);
2541 int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2544 if (old_type == MPI_DATATYPE_NULL) {
2545 retval = MPI_ERR_TYPE;
2546 } else if (count<0){
2547 retval = MPI_ERR_COUNT;
2549 int* blocklens=(int*)xbt_malloc(blocklength*count);
2550 for (i=0; i<count;i++)blocklens[i]=blocklength;
2551 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2552 xbt_free(blocklens);
2558 int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2562 retval = MPI_ERR_COUNT;
2564 retval = smpi_datatype_struct(count, blocklens, indices, old_types, new_type);
2569 int PMPI_Type_create_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2570 return PMPI_Type_struct(count, blocklens, indices, old_types, new_type);
2574 int PMPI_Error_class(int errorcode, int* errorclass) {
2575 // assume smpi uses only standard mpi error codes
2576 *errorclass=errorcode;
2581 int PMPI_Initialized(int* flag) {
2582 *flag=smpi_process_initialized();
2586 /* The topo part of MPI_COMM_WORLD should always be NULL. When other topologies
2587 * will be implemented, not only should we check if the topology is NULL, but
2588 * we should check if it is the good topology type (so we have to add a
2589 * MPIR_Topo_Type field, and replace the MPI_Topology field by an union)*/
2591 int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periodic, int reorder, MPI_Comm* comm_cart) {
2593 if (comm_old == MPI_COMM_NULL){
2594 retval = MPI_ERR_COMM;
2595 } else if (ndims < 0 ||
2596 (ndims > 0 && (dims == NULL ||
2597 periodic == NULL)) ||
2598 comm_cart == NULL) {
2599 retval = MPI_ERR_ARG;
2601 retval = smpi_mpi_cart_create(comm_old, ndims, dims, periodic, reorder, comm_cart);
2606 int PMPI_Cart_rank(MPI_Comm comm, int* coords, int* rank) {
2607 if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2608 return MPI_ERR_TOPOLOGY;
2610 if (coords == NULL) {
2613 return smpi_mpi_cart_rank(comm, coords, rank);
2616 int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* dest) {
2617 if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2618 return MPI_ERR_TOPOLOGY;
2620 if (source == NULL || dest == NULL || direction < 0 ) {
2623 return smpi_mpi_cart_shift(comm, direction, displ, source, dest);
2626 int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) {
2627 if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2628 return MPI_ERR_TOPOLOGY;
2630 if (rank < 0 || rank >= smpi_comm_size(comm)) {
2631 return MPI_ERR_RANK;
2636 if(coords == NULL) {
2639 return smpi_mpi_cart_coords(comm, rank, maxdims, coords);
2642 int PMPI_Cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) {
2643 if(comm == NULL || smpi_comm_topo(comm) == NULL) {
2644 return MPI_ERR_TOPOLOGY;
2646 if(maxdims <= 0 || dims == NULL || periods == NULL || coords == NULL) {
2649 return smpi_mpi_cart_get(comm, maxdims, dims, periods, coords);
2652 int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) {
2653 if (comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2654 return MPI_ERR_TOPOLOGY;
2656 if (ndims == NULL) {
2659 return smpi_mpi_cartdim_get(comm, ndims);
2662 int PMPI_Dims_create(int nnodes, int ndims, int* dims) {
2666 if (ndims < 1 || nnodes < 1) {
2667 return MPI_ERR_DIMS;
2670 return smpi_mpi_dims_create(nnodes, ndims, dims);
2673 int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
2674 if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2675 return MPI_ERR_TOPOLOGY;
2677 if (comm_new == NULL) {
2680 return smpi_mpi_cart_sub(comm, remain_dims, comm_new);
2683 int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype){
2684 if(oldtype == MPI_DATATYPE_NULL) {
2685 return MPI_ERR_TYPE;
2687 int blocks[3] = { 1, 1, 1 };
2688 MPI_Aint disps[3] = { lb, 0, lb+extent };
2689 MPI_Datatype types[3] = { MPI_LB, oldtype, MPI_UB };
2691 s_smpi_mpi_struct_t* subtype = smpi_datatype_struct_create( blocks,
2696 smpi_datatype_create(newtype,oldtype->size, lb, lb + extent, 1 , subtype, DT_FLAG_VECTOR);
2698 (*newtype)->flags &= ~DT_FLAG_COMMITED;
2704 int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win){
2707 if (comm == MPI_COMM_NULL) {
2708 retval= MPI_ERR_COMM;
2709 }else if ((base == NULL && size != 0)
2710 || disp_unit <= 0 || size < 0 ){
2711 retval= MPI_ERR_OTHER;
2713 *win = smpi_mpi_win_create( base, size, disp_unit, info, comm);
2714 retval = MPI_SUCCESS;
2720 int PMPI_Win_free( MPI_Win* win){
2723 if (win == NULL || *win == MPI_WIN_NULL) {
2724 retval = MPI_ERR_WIN;
2726 retval=smpi_mpi_win_free(win);
2732 int PMPI_Win_set_name(MPI_Win win, char * name)
2735 if (win == MPI_WIN_NULL) {
2736 retval = MPI_ERR_TYPE;
2737 } else if (name == NULL) {
2738 retval = MPI_ERR_ARG;
2740 smpi_mpi_win_set_name(win, name);
2741 retval = MPI_SUCCESS;
2746 int PMPI_Win_get_name(MPI_Win win, char * name, int* len)
2750 if (win == MPI_WIN_NULL) {
2751 retval = MPI_ERR_TYPE;
2752 } else if (name == NULL) {
2753 retval = MPI_ERR_ARG;
2755 smpi_mpi_win_get_name(win, name, len);
2756 retval = MPI_SUCCESS;
2762 int PMPI_Win_fence( int assert, MPI_Win win){
2765 if (win == MPI_WIN_NULL) {
2766 retval = MPI_ERR_WIN;
2768 retval = smpi_mpi_win_fence(assert, win);
2774 int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2775 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
2778 if (win == MPI_WIN_NULL) {
2779 retval = MPI_ERR_WIN;
2780 } else if (target_rank == MPI_PROC_NULL) {
2781 retval = MPI_SUCCESS;
2782 } else if (target_rank <0){
2783 retval = MPI_ERR_RANK;
2784 } else if (target_disp <0){
2785 retval = MPI_ERR_ARG;
2786 } else if (origin_count < 0 || target_count < 0) {
2787 retval = MPI_ERR_COUNT;
2788 } else if (origin_addr==NULL && origin_count > 0){
2789 retval = MPI_ERR_COUNT;
2790 } else if ((!is_datatype_valid(origin_datatype)) ||
2791 (!is_datatype_valid(target_datatype))) {
2792 retval = MPI_ERR_TYPE;
2794 retval = smpi_mpi_get( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, target_datatype, win);
2800 int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2801 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
2804 if (win == MPI_WIN_NULL) {
2805 retval = MPI_ERR_WIN;
2806 } else if (target_rank == MPI_PROC_NULL) {
2807 retval = MPI_SUCCESS;
2808 } else if (target_rank <0){
2809 retval = MPI_ERR_RANK;
2810 } else if (target_disp <0){
2811 retval = MPI_ERR_ARG;
2812 } else if (origin_count < 0 || target_count < 0) {
2813 retval = MPI_ERR_COUNT;
2814 } else if (origin_addr==NULL && origin_count > 0){
2815 retval = MPI_ERR_COUNT;
2816 } else if ((!is_datatype_valid(origin_datatype)) ||
2817 (!is_datatype_valid(target_datatype))) {
2818 retval = MPI_ERR_TYPE;
2820 retval = smpi_mpi_put( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, target_datatype, win);
2827 int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2828 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
2831 if (win == MPI_WIN_NULL) {
2832 retval = MPI_ERR_WIN;
2833 } else if (target_rank == MPI_PROC_NULL) {
2834 retval = MPI_SUCCESS;
2835 } else if (target_rank <0){
2836 retval = MPI_ERR_RANK;
2837 } else if (target_disp <0){
2838 retval = MPI_ERR_ARG;
2839 } else if (origin_count < 0 || target_count < 0) {
2840 retval = MPI_ERR_COUNT;
2841 } else if (origin_addr==NULL && origin_count > 0){
2842 retval = MPI_ERR_COUNT;
2843 } else if ((!is_datatype_valid(origin_datatype)) ||
2844 (!is_datatype_valid(target_datatype))) {
2845 retval = MPI_ERR_TYPE;
2846 } else if (op == MPI_OP_NULL) {
2847 retval = MPI_ERR_OP;
2849 retval = smpi_mpi_accumulate( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, target_datatype, op, win);
2856 int PMPI_Alloc_mem(MPI_Aint size, MPI_Info info, void *baseptr){
2857 void *ptr = xbt_malloc(size);
2859 return MPI_ERR_NO_MEM;
2861 *(void **)baseptr = ptr;
2866 int PMPI_Free_mem(void *baseptr){
2871 int PMPI_Type_set_name(MPI_Datatype datatype, char * name)
2874 if (datatype == MPI_DATATYPE_NULL) {
2875 retval = MPI_ERR_TYPE;
2876 } else if (name == NULL) {
2877 retval = MPI_ERR_ARG;
2879 smpi_datatype_set_name(datatype, name);
2880 retval = MPI_SUCCESS;
2885 int PMPI_Type_get_name(MPI_Datatype datatype, char * name, int* len)
2889 if (datatype == MPI_DATATYPE_NULL) {
2890 retval = MPI_ERR_TYPE;
2891 } else if (name == NULL) {
2892 retval = MPI_ERR_ARG;
2894 smpi_datatype_get_name(datatype, name, len);
2895 retval = MPI_SUCCESS;
2901 MPI_Datatype PMPI_Type_f2c(MPI_Fint datatype){
2902 return smpi_type_f2c(datatype);
2905 MPI_Fint PMPI_Type_c2f(MPI_Datatype datatype){
2906 return smpi_type_c2f( datatype);
2909 MPI_Group PMPI_Group_f2c(MPI_Fint group){
2910 return smpi_group_f2c( group);
2913 MPI_Fint PMPI_Group_c2f(MPI_Group group){
2914 return smpi_group_c2f(group);
2917 MPI_Request PMPI_Request_f2c(MPI_Fint request){
2918 return smpi_request_f2c(request);
2921 MPI_Fint PMPI_Request_c2f(MPI_Request request) {
2922 return smpi_request_c2f(request);
2925 MPI_Win PMPI_Win_f2c(MPI_Fint win){
2926 return smpi_win_f2c(win);
2929 MPI_Fint PMPI_Win_c2f(MPI_Win win){
2930 return smpi_win_c2f(win);
2933 MPI_Op PMPI_Op_f2c(MPI_Fint op){
2934 return smpi_op_f2c(op);
2937 MPI_Fint PMPI_Op_c2f(MPI_Op op){
2938 return smpi_op_c2f(op);
2943 /* The following calls are not yet implemented and will fail at runtime. */
2944 /* Once implemented, please move them above this notice. */
2946 #define NOT_YET_IMPLEMENTED { \
2947 XBT_WARN("Not yet implemented : %s. Please contact the Simgrid team if support is needed", __FUNCTION__); \
2948 return MPI_SUCCESS; \
2952 MPI_Info PMPI_Info_f2c(MPI_Fint info){
2956 MPI_Fint PMPI_Info_c2f(MPI_Info info){
2960 MPI_Errhandler PMPI_Errhandler_f2c(MPI_Fint errhandler){
2964 MPI_Fint PMPI_Errhandler_c2f(MPI_Errhandler errhandler){
2968 int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
2973 int PMPI_Cart_map(MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank) {
2978 int PMPI_Graph_create(MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder, MPI_Comm* comm_graph) {
2982 int PMPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int* index, int* edges) {
2986 int PMPI_Graph_map(MPI_Comm comm_old, int nnodes, int* index, int* edges, int* newrank) {
2990 int PMPI_Graph_neighbors(MPI_Comm comm, int rank, int maxneighbors, int* neighbors) {
2994 int PMPI_Graph_neighbors_count(MPI_Comm comm, int rank, int* nneighbors) {
2998 int PMPI_Graphdims_get(MPI_Comm comm, int* nnodes, int* nedges) {
3002 int PMPI_Topo_test(MPI_Comm comm, int* top_type) {
3006 int PMPI_Errhandler_create(MPI_Handler_function* function, MPI_Errhandler* errhandler) {
3010 int PMPI_Errhandler_free(MPI_Errhandler* errhandler) {
3014 int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler* errhandler) {
3018 int PMPI_Error_string(int errorcode, char* string, int* resultlen) {
3022 int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler) {
3026 int PMPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler) {
3030 int PMPI_Win_set_errhandler(MPI_Win win, MPI_Errhandler errhandler) {
3034 int PMPI_Comm_get_errhandler(MPI_Comm comm, MPI_Errhandler* errhandler) {
3038 int PMPI_Cancel(MPI_Request* request) {
3042 int PMPI_Buffer_attach(void* buffer, int size) {
3046 int PMPI_Buffer_detach(void* buffer, int* size) {
3050 int PMPI_Comm_test_inter(MPI_Comm comm, int* flag) {
3054 int PMPI_Comm_get_attr (MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag)
3059 int PMPI_Comm_set_attr (MPI_Comm comm, int comm_keyval, void *attribute_val)
3064 int PMPI_Comm_delete_attr (MPI_Comm comm, int comm_keyval)
3069 int PMPI_Comm_create_keyval(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state)
3074 int PMPI_Comm_free_keyval(int* keyval) {
3078 int PMPI_Pcontrol(const int level )
3083 int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
3087 int PMPI_Type_get_attr (MPI_Datatype type, int type_keyval, void *attribute_val, int* flag)
3092 int PMPI_Type_set_attr (MPI_Datatype type, int type_keyval, void *attribute_val)
3097 int PMPI_Type_delete_attr (MPI_Datatype type, int comm_keyval)
3102 int PMPI_Type_create_keyval(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state)
3107 int PMPI_Type_free_keyval(int* keyval) {
3111 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
3115 int PMPI_Intercomm_merge(MPI_Comm comm, int high, MPI_Comm* comm_out) {
3119 int PMPI_Bsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
3123 int PMPI_Bsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
3127 int PMPI_Ibsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
3131 int PMPI_Comm_remote_group(MPI_Comm comm, MPI_Group* group) {
3135 int PMPI_Comm_remote_size(MPI_Comm comm, int* size) {
3139 int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
3143 int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) {
3147 int PMPI_Attr_put(MPI_Comm comm, int keyval, void* attr_value) {
3151 int PMPI_Rsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
3155 int PMPI_Rsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
3159 int PMPI_Irsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
3163 int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
3167 int PMPI_Keyval_free(int* keyval) {
3171 int PMPI_Test_cancelled(MPI_Status* status, int* flag) {
3175 int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
3179 int PMPI_Pack_external_size(char *datarep, int incount, MPI_Datatype datatype, MPI_Aint *size){
3183 int PMPI_Pack_external(char *datarep, void *inbuf, int incount, MPI_Datatype datatype, void *outbuf, MPI_Aint outcount, MPI_Aint *position){
3187 int PMPI_Unpack_external( char *datarep, void *inbuf, MPI_Aint insize, MPI_Aint *position, void *outbuf, int outcount, MPI_Datatype datatype){
3191 int PMPI_Get_elements(MPI_Status* status, MPI_Datatype datatype, int* elements) {
3195 int PMPI_Info_create( MPI_Info *info){
3199 int PMPI_Info_set( MPI_Info info, char *key, char *value){
3203 int PMPI_Info_free( MPI_Info *info){
3207 int PMPI_Type_get_envelope( MPI_Datatype datatype, int *num_integers,
3208 int *num_addresses, int *num_datatypes, int *combiner){
3212 int PMPI_Type_get_contents(MPI_Datatype datatype, int max_integers, int max_addresses,
3213 int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses,
3214 MPI_Datatype* array_of_datatypes){
3218 int PMPI_Type_create_darray(int size, int rank, int ndims, int* array_of_gsizes,
3219 int* array_of_distribs, int* array_of_dargs, int* array_of_psizes,
3220 int order, MPI_Datatype oldtype, MPI_Datatype *newtype) {
3224 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){
3228 int PMPI_Type_match_size(int typeclass,int size,MPI_Datatype *datatype){
3232 int PMPI_Alltoallw( void *sendbuf, int *sendcnts, int *sdispls, MPI_Datatype *sendtypes,
3233 void *recvbuf, int *recvcnts, int *rdispls, MPI_Datatype *recvtypes,
3238 int PMPI_Comm_set_name(MPI_Comm comm, char* name){
3242 int PMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm * newcomm){
3246 int PMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm){
3250 int PMPI_Comm_set_info (MPI_Comm comm, MPI_Info info){
3254 int PMPI_Comm_get_info (MPI_Comm comm, MPI_Info* info){
3258 int PMPI_Info_get(MPI_Info info,char *key,int valuelen, char *value, int *flag){
3262 int PMPI_Comm_create_errhandler( MPI_Comm_errhandler_fn *function, MPI_Errhandler *errhandler){
3266 int PMPI_Add_error_class( int *errorclass){
3270 int PMPI_Add_error_code( int errorclass, int *errorcode){
3274 int PMPI_Add_error_string( int errorcode, char *string){
3278 int PMPI_Comm_call_errhandler(MPI_Comm comm,int errorcode){
3282 int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo){
3286 int PMPI_Info_delete(MPI_Info info, char *key){
3290 int PMPI_Info_get_nkeys( MPI_Info info, int *nkeys){
3294 int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){
3298 int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){
3302 int PMPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){
3306 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){
3310 int PMPI_Grequest_complete( MPI_Request request){
3314 int PMPI_Status_set_cancelled(MPI_Status *status,int flag){
3318 int PMPI_Status_set_elements( MPI_Status *status, MPI_Datatype datatype, int count){
3322 int PMPI_Comm_connect( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
3326 int PMPI_Publish_name( char *service_name, MPI_Info info, char *port_name){
3330 int PMPI_Unpublish_name( char *service_name, MPI_Info info, char *port_name){
3334 int PMPI_Lookup_name( char *service_name, MPI_Info info, char *port_name){
3338 int PMPI_Comm_join( int fd, MPI_Comm *intercomm){
3342 int PMPI_Open_port( MPI_Info info, char *port_name){
3346 int PMPI_Close_port(char *port_name){
3350 int PMPI_Comm_accept( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
3354 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){
3358 int PMPI_Comm_spawn_multiple( int count, char **array_of_commands, char*** array_of_argv,
3359 int* array_of_maxprocs, MPI_Info* array_of_info, int root,
3360 MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes){
3364 int PMPI_Comm_get_parent( MPI_Comm *parent){