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)
481 int retval, i, index;
483 if (group == MPI_GROUP_NULL) {
484 retval = MPI_ERR_GROUP;
485 } else if (newgroup == NULL) {
486 retval = MPI_ERR_ARG;
489 *newgroup = MPI_GROUP_EMPTY;
490 } else if (n == smpi_group_size(group)) {
492 if(group!= smpi_comm_group(MPI_COMM_WORLD)
493 && group != MPI_GROUP_NULL
494 && group != smpi_comm_group(MPI_COMM_SELF)
495 && group != MPI_GROUP_EMPTY)
496 smpi_group_use(group);
498 *newgroup = smpi_group_new(n);
499 for (i = 0; i < n; i++) {
500 index = smpi_group_index(group, ranks[i]);
501 smpi_group_set_mapping(*newgroup, index, i);
504 retval = MPI_SUCCESS;
509 int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
511 int retval, i, j, newsize, oldsize, index;
513 if (group == MPI_GROUP_NULL) {
514 retval = MPI_ERR_GROUP;
515 } else if (newgroup == NULL) {
516 retval = MPI_ERR_ARG;
520 if(group!= smpi_comm_group(MPI_COMM_WORLD)
521 && group != MPI_GROUP_NULL
522 && group != smpi_comm_group(MPI_COMM_SELF)
523 && group != MPI_GROUP_EMPTY)
524 smpi_group_use(group);
525 } else if (n == smpi_group_size(group)) {
526 *newgroup = MPI_GROUP_EMPTY;
528 oldsize=smpi_group_size(group);
529 newsize = oldsize - n;
530 *newgroup = smpi_group_new(newsize);
532 int* to_exclude=xbt_new0(int, smpi_group_size(group));
533 for(i=0; i<oldsize; i++)
536 to_exclude[ranks[i]]=1;
539 for(i=0; i<oldsize; i++){
540 if(to_exclude[i]==0){
541 index = smpi_group_index(group, i);
542 smpi_group_set_mapping(*newgroup, index, j);
547 xbt_free(to_exclude);
549 retval = MPI_SUCCESS;
554 int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
555 MPI_Group * newgroup)
557 int retval, i, j, rank, size, index;
559 if (group == MPI_GROUP_NULL) {
560 retval = MPI_ERR_GROUP;
561 } else if (newgroup == NULL) {
562 retval = MPI_ERR_ARG;
565 *newgroup = MPI_GROUP_EMPTY;
568 for (i = 0; i < n; i++) {
569 for (rank = ranges[i][0]; /* First */
570 rank >= 0; /* Last */
574 rank += ranges[i][2]; /* Stride */
575 if (ranges[i][0]<ranges[i][1]){
576 if(rank > ranges[i][1])
579 if(rank < ranges[i][1])
585 *newgroup = smpi_group_new(size);
587 for (i = 0; i < n; i++) {
588 for (rank = ranges[i][0]; /* First */
589 rank >= 0; /* Last */
591 index = smpi_group_index(group, rank);
592 smpi_group_set_mapping(*newgroup, index, j);
594 rank += ranges[i][2]; /* Stride */
595 if (ranges[i][0]<ranges[i][1]){
596 if(rank > ranges[i][1])
599 if(rank < ranges[i][1])
605 retval = MPI_SUCCESS;
610 int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
611 MPI_Group * newgroup)
613 int retval, i, rank, newrank,oldrank, size, index, add;
615 if (group == MPI_GROUP_NULL) {
616 retval = MPI_ERR_GROUP;
617 } else if (newgroup == NULL) {
618 retval = MPI_ERR_ARG;
622 if(group!= smpi_comm_group(MPI_COMM_WORLD)
623 && group != MPI_GROUP_NULL
624 && group != smpi_comm_group(MPI_COMM_SELF)
625 && group != MPI_GROUP_EMPTY)
626 smpi_group_use(group);
628 size = smpi_group_size(group);
629 for (i = 0; i < n; i++) {
630 for (rank = ranges[i][0]; /* First */
631 rank >= 0; /* Last */
635 rank += ranges[i][2]; /* Stride */
636 if (ranges[i][0]<ranges[i][1]){
637 if(rank > ranges[i][1])
640 if(rank < ranges[i][1])
646 *newgroup = MPI_GROUP_EMPTY;
648 *newgroup = smpi_group_new(size);
651 while (newrank < size) {
653 for (i = 0; i < n; i++) {
654 for (rank = ranges[i][0];rank >= 0;){
660 rank += ranges[i][2]; /* Stride */
662 if (ranges[i][0]<ranges[i][1]){
663 if(rank > ranges[i][1])
666 if(rank < ranges[i][1])
672 index = smpi_group_index(group, oldrank);
673 smpi_group_set_mapping(*newgroup, index, newrank);
681 retval = MPI_SUCCESS;
686 int PMPI_Comm_rank(MPI_Comm comm, int *rank)
689 if (comm == MPI_COMM_NULL) {
690 retval = MPI_ERR_COMM;
691 } else if (rank == NULL) {
692 retval = MPI_ERR_ARG;
694 *rank = smpi_comm_rank(comm);
695 retval = MPI_SUCCESS;
700 int PMPI_Comm_size(MPI_Comm comm, int *size)
703 if (comm == MPI_COMM_NULL) {
704 retval = MPI_ERR_COMM;
705 } else if (size == NULL) {
706 retval = MPI_ERR_ARG;
708 *size = smpi_comm_size(comm);
709 retval = MPI_SUCCESS;
714 int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len)
718 if (comm == MPI_COMM_NULL) {
719 retval = MPI_ERR_COMM;
720 } else if (name == NULL || len == NULL) {
721 retval = MPI_ERR_ARG;
723 smpi_comm_get_name(comm, name, len);
724 retval = MPI_SUCCESS;
729 int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
733 if (comm == MPI_COMM_NULL) {
734 retval = MPI_ERR_COMM;
735 } else if (group == NULL) {
736 retval = MPI_ERR_ARG;
738 *group = smpi_comm_group(comm);
739 if(*group!= smpi_comm_group(MPI_COMM_WORLD)
740 && *group != MPI_GROUP_NULL
741 && *group != smpi_comm_group(MPI_COMM_SELF)
742 && *group != MPI_GROUP_EMPTY)
743 smpi_group_use(*group);
744 retval = MPI_SUCCESS;
749 int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
753 if (comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) {
754 retval = MPI_ERR_COMM;
755 } else if (result == NULL) {
756 retval = MPI_ERR_ARG;
758 if (comm1 == comm2) { /* Same communicators means same groups */
762 smpi_group_compare(smpi_comm_group(comm1),
763 smpi_comm_group(comm2));
764 if (*result == MPI_IDENT) {
765 *result = MPI_CONGRUENT;
768 retval = MPI_SUCCESS;
773 int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm)
777 if (comm == MPI_COMM_NULL) {
778 retval = MPI_ERR_COMM;
779 } else if (newcomm == NULL) {
780 retval = MPI_ERR_ARG;
782 *newcomm = smpi_comm_new(smpi_comm_group(comm), smpi_comm_topo(comm));
783 retval = MPI_SUCCESS;
788 int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
792 if (comm == MPI_COMM_NULL) {
793 retval = MPI_ERR_COMM;
794 } else if (group == MPI_GROUP_NULL) {
795 retval = MPI_ERR_GROUP;
796 } else if (newcomm == NULL) {
797 retval = MPI_ERR_ARG;
798 } else if(smpi_group_rank(group,smpi_process_index())==MPI_UNDEFINED){
799 *newcomm= MPI_COMM_NULL;
800 retval = MPI_SUCCESS;
803 *newcomm = smpi_comm_new(group, NULL);
804 retval = MPI_SUCCESS;
809 int PMPI_Comm_free(MPI_Comm * comm)
814 retval = MPI_ERR_ARG;
815 } else if (*comm == MPI_COMM_NULL) {
816 retval = MPI_ERR_COMM;
818 smpi_comm_destroy(*comm);
819 *comm = MPI_COMM_NULL;
820 retval = MPI_SUCCESS;
825 int PMPI_Comm_disconnect(MPI_Comm * comm)
827 /* TODO: wait until all communication in comm are done */
831 retval = MPI_ERR_ARG;
832 } else if (*comm == MPI_COMM_NULL) {
833 retval = MPI_ERR_COMM;
835 smpi_comm_destroy(*comm);
836 *comm = MPI_COMM_NULL;
837 retval = MPI_SUCCESS;
842 int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out)
847 if (comm_out == NULL) {
848 retval = MPI_ERR_ARG;
849 } else if (comm == MPI_COMM_NULL) {
850 retval = MPI_ERR_COMM;
852 *comm_out = smpi_comm_split(comm, color, key);
853 retval = MPI_SUCCESS;
860 int PMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst,
861 int tag, MPI_Comm comm, MPI_Request * request)
866 if (request == NULL) {
867 retval = MPI_ERR_ARG;
868 } else if (comm == MPI_COMM_NULL) {
869 retval = MPI_ERR_COMM;
870 } else if (!is_datatype_valid(datatype)) {
871 retval = MPI_ERR_TYPE;
872 } else if (dst == MPI_PROC_NULL) {
873 retval = MPI_SUCCESS;
875 *request = smpi_mpi_send_init(buf, count, datatype, dst, tag, comm);
876 retval = MPI_SUCCESS;
879 if (retval != MPI_SUCCESS && request)
880 *request = MPI_REQUEST_NULL;
884 int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src,
885 int tag, MPI_Comm comm, MPI_Request * request)
890 if (request == NULL) {
891 retval = MPI_ERR_ARG;
892 } else if (comm == MPI_COMM_NULL) {
893 retval = MPI_ERR_COMM;
894 } else if (!is_datatype_valid(datatype)) {
895 retval = MPI_ERR_TYPE;
896 } else if (src == MPI_PROC_NULL) {
897 retval = MPI_SUCCESS;
899 *request = smpi_mpi_recv_init(buf, count, datatype, src, tag, comm);
900 retval = MPI_SUCCESS;
903 if (retval != MPI_SUCCESS && request)
904 *request = MPI_REQUEST_NULL;
908 int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype,
909 int dst, int tag, MPI_Comm comm, MPI_Request* request)
914 if (request == NULL) {
915 retval = MPI_ERR_ARG;
916 } else if (comm == MPI_COMM_NULL) {
917 retval = MPI_ERR_COMM;
918 } else if (!is_datatype_valid(datatype)) {
919 retval = MPI_ERR_TYPE;
920 } else if (dst == MPI_PROC_NULL) {
921 retval = MPI_SUCCESS;
923 *request = smpi_mpi_ssend_init(buf, count, datatype, dst, tag, comm);
924 retval = MPI_SUCCESS;
927 if (retval != MPI_SUCCESS && request)
928 *request = MPI_REQUEST_NULL;
932 int PMPI_Start(MPI_Request * request)
937 if (request == NULL || *request == MPI_REQUEST_NULL) {
938 retval = MPI_ERR_REQUEST;
940 smpi_mpi_start(*request);
941 retval = MPI_SUCCESS;
947 int PMPI_Startall(int count, MPI_Request * requests)
952 if (requests == NULL) {
953 retval = MPI_ERR_ARG;
955 retval = MPI_SUCCESS;
956 for (i = 0 ; i < count ; i++) {
957 if(requests[i] == MPI_REQUEST_NULL) {
958 retval = MPI_ERR_REQUEST;
961 if(retval != MPI_ERR_REQUEST) {
962 smpi_mpi_startall(count, requests);
969 int PMPI_Request_free(MPI_Request * request)
974 if (*request == MPI_REQUEST_NULL) {
975 retval = MPI_ERR_ARG;
977 smpi_mpi_request_free(request);
978 retval = MPI_SUCCESS;
984 int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src,
985 int tag, MPI_Comm comm, MPI_Request * request)
991 if (request == NULL) {
992 retval = MPI_ERR_ARG;
993 } else if (comm == MPI_COMM_NULL) {
994 retval = MPI_ERR_COMM;
995 } else if (src == MPI_PROC_NULL) {
996 *request = MPI_REQUEST_NULL;
997 retval = MPI_SUCCESS;
998 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
999 retval = MPI_ERR_RANK;
1000 } else if (count < 0) {
1001 retval = MPI_ERR_COUNT;
1002 } else if (buf==NULL && count > 0) {
1003 retval = MPI_ERR_COUNT;
1004 } else if (!is_datatype_valid(datatype)) {
1005 retval = MPI_ERR_TYPE;
1006 } else if(tag<0 && tag != MPI_ANY_TAG){
1007 retval = MPI_ERR_TAG;
1011 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1012 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1014 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1015 extra->type = TRACING_IRECV;
1016 extra->send_size = count;
1017 extra->src = src_traced;
1019 extra->datatype1 = encode_datatype(datatype);
1020 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
1023 *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm);
1024 retval = MPI_SUCCESS;
1027 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1028 (*request)->recv = 1;
1033 if (retval != MPI_SUCCESS && request)
1034 *request = MPI_REQUEST_NULL;
1039 int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
1040 int tag, MPI_Comm comm, MPI_Request * request)
1045 if (request == NULL) {
1046 retval = MPI_ERR_ARG;
1047 } else if (comm == MPI_COMM_NULL) {
1048 retval = MPI_ERR_COMM;
1049 } else if (dst == MPI_PROC_NULL) {
1050 *request = MPI_REQUEST_NULL;
1051 retval = MPI_SUCCESS;
1052 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1053 retval = MPI_ERR_RANK;
1054 } else if (count < 0) {
1055 retval = MPI_ERR_COUNT;
1056 } else if (buf==NULL && count > 0) {
1057 retval = MPI_ERR_COUNT;
1058 } else if (!is_datatype_valid(datatype)) {
1059 retval = MPI_ERR_TYPE;
1060 } else if(tag<0 && tag != MPI_ANY_TAG){
1061 retval = MPI_ERR_TAG;
1065 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1066 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1068 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1069 extra->type = TRACING_ISEND;
1070 extra->send_size = count;
1072 extra->dst = dst_traced;
1073 extra->datatype1 = encode_datatype(datatype);
1074 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
1075 TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype));
1078 *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm);
1079 retval = MPI_SUCCESS;
1082 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1083 (*request)->send = 1;
1088 if (retval != MPI_SUCCESS && request)
1089 *request = MPI_REQUEST_NULL;
1093 int PMPI_Issend(void* buf, int count, MPI_Datatype datatype,
1094 int dst, int tag, MPI_Comm comm, MPI_Request* request)
1099 if (request == NULL) {
1100 retval = MPI_ERR_ARG;
1101 } else if (comm == MPI_COMM_NULL) {
1102 retval = MPI_ERR_COMM;
1103 } else if (dst == MPI_PROC_NULL) {
1104 *request = MPI_REQUEST_NULL;
1105 retval = MPI_SUCCESS;
1106 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1107 retval = MPI_ERR_RANK;
1108 } else if (count < 0) {
1109 retval = MPI_ERR_COUNT;
1110 } else if (buf==NULL && count > 0) {
1111 retval = MPI_ERR_COUNT;
1112 } else if (!is_datatype_valid(datatype)) {
1113 retval = MPI_ERR_TYPE;
1114 } else if(tag<0 && tag != MPI_ANY_TAG){
1115 retval = MPI_ERR_TAG;
1119 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1120 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1121 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1122 extra->type = TRACING_ISSEND;
1123 extra->send_size = count;
1125 extra->dst = dst_traced;
1126 extra->datatype1 = encode_datatype(datatype);
1127 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
1128 TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype));
1131 *request = smpi_mpi_issend(buf, count, datatype, dst, tag, comm);
1132 retval = MPI_SUCCESS;
1135 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1136 (*request)->send = 1;
1141 if (retval != MPI_SUCCESS && request)
1142 *request = MPI_REQUEST_NULL;
1146 int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
1147 MPI_Comm comm, MPI_Status * status)
1152 if (comm == MPI_COMM_NULL) {
1153 retval = MPI_ERR_COMM;
1154 } else if (src == MPI_PROC_NULL) {
1155 smpi_empty_status(status);
1156 status->MPI_SOURCE = MPI_PROC_NULL;
1157 retval = MPI_SUCCESS;
1158 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
1159 retval = MPI_ERR_RANK;
1160 } else if (count < 0) {
1161 retval = MPI_ERR_COUNT;
1162 } else if (buf==NULL && count > 0) {
1163 retval = MPI_ERR_COUNT;
1164 } else if (!is_datatype_valid(datatype)) {
1165 retval = MPI_ERR_TYPE;
1166 } else if(tag<0 && tag != MPI_ANY_TAG){
1167 retval = MPI_ERR_TAG;
1170 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1171 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1172 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1173 extra->type = TRACING_RECV;
1174 extra->send_size = count;
1175 extra->src = src_traced;
1177 extra->datatype1 = encode_datatype(datatype);
1178 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
1181 smpi_mpi_recv(buf, count, datatype, src, tag, comm, status);
1182 retval = MPI_SUCCESS;
1185 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1186 if(status!=MPI_STATUS_IGNORE){
1187 src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
1188 TRACE_smpi_recv(rank, src_traced, rank);
1190 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1198 int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
1205 if (comm == MPI_COMM_NULL) {
1206 retval = MPI_ERR_COMM;
1207 } else if (dst == MPI_PROC_NULL) {
1208 retval = MPI_SUCCESS;
1209 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1210 retval = MPI_ERR_RANK;
1211 } else if (count < 0) {
1212 retval = MPI_ERR_COUNT;
1213 } else if (buf==NULL && count > 0) {
1214 retval = MPI_ERR_COUNT;
1215 } else if (!is_datatype_valid(datatype)) {
1216 retval = MPI_ERR_TYPE;
1217 } else if(tag<0 && tag != MPI_ANY_TAG){
1218 retval = MPI_ERR_TAG;
1222 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1223 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1224 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1225 extra->type = TRACING_SEND;
1226 extra->send_size = count;
1228 extra->dst = dst_traced;
1229 extra->datatype1 = encode_datatype(datatype);
1230 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
1231 TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype));
1234 smpi_mpi_send(buf, count, datatype, dst, tag, comm);
1235 retval = MPI_SUCCESS;
1238 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1248 int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
1253 if (comm == MPI_COMM_NULL) {
1254 retval = MPI_ERR_COMM;
1255 } else if (dst == MPI_PROC_NULL) {
1256 retval = MPI_SUCCESS;
1257 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1258 retval = MPI_ERR_RANK;
1259 } else if (count < 0) {
1260 retval = MPI_ERR_COUNT;
1261 } else if (buf==NULL && count > 0) {
1262 retval = MPI_ERR_COUNT;
1263 } else if (!is_datatype_valid(datatype)){
1264 retval = MPI_ERR_TYPE;
1265 } else if(tag<0 && tag != MPI_ANY_TAG){
1266 retval = MPI_ERR_TAG;
1270 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1271 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1272 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1273 extra->type = TRACING_SSEND;
1274 extra->send_size = count;
1276 extra->dst = dst_traced;
1277 extra->datatype1 = encode_datatype(datatype);
1278 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra); TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype));
1281 smpi_mpi_ssend(buf, count, datatype, dst, tag, comm);
1282 retval = MPI_SUCCESS;
1285 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1293 int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1294 int dst, int sendtag, void *recvbuf, int recvcount,
1295 MPI_Datatype recvtype, int src, int recvtag,
1296 MPI_Comm comm, MPI_Status * status)
1302 if (comm == MPI_COMM_NULL) {
1303 retval = MPI_ERR_COMM;
1304 } else if (!is_datatype_valid(sendtype)
1305 || !is_datatype_valid(recvtype)) {
1306 retval = MPI_ERR_TYPE;
1307 } else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
1308 smpi_empty_status(status);
1309 status->MPI_SOURCE = MPI_PROC_NULL;
1310 retval = MPI_SUCCESS;
1311 }else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0 ||
1312 (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0))){
1313 retval = MPI_ERR_RANK;
1314 } else if (sendcount < 0 || recvcount<0) {
1315 retval = MPI_ERR_COUNT;
1316 } else if ((sendbuf==NULL && sendcount > 0)||(recvbuf==NULL && recvcount>0)) {
1317 retval = MPI_ERR_COUNT;
1318 } else if((sendtag<0 && sendtag != MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){
1319 retval = MPI_ERR_TAG;
1323 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1324 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1325 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1326 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1327 extra->type = TRACING_SENDRECV;
1328 extra->send_size = sendcount;
1329 extra->recv_size = recvcount;
1330 extra->src = src_traced;
1331 extra->dst = dst_traced;
1332 extra->datatype1 = encode_datatype(sendtype);
1333 extra->datatype2 = encode_datatype(recvtype);
1335 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, extra);
1336 TRACE_smpi_send(rank, rank, dst_traced,sendcount*smpi_datatype_size(sendtype));
1340 smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf,
1341 recvcount, recvtype, src, recvtag, comm, status);
1342 retval = MPI_SUCCESS;
1345 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1346 TRACE_smpi_recv(rank, src_traced, rank);
1355 int PMPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
1356 int dst, int sendtag, int src, int recvtag,
1357 MPI_Comm comm, MPI_Status * status)
1359 //TODO: suboptimal implementation
1362 if (!is_datatype_valid(datatype)) {
1363 retval = MPI_ERR_TYPE;
1364 } else if (count < 0) {
1365 retval = MPI_ERR_COUNT;
1367 int size = smpi_datatype_get_extent(datatype) * count;
1368 recvbuf = xbt_new0(char, size);
1370 MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
1371 datatype, src, recvtag, comm, status);
1372 if(retval==MPI_SUCCESS){
1373 smpi_datatype_copy(recvbuf, count, datatype, buf, count, datatype);
1381 int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
1385 if (request == NULL || flag == NULL) {
1386 retval = MPI_ERR_ARG;
1387 } else if (*request == MPI_REQUEST_NULL) {
1389 smpi_empty_status(status);
1390 retval = MPI_ERR_REQUEST;
1393 int rank = request && (*request)->comm != MPI_COMM_NULL
1394 ? smpi_process_index()
1397 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1398 extra->type = TRACING_TEST;
1399 TRACE_smpi_testing_in(rank, extra);
1401 *flag = smpi_mpi_test(request, status);
1403 TRACE_smpi_testing_out(rank);
1405 retval = MPI_SUCCESS;
1411 int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
1412 MPI_Status * status)
1417 if (index == NULL || flag == NULL) {
1418 retval = MPI_ERR_ARG;
1420 *flag = smpi_mpi_testany(count, requests, index, status);
1421 retval = MPI_SUCCESS;
1427 int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses)
1433 retval = MPI_ERR_ARG;
1435 *flag = smpi_mpi_testall(count, requests, statuses);
1436 retval = MPI_SUCCESS;
1442 int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) {
1446 if (status == NULL) {
1447 retval = MPI_ERR_ARG;
1448 } else if (comm == MPI_COMM_NULL) {
1449 retval = MPI_ERR_COMM;
1450 } else if (source == MPI_PROC_NULL) {
1451 smpi_empty_status(status);
1452 status->MPI_SOURCE = MPI_PROC_NULL;
1453 retval = MPI_SUCCESS;
1455 smpi_mpi_probe(source, tag, comm, status);
1456 retval = MPI_SUCCESS;
1463 int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status) {
1468 retval = MPI_ERR_ARG;
1469 } else if (status == NULL) {
1470 retval = MPI_ERR_ARG;
1471 } else if (comm == MPI_COMM_NULL) {
1472 retval = MPI_ERR_COMM;
1473 } else if (source == MPI_PROC_NULL) {
1475 smpi_empty_status(status);
1476 status->MPI_SOURCE = MPI_PROC_NULL;
1477 retval = MPI_SUCCESS;
1479 smpi_mpi_iprobe(source, tag, comm, flag, status);
1480 retval = MPI_SUCCESS;
1486 int PMPI_Wait(MPI_Request * request, MPI_Status * status)
1492 smpi_empty_status(status);
1494 if (request == NULL) {
1495 retval = MPI_ERR_ARG;
1496 } else if (*request == MPI_REQUEST_NULL) {
1497 retval = MPI_ERR_REQUEST;
1501 int rank = request && (*request)->comm != MPI_COMM_NULL
1502 ? smpi_process_index()
1505 int src_traced = (*request)->src;
1506 int dst_traced = (*request)->dst;
1507 MPI_Comm comm = (*request)->comm;
1508 int is_wait_for_receive = (*request)->recv;
1509 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1510 extra->type = TRACING_WAIT;
1511 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, extra);
1514 smpi_mpi_wait(request, status);
1515 retval = MPI_SUCCESS;
1518 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1519 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1520 if (is_wait_for_receive) {
1521 if(src_traced==MPI_ANY_SOURCE)
1522 src_traced = (status!=MPI_STATUS_IGNORE) ?
1523 smpi_group_rank(smpi_comm_group(comm), status->MPI_SOURCE) :
1525 TRACE_smpi_recv(rank, src_traced, dst_traced);
1535 int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * status)
1542 //save requests information for tracing
1544 int *srcs = xbt_new0(int, count);
1545 int *dsts = xbt_new0(int, count);
1546 int *recvs = xbt_new0(int, count);
1547 MPI_Comm *comms = xbt_new0(MPI_Comm, count);
1549 for (i = 0; i < count; i++) {
1550 MPI_Request req = requests[i]; //already received requests are no longer valid
1554 recvs[i] = req->recv;
1555 comms[i] = req->comm;
1558 int rank_traced = smpi_process_index();
1559 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1560 extra->type = TRACING_WAITANY;
1561 extra->send_size=count;
1562 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,extra);
1565 *index = smpi_mpi_waitany(count, requests, status);
1567 if(*index!=MPI_UNDEFINED){
1568 int src_traced = srcs[*index];
1569 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1570 int dst_traced = dsts[*index];
1571 int is_wait_for_receive = recvs[*index];
1572 if (is_wait_for_receive) {
1573 if(srcs[*index]==MPI_ANY_SOURCE)
1574 src_traced = (status!=MPI_STATUSES_IGNORE) ?
1575 smpi_group_rank(smpi_comm_group(comms[*index]), status->MPI_SOURCE) :
1577 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1579 TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__);
1591 int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
1596 //save information from requests
1598 int *srcs = xbt_new0(int, count);
1599 int *dsts = xbt_new0(int, count);
1600 int *recvs = xbt_new0(int, count);
1601 int *valid = xbt_new0(int, count);
1602 MPI_Comm *comms = xbt_new0(MPI_Comm, count);
1604 //int valid_count = 0;
1605 for (i = 0; i < count; i++) {
1606 MPI_Request req = requests[i];
1607 if(req!=MPI_REQUEST_NULL){
1610 recvs[i] = req->recv;
1611 comms[i] = req->comm;
1617 int rank_traced = smpi_process_index();
1618 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1619 extra->type = TRACING_WAITALL;
1620 extra->send_size=count;
1621 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,extra);
1623 int retval = smpi_mpi_waitall(count, requests, status);
1625 for (i = 0; i < count; i++) {
1627 //int src_traced = srcs[*index];
1628 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1629 int src_traced = srcs[i];
1630 int dst_traced = dsts[i];
1631 int is_wait_for_receive = recvs[i];
1632 if (is_wait_for_receive) {
1633 if(src_traced==MPI_ANY_SOURCE)
1634 src_traced = (status!=MPI_STATUSES_IGNORE) ?
1635 smpi_group_rank(smpi_comm_group(comms[i]), status[i].MPI_SOURCE) :
1637 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1641 TRACE_smpi_ptp_out(rank_traced, -1, -1, __FUNCTION__);
1653 int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
1654 int *indices, MPI_Status status[])
1659 if (outcount == NULL) {
1660 retval = MPI_ERR_ARG;
1662 *outcount = smpi_mpi_waitsome(incount, requests, indices, status);
1663 retval = MPI_SUCCESS;
1669 int PMPI_Testsome(int incount, MPI_Request requests[], int* outcount,
1670 int* indices, MPI_Status status[])
1675 if (outcount == NULL) {
1676 retval = MPI_ERR_ARG;
1678 *outcount = smpi_mpi_testsome(incount, requests, indices, status);
1679 retval = MPI_SUCCESS;
1686 int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
1692 if (comm == MPI_COMM_NULL) {
1693 retval = MPI_ERR_COMM;
1696 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1697 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1699 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1700 extra->type = TRACING_BCAST;
1701 extra->send_size = count;
1702 extra->root = root_traced;
1703 extra->datatype1 = encode_datatype(datatype);
1704 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
1707 mpi_coll_bcast_fun(buf, count, datatype, root, comm);
1708 retval = MPI_SUCCESS;
1710 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1718 int PMPI_Barrier(MPI_Comm comm)
1724 if (comm == MPI_COMM_NULL) {
1725 retval = MPI_ERR_COMM;
1728 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1729 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1730 extra->type = TRACING_BARRIER;
1731 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
1733 mpi_coll_barrier_fun(comm);
1734 retval = MPI_SUCCESS;
1736 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1744 int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1745 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1746 int root, MPI_Comm comm)
1752 if (comm == MPI_COMM_NULL) {
1753 retval = MPI_ERR_COMM;
1754 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1755 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1756 retval = MPI_ERR_TYPE;
1757 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1758 ((smpi_comm_rank(comm) == root) && (recvcount <0))){
1759 retval = MPI_ERR_COUNT;
1762 char* sendtmpbuf = (char*) sendbuf;
1763 int sendtmpcount = sendcount;
1764 MPI_Datatype sendtmptype = sendtype;
1765 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1767 sendtmptype=recvtype;
1770 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1771 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1772 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1773 extra->type = TRACING_GATHER;
1774 extra->send_size = sendtmpcount;
1775 extra->recv_size = recvcount;
1776 extra->root = root_traced;
1777 extra->datatype1 = encode_datatype(sendtmptype);
1778 extra->datatype2 = encode_datatype(recvtype);
1780 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
1782 mpi_coll_gather_fun(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcount,
1783 recvtype, root, comm);
1786 retval = MPI_SUCCESS;
1788 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1796 int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1797 void *recvbuf, int *recvcounts, int *displs,
1798 MPI_Datatype recvtype, int root, MPI_Comm comm)
1804 if (comm == MPI_COMM_NULL) {
1805 retval = MPI_ERR_COMM;
1806 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1807 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1808 retval = MPI_ERR_TYPE;
1809 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1810 retval = MPI_ERR_COUNT;
1811 } else if (recvcounts == NULL || displs == NULL) {
1812 retval = MPI_ERR_ARG;
1814 char* sendtmpbuf = (char*) sendbuf;
1815 int sendtmpcount = sendcount;
1816 MPI_Datatype sendtmptype = sendtype;
1817 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1819 sendtmptype=recvtype;
1823 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1824 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1826 int size = smpi_comm_size(comm);
1827 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1828 extra->type = TRACING_GATHERV;
1829 extra->send_size = sendtmpcount;
1830 extra->recvcounts= xbt_malloc(size*sizeof(int));
1831 for(i=0; i< size; i++)//copy data to avoid bad free
1832 extra->recvcounts[i] = recvcounts[i];
1833 extra->num_processes = size;
1834 extra->root = root_traced;
1835 extra->datatype1 = encode_datatype(sendtmptype);
1836 extra->datatype2 = encode_datatype(recvtype);
1838 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
1840 smpi_mpi_gatherv(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcounts,
1841 displs, recvtype, root, comm);
1842 retval = MPI_SUCCESS;
1844 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1852 int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1853 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1860 if (comm == MPI_COMM_NULL) {
1861 retval = MPI_ERR_COMM;
1862 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1863 (recvtype == MPI_DATATYPE_NULL)){
1864 retval = MPI_ERR_TYPE;
1865 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1867 retval = MPI_ERR_COUNT;
1869 if(sendbuf == MPI_IN_PLACE) {
1870 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*recvcount*smpi_comm_rank(comm);
1871 sendcount=recvcount;
1875 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1876 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1877 extra->type = TRACING_ALLGATHER;
1878 extra->send_size = sendcount;
1879 extra->recv_size = recvcount;
1880 extra->datatype1 = encode_datatype(sendtype);
1881 extra->datatype2 = encode_datatype(recvtype);
1883 TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
1885 mpi_coll_allgather_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1887 retval = MPI_SUCCESS;
1890 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1897 int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1898 void *recvbuf, int *recvcounts, int *displs,
1899 MPI_Datatype recvtype, MPI_Comm comm)
1905 if (comm == MPI_COMM_NULL) {
1906 retval = MPI_ERR_COMM;
1907 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1908 (recvtype == MPI_DATATYPE_NULL)){
1909 retval = MPI_ERR_TYPE;
1910 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1911 retval = MPI_ERR_COUNT;
1912 } else if (recvcounts == NULL || displs == NULL) {
1913 retval = MPI_ERR_ARG;
1916 if(sendbuf == MPI_IN_PLACE) {
1917 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*displs[smpi_comm_rank(comm)];
1918 sendcount=recvcounts[smpi_comm_rank(comm)];
1922 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1924 int size = smpi_comm_size(comm);
1925 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1926 extra->type = TRACING_ALLGATHERV;
1927 extra->send_size = sendcount;
1928 extra->recvcounts= xbt_malloc(size*sizeof(int));
1929 for(i=0; i< size; i++)//copy data to avoid bad free
1930 extra->recvcounts[i] = recvcounts[i];
1931 extra->num_processes = size;
1932 extra->datatype1 = encode_datatype(sendtype);
1933 extra->datatype2 = encode_datatype(recvtype);
1935 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
1937 mpi_coll_allgatherv_fun(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
1938 displs, recvtype, comm);
1939 retval = MPI_SUCCESS;
1941 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1949 int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1950 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1951 int root, MPI_Comm comm)
1957 if (comm == MPI_COMM_NULL) {
1958 retval = MPI_ERR_COMM;
1959 } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
1960 || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
1961 retval = MPI_ERR_TYPE;
1962 } else if ((sendbuf == recvbuf) ||
1963 ((smpi_comm_rank(comm)==root) && sendcount>0 && (sendbuf == NULL))){
1964 retval = MPI_ERR_BUFFER;
1967 if (recvbuf == MPI_IN_PLACE) {
1969 recvcount=sendcount;
1972 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1973 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1974 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
1975 extra->type = TRACING_SCATTER;
1976 extra->send_size = sendcount;
1977 extra->recv_size= recvcount;
1978 extra->root = root_traced;
1979 extra->datatype1 = encode_datatype(sendtype);
1980 extra->datatype2 = encode_datatype(recvtype);
1982 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
1984 mpi_coll_scatter_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1985 recvtype, root, comm);
1986 retval = MPI_SUCCESS;
1988 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1996 int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
1997 MPI_Datatype sendtype, void *recvbuf, int recvcount,
1998 MPI_Datatype recvtype, int root, MPI_Comm comm)
2004 if (comm == MPI_COMM_NULL) {
2005 retval = MPI_ERR_COMM;
2006 } else if (sendcounts == NULL || displs == NULL) {
2007 retval = MPI_ERR_ARG;
2008 } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
2009 || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
2010 retval = MPI_ERR_TYPE;
2012 if (recvbuf == MPI_IN_PLACE) {
2014 recvcount=sendcounts[smpi_comm_rank(comm)];
2017 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2018 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
2020 int size = smpi_comm_size(comm);
2021 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2022 extra->type = TRACING_SCATTERV;
2023 extra->recv_size = recvcount;
2024 extra->sendcounts= xbt_malloc(size*sizeof(int));
2025 for(i=0; i< size; i++)//copy data to avoid bad free
2026 extra->sendcounts[i] = sendcounts[i];
2027 extra->num_processes = size;
2028 extra->root = root_traced;
2029 extra->datatype1 = encode_datatype(sendtype);
2030 extra->datatype2 = encode_datatype(recvtype);
2032 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
2035 smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
2036 recvcount, recvtype, root, comm);
2037 retval = MPI_SUCCESS;
2039 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
2047 int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
2048 MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
2054 if (comm == MPI_COMM_NULL) {
2055 retval = MPI_ERR_COMM;
2056 } else if (!is_datatype_valid(datatype) || op == MPI_OP_NULL) {
2057 retval = MPI_ERR_ARG;
2060 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2061 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
2062 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2063 extra->type = TRACING_REDUCE;
2064 extra->send_size = count;
2065 extra->datatype1 = encode_datatype(datatype);
2066 extra->root = root_traced;
2068 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra);
2070 mpi_coll_reduce_fun(sendbuf, recvbuf, count, datatype, op, root, comm);
2072 retval = MPI_SUCCESS;
2074 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
2082 int PMPI_Reduce_local(void *inbuf, void *inoutbuf, int count,
2083 MPI_Datatype datatype, MPI_Op op){
2087 if (!is_datatype_valid(datatype) || op == MPI_OP_NULL) {
2088 retval = MPI_ERR_ARG;
2090 smpi_op_apply(op, inbuf, inoutbuf, &count, &datatype);
2097 int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
2098 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2104 if (comm == MPI_COMM_NULL) {
2105 retval = MPI_ERR_COMM;
2106 } else if (!is_datatype_valid(datatype)) {
2107 retval = MPI_ERR_TYPE;
2108 } else if (op == MPI_OP_NULL) {
2109 retval = MPI_ERR_OP;
2112 char* sendtmpbuf = (char*) sendbuf;
2113 if( sendbuf == MPI_IN_PLACE ) {
2114 sendtmpbuf = (char *)xbt_malloc(count*smpi_datatype_get_extent(datatype));
2115 smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
2118 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2119 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2120 extra->type = TRACING_ALLREDUCE;
2121 extra->send_size = count;
2122 extra->datatype1 = encode_datatype(datatype);
2124 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2126 mpi_coll_allreduce_fun(sendtmpbuf, recvbuf, count, datatype, op, comm);
2128 if( sendbuf == MPI_IN_PLACE ) {
2129 xbt_free(sendtmpbuf);
2132 retval = MPI_SUCCESS;
2134 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2142 int PMPI_Scan(void *sendbuf, void *recvbuf, int count,
2143 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2149 if (comm == MPI_COMM_NULL) {
2150 retval = MPI_ERR_COMM;
2151 } else if (!is_datatype_valid(datatype)) {
2152 retval = MPI_ERR_TYPE;
2153 } else if (op == MPI_OP_NULL) {
2154 retval = MPI_ERR_OP;
2157 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2158 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2159 extra->type = TRACING_SCAN;
2160 extra->send_size = count;
2161 extra->datatype1 = encode_datatype(datatype);
2163 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2165 smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm);
2166 retval = MPI_SUCCESS;
2168 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2176 int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
2177 MPI_Op op, MPI_Comm comm){
2182 if (comm == MPI_COMM_NULL) {
2183 retval = MPI_ERR_COMM;
2184 } else if (!is_datatype_valid(datatype)) {
2185 retval = MPI_ERR_TYPE;
2186 } else if (op == MPI_OP_NULL) {
2187 retval = MPI_ERR_OP;
2190 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2191 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2192 extra->type = TRACING_EXSCAN;
2193 extra->send_size = count;
2194 extra->datatype1 = encode_datatype(datatype);
2196 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2198 smpi_mpi_exscan(sendbuf, recvbuf, count, datatype, op, comm);
2199 retval = MPI_SUCCESS;
2201 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2209 int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
2210 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2215 if (comm == MPI_COMM_NULL) {
2216 retval = MPI_ERR_COMM;
2217 } else if (!is_datatype_valid(datatype)) {
2218 retval = MPI_ERR_TYPE;
2219 } else if (op == MPI_OP_NULL) {
2220 retval = MPI_ERR_OP;
2221 } else if (recvcounts == NULL) {
2222 retval = MPI_ERR_ARG;
2225 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2227 int size = smpi_comm_size(comm);
2228 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2229 extra->type = TRACING_REDUCE_SCATTER;
2230 extra->send_size = 0;
2231 extra->recvcounts= xbt_malloc(size*sizeof(int));
2232 for(i=0; i< size; i++)//copy data to avoid bad free
2233 extra->recvcounts[i] = recvcounts[i];
2234 extra->num_processes = size;
2235 extra->datatype1 = encode_datatype(datatype);
2237 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2239 void* sendtmpbuf=sendbuf;
2240 if(sendbuf==MPI_IN_PLACE){
2244 mpi_coll_reduce_scatter_fun(sendtmpbuf, recvbuf, recvcounts,
2245 datatype, op, comm);
2246 retval = MPI_SUCCESS;
2248 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2256 int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
2257 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2262 if (comm == MPI_COMM_NULL) {
2263 retval = MPI_ERR_COMM;
2264 } else if (!is_datatype_valid(datatype)) {
2265 retval = MPI_ERR_TYPE;
2266 } else if (op == MPI_OP_NULL) {
2267 retval = MPI_ERR_OP;
2268 } else if (recvcount < 0) {
2269 retval = MPI_ERR_ARG;
2271 int count=smpi_comm_size(comm);
2274 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2275 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2276 extra->type = TRACING_REDUCE_SCATTER;
2277 extra->send_size = 0;
2278 extra->recvcounts= xbt_malloc(count*sizeof(int));
2279 for(i=0; i< count; i++)//copy data to avoid bad free
2280 extra->recvcounts[i] = recvcount;
2281 extra->num_processes = count;
2282 extra->datatype1 = encode_datatype(datatype);
2284 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2286 int* recvcounts=(int*)xbt_malloc(count);
2287 for (i=0; i<count;i++)recvcounts[i]=recvcount;
2288 mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts,
2289 datatype, op, comm);
2290 xbt_free(recvcounts);
2291 retval = MPI_SUCCESS;
2293 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2301 int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
2302 void *recvbuf, int recvcount, MPI_Datatype recvtype,
2309 if (comm == MPI_COMM_NULL) {
2310 retval = MPI_ERR_COMM;
2311 } else if (sendtype == MPI_DATATYPE_NULL
2312 || recvtype == MPI_DATATYPE_NULL) {
2313 retval = MPI_ERR_TYPE;
2316 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2317 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2318 extra->type = TRACING_ALLTOALL;
2319 extra->send_size = sendcount;
2320 extra->recv_size = recvcount;
2321 extra->datatype1 = encode_datatype(sendtype);
2322 extra->datatype2 = encode_datatype(recvtype);
2324 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2326 retval = mpi_coll_alltoall_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
2328 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2336 int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
2337 MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
2338 int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
2344 if (comm == MPI_COMM_NULL) {
2345 retval = MPI_ERR_COMM;
2346 } else if (sendtype == MPI_DATATYPE_NULL
2347 || recvtype == MPI_DATATYPE_NULL) {
2348 retval = MPI_ERR_TYPE;
2349 } else if (sendcounts == NULL || senddisps == NULL || recvcounts == NULL
2350 || recvdisps == NULL) {
2351 retval = MPI_ERR_ARG;
2354 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2356 int size = smpi_comm_size(comm);
2357 instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
2358 extra->type = TRACING_ALLTOALLV;
2359 extra->send_size = 0;
2360 extra->recv_size = 0;
2361 extra->recvcounts= xbt_malloc(size*sizeof(int));
2362 extra->sendcounts= xbt_malloc(size*sizeof(int));
2364 for(i=0; i< size; i++){//copy data to avoid bad free
2365 extra->send_size += sendcounts[i];
2366 extra->recv_size += recvcounts[i];
2368 extra->sendcounts[i] = sendcounts[i];
2369 extra->recvcounts[i] = recvcounts[i];
2371 extra->num_processes = size;
2373 extra->datatype1 = encode_datatype(sendtype);
2374 extra->datatype2 = encode_datatype(recvtype);
2376 TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
2379 mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, sendtype,
2380 recvbuf, recvcounts, recvdisps, recvtype,
2383 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2392 int PMPI_Get_processor_name(char *name, int *resultlen)
2394 int retval = MPI_SUCCESS;
2396 strncpy(name, SIMIX_host_get_name(SIMIX_host_self()),
2397 strlen(SIMIX_host_get_name(SIMIX_host_self())) < MPI_MAX_PROCESSOR_NAME - 1 ?
2398 strlen(SIMIX_host_get_name(SIMIX_host_self())) +1 :
2399 MPI_MAX_PROCESSOR_NAME - 1 );
2402 MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
2407 int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
2409 int retval = MPI_SUCCESS;
2412 if (status == NULL || count == NULL) {
2413 retval = MPI_ERR_ARG;
2414 } else if (!is_datatype_valid(datatype)) {
2415 retval = MPI_ERR_TYPE;
2417 size = smpi_datatype_size(datatype);
2420 } else if (status->count % size != 0) {
2421 retval = MPI_UNDEFINED;
2423 *count = smpi_mpi_get_count(status, datatype);
2429 int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type) {
2432 if (old_type == MPI_DATATYPE_NULL) {
2433 retval = MPI_ERR_TYPE;
2434 } else if (count<0){
2435 retval = MPI_ERR_COUNT;
2437 retval = smpi_datatype_contiguous(count, old_type, new_type, 0);
2442 int PMPI_Type_commit(MPI_Datatype* datatype) {
2445 if (datatype == NULL || *datatype == MPI_DATATYPE_NULL) {
2446 retval = MPI_ERR_TYPE;
2448 smpi_datatype_commit(datatype);
2449 retval = MPI_SUCCESS;
2455 int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2458 if (old_type == MPI_DATATYPE_NULL) {
2459 retval = MPI_ERR_TYPE;
2460 } else if (count<0 || blocklen<0){
2461 retval = MPI_ERR_COUNT;
2463 retval = smpi_datatype_vector(count, blocklen, stride, old_type, new_type);
2468 int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2471 if (old_type == MPI_DATATYPE_NULL) {
2472 retval = MPI_ERR_TYPE;
2473 } else if (count<0 || blocklen<0){
2474 retval = MPI_ERR_COUNT;
2476 retval = smpi_datatype_hvector(count, blocklen, stride, old_type, new_type);
2481 int PMPI_Type_create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2482 return MPI_Type_hvector(count, blocklen, stride, old_type, new_type);
2485 int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2488 if (old_type == MPI_DATATYPE_NULL) {
2489 retval = MPI_ERR_TYPE;
2490 } else if (count<0){
2491 retval = MPI_ERR_COUNT;
2493 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2498 int PMPI_Type_create_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2501 if (old_type == MPI_DATATYPE_NULL) {
2502 retval = MPI_ERR_TYPE;
2503 } else if (count<0){
2504 retval = MPI_ERR_COUNT;
2506 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2511 int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2514 if (old_type == MPI_DATATYPE_NULL) {
2515 retval = MPI_ERR_TYPE;
2516 } else if (count<0){
2517 retval = MPI_ERR_COUNT;
2519 int* blocklens=(int*)xbt_malloc(blocklength*count);
2520 for (i=0; i<count;i++)blocklens[i]=blocklength;
2521 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2522 xbt_free(blocklens);
2528 int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2531 if (old_type == MPI_DATATYPE_NULL) {
2532 retval = MPI_ERR_TYPE;
2533 } else if (count<0){
2534 retval = MPI_ERR_COUNT;
2536 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2541 int PMPI_Type_create_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2542 return PMPI_Type_hindexed(count, blocklens,indices,old_type,new_type);
2545 int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2548 if (old_type == MPI_DATATYPE_NULL) {
2549 retval = MPI_ERR_TYPE;
2550 } else if (count<0){
2551 retval = MPI_ERR_COUNT;
2553 int* blocklens=(int*)xbt_malloc(blocklength*count);
2554 for (i=0; i<count;i++)blocklens[i]=blocklength;
2555 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2556 xbt_free(blocklens);
2562 int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2566 retval = MPI_ERR_COUNT;
2568 retval = smpi_datatype_struct(count, blocklens, indices, old_types, new_type);
2573 int PMPI_Type_create_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2574 return PMPI_Type_struct(count, blocklens, indices, old_types, new_type);
2578 int PMPI_Error_class(int errorcode, int* errorclass) {
2579 // assume smpi uses only standard mpi error codes
2580 *errorclass=errorcode;
2585 int PMPI_Initialized(int* flag) {
2586 *flag=smpi_process_initialized();
2590 /* The topo part of MPI_COMM_WORLD should always be NULL. When other topologies
2591 * will be implemented, not only should we check if the topology is NULL, but
2592 * we should check if it is the good topology type (so we have to add a
2593 * MPIR_Topo_Type field, and replace the MPI_Topology field by an union)*/
2595 int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periodic, int reorder, MPI_Comm* comm_cart) {
2597 if (comm_old == MPI_COMM_NULL){
2598 retval = MPI_ERR_COMM;
2599 } else if (ndims < 0 ||
2600 (ndims > 0 && (dims == NULL ||
2601 periodic == NULL)) ||
2602 comm_cart == NULL) {
2603 retval = MPI_ERR_ARG;
2605 retval = smpi_mpi_cart_create(comm_old, ndims, dims, periodic, reorder, comm_cart);
2610 int PMPI_Cart_rank(MPI_Comm comm, int* coords, int* rank) {
2611 if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2612 return MPI_ERR_TOPOLOGY;
2614 if (coords == NULL) {
2617 return smpi_mpi_cart_rank(comm, coords, rank);
2620 int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* dest) {
2621 if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2622 return MPI_ERR_TOPOLOGY;
2624 if (source == NULL || dest == NULL || direction < 0 ) {
2627 return smpi_mpi_cart_shift(comm, direction, displ, source, dest);
2630 int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) {
2631 if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2632 return MPI_ERR_TOPOLOGY;
2634 if (rank < 0 || rank >= smpi_comm_size(comm)) {
2635 return MPI_ERR_RANK;
2640 if(coords == NULL) {
2643 return smpi_mpi_cart_coords(comm, rank, maxdims, coords);
2646 int PMPI_Cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) {
2647 if(comm == NULL || smpi_comm_topo(comm) == NULL) {
2648 return MPI_ERR_TOPOLOGY;
2650 if(maxdims <= 0 || dims == NULL || periods == NULL || coords == NULL) {
2653 return smpi_mpi_cart_get(comm, maxdims, dims, periods, coords);
2656 int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) {
2657 if (comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2658 return MPI_ERR_TOPOLOGY;
2660 if (ndims == NULL) {
2663 return smpi_mpi_cartdim_get(comm, ndims);
2666 int PMPI_Dims_create(int nnodes, int ndims, int* dims) {
2670 if (ndims < 1 || nnodes < 1) {
2671 return MPI_ERR_DIMS;
2674 return smpi_mpi_dims_create(nnodes, ndims, dims);
2677 int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
2678 if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) {
2679 return MPI_ERR_TOPOLOGY;
2681 if (comm_new == NULL) {
2684 return smpi_mpi_cart_sub(comm, remain_dims, comm_new);
2687 int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype){
2688 if(oldtype == MPI_DATATYPE_NULL) {
2689 return MPI_ERR_TYPE;
2691 int blocks[3] = { 1, 1, 1 };
2692 MPI_Aint disps[3] = { lb, 0, lb+extent };
2693 MPI_Datatype types[3] = { MPI_LB, oldtype, MPI_UB };
2695 s_smpi_mpi_struct_t* subtype = smpi_datatype_struct_create( blocks,
2700 smpi_datatype_create(newtype,oldtype->size, lb, lb + extent, 1 , subtype, DT_FLAG_VECTOR);
2702 (*newtype)->flags &= ~DT_FLAG_COMMITED;
2708 int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win){
2711 if (comm == MPI_COMM_NULL) {
2712 retval= MPI_ERR_COMM;
2713 }else if ((base == NULL && size != 0)
2714 || disp_unit <= 0 || size < 0 ){
2715 retval= MPI_ERR_OTHER;
2717 *win = smpi_mpi_win_create( base, size, disp_unit, info, comm);
2718 retval = MPI_SUCCESS;
2724 int PMPI_Win_free( MPI_Win* win){
2727 if (win == NULL || *win == MPI_WIN_NULL) {
2728 retval = MPI_ERR_WIN;
2730 retval=smpi_mpi_win_free(win);
2736 int PMPI_Win_set_name(MPI_Win win, char * name)
2739 if (win == MPI_WIN_NULL) {
2740 retval = MPI_ERR_TYPE;
2741 } else if (name == NULL) {
2742 retval = MPI_ERR_ARG;
2744 smpi_mpi_win_set_name(win, name);
2745 retval = MPI_SUCCESS;
2750 int PMPI_Win_get_name(MPI_Win win, char * name, int* len)
2754 if (win == MPI_WIN_NULL) {
2755 retval = MPI_ERR_TYPE;
2756 } else if (name == NULL) {
2757 retval = MPI_ERR_ARG;
2759 smpi_mpi_win_get_name(win, name, len);
2760 retval = MPI_SUCCESS;
2766 int PMPI_Win_fence( int assert, MPI_Win win){
2769 if (win == MPI_WIN_NULL) {
2770 retval = MPI_ERR_WIN;
2772 retval = smpi_mpi_win_fence(assert, win);
2778 int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2779 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
2782 if (win == MPI_WIN_NULL) {
2783 retval = MPI_ERR_WIN;
2784 } else if (target_rank == MPI_PROC_NULL) {
2785 retval = MPI_SUCCESS;
2786 } else if (target_rank <0){
2787 retval = MPI_ERR_RANK;
2788 } else if (target_disp <0){
2789 retval = MPI_ERR_ARG;
2790 } else if (origin_count < 0 || target_count < 0) {
2791 retval = MPI_ERR_COUNT;
2792 } else if (origin_addr==NULL && origin_count > 0){
2793 retval = MPI_ERR_COUNT;
2794 } else if ((!is_datatype_valid(origin_datatype)) ||
2795 (!is_datatype_valid(target_datatype))) {
2796 retval = MPI_ERR_TYPE;
2798 retval = smpi_mpi_get( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, target_datatype, win);
2804 int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2805 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
2808 if (win == MPI_WIN_NULL) {
2809 retval = MPI_ERR_WIN;
2810 } else if (target_rank == MPI_PROC_NULL) {
2811 retval = MPI_SUCCESS;
2812 } else if (target_rank <0){
2813 retval = MPI_ERR_RANK;
2814 } else if (target_disp <0){
2815 retval = MPI_ERR_ARG;
2816 } else if (origin_count < 0 || target_count < 0) {
2817 retval = MPI_ERR_COUNT;
2818 } else if (origin_addr==NULL && origin_count > 0){
2819 retval = MPI_ERR_COUNT;
2820 } else if ((!is_datatype_valid(origin_datatype)) ||
2821 (!is_datatype_valid(target_datatype))) {
2822 retval = MPI_ERR_TYPE;
2824 retval = smpi_mpi_put( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, target_datatype, win);
2831 int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2832 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
2835 if (win == MPI_WIN_NULL) {
2836 retval = MPI_ERR_WIN;
2837 } else if (target_rank == MPI_PROC_NULL) {
2838 retval = MPI_SUCCESS;
2839 } else if (target_rank <0){
2840 retval = MPI_ERR_RANK;
2841 } else if (target_disp <0){
2842 retval = MPI_ERR_ARG;
2843 } else if (origin_count < 0 || target_count < 0) {
2844 retval = MPI_ERR_COUNT;
2845 } else if (origin_addr==NULL && origin_count > 0){
2846 retval = MPI_ERR_COUNT;
2847 } else if ((!is_datatype_valid(origin_datatype)) ||
2848 (!is_datatype_valid(target_datatype))) {
2849 retval = MPI_ERR_TYPE;
2850 } else if (op == MPI_OP_NULL) {
2851 retval = MPI_ERR_OP;
2853 retval = smpi_mpi_accumulate( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, target_datatype, op, win);
2860 int PMPI_Alloc_mem(MPI_Aint size, MPI_Info info, void *baseptr){
2861 void *ptr = xbt_malloc(size);
2863 return MPI_ERR_NO_MEM;
2865 *(void **)baseptr = ptr;
2870 int PMPI_Free_mem(void *baseptr){
2875 int PMPI_Type_set_name(MPI_Datatype datatype, char * name)
2878 if (datatype == MPI_DATATYPE_NULL) {
2879 retval = MPI_ERR_TYPE;
2880 } else if (name == NULL) {
2881 retval = MPI_ERR_ARG;
2883 smpi_datatype_set_name(datatype, name);
2884 retval = MPI_SUCCESS;
2889 int PMPI_Type_get_name(MPI_Datatype datatype, char * name, int* len)
2893 if (datatype == MPI_DATATYPE_NULL) {
2894 retval = MPI_ERR_TYPE;
2895 } else if (name == NULL) {
2896 retval = MPI_ERR_ARG;
2898 smpi_datatype_get_name(datatype, name, len);
2899 retval = MPI_SUCCESS;
2904 /* The following calls are not yet implemented and will fail at runtime. */
2905 /* Once implemented, please move them above this notice. */
2907 #define NOT_YET_IMPLEMENTED { \
2908 XBT_WARN("Not yet implemented : %s. Please contact the Simgrid team if support is needed", __FUNCTION__); \
2909 return MPI_SUCCESS; \
2914 int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
2919 int PMPI_Cart_map(MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank) {
2924 int PMPI_Graph_create(MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder, MPI_Comm* comm_graph) {
2928 int PMPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int* index, int* edges) {
2932 int PMPI_Graph_map(MPI_Comm comm_old, int nnodes, int* index, int* edges, int* newrank) {
2936 int PMPI_Graph_neighbors(MPI_Comm comm, int rank, int maxneighbors, int* neighbors) {
2940 int PMPI_Graph_neighbors_count(MPI_Comm comm, int rank, int* nneighbors) {
2944 int PMPI_Graphdims_get(MPI_Comm comm, int* nnodes, int* nedges) {
2948 int PMPI_Topo_test(MPI_Comm comm, int* top_type) {
2952 int PMPI_Errhandler_create(MPI_Handler_function* function, MPI_Errhandler* errhandler) {
2956 int PMPI_Errhandler_free(MPI_Errhandler* errhandler) {
2960 int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler* errhandler) {
2964 int PMPI_Error_string(int errorcode, char* string, int* resultlen) {
2968 int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler) {
2972 int PMPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler) {
2976 int PMPI_Win_set_errhandler(MPI_Win win, MPI_Errhandler errhandler) {
2980 int PMPI_Comm_get_errhandler(MPI_Comm comm, MPI_Errhandler* errhandler) {
2984 int PMPI_Cancel(MPI_Request* request) {
2988 int PMPI_Buffer_attach(void* buffer, int size) {
2992 int PMPI_Buffer_detach(void* buffer, int* size) {
2996 int PMPI_Comm_test_inter(MPI_Comm comm, int* flag) {
3000 int PMPI_Comm_get_attr (MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag)
3005 int PMPI_Comm_set_attr (MPI_Comm comm, int comm_keyval, void *attribute_val)
3010 int PMPI_Comm_delete_attr (MPI_Comm comm, int comm_keyval)
3015 int PMPI_Comm_create_keyval(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state)
3020 int PMPI_Comm_free_keyval(int* keyval) {
3024 int PMPI_Pcontrol(const int level )
3029 int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
3033 int PMPI_Type_get_attr (MPI_Datatype type, int type_keyval, void *attribute_val, int* flag)
3038 int PMPI_Type_set_attr (MPI_Datatype type, int type_keyval, void *attribute_val)
3043 int PMPI_Type_delete_attr (MPI_Datatype type, int comm_keyval)
3048 int PMPI_Type_create_keyval(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state)
3053 int PMPI_Type_free_keyval(int* keyval) {
3057 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
3061 int PMPI_Intercomm_merge(MPI_Comm comm, int high, MPI_Comm* comm_out) {
3065 int PMPI_Bsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
3069 int PMPI_Bsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
3073 int PMPI_Ibsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
3077 int PMPI_Comm_remote_group(MPI_Comm comm, MPI_Group* group) {
3081 int PMPI_Comm_remote_size(MPI_Comm comm, int* size) {
3085 int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
3089 int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) {
3093 int PMPI_Attr_put(MPI_Comm comm, int keyval, void* attr_value) {
3097 int PMPI_Rsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
3101 int PMPI_Rsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
3105 int PMPI_Irsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
3109 int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
3113 int PMPI_Keyval_free(int* keyval) {
3117 int PMPI_Test_cancelled(MPI_Status* status, int* flag) {
3121 int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
3125 int PMPI_Pack_external_size(char *datarep, int incount, MPI_Datatype datatype, MPI_Aint *size){
3129 int PMPI_Pack_external(char *datarep, void *inbuf, int incount, MPI_Datatype datatype, void *outbuf, MPI_Aint outcount, MPI_Aint *position){
3133 int PMPI_Unpack_external( char *datarep, void *inbuf, MPI_Aint insize, MPI_Aint *position, void *outbuf, int outcount, MPI_Datatype datatype){
3137 int PMPI_Get_elements(MPI_Status* status, MPI_Datatype datatype, int* elements) {
3141 int PMPI_Info_create( MPI_Info *info){
3145 int PMPI_Info_set( MPI_Info info, char *key, char *value){
3149 int PMPI_Info_free( MPI_Info *info){
3153 int PMPI_Type_get_envelope( MPI_Datatype datatype, int *num_integers,
3154 int *num_addresses, int *num_datatypes, int *combiner){
3158 int PMPI_Type_get_contents(MPI_Datatype datatype, int max_integers, int max_addresses,
3159 int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses,
3160 MPI_Datatype* array_of_datatypes){
3164 int PMPI_Type_create_darray(int size, int rank, int ndims, int* array_of_gsizes,
3165 int* array_of_distribs, int* array_of_dargs, int* array_of_psizes,
3166 int order, MPI_Datatype oldtype, MPI_Datatype *newtype) {
3170 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){
3174 int PMPI_Type_match_size(int typeclass,int size,MPI_Datatype *datatype){
3178 int PMPI_Alltoallw( void *sendbuf, int *sendcnts, int *sdispls, MPI_Datatype *sendtypes,
3179 void *recvbuf, int *recvcnts, int *rdispls, MPI_Datatype *recvtypes,
3184 int PMPI_Comm_set_name(MPI_Comm comm, char* name){
3188 int PMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm * newcomm){
3192 int PMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm){
3196 int PMPI_Comm_set_info (MPI_Comm comm, MPI_Info info){
3200 int PMPI_Comm_get_info (MPI_Comm comm, MPI_Info* info){
3204 int PMPI_Info_get(MPI_Info info,char *key,int valuelen, char *value, int *flag){
3208 int PMPI_Comm_create_errhandler( MPI_Comm_errhandler_fn *function, MPI_Errhandler *errhandler){
3212 int PMPI_Add_error_class( int *errorclass){
3216 int PMPI_Add_error_code( int errorclass, int *errorcode){
3220 int PMPI_Add_error_string( int errorcode, char *string){
3224 int PMPI_Comm_call_errhandler(MPI_Comm comm,int errorcode){
3228 int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo){
3232 int PMPI_Info_delete(MPI_Info info, char *key){
3236 int PMPI_Info_get_nkeys( MPI_Info info, int *nkeys){
3240 int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){
3244 int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){
3248 int PMPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){
3252 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){
3256 int PMPI_Grequest_complete( MPI_Request request){
3260 int PMPI_Status_set_cancelled(MPI_Status *status,int flag){
3264 int PMPI_Status_set_elements( MPI_Status *status, MPI_Datatype datatype, int count){
3268 int PMPI_Comm_connect( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
3272 int PMPI_Publish_name( char *service_name, MPI_Info info, char *port_name){
3276 int PMPI_Unpublish_name( char *service_name, MPI_Info info, char *port_name){
3280 int PMPI_Lookup_name( char *service_name, MPI_Info info, char *port_name){
3284 int PMPI_Comm_join( int fd, MPI_Comm *intercomm){
3288 int PMPI_Open_port( MPI_Info info, char *port_name){
3292 int PMPI_Close_port(char *port_name){
3296 int PMPI_Comm_accept( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
3300 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){
3304 int PMPI_Comm_spawn_multiple( int count, char **array_of_commands, char*** array_of_argv,
3305 int* array_of_maxprocs, MPI_Info* array_of_info, int root,
3306 MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes){
3310 int PMPI_Comm_get_parent( MPI_Comm *parent){