root/ompi/mca/coll/sync/coll_sync_module.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_coll_sync_module_construct
  2. mca_coll_sync_module_destruct
  3. mca_coll_sync_init_query
  4. mca_coll_sync_comm_query
  5. mca_coll_sync_module_enable
  6. mca_coll_sync_ft_event

   1 /*
   2  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2017 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2009      Cisco Systems, Inc.  All rights reserved.
  13  * Copyright (c) 2016      Research Organization for Information Science
  14  *                         and Technology (RIST). All rights reserved.
  15  * Copyright (c) 2018      Intel, Inc. All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  */
  22 
  23 #include "ompi_config.h"
  24 
  25 #ifdef HAVE_STRING_H
  26 #include <string.h>
  27 #endif
  28 #include <stdio.h>
  29 
  30 #include "coll_sync.h"
  31 
  32 #include "mpi.h"
  33 
  34 #include "opal/util/show_help.h"
  35 #include "ompi/mca/rte/rte.h"
  36 
  37 #include "ompi/constants.h"
  38 #include "ompi/communicator/communicator.h"
  39 #include "ompi/mca/coll/coll.h"
  40 #include "ompi/mca/coll/base/base.h"
  41 #include "coll_sync.h"
  42 
  43 
  44 static void mca_coll_sync_module_construct(mca_coll_sync_module_t *module)
  45 {
  46     memset(&(module->c_coll), 0, sizeof(module->c_coll));
  47     module->before_num_operations = 0;
  48     module->after_num_operations = 0;
  49     module->in_operation = false;
  50 }
  51 
  52 static void mca_coll_sync_module_destruct(mca_coll_sync_module_t *module)
  53 {
  54     OBJ_RELEASE(module->c_coll.coll_bcast_module);
  55     OBJ_RELEASE(module->c_coll.coll_gather_module);
  56     OBJ_RELEASE(module->c_coll.coll_gatherv_module);
  57     OBJ_RELEASE(module->c_coll.coll_reduce_module);
  58     OBJ_RELEASE(module->c_coll.coll_reduce_scatter_module);
  59     OBJ_RELEASE(module->c_coll.coll_scatter_module);
  60     OBJ_RELEASE(module->c_coll.coll_scatterv_module);
  61     /* If the exscan module is not NULL, then this was an
  62        intracommunicator, and therefore scan will have a module as
  63        well. */
  64     if (NULL != module->c_coll.coll_exscan_module) {
  65         OBJ_RELEASE(module->c_coll.coll_exscan_module);
  66         OBJ_RELEASE(module->c_coll.coll_scan_module);
  67     }
  68 }
  69 
  70 OBJ_CLASS_INSTANCE(mca_coll_sync_module_t, mca_coll_base_module_t,
  71                    mca_coll_sync_module_construct,
  72                    mca_coll_sync_module_destruct);
  73 
  74 
  75 /*
  76  * Initial query function that is invoked during MPI_INIT, allowing
  77  * this component to disqualify itself if it doesn't support the
  78  * required level of thread support.
  79  */
  80 int mca_coll_sync_init_query(bool enable_progress_threads,
  81                              bool enable_mpi_threads)
  82 {
  83     /* Nothing to do */
  84     return OMPI_SUCCESS;
  85 }
  86 
  87 
  88 /*
  89  * Invoked when there's a new communicator that has been created.
  90  * Look at the communicator and decide which set of functions and
  91  * priority we want to return.
  92  */
  93 mca_coll_base_module_t *
  94 mca_coll_sync_comm_query(struct ompi_communicator_t *comm,
  95                          int *priority)
  96 {
  97     mca_coll_sync_module_t *sync_module;
  98 
  99     /* If both MCA params are 0, then disqualify us */
 100     if (0 == mca_coll_sync_component.barrier_before_nops &&
 101         0 == mca_coll_sync_component.barrier_after_nops) {
 102         return NULL;
 103     }
 104 
 105     sync_module = OBJ_NEW(mca_coll_sync_module_t);
 106     if (NULL == sync_module) {
 107         return NULL;
 108     }
 109 
 110     *priority = mca_coll_sync_component.priority;
 111 
 112     /* Choose whether to use [intra|inter] */
 113     sync_module->super.coll_module_enable = mca_coll_sync_module_enable;
 114     sync_module->super.ft_event = mca_coll_sync_ft_event;
 115 
 116     /* The "all" versions are already synchronous.  So no need for an
 117        additional barrier there. */
 118     sync_module->super.coll_allgather  = NULL;
 119     sync_module->super.coll_allgatherv = NULL;
 120     sync_module->super.coll_allreduce  = NULL;
 121     sync_module->super.coll_alltoall   = NULL;
 122     sync_module->super.coll_alltoallv  = NULL;
 123     sync_module->super.coll_alltoallw  = NULL;
 124     sync_module->super.coll_barrier    = NULL;
 125     sync_module->super.coll_bcast      = mca_coll_sync_bcast;
 126     sync_module->super.coll_exscan     = mca_coll_sync_exscan;
 127     sync_module->super.coll_gather     = mca_coll_sync_gather;
 128     sync_module->super.coll_gatherv    = mca_coll_sync_gatherv;
 129     sync_module->super.coll_reduce     = mca_coll_sync_reduce;
 130     sync_module->super.coll_reduce_scatter = mca_coll_sync_reduce_scatter;
 131     sync_module->super.coll_scan       = mca_coll_sync_scan;
 132     sync_module->super.coll_scatter    = mca_coll_sync_scatter;
 133     sync_module->super.coll_scatterv   = mca_coll_sync_scatterv;
 134 
 135     return &(sync_module->super);
 136 }
 137 
 138 
 139 /*
 140  * Init module on the communicator
 141  */
 142 int mca_coll_sync_module_enable(mca_coll_base_module_t *module,
 143                                 struct ompi_communicator_t *comm)
 144 {
 145     bool good = true;
 146     char *msg = NULL;
 147     mca_coll_sync_module_t *s = (mca_coll_sync_module_t*) module;
 148 
 149     /* Save the prior layer of coll functions */
 150     s->c_coll = *comm->c_coll;
 151 
 152 #define CHECK_AND_RETAIN(name)                           \
 153     if (NULL == s->c_coll.coll_ ## name ## _module) {    \
 154         good = false;                                    \
 155         msg = #name;                                     \
 156     } else if (good) {                                   \
 157         OBJ_RETAIN(s->c_coll.coll_ ## name ## _module);  \
 158     }
 159 
 160     CHECK_AND_RETAIN(bcast);
 161     CHECK_AND_RETAIN(gather);
 162     CHECK_AND_RETAIN(gatherv);
 163     CHECK_AND_RETAIN(reduce);
 164     CHECK_AND_RETAIN(reduce_scatter);
 165     CHECK_AND_RETAIN(scatter);
 166     CHECK_AND_RETAIN(scatterv);
 167     if (!OMPI_COMM_IS_INTER(comm)) {
 168         /* MPI does not define scan/exscan on intercommunicators */
 169         CHECK_AND_RETAIN(exscan);
 170         CHECK_AND_RETAIN(scan);
 171     }
 172 
 173     /* All done */
 174     if (good) {
 175         return OMPI_SUCCESS;
 176     }
 177     opal_show_help("help-coll-sync.txt", "missing collective", true,
 178                    ompi_process_info.nodename,
 179                    mca_coll_sync_component.priority, msg);
 180     return OMPI_ERR_NOT_FOUND;
 181 }
 182 
 183 
 184 int mca_coll_sync_ft_event(int state)
 185 {
 186     if (OPAL_CRS_CHECKPOINT == state) {
 187         ;
 188     }
 189     else if (OPAL_CRS_CONTINUE == state) {
 190         ;
 191     }
 192     else if (OPAL_CRS_RESTART == state) {
 193         ;
 194     }
 195     else if (OPAL_CRS_TERM == state ) {
 196         ;
 197     }
 198     else {
 199         ;
 200     }
 201 
 202     return OMPI_SUCCESS;
 203 }

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