1 /* selector for collective algorithms based on mvapich decision logic */
3 /* Copyright (c) 2009-2010, 2013-2014. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #include "colls_private.h"
11 #include "smpi_mvapich2_selector_stampede.h"
14 static void init_mv2_alltoall_tables_stampede(){
16 int agg_table_sum = 0;
17 mv2_alltoall_tuning_table **table_ptrs = NULL;
18 mv2_alltoall_num_ppn_conf = 3;
19 mv2_alltoall_thresholds_table
20 = malloc(sizeof(mv2_alltoall_tuning_table *)
21 * mv2_alltoall_num_ppn_conf);
22 table_ptrs = malloc(sizeof(mv2_alltoall_tuning_table *)
23 * mv2_alltoall_num_ppn_conf);
24 mv2_size_alltoall_tuning_table = malloc(sizeof(int) *
25 mv2_alltoall_num_ppn_conf);
26 mv2_alltoall_table_ppn_conf =malloc(mv2_alltoall_num_ppn_conf * sizeof(int));
27 mv2_alltoall_table_ppn_conf[0] = 1;
28 mv2_size_alltoall_tuning_table[0] = 6;
29 mv2_alltoall_tuning_table mv2_tmp_alltoall_thresholds_table_1ppn[] = {
32 {{0, -1, &MPIR_Alltoall_pairwise_MV2},
35 {{0, -1, &MPIR_Alltoall_inplace_MV2},
41 {{0, 262144, &MPIR_Alltoall_Scatter_dest_MV2},
42 {262144, -1, &MPIR_Alltoall_pairwise_MV2},
45 {{0, -1, &MPIR_Alltoall_inplace_MV2},
51 {{0, 8, &MPIR_Alltoall_RD_MV2},
52 {8, -1, &MPIR_Alltoall_Scatter_dest_MV2},
55 {{0, -1, &MPIR_Alltoall_inplace_MV2},
61 {{0, 64, &MPIR_Alltoall_RD_MV2},
62 {64, 512, &MPIR_Alltoall_bruck_MV2},
63 {512, -1, &MPIR_Alltoall_Scatter_dest_MV2},
66 {{0,-1, &MPIR_Alltoall_inplace_MV2},
72 {{0, 32, &MPIR_Alltoall_RD_MV2},
73 {32, 2048, &MPIR_Alltoall_bruck_MV2},
74 {2048, -1, &MPIR_Alltoall_Scatter_dest_MV2},
77 {{0, -1, &MPIR_Alltoall_inplace_MV2},
83 {{0, 8, &MPIR_Alltoall_RD_MV2},
84 {8, 1024, &MPIR_Alltoall_bruck_MV2},
85 {1024, -1, &MPIR_Alltoall_Scatter_dest_MV2},
88 {{0, -1, &MPIR_Alltoall_inplace_MV2},
92 table_ptrs[0] = mv2_tmp_alltoall_thresholds_table_1ppn;
93 mv2_alltoall_table_ppn_conf[1] = 2;
94 mv2_size_alltoall_tuning_table[1] = 6;
95 mv2_alltoall_tuning_table mv2_tmp_alltoall_thresholds_table_2ppn[] = {
98 {{0, 32, &MPIR_Alltoall_RD_MV2},
99 {32, -1, &MPIR_Alltoall_Scatter_dest_MV2},
102 {{0, -1, &MPIR_Alltoall_inplace_MV2},
108 {{0, 64, &MPIR_Alltoall_RD_MV2},
109 {64, -1, &MPIR_Alltoall_Scatter_dest_MV2},
112 {{0, -1, &MPIR_Alltoall_inplace_MV2},
118 {{0, 64, &MPIR_Alltoall_RD_MV2},
119 {64, 2048, &MPIR_Alltoall_bruck_MV2},
120 {2048, -1, &MPIR_Alltoall_Scatter_dest_MV2},
123 {{0,-1, &MPIR_Alltoall_inplace_MV2},
129 {{0, 16, &MPIR_Alltoall_RD_MV2},
130 {16, 2048, &MPIR_Alltoall_bruck_MV2},
131 {2048, -1, &MPIR_Alltoall_Scatter_dest_MV2},
134 {{0, -1, &MPIR_Alltoall_inplace_MV2},
140 {{0, 8, &MPIR_Alltoall_RD_MV2},
141 {8, 1024, &MPIR_Alltoall_bruck_MV2},
142 {1024, -1, &MPIR_Alltoall_Scatter_dest_MV2},
145 {{0, -1, &MPIR_Alltoall_inplace_MV2},
151 {{0, 4, &MPIR_Alltoall_RD_MV2},
152 {4, 2048, &MPIR_Alltoall_bruck_MV2},
153 {2048, -1, &MPIR_Alltoall_Scatter_dest_MV2},
156 {{0, -1, &MPIR_Alltoall_inplace_MV2},
160 table_ptrs[1] = mv2_tmp_alltoall_thresholds_table_2ppn;
161 mv2_alltoall_table_ppn_conf[2] = 16;
162 mv2_size_alltoall_tuning_table[2] = 7;
163 mv2_alltoall_tuning_table mv2_tmp_alltoall_thresholds_table_16ppn[] = {
166 {{0, 2048, &MPIR_Alltoall_bruck_MV2},
167 {2048, -1, &MPIR_Alltoall_Scatter_dest_MV2},
170 {{32768, -1, &MPIR_Alltoall_inplace_MV2},
176 {{0, 2048, &MPIR_Alltoall_bruck_MV2},
177 {2048, -1, &MPIR_Alltoall_Scatter_dest_MV2},
180 {{16384, -1, &MPIR_Alltoall_inplace_MV2},
186 {{0, 2048, &MPIR_Alltoall_bruck_MV2},
187 {2048, 16384, &MPIR_Alltoall_Scatter_dest_MV2},
188 {16384, -1, &MPIR_Alltoall_pairwise_MV2},
191 {{32768, 131072, &MPIR_Alltoall_inplace_MV2},
197 {{0, 2048, &MPIR_Alltoall_bruck_MV2},
198 {2048, -1, &MPIR_Alltoall_pairwise_MV2},
201 {{16384,65536, &MPIR_Alltoall_inplace_MV2},
207 {{0, 1024, &MPIR_Alltoall_bruck_MV2},
208 {1024, -1, &MPIR_Alltoall_pairwise_MV2},
211 {{16384, 65536, &MPIR_Alltoall_inplace_MV2},
217 {{0, 1024, &MPIR_Alltoall_bruck_MV2},
218 {1024, -1, &MPIR_Alltoall_pairwise_MV2},
221 {{16384, 65536, &MPIR_Alltoall_inplace_MV2},
226 {{0, 1024, &MPIR_Alltoall_bruck_MV2},
227 {1024, -1, &MPIR_Alltoall_pairwise_MV2},
230 {{16384, 65536, &MPIR_Alltoall_inplace_MV2},
235 table_ptrs[2] = mv2_tmp_alltoall_thresholds_table_16ppn;
237 for (i = 0; i < mv2_alltoall_num_ppn_conf; i++) {
238 agg_table_sum += mv2_size_alltoall_tuning_table[i];
240 mv2_alltoall_thresholds_table[0] =
241 malloc(agg_table_sum * sizeof (mv2_alltoall_tuning_table));
242 memcpy(mv2_alltoall_thresholds_table[0], table_ptrs[0],
243 (sizeof(mv2_alltoall_tuning_table)
244 * mv2_size_alltoall_tuning_table[0]));
245 for (i = 1; i < mv2_alltoall_num_ppn_conf; i++) {
246 mv2_alltoall_thresholds_table[i] =
247 mv2_alltoall_thresholds_table[i - 1]
248 + mv2_size_alltoall_tuning_table[i - 1];
249 memcpy(mv2_alltoall_thresholds_table[i], table_ptrs[i],
250 (sizeof(mv2_alltoall_tuning_table)
251 * mv2_size_alltoall_tuning_table[i]));
258 int smpi_coll_tuned_alltoall_mvapich2( void *sendbuf, int sendcount,
259 MPI_Datatype sendtype,
260 void* recvbuf, int recvcount,
261 MPI_Datatype recvtype,
265 if(mv2_alltoall_table_ppn_conf==NULL)
266 init_mv2_alltoall_tables_stampede();
268 int sendtype_size, recvtype_size, nbytes, comm_size;
269 char * tmp_buf = NULL;
270 int mpi_errno=MPI_SUCCESS;
272 int range_threshold = 0;
274 comm_size = smpi_comm_size(comm);
276 sendtype_size=smpi_datatype_size(sendtype);
277 recvtype_size=smpi_datatype_size(recvtype);
278 nbytes = sendtype_size * sendcount;
280 /* check if safe to use partial subscription mode */
282 /* Search for the corresponding system size inside the tuning table */
283 while ((range < (mv2_size_alltoall_tuning_table[conf_index] - 1)) &&
284 (comm_size > mv2_alltoall_thresholds_table[conf_index][range].numproc)) {
287 /* Search for corresponding inter-leader function */
288 while ((range_threshold < (mv2_alltoall_thresholds_table[conf_index][range].size_table - 1))
290 mv2_alltoall_thresholds_table[conf_index][range].algo_table[range_threshold].max)
291 && (mv2_alltoall_thresholds_table[conf_index][range].algo_table[range_threshold].max != -1)) {
294 MV2_Alltoall_function = mv2_alltoall_thresholds_table[conf_index][range].algo_table[range_threshold]
295 .MV2_pt_Alltoall_function;
297 if(sendbuf != MPI_IN_PLACE) {
298 mpi_errno = MV2_Alltoall_function(sendbuf, sendcount, sendtype,
299 recvbuf, recvcount, recvtype,
304 mv2_alltoall_thresholds_table[conf_index][range].in_place_algo_table[range_threshold].min
305 ||nbytes > mv2_alltoall_thresholds_table[conf_index][range].in_place_algo_table[range_threshold].max
307 tmp_buf = (char *)malloc( comm_size * recvcount * recvtype_size );
308 mpi_errno = smpi_datatype_copy((char *)recvbuf,
309 comm_size*recvcount, recvtype,
311 comm_size*recvcount, recvtype);
313 mpi_errno = MV2_Alltoall_function(tmp_buf, recvcount, recvtype,
314 recvbuf, recvcount, recvtype,
318 mpi_errno = MPIR_Alltoall_inplace_MV2(sendbuf, sendcount, sendtype,
319 recvbuf, recvcount, recvtype,
329 static void init_mv2_allgather_tables_stampede(){
331 int agg_table_sum = 0;
332 mv2_allgather_tuning_table **table_ptrs = NULL;
333 mv2_allgather_num_ppn_conf = 3;
334 mv2_allgather_thresholds_table
335 = malloc(sizeof(mv2_allgather_tuning_table *)
336 * mv2_allgather_num_ppn_conf);
337 table_ptrs = malloc(sizeof(mv2_allgather_tuning_table *)
338 * mv2_allgather_num_ppn_conf);
339 mv2_size_allgather_tuning_table = malloc(sizeof(int) *
340 mv2_allgather_num_ppn_conf);
341 mv2_allgather_table_ppn_conf
342 = malloc(mv2_allgather_num_ppn_conf * sizeof(int));
343 mv2_allgather_table_ppn_conf[0] = 1;
344 mv2_size_allgather_tuning_table[0] = 6;
345 mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_1ppn[] = {
351 {0, -1, &MPIR_Allgather_Ring_MV2},
359 {0, 262144, &MPIR_Allgather_RD_MV2},
360 {262144, -1, &MPIR_Allgather_Ring_MV2},
368 {0, 131072, &MPIR_Allgather_RD_MV2},
369 {131072, -1, &MPIR_Allgather_Ring_MV2},
377 {0, 131072, &MPIR_Allgather_RD_MV2},
378 {131072, -1, &MPIR_Allgather_Ring_MV2},
386 {0, 65536, &MPIR_Allgather_RD_MV2},
387 {65536, -1, &MPIR_Allgather_Ring_MV2},
395 {0, 32768, &MPIR_Allgather_RD_MV2},
396 {32768, -1, &MPIR_Allgather_Ring_MV2},
400 table_ptrs[0] = mv2_tmp_allgather_thresholds_table_1ppn;
401 mv2_allgather_table_ppn_conf[1] = 2;
402 mv2_size_allgather_tuning_table[1] = 6;
403 mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_2ppn[] = {
409 {0, 524288, &MPIR_Allgather_RD_MV2},
410 {524288, -1, &MPIR_Allgather_Ring_MV2},
418 {0, 32768, &MPIR_Allgather_RD_MV2},
419 {32768, 524288, &MPIR_Allgather_Ring_MV2},
420 {524288, -1, &MPIR_Allgather_Ring_MV2},
428 {0, 16384, &MPIR_Allgather_RD_MV2},
429 {16384, 524288, &MPIR_Allgather_Ring_MV2},
430 {524288, -1, &MPIR_Allgather_Ring_MV2},
438 {0, 65536, &MPIR_Allgather_RD_MV2},
439 {65536, 524288, &MPIR_Allgather_Ring_MV2},
440 {524288, -1, &MPIR_Allgather_Ring_MV2},
448 {0, 32768, &MPIR_Allgather_RD_MV2},
449 {32768, 524288, &MPIR_Allgather_Ring_MV2},
450 {524288, -1, &MPIR_Allgather_Ring_MV2},
458 {0, 65536, &MPIR_Allgather_RD_MV2},
459 {65536, 524288, &MPIR_Allgather_Ring_MV2},
460 {524288, -1, &MPIR_Allgather_Ring_MV2},
464 table_ptrs[1] = mv2_tmp_allgather_thresholds_table_2ppn;
465 mv2_allgather_table_ppn_conf[2] = 16;
466 mv2_size_allgather_tuning_table[2] = 6;
467 mv2_allgather_tuning_table mv2_tmp_allgather_thresholds_table_16ppn[] = {
473 {0, 1024, &MPIR_Allgather_RD_MV2},
474 {1024, -1, &MPIR_Allgather_Ring_MV2},
482 {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2},
483 {1024, -1, &MPIR_Allgather_Ring_MV2},
491 {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2},
492 {1024, -1, &MPIR_Allgather_Ring_MV2},
500 {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2},
501 {1024, -1, &MPIR_Allgather_Ring_MV2},
509 {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2},
510 {1024, -1, &MPIR_Allgather_Ring_MV2},
518 {0, 1024, &MPIR_Allgather_RD_Allgather_Comm_MV2},
519 {1024, -1, &MPIR_Allgather_Ring_MV2},
524 table_ptrs[2] = mv2_tmp_allgather_thresholds_table_16ppn;
526 for (i = 0; i < mv2_allgather_num_ppn_conf; i++) {
527 agg_table_sum += mv2_size_allgather_tuning_table[i];
529 mv2_allgather_thresholds_table[0] =
530 malloc(agg_table_sum * sizeof (mv2_allgather_tuning_table));
531 memcpy(mv2_allgather_thresholds_table[0], table_ptrs[0],
532 (sizeof(mv2_allgather_tuning_table)
533 * mv2_size_allgather_tuning_table[0]));
534 for (i = 1; i < mv2_allgather_num_ppn_conf; i++) {
535 mv2_allgather_thresholds_table[i] =
536 mv2_allgather_thresholds_table[i - 1]
537 + mv2_size_allgather_tuning_table[i - 1];
538 memcpy(mv2_allgather_thresholds_table[i], table_ptrs[i],
539 (sizeof(mv2_allgather_tuning_table)
540 * mv2_size_allgather_tuning_table[i]));
545 int smpi_coll_tuned_allgather_mvapich2(void *sendbuf, int sendcount, MPI_Datatype sendtype,
546 void *recvbuf, int recvcount, MPI_Datatype recvtype,
550 int mpi_errno = MPI_SUCCESS;
551 int nbytes = 0, comm_size, recvtype_size;
553 //int partial_sub_ok = 0;
555 int range_threshold = 0;
556 int is_two_level = 0;
557 //int local_size = -1;
558 //MPI_Comm shmem_comm;
559 //MPI_Comm *shmem_commptr=NULL;
560 /* Get the size of the communicator */
561 comm_size = smpi_comm_size(comm);
562 recvtype_size=smpi_datatype_size(recvtype);
563 nbytes = recvtype_size * recvcount;
565 if(mv2_allgather_table_ppn_conf==NULL)
566 init_mv2_allgather_tables_stampede();
569 /* check if safe to use partial subscription mode */
570 /* if (comm->ch.shmem_coll_ok == 1 && comm->ch.is_uniform) {
572 shmem_comm = comm->ch.shmem_comm;
573 MPID_Comm_get_ptr(shmem_comm, shmem_commptr);
574 local_size = shmem_commptr->local_size;
576 if (mv2_allgather_table_ppn_conf[0] == -1) {
577 // Indicating user defined tuning
582 if (local_size == mv2_allgather_table_ppn_conf[i]) {
588 } while(i < mv2_allgather_num_ppn_conf);
592 if (partial_sub_ok != 1) {
595 /* Search for the corresponding system size inside the tuning table */
596 while ((range < (mv2_size_allgather_tuning_table[conf_index] - 1)) &&
598 mv2_allgather_thresholds_table[conf_index][range].numproc)) {
601 /* Search for corresponding inter-leader function */
602 while ((range_threshold <
603 (mv2_allgather_thresholds_table[conf_index][range].size_inter_table - 1))
604 && (nbytes > mv2_allgather_thresholds_table[conf_index][range].inter_leader[range_threshold].max)
605 && (mv2_allgather_thresholds_table[conf_index][range].inter_leader[range_threshold].max !=
610 /* Set inter-leader pt */
611 MV2_Allgather_function =
612 mv2_allgather_thresholds_table[conf_index][range].inter_leader[range_threshold].
613 MV2_pt_Allgather_function;
615 is_two_level = mv2_allgather_thresholds_table[conf_index][range].two_level[range_threshold];
617 /* intracommunicator */
618 if(is_two_level ==1){
620 /* if(comm->ch.shmem_coll_ok == 1){
621 MPIR_T_PVAR_COUNTER_INC(MV2, mv2_num_shmem_coll_calls, 1);
622 if (1 == comm->ch.is_blocked) {
623 mpi_errno = MPIR_2lvl_Allgather_MV2(sendbuf, sendcount, sendtype,
624 recvbuf, recvcount, recvtype,
628 mpi_errno = MPIR_Allgather_intra(sendbuf, sendcount, sendtype,
629 recvbuf, recvcount, recvtype,
633 mpi_errno = MPIR_Allgather_RD_MV2(sendbuf, sendcount, sendtype,
634 recvbuf, recvcount, recvtype,
637 } else if(MV2_Allgather_function == &MPIR_Allgather_Bruck_MV2
638 || MV2_Allgather_function == &MPIR_Allgather_RD_MV2
639 || MV2_Allgather_function == &MPIR_Allgather_Ring_MV2) {
640 mpi_errno = MV2_Allgather_function(sendbuf, sendcount, sendtype,
641 recvbuf, recvcount, recvtype,
644 return MPI_ERR_OTHER;
650 static void init_mv2_gather_tables_stampede(){
652 mv2_size_gather_tuning_table=7;
653 mv2_gather_thresholds_table = malloc(mv2_size_gather_tuning_table*
654 sizeof (mv2_gather_tuning_table));
655 mv2_gather_tuning_table mv2_tmp_gather_thresholds_table[]={
657 2,{{0, 524288, &MPIR_Gather_MV2_Direct},
658 {524288, -1, &MPIR_Gather_intra}},
659 1,{{0, -1, &MPIR_Gather_MV2_Direct}}},
661 3,{{0, 16384, &MPIR_Gather_MV2_Direct},
662 {16384, 131072, &MPIR_Gather_intra},
663 {131072, -1, &MPIR_Gather_MV2_two_level_Direct}},
664 1,{{0, -1, &MPIR_Gather_intra}}},
666 3,{{0, 256, &MPIR_Gather_MV2_two_level_Direct},
667 {256, 16384, &MPIR_Gather_MV2_Direct},
668 {256, -1, &MPIR_Gather_MV2_two_level_Direct}},
669 1,{{0, -1, &MPIR_Gather_intra}}},
671 3,{{0, 512, &MPIR_Gather_MV2_two_level_Direct},
672 {512, 16384, &MPIR_Gather_MV2_Direct},
673 {16384, -1, &MPIR_Gather_MV2_two_level_Direct}},
674 1,{{0, -1, &MPIR_Gather_intra}}},
676 3,{{0, 512, &MPIR_Gather_MV2_two_level_Direct},
677 {512, 16384, &MPIR_Gather_MV2_Direct},
678 {16384, -1, &MPIR_Gather_MV2_two_level_Direct}},
679 1,{{0, -1, &MPIR_Gather_intra}}},
681 3,{{0, 512, &MPIR_Gather_MV2_two_level_Direct},
682 {512, 16384, &MPIR_Gather_MV2_Direct},
683 {8196, -1, &MPIR_Gather_MV2_two_level_Direct}},
684 1,{{0, -1, &MPIR_Gather_intra}}},
686 3,{{0, 512, &MPIR_Gather_MV2_two_level_Direct},
687 {512, 16384, &MPIR_Gather_MV2_Direct},
688 {8196, -1, &MPIR_Gather_MV2_two_level_Direct}},
689 1,{{0, -1, &MPIR_Gather_intra}}},
692 memcpy(mv2_gather_thresholds_table, mv2_tmp_gather_thresholds_table,
693 mv2_size_gather_tuning_table * sizeof (mv2_gather_tuning_table));
698 int smpi_coll_tuned_gather_mvapich2(void *sendbuf,
700 MPI_Datatype sendtype,
703 MPI_Datatype recvtype,
704 int root, MPI_Comm comm)
706 if(mv2_gather_thresholds_table==NULL)
707 init_mv2_gather_tables_stampede();
709 int mpi_errno = MPI_SUCCESS;
711 int range_threshold = 0;
712 int range_intra_threshold = 0;
715 int recvtype_size, sendtype_size;
717 comm_size = smpi_comm_size(comm);
718 rank = smpi_comm_rank(comm);
721 recvtype_size=smpi_datatype_size(recvtype);
722 nbytes = recvcnt * recvtype_size;
724 sendtype_size=smpi_datatype_size(sendtype);
725 nbytes = sendcnt * sendtype_size;
728 /* Search for the corresponding system size inside the tuning table */
729 while ((range < (mv2_size_gather_tuning_table - 1)) &&
730 (comm_size > mv2_gather_thresholds_table[range].numproc)) {
733 /* Search for corresponding inter-leader function */
734 while ((range_threshold < (mv2_gather_thresholds_table[range].size_inter_table - 1))
736 mv2_gather_thresholds_table[range].inter_leader[range_threshold].max)
737 && (mv2_gather_thresholds_table[range].inter_leader[range_threshold].max !=
742 /* Search for corresponding intra node function */
743 while ((range_intra_threshold < (mv2_gather_thresholds_table[range].size_intra_table - 1))
745 mv2_gather_thresholds_table[range].intra_node[range_intra_threshold].max)
746 && (mv2_gather_thresholds_table[range].intra_node[range_intra_threshold].max !=
748 range_intra_threshold++;
751 if (comm->ch.is_global_block == 1 && mv2_use_direct_gather == 1 &&
752 mv2_use_two_level_gather == 1 && comm->ch.shmem_coll_ok == 1) {
753 // Set intra-node function pt for gather_two_level
754 MV2_Gather_intra_node_function =
755 mv2_gather_thresholds_table[range].intra_node[range_intra_threshold].
756 MV2_pt_Gather_function;
757 //Set inter-leader pt
758 MV2_Gather_inter_leader_function =
759 mv2_gather_thresholds_table[range].inter_leader[range_threshold].
760 MV2_pt_Gather_function;
761 // We call Gather function
763 MV2_Gather_inter_leader_function(sendbuf, sendcnt, sendtype, recvbuf, recvcnt,
764 recvtype, root, comm);
767 // Indded, direct (non SMP-aware)gather is MPICH one
768 mpi_errno = smpi_coll_tuned_gather_mpich(sendbuf, sendcnt, sendtype,
769 recvbuf, recvcnt, recvtype,
778 static void init_mv2_allgatherv_tables_stampede(){
779 mv2_size_allgatherv_tuning_table = 6;
780 mv2_allgatherv_thresholds_table = malloc(mv2_size_allgatherv_tuning_table *
781 sizeof (mv2_allgatherv_tuning_table));
782 mv2_allgatherv_tuning_table mv2_tmp_allgatherv_thresholds_table[] = {
787 {0, 512, &MPIR_Allgatherv_Rec_Doubling_MV2},
788 {512, -1, &MPIR_Allgatherv_Ring_MV2},
795 {0, 512, &MPIR_Allgatherv_Rec_Doubling_MV2},
796 {512, -1, &MPIR_Allgatherv_Ring_MV2},
803 {0, 256, &MPIR_Allgatherv_Rec_Doubling_MV2},
804 {256, -1, &MPIR_Allgatherv_Ring_MV2},
811 {0, 256, &MPIR_Allgatherv_Rec_Doubling_MV2},
812 {256, -1, &MPIR_Allgatherv_Ring_MV2},
819 {0, 256, &MPIR_Allgatherv_Rec_Doubling_MV2},
820 {256, -1, &MPIR_Allgatherv_Ring_MV2},
827 {0, 256, &MPIR_Allgatherv_Rec_Doubling_MV2},
828 {256, -1, &MPIR_Allgatherv_Ring_MV2},
833 memcpy(mv2_allgatherv_thresholds_table, mv2_tmp_allgatherv_thresholds_table,
834 mv2_size_allgatherv_tuning_table * sizeof (mv2_allgatherv_tuning_table));
843 int smpi_coll_tuned_allgatherv_mvapich2(void *sendbuf, int sendcount, MPI_Datatype sendtype,
844 void *recvbuf, int *recvcounts, int *displs,
845 MPI_Datatype recvtype, MPI_Comm comm )
847 int mpi_errno = MPI_SUCCESS;
848 int range = 0, comm_size, total_count, recvtype_size, i;
849 int range_threshold = 0;
852 if(mv2_allgatherv_thresholds_table==NULL)
853 init_mv2_allgatherv_tables_stampede();
855 comm_size = smpi_comm_size(comm);
857 for (i = 0; i < comm_size; i++)
858 total_count += recvcounts[i];
860 recvtype_size=smpi_datatype_size(recvtype);
861 nbytes = total_count * recvtype_size;
863 /* Search for the corresponding system size inside the tuning table */
864 while ((range < (mv2_size_allgatherv_tuning_table - 1)) &&
865 (comm_size > mv2_allgatherv_thresholds_table[range].numproc)) {
868 /* Search for corresponding inter-leader function */
869 while ((range_threshold < (mv2_allgatherv_thresholds_table[range].size_inter_table - 1))
871 comm_size * mv2_allgatherv_thresholds_table[range].inter_leader[range_threshold].max)
872 && (mv2_allgatherv_thresholds_table[range].inter_leader[range_threshold].max !=
876 /* Set inter-leader pt */
877 MV2_Allgatherv_function =
878 mv2_allgatherv_thresholds_table[range].inter_leader[range_threshold].
879 MV2_pt_Allgatherv_function;
881 if (MV2_Allgatherv_function == &MPIR_Allgatherv_Rec_Doubling_MV2)
883 if(!(comm_size & (comm_size - 1)))
886 MPIR_Allgatherv_Rec_Doubling_MV2(sendbuf, sendcount,
892 MPIR_Allgatherv_Bruck_MV2(sendbuf, sendcount,
899 MV2_Allgatherv_function(sendbuf, sendcount, sendtype,
900 recvbuf, recvcounts, displs,
908 static void init_mv2_allreduce_tables_stampede(){
909 mv2_size_allreduce_tuning_table = 8;
910 mv2_allreduce_thresholds_table = malloc(mv2_size_allreduce_tuning_table *
911 sizeof (mv2_allreduce_tuning_table));
912 mv2_allreduce_tuning_table mv2_tmp_allreduce_thresholds_table[] = {
919 {0, 1024, &MPIR_Allreduce_pt2pt_rd_MV2},
920 {1024, -1, &MPIR_Allreduce_pt2pt_rs_MV2},
924 {0, 1024, &MPIR_Allreduce_reduce_shmem_MV2},
925 {1024, -1, &MPIR_Allreduce_reduce_p2p_MV2},
934 {0, 1024, &MPIR_Allreduce_pt2pt_rd_MV2},
935 {1024, 16384, &MPIR_Allreduce_pt2pt_rd_MV2},
936 {16384, -1, &MPIR_Allreduce_pt2pt_rs_MV2},
940 {0, 1024, &MPIR_Allreduce_reduce_shmem_MV2},
941 {1024, 16384, &MPIR_Allreduce_reduce_p2p_MV2},
950 {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
951 {512, 16384, &MPIR_Allreduce_pt2pt_rd_MV2},
952 {16384, -1, &MPIR_Allreduce_pt2pt_rs_MV2},
956 {0, 512, &MPIR_Allreduce_reduce_shmem_MV2},
957 {512, 16384, &MPIR_Allreduce_reduce_p2p_MV2},
966 {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
967 {512, 16384, &MPIR_Allreduce_pt2pt_rd_MV2},
968 {16384, -1, &MPIR_Allreduce_pt2pt_rs_MV2},
972 {0, 512, &MPIR_Allreduce_reduce_shmem_MV2},
973 {512, 16384, &MPIR_Allreduce_reduce_p2p_MV2},
982 {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
983 {512, 16384, &MPIR_Allreduce_pt2pt_rd_MV2},
984 {16384, -1, &MPIR_Allreduce_pt2pt_rs_MV2},
988 {0, 512, &MPIR_Allreduce_reduce_shmem_MV2},
989 {512, -1, &MPIR_Allreduce_reduce_p2p_MV2},
998 {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
999 {512, 16384, &MPIR_Allreduce_pt2pt_rd_MV2},
1000 {16384, -1, &MPIR_Allreduce_pt2pt_rs_MV2},
1004 {0, 512, &MPIR_Allreduce_reduce_shmem_MV2},
1005 {512, 16384, &MPIR_Allreduce_reduce_p2p_MV2},
1014 {0, 512, &MPIR_Allreduce_pt2pt_rd_MV2},
1015 {512, 8192, &MPIR_Allreduce_pt2pt_rd_MV2},
1016 {8192, 65536, &MPIR_Allreduce_pt2pt_rs_MV2},
1017 {65536, -1, &MPIR_Allreduce_pt2pt_rs_MV2},
1021 {0, 512, &MPIR_Allreduce_reduce_shmem_MV2},
1022 {512, -1, &MPIR_Allreduce_reduce_p2p_MV2},
1031 {0, 64, &MPIR_Allreduce_pt2pt_rd_MV2},
1032 {64, 512, &MPIR_Allreduce_reduce_p2p_MV2},
1033 {512, 4096, &MPIR_Allreduce_mcst_reduce_two_level_helper_MV2},
1034 {4096, 16384, &MPIR_Allreduce_pt2pt_rs_MV2},
1035 {16384, -1, &MPIR_Allreduce_pt2pt_rs_MV2},
1039 {0, 512, &MPIR_Allreduce_reduce_shmem_MV2},
1040 {512, -1, &MPIR_Allreduce_reduce_p2p_MV2},
1045 memcpy(mv2_allreduce_thresholds_table, mv2_tmp_allreduce_thresholds_table,
1046 mv2_size_allreduce_tuning_table * sizeof (mv2_allreduce_tuning_table));
1050 int smpi_coll_tuned_allreduce_mvapich2(void *sendbuf,
1053 MPI_Datatype datatype,
1054 MPI_Op op, MPI_Comm comm)
1057 int mpi_errno = MPI_SUCCESS;
1061 comm_size = smpi_comm_size(comm);
1062 //rank = smpi_comm_rank(comm);
1068 if (mv2_allreduce_thresholds_table == NULL)
1069 init_mv2_allreduce_tables_stampede();
1071 /* check if multiple threads are calling this collective function */
1073 MPI_Aint sendtype_size = 0;
1075 int range = 0, range_threshold = 0, range_threshold_intra = 0;
1076 int is_two_level = 0;
1077 //int is_commutative = 0;
1078 MPI_Aint true_lb, true_extent;
1080 sendtype_size=smpi_datatype_size(datatype);
1081 nbytes = count * sendtype_size;
1083 smpi_datatype_extent(datatype, &true_lb, &true_extent);
1085 //is_commutative = smpi_op_is_commute(op);
1088 /* Search for the corresponding system size inside the tuning table */
1089 while ((range < (mv2_size_allreduce_tuning_table - 1)) &&
1090 (comm_size > mv2_allreduce_thresholds_table[range].numproc)) {
1093 /* Search for corresponding inter-leader function */
1094 /* skip mcast poiters if mcast is not available */
1095 if(mv2_allreduce_thresholds_table[range].mcast_enabled != 1){
1096 while ((range_threshold < (mv2_allreduce_thresholds_table[range].size_inter_table - 1))
1097 && ((mv2_allreduce_thresholds_table[range].
1098 inter_leader[range_threshold].MV2_pt_Allreduce_function
1099 == &MPIR_Allreduce_mcst_reduce_redscat_gather_MV2) ||
1100 (mv2_allreduce_thresholds_table[range].
1101 inter_leader[range_threshold].MV2_pt_Allreduce_function
1102 == &MPIR_Allreduce_mcst_reduce_two_level_helper_MV2)
1107 while ((range_threshold < (mv2_allreduce_thresholds_table[range].size_inter_table - 1))
1109 mv2_allreduce_thresholds_table[range].inter_leader[range_threshold].max)
1110 && (mv2_allreduce_thresholds_table[range].inter_leader[range_threshold].max != -1)) {
1113 if(mv2_allreduce_thresholds_table[range].is_two_level_allreduce[range_threshold] == 1){
1116 /* Search for corresponding intra-node function */
1117 while ((range_threshold_intra <
1118 (mv2_allreduce_thresholds_table[range].size_intra_table - 1))
1120 mv2_allreduce_thresholds_table[range].intra_node[range_threshold_intra].max)
1121 && (mv2_allreduce_thresholds_table[range].intra_node[range_threshold_intra].max !=
1123 range_threshold_intra++;
1126 MV2_Allreduce_function = mv2_allreduce_thresholds_table[range].inter_leader[range_threshold]
1127 .MV2_pt_Allreduce_function;
1129 MV2_Allreduce_intra_function = mv2_allreduce_thresholds_table[range].intra_node[range_threshold_intra]
1130 .MV2_pt_Allreduce_function;
1132 /* check if mcast is ready, otherwise replace mcast with other algorithm */
1133 if((MV2_Allreduce_function == &MPIR_Allreduce_mcst_reduce_redscat_gather_MV2)||
1134 (MV2_Allreduce_function == &MPIR_Allreduce_mcst_reduce_two_level_helper_MV2)){
1136 MV2_Allreduce_function = &MPIR_Allreduce_pt2pt_rd_MV2;
1138 if(is_two_level != 1) {
1139 MV2_Allreduce_function = &MPIR_Allreduce_pt2pt_rd_MV2;
1143 if(is_two_level == 1){
1144 // check if shm is ready, if not use other algorithm first
1145 /*if ((comm->ch.shmem_coll_ok == 1)
1146 && (mv2_enable_shmem_allreduce)
1148 && (mv2_enable_shmem_collectives)) {
1149 mpi_errno = MPIR_Allreduce_two_level_MV2(sendbuf, recvbuf, count,
1150 datatype, op, comm);
1152 mpi_errno = MPIR_Allreduce_pt2pt_rd_MV2(sendbuf, recvbuf, count,
1153 datatype, op, comm);
1156 mpi_errno = MV2_Allreduce_function(sendbuf, recvbuf, count,
1157 datatype, op, comm);
1161 //comm->ch.intra_node_done=0;
1169 int smpi_coll_tuned_alltoallv_mvapich2(void *sbuf, int *scounts, int *sdisps,
1170 MPI_Datatype sdtype,
1171 void *rbuf, int *rcounts, int *rdisps,
1172 MPI_Datatype rdtype,
1177 if (sbuf == MPI_IN_PLACE) {
1178 return smpi_coll_tuned_alltoallv_ompi_basic_linear(sbuf, scounts, sdisps, sdtype,
1179 rbuf, rcounts, rdisps,rdtype,
1181 } else /* For starters, just keep the original algorithm. */
1182 return smpi_coll_tuned_alltoallv_pair(sbuf, scounts, sdisps, sdtype,
1183 rbuf, rcounts, rdisps,rdtype,
1188 int smpi_coll_tuned_barrier_mvapich2(MPI_Comm comm)
1190 return smpi_coll_tuned_barrier_mvapich2_pair(comm);
1195 static void init_mv2_bcast_tables_stampede(){
1197 mv2_size_bcast_tuning_table=8;
1198 mv2_bcast_thresholds_table = malloc(mv2_size_bcast_tuning_table *
1199 sizeof (mv2_bcast_tuning_table));
1201 mv2_bcast_tuning_table mv2_tmp_bcast_thresholds_table[]={
1205 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
1208 {0, 8, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
1209 {8, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1210 {16, 1024, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
1211 {1024, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1212 {8192, 16384, &MPIR_Bcast_binomial_MV2, -1},
1213 {16384, 32768, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1214 {32768, 65536, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
1215 {65536, 131072, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1},
1216 {131072, 262144, &MPIR_Bcast_scatter_ring_allgather_MV2, -1},
1217 {262144, 524288, &MPIR_Bcast_scatter_doubling_allgather_MV2, -1},
1218 {524288, -1, &MPIR_Bcast_scatter_ring_allgather_MV2, -1}
1222 {0, 8, &MPIR_Shmem_Bcast_MV2, 2},
1223 {8, 16, &MPIR_Shmem_Bcast_MV2, 4},
1224 {16, 1024, &MPIR_Shmem_Bcast_MV2, 2},
1225 {1024, 8192, &MPIR_Shmem_Bcast_MV2, 4},
1226 {8192, 16384, &MPIR_Shmem_Bcast_MV2, -1},
1227 {16384, 32768, &MPIR_Shmem_Bcast_MV2, 4},
1228 {32768, 65536, &MPIR_Shmem_Bcast_MV2, 2},
1229 {65536, 131072, &MPIR_Shmem_Bcast_MV2, -1},
1230 {131072, 262144, &MPIR_Shmem_Bcast_MV2, -1},
1231 {262144, 524288, &MPIR_Shmem_Bcast_MV2, -1},
1232 {524288, -1, &MPIR_Shmem_Bcast_MV2, -1}
1238 {1, 1, 1, 1, 1, 1, 1, 1},
1241 {0, 128, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
1242 {128, 256, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1243 {256, 32768, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
1244 {32768, 65536, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1245 {65536, 131072, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
1246 {131072, 262144, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
1247 {262144, 524288, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
1248 {524288, -1, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8}
1252 {0, 128, &MPIR_Shmem_Bcast_MV2, 2},
1253 {128, 256, &MPIR_Shmem_Bcast_MV2, 4},
1254 {256, 32768, &MPIR_Shmem_Bcast_MV2, 2},
1255 {32768, 65536, &MPIR_Shmem_Bcast_MV2, 4},
1256 {65536, 131072, &MPIR_Shmem_Bcast_MV2, 2},
1257 {131072, 262144, &MPIR_Shmem_Bcast_MV2, 8},
1258 {262144, 524288, &MPIR_Shmem_Bcast_MV2, 2},
1259 {524288, -1, &MPIR_Shmem_Bcast_MV2, 8}
1265 {1, 1, 1, 1, 1, 1, 1, 1, 1},
1268 {0, 2, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1269 {2, 4, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
1270 {4, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1271 {16, 32, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
1272 {32, 128, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1273 {128, 256, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
1274 {256, 4096, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1275 {4096, 32768, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
1276 {32768, -1, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2}
1280 {0, 2, &MPIR_Shmem_Bcast_MV2, 4},
1281 {2, 4, &MPIR_Shmem_Bcast_MV2, 8},
1282 {4, 16, &MPIR_Shmem_Bcast_MV2, 4},
1283 {16, 32, &MPIR_Shmem_Bcast_MV2, 8},
1284 {32, 128, &MPIR_Shmem_Bcast_MV2, 4},
1285 {128, 256, &MPIR_Shmem_Bcast_MV2, 8},
1286 {256, 4096, &MPIR_Shmem_Bcast_MV2, 4},
1287 {4096, 32768, &MPIR_Shmem_Bcast_MV2, 8},
1288 {32768, -1, &MPIR_Shmem_Bcast_MV2, 2}
1297 {0, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
1298 {8192, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1299 {16384, 524288, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
1300 {524288, -1, &MPIR_Bcast_scatter_ring_allgather_MV2, -1}
1304 {0, 8192, &MPIR_Shmem_Bcast_MV2, 8},
1305 {8192, 16384, &MPIR_Shmem_Bcast_MV2, 4},
1306 {16384, 524288, &MPIR_Shmem_Bcast_MV2, 2},
1307 {524288, -1, NULL, -1}
1316 {0, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1317 {16384, 131072, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
1318 {131072, 262144, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1},
1319 {262144, 524288, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
1320 {524288, -1, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1}
1324 {0, 16384, &MPIR_Shmem_Bcast_MV2, 4},
1325 {16384, 131072, &MPIR_Shmem_Bcast_MV2, 2},
1326 {131072, 262144, &MPIR_Shmem_Bcast_MV2, -1},
1327 {262144, 524288, &MPIR_Shmem_Bcast_MV2, 2},
1328 {524288, -1, &MPIR_Shmem_Bcast_MV2, -1}
1337 {0, 4096, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
1338 {4096, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1339 {16384, 131072, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
1340 {131072, 262144, &MPIR_Pipelined_Bcast_MV2, -1},
1341 {262144, -1, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1}
1345 {0, 4096, &MPIR_Shmem_Bcast_MV2, 8},
1346 {4096, 16384, &MPIR_Shmem_Bcast_MV2, 4},
1347 {16384, 131072, &MPIR_Shmem_Bcast_MV2, 2},
1348 {131072, 262144, &MPIR_Shmem_Bcast_MV2, -1},
1349 {262144, -1, &MPIR_Shmem_Bcast_MV2, -1}
1358 {0, 8192, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
1359 {8192, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1360 {16384, 65536, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
1361 {65536, 524288, &MPIR_Pipelined_Bcast_MV2, -1},
1362 {524288, -1, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1}
1366 {0, 8192, &MPIR_Shmem_Bcast_MV2, 8},
1367 {8192, 16384, &MPIR_Shmem_Bcast_MV2, 4},
1368 {16384, 65536, &MPIR_Shmem_Bcast_MV2, 2},
1369 {65536, 524288, &MPIR_Shmem_Bcast_MV2, -1},
1370 {524288, -1, &MPIR_Shmem_Bcast_MV2, -1}
1376 {1, 1, 1, 1, 1, 1, 1},
1379 {0, 16, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
1380 {16, 32, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1381 {32, 4096, &MPIR_Pipelined_Bcast_Zcpy_MV2, 8},
1382 {4096, 16384, &MPIR_Pipelined_Bcast_Zcpy_MV2, 4},
1383 {16384, 32768, &MPIR_Pipelined_Bcast_Zcpy_MV2, 2},
1384 {32768, 524288, &MPIR_Pipelined_Bcast_MV2, -1},
1385 {524288, -1, &MPIR_Bcast_scatter_ring_allgather_shm_MV2, -1}
1389 {0, 16, &MPIR_Shmem_Bcast_MV2, 8},
1390 {16, 32, &MPIR_Shmem_Bcast_MV2, 4},
1391 {32, 4096, &MPIR_Shmem_Bcast_MV2, 8},
1392 {4096, 16384, &MPIR_Shmem_Bcast_MV2, 4},
1393 {16384, 32768, &MPIR_Shmem_Bcast_MV2, 2},
1394 {32768, 524288, &MPIR_Shmem_Bcast_MV2, -1},
1395 {524288, -1, &MPIR_Shmem_Bcast_MV2, -1}
1400 memcpy(mv2_bcast_thresholds_table, mv2_tmp_bcast_thresholds_table,
1401 mv2_size_bcast_tuning_table * sizeof (mv2_bcast_tuning_table));
1405 int smpi_coll_tuned_bcast_mvapich2(void *buffer,
1407 MPI_Datatype datatype,
1408 int root, MPI_Comm comm)
1411 //TODO : Bcast really needs intra/inter phases in mvapich. Default to mpich if not available
1412 return smpi_coll_tuned_bcast_mpich(buffer, count, datatype, root, comm);
1416 static void init_mv2_reduce_tables_stampede(){
1418 mv2_size_reduce_tuning_table = 8;
1419 mv2_reduce_thresholds_table = malloc(mv2_size_reduce_tuning_table *
1420 sizeof (mv2_reduce_tuning_table));
1421 mv2_reduce_tuning_table mv2_tmp_reduce_thresholds_table[] = {
1429 {0, 262144, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1430 {262144, 1048576, &MPIR_Reduce_binomial_MV2},
1431 {1048576, -1, &MPIR_Reduce_redscat_gather_MV2},
1435 {0, 65536, &MPIR_Reduce_shmem_MV2},
1436 {65536,-1, &MPIR_Reduce_binomial_MV2},
1443 {1, 1, 1, 1, 0, 0, 0},
1446 {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1447 {8192, 16384, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1448 {16384, 32768, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1449 {32768, 65536, &MPIR_Reduce_binomial_MV2},
1450 {65536, 262144, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1451 {262144, 1048576, &MPIR_Reduce_binomial_MV2},
1452 {1048576, -1, &MPIR_Reduce_redscat_gather_MV2},
1456 {0, 8192, &MPIR_Reduce_shmem_MV2},
1457 {8192, 16384, &MPIR_Reduce_intra_knomial_wrapper_MV2},
1458 {16384, 32768, &MPIR_Reduce_shmem_MV2},
1459 {32768, 65536, &MPIR_Reduce_shmem_MV2},
1460 {65536, 262144, &MPIR_Reduce_shmem_MV2},
1461 {262144,-1, &MPIR_Reduce_binomial_MV2},
1471 {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1472 {8192, 16384, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1473 {16384, 65536, &MPIR_Reduce_binomial_MV2},
1474 {65536, 262144, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1475 {262144, -1, &MPIR_Reduce_redscat_gather_MV2},
1479 {0, 8192, &MPIR_Reduce_shmem_MV2},
1480 {8192, 16384, &MPIR_Reduce_intra_knomial_wrapper_MV2},
1481 {16384, 65536, &MPIR_Reduce_shmem_MV2},
1482 {65536, 262144, &MPIR_Reduce_intra_knomial_wrapper_MV2},
1483 {262144, -1, &MPIR_Reduce_binomial_MV2},
1493 {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1494 {8192, 16384, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1495 {16384, 65536, &MPIR_Reduce_binomial_MV2},
1496 {65536, 262144, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1497 {262144, 1048576, &MPIR_Reduce_binomial_MV2},
1498 {1048576, -1, &MPIR_Reduce_redscat_gather_MV2},
1502 {0, 8192, &MPIR_Reduce_shmem_MV2},
1503 {8192, 16384, &MPIR_Reduce_intra_knomial_wrapper_MV2},
1504 {16384, 65536, &MPIR_Reduce_shmem_MV2},
1505 {65536, 262144, &MPIR_Reduce_intra_knomial_wrapper_MV2},
1506 {262144, -1, &MPIR_Reduce_binomial_MV2},
1513 {1, 1, 1, 0, 1, 1, 0},
1516 {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1517 {8192, 16384, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1518 {16384, 32768, &MPIR_Reduce_binomial_MV2},
1519 {32768, 65536, &MPIR_Reduce_binomial_MV2},
1520 {65536, 262144, &MPIR_Reduce_binomial_MV2},
1521 {262144, 1048576, &MPIR_Reduce_binomial_MV2},
1522 {1048576, -1, &MPIR_Reduce_redscat_gather_MV2},
1526 {0, 8192, &MPIR_Reduce_shmem_MV2},
1527 {8192, 16384, &MPIR_Reduce_intra_knomial_wrapper_MV2},
1528 {16384, 32768, &MPIR_Reduce_shmem_MV2},
1529 {32768, 65536, &MPIR_Reduce_shmem_MV2},
1530 {65536, 262144, &MPIR_Reduce_intra_knomial_wrapper_MV2},
1531 {262144, -1, &MPIR_Reduce_binomial_MV2},
1541 {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1542 {8192, 16384, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1543 {16384, 65536, &MPIR_Reduce_binomial_MV2},
1544 {65536, 262144, &MPIR_Reduce_binomial_MV2},
1545 {262144, 1048576, &MPIR_Reduce_binomial_MV2},
1546 {1048576, -1, &MPIR_Reduce_redscat_gather_MV2},
1550 {0, 8192, &MPIR_Reduce_shmem_MV2},
1551 {8192, 16384, &MPIR_Reduce_intra_knomial_wrapper_MV2},
1552 {16384, 65536, &MPIR_Reduce_shmem_MV2},
1553 {65536, 262144, &MPIR_Reduce_intra_knomial_wrapper_MV2},
1554 {262144, -1, &MPIR_Reduce_binomial_MV2},
1564 {0, 8192, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1565 {8192, 16384, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1566 {16384, 65536, &MPIR_Reduce_binomial_MV2},
1567 {65536, 262144, &MPIR_Reduce_binomial_MV2},
1568 {262144, -1, &MPIR_Reduce_binomial_MV2},
1572 {0, 8192, &MPIR_Reduce_shmem_MV2},
1573 {8192, 16384, &MPIR_Reduce_intra_knomial_wrapper_MV2},
1574 {16384, 65536, &MPIR_Reduce_shmem_MV2},
1575 {65536, 262144, &MPIR_Reduce_intra_knomial_wrapper_MV2},
1576 {262144, -1, &MPIR_Reduce_binomial_MV2},
1586 {0, 2048, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1587 {2048, 4096, &MPIR_Reduce_inter_knomial_wrapper_MV2},
1588 {4096, 16384, &MPIR_Reduce_binomial_MV2},
1589 {16384, 65536, &MPIR_Reduce_binomial_MV2},
1590 {65536, 131072, &MPIR_Reduce_binomial_MV2},
1591 {131072, -1, &MPIR_Reduce_binomial_MV2},
1595 {0, 2048, &MPIR_Reduce_shmem_MV2},
1596 {2048, 4096, &MPIR_Reduce_shmem_MV2},
1597 {4096, 16384, &MPIR_Reduce_shmem_MV2},
1598 {16384, 65536, &MPIR_Reduce_intra_knomial_wrapper_MV2},
1599 {65536, 131072, &MPIR_Reduce_binomial_MV2},
1600 {131072, -1, &MPIR_Reduce_shmem_MV2},
1605 memcpy(mv2_reduce_thresholds_table, mv2_tmp_reduce_thresholds_table,
1606 mv2_size_reduce_tuning_table * sizeof (mv2_reduce_tuning_table));
1611 int smpi_coll_tuned_reduce_mvapich2( void *sendbuf,
1614 MPI_Datatype datatype,
1615 MPI_Op op, int root, MPI_Comm comm)
1617 if(mv2_reduce_thresholds_table == NULL)
1618 init_mv2_reduce_tables_stampede();
1620 int mpi_errno = MPI_SUCCESS;
1622 int range_threshold = 0;
1623 int range_intra_threshold = 0;
1624 int is_commutative, pof2;
1628 int is_two_level = 0;
1630 comm_size = smpi_comm_size(comm);
1631 sendtype_size=smpi_datatype_size(datatype);
1632 nbytes = count * sendtype_size;
1637 is_commutative = smpi_op_is_commute(op);
1639 /* find nearest power-of-two less than or equal to comm_size */
1640 for( pof2 = 1; pof2 <= comm_size; pof2 <<= 1 );
1644 /* Search for the corresponding system size inside the tuning table */
1645 while ((range < (mv2_size_reduce_tuning_table - 1)) &&
1646 (comm_size > mv2_reduce_thresholds_table[range].numproc)) {
1649 /* Search for corresponding inter-leader function */
1650 while ((range_threshold < (mv2_reduce_thresholds_table[range].size_inter_table - 1))
1652 mv2_reduce_thresholds_table[range].inter_leader[range_threshold].max)
1653 && (mv2_reduce_thresholds_table[range].inter_leader[range_threshold].max !=
1658 /* Search for corresponding intra node function */
1659 while ((range_intra_threshold < (mv2_reduce_thresholds_table[range].size_intra_table - 1))
1661 mv2_reduce_thresholds_table[range].intra_node[range_intra_threshold].max)
1662 && (mv2_reduce_thresholds_table[range].intra_node[range_intra_threshold].max !=
1664 range_intra_threshold++;
1667 /* Set intra-node function pt for reduce_two_level */
1668 MV2_Reduce_intra_function =
1669 mv2_reduce_thresholds_table[range].intra_node[range_intra_threshold].
1670 MV2_pt_Reduce_function;
1671 /* Set inter-leader pt */
1672 MV2_Reduce_function =
1673 mv2_reduce_thresholds_table[range].inter_leader[range_threshold].
1674 MV2_pt_Reduce_function;
1676 if(mv2_reduce_intra_knomial_factor<0)
1678 mv2_reduce_intra_knomial_factor = mv2_reduce_thresholds_table[range].intra_k_degree;
1680 if(mv2_reduce_inter_knomial_factor<0)
1682 mv2_reduce_inter_knomial_factor = mv2_reduce_thresholds_table[range].inter_k_degree;
1684 if(mv2_reduce_thresholds_table[range].is_two_level_reduce[range_threshold] == 1){
1687 /* We call Reduce function */
1688 if(is_two_level == 1)
1690 /* if (comm->ch.shmem_coll_ok == 1
1691 && is_commutative == 1) {
1692 mpi_errno = MPIR_Reduce_two_level_helper_MV2(sendbuf, recvbuf, count,
1693 datatype, op, root, comm, errflag);
1695 mpi_errno = MPIR_Reduce_binomial_MV2(sendbuf, recvbuf, count,
1696 datatype, op, root, comm);
1698 } else if(MV2_Reduce_function == &MPIR_Reduce_inter_knomial_wrapper_MV2 ){
1699 if(is_commutative ==1)
1701 mpi_errno = MV2_Reduce_function(sendbuf, recvbuf, count,
1702 datatype, op, root, comm);
1704 mpi_errno = MPIR_Reduce_binomial_MV2(sendbuf, recvbuf, count,
1705 datatype, op, root, comm);
1707 } else if(MV2_Reduce_function == &MPIR_Reduce_redscat_gather_MV2){
1708 if (/*(HANDLE_GET_KIND(op) == HANDLE_KIND_BUILTIN) &&*/ (count >= pof2))
1710 mpi_errno = MV2_Reduce_function(sendbuf, recvbuf, count,
1711 datatype, op, root, comm);
1713 mpi_errno = MPIR_Reduce_binomial_MV2(sendbuf, recvbuf, count,
1714 datatype, op, root, comm);
1717 mpi_errno = MV2_Reduce_function(sendbuf, recvbuf, count,
1718 datatype, op, root, comm);
1728 static void init_mv2_reduce_scatter_tables_stampede(){
1729 mv2_size_red_scat_tuning_table = 6;
1730 mv2_red_scat_thresholds_table = malloc(mv2_size_red_scat_tuning_table *
1731 sizeof (mv2_red_scat_tuning_table));
1732 mv2_red_scat_tuning_table mv2_tmp_red_scat_thresholds_table[] = {
1737 {0, 64, &MPIR_Reduce_Scatter_Basic_MV2},
1738 {64, 65536, &MPIR_Reduce_scatter_Rec_Halving_MV2},
1739 {65536, -1, &MPIR_Reduce_scatter_Pair_Wise_MV2},
1746 {0, 64, &MPIR_Reduce_Scatter_Basic_MV2},
1747 {64, 131072, &MPIR_Reduce_scatter_Rec_Halving_MV2},
1748 {131072, -1, &MPIR_Reduce_scatter_Pair_Wise_MV2},
1755 {0, 1024, &MPIR_Reduce_Scatter_Basic_MV2},
1756 {1024, 262144, &MPIR_Reduce_scatter_Rec_Halving_MV2},
1757 {262144, -1, &MPIR_Reduce_scatter_Pair_Wise_MV2},
1764 {0, 128, &MPIR_Reduce_Scatter_Basic_MV2},
1765 {128, -1, &MPIR_Reduce_scatter_Rec_Halving_MV2},
1772 {0, 128, &MPIR_Reduce_Scatter_Basic_MV2},
1773 {128, -1, &MPIR_Reduce_scatter_Rec_Halving_MV2},
1780 {0, 256, &MPIR_Reduce_Scatter_Basic_MV2},
1781 {256, -1, &MPIR_Reduce_scatter_Rec_Halving_MV2},
1786 memcpy(mv2_red_scat_thresholds_table, mv2_tmp_red_scat_thresholds_table,
1787 mv2_size_red_scat_tuning_table * sizeof (mv2_red_scat_tuning_table));
1790 int smpi_coll_tuned_reduce_scatter_mvapich2(void *sendbuf, void *recvbuf, int *recvcnts,
1791 MPI_Datatype datatype, MPI_Op op,
1794 int mpi_errno = MPI_SUCCESS;
1795 int i = 0, comm_size = smpi_comm_size(comm), total_count = 0, type_size =
1798 int range_threshold = 0;
1799 int is_commutative = 0;
1800 int *disps = malloc(comm_size * sizeof (int));
1802 if(mv2_red_scat_thresholds_table==NULL)
1803 init_mv2_reduce_scatter_tables_stampede();
1805 is_commutative=smpi_op_is_commute(op);
1806 for (i = 0; i < comm_size; i++) {
1807 disps[i] = total_count;
1808 total_count += recvcnts[i];
1811 type_size=smpi_datatype_size(datatype);
1812 nbytes = total_count * type_size;
1814 if (is_commutative) {
1816 /* Search for the corresponding system size inside the tuning table */
1817 while ((range < (mv2_size_red_scat_tuning_table - 1)) &&
1818 (comm_size > mv2_red_scat_thresholds_table[range].numproc)) {
1821 /* Search for corresponding inter-leader function */
1822 while ((range_threshold < (mv2_red_scat_thresholds_table[range].size_inter_table - 1))
1824 mv2_red_scat_thresholds_table[range].inter_leader[range_threshold].max)
1825 && (mv2_red_scat_thresholds_table[range].inter_leader[range_threshold].max !=
1830 /* Set inter-leader pt */
1831 MV2_Red_scat_function =
1832 mv2_red_scat_thresholds_table[range].inter_leader[range_threshold].
1833 MV2_pt_Red_scat_function;
1835 mpi_errno = MV2_Red_scat_function(sendbuf, recvbuf,
1839 mpi_errno = MPIR_Reduce_scatter_non_comm_MV2(sendbuf, recvbuf,
1850 static void init_mv2_scatter_tables_stampede(){
1852 int agg_table_sum = 0;
1854 mv2_scatter_tuning_table **table_ptrs = NULL;
1855 mv2_scatter_num_ppn_conf = 3;
1856 mv2_scatter_thresholds_table
1857 = malloc(sizeof(mv2_scatter_tuning_table *)
1858 * mv2_scatter_num_ppn_conf);
1859 table_ptrs = malloc(sizeof(mv2_scatter_tuning_table *)
1860 * mv2_scatter_num_ppn_conf);
1861 mv2_size_scatter_tuning_table = malloc(sizeof(int) *
1862 mv2_scatter_num_ppn_conf);
1863 mv2_scatter_table_ppn_conf
1864 = malloc(mv2_scatter_num_ppn_conf * sizeof(int));
1865 mv2_scatter_table_ppn_conf[0] = 1;
1866 mv2_size_scatter_tuning_table[0] = 6;
1867 mv2_scatter_tuning_table mv2_tmp_scatter_thresholds_table_1ppn[] = {
1871 {0, -1, &MPIR_Scatter_MV2_Binomial},
1875 {0, -1, &MPIR_Scatter_MV2_Binomial},
1882 {0, -1, &MPIR_Scatter_MV2_Direct},
1886 {0, -1, &MPIR_Scatter_MV2_Direct},
1893 {0, -1, &MPIR_Scatter_MV2_Direct},
1897 {0, -1, &MPIR_Scatter_MV2_Direct},
1904 {0, -1, &MPIR_Scatter_MV2_Direct},
1908 {0, -1, &MPIR_Scatter_MV2_Direct},
1915 {0, -1, &MPIR_Scatter_MV2_Direct},
1919 {0, -1, &MPIR_Scatter_MV2_Direct},
1926 {0, 32, &MPIR_Scatter_MV2_Binomial},
1927 {32, -1, &MPIR_Scatter_MV2_Direct},
1931 {0, -1, &MPIR_Scatter_MV2_Binomial},
1935 table_ptrs[0] = mv2_tmp_scatter_thresholds_table_1ppn;
1936 mv2_scatter_table_ppn_conf[1] = 2;
1937 mv2_size_scatter_tuning_table[1] = 6;
1938 mv2_scatter_tuning_table mv2_tmp_scatter_thresholds_table_2ppn[] = {
1942 {0, 4096, &MPIR_Scatter_MV2_Binomial},
1943 {4096, -1, &MPIR_Scatter_MV2_Direct},
1947 {0, -1, &MPIR_Scatter_MV2_Direct},
1954 {0, 512, &MPIR_Scatter_MV2_two_level_Direct},
1955 {512, -1, &MPIR_Scatter_MV2_Direct},
1959 {0, -1, &MPIR_Scatter_MV2_Binomial},
1966 {0, 2048, &MPIR_Scatter_MV2_two_level_Direct},
1967 {2048, -1, &MPIR_Scatter_MV2_Direct},
1971 {0, -1, &MPIR_Scatter_MV2_Binomial},
1978 {0, 2048, &MPIR_Scatter_MV2_two_level_Direct},
1979 {2048, -1, &MPIR_Scatter_MV2_Direct},
1983 {0, -1, &MPIR_Scatter_MV2_Binomial},
1990 {0, 8192, &MPIR_Scatter_MV2_two_level_Direct},
1991 {8192, -1, &MPIR_Scatter_MV2_Direct},
1995 {0, -1, &MPIR_Scatter_MV2_Binomial},
2002 {0, 16, &MPIR_Scatter_MV2_Binomial},
2003 {16, 128, &MPIR_Scatter_MV2_two_level_Binomial},
2004 {128, 16384, &MPIR_Scatter_MV2_two_level_Direct},
2005 {16384, -1, &MPIR_Scatter_MV2_Direct},
2009 {0, 128, &MPIR_Scatter_MV2_Direct},
2010 {128, -1, &MPIR_Scatter_MV2_Binomial},
2014 table_ptrs[1] = mv2_tmp_scatter_thresholds_table_2ppn;
2015 mv2_scatter_table_ppn_conf[2] = 16;
2016 mv2_size_scatter_tuning_table[2] = 8;
2017 mv2_scatter_tuning_table mv2_tmp_scatter_thresholds_table_16ppn[] = {
2022 {0, 256, &MPIR_Scatter_MV2_Binomial},
2023 {256, -1, &MPIR_Scatter_MV2_Direct},
2027 { 0, -1, &MPIR_Scatter_MV2_Direct},
2035 {0, 512, &MPIR_Scatter_MV2_Binomial},
2036 {512, -1, &MPIR_Scatter_MV2_Direct},
2040 { 0, -1, &MPIR_Scatter_MV2_Direct},
2048 {0, 1024, &MPIR_Scatter_MV2_two_level_Direct},
2049 {1024, -1, &MPIR_Scatter_MV2_Direct},
2053 { 0, -1, &MPIR_Scatter_MV2_Direct},
2061 {0, 16, &MPIR_Scatter_mcst_wrap_MV2},
2062 {0, 16, &MPIR_Scatter_MV2_two_level_Direct},
2063 {16, 2048, &MPIR_Scatter_MV2_two_level_Direct},
2064 {2048, -1, &MPIR_Scatter_MV2_Direct},
2068 { 0, -1, &MPIR_Scatter_MV2_Direct},
2076 {0, 16, &MPIR_Scatter_mcst_wrap_MV2},
2077 {0, 16, &MPIR_Scatter_MV2_two_level_Direct},
2078 {16, 2048, &MPIR_Scatter_MV2_two_level_Direct},
2079 {2048, -1, &MPIR_Scatter_MV2_Direct},
2083 { 0, -1, &MPIR_Scatter_MV2_Direct},
2091 {0, 16, &MPIR_Scatter_mcst_wrap_MV2},
2092 {16, 16, &MPIR_Scatter_MV2_two_level_Direct},
2093 {16, 4096, &MPIR_Scatter_MV2_two_level_Direct},
2094 {4096, -1, &MPIR_Scatter_MV2_Direct},
2098 { 0, -1, &MPIR_Scatter_MV2_Binomial},
2105 {0, 16, &MPIR_Scatter_mcst_wrap_MV2},
2106 {0, 16, &MPIR_Scatter_MV2_Binomial},
2107 {16, 32, &MPIR_Scatter_MV2_Binomial},
2108 {32, 4096, &MPIR_Scatter_MV2_two_level_Direct},
2109 {4096, -1, &MPIR_Scatter_MV2_Direct},
2113 { 0, -1, &MPIR_Scatter_MV2_Binomial},
2120 {0, 16, &MPIR_Scatter_mcst_wrap_MV2},
2121 {0, 16, &MPIR_Scatter_MV2_two_level_Binomial},
2122 {16, 128, &MPIR_Scatter_MV2_two_level_Binomial},
2123 {128, 1024, &MPIR_Scatter_MV2_two_level_Direct},
2124 {1024, 16384, &MPIR_Scatter_MV2_two_level_Direct},
2125 {16384, 65536, &MPIR_Scatter_MV2_Direct},
2126 {65536, -1, &MPIR_Scatter_MV2_two_level_Direct},
2130 {0, 16, &MPIR_Scatter_MV2_Binomial},
2131 {16, 128, &MPIR_Scatter_MV2_Binomial},
2132 {128, 1024, &MPIR_Scatter_MV2_Binomial},
2133 {1024, 16384, &MPIR_Scatter_MV2_Direct},
2134 {16384, 65536, &MPIR_Scatter_MV2_Direct},
2135 {65536, -1, &MPIR_Scatter_MV2_Direct},
2139 table_ptrs[2] = mv2_tmp_scatter_thresholds_table_16ppn;
2141 for (i = 0; i < mv2_scatter_num_ppn_conf; i++) {
2142 agg_table_sum += mv2_size_scatter_tuning_table[i];
2144 mv2_scatter_thresholds_table[0] =
2145 malloc(agg_table_sum * sizeof (mv2_scatter_tuning_table));
2146 memcpy(mv2_scatter_thresholds_table[0], table_ptrs[0],
2147 (sizeof(mv2_scatter_tuning_table)
2148 * mv2_size_scatter_tuning_table[0]));
2149 for (i = 1; i < mv2_scatter_num_ppn_conf; i++) {
2150 mv2_scatter_thresholds_table[i] =
2151 mv2_scatter_thresholds_table[i - 1]
2152 + mv2_size_scatter_tuning_table[i - 1];
2153 memcpy(mv2_scatter_thresholds_table[i], table_ptrs[i],
2154 (sizeof(mv2_scatter_tuning_table)
2155 * mv2_size_scatter_tuning_table[i]));
2161 int smpi_coll_tuned_scatter_mvapich2(void *sendbuf,
2163 MPI_Datatype sendtype,
2166 MPI_Datatype recvtype,
2167 int root, MPI_Comm comm_ptr)
2169 int range = 0, range_threshold = 0, range_threshold_intra = 0;
2170 int mpi_errno = MPI_SUCCESS;
2171 // int mpi_errno_ret = MPI_SUCCESS;
2172 int rank, nbytes, comm_size;
2173 int recvtype_size, sendtype_size;
2174 int partial_sub_ok = 0;
2176 // int local_size = -1;
2178 // MPI_Comm shmem_comm;
2179 // MPID_Comm *shmem_commptr=NULL;
2180 if(mv2_scatter_thresholds_table==NULL)
2181 init_mv2_scatter_tables_stampede();
2183 comm_size = smpi_comm_size(comm_ptr);
2185 rank = smpi_comm_rank(comm_ptr);
2188 sendtype_size=smpi_datatype_size(sendtype);
2189 nbytes = sendcnt * sendtype_size;
2191 recvtype_size=smpi_datatype_size(recvtype);
2192 nbytes = recvcnt * recvtype_size;
2195 // check if safe to use partial subscription mode
2196 if (comm_ptr->ch.shmem_coll_ok == 1 && comm_ptr->ch.is_uniform) {
2198 shmem_comm = comm_ptr->ch.shmem_comm;
2199 MPID_Comm_get_ptr(shmem_comm, shmem_commptr);
2200 local_size = shmem_commptr->local_size;
2202 if (mv2_scatter_table_ppn_conf[0] == -1) {
2203 // Indicating user defined tuning
2205 goto conf_check_end;
2208 if (local_size == mv2_scatter_table_ppn_conf[i]) {
2214 } while(i < mv2_scatter_num_ppn_conf);
2217 if (partial_sub_ok != 1) {
2221 /* Search for the corresponding system size inside the tuning table */
2222 while ((range < (mv2_size_scatter_tuning_table[conf_index] - 1)) &&
2223 (comm_size > mv2_scatter_thresholds_table[conf_index][range].numproc)) {
2226 /* Search for corresponding inter-leader function */
2227 while ((range_threshold < (mv2_scatter_thresholds_table[conf_index][range].size_inter_table - 1))
2229 mv2_scatter_thresholds_table[conf_index][range].inter_leader[range_threshold].max)
2230 && (mv2_scatter_thresholds_table[conf_index][range].inter_leader[range_threshold].max != -1)) {
2234 /* Search for corresponding intra-node function */
2235 while ((range_threshold_intra <
2236 (mv2_scatter_thresholds_table[conf_index][range].size_intra_table - 1))
2238 mv2_scatter_thresholds_table[conf_index][range].intra_node[range_threshold_intra].max)
2239 && (mv2_scatter_thresholds_table[conf_index][range].intra_node[range_threshold_intra].max !=
2241 range_threshold_intra++;
2244 MV2_Scatter_function = mv2_scatter_thresholds_table[conf_index][range].inter_leader[range_threshold]
2245 .MV2_pt_Scatter_function;
2247 if(MV2_Scatter_function == &MPIR_Scatter_mcst_wrap_MV2) {
2248 #if defined(_MCST_SUPPORT_)
2249 if(comm_ptr->ch.is_mcast_ok == 1
2250 && mv2_use_mcast_scatter == 1
2251 && comm_ptr->ch.shmem_coll_ok == 1) {
2252 MV2_Scatter_function = &MPIR_Scatter_mcst_MV2;
2254 #endif /*#if defined(_MCST_SUPPORT_) */
2256 if(mv2_scatter_thresholds_table[conf_index][range].inter_leader[range_threshold + 1].
2257 MV2_pt_Scatter_function != NULL) {
2258 MV2_Scatter_function = mv2_scatter_thresholds_table[conf_index][range].inter_leader[range_threshold + 1]
2259 .MV2_pt_Scatter_function;
2262 MV2_Scatter_function = &MPIR_Scatter_MV2_Binomial;
2267 if( (MV2_Scatter_function == &MPIR_Scatter_MV2_two_level_Direct) ||
2268 (MV2_Scatter_function == &MPIR_Scatter_MV2_two_level_Binomial)) {
2269 /* if( comm_ptr->ch.shmem_coll_ok == 1 &&
2270 comm_ptr->ch.is_global_block == 1 ) {
2271 MV2_Scatter_intra_function = mv2_scatter_thresholds_table[conf_index][range].intra_node[range_threshold_intra]
2272 .MV2_pt_Scatter_function;
2275 MV2_Scatter_function(sendbuf, sendcnt, sendtype,
2276 recvbuf, recvcnt, recvtype, root,
2279 mpi_errno = MPIR_Scatter_MV2_Binomial(sendbuf, sendcnt, sendtype,
2280 recvbuf, recvcnt, recvtype, root,
2285 mpi_errno = MV2_Scatter_function(sendbuf, sendcnt, sendtype,
2286 recvbuf, recvcnt, recvtype, root,