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 retval = smpi_comm_dup(comm, newcomm);
781 int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
785 if (comm == MPI_COMM_NULL) {
786 retval = MPI_ERR_COMM;
787 } else if (group == MPI_GROUP_NULL) {
788 retval = MPI_ERR_GROUP;
789 } else if (newcomm == NULL) {
790 retval = MPI_ERR_ARG;
791 } else if(smpi_group_rank(group,smpi_process_index())==MPI_UNDEFINED){
792 *newcomm= MPI_COMM_NULL;
793 retval = MPI_SUCCESS;
796 *newcomm = smpi_comm_new(group, NULL);
797 retval = MPI_SUCCESS;
802 int PMPI_Comm_free(MPI_Comm * comm)
807 retval = MPI_ERR_ARG;
808 } else if (*comm == MPI_COMM_NULL) {
809 retval = MPI_ERR_COMM;
811 smpi_comm_destroy(*comm);
812 *comm = MPI_COMM_NULL;
813 retval = MPI_SUCCESS;
818 int PMPI_Comm_disconnect(MPI_Comm * comm)
820 /* TODO: wait until all communication in comm are done */
824 retval = MPI_ERR_ARG;
825 } else if (*comm == MPI_COMM_NULL) {
826 retval = MPI_ERR_COMM;
828 smpi_comm_destroy(*comm);
829 *comm = MPI_COMM_NULL;
830 retval = MPI_SUCCESS;
835 int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out)
840 if (comm_out == NULL) {
841 retval = MPI_ERR_ARG;
842 } else if (comm == MPI_COMM_NULL) {
843 retval = MPI_ERR_COMM;
845 *comm_out = smpi_comm_split(comm, color, key);
846 retval = MPI_SUCCESS;
853 int PMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst,
854 int tag, MPI_Comm comm, MPI_Request * request)
859 if (request == NULL) {
860 retval = MPI_ERR_ARG;
861 } else if (comm == MPI_COMM_NULL) {
862 retval = MPI_ERR_COMM;
863 } else if (!is_datatype_valid(datatype)) {
864 retval = MPI_ERR_TYPE;
865 } else if (dst == MPI_PROC_NULL) {
866 retval = MPI_SUCCESS;
868 *request = smpi_mpi_send_init(buf, count, datatype, dst, tag, comm);
869 retval = MPI_SUCCESS;
872 if (retval != MPI_SUCCESS && request)
873 *request = MPI_REQUEST_NULL;
877 int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src,
878 int tag, MPI_Comm comm, MPI_Request * request)
883 if (request == NULL) {
884 retval = MPI_ERR_ARG;
885 } else if (comm == MPI_COMM_NULL) {
886 retval = MPI_ERR_COMM;
887 } else if (!is_datatype_valid(datatype)) {
888 retval = MPI_ERR_TYPE;
889 } else if (src == MPI_PROC_NULL) {
890 retval = MPI_SUCCESS;
892 *request = smpi_mpi_recv_init(buf, count, datatype, src, tag, comm);
893 retval = MPI_SUCCESS;
896 if (retval != MPI_SUCCESS && request)
897 *request = MPI_REQUEST_NULL;
901 int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype,
902 int dst, int tag, MPI_Comm comm, MPI_Request* request)
907 if (request == NULL) {
908 retval = MPI_ERR_ARG;
909 } else if (comm == MPI_COMM_NULL) {
910 retval = MPI_ERR_COMM;
911 } else if (!is_datatype_valid(datatype)) {
912 retval = MPI_ERR_TYPE;
913 } else if (dst == MPI_PROC_NULL) {
914 retval = MPI_SUCCESS;
916 *request = smpi_mpi_ssend_init(buf, count, datatype, dst, tag, comm);
917 retval = MPI_SUCCESS;
920 if (retval != MPI_SUCCESS && request)
921 *request = MPI_REQUEST_NULL;
925 int PMPI_Start(MPI_Request * request)
930 if (request == NULL || *request == MPI_REQUEST_NULL) {
931 retval = MPI_ERR_REQUEST;
933 smpi_mpi_start(*request);
934 retval = MPI_SUCCESS;
940 int PMPI_Startall(int count, MPI_Request * requests)
945 if (requests == NULL) {
946 retval = MPI_ERR_ARG;
948 retval = MPI_SUCCESS;
949 for (i = 0 ; i < count ; i++) {
950 if(requests[i] == MPI_REQUEST_NULL) {
951 retval = MPI_ERR_REQUEST;
954 if(retval != MPI_ERR_REQUEST) {
955 smpi_mpi_startall(count, requests);
962 int PMPI_Request_free(MPI_Request * request)
967 if (*request == MPI_REQUEST_NULL) {
968 retval = MPI_ERR_ARG;
970 smpi_mpi_request_free(request);
971 retval = MPI_SUCCESS;
977 int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src,
978 int tag, MPI_Comm comm, MPI_Request * request)
984 if (request == NULL) {
985 retval = MPI_ERR_ARG;
986 } else if (comm == MPI_COMM_NULL) {
987 retval = MPI_ERR_COMM;
988 } else if (src == MPI_PROC_NULL) {
989 *request = MPI_REQUEST_NULL;
990 retval = MPI_SUCCESS;
991 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
992 retval = MPI_ERR_RANK;
993 } else if (count < 0) {
994 retval = MPI_ERR_COUNT;
995 } else if (buf==NULL && count > 0) {
996 retval = MPI_ERR_COUNT;
997 } else if (!is_datatype_valid(datatype)) {
998 retval = MPI_ERR_TYPE;
999 } else if(tag<0 && tag != MPI_ANY_TAG){
1000 retval = MPI_ERR_TAG;
1004 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1005 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1007 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1008 extra->type = TRACING_IRECV;
1009 extra->send_size = count;
1010 extra->src = src_traced;
1012 extra->datatype1 = encode_datatype(datatype);
1013 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
1016 *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm);
1017 retval = MPI_SUCCESS;
1020 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1021 (*request)->recv = 1;
1026 if (retval != MPI_SUCCESS && request)
1027 *request = MPI_REQUEST_NULL;
1032 int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
1033 int tag, MPI_Comm comm, MPI_Request * request)
1038 if (request == NULL) {
1039 retval = MPI_ERR_ARG;
1040 } else if (comm == MPI_COMM_NULL) {
1041 retval = MPI_ERR_COMM;
1042 } else if (dst == MPI_PROC_NULL) {
1043 *request = MPI_REQUEST_NULL;
1044 retval = MPI_SUCCESS;
1045 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1046 retval = MPI_ERR_RANK;
1047 } else if (count < 0) {
1048 retval = MPI_ERR_COUNT;
1049 } else if (buf==NULL && count > 0) {
1050 retval = MPI_ERR_COUNT;
1051 } else if (!is_datatype_valid(datatype)) {
1052 retval = MPI_ERR_TYPE;
1053 } else if(tag<0 && tag != MPI_ANY_TAG){
1054 retval = MPI_ERR_TAG;
1058 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1059 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1061 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1062 extra->type = TRACING_ISEND;
1063 extra->send_size = count;
1065 extra->dst = dst_traced;
1066 extra->datatype1 = encode_datatype(datatype);
1067 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
1068 TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype));
1071 *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm);
1072 retval = MPI_SUCCESS;
1075 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1076 (*request)->send = 1;
1081 if (retval != MPI_SUCCESS && request)
1082 *request = MPI_REQUEST_NULL;
1086 int PMPI_Issend(void* buf, int count, MPI_Datatype datatype,
1087 int dst, int tag, MPI_Comm comm, MPI_Request* request)
1092 if (request == NULL) {
1093 retval = MPI_ERR_ARG;
1094 } else if (comm == MPI_COMM_NULL) {
1095 retval = MPI_ERR_COMM;
1096 } else if (dst == MPI_PROC_NULL) {
1097 *request = MPI_REQUEST_NULL;
1098 retval = MPI_SUCCESS;
1099 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1100 retval = MPI_ERR_RANK;
1101 } else if (count < 0) {
1102 retval = MPI_ERR_COUNT;
1103 } else if (buf==NULL && count > 0) {
1104 retval = MPI_ERR_COUNT;
1105 } else if (!is_datatype_valid(datatype)) {
1106 retval = MPI_ERR_TYPE;
1107 } else if(tag<0 && tag != MPI_ANY_TAG){
1108 retval = MPI_ERR_TAG;
1112 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1113 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1114 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1115 extra->type = TRACING_ISSEND;
1116 extra->send_size = count;
1118 extra->dst = dst_traced;
1119 extra->datatype1 = encode_datatype(datatype);
1120 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
1121 TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype));
1124 *request = smpi_mpi_issend(buf, count, datatype, dst, tag, comm);
1125 retval = MPI_SUCCESS;
1128 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1129 (*request)->send = 1;
1134 if (retval != MPI_SUCCESS && request)
1135 *request = MPI_REQUEST_NULL;
1139 int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
1140 MPI_Comm comm, MPI_Status * status)
1145 if (comm == MPI_COMM_NULL) {
1146 retval = MPI_ERR_COMM;
1147 } else if (src == MPI_PROC_NULL) {
1148 smpi_empty_status(status);
1149 status->MPI_SOURCE = MPI_PROC_NULL;
1150 retval = MPI_SUCCESS;
1151 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
1152 retval = MPI_ERR_RANK;
1153 } else if (count < 0) {
1154 retval = MPI_ERR_COUNT;
1155 } else if (buf==NULL && count > 0) {
1156 retval = MPI_ERR_COUNT;
1157 } else if (!is_datatype_valid(datatype)) {
1158 retval = MPI_ERR_TYPE;
1159 } else if(tag<0 && tag != MPI_ANY_TAG){
1160 retval = MPI_ERR_TAG;
1163 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1164 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1165 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1166 extra->type = TRACING_RECV;
1167 extra->send_size = count;
1168 extra->src = src_traced;
1170 extra->datatype1 = encode_datatype(datatype);
1171 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
1174 smpi_mpi_recv(buf, count, datatype, src, tag, comm, status);
1175 retval = MPI_SUCCESS;
1178 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1179 if(status!=MPI_STATUS_IGNORE){
1180 src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
1181 TRACE_smpi_recv(rank, src_traced, rank);
1183 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1191 int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
1198 if (comm == MPI_COMM_NULL) {
1199 retval = MPI_ERR_COMM;
1200 } else if (dst == MPI_PROC_NULL) {
1201 retval = MPI_SUCCESS;
1202 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1203 retval = MPI_ERR_RANK;
1204 } else if (count < 0) {
1205 retval = MPI_ERR_COUNT;
1206 } else if (buf==NULL && count > 0) {
1207 retval = MPI_ERR_COUNT;
1208 } else if (!is_datatype_valid(datatype)) {
1209 retval = MPI_ERR_TYPE;
1210 } else if(tag<0 && tag != MPI_ANY_TAG){
1211 retval = MPI_ERR_TAG;
1215 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1216 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1217 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1218 extra->type = TRACING_SEND;
1219 extra->send_size = count;
1221 extra->dst = dst_traced;
1222 extra->datatype1 = encode_datatype(datatype);
1223 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
1224 TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype));
1227 smpi_mpi_send(buf, count, datatype, dst, tag, comm);
1228 retval = MPI_SUCCESS;
1231 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1241 int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
1246 if (comm == MPI_COMM_NULL) {
1247 retval = MPI_ERR_COMM;
1248 } else if (dst == MPI_PROC_NULL) {
1249 retval = MPI_SUCCESS;
1250 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1251 retval = MPI_ERR_RANK;
1252 } else if (count < 0) {
1253 retval = MPI_ERR_COUNT;
1254 } else if (buf==NULL && count > 0) {
1255 retval = MPI_ERR_COUNT;
1256 } else if (!is_datatype_valid(datatype)){
1257 retval = MPI_ERR_TYPE;
1258 } else if(tag<0 && tag != MPI_ANY_TAG){
1259 retval = MPI_ERR_TAG;
1263 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1264 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1265 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1266 extra->type = TRACING_SSEND;
1267 extra->send_size = count;
1269 extra->dst = dst_traced;
1270 extra->datatype1 = encode_datatype(datatype);
1271 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra); TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype));
1274 smpi_mpi_ssend(buf, count, datatype, dst, tag, comm);
1275 retval = MPI_SUCCESS;
1278 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1286 int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1287 int dst, int sendtag, void *recvbuf, int recvcount,
1288 MPI_Datatype recvtype, int src, int recvtag,
1289 MPI_Comm comm, MPI_Status * status)
1295 if (comm == MPI_COMM_NULL) {
1296 retval = MPI_ERR_COMM;
1297 } else if (!is_datatype_valid(sendtype)
1298 || !is_datatype_valid(recvtype)) {
1299 retval = MPI_ERR_TYPE;
1300 } else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
1301 smpi_empty_status(status);
1302 status->MPI_SOURCE = MPI_PROC_NULL;
1303 retval = MPI_SUCCESS;
1304 }else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0 ||
1305 (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0))){
1306 retval = MPI_ERR_RANK;
1307 } else if (sendcount < 0 || recvcount<0) {
1308 retval = MPI_ERR_COUNT;
1309 } else if ((sendbuf==NULL && sendcount > 0)||(recvbuf==NULL && recvcount>0)) {
1310 retval = MPI_ERR_COUNT;
1311 } else if((sendtag<0 && sendtag != MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){
1312 retval = MPI_ERR_TAG;
1316 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1317 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1318 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1319 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1320 extra->type = TRACING_SENDRECV;
1321 extra->send_size = sendcount;
1322 extra->recv_size = recvcount;
1323 extra->src = src_traced;
1324 extra->dst = dst_traced;
1325 extra->datatype1 = encode_datatype(sendtype);
1326 extra->datatype2 = encode_datatype(recvtype);
1328 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, extra);
1329 TRACE_smpi_send(rank, rank, dst_traced,sendcount*smpi_datatype_size(sendtype));
1333 smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf,
1334 recvcount, recvtype, src, recvtag, comm, status);
1335 retval = MPI_SUCCESS;
1338 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1339 TRACE_smpi_recv(rank, src_traced, rank);
1348 int PMPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
1349 int dst, int sendtag, int src, int recvtag,
1350 MPI_Comm comm, MPI_Status * status)
1352 //TODO: suboptimal implementation
1355 if (!is_datatype_valid(datatype)) {
1356 retval = MPI_ERR_TYPE;
1357 } else if (count < 0) {
1358 retval = MPI_ERR_COUNT;
1360 int size = smpi_datatype_get_extent(datatype) * count;
1361 recvbuf = xbt_new0(char, size);
1363 MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
1364 datatype, src, recvtag, comm, status);
1365 if(retval==MPI_SUCCESS){
1366 smpi_datatype_copy(recvbuf, count, datatype, buf, count, datatype);
1374 int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
1378 if (request == NULL || flag == NULL) {
1379 retval = MPI_ERR_ARG;
1380 } else if (*request == MPI_REQUEST_NULL) {
1382 smpi_empty_status(status);
1383 retval = MPI_ERR_REQUEST;
1386 int rank = request && (*request)->comm != MPI_COMM_NULL
1387 ? smpi_process_index()
1390 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1391 extra->type = TRACING_TEST;
1392 TRACE_smpi_testing_in(rank, extra);
1394 *flag = smpi_mpi_test(request, status);
1396 TRACE_smpi_testing_out(rank);
1398 retval = MPI_SUCCESS;
1404 int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
1405 MPI_Status * status)
1410 if (index == NULL || flag == NULL) {
1411 retval = MPI_ERR_ARG;
1413 *flag = smpi_mpi_testany(count, requests, index, status);
1414 retval = MPI_SUCCESS;
1420 int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses)
1426 retval = MPI_ERR_ARG;
1428 *flag = smpi_mpi_testall(count, requests, statuses);
1429 retval = MPI_SUCCESS;
1435 int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) {
1439 if (status == NULL) {
1440 retval = MPI_ERR_ARG;
1441 } else if (comm == MPI_COMM_NULL) {
1442 retval = MPI_ERR_COMM;
1443 } else if (source == MPI_PROC_NULL) {
1444 smpi_empty_status(status);
1445 status->MPI_SOURCE = MPI_PROC_NULL;
1446 retval = MPI_SUCCESS;
1448 smpi_mpi_probe(source, tag, comm, status);
1449 retval = MPI_SUCCESS;
1456 int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status) {
1461 retval = MPI_ERR_ARG;
1462 } else if (status == NULL) {
1463 retval = MPI_ERR_ARG;
1464 } else if (comm == MPI_COMM_NULL) {
1465 retval = MPI_ERR_COMM;
1466 } else if (source == MPI_PROC_NULL) {
1468 smpi_empty_status(status);
1469 status->MPI_SOURCE = MPI_PROC_NULL;
1470 retval = MPI_SUCCESS;
1472 smpi_mpi_iprobe(source, tag, comm, flag, status);
1473 retval = MPI_SUCCESS;
1479 int PMPI_Wait(MPI_Request * request, MPI_Status * status)
1485 smpi_empty_status(status);
1487 if (request == NULL) {
1488 retval = MPI_ERR_ARG;
1489 } else if (*request == MPI_REQUEST_NULL) {
1490 retval = MPI_ERR_REQUEST;
1494 int rank = request && (*request)->comm != MPI_COMM_NULL
1495 ? smpi_process_index()
1498 int src_traced = (*request)->src;
1499 int dst_traced = (*request)->dst;
1500 MPI_Comm comm = (*request)->comm;
1501 int is_wait_for_receive = (*request)->recv;
1502 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1503 extra->type = TRACING_WAIT;
1504 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, extra);
1507 smpi_mpi_wait(request, status);
1508 retval = MPI_SUCCESS;
1511 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1512 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1513 if (is_wait_for_receive) {
1514 if(src_traced==MPI_ANY_SOURCE)
1515 src_traced = (status!=MPI_STATUS_IGNORE) ?
1516 smpi_group_rank(smpi_comm_group(comm), status->MPI_SOURCE) :
1518 TRACE_smpi_recv(rank, src_traced, dst_traced);
1528 int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * status)
1535 //save requests information for tracing
1537 int *srcs = xbt_new0(int, count);
1538 int *dsts = xbt_new0(int, count);
1539 int *recvs = xbt_new0(int, count);
1540 MPI_Comm *comms = xbt_new0(MPI_Comm, count);
1542 for (i = 0; i < count; i++) {
1543 MPI_Request req = requests[i]; //already received requests are no longer valid
1547 recvs[i] = req->recv;
1548 comms[i] = req->comm;
1551 int rank_traced = smpi_process_index();
1552 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1553 extra->type = TRACING_WAITANY;
1554 extra->send_size=count;
1555 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,extra);
1558 *index = smpi_mpi_waitany(count, requests, status);
1560 if(*index!=MPI_UNDEFINED){
1561 int src_traced = srcs[*index];
1562 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1563 int dst_traced = dsts[*index];
1564 int is_wait_for_receive = recvs[*index];
1565 if (is_wait_for_receive) {
1566 if(srcs[*index]==MPI_ANY_SOURCE)
1567 src_traced = (status!=MPI_STATUSES_IGNORE) ?
1568 smpi_group_rank(smpi_comm_group(comms[*index]), status->MPI_SOURCE) :
1570 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1572 TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__);
1584 int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
1589 //save information from requests
1591 int *srcs = xbt_new0(int, count);
1592 int *dsts = xbt_new0(int, count);
1593 int *recvs = xbt_new0(int, count);
1594 int *valid = xbt_new0(int, count);
1595 MPI_Comm *comms = xbt_new0(MPI_Comm, count);
1597 //int valid_count = 0;
1598 for (i = 0; i < count; i++) {
1599 MPI_Request req = requests[i];
1600 if(req!=MPI_REQUEST_NULL){
1603 recvs[i] = req->recv;
1604 comms[i] = req->comm;
1610 int rank_traced = smpi_process_index();
1611 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1612 extra->type = TRACING_WAITALL;
1613 extra->send_size=count;
1614 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,extra);
1616 int retval = smpi_mpi_waitall(count, requests, status);
1618 for (i = 0; i < count; i++) {
1620 //int src_traced = srcs[*index];
1621 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1622 int src_traced = srcs[i];
1623 int dst_traced = dsts[i];
1624 int is_wait_for_receive = recvs[i];
1625 if (is_wait_for_receive) {
1626 if(src_traced==MPI_ANY_SOURCE)
1627 src_traced = (status!=MPI_STATUSES_IGNORE) ?
1628 smpi_group_rank(smpi_comm_group(comms[i]), status[i].MPI_SOURCE) :
1630 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1634 TRACE_smpi_ptp_out(rank_traced, -1, -1, __FUNCTION__);
1646 int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
1647 int *indices, MPI_Status status[])
1652 if (outcount == NULL) {
1653 retval = MPI_ERR_ARG;
1655 *outcount = smpi_mpi_waitsome(incount, requests, indices, status);
1656 retval = MPI_SUCCESS;
1662 int PMPI_Testsome(int incount, MPI_Request requests[], int* outcount,
1663 int* indices, MPI_Status status[])
1668 if (outcount == NULL) {
1669 retval = MPI_ERR_ARG;
1671 *outcount = smpi_mpi_testsome(incount, requests, indices, status);
1672 retval = MPI_SUCCESS;
1679 int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
1685 if (comm == MPI_COMM_NULL) {
1686 retval = MPI_ERR_COMM;
1687 } else if (!is_datatype_valid(datatype)) {
1688 retval = MPI_ERR_ARG;
1691 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1692 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1694 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1695 extra->type = TRACING_BCAST;
1696 extra->send_size = count;
1697 extra->root = root_traced;
1698 extra->datatype1 = encode_datatype(datatype);
1699 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
1702 mpi_coll_bcast_fun(buf, count, datatype, root, comm);
1703 retval = MPI_SUCCESS;
1705 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1713 int PMPI_Barrier(MPI_Comm comm)
1719 if (comm == MPI_COMM_NULL) {
1720 retval = MPI_ERR_COMM;
1723 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1724 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1725 extra->type = TRACING_BARRIER;
1726 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
1728 mpi_coll_barrier_fun(comm);
1729 retval = MPI_SUCCESS;
1731 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1739 int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1740 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1741 int root, MPI_Comm comm)
1747 if (comm == MPI_COMM_NULL) {
1748 retval = MPI_ERR_COMM;
1749 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1750 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1751 retval = MPI_ERR_TYPE;
1752 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1753 ((smpi_comm_rank(comm) == root) && (recvcount <0))){
1754 retval = MPI_ERR_COUNT;
1757 char* sendtmpbuf = (char*) sendbuf;
1758 int sendtmpcount = sendcount;
1759 MPI_Datatype sendtmptype = sendtype;
1760 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1762 sendtmptype=recvtype;
1765 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1766 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1767 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1768 extra->type = TRACING_GATHER;
1769 extra->send_size = sendtmpcount;
1770 extra->recv_size = recvcount;
1771 extra->root = root_traced;
1772 extra->datatype1 = encode_datatype(sendtmptype);
1773 extra->datatype2 = encode_datatype(recvtype);
1775 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
1777 mpi_coll_gather_fun(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcount,
1778 recvtype, root, comm);
1781 retval = MPI_SUCCESS;
1783 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1791 int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1792 void *recvbuf, int *recvcounts, int *displs,
1793 MPI_Datatype recvtype, int root, MPI_Comm comm)
1799 if (comm == MPI_COMM_NULL) {
1800 retval = MPI_ERR_COMM;
1801 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1802 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1803 retval = MPI_ERR_TYPE;
1804 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1805 retval = MPI_ERR_COUNT;
1806 } else if (recvcounts == NULL || displs == NULL) {
1807 retval = MPI_ERR_ARG;
1809 char* sendtmpbuf = (char*) sendbuf;
1810 int sendtmpcount = sendcount;
1811 MPI_Datatype sendtmptype = sendtype;
1812 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1814 sendtmptype=recvtype;
1818 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1819 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1821 int size = smpi_comm_size(comm);
1822 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1823 extra->type = TRACING_GATHERV;
1824 extra->send_size = sendtmpcount;
1825 extra->recvcounts= xbt_malloc(size*sizeof(int));
1826 for(i=0; i< size; i++)//copy data to avoid bad free
1827 extra->recvcounts[i] = recvcounts[i];
1828 extra->num_processes = size;
1829 extra->root = root_traced;
1830 extra->datatype1 = encode_datatype(sendtmptype);
1831 extra->datatype2 = encode_datatype(recvtype);
1833 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
1835 smpi_mpi_gatherv(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcounts,
1836 displs, recvtype, root, comm);
1837 retval = MPI_SUCCESS;
1839 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1847 int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1848 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1855 if (comm == MPI_COMM_NULL) {
1856 retval = MPI_ERR_COMM;
1857 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1858 (recvtype == MPI_DATATYPE_NULL)){
1859 retval = MPI_ERR_TYPE;
1860 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1862 retval = MPI_ERR_COUNT;
1864 if(sendbuf == MPI_IN_PLACE) {
1865 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*recvcount*smpi_comm_rank(comm);
1866 sendcount=recvcount;
1870 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1871 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1872 extra->type = TRACING_ALLGATHER;
1873 extra->send_size = sendcount;
1874 extra->recv_size = recvcount;
1875 extra->datatype1 = encode_datatype(sendtype);
1876 extra->datatype2 = encode_datatype(recvtype);
1878 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
1880 mpi_coll_allgather_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1882 retval = MPI_SUCCESS;
1885 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1892 int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1893 void *recvbuf, int *recvcounts, int *displs,
1894 MPI_Datatype recvtype, MPI_Comm comm)
1900 if (comm == MPI_COMM_NULL) {
1901 retval = MPI_ERR_COMM;
1902 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1903 (recvtype == MPI_DATATYPE_NULL)){
1904 retval = MPI_ERR_TYPE;
1905 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1906 retval = MPI_ERR_COUNT;
1907 } else if (recvcounts == NULL || displs == NULL) {
1908 retval = MPI_ERR_ARG;
1911 if(sendbuf == MPI_IN_PLACE) {
1912 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*displs[smpi_comm_rank(comm)];
1913 sendcount=recvcounts[smpi_comm_rank(comm)];
1917 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1919 int size = smpi_comm_size(comm);
1920 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1921 extra->type = TRACING_ALLGATHERV;
1922 extra->send_size = sendcount;
1923 extra->recvcounts= xbt_malloc(size*sizeof(int));
1924 for(i=0; i< size; i++)//copy data to avoid bad free
1925 extra->recvcounts[i] = recvcounts[i];
1926 extra->num_processes = size;
1927 extra->datatype1 = encode_datatype(sendtype);
1928 extra->datatype2 = encode_datatype(recvtype);
1930 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
1932 mpi_coll_allgatherv_fun(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
1933 displs, recvtype, comm);
1934 retval = MPI_SUCCESS;
1936 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1944 int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1945 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1946 int root, MPI_Comm comm)
1952 if (comm == MPI_COMM_NULL) {
1953 retval = MPI_ERR_COMM;
1954 } else if (((smpi_comm_rank(comm)==root) && (!is_datatype_valid(sendtype)))
1955 || ((recvbuf !=MPI_IN_PLACE) && (!is_datatype_valid(recvtype)))){
1956 retval = MPI_ERR_TYPE;
1957 } else if ((sendbuf == recvbuf) ||
1958 ((smpi_comm_rank(comm)==root) && sendcount>0 && (sendbuf == NULL))){
1959 retval = MPI_ERR_BUFFER;
1962 if (recvbuf == MPI_IN_PLACE) {
1964 recvcount=sendcount;
1967 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1968 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1969 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1970 extra->type = TRACING_SCATTER;
1971 extra->send_size = sendcount;
1972 extra->recv_size= recvcount;
1973 extra->root = root_traced;
1974 extra->datatype1 = encode_datatype(sendtype);
1975 extra->datatype2 = encode_datatype(recvtype);
1977 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
1979 mpi_coll_scatter_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1980 recvtype, root, comm);
1981 retval = MPI_SUCCESS;
1983 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1991 int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
1992 MPI_Datatype sendtype, void *recvbuf, int recvcount,
1993 MPI_Datatype recvtype, int root, MPI_Comm comm)
1999 if (comm == MPI_COMM_NULL) {
2000 retval = MPI_ERR_COMM;
2001 } else if (sendcounts == NULL || displs == NULL) {
2002 retval = MPI_ERR_ARG;
2003 } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
2004 || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
2005 retval = MPI_ERR_TYPE;
2007 if (recvbuf == MPI_IN_PLACE) {
2009 recvcount=sendcounts[smpi_comm_rank(comm)];
2012 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2013 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
2015 int size = smpi_comm_size(comm);
2016 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2017 extra->type = TRACING_SCATTERV;
2018 extra->recv_size = recvcount;
2019 extra->sendcounts= xbt_malloc(size*sizeof(int));
2020 for(i=0; i< size; i++)//copy data to avoid bad free
2021 extra->sendcounts[i] = sendcounts[i];
2022 extra->num_processes = size;
2023 extra->root = root_traced;
2024 extra->datatype1 = encode_datatype(sendtype);
2025 extra->datatype2 = encode_datatype(recvtype);
2027 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
2030 smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
2031 recvcount, recvtype, root, comm);
2032 retval = MPI_SUCCESS;
2034 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
2042 int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
2043 MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
2049 if (comm == MPI_COMM_NULL) {
2050 retval = MPI_ERR_COMM;
2051 } else if (!is_datatype_valid(datatype) || op == MPI_OP_NULL) {
2052 retval = MPI_ERR_ARG;
2055 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2056 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
2057 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2058 extra->type = TRACING_REDUCE;
2059 extra->send_size = count;
2060 extra->datatype1 = encode_datatype(datatype);
2061 extra->root = root_traced;
2063 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
2065 mpi_coll_reduce_fun(sendbuf, recvbuf, count, datatype, op, root, comm);
2067 retval = MPI_SUCCESS;
2069 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
2077 int PMPI_Reduce_local(void *inbuf, void *inoutbuf, int count,
2078 MPI_Datatype datatype, MPI_Op op){
2082 if (!is_datatype_valid(datatype) || op == MPI_OP_NULL) {
2083 retval = MPI_ERR_ARG;
2085 smpi_op_apply(op, inbuf, inoutbuf, &count, &datatype);
2092 int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
2093 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2099 if (comm == MPI_COMM_NULL) {
2100 retval = MPI_ERR_COMM;
2101 } else if (!is_datatype_valid(datatype)) {
2102 retval = MPI_ERR_TYPE;
2103 } else if (op == MPI_OP_NULL) {
2104 retval = MPI_ERR_OP;
2107 char* sendtmpbuf = (char*) sendbuf;
2108 if( sendbuf == MPI_IN_PLACE ) {
2109 sendtmpbuf = (char *)xbt_malloc(count*smpi_datatype_get_extent(datatype));
2110 smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
2113 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2114 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2115 extra->type = TRACING_ALLREDUCE;
2116 extra->send_size = count;
2117 extra->datatype1 = encode_datatype(datatype);
2119 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2121 mpi_coll_allreduce_fun(sendtmpbuf, recvbuf, count, datatype, op, comm);
2123 if( sendbuf == MPI_IN_PLACE ) {
2124 xbt_free(sendtmpbuf);
2127 retval = MPI_SUCCESS;
2129 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2137 int PMPI_Scan(void *sendbuf, void *recvbuf, int count,
2138 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2144 if (comm == MPI_COMM_NULL) {
2145 retval = MPI_ERR_COMM;
2146 } else if (!is_datatype_valid(datatype)) {
2147 retval = MPI_ERR_TYPE;
2148 } else if (op == MPI_OP_NULL) {
2149 retval = MPI_ERR_OP;
2152 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2153 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2154 extra->type = TRACING_SCAN;
2155 extra->send_size = count;
2156 extra->datatype1 = encode_datatype(datatype);
2158 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2160 smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm);
2161 retval = MPI_SUCCESS;
2163 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2171 int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
2172 MPI_Op op, MPI_Comm comm){
2177 if (comm == MPI_COMM_NULL) {
2178 retval = MPI_ERR_COMM;
2179 } else if (!is_datatype_valid(datatype)) {
2180 retval = MPI_ERR_TYPE;
2181 } else if (op == MPI_OP_NULL) {
2182 retval = MPI_ERR_OP;
2185 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2186 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2187 extra->type = TRACING_EXSCAN;
2188 extra->send_size = count;
2189 extra->datatype1 = encode_datatype(datatype);
2191 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2193 smpi_mpi_exscan(sendbuf, recvbuf, count, datatype, op, comm);
2194 retval = MPI_SUCCESS;
2196 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2204 int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
2205 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2210 if (comm == MPI_COMM_NULL) {
2211 retval = MPI_ERR_COMM;
2212 } else if (!is_datatype_valid(datatype)) {
2213 retval = MPI_ERR_TYPE;
2214 } else if (op == MPI_OP_NULL) {
2215 retval = MPI_ERR_OP;
2216 } else if (recvcounts == NULL) {
2217 retval = MPI_ERR_ARG;
2220 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2222 int size = smpi_comm_size(comm);
2223 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2224 extra->type = TRACING_REDUCE_SCATTER;
2225 extra->send_size = 0;
2226 extra->recvcounts= xbt_malloc(size*sizeof(int));
2227 for(i=0; i< size; i++)//copy data to avoid bad free
2228 extra->recvcounts[i] = recvcounts[i];
2229 extra->num_processes = size;
2230 extra->datatype1 = encode_datatype(datatype);
2232 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2234 void* sendtmpbuf=sendbuf;
2235 if(sendbuf==MPI_IN_PLACE){
2239 mpi_coll_reduce_scatter_fun(sendtmpbuf, recvbuf, recvcounts,
2240 datatype, op, comm);
2241 retval = MPI_SUCCESS;
2243 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2251 int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
2252 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2257 if (comm == MPI_COMM_NULL) {
2258 retval = MPI_ERR_COMM;
2259 } else if (!is_datatype_valid(datatype)) {
2260 retval = MPI_ERR_TYPE;
2261 } else if (op == MPI_OP_NULL) {
2262 retval = MPI_ERR_OP;
2263 } else if (recvcount < 0) {
2264 retval = MPI_ERR_ARG;
2266 int count=smpi_comm_size(comm);
2269 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2270 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2271 extra->type = TRACING_REDUCE_SCATTER;
2272 extra->send_size = 0;
2273 extra->recvcounts= xbt_malloc(count*sizeof(int));
2274 for(i=0; i< count; i++)//copy data to avoid bad free
2275 extra->recvcounts[i] = recvcount;
2276 extra->num_processes = count;
2277 extra->datatype1 = encode_datatype(datatype);
2279 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2281 int* recvcounts=(int*)xbt_malloc(count);
2282 for (i=0; i<count;i++)recvcounts[i]=recvcount;
2283 mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts,
2284 datatype, op, comm);
2285 xbt_free(recvcounts);
2286 retval = MPI_SUCCESS;
2288 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2296 int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
2297 void *recvbuf, int recvcount, MPI_Datatype recvtype,
2304 if (comm == MPI_COMM_NULL) {
2305 retval = MPI_ERR_COMM;
2306 } else if (sendtype == MPI_DATATYPE_NULL
2307 || recvtype == MPI_DATATYPE_NULL) {
2308 retval = MPI_ERR_TYPE;
2311 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2312 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2313 extra->type = TRACING_ALLTOALL;
2314 extra->send_size = sendcount;
2315 extra->recv_size = recvcount;
2316 extra->datatype1 = encode_datatype(sendtype);
2317 extra->datatype2 = encode_datatype(recvtype);
2319 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2321 retval = mpi_coll_alltoall_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
2323 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2331 int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
2332 MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
2333 int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
2339 if (comm == MPI_COMM_NULL) {
2340 retval = MPI_ERR_COMM;
2341 } else if (sendtype == MPI_DATATYPE_NULL
2342 || recvtype == MPI_DATATYPE_NULL) {
2343 retval = MPI_ERR_TYPE;
2344 } else if (sendcounts == NULL || senddisps == NULL || recvcounts == NULL
2345 || recvdisps == NULL) {
2346 retval = MPI_ERR_ARG;
2349 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2351 int size = smpi_comm_size(comm);
2352 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2353 extra->type = TRACING_ALLTOALLV;
2354 extra->send_size = 0;
2355 extra->recv_size = 0;
2356 extra->recvcounts= xbt_malloc(size*sizeof(int));
2357 extra->sendcounts= xbt_malloc(size*sizeof(int));
2359 for(i=0; i< size; i++){//copy data to avoid bad free
2360 extra->send_size += sendcounts[i];
2361 extra->recv_size += recvcounts[i];
2363 extra->sendcounts[i] = sendcounts[i];
2364 extra->recvcounts[i] = recvcounts[i];
2366 extra->num_processes = size;
2368 extra->datatype1 = encode_datatype(sendtype);
2369 extra->datatype2 = encode_datatype(recvtype);
2371 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2374 mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, sendtype,
2375 recvbuf, recvcounts, recvdisps, recvtype,
2378 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2387 int PMPI_Get_processor_name(char *name, int *resultlen)
2389 int retval = MPI_SUCCESS;
2391 strncpy(name, SIMIX_host_get_name(SIMIX_host_self()),
2392 strlen(SIMIX_host_get_name(SIMIX_host_self())) < MPI_MAX_PROCESSOR_NAME - 1 ?
2393 strlen(SIMIX_host_get_name(SIMIX_host_self())) +1 :
2394 MPI_MAX_PROCESSOR_NAME - 1 );
2397 MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
2402 int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
2404 int retval = MPI_SUCCESS;
2407 if (status == NULL || count == NULL) {
2408 retval = MPI_ERR_ARG;
2409 } else if (!is_datatype_valid(datatype)) {
2410 retval = MPI_ERR_TYPE;
2412 size = smpi_datatype_size(datatype);
2415 } else if (status->count % size != 0) {
2416 retval = MPI_UNDEFINED;
2418 *count = smpi_mpi_get_count(status, datatype);
2424 int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type) {
2427 if (old_type == MPI_DATATYPE_NULL) {
2428 retval = MPI_ERR_TYPE;
2429 } else if (count<0){
2430 retval = MPI_ERR_COUNT;
2432 retval = smpi_datatype_contiguous(count, old_type, new_type, 0);
2437 int PMPI_Type_commit(MPI_Datatype* datatype) {
2440 if (datatype == NULL || *datatype == MPI_DATATYPE_NULL) {
2441 retval = MPI_ERR_TYPE;
2443 smpi_datatype_commit(datatype);
2444 retval = MPI_SUCCESS;
2450 int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2453 if (old_type == MPI_DATATYPE_NULL) {
2454 retval = MPI_ERR_TYPE;
2455 } else if (count<0 || blocklen<0){
2456 retval = MPI_ERR_COUNT;
2458 retval = smpi_datatype_vector(count, blocklen, stride, old_type, new_type);
2463 int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2466 if (old_type == MPI_DATATYPE_NULL) {
2467 retval = MPI_ERR_TYPE;
2468 } else if (count<0 || blocklen<0){
2469 retval = MPI_ERR_COUNT;
2471 retval = smpi_datatype_hvector(count, blocklen, stride, old_type, new_type);
2476 int PMPI_Type_create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2477 return MPI_Type_hvector(count, blocklen, stride, old_type, new_type);
2480 int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2483 if (old_type == MPI_DATATYPE_NULL) {
2484 retval = MPI_ERR_TYPE;
2485 } else if (count<0){
2486 retval = MPI_ERR_COUNT;
2488 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2493 int PMPI_Type_create_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2496 if (old_type == MPI_DATATYPE_NULL) {
2497 retval = MPI_ERR_TYPE;
2498 } else if (count<0){
2499 retval = MPI_ERR_COUNT;
2501 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2506 int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2509 if (old_type == MPI_DATATYPE_NULL) {
2510 retval = MPI_ERR_TYPE;
2511 } else if (count<0){
2512 retval = MPI_ERR_COUNT;
2514 int* blocklens=(int*)xbt_malloc(blocklength*count);
2515 for (i=0; i<count;i++)blocklens[i]=blocklength;
2516 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2517 xbt_free(blocklens);
2523 int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2526 if (old_type == MPI_DATATYPE_NULL) {
2527 retval = MPI_ERR_TYPE;
2528 } else if (count<0){
2529 retval = MPI_ERR_COUNT;
2531 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2536 int PMPI_Type_create_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2537 return PMPI_Type_hindexed(count, blocklens,indices,old_type,new_type);
2540 int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2543 if (old_type == MPI_DATATYPE_NULL) {
2544 retval = MPI_ERR_TYPE;
2545 } else if (count<0){
2546 retval = MPI_ERR_COUNT;
2548 int* blocklens=(int*)xbt_malloc(blocklength*count);
2549 for (i=0; i<count;i++)blocklens[i]=blocklength;
2550 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2551 xbt_free(blocklens);
2557 int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2561 retval = MPI_ERR_COUNT;
2563 retval = smpi_datatype_struct(count, blocklens, indices, old_types, new_type);
2568 int PMPI_Type_create_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2569 return PMPI_Type_struct(count, blocklens, indices, old_types, new_type);
2573 int PMPI_Error_class(int errorcode, int* errorclass) {
2574 // assume smpi uses only standard mpi error codes
2575 *errorclass=errorcode;
2580 int PMPI_Initialized(int* flag) {
2581 *flag=smpi_process_initialized();
2585 /* The topo part of MPI_COMM_WORLD should always be NULL. When other topologies
2586 * will be implemented, not only should we check if the topology is NULL, but
2587 * we should check if it is the good topology type (so we have to add a
2588 * MPIR_Topo_Type field, and replace the MPI_Topology field by an union)*/
2590 int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periodic, int reorder, MPI_Comm* comm_cart) {
2592 if (comm_old == MPI_COMM_NULL){
2593 retval = MPI_ERR_COMM;
2594 } else if (ndims < 0 ||
2595 (ndims > 0 && (dims == NULL ||
2596 periodic == NULL)) ||
2597 comm_cart == NULL) {
2598 retval = MPI_ERR_ARG;
2600 retval = smpi_mpi_cart_create(comm_old, ndims, dims, periodic, reorder, comm_cart);
2605 int PMPI_Cart_rank(MPI_Comm comm, int* coords, int* rank) {
2606 if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2607 return MPI_ERR_TOPOLOGY;
2609 if (coords == NULL) {
2612 return smpi_mpi_cart_rank(comm, coords, rank);
2615 int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* dest) {
2616 if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2617 return MPI_ERR_TOPOLOGY;
2619 if (source == NULL || dest == NULL || direction < 0 ) {
2622 return smpi_mpi_cart_shift(comm, direction, displ, source, dest);
2625 int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) {
2626 if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2627 return MPI_ERR_TOPOLOGY;
2629 if (rank < 0 || rank >= smpi_comm_size(comm)) {
2630 return MPI_ERR_RANK;
2635 if(coords == NULL) {
2638 return smpi_mpi_cart_coords(comm, rank, maxdims, coords);
2641 int PMPI_Cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) {
2642 if(comm == NULL || smpi_comm_topo(comm) == NULL) {
2643 return MPI_ERR_TOPOLOGY;
2645 if(maxdims <= 0 || dims == NULL || periods == NULL || coords == NULL) {
2648 return smpi_mpi_cart_get(comm, maxdims, dims, periods, coords);
2651 int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) {
2652 if (comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2653 return MPI_ERR_TOPOLOGY;
2655 if (ndims == NULL) {
2658 return smpi_mpi_cartdim_get(comm, ndims);
2661 int PMPI_Dims_create(int nnodes, int ndims, int* dims) {
2665 if (ndims < 1 || nnodes < 1) {
2666 return MPI_ERR_DIMS;
2669 return smpi_mpi_dims_create(nnodes, ndims, dims);
2672 int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
2673 if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2674 return MPI_ERR_TOPOLOGY;
2676 if (comm_new == NULL) {
2679 return smpi_mpi_cart_sub(comm, remain_dims, comm_new);
2682 int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype){
2683 if(oldtype == MPI_DATATYPE_NULL) {
2684 return MPI_ERR_TYPE;
2686 int blocks[3] = { 1, 1, 1 };
2687 MPI_Aint disps[3] = { lb, 0, lb+extent };
2688 MPI_Datatype types[3] = { MPI_LB, oldtype, MPI_UB };
2690 s_smpi_mpi_struct_t* subtype = smpi_datatype_struct_create( blocks,
2695 smpi_datatype_create(newtype,oldtype->size, lb, lb + extent, 1 , subtype, DT_FLAG_VECTOR);
2697 (*newtype)->flags &= ~DT_FLAG_COMMITED;
2703 int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win){
2706 if (comm == MPI_COMM_NULL) {
2707 retval= MPI_ERR_COMM;
2708 }else if ((base == NULL && size != 0)
2709 || disp_unit <= 0 || size < 0 ){
2710 retval= MPI_ERR_OTHER;
2712 *win = smpi_mpi_win_create( base, size, disp_unit, info, comm);
2713 retval = MPI_SUCCESS;
2719 int PMPI_Win_free( MPI_Win* win){
2722 if (win == NULL || *win == MPI_WIN_NULL) {
2723 retval = MPI_ERR_WIN;
2725 retval=smpi_mpi_win_free(win);
2731 int PMPI_Win_set_name(MPI_Win win, char * name)
2734 if (win == MPI_WIN_NULL) {
2735 retval = MPI_ERR_TYPE;
2736 } else if (name == NULL) {
2737 retval = MPI_ERR_ARG;
2739 smpi_mpi_win_set_name(win, name);
2740 retval = MPI_SUCCESS;
2745 int PMPI_Win_get_name(MPI_Win win, char * name, int* len)
2747 int retval = MPI_SUCCESS;
2749 if (win == MPI_WIN_NULL) {
2750 retval = MPI_ERR_WIN;
2751 } else if (name == NULL) {
2752 retval = MPI_ERR_ARG;
2754 smpi_mpi_win_get_name(win, name, len);
2759 int PMPI_Win_get_group(MPI_Win win, MPI_Group * group){
2760 int retval = MPI_SUCCESS;
2761 if (win == MPI_WIN_NULL) {
2762 retval = MPI_ERR_WIN;
2764 smpi_mpi_win_get_group(win, group);
2770 int PMPI_Win_fence( int assert, MPI_Win win){
2773 if (win == MPI_WIN_NULL) {
2774 retval = MPI_ERR_WIN;
2776 retval = smpi_mpi_win_fence(assert, win);
2782 int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2783 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
2786 if (win == MPI_WIN_NULL) {
2787 retval = MPI_ERR_WIN;
2788 } else if (target_rank == MPI_PROC_NULL) {
2789 retval = MPI_SUCCESS;
2790 } else if (target_rank <0){
2791 retval = MPI_ERR_RANK;
2792 } else if (target_disp <0){
2793 retval = MPI_ERR_ARG;
2794 } else if (origin_count < 0 || target_count < 0) {
2795 retval = MPI_ERR_COUNT;
2796 } else if (origin_addr==NULL && origin_count > 0){
2797 retval = MPI_ERR_COUNT;
2798 } else if ((!is_datatype_valid(origin_datatype)) ||
2799 (!is_datatype_valid(target_datatype))) {
2800 retval = MPI_ERR_TYPE;
2802 retval = smpi_mpi_get( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, target_datatype, win);
2808 int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2809 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
2812 if (win == MPI_WIN_NULL) {
2813 retval = MPI_ERR_WIN;
2814 } else if (target_rank == MPI_PROC_NULL) {
2815 retval = MPI_SUCCESS;
2816 } else if (target_rank <0){
2817 retval = MPI_ERR_RANK;
2818 } else if (target_disp <0){
2819 retval = MPI_ERR_ARG;
2820 } else if (origin_count < 0 || target_count < 0) {
2821 retval = MPI_ERR_COUNT;
2822 } else if (origin_addr==NULL && origin_count > 0){
2823 retval = MPI_ERR_COUNT;
2824 } else if ((!is_datatype_valid(origin_datatype)) ||
2825 (!is_datatype_valid(target_datatype))) {
2826 retval = MPI_ERR_TYPE;
2828 retval = smpi_mpi_put( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, target_datatype, win);
2835 int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2836 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
2839 if (win == MPI_WIN_NULL) {
2840 retval = MPI_ERR_WIN;
2841 } else if (target_rank == MPI_PROC_NULL) {
2842 retval = MPI_SUCCESS;
2843 } else if (target_rank <0){
2844 retval = MPI_ERR_RANK;
2845 } else if (target_disp <0){
2846 retval = MPI_ERR_ARG;
2847 } else if (origin_count < 0 || target_count < 0) {
2848 retval = MPI_ERR_COUNT;
2849 } else if (origin_addr==NULL && origin_count > 0){
2850 retval = MPI_ERR_COUNT;
2851 } else if ((!is_datatype_valid(origin_datatype)) ||
2852 (!is_datatype_valid(target_datatype))) {
2853 retval = MPI_ERR_TYPE;
2854 } else if (op == MPI_OP_NULL) {
2855 retval = MPI_ERR_OP;
2857 retval = smpi_mpi_accumulate( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, target_datatype, op, win);
2864 int PMPI_Alloc_mem(MPI_Aint size, MPI_Info info, void *baseptr){
2865 void *ptr = xbt_malloc(size);
2867 return MPI_ERR_NO_MEM;
2869 *(void **)baseptr = ptr;
2874 int PMPI_Free_mem(void *baseptr){
2879 int PMPI_Type_set_name(MPI_Datatype datatype, char * name)
2882 if (datatype == MPI_DATATYPE_NULL) {
2883 retval = MPI_ERR_TYPE;
2884 } else if (name == NULL) {
2885 retval = MPI_ERR_ARG;
2887 smpi_datatype_set_name(datatype, name);
2888 retval = MPI_SUCCESS;
2893 int PMPI_Type_get_name(MPI_Datatype datatype, char * name, int* len)
2897 if (datatype == MPI_DATATYPE_NULL) {
2898 retval = MPI_ERR_TYPE;
2899 } else if (name == NULL) {
2900 retval = MPI_ERR_ARG;
2902 smpi_datatype_get_name(datatype, name, len);
2903 retval = MPI_SUCCESS;
2909 MPI_Datatype PMPI_Type_f2c(MPI_Fint datatype){
2910 return smpi_type_f2c(datatype);
2913 MPI_Fint PMPI_Type_c2f(MPI_Datatype datatype){
2914 return smpi_type_c2f( datatype);
2917 MPI_Group PMPI_Group_f2c(MPI_Fint group){
2918 return smpi_group_f2c( group);
2921 MPI_Fint PMPI_Group_c2f(MPI_Group group){
2922 return smpi_group_c2f(group);
2925 MPI_Request PMPI_Request_f2c(MPI_Fint request){
2926 return smpi_request_f2c(request);
2929 MPI_Fint PMPI_Request_c2f(MPI_Request request) {
2930 return smpi_request_c2f(request);
2933 MPI_Win PMPI_Win_f2c(MPI_Fint win){
2934 return smpi_win_f2c(win);
2937 MPI_Fint PMPI_Win_c2f(MPI_Win win){
2938 return smpi_win_c2f(win);
2941 MPI_Op PMPI_Op_f2c(MPI_Fint op){
2942 return smpi_op_f2c(op);
2945 MPI_Fint PMPI_Op_c2f(MPI_Op op){
2946 return smpi_op_c2f(op);
2949 MPI_Comm PMPI_Comm_f2c(MPI_Fint comm){
2950 return smpi_comm_f2c(comm);
2953 MPI_Fint PMPI_Comm_c2f(MPI_Comm comm){
2954 return smpi_comm_c2f(comm);
2957 int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
2958 return smpi_keyval_create(copy_fn, delete_fn, keyval, extra_state);
2961 int PMPI_Keyval_free(int* keyval) {
2962 return smpi_keyval_free(keyval);
2965 int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
2966 if(keyval == MPI_TAG_UB||keyval == MPI_HOST||keyval == MPI_IO
2967 ||keyval == MPI_WTIME_IS_GLOBAL||keyval == MPI_APPNUM
2968 ||keyval == MPI_UNIVERSE_SIZE||keyval == MPI_LASTUSEDCODE)
2970 else if (comm==MPI_COMM_NULL)
2971 return MPI_ERR_COMM;
2973 return smpi_attr_delete(comm, keyval);
2976 int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) {
2977 if (comm==MPI_COMM_NULL){
2979 return MPI_ERR_COMM;
2980 } else if(keyval == MPI_TAG_UB||keyval == MPI_HOST||keyval == MPI_IO
2981 ||keyval == MPI_WTIME_IS_GLOBAL||keyval == MPI_APPNUM
2982 ||keyval == MPI_UNIVERSE_SIZE||keyval == MPI_LASTUSEDCODE){
2984 //FIXME : not ideal and leaky, but should not be called too much
2985 int* res = xbt_new(int, 1);
2987 *(int**)attr_value=res;
2990 return smpi_attr_get(comm, keyval, attr_value, flag);
2993 int PMPI_Attr_put(MPI_Comm comm, int keyval, void* attr_value) {
2994 if(keyval == MPI_TAG_UB||keyval == MPI_HOST||keyval == MPI_IO
2995 ||keyval == MPI_WTIME_IS_GLOBAL||keyval == MPI_APPNUM
2996 ||keyval == MPI_UNIVERSE_SIZE||keyval == MPI_LASTUSEDCODE)
2998 else if (comm==MPI_COMM_NULL)
2999 return MPI_ERR_COMM;
3001 return smpi_attr_put(comm, keyval, attr_value);
3005 int PMPI_Comm_get_attr (MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag)
3007 return PMPI_Attr_get(comm, comm_keyval, attribute_val,flag);
3010 int PMPI_Comm_set_attr (MPI_Comm comm, int comm_keyval, void *attribute_val)
3012 return PMPI_Attr_put(comm, comm_keyval, attribute_val);
3015 int PMPI_Comm_delete_attr (MPI_Comm comm, int comm_keyval)
3017 return PMPI_Attr_delete(comm, comm_keyval);
3020 int PMPI_Comm_create_keyval(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state)
3022 return PMPI_Keyval_create(copy_fn, delete_fn, keyval, extra_state);
3025 int PMPI_Comm_free_keyval(int* keyval) {
3026 return PMPI_Keyval_free(keyval);
3029 /* The following calls are not yet implemented and will fail at runtime. */
3030 /* Once implemented, please move them above this notice. */
3032 #define NOT_YET_IMPLEMENTED { \
3033 XBT_WARN("Not yet implemented : %s. Please contact the Simgrid team if support is needed", __FUNCTION__); \
3034 return MPI_SUCCESS; \
3038 MPI_Info PMPI_Info_f2c(MPI_Fint info){
3042 MPI_Fint PMPI_Info_c2f(MPI_Info info){
3046 MPI_Errhandler PMPI_Errhandler_f2c(MPI_Fint errhandler){
3050 MPI_Fint PMPI_Errhandler_c2f(MPI_Errhandler errhandler){
3054 int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
3059 int PMPI_Cart_map(MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank) {
3064 int PMPI_Graph_create(MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder, MPI_Comm* comm_graph) {
3068 int PMPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int* index, int* edges) {
3072 int PMPI_Graph_map(MPI_Comm comm_old, int nnodes, int* index, int* edges, int* newrank) {
3076 int PMPI_Graph_neighbors(MPI_Comm comm, int rank, int maxneighbors, int* neighbors) {
3080 int PMPI_Graph_neighbors_count(MPI_Comm comm, int rank, int* nneighbors) {
3084 int PMPI_Graphdims_get(MPI_Comm comm, int* nnodes, int* nedges) {
3088 int PMPI_Topo_test(MPI_Comm comm, int* top_type) {
3092 int PMPI_Errhandler_create(MPI_Handler_function* function, MPI_Errhandler* errhandler) {
3096 int PMPI_Errhandler_free(MPI_Errhandler* errhandler) {
3100 int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler* errhandler) {
3104 int PMPI_Error_string(int errorcode, char* string, int* resultlen) {
3108 int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler) {
3112 int PMPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler) {
3116 int PMPI_Win_set_errhandler(MPI_Win win, MPI_Errhandler errhandler) {
3120 int PMPI_Comm_get_errhandler(MPI_Comm comm, MPI_Errhandler* errhandler) {
3124 int PMPI_Cancel(MPI_Request* request) {
3128 int PMPI_Buffer_attach(void* buffer, int size) {
3132 int PMPI_Buffer_detach(void* buffer, int* size) {
3136 int PMPI_Comm_test_inter(MPI_Comm comm, int* flag) {
3140 int PMPI_Pcontrol(const int level )
3145 int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
3149 int PMPI_Type_get_attr (MPI_Datatype type, int type_keyval, void *attribute_val, int* flag)
3154 int PMPI_Type_set_attr (MPI_Datatype type, int type_keyval, void *attribute_val)
3159 int PMPI_Type_delete_attr (MPI_Datatype type, int comm_keyval)
3164 int PMPI_Type_create_keyval(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state)
3169 int PMPI_Type_free_keyval(int* keyval) {
3173 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
3177 int PMPI_Intercomm_merge(MPI_Comm comm, int high, MPI_Comm* comm_out) {
3181 int PMPI_Bsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
3185 int PMPI_Bsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
3189 int PMPI_Ibsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
3193 int PMPI_Comm_remote_group(MPI_Comm comm, MPI_Group* group) {
3197 int PMPI_Comm_remote_size(MPI_Comm comm, int* size) {
3201 int PMPI_Rsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
3205 int PMPI_Rsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
3209 int PMPI_Irsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
3213 int PMPI_Test_cancelled(MPI_Status* status, int* flag) {
3217 int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
3221 int PMPI_Pack_external_size(char *datarep, int incount, MPI_Datatype datatype, MPI_Aint *size){
3225 int PMPI_Pack_external(char *datarep, void *inbuf, int incount, MPI_Datatype datatype, void *outbuf, MPI_Aint outcount, MPI_Aint *position){
3229 int PMPI_Unpack_external( char *datarep, void *inbuf, MPI_Aint insize, MPI_Aint *position, void *outbuf, int outcount, MPI_Datatype datatype){
3233 int PMPI_Get_elements(MPI_Status* status, MPI_Datatype datatype, int* elements) {
3237 int PMPI_Info_create( MPI_Info *info){
3241 int PMPI_Info_set( MPI_Info info, char *key, char *value){
3245 int PMPI_Info_free( MPI_Info *info){
3249 int PMPI_Type_get_envelope( MPI_Datatype datatype, int *num_integers,
3250 int *num_addresses, int *num_datatypes, int *combiner){
3254 int PMPI_Type_get_contents(MPI_Datatype datatype, int max_integers, int max_addresses,
3255 int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses,
3256 MPI_Datatype* array_of_datatypes){
3260 int PMPI_Type_create_darray(int size, int rank, int ndims, int* array_of_gsizes,
3261 int* array_of_distribs, int* array_of_dargs, int* array_of_psizes,
3262 int order, MPI_Datatype oldtype, MPI_Datatype *newtype) {
3266 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){
3270 int PMPI_Type_match_size(int typeclass,int size,MPI_Datatype *datatype){
3274 int PMPI_Alltoallw( void *sendbuf, int *sendcnts, int *sdispls, MPI_Datatype *sendtypes,
3275 void *recvbuf, int *recvcnts, int *rdispls, MPI_Datatype *recvtypes,
3280 int PMPI_Comm_set_name(MPI_Comm comm, char* name){
3284 int PMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm * newcomm){
3288 int PMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm){
3292 int PMPI_Comm_set_info (MPI_Comm comm, MPI_Info info){
3296 int PMPI_Comm_get_info (MPI_Comm comm, MPI_Info* info){
3300 int PMPI_Info_get(MPI_Info info,char *key,int valuelen, char *value, int *flag){
3304 int PMPI_Comm_create_errhandler( MPI_Comm_errhandler_fn *function, MPI_Errhandler *errhandler){
3308 int PMPI_Add_error_class( int *errorclass){
3312 int PMPI_Add_error_code( int errorclass, int *errorcode){
3316 int PMPI_Add_error_string( int errorcode, char *string){
3320 int PMPI_Comm_call_errhandler(MPI_Comm comm,int errorcode){
3324 int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo){
3328 int PMPI_Info_delete(MPI_Info info, char *key){
3332 int PMPI_Info_get_nkeys( MPI_Info info, int *nkeys){
3336 int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){
3340 int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){
3344 int PMPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){
3348 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){
3352 int PMPI_Grequest_complete( MPI_Request request){
3356 int PMPI_Status_set_cancelled(MPI_Status *status,int flag){
3360 int PMPI_Status_set_elements( MPI_Status *status, MPI_Datatype datatype, int count){
3364 int PMPI_Comm_connect( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
3368 int PMPI_Publish_name( char *service_name, MPI_Info info, char *port_name){
3372 int PMPI_Unpublish_name( char *service_name, MPI_Info info, char *port_name){
3376 int PMPI_Lookup_name( char *service_name, MPI_Info info, char *port_name){
3380 int PMPI_Comm_join( int fd, MPI_Comm *intercomm){
3384 int PMPI_Open_port( MPI_Info info, char *port_name){
3388 int PMPI_Close_port(char *port_name){
3392 int PMPI_Comm_accept( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
3396 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){
3400 int PMPI_Comm_spawn_multiple( int count, char **array_of_commands, char*** array_of_argv,
3401 int* array_of_maxprocs, MPI_Info* array_of_info, int root,
3402 MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes){
3406 int PMPI_Comm_get_parent( MPI_Comm *parent){
3410 int PMPI_Win_complete(MPI_Win win){
3414 int PMPI_Win_lock(int lock_type, int rank, int assert, MPI_Win win) {
3418 int PMPI_Win_post(MPI_Group group, int assert, MPI_Win win){
3422 int PMPI_Win_start(MPI_Group group, int assert, MPI_Win win){
3426 int PMPI_Win_test(MPI_Win win, int *flag){
3430 int PMPI_Win_unlock(int rank, MPI_Win win){
3434 int PMPI_Win_wait(MPI_Win win){