root/ompi/mca/coll/libnbc/coll_libnbc_component.c

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

DEFINITIONS

This source file includes following definitions.
  1. libnbc_open
  2. libnbc_close
  3. libnbc_register
  4. libnbc_init_query
  5. libnbc_comm_query
  6. libnbc_module_enable
  7. ompi_coll_libnbc_progress
  8. libnbc_module_construct
  9. libnbc_module_destruct
  10. request_start
  11. request_cancel
  12. request_free
  13. request_construct

   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-2016 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      Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
  15  *                         reserved.
  16  * Copyright (c) 2016-2017 Research Organization for Information Science
  17  *                         and Technology (RIST). All rights reserved.
  18  * Copyright (c) 2016      IBM Corporation.  All rights reserved.
  19  * Copyright (c) 2017      Ian Bradley Morgan and Anthony Skjellum. All
  20  *                         rights reserved.
  21  * Copyright (c) 2018      FUJITSU LIMITED.  All rights reserved.
  22  * $COPYRIGHT$
  23  *
  24  * Additional copyrights may follow
  25  *
  26  * $HEADER$
  27  */
  28 
  29 #include "ompi_config.h"
  30 
  31 #include "coll_libnbc.h"
  32 #include "nbc_internal.h"
  33 
  34 #include "mpi.h"
  35 #include "ompi/mca/coll/coll.h"
  36 #include "ompi/communicator/communicator.h"
  37 
  38 /*
  39  * Public string showing the coll ompi_libnbc component version number
  40  */
  41 const char *mca_coll_libnbc_component_version_string =
  42     "Open MPI libnbc collective MCA component version " OMPI_VERSION;
  43 
  44 
  45 static int libnbc_priority = 10;
  46 static bool libnbc_in_progress = false;     /* protect from recursive calls */
  47 bool libnbc_ibcast_skip_dt_decision = true;
  48 
  49 int libnbc_iallgather_algorithm = 0;             /* iallgather user forced algorithm */
  50 static mca_base_var_enum_value_t iallgather_algorithms[] = {
  51     {0, "ignore"},
  52     {1, "linear"},
  53     {2, "recursive_doubling"},
  54     {0, NULL}
  55 };
  56 
  57 int libnbc_iallreduce_algorithm = 0;             /* iallreduce user forced algorithm */
  58 static mca_base_var_enum_value_t iallreduce_algorithms[] = {
  59     {0, "ignore"},
  60     {1, "ring"},
  61     {2, "binomial"},
  62     {3, "rabenseifner"},
  63     {0, NULL}
  64 };
  65 
  66 int libnbc_ibcast_algorithm = 0;             /* ibcast user forced algorithm */
  67 int libnbc_ibcast_knomial_radix = 4;
  68 static mca_base_var_enum_value_t ibcast_algorithms[] = {
  69     {0, "ignore"},
  70     {1, "linear"},
  71     {2, "binomial"},
  72     {3, "chain"},
  73     {4, "knomial"},
  74     {0, NULL}
  75 };
  76 
  77 int libnbc_iexscan_algorithm = 0;             /* iexscan user forced algorithm */
  78 static mca_base_var_enum_value_t iexscan_algorithms[] = {
  79     {0, "ignore"},
  80     {1, "linear"},
  81     {2, "recursive_doubling"},
  82     {0, NULL}
  83 };
  84 
  85 int libnbc_ireduce_algorithm = 0;            /* ireduce user forced algorithm */
  86 static mca_base_var_enum_value_t ireduce_algorithms[] = {
  87     {0, "ignore"},
  88     {1, "chain"},
  89     {2, "binomial"},
  90     {3, "rabenseifner"},
  91     {0, NULL}
  92 };
  93 
  94 int libnbc_iscan_algorithm = 0;             /* iscan user forced algorithm */
  95 static mca_base_var_enum_value_t iscan_algorithms[] = {
  96     {0, "ignore"},
  97     {1, "linear"},
  98     {2, "recursive_doubling"},
  99     {0, NULL}
 100 };
 101 
 102 static int libnbc_open(void);
 103 static int libnbc_close(void);
 104 static int libnbc_register(void);
 105 static int libnbc_init_query(bool, bool);
 106 static mca_coll_base_module_t *libnbc_comm_query(struct ompi_communicator_t *, int *);
 107 static int libnbc_module_enable(mca_coll_base_module_t *, struct ompi_communicator_t *);
 108 
 109 /*
 110  * Instantiate the public struct with all of our public information
 111  * and pointers to our public functions in it
 112  */
 113 
 114 ompi_coll_libnbc_component_t mca_coll_libnbc_component = {
 115     {
 116         /* First, the mca_component_t struct containing meta information
 117          * about the component itself */
 118         .collm_version = {
 119             MCA_COLL_BASE_VERSION_2_0_0,
 120 
 121             /* Component name and version */
 122             .mca_component_name = "libnbc",
 123             MCA_BASE_MAKE_VERSION(component, OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION,
 124                                   OMPI_RELEASE_VERSION),
 125 
 126             /* Component open and close functions */
 127             .mca_open_component = libnbc_open,
 128             .mca_close_component = libnbc_close,
 129             .mca_register_component_params = libnbc_register,
 130         },
 131         .collm_data = {
 132             /* The component is checkpoint ready */
 133             MCA_BASE_METADATA_PARAM_CHECKPOINT
 134         },
 135 
 136         /* Initialization / querying functions */
 137         .collm_init_query = libnbc_init_query,
 138         .collm_comm_query = libnbc_comm_query,
 139     }
 140 };
 141 
 142 
 143 static int
 144 libnbc_open(void)
 145 {
 146     int ret;
 147 
 148     OBJ_CONSTRUCT(&mca_coll_libnbc_component.requests, opal_free_list_t);
 149     OBJ_CONSTRUCT(&mca_coll_libnbc_component.active_requests, opal_list_t);
 150     OBJ_CONSTRUCT(&mca_coll_libnbc_component.lock, opal_mutex_t);
 151     ret = opal_free_list_init (&mca_coll_libnbc_component.requests,
 152                                sizeof(ompi_coll_libnbc_request_t), 8,
 153                                OBJ_CLASS(ompi_coll_libnbc_request_t),
 154                                0, 0, 0, -1, 8, NULL, 0, NULL, NULL, NULL);
 155     if (OMPI_SUCCESS != ret) return ret;
 156 
 157     /* note: active comms is the number of communicators who have had
 158        a non-blocking collective started */
 159     mca_coll_libnbc_component.active_comms = 0;
 160 
 161     return OMPI_SUCCESS;
 162 }
 163 
 164 static int
 165 libnbc_close(void)
 166 {
 167     if (0 != mca_coll_libnbc_component.active_comms) {
 168         opal_progress_unregister(ompi_coll_libnbc_progress);
 169     }
 170 
 171     OBJ_DESTRUCT(&mca_coll_libnbc_component.requests);
 172     OBJ_DESTRUCT(&mca_coll_libnbc_component.active_requests);
 173     OBJ_DESTRUCT(&mca_coll_libnbc_component.lock);
 174 
 175     return OMPI_SUCCESS;
 176 }
 177 
 178 
 179 static int
 180 libnbc_register(void)
 181 {
 182     mca_base_var_enum_t *new_enum = NULL;
 183 
 184     /* Use a low priority, but allow other components to be lower */
 185     libnbc_priority = 10;
 186     (void) mca_base_component_var_register(&mca_coll_libnbc_component.super.collm_version,
 187                                            "priority", "Priority of the libnbc coll component",
 188                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
 189                                            OPAL_INFO_LVL_9,
 190                                            MCA_BASE_VAR_SCOPE_READONLY,
 191                                            &libnbc_priority);
 192 
 193     /* ibcast decision function can make the wrong decision if a legal
 194      * non-uniform data type signature is used. This has resulted in the
 195      * collective operation failing, and possibly producing wrong answers.
 196      * We are investigating a fix for this problem, but it is taking a while.
 197      *   https://github.com/open-mpi/ompi/issues/2256
 198      *   https://github.com/open-mpi/ompi/issues/1763
 199      * As a result we are adding an MCA parameter to make a conservative
 200      * decision to avoid this issue. If the user knows that their application
 201      * does not use data types in this way, then they can set this parameter
 202      * to get the old behavior. Once the issue is truely fixed, then this
 203      * parameter can be removed.
 204      */
 205     libnbc_ibcast_skip_dt_decision = true;
 206     (void) mca_base_component_var_register(&mca_coll_libnbc_component.super.collm_version,
 207                                            "ibcast_skip_dt_decision",
 208                                            "In ibcast only use size of communicator to choose algorithm, exclude data type signature. Set to 'false' to use data type signature in decision. WARNING: If you set this to 'false' then your application should not use non-uniform data type signatures in calls to ibcast.",
 209                                            MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
 210                                            OPAL_INFO_LVL_9,
 211                                            MCA_BASE_VAR_SCOPE_READONLY,
 212                                            &libnbc_ibcast_skip_dt_decision);
 213 
 214     libnbc_iallgather_algorithm = 0;
 215     (void) mca_base_var_enum_create("coll_libnbc_iallgather_algorithms", iallgather_algorithms, &new_enum);
 216     mca_base_component_var_register(&mca_coll_libnbc_component.super.collm_version,
 217                                     "iallgather_algorithm",
 218                                     "Which iallgather algorithm is used: 0 ignore, 1 linear, 2 recursive_doubling",
 219                                     MCA_BASE_VAR_TYPE_INT, new_enum, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 220                                     OPAL_INFO_LVL_5, MCA_BASE_VAR_SCOPE_ALL,
 221                                     &libnbc_iallgather_algorithm);
 222     OBJ_RELEASE(new_enum);
 223 
 224     libnbc_iallreduce_algorithm = 0;
 225     (void) mca_base_var_enum_create("coll_libnbc_iallreduce_algorithms", iallreduce_algorithms, &new_enum);
 226     mca_base_component_var_register(&mca_coll_libnbc_component.super.collm_version,
 227                                     "iallreduce_algorithm",
 228                                     "Which iallreduce algorithm is used: 0 ignore, 1 ring, 2 binomial, 3 rabenseifner",
 229                                     MCA_BASE_VAR_TYPE_INT, new_enum, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 230                                     OPAL_INFO_LVL_5, MCA_BASE_VAR_SCOPE_ALL,
 231                                     &libnbc_iallreduce_algorithm);
 232     OBJ_RELEASE(new_enum);
 233 
 234     libnbc_ibcast_algorithm = 0;
 235     (void) mca_base_var_enum_create("coll_libnbc_ibcast_algorithms", ibcast_algorithms, &new_enum);
 236     mca_base_component_var_register(&mca_coll_libnbc_component.super.collm_version,
 237                                     "ibcast_algorithm",
 238                                     "Which ibcast algorithm is used: 0 ignore, 1 linear, 2 binomial, 3 chain, 4 knomial",
 239                                     MCA_BASE_VAR_TYPE_INT, new_enum, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 240                                     OPAL_INFO_LVL_5, MCA_BASE_VAR_SCOPE_ALL,
 241                                     &libnbc_ibcast_algorithm);
 242     OBJ_RELEASE(new_enum);
 243 
 244     libnbc_ibcast_knomial_radix = 4;
 245     (void) mca_base_component_var_register(&mca_coll_libnbc_component.super.collm_version,
 246                                            "ibcast_knomial_radix", "k-nomial tree radix for the ibcast algorithm (radix > 1)",
 247                                            MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
 248                                            OPAL_INFO_LVL_9,
 249                                            MCA_BASE_VAR_SCOPE_READONLY,
 250                                            &libnbc_ibcast_knomial_radix);
 251 
 252     libnbc_iexscan_algorithm = 0;
 253     (void) mca_base_var_enum_create("coll_libnbc_iexscan_algorithms", iexscan_algorithms, &new_enum);
 254     mca_base_component_var_register(&mca_coll_libnbc_component.super.collm_version,
 255                                     "iexscan_algorithm",
 256                                     "Which iexscan algorithm is used: 0 ignore, 1 linear, 2 recursive_doubling",
 257                                     MCA_BASE_VAR_TYPE_INT, new_enum, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 258                                     OPAL_INFO_LVL_5, MCA_BASE_VAR_SCOPE_ALL,
 259                                     &libnbc_iexscan_algorithm);
 260     OBJ_RELEASE(new_enum);
 261 
 262     libnbc_ireduce_algorithm = 0;
 263     (void) mca_base_var_enum_create("coll_libnbc_ireduce_algorithms", ireduce_algorithms, &new_enum);
 264     mca_base_component_var_register(&mca_coll_libnbc_component.super.collm_version,
 265                                     "ireduce_algorithm",
 266                                     "Which ireduce algorithm is used: 0 ignore, 1 chain, 2 binomial, 3 rabenseifner",
 267                                     MCA_BASE_VAR_TYPE_INT, new_enum, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 268                                     OPAL_INFO_LVL_5, MCA_BASE_VAR_SCOPE_ALL,
 269                                     &libnbc_ireduce_algorithm);
 270     OBJ_RELEASE(new_enum);
 271 
 272     libnbc_iscan_algorithm = 0;
 273     (void) mca_base_var_enum_create("coll_libnbc_iscan_algorithms", iscan_algorithms, &new_enum);
 274     mca_base_component_var_register(&mca_coll_libnbc_component.super.collm_version,
 275                                     "iscan_algorithm",
 276                                     "Which iscan algorithm is used: 0 ignore, 1 linear, 2 recursive_doubling",
 277                                     MCA_BASE_VAR_TYPE_INT, new_enum, 0, MCA_BASE_VAR_FLAG_SETTABLE,
 278                                     OPAL_INFO_LVL_5, MCA_BASE_VAR_SCOPE_ALL,
 279                                     &libnbc_iscan_algorithm);
 280     OBJ_RELEASE(new_enum);
 281 
 282     return OMPI_SUCCESS;
 283 }
 284 
 285 /*
 286  * Initial query function that is invoked during MPI_INIT, allowing
 287  * this component to disqualify itself if it doesn't support the
 288  * required level of thread support.
 289  */
 290 static int
 291 libnbc_init_query(bool enable_progress_threads,
 292                   bool enable_mpi_threads)
 293 {
 294     /* Nothing to do */
 295     return OMPI_SUCCESS;
 296 }
 297 
 298 /*
 299  * Invoked when there's a new communicator that has been created.
 300  * Look at the communicator and decide which set of functions and
 301  * priority we want to return.
 302  */
 303 mca_coll_base_module_t *
 304 libnbc_comm_query(struct ompi_communicator_t *comm,
 305                   int *priority)
 306 {
 307     ompi_coll_libnbc_module_t *module;
 308 
 309     module = OBJ_NEW(ompi_coll_libnbc_module_t);
 310     if (NULL == module) return NULL;
 311 
 312     *priority = libnbc_priority;
 313 
 314     module->super.coll_module_enable = libnbc_module_enable;
 315     if (OMPI_COMM_IS_INTER(comm)) {
 316         module->super.coll_iallgather = ompi_coll_libnbc_iallgather_inter;
 317         module->super.coll_iallgatherv = ompi_coll_libnbc_iallgatherv_inter;
 318         module->super.coll_iallreduce = ompi_coll_libnbc_iallreduce_inter;
 319         module->super.coll_ialltoall = ompi_coll_libnbc_ialltoall_inter;
 320         module->super.coll_ialltoallv = ompi_coll_libnbc_ialltoallv_inter;
 321         module->super.coll_ialltoallw = ompi_coll_libnbc_ialltoallw_inter;
 322         module->super.coll_ibarrier = ompi_coll_libnbc_ibarrier_inter;
 323         module->super.coll_ibcast = ompi_coll_libnbc_ibcast_inter;
 324         module->super.coll_iexscan = NULL;
 325         module->super.coll_igather = ompi_coll_libnbc_igather_inter;
 326         module->super.coll_igatherv = ompi_coll_libnbc_igatherv_inter;
 327         module->super.coll_ireduce = ompi_coll_libnbc_ireduce_inter;
 328         module->super.coll_ireduce_scatter = ompi_coll_libnbc_ireduce_scatter_inter;
 329         module->super.coll_ireduce_scatter_block = ompi_coll_libnbc_ireduce_scatter_block_inter;
 330         module->super.coll_iscan = NULL;
 331         module->super.coll_iscatter = ompi_coll_libnbc_iscatter_inter;
 332         module->super.coll_iscatterv = ompi_coll_libnbc_iscatterv_inter;
 333 
 334         module->super.coll_allgather_init = ompi_coll_libnbc_allgather_inter_init;
 335         module->super.coll_allgatherv_init = ompi_coll_libnbc_allgatherv_inter_init;
 336         module->super.coll_allreduce_init = ompi_coll_libnbc_allreduce_inter_init;
 337         module->super.coll_alltoall_init = ompi_coll_libnbc_alltoall_inter_init;
 338         module->super.coll_alltoallv_init = ompi_coll_libnbc_alltoallv_inter_init;
 339         module->super.coll_alltoallw_init = ompi_coll_libnbc_alltoallw_inter_init;
 340         module->super.coll_barrier_init = ompi_coll_libnbc_barrier_inter_init;
 341         module->super.coll_bcast_init = ompi_coll_libnbc_bcast_inter_init;
 342         module->super.coll_exscan_init = NULL;
 343         module->super.coll_gather_init = ompi_coll_libnbc_gather_inter_init;
 344         module->super.coll_gatherv_init = ompi_coll_libnbc_gatherv_inter_init;
 345         module->super.coll_reduce_init = ompi_coll_libnbc_reduce_inter_init;
 346         module->super.coll_reduce_scatter_init = ompi_coll_libnbc_reduce_scatter_inter_init;
 347         module->super.coll_reduce_scatter_block_init = ompi_coll_libnbc_reduce_scatter_block_inter_init;
 348         module->super.coll_scan_init = NULL;
 349         module->super.coll_scatter_init = ompi_coll_libnbc_scatter_inter_init;
 350         module->super.coll_scatterv_init = ompi_coll_libnbc_scatterv_inter_init;
 351     } else {
 352         module->super.coll_iallgather = ompi_coll_libnbc_iallgather;
 353         module->super.coll_iallgatherv = ompi_coll_libnbc_iallgatherv;
 354         module->super.coll_iallreduce = ompi_coll_libnbc_iallreduce;
 355         module->super.coll_ialltoall = ompi_coll_libnbc_ialltoall;
 356         module->super.coll_ialltoallv = ompi_coll_libnbc_ialltoallv;
 357         module->super.coll_ialltoallw = ompi_coll_libnbc_ialltoallw;
 358         module->super.coll_ibarrier = ompi_coll_libnbc_ibarrier;
 359         module->super.coll_ibcast = ompi_coll_libnbc_ibcast;
 360         module->super.coll_iexscan = ompi_coll_libnbc_iexscan;
 361         module->super.coll_igather = ompi_coll_libnbc_igather;
 362         module->super.coll_igatherv = ompi_coll_libnbc_igatherv;
 363         module->super.coll_ireduce = ompi_coll_libnbc_ireduce;
 364         module->super.coll_ireduce_scatter = ompi_coll_libnbc_ireduce_scatter;
 365         module->super.coll_ireduce_scatter_block = ompi_coll_libnbc_ireduce_scatter_block;
 366         module->super.coll_iscan = ompi_coll_libnbc_iscan;
 367         module->super.coll_iscatter = ompi_coll_libnbc_iscatter;
 368         module->super.coll_iscatterv = ompi_coll_libnbc_iscatterv;
 369 
 370         module->super.coll_ineighbor_allgather = ompi_coll_libnbc_ineighbor_allgather;
 371         module->super.coll_ineighbor_allgatherv = ompi_coll_libnbc_ineighbor_allgatherv;
 372         module->super.coll_ineighbor_alltoall = ompi_coll_libnbc_ineighbor_alltoall;
 373         module->super.coll_ineighbor_alltoallv = ompi_coll_libnbc_ineighbor_alltoallv;
 374         module->super.coll_ineighbor_alltoallw = ompi_coll_libnbc_ineighbor_alltoallw;
 375 
 376         module->super.coll_allgather_init = ompi_coll_libnbc_allgather_init;
 377         module->super.coll_allgatherv_init = ompi_coll_libnbc_allgatherv_init;
 378         module->super.coll_allreduce_init = ompi_coll_libnbc_allreduce_init;
 379         module->super.coll_alltoall_init = ompi_coll_libnbc_alltoall_init;
 380         module->super.coll_alltoallv_init = ompi_coll_libnbc_alltoallv_init;
 381         module->super.coll_alltoallw_init = ompi_coll_libnbc_alltoallw_init;
 382         module->super.coll_barrier_init = ompi_coll_libnbc_barrier_init;
 383         module->super.coll_bcast_init = ompi_coll_libnbc_bcast_init;
 384         module->super.coll_exscan_init = ompi_coll_libnbc_exscan_init;
 385         module->super.coll_gather_init = ompi_coll_libnbc_gather_init;
 386         module->super.coll_gatherv_init = ompi_coll_libnbc_gatherv_init;
 387         module->super.coll_reduce_init = ompi_coll_libnbc_reduce_init;
 388         module->super.coll_reduce_scatter_init = ompi_coll_libnbc_reduce_scatter_init;
 389         module->super.coll_reduce_scatter_block_init = ompi_coll_libnbc_reduce_scatter_block_init;
 390         module->super.coll_scan_init = ompi_coll_libnbc_scan_init;
 391         module->super.coll_scatter_init = ompi_coll_libnbc_scatter_init;
 392         module->super.coll_scatterv_init = ompi_coll_libnbc_scatterv_init;
 393 
 394         module->super.coll_neighbor_allgather_init = ompi_coll_libnbc_neighbor_allgather_init;
 395         module->super.coll_neighbor_allgatherv_init = ompi_coll_libnbc_neighbor_allgatherv_init;
 396         module->super.coll_neighbor_alltoall_init = ompi_coll_libnbc_neighbor_alltoall_init;
 397         module->super.coll_neighbor_alltoallv_init = ompi_coll_libnbc_neighbor_alltoallv_init;
 398         module->super.coll_neighbor_alltoallw_init = ompi_coll_libnbc_neighbor_alltoallw_init;
 399     }
 400 
 401     module->super.ft_event = NULL;
 402 
 403     if (OMPI_SUCCESS != NBC_Init_comm(comm, module)) {
 404         OBJ_RELEASE(module);
 405         return NULL;
 406     }
 407 
 408     return &(module->super);
 409 }
 410 
 411 
 412 /*
 413  * Init module on the communicator
 414  */
 415 static int
 416 libnbc_module_enable(mca_coll_base_module_t *module,
 417                      struct ompi_communicator_t *comm)
 418 {
 419     /* All done */
 420     return OMPI_SUCCESS;
 421 }
 422 
 423 
 424 int
 425 ompi_coll_libnbc_progress(void)
 426 {
 427     ompi_coll_libnbc_request_t* request, *next;
 428     int res;
 429 
 430     if (0 == opal_list_get_size (&mca_coll_libnbc_component.active_requests)) {
 431         /* no requests -- nothing to do. do not grab a lock */
 432         return 0;
 433     }
 434 
 435     /* process active requests, and use mca_coll_libnbc_component.lock to access the
 436      * mca_coll_libnbc_component.active_requests list */
 437     OPAL_THREAD_LOCK(&mca_coll_libnbc_component.lock);
 438     /* return if invoked recursively */
 439     if (!libnbc_in_progress) {
 440         libnbc_in_progress = true;
 441 
 442         OPAL_LIST_FOREACH_SAFE(request, next, &mca_coll_libnbc_component.active_requests,
 443                                ompi_coll_libnbc_request_t) {
 444             OPAL_THREAD_UNLOCK(&mca_coll_libnbc_component.lock);
 445             res = NBC_Progress(request);
 446             if( NBC_CONTINUE != res ) {
 447                 /* done, remove and complete */
 448                 OPAL_THREAD_LOCK(&mca_coll_libnbc_component.lock);
 449                 opal_list_remove_item(&mca_coll_libnbc_component.active_requests,
 450                                       &request->super.super.super);
 451                 OPAL_THREAD_UNLOCK(&mca_coll_libnbc_component.lock);
 452 
 453                 if( OMPI_SUCCESS == res || NBC_OK == res || NBC_SUCCESS == res ) {
 454                     request->super.req_status.MPI_ERROR = OMPI_SUCCESS;
 455                 }
 456                 else {
 457                     request->super.req_status.MPI_ERROR = res;
 458                 }
 459                 if(request->super.req_persistent) {
 460                     /* reset for the next communication */
 461                     request->row_offset = 0;
 462                 }
 463                 if(!request->super.req_persistent || !REQUEST_COMPLETE(&request->super)) {
 464                     ompi_request_complete(&request->super, true);
 465                 }
 466             }
 467             OPAL_THREAD_LOCK(&mca_coll_libnbc_component.lock);
 468         }
 469         libnbc_in_progress = false;
 470     }
 471     OPAL_THREAD_UNLOCK(&mca_coll_libnbc_component.lock);
 472 
 473     return 0;
 474 }
 475 
 476 
 477 static void
 478 libnbc_module_construct(ompi_coll_libnbc_module_t *module)
 479 {
 480     OBJ_CONSTRUCT(&module->mutex, opal_mutex_t);
 481     module->comm_registered = false;
 482 }
 483 
 484 
 485 static void
 486 libnbc_module_destruct(ompi_coll_libnbc_module_t *module)
 487 {
 488     OBJ_DESTRUCT(&module->mutex);
 489 
 490     /* if we ever were used for a collective op, do the progress cleanup. */
 491     if (true == module->comm_registered) {
 492         int32_t tmp =
 493             OPAL_THREAD_ADD_FETCH32(&mca_coll_libnbc_component.active_comms, -1);
 494         if (0 == tmp) {
 495             opal_progress_unregister(ompi_coll_libnbc_progress);
 496         }
 497     }
 498 }
 499 
 500 
 501 OBJ_CLASS_INSTANCE(ompi_coll_libnbc_module_t,
 502                    mca_coll_base_module_t,
 503                    libnbc_module_construct,
 504                    libnbc_module_destruct);
 505 
 506 
 507 static int
 508 request_start(size_t count, ompi_request_t ** requests)
 509 {
 510     int res;
 511     size_t i;
 512 
 513     NBC_DEBUG(5, " ** request_start **\n");
 514 
 515     for (i = 0; i < count; i++) {
 516         NBC_Handle *handle = (NBC_Handle *) requests[i];
 517         NBC_Schedule *schedule = handle->schedule;
 518 
 519         NBC_DEBUG(5, "--------------------------------\n");
 520         NBC_DEBUG(5, "schedule %p size %u\n", &schedule, sizeof(schedule));
 521         NBC_DEBUG(5, "handle %p size %u\n", &handle, sizeof(handle));
 522         NBC_DEBUG(5, "data %p size %u\n", &schedule->data, sizeof(schedule->data));
 523         NBC_DEBUG(5, "req_array %p size %u\n", &handle->req_array, sizeof(handle->req_array));
 524         NBC_DEBUG(5, "row_offset=%u address=%p size=%u\n", handle->row_offset, &handle->row_offset, sizeof(handle->row_offset));
 525         NBC_DEBUG(5, "req_count=%u address=%p size=%u\n", handle->req_count, &handle->req_count, sizeof(handle->req_count));
 526         NBC_DEBUG(5, "tmpbuf address=%p size=%u\n", handle->tmpbuf, sizeof(handle->tmpbuf));
 527         NBC_DEBUG(5, "--------------------------------\n");
 528 
 529         handle->super.req_complete = REQUEST_PENDING;
 530         handle->nbc_complete = false;
 531 
 532         res = NBC_Start(handle);
 533         if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
 534             NBC_DEBUG(5, " ** bad result from NBC_Start **\n");
 535             return res;
 536         }
 537     }
 538 
 539     NBC_DEBUG(5, " ** LEAVING request_start **\n");
 540 
 541     return OMPI_SUCCESS;
 542 
 543 }
 544 
 545 
 546 static int
 547 request_cancel(struct ompi_request_t *request, int complete)
 548 {
 549     return MPI_ERR_REQUEST;
 550 }
 551 
 552 
 553 static int
 554 request_free(struct ompi_request_t **ompi_req)
 555 {
 556     ompi_coll_libnbc_request_t *request =
 557         (ompi_coll_libnbc_request_t*) *ompi_req;
 558 
 559     if( !REQUEST_COMPLETE(&request->super) ) {
 560         return MPI_ERR_REQUEST;
 561     }
 562 
 563     OMPI_COLL_LIBNBC_REQUEST_RETURN(request);
 564     *ompi_req = MPI_REQUEST_NULL;
 565 
 566     return OMPI_SUCCESS;
 567 }
 568 
 569 
 570 static void
 571 request_construct(ompi_coll_libnbc_request_t *request)
 572 {
 573     request->super.req_type = OMPI_REQUEST_COLL;
 574     request->super.req_status._cancelled = 0;
 575     request->super.req_start = request_start;
 576     request->super.req_free = request_free;
 577     request->super.req_cancel = request_cancel;
 578 }
 579 
 580 
 581 OBJ_CLASS_INSTANCE(ompi_coll_libnbc_request_t,
 582                    ompi_request_t,
 583                    request_construct,
 584                    NULL);

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