root/ompi/mca/coll/sm/coll_sm_component.c

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

DEFINITIONS

This source file includes following definitions.
  1. sm_close
  2. sm_verify_mca_variables
  3. sm_register

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2005 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2008-2009 Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2011-2015 Los Alamos National Security, LLC.
  15  *                         All rights reserved.
  16  * Copyright (c) 2015      Intel, Inc. All rights reserved.
  17  * Copyright (c) 2018      Amazon.com, Inc. or its affiliates.  All Rights reserved.
  18  * $COPYRIGHT$
  19  *
  20  * Additional copyrights may follow
  21  *
  22  * $HEADER$
  23  */
  24 /**
  25  * @file
  26  *
  27  * Most of the description of the data layout is in the
  28  * coll_sm_module.c file.
  29  */
  30 
  31 #include "ompi_config.h"
  32 
  33 #include "opal/util/show_help.h"
  34 #include "opal/util/printf.h"
  35 #include "ompi/constants.h"
  36 #include "ompi/mca/coll/coll.h"
  37 #include "coll_sm.h"
  38 
  39 
  40 /*
  41  * Public string showing the coll ompi_sm component version number
  42  */
  43 const char *mca_coll_sm_component_version_string =
  44     "Open MPI sm collective MCA component version " OMPI_VERSION;
  45 
  46 
  47 /*
  48  * Local functions
  49  */
  50 static int sm_close(void);
  51 static int sm_register(void);
  52 
  53 static int coll_sm_shared_mem_used_data;
  54 
  55 /*
  56  * Instantiate the public struct with all of our public information
  57  * and pointers to our public functions in it
  58  */
  59 
  60 mca_coll_sm_component_t mca_coll_sm_component = {
  61 
  62     /* First, fill in the super */
  63 
  64     {
  65         /* First, the mca_component_t struct containing meta
  66            information about the component itself */
  67 
  68         .collm_version = {
  69             MCA_COLL_BASE_VERSION_2_0_0,
  70 
  71             /* Component name and version */
  72             .mca_component_name = "sm",
  73             MCA_BASE_MAKE_VERSION(component, OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION,
  74                                   OMPI_RELEASE_VERSION),
  75 
  76             /* Component functions */
  77             .mca_close_component = sm_close,
  78             .mca_register_component_params = sm_register,
  79         },
  80         .collm_data = {
  81             /* The component is not checkpoint ready */
  82             MCA_BASE_METADATA_PARAM_NONE
  83         },
  84 
  85         /* Initialization / querying functions */
  86 
  87         .collm_init_query = mca_coll_sm_init_query,
  88         .collm_comm_query = mca_coll_sm_comm_query,
  89     },
  90 
  91     /* sm-component specifc information */
  92 
  93     /* (default) priority */
  94     /* JMS temporarily lowered until we can get more testing */
  95     0,
  96 
  97     /* (default) control size (bytes) */
  98     4096,
  99 
 100     /* (default) number of "in use" flags for each communicator's area
 101        in the per-communicator shmem segment */
 102     2,
 103 
 104     /* (default) number of segments for each communicator in the
 105        per-communicator shmem segment */
 106     8,
 107 
 108     /* (default) fragment size */
 109     8192,
 110 
 111     /* (default) degree of tree for tree-based operations (must be <=
 112        control unit size) */
 113     4,
 114 
 115     /* (default) number of processes in coll_sm_shared_mem_size
 116        information variable */
 117     4,
 118 
 119     /* default values for non-MCA parameters */
 120     /* Not specifying values here gives us all 0's */
 121 };
 122 
 123 
 124 /*
 125  * Shut down the component
 126  */
 127 static int sm_close(void)
 128 {
 129     return OMPI_SUCCESS;
 130 }
 131 
 132 static int sm_verify_mca_variables(void)
 133 {
 134     mca_coll_sm_component_t *cs = &mca_coll_sm_component;
 135 
 136     if (0 != (cs->sm_fragment_size % cs->sm_control_size)) {
 137         cs->sm_fragment_size += cs->sm_control_size -
 138             (cs->sm_fragment_size % cs->sm_control_size);
 139     }
 140 
 141     if (cs->sm_comm_num_in_use_flags < 2) {
 142         cs->sm_comm_num_in_use_flags = 2;
 143     }
 144 
 145     if (cs->sm_comm_num_segments < cs->sm_comm_num_in_use_flags) {
 146         cs->sm_comm_num_segments = cs->sm_comm_num_in_use_flags;
 147     }
 148     if (0 != (cs->sm_comm_num_segments % cs->sm_comm_num_in_use_flags)) {
 149         cs->sm_comm_num_segments += cs->sm_comm_num_in_use_flags -
 150             (cs->sm_comm_num_segments % cs->sm_comm_num_in_use_flags);
 151     }
 152     cs->sm_segs_per_inuse_flag =
 153         cs->sm_comm_num_segments / cs->sm_comm_num_in_use_flags;
 154 
 155     if (cs->sm_tree_degree > cs->sm_control_size) {
 156         opal_show_help("help-mpi-coll-sm.txt",
 157                        "tree-degree-larger-than-control", true,
 158                        cs->sm_tree_degree, cs->sm_control_size);
 159         cs->sm_tree_degree = cs->sm_control_size;
 160     }
 161     if (cs->sm_tree_degree > 255) {
 162         opal_show_help("help-mpi-coll-sm.txt",
 163                        "tree-degree-larger-than-255", true,
 164                        cs->sm_tree_degree);
 165         cs->sm_tree_degree = 255;
 166     }
 167 
 168     coll_sm_shared_mem_used_data = (int)(4 * cs->sm_control_size +
 169         (cs->sm_comm_num_in_use_flags * cs->sm_control_size) +
 170         (cs->sm_comm_num_segments * (cs->sm_info_comm_size * cs->sm_control_size * 2)) +
 171         (cs->sm_comm_num_segments * (cs->sm_info_comm_size * cs->sm_fragment_size)));
 172 
 173     return OMPI_SUCCESS;
 174 }
 175 
 176 /*
 177  * Register MCA params
 178  */
 179 static int sm_register(void)
 180 {
 181     mca_base_component_t *c = &mca_coll_sm_component.super.collm_version;
 182     mca_coll_sm_component_t *cs = &mca_coll_sm_component;
 183 
 184     /* If we want to be selected (i.e., all procs on one node), then
 185        we should have a high priority */
 186 
 187     cs->sm_priority = 0;
 188     (void) mca_base_component_var_register(c, "priority", "Priority of the sm coll component",
 189                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
 190                                            OPAL_INFO_LVL_9,
 191                                            MCA_BASE_VAR_SCOPE_READONLY,
 192                                            &cs->sm_priority);
 193 
 194     cs->sm_control_size = 4096;
 195     (void) mca_base_component_var_register(c, "control_size",
 196                                            "Length of the control data -- should usually be either the length of a cache line on most SMPs, or the size of a page on machines that support direct memory affinity page placement (in bytes)",
 197                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
 198                                            OPAL_INFO_LVL_9,
 199                                            MCA_BASE_VAR_SCOPE_READONLY,
 200                                            &cs->sm_control_size);
 201 
 202     cs->sm_fragment_size = 8192;
 203     (void) mca_base_component_var_register(c, "fragment_size",
 204                                            "Fragment size (in bytes) used for passing data through shared memory (will be rounded up to the nearest control_size size)",
 205                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
 206                                            OPAL_INFO_LVL_9,
 207                                            MCA_BASE_VAR_SCOPE_READONLY,
 208                                            &cs->sm_fragment_size);
 209 
 210     cs->sm_comm_num_in_use_flags = 2;
 211     (void) mca_base_component_var_register(c, "comm_in_use_flags",
 212                                            "Number of \"in use\" flags, used to mark a message passing area segment as currently being used or not (must be >= 2 and <= comm_num_segments)",
 213                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
 214                                            OPAL_INFO_LVL_9,
 215                                            MCA_BASE_VAR_SCOPE_READONLY,
 216                                            &cs->sm_comm_num_in_use_flags);
 217 
 218     cs->sm_comm_num_segments = 8;
 219     (void) mca_base_component_var_register(c, "comm_num_segments",
 220                                            "Number of segments in each communicator's shared memory message passing area (must be >= 2, and must be a multiple of comm_in_use_flags)",
 221                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
 222                                            OPAL_INFO_LVL_9,
 223                                            MCA_BASE_VAR_SCOPE_READONLY,
 224                                            &cs->sm_comm_num_segments);
 225 
 226     cs->sm_tree_degree = 4;
 227     (void) mca_base_component_var_register(c, "tree_degree",
 228                                            "Degree of the tree for tree-based operations (must be => 1 and <= min(control_size, 255))",
 229                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
 230                                            OPAL_INFO_LVL_9,
 231                                            MCA_BASE_VAR_SCOPE_READONLY,
 232                                            &cs->sm_tree_degree);
 233 
 234     /* INFO: Calculate how much space we need in the per-communicator
 235        shmem data segment.  This formula taken directly from
 236        coll_sm_module.c. */
 237     cs->sm_info_comm_size = 4;
 238     (void) mca_base_component_var_register(c, "info_num_procs",
 239                                            "Number of processes to use for the calculation of the shared_mem_size MCA information parameter (must be => 2)",
 240                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
 241                                            OPAL_INFO_LVL_9,
 242                                            MCA_BASE_VAR_SCOPE_READONLY,
 243                                            &cs->sm_info_comm_size);
 244 
 245     coll_sm_shared_mem_used_data = (int)(4 * cs->sm_control_size +
 246         (cs->sm_comm_num_in_use_flags * cs->sm_control_size) +
 247         (cs->sm_comm_num_segments * (cs->sm_info_comm_size * cs->sm_control_size * 2)) +
 248         (cs->sm_comm_num_segments * (cs->sm_info_comm_size * cs->sm_fragment_size)));
 249 
 250     (void) mca_base_component_var_register(c, "shared_mem_used_data",
 251                                            "Amount of shared memory used, per communicator, in the shared memory data area for info_num_procs processes (in bytes)",
 252                                            MCA_BASE_VAR_TYPE_INT, NULL, 0,
 253                                            MCA_BASE_VAR_FLAG_DEFAULT_ONLY,
 254                                            OPAL_INFO_LVL_9,
 255                                            MCA_BASE_VAR_SCOPE_READONLY,
 256                                            &coll_sm_shared_mem_used_data);
 257 
 258     return sm_verify_mca_variables();
 259 }

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