1 /* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
8 #include "smpi_mpi_dt_private.h"
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_pmpi, smpi,
11 "Logging specific to SMPI (pmpi)");
14 //this function need to be here because of the calls to smpi_bench
15 void TRACE_smpi_set_category(const char *category)
17 //need to end bench otherwise categories for execution tasks are wrong
19 TRACE_internal_smpi_set_category (category);
20 //begin bench after changing process's category
25 /* PMPI User level calls */
27 int PMPI_Init(int *argc, char ***argv)
29 smpi_process_init(argc, argv);
31 int rank = smpi_process_index();
32 TRACE_smpi_init(rank);
34 TRACE_smpi_computing_init(rank);
40 int PMPI_Finalize(void)
42 smpi_process_finalize();
45 int rank = smpi_process_index();
46 TRACE_smpi_computing_out(rank);
47 TRACE_smpi_finalize(smpi_process_index());
49 smpi_process_destroy();
53 int PMPI_Finalized(int* flag)
55 *flag=smpi_process_finalized();
59 int PMPI_Get_version (int *version,int *subversion){
60 *version = MPI_VERSION;
61 *subversion= MPI_SUBVERSION;
65 int PMPI_Get_library_version (char *version,int *len){
66 int retval = MPI_SUCCESS;
68 snprintf(version,MPI_MAX_LIBRARY_VERSION_STRING,"SMPI Version %d.%d. Copyright The Simgrid Team 2007-2013",SIMGRID_VERSION_MAJOR,
69 SIMGRID_VERSION_MINOR);
70 *len = strlen(version) > MPI_MAX_LIBRARY_VERSION_STRING ? MPI_MAX_LIBRARY_VERSION_STRING : strlen(version);
75 int PMPI_Init_thread(int *argc, char ***argv, int required, int *provided)
77 if (provided != NULL) {
78 *provided = MPI_THREAD_MULTIPLE;
80 return MPI_Init(argc, argv);
83 int PMPI_Query_thread(int *provided)
88 if (provided == NULL) {
91 *provided = MPI_THREAD_MULTIPLE;
98 int PMPI_Is_thread_main(int *flag)
104 retval = MPI_ERR_ARG;
106 *flag = smpi_process_index() == 0;
107 retval = MPI_SUCCESS;
113 int PMPI_Abort(MPI_Comm comm, int errorcode)
116 smpi_process_destroy();
118 int rank = smpi_process_index();
119 TRACE_smpi_computing_out(rank);
121 // FIXME: should kill all processes in comm instead
122 simcall_process_kill(SIMIX_process_self());
126 double PMPI_Wtime(void)
131 time = SIMIX_get_clock();
135 extern double sg_maxmin_precision;
136 double PMPI_Wtick(void)
138 return sg_maxmin_precision;
141 int PMPI_Address(void *location, MPI_Aint * address)
147 retval = MPI_ERR_ARG;
149 *address = (MPI_Aint) location;
150 retval = MPI_SUCCESS;
156 int PMPI_Get_address(void *location, MPI_Aint * address)
158 return PMPI_Address(location, address);
161 int PMPI_Type_free(MPI_Datatype * datatype)
167 retval = MPI_ERR_ARG;
169 smpi_datatype_free(datatype);
170 retval = MPI_SUCCESS;
176 int PMPI_Type_size(MPI_Datatype datatype, int *size)
181 if (datatype == MPI_DATATYPE_NULL) {
182 retval = MPI_ERR_TYPE;
183 } else if (size == NULL) {
184 retval = MPI_ERR_ARG;
186 *size = (int) smpi_datatype_size(datatype);
187 retval = MPI_SUCCESS;
193 int PMPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
198 if (datatype == MPI_DATATYPE_NULL) {
199 retval = MPI_ERR_TYPE;
200 } else if (lb == NULL || extent == NULL) {
201 retval = MPI_ERR_ARG;
203 retval = smpi_datatype_extent(datatype, lb, extent);
209 int PMPI_Type_get_true_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
211 return PMPI_Type_get_extent(datatype, lb, extent);
214 int PMPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent)
219 if (datatype == MPI_DATATYPE_NULL) {
220 retval = MPI_ERR_TYPE;
221 } else if (extent == NULL) {
222 retval = MPI_ERR_ARG;
224 *extent = smpi_datatype_get_extent(datatype);
225 retval = MPI_SUCCESS;
231 int PMPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp)
236 if (datatype == MPI_DATATYPE_NULL) {
237 retval = MPI_ERR_TYPE;
238 } else if (disp == NULL) {
239 retval = MPI_ERR_ARG;
241 *disp = smpi_datatype_lb(datatype);
242 retval = MPI_SUCCESS;
248 int PMPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp)
253 if (datatype == MPI_DATATYPE_NULL) {
254 retval = MPI_ERR_TYPE;
255 } else if (disp == NULL) {
256 retval = MPI_ERR_ARG;
258 *disp = smpi_datatype_ub(datatype);
259 retval = MPI_SUCCESS;
265 int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
270 if (function == NULL || op == NULL) {
271 retval = MPI_ERR_ARG;
273 *op = smpi_op_new(function, commute);
274 retval = MPI_SUCCESS;
280 int PMPI_Op_free(MPI_Op * op)
286 retval = MPI_ERR_ARG;
287 } else if (*op == MPI_OP_NULL) {
290 smpi_op_destroy(*op);
292 retval = MPI_SUCCESS;
298 int PMPI_Group_free(MPI_Group * group)
304 retval = MPI_ERR_ARG;
306 if(*group!= smpi_comm_group(MPI_COMM_WORLD))// do not free the group of the comm_world
307 smpi_group_destroy(*group);
308 *group = MPI_GROUP_NULL;
309 retval = MPI_SUCCESS;
315 int PMPI_Group_size(MPI_Group group, int *size)
320 if (group == MPI_GROUP_NULL) {
321 retval = MPI_ERR_GROUP;
322 } else if (size == NULL) {
323 retval = MPI_ERR_ARG;
325 *size = smpi_group_size(group);
326 retval = MPI_SUCCESS;
332 int PMPI_Group_rank(MPI_Group group, int *rank)
337 if (group == MPI_GROUP_NULL) {
338 retval = MPI_ERR_GROUP;
339 } else if (rank == NULL) {
340 retval = MPI_ERR_ARG;
342 *rank = smpi_group_rank(group, smpi_process_index());
343 retval = MPI_SUCCESS;
349 int PMPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
350 MPI_Group group2, int *ranks2)
352 int retval, i, index;
355 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
356 retval = MPI_ERR_GROUP;
358 for (i = 0; i < n; i++) {
359 index = smpi_group_index(group1, ranks1[i]);
360 ranks2[i] = smpi_group_rank(group2, index);
362 retval = MPI_SUCCESS;
368 int PMPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result)
373 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
374 retval = MPI_ERR_GROUP;
375 } else if (result == NULL) {
376 retval = MPI_ERR_ARG;
378 *result = smpi_group_compare(group1, group2);
379 retval = MPI_SUCCESS;
385 int PMPI_Group_union(MPI_Group group1, MPI_Group group2,
386 MPI_Group * newgroup)
388 int retval, i, proc1, proc2, size, size2;
391 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
392 retval = MPI_ERR_GROUP;
393 } else if (newgroup == NULL) {
394 retval = MPI_ERR_ARG;
396 size = smpi_group_size(group1);
397 size2 = smpi_group_size(group2);
398 for (i = 0; i < size2; i++) {
399 proc2 = smpi_group_index(group2, i);
400 proc1 = smpi_group_rank(group1, proc2);
401 if (proc1 == MPI_UNDEFINED) {
406 *newgroup = MPI_GROUP_EMPTY;
408 *newgroup = smpi_group_new(size);
409 size2 = smpi_group_size(group1);
410 for (i = 0; i < size2; i++) {
411 proc1 = smpi_group_index(group1, i);
412 smpi_group_set_mapping(*newgroup, proc1, i);
414 for (i = size2; i < size; i++) {
415 proc2 = smpi_group_index(group2, i - size2);
416 smpi_group_set_mapping(*newgroup, proc2, i);
419 smpi_group_use(*newgroup);
420 retval = MPI_SUCCESS;
426 int PMPI_Group_intersection(MPI_Group group1, MPI_Group group2,
427 MPI_Group * newgroup)
429 int retval, i, proc1, proc2, size;
432 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
433 retval = MPI_ERR_GROUP;
434 } else if (newgroup == NULL) {
435 retval = MPI_ERR_ARG;
437 size = smpi_group_size(group2);
438 for (i = 0; i < size; i++) {
439 proc2 = smpi_group_index(group2, i);
440 proc1 = smpi_group_rank(group1, proc2);
441 if (proc1 == MPI_UNDEFINED) {
446 *newgroup = MPI_GROUP_EMPTY;
448 *newgroup = smpi_group_new(size);
450 for (i = 0; i < smpi_group_size(group2); i++) {
451 proc2 = smpi_group_index(group2, i);
452 proc1 = smpi_group_rank(group1, proc2);
453 if (proc1 != MPI_UNDEFINED) {
454 smpi_group_set_mapping(*newgroup, proc2, j);
459 smpi_group_use(*newgroup);
460 retval = MPI_SUCCESS;
466 int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgroup)
468 int retval, i, proc1, proc2, size, size2;
471 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
472 retval = MPI_ERR_GROUP;
473 } else if (newgroup == NULL) {
474 retval = MPI_ERR_ARG;
476 size = size2 = smpi_group_size(group1);
477 for (i = 0; i < size2; i++) {
478 proc1 = smpi_group_index(group1, i);
479 proc2 = smpi_group_rank(group2, proc1);
480 if (proc2 != MPI_UNDEFINED) {
485 *newgroup = MPI_GROUP_EMPTY;
487 *newgroup = smpi_group_new(size);
488 for (i = 0; i < size2; i++) {
489 proc1 = smpi_group_index(group1, i);
490 proc2 = smpi_group_rank(group2, proc1);
491 if (proc2 == MPI_UNDEFINED) {
492 smpi_group_set_mapping(*newgroup, proc1, i);
496 smpi_group_use(*newgroup);
497 retval = MPI_SUCCESS;
503 int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
505 int retval, i, index;
508 if (group == MPI_GROUP_NULL) {
509 retval = MPI_ERR_GROUP;
510 } else if (newgroup == NULL) {
511 retval = MPI_ERR_ARG;
514 *newgroup = MPI_GROUP_EMPTY;
515 } else if (n == smpi_group_size(group)) {
518 *newgroup = smpi_group_new(n);
519 for (i = 0; i < n; i++) {
520 index = smpi_group_index(group, ranks[i]);
521 smpi_group_set_mapping(*newgroup, index, i);
524 smpi_group_use(*newgroup);
525 retval = MPI_SUCCESS;
531 int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
533 int retval, i, j, newsize, oldsize, index;
536 if (group == MPI_GROUP_NULL) {
537 retval = MPI_ERR_GROUP;
538 } else if (newgroup == NULL) {
539 retval = MPI_ERR_ARG;
543 } else if (n == smpi_group_size(group)) {
544 *newgroup = MPI_GROUP_EMPTY;
546 oldsize=smpi_group_size(group);
547 newsize = oldsize - n;
548 *newgroup = smpi_group_new(newsize);
550 int* to_exclude=xbt_new(int, smpi_group_size(group));
551 for(i=0; i<oldsize; i++)
554 to_exclude[ranks[i]]=1;
557 for(i=0; i<oldsize; i++){
558 if(to_exclude[i]==0){
559 index = smpi_group_index(group, i);
560 smpi_group_set_mapping(*newgroup, index, j);
565 xbt_free(to_exclude);
567 smpi_group_use(*newgroup);
568 retval = MPI_SUCCESS;
574 int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
575 MPI_Group * newgroup)
577 int retval, i, j, rank, size, index;
580 if (group == MPI_GROUP_NULL) {
581 retval = MPI_ERR_GROUP;
582 } else if (newgroup == NULL) {
583 retval = MPI_ERR_ARG;
586 *newgroup = MPI_GROUP_EMPTY;
589 for (i = 0; i < n; i++) {
590 for (rank = ranges[i][0]; /* First */
591 rank >= 0; /* Last */
595 rank += ranges[i][2]; /* Stride */
596 if (ranges[i][0]<ranges[i][1]){
597 if(rank > ranges[i][1])
600 if(rank < ranges[i][1])
606 *newgroup = smpi_group_new(size);
608 for (i = 0; i < n; i++) {
609 for (rank = ranges[i][0]; /* First */
610 rank >= 0; /* Last */
612 index = smpi_group_index(group, rank);
613 smpi_group_set_mapping(*newgroup, index, j);
615 rank += ranges[i][2]; /* Stride */
616 if (ranges[i][0]<ranges[i][1]){
617 if(rank > ranges[i][1])
620 if(rank < ranges[i][1])
627 smpi_group_use(*newgroup);
628 retval = MPI_SUCCESS;
634 int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
635 MPI_Group * newgroup)
637 int retval, i, newrank, rank, size, index, add;
640 if (group == MPI_GROUP_NULL) {
641 retval = MPI_ERR_GROUP;
642 } else if (newgroup == NULL) {
643 retval = MPI_ERR_ARG;
648 size = smpi_group_size(group);
649 for (i = 0; i < n; i++) {
650 for (rank = ranges[i][0]; /* First */
651 rank >= 0 && rank <= ranges[i][1]; /* Last */
652 rank += ranges[i][2] /* Stride */ ) {
657 *newgroup = MPI_GROUP_EMPTY;
659 *newgroup = smpi_group_new(size);
661 while (newrank < size) {
662 for (i = 0; i < n; i++) {
664 for (rank = ranges[i][0]; /* First */
665 rank >= 0 && rank <= ranges[i][1]; /* Last */
666 rank += ranges[i][2] /* Stride */ ) {
667 if (rank == newrank) {
673 index = smpi_group_index(group, newrank);
674 smpi_group_set_mapping(*newgroup, index, newrank);
677 newrank++; //added to avoid looping, need to be checked ..
681 smpi_group_use(*newgroup);
682 retval = MPI_SUCCESS;
688 int PMPI_Comm_rank(MPI_Comm comm, int *rank)
693 if (comm == MPI_COMM_NULL) {
694 retval = MPI_ERR_COMM;
695 } else if (rank == NULL) {
696 retval = MPI_ERR_ARG;
698 *rank = smpi_comm_rank(comm);
699 retval = MPI_SUCCESS;
705 int PMPI_Comm_size(MPI_Comm comm, int *size)
710 if (comm == MPI_COMM_NULL) {
711 retval = MPI_ERR_COMM;
712 } else if (size == NULL) {
713 retval = MPI_ERR_ARG;
715 *size = smpi_comm_size(comm);
716 retval = MPI_SUCCESS;
722 int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len)
727 if (comm == MPI_COMM_NULL) {
728 retval = MPI_ERR_COMM;
729 } else if (name == NULL || len == NULL) {
730 retval = MPI_ERR_ARG;
732 smpi_comm_get_name(comm, name, len);
733 retval = MPI_SUCCESS;
739 int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
744 if (comm == MPI_COMM_NULL) {
745 retval = MPI_ERR_COMM;
746 } else if (group == NULL) {
747 retval = MPI_ERR_ARG;
749 *group = smpi_comm_group(comm);
750 retval = MPI_SUCCESS;
756 int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
761 if (comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) {
762 retval = MPI_ERR_COMM;
763 } else if (result == NULL) {
764 retval = MPI_ERR_ARG;
766 if (comm1 == comm2) { /* Same communicators means same groups */
770 smpi_group_compare(smpi_comm_group(comm1),
771 smpi_comm_group(comm2));
772 if (*result == MPI_IDENT) {
773 *result = MPI_CONGRUENT;
776 retval = MPI_SUCCESS;
782 int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm)
787 if (comm == MPI_COMM_NULL) {
788 retval = MPI_ERR_COMM;
789 } else if (newcomm == NULL) {
790 retval = MPI_ERR_ARG;
792 *newcomm = smpi_comm_new(smpi_comm_group(comm));
793 retval = MPI_SUCCESS;
799 int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
804 if (comm == MPI_COMM_NULL) {
805 retval = MPI_ERR_COMM;
806 } else if (group == MPI_GROUP_NULL) {
807 retval = MPI_ERR_GROUP;
808 } else if (newcomm == NULL) {
809 retval = MPI_ERR_ARG;
810 } else if(smpi_group_rank(group,smpi_process_index())==MPI_UNDEFINED){
811 *newcomm= MPI_COMM_NULL;
812 retval = MPI_SUCCESS;
815 *newcomm = smpi_comm_new(group);
816 retval = MPI_SUCCESS;
822 int PMPI_Comm_free(MPI_Comm * comm)
828 retval = MPI_ERR_ARG;
829 } else if (*comm == MPI_COMM_NULL) {
830 retval = MPI_ERR_COMM;
832 smpi_comm_destroy(*comm);
833 *comm = MPI_COMM_NULL;
834 retval = MPI_SUCCESS;
840 int PMPI_Comm_disconnect(MPI_Comm * comm)
842 /* TODO: wait until all communication in comm are done */
847 retval = MPI_ERR_ARG;
848 } else if (*comm == MPI_COMM_NULL) {
849 retval = MPI_ERR_COMM;
851 smpi_comm_destroy(*comm);
852 *comm = MPI_COMM_NULL;
853 retval = MPI_SUCCESS;
859 int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out)
864 if (comm_out == NULL) {
865 retval = MPI_ERR_ARG;
866 } else if (comm == MPI_COMM_NULL) {
867 retval = MPI_ERR_COMM;
869 *comm_out = smpi_comm_split(comm, color, key);
870 retval = MPI_SUCCESS;
876 int PMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst,
877 int tag, MPI_Comm comm, MPI_Request * request)
882 if (request == NULL) {
883 retval = MPI_ERR_ARG;
884 } else if (comm == MPI_COMM_NULL) {
885 retval = MPI_ERR_COMM;
886 } else if (dst == MPI_PROC_NULL) {
887 retval = MPI_SUCCESS;
889 *request = smpi_mpi_send_init(buf, count, datatype, dst, tag, comm);
890 retval = MPI_SUCCESS;
896 int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src,
897 int tag, MPI_Comm comm, MPI_Request * request)
902 if (request == NULL) {
903 retval = MPI_ERR_ARG;
904 } else if (comm == MPI_COMM_NULL) {
905 retval = MPI_ERR_COMM;
906 } else if (src == MPI_PROC_NULL) {
907 retval = MPI_SUCCESS;
909 *request = smpi_mpi_recv_init(buf, count, datatype, src, tag, comm);
910 retval = MPI_SUCCESS;
916 int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) {
920 if (request == NULL) {
921 retval = MPI_ERR_ARG;
922 } else if (comm == MPI_COMM_NULL) {
923 retval = MPI_ERR_COMM;
924 } else if (dst == MPI_PROC_NULL) {
925 retval = MPI_SUCCESS;
927 *request = smpi_mpi_ssend_init(buf, count, datatype, dst, tag, comm);
928 retval = MPI_SUCCESS;
934 int PMPI_Start(MPI_Request * request)
939 if (request == NULL || *request == MPI_REQUEST_NULL) {
940 retval = MPI_ERR_ARG;
942 smpi_mpi_start(*request);
943 retval = MPI_SUCCESS;
949 int PMPI_Startall(int count, MPI_Request * requests)
954 if (requests == NULL) {
955 retval = MPI_ERR_ARG;
957 smpi_mpi_startall(count, requests);
958 retval = MPI_SUCCESS;
964 int PMPI_Request_free(MPI_Request * request)
969 if (*request == MPI_REQUEST_NULL) {
970 retval = MPI_ERR_ARG;
972 if((*request)->flags & PERSISTENT)(*request)->refcount--;
973 smpi_mpi_request_free(request);
974 retval = MPI_SUCCESS;
980 int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src,
981 int tag, MPI_Comm comm, MPI_Request * request)
987 if (request == NULL) {
988 retval = MPI_ERR_ARG;
989 } else if (comm == MPI_COMM_NULL) {
990 retval = MPI_ERR_COMM;
991 } else if (src == MPI_PROC_NULL) {
992 *request = MPI_REQUEST_NULL;
993 retval = MPI_SUCCESS;
994 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
995 retval = MPI_ERR_COMM;
996 } else if (count < 0) {
997 retval = MPI_ERR_COUNT;
998 } else if (buf==NULL && count > 0) {
999 retval = MPI_ERR_COUNT;
1000 } else if (datatype == MPI_DATATYPE_NULL){
1001 retval = MPI_ERR_TYPE;
1002 } else if(tag<0 && tag != MPI_ANY_TAG){
1003 retval = MPI_ERR_TAG;
1007 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1008 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1009 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
1012 *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm);
1013 retval = MPI_SUCCESS;
1016 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1017 (*request)->recv = 1;
1026 int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
1027 int tag, MPI_Comm comm, MPI_Request * request)
1032 if (request == NULL) {
1033 retval = MPI_ERR_ARG;
1034 } else if (comm == MPI_COMM_NULL) {
1035 retval = MPI_ERR_COMM;
1036 } else if (dst == MPI_PROC_NULL) {
1037 *request = MPI_REQUEST_NULL;
1038 retval = MPI_SUCCESS;
1039 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1040 retval = MPI_ERR_RANK;
1041 } else if (count < 0) {
1042 retval = MPI_ERR_COUNT;
1043 } else if (buf==NULL && count > 0) {
1044 retval = MPI_ERR_COUNT;
1045 } else if (datatype == MPI_DATATYPE_NULL){
1046 retval = MPI_ERR_TYPE;
1047 } else if(tag<0 && tag != MPI_ANY_TAG){
1048 retval = MPI_ERR_TAG;
1052 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1053 TRACE_smpi_computing_out(rank);
1054 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1055 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1056 TRACE_smpi_send(rank, rank, dst_traced);
1059 *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm);
1060 retval = MPI_SUCCESS;
1063 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1064 (*request)->send = 1;
1065 TRACE_smpi_computing_in(rank);
1073 int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) {
1077 if (request == NULL) {
1078 retval = MPI_ERR_ARG;
1079 } else if (comm == MPI_COMM_NULL) {
1080 retval = MPI_ERR_COMM;
1081 } else if (dst == MPI_PROC_NULL) {
1082 *request = MPI_REQUEST_NULL;
1083 retval = MPI_SUCCESS;
1084 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1085 retval = MPI_ERR_RANK;
1086 } else if (count < 0) {
1087 retval = MPI_ERR_COUNT;
1088 } else if (buf==NULL && count > 0) {
1089 retval = MPI_ERR_COUNT;
1090 } else if (datatype == MPI_DATATYPE_NULL){
1091 retval = MPI_ERR_TYPE;
1092 } else if(tag<0 && tag != MPI_ANY_TAG){
1093 retval = MPI_ERR_TAG;
1097 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1098 TRACE_smpi_computing_out(rank);
1099 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1100 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1101 TRACE_smpi_send(rank, rank, dst_traced);
1104 *request = smpi_mpi_issend(buf, count, datatype, dst, tag, comm);
1105 retval = MPI_SUCCESS;
1108 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1109 (*request)->send = 1;
1110 TRACE_smpi_computing_in(rank);
1118 int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
1119 MPI_Comm comm, MPI_Status * status)
1124 if (comm == MPI_COMM_NULL) {
1125 retval = MPI_ERR_COMM;
1126 } else if (src == MPI_PROC_NULL) {
1127 smpi_empty_status(status);
1128 status->MPI_SOURCE = MPI_PROC_NULL;
1129 retval = MPI_SUCCESS;
1130 } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){
1131 retval = MPI_ERR_RANK;
1132 } else if (count < 0) {
1133 retval = MPI_ERR_COUNT;
1134 } else if (buf==NULL && count > 0) {
1135 retval = MPI_ERR_COUNT;
1136 } else if (datatype == MPI_DATATYPE_NULL){
1137 retval = MPI_ERR_TYPE;
1138 } else if(tag<0 && tag != MPI_ANY_TAG){
1139 retval = MPI_ERR_TAG;
1142 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1143 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1144 TRACE_smpi_computing_out(rank);
1146 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
1149 smpi_mpi_recv(buf, count, datatype, src, tag, comm, status);
1150 retval = MPI_SUCCESS;
1153 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
1154 if(status!=MPI_STATUS_IGNORE)src_traced = smpi_group_index(smpi_comm_group(comm), status->MPI_SOURCE);
1155 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
1156 TRACE_smpi_recv(rank, src_traced, rank);
1157 TRACE_smpi_computing_in(rank);
1165 int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
1172 if (comm == MPI_COMM_NULL) {
1173 retval = MPI_ERR_COMM;
1174 } else if (dst == MPI_PROC_NULL) {
1175 retval = MPI_SUCCESS;
1176 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1177 retval = MPI_ERR_RANK;
1178 } else if (count < 0) {
1179 retval = MPI_ERR_COUNT;
1180 } else if (buf==NULL && count > 0) {
1181 retval = MPI_ERR_COUNT;
1182 } else if (datatype == MPI_DATATYPE_NULL){
1183 retval = MPI_ERR_TYPE;
1184 } else if(tag<0 && tag != MPI_ANY_TAG){
1185 retval = MPI_ERR_TAG;
1189 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1190 TRACE_smpi_computing_out(rank);
1191 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1192 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1193 TRACE_smpi_send(rank, rank, dst_traced);
1196 smpi_mpi_send(buf, count, datatype, dst, tag, comm);
1197 retval = MPI_SUCCESS;
1200 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1201 TRACE_smpi_computing_in(rank);
1211 int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
1216 if (comm == MPI_COMM_NULL) {
1217 retval = MPI_ERR_COMM;
1218 } else if (dst == MPI_PROC_NULL) {
1219 retval = MPI_SUCCESS;
1220 } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){
1221 retval = MPI_ERR_RANK;
1222 } else if (count < 0) {
1223 retval = MPI_ERR_COUNT;
1224 } else if (buf==NULL && count > 0) {
1225 retval = MPI_ERR_COUNT;
1226 } else if (datatype == MPI_DATATYPE_NULL){
1227 retval = MPI_ERR_TYPE;
1228 } else if(tag<0 && tag != MPI_ANY_TAG){
1229 retval = MPI_ERR_TAG;
1233 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1234 TRACE_smpi_computing_out(rank);
1235 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1236 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
1237 TRACE_smpi_send(rank, rank, dst_traced);
1240 smpi_mpi_ssend(buf, count, datatype, dst, tag, comm);
1241 retval = MPI_SUCCESS;
1244 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1245 TRACE_smpi_computing_in(rank);
1253 int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1254 int dst, int sendtag, void *recvbuf, int recvcount,
1255 MPI_Datatype recvtype, int src, int recvtag,
1256 MPI_Comm comm, MPI_Status * status)
1262 if (comm == MPI_COMM_NULL) {
1263 retval = MPI_ERR_COMM;
1264 } else if (sendtype == MPI_DATATYPE_NULL
1265 || recvtype == MPI_DATATYPE_NULL) {
1266 retval = MPI_ERR_TYPE;
1267 } else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
1268 smpi_empty_status(status);
1269 status->MPI_SOURCE = MPI_PROC_NULL;
1270 retval = MPI_SUCCESS;
1271 }else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0 ||
1272 (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0))){
1273 retval = MPI_ERR_RANK;
1274 } else if (sendcount < 0 || recvcount<0) {
1275 retval = MPI_ERR_COUNT;
1276 } else if ((sendbuf==NULL && sendcount > 0)||(recvbuf==NULL && recvcount>0)) {
1277 retval = MPI_ERR_COUNT;
1278 } else if((sendtag<0 && sendtag != MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){
1279 retval = MPI_ERR_TAG;
1283 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1284 TRACE_smpi_computing_out(rank);
1285 int dst_traced = smpi_group_index(smpi_comm_group(comm), dst);
1286 int src_traced = smpi_group_index(smpi_comm_group(comm), src);
1287 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
1288 TRACE_smpi_send(rank, rank, dst_traced);
1292 smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf,
1293 recvcount, recvtype, src, recvtag, comm, status);
1294 retval = MPI_SUCCESS;
1297 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1298 TRACE_smpi_recv(rank, src_traced, rank);
1299 TRACE_smpi_computing_in(rank);
1308 int PMPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
1309 int dst, int sendtag, int src, int recvtag,
1310 MPI_Comm comm, MPI_Status * status)
1312 //TODO: suboptimal implementation
1315 if (datatype == MPI_DATATYPE_NULL) {
1316 retval = MPI_ERR_TYPE;
1317 } else if (count < 0) {
1318 retval = MPI_ERR_COUNT;
1320 int size = smpi_datatype_get_extent(datatype) * count;
1321 recvbuf = xbt_new(char, size);
1323 MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
1324 datatype, src, recvtag, comm, status);
1325 if(retval==MPI_SUCCESS){
1326 smpi_datatype_copy(recvbuf, count, datatype, buf, count, datatype);
1334 int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
1339 if (request == MPI_REQUEST_NULL || flag == NULL) {
1340 retval = MPI_ERR_ARG;
1341 } else if (*request == MPI_REQUEST_NULL) {
1343 retval = MPI_ERR_REQUEST;
1345 *flag = smpi_mpi_test(request, status);
1346 retval = MPI_SUCCESS;
1352 int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
1353 MPI_Status * status)
1358 if (index == NULL || flag == NULL) {
1359 retval = MPI_ERR_ARG;
1361 *flag = smpi_mpi_testany(count, requests, index, status);
1362 retval = MPI_SUCCESS;
1368 int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses)
1374 retval = MPI_ERR_ARG;
1376 *flag = smpi_mpi_testall(count, requests, statuses);
1377 retval = MPI_SUCCESS;
1383 int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) {
1387 if (status == NULL) {
1388 retval = MPI_ERR_ARG;
1389 } else if (comm == MPI_COMM_NULL) {
1390 retval = MPI_ERR_COMM;
1391 } else if (source == MPI_PROC_NULL) {
1392 smpi_empty_status(status);
1393 status->MPI_SOURCE = MPI_PROC_NULL;
1394 retval = MPI_SUCCESS;
1396 smpi_mpi_probe(source, tag, comm, status);
1397 retval = MPI_SUCCESS;
1404 int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status) {
1409 retval = MPI_ERR_ARG;
1410 } else if (status == NULL) {
1411 retval = MPI_ERR_ARG;
1412 } else if (comm == MPI_COMM_NULL) {
1413 retval = MPI_ERR_COMM;
1414 } else if (source == MPI_PROC_NULL) {
1415 smpi_empty_status(status);
1416 status->MPI_SOURCE = MPI_PROC_NULL;
1417 retval = MPI_SUCCESS;
1419 smpi_mpi_iprobe(source, tag, comm, flag, status);
1420 retval = MPI_SUCCESS;
1426 int PMPI_Wait(MPI_Request * request, MPI_Status * status)
1432 if (request == NULL) {
1433 retval = MPI_ERR_ARG;
1434 } else if (*request == MPI_REQUEST_NULL) {
1435 retval = MPI_ERR_REQUEST;
1439 int rank = request && (*request)->comm != MPI_COMM_NULL
1440 ? smpi_process_index()
1442 TRACE_smpi_computing_out(rank);
1444 int src_traced = (*request)->src;
1445 int dst_traced = (*request)->dst;
1446 int is_wait_for_receive = (*request)->recv;
1447 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
1450 smpi_mpi_wait(request, status);
1451 retval = MPI_SUCCESS;
1454 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1455 if (is_wait_for_receive) {
1456 TRACE_smpi_recv(rank, src_traced, dst_traced);
1458 TRACE_smpi_computing_in(rank);
1467 int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * status)
1473 //save requests information for tracing
1475 int *srcs = xbt_new(int, count);
1476 int *dsts = xbt_new(int, count);
1477 int *recvs = xbt_new(int, count);
1478 for (i = 0; i < count; i++) {
1479 MPI_Request req = requests[i]; //already received requests are no longer valid
1483 recvs[i] = req->recv;
1486 int rank_traced = smpi_process_index();
1487 TRACE_smpi_computing_out(rank_traced);
1489 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
1492 if (index == NULL) {
1493 retval = MPI_ERR_ARG;
1495 *index = smpi_mpi_waitany(count, requests, status);
1496 retval = MPI_SUCCESS;
1499 if(*index!=MPI_UNDEFINED){
1500 int src_traced = srcs[*index];
1501 int dst_traced = dsts[*index];
1502 int is_wait_for_receive = recvs[*index];
1503 if (is_wait_for_receive) {
1504 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1506 TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__);
1511 TRACE_smpi_computing_in(rank_traced);
1517 int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
1522 //save information from requests
1524 int *srcs = xbt_new(int, count);
1525 int *dsts = xbt_new(int, count);
1526 int *recvs = xbt_new(int, count);
1527 int valid_count = 0;
1528 for (i = 0; i < count; i++) {
1529 MPI_Request req = requests[i];
1530 if(req!=MPI_REQUEST_NULL){
1531 srcs[valid_count] = req->src;
1532 dsts[valid_count] = req->dst;
1533 recvs[valid_count] = req->recv;
1537 int rank_traced = smpi_process_index();
1538 TRACE_smpi_computing_out(rank_traced);
1540 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
1542 int retval = smpi_mpi_waitall(count, requests, status);
1544 for (i = 0; i < valid_count; i++) {
1545 int src_traced = srcs[i];
1546 int dst_traced = dsts[i];
1547 int is_wait_for_receive = recvs[i];
1548 if (is_wait_for_receive) {
1549 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1552 TRACE_smpi_ptp_out(rank_traced, -1, -1, __FUNCTION__);
1556 TRACE_smpi_computing_in(rank_traced);
1562 int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
1563 int *indices, MPI_Status status[])
1568 if (outcount == NULL || indices == NULL) {
1569 retval = MPI_ERR_ARG;
1571 *outcount = smpi_mpi_waitsome(incount, requests, indices, status);
1572 retval = MPI_SUCCESS;
1578 int PMPI_Testsome(int incount, MPI_Request requests[], int* outcount,
1579 int* indices, MPI_Status status[])
1584 if (outcount == NULL || indices == NULL) {
1585 retval = MPI_ERR_ARG;
1587 *outcount = smpi_mpi_testsome(incount, requests, indices, status);
1588 retval = MPI_SUCCESS;
1595 int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
1601 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1602 TRACE_smpi_computing_out(rank);
1603 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1604 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1606 if (comm == MPI_COMM_NULL) {
1607 retval = MPI_ERR_COMM;
1609 mpi_coll_bcast_fun(buf, count, datatype, root, comm);
1610 retval = MPI_SUCCESS;
1613 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1614 TRACE_smpi_computing_in(rank);
1620 int PMPI_Barrier(MPI_Comm comm)
1626 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1627 TRACE_smpi_computing_out(rank);
1628 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1630 if (comm == MPI_COMM_NULL) {
1631 retval = MPI_ERR_COMM;
1633 mpi_coll_barrier_fun(comm);
1634 retval = MPI_SUCCESS;
1637 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1638 TRACE_smpi_computing_in(rank);
1644 int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1645 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1646 int root, MPI_Comm comm)
1652 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1653 TRACE_smpi_computing_out(rank);
1654 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1655 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1657 if (comm == MPI_COMM_NULL) {
1658 retval = MPI_ERR_COMM;
1659 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1660 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1661 retval = MPI_ERR_TYPE;
1662 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1663 ((smpi_comm_rank(comm) == root) && (recvcount <0))){
1664 retval = MPI_ERR_COUNT;
1667 char* sendtmpbuf = (char*) sendbuf;
1668 int sendtmpcount = sendcount;
1669 MPI_Datatype sendtmptype = sendtype;
1670 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1672 sendtmptype=recvtype;
1675 mpi_coll_gather_fun(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcount,
1676 recvtype, root, comm);
1679 retval = MPI_SUCCESS;
1682 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1683 TRACE_smpi_computing_in(rank);
1689 int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1690 void *recvbuf, int *recvcounts, int *displs,
1691 MPI_Datatype recvtype, int root, MPI_Comm comm)
1697 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1698 TRACE_smpi_computing_out(rank);
1699 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1700 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1702 if (comm == MPI_COMM_NULL) {
1703 retval = MPI_ERR_COMM;
1704 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1705 ((smpi_comm_rank(comm) == root) && (recvtype == MPI_DATATYPE_NULL))){
1706 retval = MPI_ERR_TYPE;
1707 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1708 retval = MPI_ERR_COUNT;
1709 } else if (recvcounts == NULL || displs == NULL) {
1710 retval = MPI_ERR_ARG;
1713 char* sendtmpbuf = (char*) sendbuf;
1714 int sendtmpcount = sendcount;
1715 MPI_Datatype sendtmptype = sendtype;
1716 if( (smpi_comm_rank(comm) == root) && (sendbuf == MPI_IN_PLACE )) {
1718 sendtmptype=recvtype;
1721 smpi_mpi_gatherv(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcounts,
1722 displs, recvtype, root, comm);
1723 retval = MPI_SUCCESS;
1726 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1727 TRACE_smpi_computing_in(rank);
1733 int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1734 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1741 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1742 TRACE_smpi_computing_out(rank);
1743 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1745 if (comm == MPI_COMM_NULL) {
1746 retval = MPI_ERR_COMM;
1747 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1748 (recvtype == MPI_DATATYPE_NULL)){
1749 retval = MPI_ERR_TYPE;
1750 } else if ((( sendbuf != MPI_IN_PLACE) && (sendcount <0)) ||
1752 retval = MPI_ERR_COUNT;
1755 if(sendbuf == MPI_IN_PLACE) {
1756 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*recvcount*smpi_comm_rank(comm);
1757 sendcount=recvcount;
1761 mpi_coll_allgather_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1763 retval = MPI_SUCCESS;
1766 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1772 int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1773 void *recvbuf, int *recvcounts, int *displs,
1774 MPI_Datatype recvtype, MPI_Comm comm)
1780 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1781 TRACE_smpi_computing_out(rank);
1782 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1784 if (comm == MPI_COMM_NULL) {
1785 retval = MPI_ERR_COMM;
1786 } else if ((( sendbuf != MPI_IN_PLACE) && (sendtype == MPI_DATATYPE_NULL)) ||
1787 (recvtype == MPI_DATATYPE_NULL)){
1788 retval = MPI_ERR_TYPE;
1789 } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){
1790 retval = MPI_ERR_COUNT;
1791 } else if (recvcounts == NULL || displs == NULL) {
1792 retval = MPI_ERR_ARG;
1795 if(sendbuf == MPI_IN_PLACE) {
1796 sendbuf=((char*)recvbuf)+smpi_datatype_get_extent(recvtype)*displs[smpi_comm_rank(comm)];
1797 sendcount=recvcounts[smpi_comm_rank(comm)];
1801 mpi_coll_allgatherv_fun(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
1802 displs, recvtype, comm);
1803 retval = MPI_SUCCESS;
1806 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1807 TRACE_smpi_computing_in(rank);
1813 int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1814 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1815 int root, MPI_Comm comm)
1821 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1822 TRACE_smpi_computing_out(rank);
1823 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1825 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1827 if (comm == MPI_COMM_NULL) {
1828 retval = MPI_ERR_COMM;
1829 } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
1830 || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
1831 retval = MPI_ERR_TYPE;
1834 if(recvbuf==MPI_IN_PLACE){
1837 mpi_coll_scatter_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1838 recvtype, root, comm);
1839 retval = MPI_SUCCESS;
1842 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1843 TRACE_smpi_computing_in(rank);
1849 int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
1850 MPI_Datatype sendtype, void *recvbuf, int recvcount,
1851 MPI_Datatype recvtype, int root, MPI_Comm comm)
1857 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1858 TRACE_smpi_computing_out(rank);
1859 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1860 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1862 if (comm == MPI_COMM_NULL) {
1863 retval = MPI_ERR_COMM;
1864 } else if (sendcounts == NULL || displs == NULL) {
1865 retval = MPI_ERR_ARG;
1866 } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL))
1867 || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
1868 retval = MPI_ERR_TYPE;
1871 if(recvbuf==MPI_IN_PLACE){
1875 smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
1876 recvcount, recvtype, root, comm);
1877 retval = MPI_SUCCESS;
1880 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1881 TRACE_smpi_computing_in(rank);
1887 int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
1888 MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
1894 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1895 TRACE_smpi_computing_out(rank);
1896 int root_traced = smpi_group_index(smpi_comm_group(comm), root);
1897 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1899 if (comm == MPI_COMM_NULL) {
1900 retval = MPI_ERR_COMM;
1901 } else if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
1902 retval = MPI_ERR_ARG;
1905 char* sendtmpbuf = (char*) sendbuf;
1906 if( sendbuf == MPI_IN_PLACE ) {
1907 sendtmpbuf = (char *)xbt_malloc(count*smpi_datatype_get_extent(datatype));
1908 smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
1911 mpi_coll_reduce_fun(sendtmpbuf, recvbuf, count, datatype, op, root, comm);
1913 if( sendbuf == MPI_IN_PLACE ) {
1914 xbt_free(sendtmpbuf);
1917 retval = MPI_SUCCESS;
1920 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1921 TRACE_smpi_computing_in(rank);
1927 int PMPI_Reduce_local(void *inbuf, void *inoutbuf, int count,
1928 MPI_Datatype datatype, MPI_Op op){
1932 if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
1933 retval = MPI_ERR_ARG;
1935 smpi_op_apply(op, inbuf, inoutbuf, &count, &datatype);
1942 int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
1943 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
1949 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1950 TRACE_smpi_computing_out(rank);
1951 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1953 if (comm == MPI_COMM_NULL) {
1954 retval = MPI_ERR_COMM;
1955 } else if (datatype == MPI_DATATYPE_NULL) {
1956 retval = MPI_ERR_TYPE;
1957 } else if (op == MPI_OP_NULL) {
1958 retval = MPI_ERR_OP;
1961 char* sendtmpbuf = (char*) sendbuf;
1962 if( sendbuf == MPI_IN_PLACE ) {
1963 sendtmpbuf = (char *)xbt_malloc(count*smpi_datatype_get_extent(datatype));
1964 smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
1967 mpi_coll_allreduce_fun(sendtmpbuf, recvbuf, count, datatype, op, comm);
1969 if( sendbuf == MPI_IN_PLACE ) {
1970 xbt_free(sendtmpbuf);
1973 retval = MPI_SUCCESS;
1977 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1978 TRACE_smpi_computing_in(rank);
1984 int PMPI_Scan(void *sendbuf, void *recvbuf, int count,
1985 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
1991 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
1992 TRACE_smpi_computing_out(rank);
1993 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1995 if (comm == MPI_COMM_NULL) {
1996 retval = MPI_ERR_COMM;
1997 } else if (datatype == MPI_DATATYPE_NULL) {
1998 retval = MPI_ERR_TYPE;
1999 } else if (op == MPI_OP_NULL) {
2000 retval = MPI_ERR_OP;
2002 smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm);
2003 retval = MPI_SUCCESS;
2006 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2007 TRACE_smpi_computing_in(rank);
2013 int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
2014 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2019 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2020 TRACE_smpi_computing_out(rank);
2021 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2023 if (comm == MPI_COMM_NULL) {
2024 retval = MPI_ERR_COMM;
2025 } else if (datatype == MPI_DATATYPE_NULL) {
2026 retval = MPI_ERR_TYPE;
2027 } else if (op == MPI_OP_NULL) {
2028 retval = MPI_ERR_OP;
2029 } else if (recvcounts == NULL) {
2030 retval = MPI_ERR_ARG;
2032 void* sendtmpbuf=sendbuf;
2033 if(sendbuf==MPI_IN_PLACE){
2037 mpi_coll_reduce_scatter_fun(sendtmpbuf, recvbuf, recvcounts,
2038 datatype, op, comm);
2039 retval = MPI_SUCCESS;
2042 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2043 TRACE_smpi_computing_in(rank);
2049 int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
2050 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
2055 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2056 TRACE_smpi_computing_out(rank);
2057 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2059 if (comm == MPI_COMM_NULL) {
2060 retval = MPI_ERR_COMM;
2061 } else if (datatype == MPI_DATATYPE_NULL) {
2062 retval = MPI_ERR_TYPE;
2063 } else if (op == MPI_OP_NULL) {
2064 retval = MPI_ERR_OP;
2065 } else if (recvcount < 0) {
2066 retval = MPI_ERR_ARG;
2068 int count=smpi_comm_size(comm);
2069 int* recvcounts=(int*)xbt_malloc(count);
2070 for (i=0; i<count;i++)recvcounts[i]=recvcount;
2071 mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts,
2072 datatype, op, comm);
2073 xbt_free(recvcounts);
2074 retval = MPI_SUCCESS;
2077 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2078 TRACE_smpi_computing_in(rank);
2084 int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
2085 void *recvbuf, int recvcount, MPI_Datatype recvtype,
2092 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2093 TRACE_smpi_computing_out(rank);
2094 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2096 if (comm == MPI_COMM_NULL) {
2097 retval = MPI_ERR_COMM;
2098 } else if (sendtype == MPI_DATATYPE_NULL
2099 || recvtype == MPI_DATATYPE_NULL) {
2100 retval = MPI_ERR_TYPE;
2102 retval = mpi_coll_alltoall_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
2105 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2106 TRACE_smpi_computing_in(rank);
2112 int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
2113 MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
2114 int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
2120 int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1;
2121 TRACE_smpi_computing_out(rank);
2122 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
2124 if (comm == MPI_COMM_NULL) {
2125 retval = MPI_ERR_COMM;
2126 } else if (sendtype == MPI_DATATYPE_NULL
2127 || recvtype == MPI_DATATYPE_NULL) {
2128 retval = MPI_ERR_TYPE;
2129 } else if (sendcounts == NULL || senddisps == NULL || recvcounts == NULL
2130 || recvdisps == NULL) {
2131 retval = MPI_ERR_ARG;
2134 mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, sendtype,
2135 recvbuf, recvcounts, recvdisps, recvtype,
2139 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
2140 TRACE_smpi_computing_in(rank);
2147 int PMPI_Get_processor_name(char *name, int *resultlen)
2149 int retval = MPI_SUCCESS;
2152 strncpy(name, SIMIX_host_get_name(SIMIX_host_self()),
2153 strlen(SIMIX_host_get_name(SIMIX_host_self())) < MPI_MAX_PROCESSOR_NAME - 1 ?
2154 strlen(SIMIX_host_get_name(SIMIX_host_self())) +1 :
2155 MPI_MAX_PROCESSOR_NAME - 1 );
2158 MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
2164 int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
2166 int retval = MPI_SUCCESS;
2170 if (status == NULL || count == NULL) {
2171 retval = MPI_ERR_ARG;
2172 } else if (datatype == MPI_DATATYPE_NULL) {
2173 retval = MPI_ERR_TYPE;
2175 size = smpi_datatype_size(datatype);
2178 } else if (status->count % size != 0) {
2179 retval = MPI_UNDEFINED;
2181 *count = smpi_mpi_get_count(status, datatype);
2188 int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type) {
2192 if (old_type == MPI_DATATYPE_NULL) {
2193 retval = MPI_ERR_TYPE;
2194 } else if (count<0){
2195 retval = MPI_ERR_COUNT;
2197 retval = smpi_datatype_contiguous(count, old_type, new_type, 0);
2203 int PMPI_Type_commit(MPI_Datatype* datatype) {
2207 if (datatype == MPI_DATATYPE_NULL) {
2208 retval = MPI_ERR_TYPE;
2210 smpi_datatype_commit(datatype);
2211 retval = MPI_SUCCESS;
2218 int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2222 if (old_type == MPI_DATATYPE_NULL) {
2223 retval = MPI_ERR_TYPE;
2224 } else if (count<0 || blocklen<0){
2225 retval = MPI_ERR_COUNT;
2227 retval = smpi_datatype_vector(count, blocklen, stride, old_type, new_type);
2233 int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2237 if (old_type == MPI_DATATYPE_NULL) {
2238 retval = MPI_ERR_TYPE;
2239 } else if (count<0 || blocklen<0){
2240 retval = MPI_ERR_COUNT;
2242 retval = smpi_datatype_hvector(count, blocklen, stride, old_type, new_type);
2248 int PMPI_Type_create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
2249 return MPI_Type_hvector(count, blocklen, stride, old_type, new_type);
2252 int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2256 if (old_type == MPI_DATATYPE_NULL) {
2257 retval = MPI_ERR_TYPE;
2258 } else if (count<0){
2259 retval = MPI_ERR_COUNT;
2261 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2267 int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2271 if (old_type == MPI_DATATYPE_NULL) {
2272 retval = MPI_ERR_TYPE;
2273 } else if (count<0){
2274 retval = MPI_ERR_COUNT;
2276 int* blocklens=(int*)xbt_malloc(blocklength*count);
2277 for (i=0; i<count;i++)blocklens[i]=blocklength;
2278 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
2279 xbt_free(blocklens);
2286 int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2290 if (old_type == MPI_DATATYPE_NULL) {
2291 retval = MPI_ERR_TYPE;
2292 } else if (count<0){
2293 retval = MPI_ERR_COUNT;
2295 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2301 int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
2305 if (old_type == MPI_DATATYPE_NULL) {
2306 retval = MPI_ERR_TYPE;
2307 } else if (count<0){
2308 retval = MPI_ERR_COUNT;
2310 int* blocklens=(int*)xbt_malloc(blocklength*count);
2311 for (i=0; i<count;i++)blocklens[i]=blocklength;
2312 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
2313 xbt_free(blocklens);
2320 int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2325 retval = MPI_ERR_COUNT;
2327 retval = smpi_datatype_struct(count, blocklens, indices, old_types, new_type);
2333 int PMPI_Type_create_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
2334 return PMPI_Type_struct(count, blocklens, indices, old_types, new_type);
2338 int PMPI_Error_class(int errorcode, int* errorclass) {
2339 // assume smpi uses only standard mpi error codes
2340 *errorclass=errorcode;
2345 int PMPI_Initialized(int* flag) {
2346 *flag=(smpi_process_data()!=NULL);
2350 /* The following calls are not yet implemented and will fail at runtime. */
2351 /* Once implemented, please move them above this notice. */
2353 #define NOT_YET_IMPLEMENTED {\
2354 XBT_WARN("Not yet implemented : %s. Please contact the Simgrid team if support is needed", __FUNCTION__);\
2355 return MPI_SUCCESS;\
2359 int PMPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype){
2363 int PMPI_Type_set_name(MPI_Datatype datatype, char * name)
2368 int PMPI_Type_get_name(MPI_Datatype datatype, char * name, int* len)
2373 int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
2377 int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) {
2381 int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periods, int reorder, MPI_Comm* comm_cart) {
2385 int PMPI_Cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) {
2389 int PMPI_Cart_map(MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank) {
2393 int PMPI_Cart_rank(MPI_Comm comm, int* coords, int* rank) {
2397 int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* dest) {
2401 int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
2405 int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) {
2409 int PMPI_Graph_create(MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder, MPI_Comm* comm_graph) {
2413 int PMPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int* index, int* edges) {
2417 int PMPI_Graph_map(MPI_Comm comm_old, int nnodes, int* index, int* edges, int* newrank) {
2421 int PMPI_Graph_neighbors(MPI_Comm comm, int rank, int maxneighbors, int* neighbors) {
2425 int PMPI_Graph_neighbors_count(MPI_Comm comm, int rank, int* nneighbors) {
2429 int PMPI_Graphdims_get(MPI_Comm comm, int* nnodes, int* nedges) {
2433 int PMPI_Topo_test(MPI_Comm comm, int* top_type) {
2437 int PMPI_Errhandler_create(MPI_Handler_function* function, MPI_Errhandler* errhandler) {
2441 int PMPI_Errhandler_free(MPI_Errhandler* errhandler) {
2445 int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler* errhandler) {
2449 int PMPI_Error_string(int errorcode, char* string, int* resultlen) {
2453 int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler) {
2457 int PMPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler) {
2461 int PMPI_Cancel(MPI_Request* request) {
2465 int PMPI_Buffer_attach(void* buffer, int size) {
2469 int PMPI_Buffer_detach(void* buffer, int* size) {
2473 int PMPI_Comm_test_inter(MPI_Comm comm, int* flag) {
2477 int PMPI_Comm_get_attr (MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag)
2482 int PMPI_Comm_set_attr (MPI_Comm comm, int comm_keyval, void *attribute_val)
2487 int PMPI_Comm_delete_attr (MPI_Comm comm, int comm_keyval)
2492 int PMPI_Comm_create_keyval(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state)
2497 int PMPI_Comm_free_keyval(int* keyval) {
2501 int PMPI_Pcontrol(const int level )
2506 int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
2510 int PMPI_Type_get_attr (MPI_Datatype type, int type_keyval, void *attribute_val, int* flag)
2515 int PMPI_Type_set_attr (MPI_Datatype type, int type_keyval, void *attribute_val)
2520 int PMPI_Type_delete_attr (MPI_Datatype type, int comm_keyval)
2525 int PMPI_Type_create_keyval(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state)
2530 int PMPI_Type_free_keyval(int* keyval) {
2534 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
2538 int PMPI_Intercomm_merge(MPI_Comm comm, int high, MPI_Comm* comm_out) {
2542 int PMPI_Bsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2546 int PMPI_Bsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2550 int PMPI_Ibsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2554 int PMPI_Comm_remote_group(MPI_Comm comm, MPI_Group* group) {
2558 int PMPI_Comm_remote_size(MPI_Comm comm, int* size) {
2562 int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
2566 int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) {
2570 int PMPI_Attr_put(MPI_Comm comm, int keyval, void* attr_value) {
2574 int PMPI_Rsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2578 int PMPI_Rsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2582 int PMPI_Irsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2586 int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
2590 int PMPI_Keyval_free(int* keyval) {
2594 int PMPI_Test_cancelled(MPI_Status* status, int* flag) {
2598 int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
2602 int PMPI_Pack_external_size(char *datarep, int incount, MPI_Datatype datatype, MPI_Aint *size){
2606 int PMPI_Pack_external(char *datarep, void *inbuf, int incount, MPI_Datatype datatype, void *outbuf, MPI_Aint outcount, MPI_Aint *position){
2610 int PMPI_Unpack_external( char *datarep, void *inbuf, MPI_Aint insize, MPI_Aint *position, void *outbuf, int outcount, MPI_Datatype datatype){
2614 int PMPI_Get_elements(MPI_Status* status, MPI_Datatype datatype, int* elements) {
2618 int PMPI_Dims_create(int nnodes, int ndims, int* dims) {
2622 int PMPI_Win_fence( int assert, MPI_Win win){
2626 int PMPI_Win_free( MPI_Win* win){
2630 int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win){
2634 int PMPI_Info_create( MPI_Info *info){
2638 int PMPI_Info_set( MPI_Info info, char *key, char *value){
2642 int PMPI_Info_free( MPI_Info *info){
2646 int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
2647 MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win){
2651 int PMPI_Type_get_envelope( MPI_Datatype datatype, int *num_integers,
2652 int *num_addresses, int *num_datatypes, int *combiner){
2656 int PMPI_Type_get_contents(MPI_Datatype datatype, int max_integers, int max_addresses,
2657 int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses,
2658 MPI_Datatype* array_of_datatypes){
2662 int PMPI_Type_create_darray(int size, int rank, int ndims, int* array_of_gsizes,
2663 int* array_of_distribs, int* array_of_dargs, int* array_of_psizes,
2664 int order, MPI_Datatype oldtype, MPI_Datatype *newtype) {
2668 int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype){
2672 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){
2676 int PMPI_Type_match_size(int typeclass,int size,MPI_Datatype *datatype){
2680 int PMPI_Alltoallw( void *sendbuf, int *sendcnts, int *sdispls, MPI_Datatype *sendtypes,
2681 void *recvbuf, int *recvcnts, int *rdispls, MPI_Datatype *recvtypes,
2686 int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
2687 MPI_Op op, MPI_Comm comm){
2691 int PMPI_Comm_set_name(MPI_Comm comm, char* name){
2695 int PMPI_Comm_dup_with_info(MPI_Comm comm, MPI_Info info, MPI_Comm * newcomm){
2699 int PMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm){
2703 int PMPI_Comm_set_info (MPI_Comm comm, MPI_Info info){
2707 int PMPI_Comm_get_info (MPI_Comm comm, MPI_Info* info){
2711 int PMPI_Info_get(MPI_Info info,char *key,int valuelen, char *value, int *flag){
2715 int PMPI_Comm_create_errhandler( MPI_Comm_errhandler_fn *function, MPI_Errhandler *errhandler){
2719 int PMPI_Add_error_class( int *errorclass){
2723 int PMPI_Add_error_code( int errorclass, int *errorcode){
2727 int PMPI_Add_error_string( int errorcode, char *string){
2731 int PMPI_Comm_call_errhandler(MPI_Comm comm,int errorcode){
2735 int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo){
2739 int PMPI_Info_delete(MPI_Info info, char *key){
2743 int PMPI_Info_get_nkeys( MPI_Info info, int *nkeys){
2747 int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){
2751 int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){
2755 int PMPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){
2759 int MPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status){
2763 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){
2767 int PMPI_Grequest_complete( MPI_Request request){
2771 int PMPI_Status_set_cancelled(MPI_Status *status,int flag){
2775 int PMPI_Status_set_elements( MPI_Status *status, MPI_Datatype datatype, int count){
2779 int PMPI_Comm_connect( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
2783 int PMPI_Publish_name( char *service_name, MPI_Info info, char *port_name){
2787 int PMPI_Unpublish_name( char *service_name, MPI_Info info, char *port_name){
2791 int PMPI_Lookup_name( char *service_name, MPI_Info info, char *port_name){
2795 int PMPI_Comm_join( int fd, MPI_Comm *intercomm){
2799 int PMPI_Open_port( MPI_Info info, char *port_name){
2803 int PMPI_Close_port(char *port_name){
2807 int PMPI_Comm_accept( char *port_name, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *newcomm){
2811 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){
2815 int PMPI_Comm_spawn_multiple( int count, char **array_of_commands, char*** array_of_argv,
2816 int* array_of_maxprocs, MPI_Info* array_of_info, int root,
2817 MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes){
2821 int PMPI_Comm_get_parent( MPI_Comm *parent){