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_Init_thread(int *argc, char ***argv, int required, int *provided)
55 if (provided != NULL) {
56 *provided = MPI_THREAD_MULTIPLE;
58 return MPI_Init(argc, argv);
61 int PMPI_Query_thread(int *provided)
66 if (provided == NULL) {
69 *provided = MPI_THREAD_MULTIPLE;
76 int PMPI_Is_thread_main(int *flag)
84 *flag = smpi_process_index() == 0;
91 int PMPI_Abort(MPI_Comm comm, int errorcode)
94 smpi_process_destroy();
96 int rank = smpi_process_index();
97 TRACE_smpi_computing_out(rank);
99 // FIXME: should kill all processes in comm instead
100 simcall_process_kill(SIMIX_process_self());
104 double PMPI_Wtime(void)
109 time = SIMIX_get_clock();
113 extern double sg_maxmin_precision;
114 double PMPI_Wtick(void)
116 return sg_maxmin_precision;
119 int PMPI_Address(void *location, MPI_Aint * address)
125 retval = MPI_ERR_ARG;
127 *address = (MPI_Aint) location;
133 int PMPI_Type_free(MPI_Datatype * datatype)
139 retval = MPI_ERR_ARG;
141 smpi_datatype_free(datatype);
142 retval = MPI_SUCCESS;
148 int PMPI_Type_size(MPI_Datatype datatype, int *size)
153 if (datatype == MPI_DATATYPE_NULL) {
154 retval = MPI_ERR_TYPE;
155 } else if (size == NULL) {
156 retval = MPI_ERR_ARG;
158 *size = (int) smpi_datatype_size(datatype);
159 retval = MPI_SUCCESS;
165 int PMPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent)
170 if (datatype == MPI_DATATYPE_NULL) {
171 retval = MPI_ERR_TYPE;
172 } else if (lb == NULL || extent == NULL) {
173 retval = MPI_ERR_ARG;
175 retval = smpi_datatype_extent(datatype, lb, extent);
181 int PMPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent)
187 if (datatype == MPI_DATATYPE_NULL) {
188 retval = MPI_ERR_TYPE;
189 } else if (extent == NULL) {
190 retval = MPI_ERR_ARG;
192 retval = smpi_datatype_extent(datatype, &dummy, extent);
198 int PMPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp)
203 if (datatype == MPI_DATATYPE_NULL) {
204 retval = MPI_ERR_TYPE;
205 } else if (disp == NULL) {
206 retval = MPI_ERR_ARG;
208 *disp = smpi_datatype_lb(datatype);
209 retval = MPI_SUCCESS;
215 int PMPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp)
220 if (datatype == MPI_DATATYPE_NULL) {
221 retval = MPI_ERR_TYPE;
222 } else if (disp == NULL) {
223 retval = MPI_ERR_ARG;
225 *disp = smpi_datatype_ub(datatype);
226 retval = MPI_SUCCESS;
232 int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
237 if (function == NULL || op == NULL) {
238 retval = MPI_ERR_ARG;
240 *op = smpi_op_new(function, commute);
241 retval = MPI_SUCCESS;
247 int PMPI_Op_free(MPI_Op * op)
253 retval = MPI_ERR_ARG;
254 } else if (*op == MPI_OP_NULL) {
257 smpi_op_destroy(*op);
259 retval = MPI_SUCCESS;
265 int PMPI_Group_free(MPI_Group * group)
271 retval = MPI_ERR_ARG;
273 smpi_group_destroy(*group);
274 *group = MPI_GROUP_NULL;
275 retval = MPI_SUCCESS;
281 int PMPI_Group_size(MPI_Group group, int *size)
286 if (group == MPI_GROUP_NULL) {
287 retval = MPI_ERR_GROUP;
288 } else if (size == NULL) {
289 retval = MPI_ERR_ARG;
291 *size = smpi_group_size(group);
292 retval = MPI_SUCCESS;
298 int PMPI_Group_rank(MPI_Group group, int *rank)
303 if (group == MPI_GROUP_NULL) {
304 retval = MPI_ERR_GROUP;
305 } else if (rank == NULL) {
306 retval = MPI_ERR_ARG;
308 *rank = smpi_group_rank(group, smpi_process_index());
309 retval = MPI_SUCCESS;
315 int PMPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
316 MPI_Group group2, int *ranks2)
318 int retval, i, index;
321 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
322 retval = MPI_ERR_GROUP;
324 for (i = 0; i < n; i++) {
325 index = smpi_group_index(group1, ranks1[i]);
326 ranks2[i] = smpi_group_rank(group2, index);
328 retval = MPI_SUCCESS;
334 int PMPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result)
339 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
340 retval = MPI_ERR_GROUP;
341 } else if (result == NULL) {
342 retval = MPI_ERR_ARG;
344 *result = smpi_group_compare(group1, group2);
345 retval = MPI_SUCCESS;
351 int PMPI_Group_union(MPI_Group group1, MPI_Group group2,
352 MPI_Group * newgroup)
354 int retval, i, proc1, proc2, size, size2;
357 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
358 retval = MPI_ERR_GROUP;
359 } else if (newgroup == NULL) {
360 retval = MPI_ERR_ARG;
362 size = smpi_group_size(group1);
363 size2 = smpi_group_size(group2);
364 for (i = 0; i < size2; i++) {
365 proc2 = smpi_group_index(group2, i);
366 proc1 = smpi_group_rank(group1, proc2);
367 if (proc1 == MPI_UNDEFINED) {
372 *newgroup = MPI_GROUP_EMPTY;
374 *newgroup = smpi_group_new(size);
375 size2 = smpi_group_size(group1);
376 for (i = 0; i < size2; i++) {
377 proc1 = smpi_group_index(group1, i);
378 smpi_group_set_mapping(*newgroup, proc1, i);
380 for (i = size2; i < size; i++) {
381 proc2 = smpi_group_index(group2, i - size2);
382 smpi_group_set_mapping(*newgroup, proc2, i);
385 smpi_group_use(*newgroup);
386 retval = MPI_SUCCESS;
392 int PMPI_Group_intersection(MPI_Group group1, MPI_Group group2,
393 MPI_Group * newgroup)
395 int retval, i, proc1, proc2, size, size2;
398 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
399 retval = MPI_ERR_GROUP;
400 } else if (newgroup == NULL) {
401 retval = MPI_ERR_ARG;
403 size = smpi_group_size(group1);
404 size2 = smpi_group_size(group2);
405 for (i = 0; i < size2; i++) {
406 proc2 = smpi_group_index(group2, i);
407 proc1 = smpi_group_rank(group1, proc2);
408 if (proc1 == MPI_UNDEFINED) {
413 *newgroup = MPI_GROUP_EMPTY;
415 *newgroup = smpi_group_new(size);
416 size2 = smpi_group_size(group1);
417 for (i = 0; i < size2; i++) {
418 proc1 = smpi_group_index(group1, i);
419 proc2 = smpi_group_rank(group2, proc1);
420 if (proc2 != MPI_UNDEFINED) {
421 smpi_group_set_mapping(*newgroup, proc1, i);
425 smpi_group_use(*newgroup);
426 retval = MPI_SUCCESS;
432 int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgroup)
434 int retval, i, proc1, proc2, size, size2;
437 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
438 retval = MPI_ERR_GROUP;
439 } else if (newgroup == NULL) {
440 retval = MPI_ERR_ARG;
442 size = size2 = smpi_group_size(group1);
443 for (i = 0; i < size2; i++) {
444 proc1 = smpi_group_index(group1, i);
445 proc2 = smpi_group_rank(group2, proc1);
446 if (proc2 != MPI_UNDEFINED) {
451 *newgroup = MPI_GROUP_EMPTY;
453 *newgroup = smpi_group_new(size);
454 for (i = 0; i < size2; i++) {
455 proc1 = smpi_group_index(group1, i);
456 proc2 = smpi_group_rank(group2, proc1);
457 if (proc2 == MPI_UNDEFINED) {
458 smpi_group_set_mapping(*newgroup, proc1, i);
462 smpi_group_use(*newgroup);
463 retval = MPI_SUCCESS;
469 int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
471 int retval, i, index;
474 if (group == MPI_GROUP_NULL) {
475 retval = MPI_ERR_GROUP;
476 } else if (newgroup == NULL) {
477 retval = MPI_ERR_ARG;
480 *newgroup = MPI_GROUP_EMPTY;
481 } else if (n == smpi_group_size(group)) {
484 *newgroup = smpi_group_new(n);
485 for (i = 0; i < n; i++) {
486 index = smpi_group_index(group, ranks[i]);
487 smpi_group_set_mapping(*newgroup, index, i);
490 smpi_group_use(*newgroup);
491 retval = MPI_SUCCESS;
497 int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup)
499 int retval, i, size, rank, index;
502 if (group == MPI_GROUP_NULL) {
503 retval = MPI_ERR_GROUP;
504 } else if (newgroup == NULL) {
505 retval = MPI_ERR_ARG;
509 } else if (n == smpi_group_size(group)) {
510 *newgroup = MPI_GROUP_EMPTY;
512 size = smpi_group_size(group) - n;
513 *newgroup = smpi_group_new(size);
515 while (rank < size) {
516 for (i = 0; i < n; i++) {
517 if (ranks[i] == rank) {
522 index = smpi_group_index(group, rank);
523 smpi_group_set_mapping(*newgroup, index, rank);
528 smpi_group_use(*newgroup);
529 retval = MPI_SUCCESS;
535 int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
536 MPI_Group * newgroup)
538 int retval, i, j, rank, size, index;
541 if (group == MPI_GROUP_NULL) {
542 retval = MPI_ERR_GROUP;
543 } else if (newgroup == NULL) {
544 retval = MPI_ERR_ARG;
547 *newgroup = MPI_GROUP_EMPTY;
550 for (i = 0; i < n; i++) {
551 for (rank = ranges[i][0]; /* First */
552 rank >= 0 && rank <= ranges[i][1]; /* Last */
553 rank += ranges[i][2] /* Stride */ ) {
557 if (size == smpi_group_size(group)) {
560 *newgroup = smpi_group_new(size);
562 for (i = 0; i < n; i++) {
563 for (rank = ranges[i][0]; /* First */
564 rank >= 0 && rank <= ranges[i][1]; /* Last */
565 rank += ranges[i][2] /* Stride */ ) {
566 index = smpi_group_index(group, rank);
567 smpi_group_set_mapping(*newgroup, index, j);
573 smpi_group_use(*newgroup);
574 retval = MPI_SUCCESS;
580 int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
581 MPI_Group * newgroup)
583 int retval, i, newrank, rank, size, index, add;
586 if (group == MPI_GROUP_NULL) {
587 retval = MPI_ERR_GROUP;
588 } else if (newgroup == NULL) {
589 retval = MPI_ERR_ARG;
594 size = smpi_group_size(group);
595 for (i = 0; i < n; i++) {
596 for (rank = ranges[i][0]; /* First */
597 rank >= 0 && rank <= ranges[i][1]; /* Last */
598 rank += ranges[i][2] /* Stride */ ) {
603 *newgroup = MPI_GROUP_EMPTY;
605 *newgroup = smpi_group_new(size);
607 while (newrank < size) {
608 for (i = 0; i < n; i++) {
610 for (rank = ranges[i][0]; /* First */
611 rank >= 0 && rank <= ranges[i][1]; /* Last */
612 rank += ranges[i][2] /* Stride */ ) {
613 if (rank == newrank) {
619 index = smpi_group_index(group, newrank);
620 smpi_group_set_mapping(*newgroup, index, newrank);
626 smpi_group_use(*newgroup);
627 retval = MPI_SUCCESS;
633 int PMPI_Comm_rank(MPI_Comm comm, int *rank)
638 if (comm == MPI_COMM_NULL) {
639 retval = MPI_ERR_COMM;
640 } else if (rank == NULL) {
641 retval = MPI_ERR_ARG;
643 *rank = smpi_comm_rank(comm);
644 retval = MPI_SUCCESS;
650 int PMPI_Comm_size(MPI_Comm comm, int *size)
655 if (comm == MPI_COMM_NULL) {
656 retval = MPI_ERR_COMM;
657 } else if (size == NULL) {
658 retval = MPI_ERR_ARG;
660 *size = smpi_comm_size(comm);
661 retval = MPI_SUCCESS;
667 int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len)
672 if (comm == MPI_COMM_NULL) {
673 retval = MPI_ERR_COMM;
674 } else if (name == NULL || len == NULL) {
675 retval = MPI_ERR_ARG;
677 smpi_comm_get_name(comm, name, len);
678 retval = MPI_SUCCESS;
684 int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
689 if (comm == MPI_COMM_NULL) {
690 retval = MPI_ERR_COMM;
691 } else if (group == NULL) {
692 retval = MPI_ERR_ARG;
694 *group = smpi_comm_group(comm);
695 retval = MPI_SUCCESS;
701 int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
706 if (comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) {
707 retval = MPI_ERR_COMM;
708 } else if (result == NULL) {
709 retval = MPI_ERR_ARG;
711 if (comm1 == comm2) { /* Same communicators means same groups */
715 smpi_group_compare(smpi_comm_group(comm1),
716 smpi_comm_group(comm2));
717 if (*result == MPI_IDENT) {
718 *result = MPI_CONGRUENT;
721 retval = MPI_SUCCESS;
727 int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm)
732 if (comm == MPI_COMM_NULL) {
733 retval = MPI_ERR_COMM;
734 } else if (newcomm == NULL) {
735 retval = MPI_ERR_ARG;
737 *newcomm = smpi_comm_new(smpi_comm_group(comm));
738 retval = MPI_SUCCESS;
744 int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
749 if (comm == MPI_COMM_NULL) {
750 retval = MPI_ERR_COMM;
751 } else if (group == MPI_GROUP_NULL) {
752 retval = MPI_ERR_GROUP;
753 } else if (newcomm == NULL) {
754 retval = MPI_ERR_ARG;
756 *newcomm = smpi_comm_new(group);
757 retval = MPI_SUCCESS;
763 int PMPI_Comm_free(MPI_Comm * comm)
769 retval = MPI_ERR_ARG;
770 } else if (*comm == MPI_COMM_NULL) {
771 retval = MPI_ERR_COMM;
773 smpi_comm_destroy(*comm);
774 *comm = MPI_COMM_NULL;
775 retval = MPI_SUCCESS;
781 int PMPI_Comm_disconnect(MPI_Comm * comm)
783 /* TODO: wait until all communication in comm are done */
788 retval = MPI_ERR_ARG;
789 } else if (*comm == MPI_COMM_NULL) {
790 retval = MPI_ERR_COMM;
792 smpi_comm_destroy(*comm);
793 *comm = MPI_COMM_NULL;
794 retval = MPI_SUCCESS;
800 int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out)
805 if (comm_out == NULL) {
806 retval = MPI_ERR_ARG;
807 } else if (comm == MPI_COMM_NULL) {
808 retval = MPI_ERR_COMM;
810 *comm_out = smpi_comm_split(comm, color, key);
811 retval = MPI_SUCCESS;
817 int PMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst,
818 int tag, MPI_Comm comm, MPI_Request * request)
823 if (request == NULL) {
824 retval = MPI_ERR_ARG;
825 } else if (comm == MPI_COMM_NULL) {
826 retval = MPI_ERR_COMM;
828 *request = smpi_mpi_send_init(buf, count, datatype, dst, tag, comm);
829 retval = MPI_SUCCESS;
835 int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src,
836 int tag, MPI_Comm comm, MPI_Request * request)
841 if (request == NULL) {
842 retval = MPI_ERR_ARG;
843 } else if (comm == MPI_COMM_NULL) {
844 retval = MPI_ERR_COMM;
846 *request = smpi_mpi_recv_init(buf, count, datatype, src, tag, comm);
847 retval = MPI_SUCCESS;
853 int PMPI_Start(MPI_Request * request)
858 if (request == NULL) {
859 retval = MPI_ERR_ARG;
861 smpi_mpi_start(*request);
862 retval = MPI_SUCCESS;
868 int PMPI_Startall(int count, MPI_Request * requests)
873 if (requests == NULL) {
874 retval = MPI_ERR_ARG;
876 smpi_mpi_startall(count, requests);
877 retval = MPI_SUCCESS;
883 int PMPI_Request_free(MPI_Request * request)
888 if (request == NULL) {
889 retval = MPI_ERR_ARG;
891 smpi_mpi_request_free(request);
892 retval = MPI_SUCCESS;
898 int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src,
899 int tag, MPI_Comm comm, MPI_Request * request)
905 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
906 int src_traced = smpi_group_rank(smpi_comm_group(comm), src);
907 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
909 if (request == NULL) {
910 retval = MPI_ERR_ARG;
911 } else if (comm == MPI_COMM_NULL) {
912 retval = MPI_ERR_COMM;
914 *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm);
915 retval = MPI_SUCCESS;
918 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
919 (*request)->recv = 1;
926 int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
927 int tag, MPI_Comm comm, MPI_Request * request)
933 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
934 TRACE_smpi_computing_out(rank);
935 int dst_traced = smpi_group_rank(smpi_comm_group(comm), dst);
936 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
937 TRACE_smpi_send(rank, rank, dst_traced);
939 if (request == NULL) {
940 retval = MPI_ERR_ARG;
941 } else if (comm == MPI_COMM_NULL) {
942 retval = MPI_ERR_COMM;
944 *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm);
945 retval = MPI_SUCCESS;
948 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
949 (*request)->send = 1;
950 TRACE_smpi_computing_in(rank);
958 int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
959 MPI_Comm comm, MPI_Status * status)
965 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
966 int src_traced = smpi_group_rank(smpi_comm_group(comm), src);
967 TRACE_smpi_computing_out(rank);
969 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
971 if (comm == MPI_COMM_NULL) {
972 retval = MPI_ERR_COMM;
974 smpi_mpi_recv(buf, count, datatype, src, tag, comm, status);
975 retval = MPI_SUCCESS;
978 //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
979 if(status!=MPI_STATUS_IGNORE)src_traced = smpi_group_rank(smpi_comm_group(comm), status->MPI_SOURCE);
980 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
981 TRACE_smpi_recv(rank, src_traced, rank);
982 TRACE_smpi_computing_in(rank);
988 int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
995 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
996 TRACE_smpi_computing_out(rank);
997 int dst_traced = smpi_group_rank(smpi_comm_group(comm), dst);
998 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
999 TRACE_smpi_send(rank, rank, dst_traced);
1001 if (comm == MPI_COMM_NULL) {
1002 retval = MPI_ERR_COMM;
1004 smpi_mpi_send(buf, count, datatype, dst, tag, comm);
1005 retval = MPI_SUCCESS;
1008 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
1009 TRACE_smpi_computing_in(rank);
1015 int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1016 int dst, int sendtag, void *recvbuf, int recvcount,
1017 MPI_Datatype recvtype, int src, int recvtag,
1018 MPI_Comm comm, MPI_Status * status)
1024 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1025 TRACE_smpi_computing_out(rank);
1026 int dst_traced = smpi_group_rank(smpi_comm_group(comm), dst);
1027 int src_traced = smpi_group_rank(smpi_comm_group(comm), src);
1028 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
1029 TRACE_smpi_send(rank, rank, dst_traced);
1030 TRACE_smpi_send(rank, src_traced, rank);
1032 if (comm == MPI_COMM_NULL) {
1033 retval = MPI_ERR_COMM;
1034 } else if (sendtype == MPI_DATATYPE_NULL
1035 || recvtype == MPI_DATATYPE_NULL) {
1036 retval = MPI_ERR_TYPE;
1038 smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf,
1039 recvcount, recvtype, src, recvtag, comm, status);
1040 retval = MPI_SUCCESS;
1043 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1044 TRACE_smpi_recv(rank, rank, dst_traced);
1045 TRACE_smpi_recv(rank, src_traced, rank);
1046 TRACE_smpi_computing_in(rank);
1053 int PMPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
1054 int dst, int sendtag, int src, int recvtag,
1055 MPI_Comm comm, MPI_Status * status)
1057 //TODO: suboptimal implementation
1061 size = smpi_datatype_size(datatype) * count;
1062 recvbuf = xbt_new(char, size);
1064 MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
1065 datatype, src, recvtag, comm, status);
1066 memcpy(buf, recvbuf, size * sizeof(char));
1071 int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
1076 if (request == NULL || flag == NULL) {
1077 retval = MPI_ERR_ARG;
1078 } else if (*request == MPI_REQUEST_NULL) {
1079 retval = MPI_ERR_REQUEST;
1081 *flag = smpi_mpi_test(request, status);
1082 retval = MPI_SUCCESS;
1088 int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
1089 MPI_Status * status)
1094 if (index == NULL || flag == NULL) {
1095 retval = MPI_ERR_ARG;
1097 *flag = smpi_mpi_testany(count, requests, index, status);
1098 retval = MPI_SUCCESS;
1104 int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses)
1110 retval = MPI_ERR_ARG;
1112 *flag = smpi_mpi_testall(count, requests, statuses);
1113 retval = MPI_SUCCESS;
1119 int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) {
1123 if (status == NULL) {
1124 retval = MPI_ERR_ARG;
1125 }else if (comm == MPI_COMM_NULL) {
1126 retval = MPI_ERR_COMM;
1128 smpi_mpi_probe(source, tag, comm, status);
1129 retval = MPI_SUCCESS;
1136 int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status) {
1141 retval = MPI_ERR_ARG;
1142 }else if (status == NULL) {
1143 retval = MPI_ERR_ARG;
1144 }else if (comm == MPI_COMM_NULL) {
1145 retval = MPI_ERR_COMM;
1147 smpi_mpi_iprobe(source, tag, comm, flag, status);
1148 retval = MPI_SUCCESS;
1154 int PMPI_Wait(MPI_Request * request, MPI_Status * status)
1160 int rank = request && (*request)->comm != MPI_COMM_NULL
1161 ? smpi_comm_rank((*request)->comm)
1163 TRACE_smpi_computing_out(rank);
1165 MPI_Group group = smpi_comm_group((*request)->comm);
1166 int src_traced = smpi_group_rank(group, (*request)->src);
1167 int dst_traced = smpi_group_rank(group, (*request)->dst);
1168 int is_wait_for_receive = (*request)->recv;
1169 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
1171 if (request == NULL) {
1172 retval = MPI_ERR_ARG;
1173 } else if (*request == MPI_REQUEST_NULL) {
1174 retval = MPI_ERR_REQUEST;
1176 smpi_mpi_wait(request, status);
1177 retval = MPI_SUCCESS;
1180 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1181 if (is_wait_for_receive) {
1182 TRACE_smpi_recv(rank, src_traced, dst_traced);
1184 TRACE_smpi_computing_in(rank);
1191 int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * status)
1197 //save requests information for tracing
1199 xbt_dynar_t srcs = xbt_dynar_new(sizeof(int), NULL);
1200 xbt_dynar_t dsts = xbt_dynar_new(sizeof(int), NULL);
1201 xbt_dynar_t recvs = xbt_dynar_new(sizeof(int), NULL);
1202 for (i = 0; i < count; i++) {
1203 MPI_Request req = requests[i]; //already received requests are no longer valid
1205 int *asrc = xbt_new(int, 1);
1206 int *adst = xbt_new(int, 1);
1207 int *arecv = xbt_new(int, 1);
1211 xbt_dynar_insert_at(srcs, i, asrc);
1212 xbt_dynar_insert_at(dsts, i, adst);
1213 xbt_dynar_insert_at(recvs, i, arecv);
1218 int *t = xbt_new(int, 1);
1219 xbt_dynar_insert_at(srcs, i, t);
1220 xbt_dynar_insert_at(dsts, i, t);
1221 xbt_dynar_insert_at(recvs, i, t);
1225 int rank_traced = smpi_comm_rank(MPI_COMM_WORLD);
1226 TRACE_smpi_computing_out(rank_traced);
1228 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
1231 if (index == NULL) {
1232 retval = MPI_ERR_ARG;
1234 *index = smpi_mpi_waitany(count, requests, status);
1235 retval = MPI_SUCCESS;
1238 int src_traced, dst_traced, is_wait_for_receive;
1239 xbt_dynar_get_cpy(srcs, *index, &src_traced);
1240 xbt_dynar_get_cpy(dsts, *index, &dst_traced);
1241 xbt_dynar_get_cpy(recvs, *index, &is_wait_for_receive);
1242 if (is_wait_for_receive) {
1243 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1245 TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__);
1246 //clean-up of dynars
1247 xbt_dynar_free(&srcs);
1248 xbt_dynar_free(&dsts);
1249 xbt_dynar_free(&recvs);
1250 TRACE_smpi_computing_in(rank_traced);
1257 int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
1262 //save information from requests
1264 xbt_dynar_t srcs = xbt_dynar_new(sizeof(int), NULL);
1265 xbt_dynar_t dsts = xbt_dynar_new(sizeof(int), NULL);
1266 xbt_dynar_t recvs = xbt_dynar_new(sizeof(int), NULL);
1267 for (i = 0; i < count; i++) {
1268 MPI_Request req = requests[i]; //all req should be valid in Waitall
1269 int *asrc = xbt_new(int, 1);
1270 int *adst = xbt_new(int, 1);
1271 int *arecv = xbt_new(int, 1);
1275 xbt_dynar_insert_at(srcs, i, asrc);
1276 xbt_dynar_insert_at(dsts, i, adst);
1277 xbt_dynar_insert_at(recvs, i, arecv);
1282 int rank_traced = smpi_comm_rank (MPI_COMM_WORLD);
1283 TRACE_smpi_computing_out(rank_traced);
1285 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
1287 smpi_mpi_waitall(count, requests, status);
1289 for (i = 0; i < count; i++) {
1290 int src_traced, dst_traced, is_wait_for_receive;
1291 xbt_dynar_get_cpy(srcs, i, &src_traced);
1292 xbt_dynar_get_cpy(dsts, i, &dst_traced);
1293 xbt_dynar_get_cpy(recvs, i, &is_wait_for_receive);
1294 if (is_wait_for_receive) {
1295 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1298 TRACE_smpi_ptp_out(rank_traced, -1, -1, __FUNCTION__);
1299 //clean-up of dynars
1300 xbt_dynar_free(&srcs);
1301 xbt_dynar_free(&dsts);
1302 xbt_dynar_free(&recvs);
1303 TRACE_smpi_computing_in(rank_traced);
1309 int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
1310 int *indices, MPI_Status status[])
1315 if (outcount == NULL || indices == NULL) {
1316 retval = MPI_ERR_ARG;
1318 *outcount = smpi_mpi_waitsome(incount, requests, indices, status);
1319 retval = MPI_SUCCESS;
1325 int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
1331 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1332 TRACE_smpi_computing_out(rank);
1333 int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
1334 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1336 if (comm == MPI_COMM_NULL) {
1337 retval = MPI_ERR_COMM;
1339 smpi_mpi_bcast(buf, count, datatype, root, comm);
1340 retval = MPI_SUCCESS;
1343 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1344 TRACE_smpi_computing_in(rank);
1350 int PMPI_Barrier(MPI_Comm comm)
1356 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1357 TRACE_smpi_computing_out(rank);
1358 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1360 if (comm == MPI_COMM_NULL) {
1361 retval = MPI_ERR_COMM;
1363 smpi_mpi_barrier(comm);
1364 retval = MPI_SUCCESS;
1367 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1368 TRACE_smpi_computing_in(rank);
1374 int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1375 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1376 int root, MPI_Comm comm)
1382 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1383 TRACE_smpi_computing_out(rank);
1384 int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
1385 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1387 if (comm == MPI_COMM_NULL) {
1388 retval = MPI_ERR_COMM;
1389 } else if (sendtype == MPI_DATATYPE_NULL
1390 || recvtype == MPI_DATATYPE_NULL) {
1391 retval = MPI_ERR_TYPE;
1393 smpi_mpi_gather(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1394 recvtype, root, comm);
1395 retval = MPI_SUCCESS;
1398 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1399 TRACE_smpi_computing_in(rank);
1405 int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1406 void *recvbuf, int *recvcounts, int *displs,
1407 MPI_Datatype recvtype, int root, MPI_Comm comm)
1413 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1414 TRACE_smpi_computing_out(rank);
1415 int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
1416 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1418 if (comm == MPI_COMM_NULL) {
1419 retval = MPI_ERR_COMM;
1420 } else if (sendtype == MPI_DATATYPE_NULL
1421 || recvtype == MPI_DATATYPE_NULL) {
1422 retval = MPI_ERR_TYPE;
1423 } else if (recvcounts == NULL || displs == NULL) {
1424 retval = MPI_ERR_ARG;
1426 smpi_mpi_gatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
1427 displs, recvtype, root, comm);
1428 retval = MPI_SUCCESS;
1431 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1432 TRACE_smpi_computing_in(rank);
1438 int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1439 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1446 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1447 TRACE_smpi_computing_out(rank);
1448 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1450 if (comm == MPI_COMM_NULL) {
1451 retval = MPI_ERR_COMM;
1452 } else if (sendtype == MPI_DATATYPE_NULL
1453 || recvtype == MPI_DATATYPE_NULL) {
1454 retval = MPI_ERR_TYPE;
1456 smpi_mpi_allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1458 retval = MPI_SUCCESS;
1461 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1467 int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1468 void *recvbuf, int *recvcounts, int *displs,
1469 MPI_Datatype recvtype, MPI_Comm comm)
1475 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1476 TRACE_smpi_computing_out(rank);
1477 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1479 if (comm == MPI_COMM_NULL) {
1480 retval = MPI_ERR_COMM;
1481 } else if (sendtype == MPI_DATATYPE_NULL
1482 || recvtype == MPI_DATATYPE_NULL) {
1483 retval = MPI_ERR_TYPE;
1484 } else if (recvcounts == NULL || displs == NULL) {
1485 retval = MPI_ERR_ARG;
1487 smpi_mpi_allgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
1488 displs, recvtype, comm);
1489 retval = MPI_SUCCESS;
1492 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1493 TRACE_smpi_computing_in(rank);
1499 int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1500 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1501 int root, MPI_Comm comm)
1507 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1508 TRACE_smpi_computing_out(rank);
1509 int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
1510 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1512 if (comm == MPI_COMM_NULL) {
1513 retval = MPI_ERR_COMM;
1514 } else if (sendtype == MPI_DATATYPE_NULL
1515 || recvtype == MPI_DATATYPE_NULL) {
1516 retval = MPI_ERR_TYPE;
1518 smpi_mpi_scatter(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1519 recvtype, root, comm);
1520 retval = MPI_SUCCESS;
1523 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1524 TRACE_smpi_computing_in(rank);
1530 int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
1531 MPI_Datatype sendtype, void *recvbuf, int recvcount,
1532 MPI_Datatype recvtype, int root, MPI_Comm comm)
1538 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1539 TRACE_smpi_computing_out(rank);
1540 int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
1541 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1543 if (comm == MPI_COMM_NULL) {
1544 retval = MPI_ERR_COMM;
1545 } else if (sendtype == MPI_DATATYPE_NULL
1546 || recvtype == MPI_DATATYPE_NULL) {
1547 retval = MPI_ERR_TYPE;
1548 } else if (sendcounts == NULL || displs == NULL) {
1549 retval = MPI_ERR_ARG;
1551 smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
1552 recvcount, recvtype, root, comm);
1553 retval = MPI_SUCCESS;
1556 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1557 TRACE_smpi_computing_in(rank);
1563 int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
1564 MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
1570 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1571 TRACE_smpi_computing_out(rank);
1572 int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
1573 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1575 if (comm == MPI_COMM_NULL) {
1576 retval = MPI_ERR_COMM;
1577 } else if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
1578 retval = MPI_ERR_ARG;
1580 smpi_mpi_reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
1581 retval = MPI_SUCCESS;
1584 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1585 TRACE_smpi_computing_in(rank);
1591 int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count,
1592 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
1598 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1599 TRACE_smpi_computing_out(rank);
1600 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1602 if (comm == MPI_COMM_NULL) {
1603 retval = MPI_ERR_COMM;
1604 } else if (datatype == MPI_DATATYPE_NULL) {
1605 retval = MPI_ERR_TYPE;
1606 } else if (op == MPI_OP_NULL) {
1607 retval = MPI_ERR_OP;
1609 smpi_mpi_allreduce(sendbuf, recvbuf, count, datatype, op, comm);
1610 retval = MPI_SUCCESS;
1613 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1614 TRACE_smpi_computing_in(rank);
1620 int PMPI_Scan(void *sendbuf, void *recvbuf, int count,
1621 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
1627 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1628 TRACE_smpi_computing_out(rank);
1629 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1631 if (comm == MPI_COMM_NULL) {
1632 retval = MPI_ERR_COMM;
1633 } else if (datatype == MPI_DATATYPE_NULL) {
1634 retval = MPI_ERR_TYPE;
1635 } else if (op == MPI_OP_NULL) {
1636 retval = MPI_ERR_OP;
1638 smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm);
1639 retval = MPI_SUCCESS;
1642 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1643 TRACE_smpi_computing_in(rank);
1649 int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
1650 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
1652 int retval, i, size, count;
1654 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1658 TRACE_smpi_computing_out(rank);
1659 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1661 if (comm == MPI_COMM_NULL) {
1662 retval = MPI_ERR_COMM;
1663 } else if (datatype == MPI_DATATYPE_NULL) {
1664 retval = MPI_ERR_TYPE;
1665 } else if (op == MPI_OP_NULL) {
1666 retval = MPI_ERR_OP;
1667 } else if (recvcounts == NULL) {
1668 retval = MPI_ERR_ARG;
1670 /* arbitrarily choose root as rank 0 */
1671 /* TODO: faster direct implementation ? */
1672 size = smpi_comm_size(comm);
1674 displs = xbt_new(int, size);
1675 for (i = 0; i < size; i++) {
1676 count += recvcounts[i];
1679 smpi_mpi_reduce(sendbuf, recvbuf, count, datatype, op, 0, comm);
1680 smpi_mpi_scatterv(recvbuf, recvcounts, displs, datatype, recvbuf,
1681 recvcounts[rank], datatype, 0, comm);
1683 retval = MPI_SUCCESS;
1686 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1687 TRACE_smpi_computing_in(rank);
1693 int PMPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1694 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1697 int retval, size, sendsize;
1701 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1702 TRACE_smpi_computing_out(rank);
1703 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1705 if (comm == MPI_COMM_NULL) {
1706 retval = MPI_ERR_COMM;
1707 } else if (sendtype == MPI_DATATYPE_NULL
1708 || recvtype == MPI_DATATYPE_NULL) {
1709 retval = MPI_ERR_TYPE;
1711 size = smpi_comm_size(comm);
1712 sendsize = smpi_datatype_size(sendtype) * sendcount;
1713 if (sendsize < 200 && size > 12) {
1715 smpi_coll_tuned_alltoall_bruck(sendbuf, sendcount, sendtype,
1716 recvbuf, recvcount, recvtype,
1718 } else if (sendsize < 3000) {
1720 smpi_coll_tuned_alltoall_basic_linear(sendbuf, sendcount,
1722 recvcount, recvtype, comm);
1725 smpi_coll_tuned_alltoall_pairwise(sendbuf, sendcount, sendtype,
1726 recvbuf, recvcount, recvtype,
1731 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1732 TRACE_smpi_computing_in(rank);
1738 int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
1739 MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
1740 int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
1746 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1747 TRACE_smpi_computing_out(rank);
1748 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1750 if (comm == MPI_COMM_NULL) {
1751 retval = MPI_ERR_COMM;
1752 } else if (sendtype == MPI_DATATYPE_NULL
1753 || recvtype == MPI_DATATYPE_NULL) {
1754 retval = MPI_ERR_TYPE;
1755 } else if (sendcounts == NULL || senddisps == NULL || recvcounts == NULL
1756 || recvdisps == NULL) {
1757 retval = MPI_ERR_ARG;
1760 smpi_coll_basic_alltoallv(sendbuf, sendcounts, senddisps, sendtype,
1761 recvbuf, recvcounts, recvdisps, recvtype,
1765 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1766 TRACE_smpi_computing_in(rank);
1773 int PMPI_Get_processor_name(char *name, int *resultlen)
1775 int retval = MPI_SUCCESS;
1778 strncpy(name, SIMIX_host_get_name(SIMIX_host_self()),
1779 MPI_MAX_PROCESSOR_NAME - 1);
1782 MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
1788 int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
1790 int retval = MPI_SUCCESS;
1794 if (status == NULL || count == NULL) {
1795 retval = MPI_ERR_ARG;
1796 } else if (datatype == MPI_DATATYPE_NULL) {
1797 retval = MPI_ERR_TYPE;
1799 size = smpi_datatype_size(datatype);
1802 } else if (status->count % size != 0) {
1803 retval = MPI_UNDEFINED;
1805 *count = smpi_mpi_get_count(status, datatype);
1812 int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type) {
1816 if (old_type == MPI_DATATYPE_NULL) {
1817 retval = MPI_ERR_TYPE;
1818 } else if (count<=0){
1819 retval = MPI_ERR_COUNT;
1821 retval = smpi_datatype_contiguous(count, old_type, new_type);
1827 int PMPI_Type_commit(MPI_Datatype* datatype) {
1831 if (datatype == MPI_DATATYPE_NULL) {
1832 retval = MPI_ERR_TYPE;
1834 smpi_datatype_commit(datatype);
1835 retval = MPI_SUCCESS;
1842 int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
1846 if (old_type == MPI_DATATYPE_NULL) {
1847 retval = MPI_ERR_TYPE;
1848 } else if (count<=0 || blocklen<=0){
1849 retval = MPI_ERR_COUNT;
1851 retval = smpi_datatype_vector(count, blocklen, stride, old_type, new_type);
1857 int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type) {
1861 if (old_type == MPI_DATATYPE_NULL) {
1862 retval = MPI_ERR_TYPE;
1863 } else if (count<=0 || blocklen<=0){
1864 retval = MPI_ERR_COUNT;
1866 retval = smpi_datatype_hvector(count, blocklen, stride, old_type, new_type);
1873 int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
1877 if (old_type == MPI_DATATYPE_NULL) {
1878 retval = MPI_ERR_TYPE;
1879 } else if (count<=0){
1880 retval = MPI_ERR_COUNT;
1882 retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
1888 int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
1892 if (old_type == MPI_DATATYPE_NULL) {
1893 retval = MPI_ERR_TYPE;
1894 } else if (count<=0){
1895 retval = MPI_ERR_COUNT;
1897 retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
1904 int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
1909 retval = MPI_ERR_COUNT;
1911 retval = smpi_datatype_struct(count, blocklens, indices, old_types, new_type);
1917 /* The following calls are not yet implemented and will fail at runtime. */
1918 /* Once implemented, please move them above this notice. */
1920 static int not_yet_implemented(void) {
1921 XBT_WARN("Not yet implemented");
1925 int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
1926 return not_yet_implemented();
1929 int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) {
1930 return not_yet_implemented();
1933 int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periods, int reorder, MPI_Comm* comm_cart) {
1934 return not_yet_implemented();
1937 int PMPI_Cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) {
1938 return not_yet_implemented();
1941 int PMPI_Cart_map(MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank) {
1942 return not_yet_implemented();
1945 int PMPI_Cart_rank(MPI_Comm comm, int* coords, int* rank) {
1946 return not_yet_implemented();
1949 int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* dest) {
1950 return not_yet_implemented();
1953 int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
1954 return not_yet_implemented();
1957 int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) {
1958 return not_yet_implemented();
1961 int PMPI_Graph_create(MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder, MPI_Comm* comm_graph) {
1962 return not_yet_implemented();
1965 int PMPI_Graph_get(MPI_Comm comm, int maxindex, int maxedges, int* index, int* edges) {
1966 return not_yet_implemented();
1969 int PMPI_Graph_map(MPI_Comm comm_old, int nnodes, int* index, int* edges, int* newrank) {
1970 return not_yet_implemented();
1973 int PMPI_Graph_neighbors(MPI_Comm comm, int rank, int maxneighbors, int* neighbors) {
1974 return not_yet_implemented();
1977 int PMPI_Graph_neighbors_count(MPI_Comm comm, int rank, int* nneighbors) {
1978 return not_yet_implemented();
1981 int PMPI_Graphdims_get(MPI_Comm comm, int* nnodes, int* nedges) {
1982 return not_yet_implemented();
1985 int PMPI_Topo_test(MPI_Comm comm, int* top_type) {
1986 return not_yet_implemented();
1989 int PMPI_Error_class(int errorcode, int* errorclass) {
1990 return not_yet_implemented();
1993 int PMPI_Errhandler_create(MPI_Handler_function* function, MPI_Errhandler* errhandler) {
1994 return not_yet_implemented();
1997 int PMPI_Errhandler_free(MPI_Errhandler* errhandler) {
1998 return not_yet_implemented();
2001 int PMPI_Errhandler_get(MPI_Comm comm, MPI_Errhandler* errhandler) {
2002 return not_yet_implemented();
2005 int PMPI_Error_string(int errorcode, char* string, int* resultlen) {
2006 return not_yet_implemented();
2009 int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler) {
2010 return not_yet_implemented();
2014 int PMPI_Cancel(MPI_Request* request) {
2015 return not_yet_implemented();
2018 int PMPI_Buffer_attach(void* buffer, int size) {
2019 return not_yet_implemented();
2022 int PMPI_Buffer_detach(void* buffer, int* size) {
2023 return not_yet_implemented();
2026 int PMPI_Testsome(int incount, MPI_Request* requests, int* outcount, int* indices, MPI_Status* statuses) {
2027 return not_yet_implemented();
2030 int PMPI_Comm_test_inter(MPI_Comm comm, int* flag) {
2031 return not_yet_implemented();
2034 int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
2035 return not_yet_implemented();
2038 int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2039 return not_yet_implemented();
2042 int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2043 return not_yet_implemented();
2046 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
2047 return not_yet_implemented();
2050 int PMPI_Intercomm_merge(MPI_Comm comm, int high, MPI_Comm* comm_out) {
2051 return not_yet_implemented();
2054 int PMPI_Bsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2055 return not_yet_implemented();
2058 int PMPI_Bsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2059 return not_yet_implemented();
2062 int PMPI_Ibsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2063 return not_yet_implemented();
2066 int PMPI_Comm_remote_group(MPI_Comm comm, MPI_Group* group) {
2067 return not_yet_implemented();
2070 int PMPI_Comm_remote_size(MPI_Comm comm, int* size) {
2071 return not_yet_implemented();
2074 int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2075 return not_yet_implemented();
2079 int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
2080 return not_yet_implemented();
2083 int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) {
2084 return not_yet_implemented();
2087 int PMPI_Attr_put(MPI_Comm comm, int keyval, void* attr_value) {
2088 return not_yet_implemented();
2091 int PMPI_Rsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
2092 return not_yet_implemented();
2095 int PMPI_Rsend_init(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2096 return not_yet_implemented();
2099 int PMPI_Irsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request) {
2100 return not_yet_implemented();
2103 int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
2104 return not_yet_implemented();
2107 int PMPI_Keyval_free(int* keyval) {
2108 return not_yet_implemented();
2111 int PMPI_Test_cancelled(MPI_Status* status, int* flag) {
2112 return not_yet_implemented();
2115 int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
2116 return not_yet_implemented();
2119 int PMPI_Get_elements(MPI_Status* status, MPI_Datatype datatype, int* elements) {
2120 return not_yet_implemented();
2123 int PMPI_Dims_create(int nnodes, int ndims, int* dims) {
2124 return not_yet_implemented();
2127 int PMPI_Initialized(int* flag) {
2128 return not_yet_implemented();