root/ompi/mca/coll/inter/coll_inter.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_coll_inter_init_query
  2. mca_coll_inter_comm_query
  3. mca_coll_inter_module_enable
  4. mca_coll_inter_dump_struct

   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2006 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) 2006-2007 University of Houston. All rights reserved.
  13  * Copyright (c) 2008      Sun Microsystems, Inc.  All rights reserved.
  14  * Copyright (c) 2013 Cisco Systems, Inc.  All rights reserved.
  15  * Copyright (c) 2017      IBM Corporation.  All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  */
  22 
  23 #include "ompi_config.h"
  24 #include "coll_inter.h"
  25 
  26 #include <stdio.h>
  27 
  28 #include "mpi.h"
  29 #include "ompi/communicator/communicator.h"
  30 
  31 #include "ompi/mca/coll/coll.h"
  32 #include "ompi/mca/coll/base/base.h"
  33 #include "ompi/mca/coll/base/coll_base_functions.h"
  34 #include "ompi/mca/coll/base/coll_tags.h"
  35 
  36 #include "ompi/mca/bml/base/base.h"
  37 
  38 
  39 #if 0
  40 static void mca_coll_inter_dump_struct ( struct mca_coll_base_comm_t *c);
  41 
  42 static const mca_coll_base_module_1_0_0_t inter = {
  43 
  44   /* Initialization / finalization functions */
  45 
  46   mca_coll_inter_module_init,
  47   mca_coll_inter_module_finalize,
  48 
  49   /* Collective function pointers */
  50   /* function pointers marked with NULL are not yet implemented
  51      and will use the functions provided in the basic module */
  52   mca_coll_inter_allgather_inter,
  53   mca_coll_inter_allgatherv_inter,
  54   mca_coll_inter_allreduce_inter,
  55   NULL, /* alltoall */
  56   NULL, /* alltoallv */
  57   NULL, /* alltoallw */
  58   NULL, /* barrier */
  59   mca_coll_inter_bcast_inter,
  60   NULL,  /* exscan */
  61   mca_coll_inter_gather_inter,
  62   mca_coll_inter_gatherv_inter,
  63   mca_coll_inter_reduce_inter,
  64   NULL,  /* reduce_scatter */
  65   NULL,  /* scan */
  66   mca_coll_inter_scatter_inter,
  67   mca_coll_inter_scatterv_inter
  68 };
  69 #endif
  70 
  71 
  72 /*
  73  * Initial query function that is invoked during MPI_INIT, allowing
  74  * this module to indicate what level of thread support it provides.
  75  */
  76 int mca_coll_inter_init_query(bool allow_inter_user_threads,
  77                              bool have_hidden_user_threads)
  78 {
  79     /* Don't ask. All done */
  80     return OMPI_SUCCESS;
  81 }
  82 
  83 
  84 /*
  85  * Invoked when there's a new communicator that has been created.
  86  * Look at the communicator and decide which set of functions and
  87  * priority we want to return.
  88  */
  89 mca_coll_base_module_t *
  90 mca_coll_inter_comm_query(struct ompi_communicator_t *comm, int *priority)
  91 {
  92     int size, rsize;
  93     mca_coll_inter_module_t *inter_module;
  94 
  95     /* This module only works for inter-communicators */
  96     if (!OMPI_COMM_IS_INTER(comm)) {
  97         return NULL;
  98     }
  99 
 100     /* Get the priority level attached to this module. If priority is less
 101      * than or equal to 0, then the module is unavailable. */
 102     *priority = mca_coll_inter_priority_param;
 103     if (0 >= mca_coll_inter_priority_param) {
 104         return NULL;
 105     }
 106 
 107     size = ompi_comm_size(comm);
 108     rsize = ompi_comm_remote_size(comm);
 109 
 110     if ( size < mca_coll_inter_crossover && rsize < mca_coll_inter_crossover) {
 111         return NULL;
 112     }
 113 
 114     inter_module = OBJ_NEW(mca_coll_inter_module_t);
 115     if (NULL == inter_module) {
 116         return NULL;
 117     }
 118 
 119     inter_module->super.coll_module_enable = mca_coll_inter_module_enable;
 120     inter_module->super.ft_event = NULL;
 121 
 122     inter_module->super.coll_allgather  = mca_coll_inter_allgather_inter;
 123     inter_module->super.coll_allgatherv = mca_coll_inter_allgatherv_inter;
 124     inter_module->super.coll_allreduce  = mca_coll_inter_allreduce_inter;
 125     inter_module->super.coll_alltoall   = NULL;
 126     inter_module->super.coll_alltoallv  = NULL;
 127     inter_module->super.coll_alltoallw  = NULL;
 128     inter_module->super.coll_barrier    = NULL;
 129     inter_module->super.coll_bcast      = mca_coll_inter_bcast_inter;
 130     inter_module->super.coll_exscan     = NULL;
 131     inter_module->super.coll_gather     = mca_coll_inter_gather_inter;
 132     inter_module->super.coll_gatherv    = mca_coll_inter_gatherv_inter;
 133     inter_module->super.coll_reduce     = mca_coll_inter_reduce_inter;
 134     inter_module->super.coll_reduce_scatter = NULL;
 135     inter_module->super.coll_scan       = NULL;
 136     inter_module->super.coll_scatter    = mca_coll_inter_scatter_inter;
 137     inter_module->super.coll_scatterv   = mca_coll_inter_scatterv_inter;
 138     inter_module->super.coll_reduce_local = mca_coll_base_reduce_local;
 139 
 140     return &(inter_module->super);
 141 }
 142 
 143 
 144 /*
 145  * Init module on the communicator
 146  */
 147 int
 148 mca_coll_inter_module_enable(mca_coll_base_module_t *module,
 149                              struct ompi_communicator_t *comm)
 150 {
 151     mca_coll_inter_module_t *inter_module = (mca_coll_inter_module_t*) module;
 152 
 153     inter_module->inter_comm = comm;
 154 
 155 #if 0
 156     if ( mca_coll_inter_verbose_param ) {
 157       mca_coll_inter_dump_struct (data);
 158     }
 159 #endif
 160 
 161     return OMPI_SUCCESS;
 162 }
 163 
 164 
 165 #if 0
 166 static void mca_coll_inter_dump_struct ( struct mca_coll_base_comm_t *c)
 167 {
 168     int rank;
 169 
 170     rank = ompi_comm_rank ( c->inter_comm );
 171 
 172     printf("%d: Dump of inter-struct for  comm %s cid %u\n",
 173            rank, c->inter_comm->c_name, c->inter_comm->c_contextid);
 174 
 175 
 176     return;
 177 }
 178 #endif

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