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

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

DEFINITIONS

This source file includes following definitions.
  1. ompi_coll_tuned_reduce_scatter_block_intra_check_forced_init
  2. ompi_coll_tuned_reduce_scatter_block_intra_do_this

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2018      Siberian State University of Telecommunications
   4  *                         and Information Sciences. All rights reserved.
   5  * Copyright (c) 2018      Research Organization for Information Science
   6  *                         and Technology (RIST).  All rights reserved.
   7  * $COPYRIGHT$
   8  *
   9  * Additional copyrights may follow
  10  *
  11  * $HEADER$
  12  */
  13 
  14 #include "ompi_config.h"
  15 
  16 #include "mpi.h"
  17 #include "opal/util/bit_ops.h"
  18 #include "ompi/constants.h"
  19 #include "ompi/datatype/ompi_datatype.h"
  20 #include "ompi/communicator/communicator.h"
  21 #include "ompi/mca/coll/coll.h"
  22 #include "ompi/mca/coll/base/coll_base_topo.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 
  28 /* reduce_scatter_block algorithm variables */
  29 static int coll_tuned_reduce_scatter_block_forced_algorithm = 0;
  30 static int coll_tuned_reduce_scatter_block_segment_size = 0;
  31 static int coll_tuned_reduce_scatter_block_tree_fanout;
  32 
  33 /* valid values for coll_tuned_reduce_scatter_blokc_forced_algorithm */
  34 static mca_base_var_enum_value_t reduce_scatter_block_algorithms[] = {
  35     {0, "ignore"},
  36     {1, "basic_linear"},
  37     {2, "recursive_doubling"},
  38     {3, "recursive_halving"},
  39     {4, "butterfly"},
  40     {0, NULL}
  41 };
  42 
  43 /**
  44  * The following are used by dynamic and forced rules
  45  *
  46  * publish details of each algorithm and if its forced/fixed/locked in
  47  * as you add methods/algorithms you must update this and the query/map routines
  48  *
  49  * this routine is called by the component only
  50  * this makes sure that the mca parameters are set to their initial values and
  51  * perms module does not call this they call the forced_getvalues routine
  52  * instead
  53  */
  54 
  55 int ompi_coll_tuned_reduce_scatter_block_intra_check_forced_init (coll_tuned_force_algorithm_mca_param_indices_t *mca_param_indices)
  56 {
  57     mca_base_var_enum_t *new_enum;
  58     int cnt;
  59 
  60     for( cnt = 0; NULL != reduce_scatter_block_algorithms[cnt].string; cnt++ );
  61     ompi_coll_tuned_forced_max_algorithms[REDUCESCATTERBLOCK] = cnt;
  62 
  63     (void) mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version,
  64                                            "reduce_scatter_block_algorithm_count",
  65                                            "Number of reduce_scatter_block algorithms available",
  66                                            MCA_BASE_VAR_TYPE_INT, NULL, 0,
  67                                            MCA_BASE_VAR_FLAG_DEFAULT_ONLY,
  68                                            OPAL_INFO_LVL_5,
  69                                            MCA_BASE_VAR_SCOPE_CONSTANT,
  70                                            &ompi_coll_tuned_forced_max_algorithms[REDUCESCATTERBLOCK]);
  71 
  72     /* MPI_T: This variable should eventually be bound to a communicator */
  73     coll_tuned_reduce_scatter_block_forced_algorithm = 0;
  74     (void) mca_base_var_enum_create("coll_tuned_reduce_scatter_block_algorithms", reduce_scatter_block_algorithms, &new_enum);
  75     mca_param_indices->algorithm_param_index =
  76         mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version,
  77                                         "reduce_scatter_block_algorithm",
  78                                         "Which reduce reduce_scatter_block algorithm is used. "
  79                                         "Can be locked down to choice of: 0 ignore, 1 basic_linear, 2 recursive_doubling, "
  80                                         "3 recursive_halving, 4 butterfly",
  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_reduce_scatter_block_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_reduce_scatter_block_segment_size = 0;
  91     mca_param_indices->segsize_param_index =
  92         mca_base_component_var_register(&mca_coll_tuned_component.super.collm_version,
  93                                         "reduce_scatter_block_algorithm_segmentsize",
  94                                         "Segment size in bytes used by default for reduce_scatter_block 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_reduce_scatter_block_segment_size);
  99 
 100     coll_tuned_reduce_scatter_block_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                                         "reduce_scatter_block_algorithm_tree_fanout",
 104                                         "Fanout for n-tree used for reduce_scatter_block 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_reduce_scatter_block_tree_fanout);
 109 
 110     return (MPI_SUCCESS);
 111 }
 112 
 113 int ompi_coll_tuned_reduce_scatter_block_intra_do_this(const void *sbuf, void *rbuf,
 114                                                        int rcount,
 115                                                        struct ompi_datatype_t *dtype,
 116                                                        struct ompi_op_t *op,
 117                                                        struct ompi_communicator_t *comm,
 118                                                        mca_coll_base_module_t *module,
 119                                                        int algorithm, int faninout, int segsize)
 120 {
 121     OPAL_OUTPUT((ompi_coll_tuned_stream, "coll:tuned:reduce_scatter_block_intra_do_this selected algorithm %d topo faninout %d segsize %d",
 122                  algorithm, faninout, segsize));
 123 
 124     switch (algorithm) {
 125     case (0): return ompi_coll_tuned_reduce_scatter_block_intra_dec_fixed(sbuf, rbuf, rcount,
 126                                                                           dtype, op, comm, module);
 127     case (1): return ompi_coll_base_reduce_scatter_block_basic_linear(sbuf, rbuf, rcount,
 128                                                                       dtype, op, comm, module);
 129     case (2): return ompi_coll_base_reduce_scatter_block_intra_recursivedoubling(sbuf, rbuf, rcount,
 130                                                                                  dtype, op, comm, module);
 131     case (3): return ompi_coll_base_reduce_scatter_block_intra_recursivehalving(sbuf, rbuf, rcount,
 132                                                                                 dtype, op, comm, module);
 133     case (4): return ompi_coll_base_reduce_scatter_block_intra_butterfly(sbuf, rbuf, rcount, dtype, op, comm, 
 134                                                                          module);
 135     } /* switch */
 136     OPAL_OUTPUT((ompi_coll_tuned_stream, "coll:tuned:reduce_scatter_block_intra_do_this attempt to select algorithm %d when only 0-%d is valid?",
 137                  algorithm, ompi_coll_tuned_forced_max_algorithms[REDUCESCATTERBLOCK]));
 138     return (MPI_ERR_ARG);
 139 }

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