root/ompi/mca/coll/tuned/coll_tuned_allreduce_decision.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ompi_coll_tuned_allreduce_intra_check_forced_init
  2. ompi_coll_tuned_allreduce_intra_do_this

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2017 The University of Tennessee and The University
   4  *                         of Tennessee Research Foundation.  All rights
   5  *                         reserved.
   6  * Copyright (c) 2015-2018 Research Organization for Information Science
   7  *                         and Technology (RIST).  All rights reserved.
   8  * $COPYRIGHT$
   9  *
  10  * Additional copyrights may follow
  11  *
  12  * $HEADER$
  13  */
  14 
  15 #include "ompi_config.h"
  16 
  17 #include "mpi.h"
  18 #include "opal/util/bit_ops.h"
  19 #include "ompi/constants.h"
  20 #include "ompi/datatype/ompi_datatype.h"
  21 #include "ompi/communicator/communicator.h"
  22 #include "ompi/mca/coll/coll.h"
  23 #include "ompi/mca/coll/base/coll_tags.h"
  24 #include "ompi/mca/pml/pml.h"
  25 #include "ompi/op/op.h"
  26 #include "coll_tuned.h"
  27 #include "ompi/mca/coll/base/coll_base_topo.h"
  28 #include "ompi/mca/coll/base/coll_base_util.h"
  29 
  30 /* allreduce algorithm variables */
  31 static int coll_tuned_allreduce_forced_algorithm = 0;
  32 static int coll_tuned_allreduce_segment_size = 0;
  33 static int coll_tuned_allreduce_tree_fanout;
  34 static int coll_tuned_allreduce_chain_fanout;
  35 
  36 /* valid values for coll_tuned_allreduce_forced_algorithm */
  37 static mca_base_var_enum_value_t allreduce_algorithms[] = {
  38     {0, "ignore"},
  39     {1, "basic_linear"},
  40     {2, "nonoverlapping"},
  41     {3, "recursive_doubling"},
  42     {4, "ring"},
  43     {5, "segmented_ring"},
  44     {6, "rabenseifner"},
  45     {0, NULL}
  46 };
  47 
  48 /* The following are used by dynamic and forced rules */
  49 
  50 /* publish details of each algorithm and if its forced/fixed/locked in */
  51 /* as you add methods/algorithms you must update this and the query/map routines */
  52 
  53 /* this routine is called by the component only */
  54 /* this makes sure that the mca parameters are set to their initial values and perms */
  55 /* module does not call this they call the forced_getvalues routine instead */
  56 
  57 int ompi_coll_tuned_allreduce_intra_check_forced_init (coll_tuned_force_algorithm_mca_param_indices_t *mca_param_indices)
  58 {
  59     mca_base_var_enum_t *new_enum;
  60     int cnt;
  61 
  62     for( cnt = 0; NULL != allreduce_algorithms[cnt].string; cnt++ );
  63     ompi_coll_tuned_forced_max_algorithms[ALLREDUCE] = cnt;
  64 
  65     (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version,
  66                                            "allreduce_algorithm_count",
  67                                            "Number of allreduce algorithms available",
  68                                            MCA_BASE_VAR_TYPE_INT, NULL, 0,
  69                                            MCA_BASE_VAR_FLAG_DEFAULT_ONLY,
  70                                            OPAL_INFO_LVL_5,
  71                                            MCA_BASE_VAR_SCOPE_CONSTANT,
  72                                            &ompi_coll_tuned_forced_max_algorithms[ALLREDUCE]);
  73 
  74     /* MPI_T: This variable should eventually be bound to a communicator */
  75     coll_tuned_allreduce_forced_algorithm = 0;
  76     (void) mca_base_var_enum_create("coll_tuned_allreduce_algorithms", allreduce_algorithms, &new_enum);
  77     mca_param_indices->algorithm_param_index =
  78         mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version,
  79                                         "allreduce_algorithm",
  80                                         "Which allreduce algorithm is used. Can be locked down to any of: 0 ignore, 1 basic linear, 2 nonoverlapping (tuned reduce + tuned bcast), 3 recursive doubling, 4 ring, 5 segmented ring",
  81                                         MCA_BASE_VAR_TYPE_INT, new_enum, 0, MCA_BASE_VAR_FLAG_SETTABLE,
  82                                         OPAL_INFO_LVL_5,
  83                                         MCA_BASE_VAR_SCOPE_ALL,
  84                                         &coll_tuned_allreduce_forced_algorithm);
  85     OBJ_RELEASE(new_enum);
  86     if (mca_param_indices->algorithm_param_index < 0) {
  87         return mca_param_indices->algorithm_param_index;
  88     }
  89 
  90     coll_tuned_allreduce_segment_size = 0;
  91     mca_param_indices->segsize_param_index =
  92         mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version,
  93                                         "allreduce_algorithm_segmentsize",
  94                                         "Segment size in bytes used by default for allreduce algorithms. Only has meaning if algorithm is forced and supports segmenting. 0 bytes means no segmentation.",
  95                                         MCA_BASE_VAR_TYPE_INT, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
  96                                         OPAL_INFO_LVL_5,
  97                                         MCA_BASE_VAR_SCOPE_ALL,
  98                                         &coll_tuned_allreduce_segment_size);
  99 
 100     coll_tuned_allreduce_tree_fanout = ompi_coll_tuned_init_tree_fanout; /* get system wide default */
 101     mca_param_indices->tree_fanout_param_index =
 102         mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version,
 103                                         "allreduce_algorithm_tree_fanout",
 104                                         "Fanout for n-tree used for allreduce algorithms. Only has meaning if algorithm is forced and supports n-tree topo based operation.",
 105                                         MCA_BASE_VAR_TYPE_INT, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 106                                         OPAL_INFO_LVL_5,
 107                                         MCA_BASE_VAR_SCOPE_ALL,
 108                                         &coll_tuned_allreduce_tree_fanout);
 109 
 110     coll_tuned_allreduce_chain_fanout = ompi_coll_tuned_init_chain_fanout; /* get system wide default */
 111     mca_param_indices->chain_fanout_param_index =
 112       mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version,
 113                                       "allreduce_algorithm_chain_fanout",
 114                                       "Fanout for chains used for allreduce algorithms. Only has meaning if algorithm is forced and supports chain topo based operation.",
 115                                       MCA_BASE_VAR_TYPE_INT, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 116                                       OPAL_INFO_LVL_5,
 117                                       MCA_BASE_VAR_SCOPE_ALL,
 118                                       &coll_tuned_allreduce_chain_fanout);
 119 
 120     return (MPI_SUCCESS);
 121 }
 122 
 123 int ompi_coll_tuned_allreduce_intra_do_this(const void *sbuf, void *rbuf, int count,
 124                                             struct ompi_datatype_t *dtype,
 125                                             struct ompi_op_t *op,
 126                                             struct ompi_communicator_t *comm,
 127                                             mca_coll_base_module_t *module,
 128                                             int algorithm, int faninout, int segsize)
 129 {
 130     OPAL_OUTPUT((ompi_coll_tuned_stream,"coll:tuned:allreduce_intra_do_this algorithm %d topo fan in/out %d segsize %d",
 131                  algorithm, faninout, segsize));
 132 
 133     switch (algorithm) {
 134     case (0):
 135         return ompi_coll_tuned_allreduce_intra_dec_fixed(sbuf, rbuf, count, dtype, op, comm, module);
 136     case (1):
 137         return ompi_coll_base_allreduce_intra_basic_linear(sbuf, rbuf, count, dtype, op, comm, module);
 138     case (2):
 139         return ompi_coll_base_allreduce_intra_nonoverlapping(sbuf, rbuf, count, dtype, op, comm, module);
 140     case (3):
 141         return ompi_coll_base_allreduce_intra_recursivedoubling(sbuf, rbuf, count, dtype, op, comm, module);
 142     case (4):
 143         return ompi_coll_base_allreduce_intra_ring(sbuf, rbuf, count, dtype, op, comm, module);
 144     case (5):
 145         return ompi_coll_base_allreduce_intra_ring_segmented(sbuf, rbuf, count, dtype, op, comm, module, segsize);
 146     case (6):
 147         return ompi_coll_base_allreduce_intra_redscat_allgather(sbuf, rbuf, count, dtype, op, comm, module);
 148     } /* switch */
 149     OPAL_OUTPUT((ompi_coll_tuned_stream,"coll:tuned:allreduce_intra_do_this attempt to select algorithm %d when only 0-%d is valid?",
 150                  algorithm, ompi_coll_tuned_forced_max_algorithms[ALLREDUCE]));
 151     return (MPI_ERR_ARG);
 152 }

/* [<][>][^][v][top][bottom][index][help] */