root/ompi/runtime/ompi_spc.h

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

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2018      The University of Tennessee and The University
   3  *                         of Tennessee Research Foundation.  All rights
   4  *                         reserved.
   5  * Copyright (c) 2018      Research Organization for Information Science
   6  *                         and Technology (RIST).  All rights reserved.
   7  *
   8  * $COPYRIGHT$
   9  *
  10  * Additional copyrights may follow
  11  *
  12  * $HEADER$
  13  */
  14 
  15 #ifndef OMPI_SPC
  16 #define OMPI_SPC
  17 
  18 #include <stdio.h>
  19 #include <stdlib.h>
  20 #include <string.h>
  21 #include <dlfcn.h>
  22 
  23 #include "ompi/communicator/communicator.h"
  24 #include "ompi/datatype/ompi_datatype.h"
  25 #include "ompi/runtime/params.h"
  26 #include "opal/mca/timer/timer.h"
  27 #include "opal/mca/base/mca_base_pvar.h"
  28 #include "opal/util/argv.h"
  29 #include "opal/util/show_help.h"
  30 #include "opal/util/output.h"
  31 
  32 #include MCA_timer_IMPLEMENTATION_HEADER
  33 
  34 /* INSTRUCTIONS FOR ADDING COUNTERS
  35  * 1.) Add a new counter name in the ompi_spc_counters_t enum before
  36  *     OMPI_SPC_NUM_COUNTERS below.
  37  * 2.) Add corresponding counter name and descriptions to the
  38  *     counter_names and counter_descriptions arrays in
  39  *     ompi_spc.c  NOTE: The names and descriptions
  40  *     MUST be in the same array location as where you added the
  41  *     counter name in step 1.
  42  * 3.) If this counter is based on a timer, add its enum name to
  43  *     the logic for timer-based counters in the ompi_spc_init
  44  *     function in ompi_spc.c
  45  * 4.) Instrument the Open MPI code base where it makes sense for
  46  *     your counter to be modified using the SPC_RECORD macro.
  47  *     Note: If your counter is timer-based you should use the
  48  *     SPC_TIMER_START and SPC_TIMER_STOP macros to record
  49  *     the time in cycles to then be converted to microseconds later
  50  *     in the ompi_spc_get_count function when requested by MPI_T
  51  */
  52 
  53 /* This enumeration serves as event ids for the various events */
  54 typedef enum ompi_spc_counters {
  55     OMPI_SPC_SEND,
  56     OMPI_SPC_BSEND,
  57     OMPI_SPC_RSEND,
  58     OMPI_SPC_SSEND,
  59     OMPI_SPC_RECV,
  60     OMPI_SPC_MRECV,
  61     OMPI_SPC_ISEND,
  62     OMPI_SPC_IBSEND,
  63     OMPI_SPC_IRSEND,
  64     OMPI_SPC_ISSEND,
  65     OMPI_SPC_IRECV,
  66     OMPI_SPC_SENDRECV,
  67     OMPI_SPC_SENDRECV_REPLACE,
  68     OMPI_SPC_PUT,
  69     OMPI_SPC_RPUT,
  70     OMPI_SPC_GET,
  71     OMPI_SPC_RGET,
  72     OMPI_SPC_PROBE,
  73     OMPI_SPC_IPROBE,
  74     OMPI_SPC_BCAST,
  75     OMPI_SPC_IBCAST,
  76     OMPI_SPC_BCAST_INIT,
  77     OMPI_SPC_REDUCE,
  78     OMPI_SPC_REDUCE_SCATTER,
  79     OMPI_SPC_REDUCE_SCATTER_BLOCK,
  80     OMPI_SPC_IREDUCE,
  81     OMPI_SPC_IREDUCE_SCATTER,
  82     OMPI_SPC_IREDUCE_SCATTER_BLOCK,
  83     OMPI_SPC_REDUCE_INIT,
  84     OMPI_SPC_REDUCE_SCATTER_INIT,
  85     OMPI_SPC_REDUCE_SCATTER_BLOCK_INIT,
  86     OMPI_SPC_ALLREDUCE,
  87     OMPI_SPC_IALLREDUCE,
  88     OMPI_SPC_ALLREDUCE_INIT,
  89     OMPI_SPC_SCAN,
  90     OMPI_SPC_EXSCAN,
  91     OMPI_SPC_ISCAN,
  92     OMPI_SPC_IEXSCAN,
  93     OMPI_SPC_SCAN_INIT,
  94     OMPI_SPC_EXSCAN_INIT,
  95     OMPI_SPC_SCATTER,
  96     OMPI_SPC_SCATTERV,
  97     OMPI_SPC_ISCATTER,
  98     OMPI_SPC_ISCATTERV,
  99     OMPI_SPC_SCATTER_INIT,
 100     OMPI_SPC_SCATTERV_INIT,
 101     OMPI_SPC_GATHER,
 102     OMPI_SPC_GATHERV,
 103     OMPI_SPC_IGATHER,
 104     OMPI_SPC_IGATHERV,
 105     OMPI_SPC_GATHER_INIT,
 106     OMPI_SPC_GATHERV_INIT,
 107     OMPI_SPC_ALLTOALL,
 108     OMPI_SPC_ALLTOALLV,
 109     OMPI_SPC_ALLTOALLW,
 110     OMPI_SPC_IALLTOALL,
 111     OMPI_SPC_IALLTOALLV,
 112     OMPI_SPC_IALLTOALLW,
 113     OMPI_SPC_ALLTOALL_INIT,
 114     OMPI_SPC_ALLTOALLV_INIT,
 115     OMPI_SPC_ALLTOALLW_INIT,
 116     OMPI_SPC_NEIGHBOR_ALLTOALL,
 117     OMPI_SPC_NEIGHBOR_ALLTOALLV,
 118     OMPI_SPC_NEIGHBOR_ALLTOALLW,
 119     OMPI_SPC_INEIGHBOR_ALLTOALL,
 120     OMPI_SPC_INEIGHBOR_ALLTOALLV,
 121     OMPI_SPC_INEIGHBOR_ALLTOALLW,
 122     OMPI_SPC_NEIGHBOR_ALLTOALL_INIT,
 123     OMPI_SPC_NEIGHBOR_ALLTOALLV_INIT,
 124     OMPI_SPC_NEIGHBOR_ALLTOALLW_INIT,
 125     OMPI_SPC_ALLGATHER,
 126     OMPI_SPC_ALLGATHERV,
 127     OMPI_SPC_IALLGATHER,
 128     OMPI_SPC_IALLGATHERV,
 129     OMPI_SPC_ALLGATHER_INIT,
 130     OMPI_SPC_ALLGATHERV_INIT,
 131     OMPI_SPC_NEIGHBOR_ALLGATHER,
 132     OMPI_SPC_NEIGHBOR_ALLGATHERV,
 133     OMPI_SPC_INEIGHBOR_ALLGATHER,
 134     OMPI_SPC_INEIGHBOR_ALLGATHERV,
 135     OMPI_SPC_NEIGHBOR_ALLGATHER_INIT,
 136     OMPI_SPC_NEIGHBOR_ALLGATHERV_INIT,
 137     OMPI_SPC_TEST,
 138     OMPI_SPC_TESTALL,
 139     OMPI_SPC_TESTANY,
 140     OMPI_SPC_TESTSOME,
 141     OMPI_SPC_WAIT,
 142     OMPI_SPC_WAITALL,
 143     OMPI_SPC_WAITANY,
 144     OMPI_SPC_WAITSOME,
 145     OMPI_SPC_BARRIER,
 146     OMPI_SPC_IBARRIER,
 147     OMPI_SPC_BARRIER_INIT,
 148     OMPI_SPC_WTIME,
 149     OMPI_SPC_CANCEL,
 150     OMPI_SPC_BYTES_RECEIVED_USER,
 151     OMPI_SPC_BYTES_RECEIVED_MPI,
 152     OMPI_SPC_BYTES_SENT_USER,
 153     OMPI_SPC_BYTES_SENT_MPI,
 154     OMPI_SPC_BYTES_PUT,
 155     OMPI_SPC_BYTES_GET,
 156     OMPI_SPC_UNEXPECTED,
 157     OMPI_SPC_OUT_OF_SEQUENCE,
 158     OMPI_SPC_MATCH_TIME,
 159     OMPI_SPC_UNEXPECTED_IN_QUEUE,
 160     OMPI_SPC_OOS_IN_QUEUE,
 161     OMPI_SPC_MAX_UNEXPECTED_IN_QUEUE,
 162     OMPI_SPC_MAX_OOS_IN_QUEUE,
 163     OMPI_SPC_NUM_COUNTERS /* This serves as the number of counters.  It must be last. */
 164 } ompi_spc_counters_t;
 165 
 166 /* There is currently no support for atomics on long long values so we will default to
 167  * size_t for now until support for such atomics is implemented.
 168  */
 169 typedef opal_atomic_size_t ompi_spc_value_t;
 170 
 171 /* A structure for storing the event data */
 172 typedef struct ompi_spc_s{
 173     char *name;
 174     ompi_spc_value_t value;
 175 } ompi_spc_t;
 176 
 177 /* Events data structure initialization function */
 178 void ompi_spc_events_init(void);
 179 
 180 /* OMPI SPC utility functions */
 181 void ompi_spc_init(void);
 182 void ompi_spc_fini(void);
 183 void ompi_spc_record(unsigned int event_id, ompi_spc_value_t value);
 184 void ompi_spc_timer_start(unsigned int event_id, opal_timer_t *cycles);
 185 void ompi_spc_timer_stop(unsigned int event_id, opal_timer_t *cycles);
 186 void ompi_spc_user_or_mpi(int tag, ompi_spc_value_t value, unsigned int user_enum, unsigned int mpi_enum);
 187 void ompi_spc_cycles_to_usecs(ompi_spc_value_t *cycles);
 188 void ompi_spc_update_watermark(unsigned int watermark_enum, unsigned int value_enum);
 189 
 190 /* Macros for using the SPC utility functions throughout the codebase.
 191  * If SPC_ENABLE is not 1, the macros become no-ops.
 192  */
 193 #if SPC_ENABLE == 1
 194 
 195 #define SPC_INIT()  \
 196     ompi_spc_init()
 197 
 198 #define SPC_FINI()  \
 199     ompi_spc_fini()
 200 
 201 #define SPC_RECORD(event_id, value)  \
 202     ompi_spc_record(event_id, value)
 203 
 204 #define SPC_TIMER_START(event_id, usec)  \
 205     ompi_spc_timer_start(event_id, usec)
 206 
 207 #define SPC_TIMER_STOP(event_id, usec)  \
 208     ompi_spc_timer_stop(event_id, usec)
 209 
 210 #define SPC_USER_OR_MPI(tag, value, enum_if_user, enum_if_mpi) \
 211     ompi_spc_user_or_mpi(tag, value, enum_if_user, enum_if_mpi)
 212 
 213 #define SPC_CYCLES_TO_USECS(cycles) \
 214     ompi_spc_cycles_to_usecs(cycles)
 215 
 216 #define SPC_UPDATE_WATERMARK(watermark_enum, value_enum) \
 217     ompi_spc_update_watermark(watermark_enum, value_enum)
 218 
 219 #else /* SPCs are not enabled */
 220 
 221 #define SPC_INIT()  \
 222     ((void)0)
 223 
 224 #define SPC_FINI()  \
 225     ((void)0)
 226 
 227 #define SPC_RECORD(event_id, value)  \
 228     ((void)0)
 229 
 230 #define SPC_TIMER_START(event_id, usec)  \
 231     ((void)0)
 232 
 233 #define SPC_TIMER_STOP(event_id, usec)  \
 234     ((void)0)
 235 
 236 #define SPC_USER_OR_MPI(tag, value, enum_if_user, enum_if_mpi) \
 237     ((void)0)
 238 
 239 #define SPC_CYCLES_TO_USECS(cycles) \
 240     ((void)0)
 241 
 242 #define SPC_UPDATE_WATERMARK(watermark_enum, value_enum) \
 243     ((void)0)
 244 
 245 #endif
 246 
 247 #endif

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