root/ompi/mca/coll/sync/coll_sync.h

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

INCLUDED FROM


   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-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) 2008-2009 Cisco Systems, Inc.  All rights reserved.
  13  * $COPYRIGHT$
  14  *
  15  * Additional copyrights may follow
  16  *
  17  * $HEADER$
  18  */
  19 
  20 #ifndef MCA_COLL_SYNC_EXPORT_H
  21 #define MCA_COLL_SYNC_EXPORT_H
  22 
  23 #include "ompi_config.h"
  24 
  25 #include "mpi.h"
  26 
  27 #include "opal/class/opal_object.h"
  28 #include "opal/mca/mca.h"
  29 #include "opal/util/output.h"
  30 
  31 #include "ompi/constants.h"
  32 #include "ompi/mca/coll/coll.h"
  33 #include "ompi/mca/coll/base/base.h"
  34 #include "ompi/communicator/communicator.h"
  35 
  36 BEGIN_C_DECLS
  37 
  38 /* API functions */
  39 
  40 int mca_coll_sync_init_query(bool enable_progress_threads,
  41                              bool enable_mpi_threads);
  42 mca_coll_base_module_t
  43 *mca_coll_sync_comm_query(struct ompi_communicator_t *comm,
  44                           int *priority);
  45 
  46 int mca_coll_sync_module_enable(mca_coll_base_module_t *module,
  47                                 struct ompi_communicator_t *comm);
  48 
  49 int mca_coll_sync_barrier(struct ompi_communicator_t *comm,
  50                           mca_coll_base_module_t *module);
  51 
  52 int mca_coll_sync_bcast(void *buff, int count,
  53                         struct ompi_datatype_t *datatype,
  54                         int root,
  55                         struct ompi_communicator_t *comm,
  56                         mca_coll_base_module_t *module);
  57 
  58 int mca_coll_sync_exscan(const void *sbuf, void *rbuf, int count,
  59                          struct ompi_datatype_t *dtype,
  60                          struct ompi_op_t *op,
  61                          struct ompi_communicator_t *comm,
  62                          mca_coll_base_module_t *module);
  63 
  64 int mca_coll_sync_gather(const void *sbuf, int scount,
  65                          struct ompi_datatype_t *sdtype,
  66                          void *rbuf, int rcount,
  67                          struct ompi_datatype_t *rdtype,
  68                          int root,
  69                          struct ompi_communicator_t *comm,
  70                          mca_coll_base_module_t *module);
  71 
  72 int mca_coll_sync_gatherv(const void *sbuf, int scount,
  73                           struct ompi_datatype_t *sdtype,
  74                           void *rbuf, const int *rcounts, const int *disps,
  75                           struct ompi_datatype_t *rdtype,
  76                           int root,
  77                           struct ompi_communicator_t *comm,
  78                           mca_coll_base_module_t *module);
  79 
  80 int mca_coll_sync_reduce(const void *sbuf, void *rbuf, int count,
  81                          struct ompi_datatype_t *dtype,
  82                          struct ompi_op_t *op,
  83                          int root,
  84                          struct ompi_communicator_t *comm,
  85                          mca_coll_base_module_t *module);
  86 
  87 int mca_coll_sync_reduce_scatter(const void *sbuf, void *rbuf,
  88                                  const int *rcounts,
  89                                  struct ompi_datatype_t *dtype,
  90                                  struct ompi_op_t *op,
  91                                  struct ompi_communicator_t *comm,
  92                                  mca_coll_base_module_t *module);
  93 
  94 int mca_coll_sync_scan(const void *sbuf, void *rbuf, int count,
  95                        struct ompi_datatype_t *dtype,
  96                        struct ompi_op_t *op,
  97                        struct ompi_communicator_t *comm,
  98                        mca_coll_base_module_t *module);
  99 
 100 int mca_coll_sync_scatter(const void *sbuf, int scount,
 101                           struct ompi_datatype_t *sdtype,
 102                           void *rbuf, int rcount,
 103                           struct ompi_datatype_t *rdtype,
 104                           int root,
 105                           struct ompi_communicator_t *comm,
 106                           mca_coll_base_module_t *module);
 107 
 108 int mca_coll_sync_scatterv(const void *sbuf, const int *scounts, const int *disps,
 109                            struct ompi_datatype_t *sdtype,
 110                            void *rbuf, int rcount,
 111                            struct ompi_datatype_t *rdtype,
 112                            int root,
 113                            struct ompi_communicator_t *comm,
 114                            mca_coll_base_module_t *module);
 115 
 116 int mca_coll_sync_ft_event(int status);
 117 
 118 /* Types */
 119 /* Module */
 120 
 121 typedef struct mca_coll_sync_module_t {
 122     mca_coll_base_module_t super;
 123 
 124     /* Pointers to all the "real" collective functions */
 125     mca_coll_base_comm_coll_t c_coll;
 126 
 127     /* How many ops we've executed */
 128     int before_num_operations;
 129 
 130     /* How many ops we've executed (it's easier to have 2) */
 131     int after_num_operations;
 132 
 133     /* Avoid recursion of syncs */
 134     bool in_operation;
 135 } mca_coll_sync_module_t;
 136 
 137 OBJ_CLASS_DECLARATION(mca_coll_sync_module_t);
 138 
 139 /* Component */
 140 
 141 typedef struct mca_coll_sync_component_t {
 142     mca_coll_base_component_2_0_0_t super;
 143 
 144     /* Priority of this component */
 145     int priority;
 146 
 147     /* Do a sync *before* each Nth collective */
 148     int barrier_before_nops;
 149 
 150     /* Do a sync *after* each Nth collective */
 151     int barrier_after_nops;
 152 } mca_coll_sync_component_t;
 153 
 154 /* Globally exported variables */
 155 
 156 OMPI_MODULE_DECLSPEC extern mca_coll_sync_component_t mca_coll_sync_component;
 157 
 158 /* Macro used in most of the collectives */
 159 
 160 #define COLL_SYNC(m, op) \
 161 do { \
 162     int err = MPI_SUCCESS; \
 163     (m)->in_operation = true; \
 164     if (OPAL_UNLIKELY(++((m)->before_num_operations) ==                         \
 165                       mca_coll_sync_component.barrier_before_nops)) {           \
 166         (m)->before_num_operations = 0;                                         \
 167         err = (m)->c_coll.coll_barrier(comm, (m)->c_coll.coll_barrier_module);  \
 168     }                                                                           \
 169     if (OPAL_LIKELY(MPI_SUCCESS == err)) {                                      \
 170         err = op;                                                               \
 171     }                                                                           \
 172     if (OPAL_UNLIKELY(++((m)->after_num_operations) ==                          \
 173                       mca_coll_sync_component.barrier_after_nops) &&            \
 174         OPAL_LIKELY(MPI_SUCCESS == err)) {                                      \
 175         (m)->after_num_operations = 0;                                          \
 176         err = (m)->c_coll.coll_barrier(comm, (m)->c_coll.coll_barrier_module);  \
 177     }                                                                           \
 178     (m)->in_operation = false;                                                  \
 179     return err;                                                                 \
 180 } while(0)
 181 
 182 END_C_DECLS
 183 
 184 #endif /* MCA_COLL_SYNC_EXPORT_H */

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