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_coll_private.h"
9 #include "smpi_mpi_dt_private.h"
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi, smpi,
12 "Logging specific to SMPI (mpi)");
15 //this function need to be here because of the calls to smpi_bench
16 int TRACE_smpi_set_category(const char *category)
18 //need to end bench otherwise categories for execution tasks are wrong
19 smpi_bench_end (-1, NULL);
24 if (category != NULL) {
25 ret = TRACE_category(category);
26 TRACE_category_set(SIMIX_process_self(), category);
28 //if category is NULL, trace of platform is disabled for this process
29 TRACE_category_unset(SIMIX_process_self());
33 //begin bench after changing process's category
34 smpi_bench_begin (-1, NULL);
39 /* MPI User level calls */
41 int MPI_Init(int *argc, char ***argv)
43 smpi_process_init(argc, argv);
45 TRACE_smpi_init(smpi_process_index());
47 smpi_bench_begin(-1, NULL);
51 int MPI_Finalize(void)
53 smpi_bench_end(-1, NULL);
55 TRACE_smpi_finalize(smpi_process_index());
57 smpi_process_destroy();
61 int MPI_Init_thread(int *argc, char ***argv, int required, int *provided)
63 if (provided != NULL) {
64 *provided = MPI_THREAD_MULTIPLE;
66 return MPI_Init(argc, argv);
69 int MPI_Query_thread(int *provided)
73 smpi_bench_end(-1, NULL);
74 if (provided == NULL) {
77 *provided = MPI_THREAD_MULTIPLE;
80 smpi_bench_begin(-1, NULL);
84 int MPI_Is_thread_main(int *flag)
88 smpi_bench_end(-1, NULL);
92 *flag = smpi_process_index() == 0;
95 smpi_bench_begin(-1, NULL);
99 int MPI_Abort(MPI_Comm comm, int errorcode)
101 smpi_bench_end(-1, NULL);
102 smpi_process_destroy();
103 // FIXME: should kill all processes in comm instead
104 SIMIX_process_kill(SIMIX_process_self());
108 double MPI_Wtime(void)
112 smpi_bench_end(-1, NULL);
113 time = SIMIX_get_clock();
114 smpi_bench_begin(-1, NULL);
118 int MPI_Address(void *location, MPI_Aint * address)
122 smpi_bench_end(-1, NULL);
124 retval = MPI_ERR_ARG;
126 *address = (MPI_Aint) location;
128 smpi_bench_begin(-1, NULL);
132 int MPI_Type_free(MPI_Datatype * datatype)
136 smpi_bench_end(-1, NULL);
138 retval = MPI_ERR_ARG;
140 // FIXME: always fail for now
141 retval = MPI_ERR_TYPE;
143 smpi_bench_begin(-1, NULL);
147 int MPI_Type_size(MPI_Datatype datatype, int *size)
151 smpi_bench_end(-1, NULL);
152 if (datatype == MPI_DATATYPE_NULL) {
153 retval = MPI_ERR_TYPE;
154 } else if (size == NULL) {
155 retval = MPI_ERR_ARG;
157 *size = (int) smpi_datatype_size(datatype);
158 retval = MPI_SUCCESS;
160 smpi_bench_begin(-1, NULL);
164 int MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb,
169 smpi_bench_end(-1, NULL);
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);
177 smpi_bench_begin(-1, NULL);
181 int MPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent)
186 smpi_bench_end(-1, NULL);
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);
194 smpi_bench_begin(-1, NULL);
198 int MPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp)
202 smpi_bench_end(-1, NULL);
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;
211 smpi_bench_begin(-1, NULL);
215 int MPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp)
219 smpi_bench_end(-1, NULL);
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;
228 smpi_bench_begin(-1, NULL);
232 int MPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op)
236 smpi_bench_end(-1, NULL);
237 if (function == NULL || op == NULL) {
238 retval = MPI_ERR_ARG;
240 *op = smpi_op_new(function, commute);
241 retval = MPI_SUCCESS;
243 smpi_bench_begin(-1, NULL);
247 int MPI_Op_free(MPI_Op * op)
251 smpi_bench_end(-1, NULL);
253 retval = MPI_ERR_ARG;
254 } else if (*op == MPI_OP_NULL) {
257 smpi_op_destroy(*op);
259 retval = MPI_SUCCESS;
261 smpi_bench_begin(-1, NULL);
265 int MPI_Group_free(MPI_Group * group)
269 smpi_bench_end(-1, NULL);
271 retval = MPI_ERR_ARG;
273 smpi_group_destroy(*group);
274 *group = MPI_GROUP_NULL;
275 retval = MPI_SUCCESS;
277 smpi_bench_begin(-1, NULL);
281 int MPI_Group_size(MPI_Group group, int *size)
285 smpi_bench_end(-1, NULL);
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;
294 smpi_bench_begin(-1, NULL);
298 int MPI_Group_rank(MPI_Group group, int *rank)
302 smpi_bench_end(-1, NULL);
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;
311 smpi_bench_begin(-1, NULL);
315 int MPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
316 MPI_Group group2, int *ranks2)
318 int retval, i, index;
320 smpi_bench_end(-1, NULL);
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;
330 smpi_bench_begin(-1, NULL);
334 int MPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result)
338 smpi_bench_end(-1, NULL);
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;
347 smpi_bench_begin(-1, NULL);
351 int MPI_Group_union(MPI_Group group1, MPI_Group group2,
352 MPI_Group * newgroup)
354 int retval, i, proc1, proc2, size, size2;
356 smpi_bench_end(-1, NULL);
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;
388 smpi_bench_begin(-1, NULL);
392 int MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
393 MPI_Group * newgroup)
395 int retval, i, proc1, proc2, size, size2;
397 smpi_bench_end(-1, NULL);
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;
428 smpi_bench_begin(-1, NULL);
432 int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
433 MPI_Group * newgroup)
435 int retval, i, proc1, proc2, size, size2;
437 smpi_bench_end(-1, NULL);
438 if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) {
439 retval = MPI_ERR_GROUP;
440 } else if (newgroup == NULL) {
441 retval = MPI_ERR_ARG;
443 size = size2 = smpi_group_size(group1);
444 for (i = 0; i < size2; i++) {
445 proc1 = smpi_group_index(group1, i);
446 proc2 = smpi_group_rank(group2, proc1);
447 if (proc2 != MPI_UNDEFINED) {
452 *newgroup = MPI_GROUP_EMPTY;
454 *newgroup = smpi_group_new(size);
455 for (i = 0; i < size2; i++) {
456 proc1 = smpi_group_index(group1, i);
457 proc2 = smpi_group_rank(group2, proc1);
458 if (proc2 == MPI_UNDEFINED) {
459 smpi_group_set_mapping(*newgroup, proc1, i);
463 smpi_group_use(*newgroup);
464 retval = MPI_SUCCESS;
466 smpi_bench_begin(-1, NULL);
470 int MPI_Group_incl(MPI_Group group, int n, int *ranks,
471 MPI_Group * newgroup)
473 int retval, i, index;
475 smpi_bench_end(-1, NULL);
476 if (group == MPI_GROUP_NULL) {
477 retval = MPI_ERR_GROUP;
478 } else if (newgroup == NULL) {
479 retval = MPI_ERR_ARG;
482 *newgroup = MPI_GROUP_EMPTY;
483 } else if (n == smpi_group_size(group)) {
486 *newgroup = smpi_group_new(n);
487 for (i = 0; i < n; i++) {
488 index = smpi_group_index(group, ranks[i]);
489 smpi_group_set_mapping(*newgroup, index, i);
492 smpi_group_use(*newgroup);
493 retval = MPI_SUCCESS;
495 smpi_bench_begin(-1, NULL);
499 int MPI_Group_excl(MPI_Group group, int n, int *ranks,
500 MPI_Group * newgroup)
502 int retval, i, size, rank, index;
504 smpi_bench_end(-1, NULL);
505 if (group == MPI_GROUP_NULL) {
506 retval = MPI_ERR_GROUP;
507 } else if (newgroup == NULL) {
508 retval = MPI_ERR_ARG;
512 } else if (n == smpi_group_size(group)) {
513 *newgroup = MPI_GROUP_EMPTY;
515 size = smpi_group_size(group) - n;
516 *newgroup = smpi_group_new(size);
518 while (rank < size) {
519 for (i = 0; i < n; i++) {
520 if (ranks[i] == rank) {
525 index = smpi_group_index(group, rank);
526 smpi_group_set_mapping(*newgroup, index, rank);
531 smpi_group_use(*newgroup);
532 retval = MPI_SUCCESS;
534 smpi_bench_begin(-1, NULL);
538 int MPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
539 MPI_Group * newgroup)
541 int retval, i, j, rank, size, index;
543 smpi_bench_end(-1, NULL);
544 if (group == MPI_GROUP_NULL) {
545 retval = MPI_ERR_GROUP;
546 } else if (newgroup == NULL) {
547 retval = MPI_ERR_ARG;
550 *newgroup = MPI_GROUP_EMPTY;
553 for (i = 0; i < n; i++) {
554 for (rank = ranges[i][0]; /* First */
555 rank >= 0 && rank <= ranges[i][1]; /* Last */
556 rank += ranges[i][2] /* Stride */ ) {
560 if (size == smpi_group_size(group)) {
563 *newgroup = smpi_group_new(size);
565 for (i = 0; i < n; i++) {
566 for (rank = ranges[i][0]; /* First */
567 rank >= 0 && rank <= ranges[i][1]; /* Last */
568 rank += ranges[i][2] /* Stride */ ) {
569 index = smpi_group_index(group, rank);
570 smpi_group_set_mapping(*newgroup, index, j);
576 smpi_group_use(*newgroup);
577 retval = MPI_SUCCESS;
579 smpi_bench_begin(-1, NULL);
583 int MPI_Group_range_excl(MPI_Group group, int n, int ranges[][3],
584 MPI_Group * newgroup)
586 int retval, i, newrank, rank, size, index, add;
588 smpi_bench_end(-1, NULL);
589 if (group == MPI_GROUP_NULL) {
590 retval = MPI_ERR_GROUP;
591 } else if (newgroup == NULL) {
592 retval = MPI_ERR_ARG;
597 size = smpi_group_size(group);
598 for (i = 0; i < n; i++) {
599 for (rank = ranges[i][0]; /* First */
600 rank >= 0 && rank <= ranges[i][1]; /* Last */
601 rank += ranges[i][2] /* Stride */ ) {
606 *newgroup = MPI_GROUP_EMPTY;
608 *newgroup = smpi_group_new(size);
610 while (newrank < size) {
611 for (i = 0; i < n; i++) {
613 for (rank = ranges[i][0]; /* First */
614 rank >= 0 && rank <= ranges[i][1]; /* Last */
615 rank += ranges[i][2] /* Stride */ ) {
616 if (rank == newrank) {
622 index = smpi_group_index(group, newrank);
623 smpi_group_set_mapping(*newgroup, index, newrank);
629 smpi_group_use(*newgroup);
630 retval = MPI_SUCCESS;
632 smpi_bench_begin(-1, NULL);
636 int MPI_Comm_rank(MPI_Comm comm, int *rank)
640 smpi_bench_end(-1, NULL);
641 if (comm == MPI_COMM_NULL) {
642 retval = MPI_ERR_COMM;
644 *rank = smpi_comm_rank(comm);
645 retval = MPI_SUCCESS;
647 smpi_bench_begin(-1, NULL);
651 int MPI_Comm_size(MPI_Comm comm, int *size)
655 smpi_bench_end(-1, NULL);
656 if (comm == MPI_COMM_NULL) {
657 retval = MPI_ERR_COMM;
658 } else if (size == NULL) {
659 retval = MPI_ERR_ARG;
661 *size = smpi_comm_size(comm);
662 retval = MPI_SUCCESS;
664 smpi_bench_begin(-1, NULL);
668 int MPI_Comm_group(MPI_Comm comm, MPI_Group * group)
672 smpi_bench_end(-1, NULL);
673 if (comm == MPI_COMM_NULL) {
674 retval = MPI_ERR_COMM;
675 } else if (group == NULL) {
676 retval = MPI_ERR_ARG;
678 *group = smpi_comm_group(comm);
679 retval = MPI_SUCCESS;
681 smpi_bench_begin(-1, NULL);
685 int MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result)
689 smpi_bench_end(-1, NULL);
690 if (comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) {
691 retval = MPI_ERR_COMM;
692 } else if (result == NULL) {
693 retval = MPI_ERR_ARG;
695 if (comm1 == comm2) { /* Same communicators means same groups */
699 smpi_group_compare(smpi_comm_group(comm1),
700 smpi_comm_group(comm2));
701 if (*result == MPI_IDENT) {
702 *result = MPI_CONGRUENT;
705 retval = MPI_SUCCESS;
707 smpi_bench_begin(-1, NULL);
711 int MPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm)
715 smpi_bench_end(-1, NULL);
716 if (comm == MPI_COMM_NULL) {
717 retval = MPI_ERR_COMM;
718 } else if (newcomm == NULL) {
719 retval = MPI_ERR_ARG;
721 *newcomm = smpi_comm_new(smpi_comm_group(comm));
722 retval = MPI_SUCCESS;
724 smpi_bench_begin(-1, NULL);
728 int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
732 smpi_bench_end(-1, NULL);
733 if (comm == MPI_COMM_NULL) {
734 retval = MPI_ERR_COMM;
735 } else if (group == MPI_GROUP_NULL) {
736 retval = MPI_ERR_GROUP;
737 } else if (newcomm == NULL) {
738 retval = MPI_ERR_ARG;
740 *newcomm = smpi_comm_new(group);
741 retval = MPI_SUCCESS;
743 smpi_bench_begin(-1, NULL);
747 int MPI_Comm_free(MPI_Comm * comm)
751 smpi_bench_end(-1, NULL);
753 retval = MPI_ERR_ARG;
754 } else if (*comm == MPI_COMM_NULL) {
755 retval = MPI_ERR_COMM;
757 smpi_comm_destroy(*comm);
758 *comm = MPI_COMM_NULL;
759 retval = MPI_SUCCESS;
761 smpi_bench_begin(-1, NULL);
765 int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out)
769 smpi_bench_end(-1, NULL);
770 if (comm_out == NULL) {
771 retval = MPI_ERR_ARG;
772 } else if (comm == MPI_COMM_NULL) {
773 retval = MPI_ERR_COMM;
775 *comm_out = smpi_comm_split(comm, color, key);
776 retval = MPI_SUCCESS;
778 smpi_bench_begin(-1, NULL);
782 int MPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst,
783 int tag, MPI_Comm comm, MPI_Request * request)
786 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
788 smpi_bench_end(rank, "Send_init");
789 if (request == NULL) {
790 retval = MPI_ERR_ARG;
791 } else if (comm == MPI_COMM_NULL) {
792 retval = MPI_ERR_COMM;
794 *request = smpi_mpi_send_init(buf, count, datatype, dst, tag, comm);
795 retval = MPI_SUCCESS;
797 smpi_bench_begin(rank, "Send_init");
801 int MPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src,
802 int tag, MPI_Comm comm, MPI_Request * request)
805 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
807 smpi_bench_end(rank, "Recv_init");
808 if (request == NULL) {
809 retval = MPI_ERR_ARG;
810 } else if (comm == MPI_COMM_NULL) {
811 retval = MPI_ERR_COMM;
813 *request = smpi_mpi_recv_init(buf, count, datatype, src, tag, comm);
814 retval = MPI_SUCCESS;
816 smpi_bench_begin(rank, "Recv_init");
820 int MPI_Start(MPI_Request * request)
823 MPI_Comm comm = (*request)->comm;
824 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
826 smpi_bench_end(rank, "Start");
827 if (request == NULL) {
828 retval = MPI_ERR_ARG;
830 smpi_mpi_start(*request);
831 retval = MPI_SUCCESS;
833 smpi_bench_begin(rank, "Start");
837 int MPI_Startall(int count, MPI_Request * requests)
840 MPI_Comm comm = count > 0
841 && requests ? requests[0]->comm : MPI_COMM_NULL;
842 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
844 smpi_bench_end(rank, "Startall");
845 if (requests == NULL) {
846 retval = MPI_ERR_ARG;
848 smpi_mpi_startall(count, requests);
849 retval = MPI_SUCCESS;
851 smpi_bench_begin(rank, "Startall");
855 int MPI_Request_free(MPI_Request * request)
858 MPI_Comm comm = (*request)->comm;
859 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
861 smpi_bench_end(rank, "Request_free");
862 if (request == NULL) {
863 retval = MPI_ERR_ARG;
865 smpi_mpi_request_free(request);
866 retval = MPI_SUCCESS;
868 smpi_bench_begin(rank, "Request_free");
872 int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src,
873 int tag, MPI_Comm comm, MPI_Request * request)
876 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
878 smpi_bench_end(rank, "Irecv");
880 int src_traced = smpi_group_rank(smpi_comm_group(comm), src);
881 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
883 if (request == NULL) {
884 retval = MPI_ERR_ARG;
885 } else if (comm == MPI_COMM_NULL) {
886 retval = MPI_ERR_COMM;
888 *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm);
889 retval = MPI_SUCCESS;
892 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
893 (*request)->recv = 1;
895 smpi_bench_begin(rank, "Irecv");
899 int MPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
900 int tag, MPI_Comm comm, MPI_Request * request)
903 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
905 smpi_bench_end(rank, "Isend");
907 int dst_traced = smpi_group_rank(smpi_comm_group(comm), dst);
908 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
909 TRACE_smpi_send(rank, rank, dst_traced);
911 if (request == NULL) {
912 retval = MPI_ERR_ARG;
913 } else if (comm == MPI_COMM_NULL) {
914 retval = MPI_ERR_COMM;
916 *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm);
917 retval = MPI_SUCCESS;
920 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
921 (*request)->send = 1;
923 smpi_bench_begin(rank, "Isend");
927 int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
928 MPI_Comm comm, MPI_Status * status)
931 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
933 smpi_bench_end(rank, "Recv");
935 int src_traced = smpi_group_rank(smpi_comm_group(comm), src);
936 TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__);
938 if (comm == MPI_COMM_NULL) {
939 retval = MPI_ERR_COMM;
941 smpi_mpi_recv(buf, count, datatype, src, tag, comm, status);
942 retval = MPI_SUCCESS;
945 TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
946 TRACE_smpi_recv(rank, src_traced, rank);
948 smpi_bench_begin(rank, "Recv");
952 int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag,
956 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
958 smpi_bench_end(rank, "Send");
960 int dst_traced = smpi_group_rank(smpi_comm_group(comm), dst);
961 TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__);
962 TRACE_smpi_send(rank, rank, dst_traced);
964 if (comm == MPI_COMM_NULL) {
965 retval = MPI_ERR_COMM;
967 smpi_mpi_send(buf, count, datatype, dst, tag, comm);
968 retval = MPI_SUCCESS;
971 TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
973 smpi_bench_begin(rank, "Send");
977 int MPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
978 int dst, int sendtag, void *recvbuf, int recvcount,
979 MPI_Datatype recvtype, int src, int recvtag,
980 MPI_Comm comm, MPI_Status * status)
983 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
985 smpi_bench_end(rank, "Sendrecv");
987 int dst_traced = smpi_group_rank(smpi_comm_group(comm), dst);
988 int src_traced = smpi_group_rank(smpi_comm_group(comm), src);
989 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
990 TRACE_smpi_send(rank, rank, dst_traced);
991 TRACE_smpi_send(rank, src_traced, rank);
993 if (comm == MPI_COMM_NULL) {
994 retval = MPI_ERR_COMM;
995 } else if (sendtype == MPI_DATATYPE_NULL
996 || recvtype == MPI_DATATYPE_NULL) {
997 retval = MPI_ERR_TYPE;
999 smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf,
1000 recvcount, recvtype, src, recvtag, comm, status);
1001 retval = MPI_SUCCESS;
1004 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1005 TRACE_smpi_recv(rank, rank, dst_traced);
1006 TRACE_smpi_recv(rank, src_traced, rank);
1008 smpi_bench_begin(rank, "Sendrecv");
1012 int MPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype,
1013 int dst, int sendtag, int src, int recvtag,
1014 MPI_Comm comm, MPI_Status * status)
1016 //TODO: suboptimal implementation
1020 size = smpi_datatype_size(datatype) * count;
1021 recvbuf = xbt_new(char, size);
1023 MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count,
1024 datatype, src, recvtag, comm, status);
1025 memcpy(buf, recvbuf, size * sizeof(char));
1030 int MPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
1033 int rank = request && (*request)->comm != MPI_COMM_NULL
1034 ? smpi_comm_rank((*request)->comm)
1037 smpi_bench_end(rank, "Test");
1038 if (request == NULL || flag == NULL) {
1039 retval = MPI_ERR_ARG;
1040 } else if (*request == MPI_REQUEST_NULL) {
1041 retval = MPI_ERR_REQUEST;
1043 *flag = smpi_mpi_test(request, status);
1044 retval = MPI_SUCCESS;
1046 smpi_bench_begin(rank, "Test");
1050 int MPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
1051 MPI_Status * status)
1055 smpi_bench_end(-1, NULL); //FIXME
1056 if (index == NULL || flag == NULL) {
1057 retval = MPI_ERR_ARG;
1059 *flag = smpi_mpi_testany(count, requests, index, status);
1060 retval = MPI_SUCCESS;
1062 smpi_bench_begin(-1, NULL);
1066 int MPI_Wait(MPI_Request * request, MPI_Status * status)
1069 int rank = request && (*request)->comm != MPI_COMM_NULL
1070 ? smpi_comm_rank((*request)->comm)
1073 smpi_bench_end(rank, "Wait");
1075 MPI_Group group = smpi_comm_group((*request)->comm);
1076 int src_traced = smpi_group_rank(group, (*request)->src);
1077 int dst_traced = smpi_group_rank(group, (*request)->dst);
1078 int is_wait_for_receive = (*request)->recv;
1079 TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__);
1081 if (request == NULL) {
1082 retval = MPI_ERR_ARG;
1083 } else if (*request == MPI_REQUEST_NULL) {
1084 retval = MPI_ERR_REQUEST;
1086 smpi_mpi_wait(request, status);
1087 retval = MPI_SUCCESS;
1090 TRACE_smpi_ptp_out(rank, src_traced, dst_traced, __FUNCTION__);
1091 if (is_wait_for_receive) {
1092 TRACE_smpi_recv(rank, src_traced, dst_traced);
1095 smpi_bench_begin(rank, "Wait");
1099 int MPI_Waitany(int count, MPI_Request requests[], int *index,
1100 MPI_Status * status)
1104 smpi_bench_end(-1, NULL); //FIXME
1106 //save requests information for tracing
1108 xbt_dynar_t srcs = xbt_dynar_new(sizeof(int), xbt_free);
1109 xbt_dynar_t dsts = xbt_dynar_new(sizeof(int), xbt_free);
1110 xbt_dynar_t recvs = xbt_dynar_new(sizeof(int), xbt_free);
1111 for (i = 0; i < count; i++) {
1112 MPI_Request req = requests[i]; //already received requests are no longer valid
1114 int *asrc = xbt_new(int, 1);
1115 int *adst = xbt_new(int, 1);
1116 int *arecv = xbt_new(int, 1);
1120 xbt_dynar_insert_at(srcs, i, asrc);
1121 xbt_dynar_insert_at(dsts, i, adst);
1122 xbt_dynar_insert_at(recvs, i, arecv);
1124 int *t = xbt_new(int, 1);
1125 xbt_dynar_insert_at(srcs, i, t);
1126 xbt_dynar_insert_at(dsts, i, t);
1127 xbt_dynar_insert_at(recvs, i, t);
1130 int rank_traced = smpi_comm_rank(MPI_COMM_WORLD);
1131 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
1133 if (index == NULL) {
1134 retval = MPI_ERR_ARG;
1136 *index = smpi_mpi_waitany(count, requests, status);
1137 retval = MPI_SUCCESS;
1140 int src_traced, dst_traced, is_wait_for_receive;
1141 xbt_dynar_get_cpy(srcs, *index, &src_traced);
1142 xbt_dynar_get_cpy(dsts, *index, &dst_traced);
1143 xbt_dynar_get_cpy(recvs, *index, &is_wait_for_receive);
1144 if (is_wait_for_receive) {
1145 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1147 TRACE_smpi_ptp_out(rank_traced, src_traced, dst_traced, __FUNCTION__);
1148 //clean-up of dynars
1153 smpi_bench_begin(-1, NULL);
1157 int MPI_Waitall(int count, MPI_Request requests[], MPI_Status status[])
1160 smpi_bench_end(-1, NULL); //FIXME
1162 //save information from requests
1164 xbt_dynar_t srcs = xbt_dynar_new(sizeof(int), xbt_free);
1165 xbt_dynar_t dsts = xbt_dynar_new(sizeof(int), xbt_free);
1166 xbt_dynar_t recvs = xbt_dynar_new(sizeof(int), xbt_free);
1167 for (i = 0; i < count; i++) {
1168 MPI_Request req = requests[i]; //all req should be valid in Waitall
1169 int *asrc = xbt_new(int, 1);
1170 int *adst = xbt_new(int, 1);
1171 int *arecv = xbt_new(int, 1);
1175 xbt_dynar_insert_at(srcs, i, asrc);
1176 xbt_dynar_insert_at(dsts, i, adst);
1177 xbt_dynar_insert_at(recvs, i, arecv);
1179 int rank_traced = smpi_comm_rank (MPI_COMM_WORLD);
1180 TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__);
1182 smpi_mpi_waitall(count, requests, status);
1184 for (i = 0; i < count; i++) {
1185 int src_traced, dst_traced, is_wait_for_receive;
1186 xbt_dynar_get_cpy(srcs, i, &src_traced);
1187 xbt_dynar_get_cpy(dsts, i, &dst_traced);
1188 xbt_dynar_get_cpy(recvs, i, &is_wait_for_receive);
1189 if (is_wait_for_receive) {
1190 TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
1193 TRACE_smpi_ptp_out(rank_traced, -1, -1, __FUNCTION__);
1194 //clean-up of dynars
1199 smpi_bench_begin(-1, NULL);
1203 int MPI_Waitsome(int incount, MPI_Request requests[], int *outcount,
1204 int *indices, MPI_Status status[])
1208 smpi_bench_end(-1, NULL); //FIXME
1209 if (outcount == NULL || indices == NULL) {
1210 retval = MPI_ERR_ARG;
1212 *outcount = smpi_mpi_waitsome(incount, requests, indices, status);
1213 retval = MPI_SUCCESS;
1215 smpi_bench_begin(-1, NULL);
1219 int MPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root,
1223 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1225 smpi_bench_end(rank, "Bcast");
1227 int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
1228 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1230 if (comm == MPI_COMM_NULL) {
1231 retval = MPI_ERR_COMM;
1233 smpi_mpi_bcast(buf, count, datatype, root, comm);
1234 retval = MPI_SUCCESS;
1237 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1239 smpi_bench_begin(rank, "Bcast");
1243 int MPI_Barrier(MPI_Comm comm)
1246 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1248 smpi_bench_end(rank, "Barrier");
1250 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1252 if (comm == MPI_COMM_NULL) {
1253 retval = MPI_ERR_COMM;
1255 smpi_mpi_barrier(comm);
1256 retval = MPI_SUCCESS;
1259 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1261 smpi_bench_begin(rank, "Barrier");
1265 int MPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1266 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1267 int root, MPI_Comm comm)
1270 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1272 smpi_bench_end(rank, "Gather");
1274 int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
1275 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1277 if (comm == MPI_COMM_NULL) {
1278 retval = MPI_ERR_COMM;
1279 } else if (sendtype == MPI_DATATYPE_NULL
1280 || recvtype == MPI_DATATYPE_NULL) {
1281 retval = MPI_ERR_TYPE;
1283 smpi_mpi_gather(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1284 recvtype, root, comm);
1285 retval = MPI_SUCCESS;
1288 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1290 smpi_bench_begin(rank, "Gather");
1294 int MPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1295 void *recvbuf, int *recvcounts, int *displs,
1296 MPI_Datatype recvtype, int root, MPI_Comm comm)
1299 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1301 smpi_bench_end(rank, "Gatherv");
1303 int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
1304 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1306 if (comm == MPI_COMM_NULL) {
1307 retval = MPI_ERR_COMM;
1308 } else if (sendtype == MPI_DATATYPE_NULL
1309 || recvtype == MPI_DATATYPE_NULL) {
1310 retval = MPI_ERR_TYPE;
1311 } else if (recvcounts == NULL || displs == NULL) {
1312 retval = MPI_ERR_ARG;
1314 smpi_mpi_gatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
1315 displs, recvtype, root, comm);
1316 retval = MPI_SUCCESS;
1319 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1321 smpi_bench_begin(rank, "Gatherv");
1325 int MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1326 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1330 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1332 smpi_bench_end(rank, "Allgather");
1334 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1336 if (comm == MPI_COMM_NULL) {
1337 retval = MPI_ERR_COMM;
1338 } else if (sendtype == MPI_DATATYPE_NULL
1339 || recvtype == MPI_DATATYPE_NULL) {
1340 retval = MPI_ERR_TYPE;
1342 smpi_mpi_allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1344 retval = MPI_SUCCESS;
1347 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1349 smpi_bench_begin(rank, "Allgather");
1353 int MPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1354 void *recvbuf, int *recvcounts, int *displs,
1355 MPI_Datatype recvtype, MPI_Comm comm)
1358 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1360 smpi_bench_end(rank, "Allgatherv");
1362 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1364 if (comm == MPI_COMM_NULL) {
1365 retval = MPI_ERR_COMM;
1366 } else if (sendtype == MPI_DATATYPE_NULL
1367 || recvtype == MPI_DATATYPE_NULL) {
1368 retval = MPI_ERR_TYPE;
1369 } else if (recvcounts == NULL || displs == NULL) {
1370 retval = MPI_ERR_ARG;
1372 smpi_mpi_allgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
1373 displs, recvtype, comm);
1374 retval = MPI_SUCCESS;
1377 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1379 smpi_bench_begin(rank, "Allgatherv");
1383 int MPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1384 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1385 int root, MPI_Comm comm)
1388 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1390 smpi_bench_end(rank, "Scatter");
1392 int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
1393 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1395 if (comm == MPI_COMM_NULL) {
1396 retval = MPI_ERR_COMM;
1397 } else if (sendtype == MPI_DATATYPE_NULL
1398 || recvtype == MPI_DATATYPE_NULL) {
1399 retval = MPI_ERR_TYPE;
1401 smpi_mpi_scatter(sendbuf, sendcount, sendtype, recvbuf, recvcount,
1402 recvtype, root, comm);
1403 retval = MPI_SUCCESS;
1406 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1408 smpi_bench_begin(rank, "Scatter");
1412 int MPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
1413 MPI_Datatype sendtype, void *recvbuf, int recvcount,
1414 MPI_Datatype recvtype, int root, MPI_Comm comm)
1417 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1419 smpi_bench_end(rank, "Scatterv");
1421 int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
1422 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1424 if (comm == MPI_COMM_NULL) {
1425 retval = MPI_ERR_COMM;
1426 } else if (sendtype == MPI_DATATYPE_NULL
1427 || recvtype == MPI_DATATYPE_NULL) {
1428 retval = MPI_ERR_TYPE;
1429 } else if (sendcounts == NULL || displs == NULL) {
1430 retval = MPI_ERR_ARG;
1432 smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
1433 recvcount, recvtype, root, comm);
1434 retval = MPI_SUCCESS;
1437 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1439 smpi_bench_begin(rank, "Scatterv");
1443 int MPI_Reduce(void *sendbuf, void *recvbuf, int count,
1444 MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
1447 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1449 smpi_bench_end(rank, "Reduce");
1451 int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
1452 TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
1454 if (comm == MPI_COMM_NULL) {
1455 retval = MPI_ERR_COMM;
1456 } else if (datatype == MPI_DATATYPE_NULL || op == MPI_OP_NULL) {
1457 retval = MPI_ERR_ARG;
1459 smpi_mpi_reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
1460 retval = MPI_SUCCESS;
1463 TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
1465 smpi_bench_begin(rank, "Reduce");
1469 int MPI_Allreduce(void *sendbuf, void *recvbuf, int count,
1470 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
1473 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1475 smpi_bench_end(rank, "Allreduce");
1477 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1479 if (comm == MPI_COMM_NULL) {
1480 retval = MPI_ERR_COMM;
1481 } else if (datatype == MPI_DATATYPE_NULL) {
1482 retval = MPI_ERR_TYPE;
1483 } else if (op == MPI_OP_NULL) {
1484 retval = MPI_ERR_OP;
1486 smpi_mpi_allreduce(sendbuf, recvbuf, count, datatype, op, comm);
1487 retval = MPI_SUCCESS;
1490 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1492 smpi_bench_begin(rank, "Allreduce");
1496 int MPI_Scan(void *sendbuf, void *recvbuf, int count,
1497 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
1500 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1502 smpi_bench_end(rank, "Scan");
1504 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1506 if (comm == MPI_COMM_NULL) {
1507 retval = MPI_ERR_COMM;
1508 } else if (datatype == MPI_DATATYPE_NULL) {
1509 retval = MPI_ERR_TYPE;
1510 } else if (op == MPI_OP_NULL) {
1511 retval = MPI_ERR_OP;
1513 smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm);
1514 retval = MPI_SUCCESS;
1517 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1519 smpi_bench_begin(rank, "Scan");
1523 int MPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
1524 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
1526 int retval, i, size, count;
1528 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1530 smpi_bench_end(rank, "Reduce_scatter");
1532 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1534 if (comm == MPI_COMM_NULL) {
1535 retval = MPI_ERR_COMM;
1536 } else if (datatype == MPI_DATATYPE_NULL) {
1537 retval = MPI_ERR_TYPE;
1538 } else if (op == MPI_OP_NULL) {
1539 retval = MPI_ERR_OP;
1540 } else if (recvcounts == NULL) {
1541 retval = MPI_ERR_ARG;
1543 /* arbitrarily choose root as rank 0 */
1544 /* TODO: faster direct implementation ? */
1545 size = smpi_comm_size(comm);
1547 displs = xbt_new(int, size);
1548 for (i = 0; i < size; i++) {
1549 count += recvcounts[i];
1552 smpi_mpi_reduce(sendbuf, recvbuf, count, datatype, op, 0, comm);
1553 smpi_mpi_scatterv(recvbuf, recvcounts, displs, datatype, recvbuf,
1554 recvcounts[rank], datatype, 0, comm);
1556 retval = MPI_SUCCESS;
1559 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1561 smpi_bench_begin(rank, "Reduce_scatter");
1565 int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
1566 void *recvbuf, int recvcount, MPI_Datatype recvtype,
1569 int retval, size, sendsize;
1570 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1572 smpi_bench_end(rank, "Alltoall");
1574 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1576 if (comm == MPI_COMM_NULL) {
1577 retval = MPI_ERR_COMM;
1578 } else if (sendtype == MPI_DATATYPE_NULL
1579 || recvtype == MPI_DATATYPE_NULL) {
1580 retval = MPI_ERR_TYPE;
1582 size = smpi_comm_size(comm);
1583 sendsize = smpi_datatype_size(sendtype) * sendcount;
1584 if (sendsize < 200 && size > 12) {
1586 smpi_coll_tuned_alltoall_bruck(sendbuf, sendcount, sendtype,
1587 recvbuf, recvcount, recvtype,
1589 } else if (sendsize < 3000) {
1591 smpi_coll_tuned_alltoall_basic_linear(sendbuf, sendcount,
1593 recvcount, recvtype, comm);
1596 smpi_coll_tuned_alltoall_pairwise(sendbuf, sendcount, sendtype,
1597 recvbuf, recvcount, recvtype,
1602 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1604 smpi_bench_begin(rank, "Alltoall");
1608 int MPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,
1609 MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
1610 int *recvdisps, MPI_Datatype recvtype, MPI_Comm comm)
1613 int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
1615 smpi_bench_end(rank, "Alltoallv");
1617 TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
1619 if (comm == MPI_COMM_NULL) {
1620 retval = MPI_ERR_COMM;
1621 } else if (sendtype == MPI_DATATYPE_NULL
1622 || recvtype == MPI_DATATYPE_NULL) {
1623 retval = MPI_ERR_TYPE;
1624 } else if (sendcounts == NULL || senddisps == NULL || recvcounts == NULL
1625 || recvdisps == NULL) {
1626 retval = MPI_ERR_ARG;
1629 smpi_coll_basic_alltoallv(sendbuf, sendcounts, senddisps, sendtype,
1630 recvbuf, recvcounts, recvdisps, recvtype,
1634 TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
1636 smpi_bench_begin(rank, "Alltoallv");
1641 int MPI_Get_processor_name(char *name, int *resultlen)
1643 int retval = MPI_SUCCESS;
1645 smpi_bench_end(-1, NULL);
1646 strncpy(name, SIMIX_host_get_name(SIMIX_host_self()),
1647 MPI_MAX_PROCESSOR_NAME - 1);
1650 MPI_MAX_PROCESSOR_NAME ? MPI_MAX_PROCESSOR_NAME : strlen(name);
1652 smpi_bench_begin(-1, NULL);
1656 int MPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
1658 int retval = MPI_SUCCESS;
1661 smpi_bench_end(-1, NULL);
1662 if (status == NULL || count == NULL) {
1663 retval = MPI_ERR_ARG;
1664 } else if (datatype == MPI_DATATYPE_NULL) {
1665 retval = MPI_ERR_TYPE;
1667 size = smpi_datatype_size(datatype);
1670 } else if (status->count % size != 0) {
1671 retval = MPI_UNDEFINED;
1673 *count = smpi_mpi_get_count(status, datatype);
1676 smpi_bench_begin(-1, NULL);