root/ompi/mca/mtl/ofi/mtl_ofi_types.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. mtl_ofi_create_send_tag_CQD
  2. mtl_ofi_create_recv_tag_CQD
  3. mtl_ofi_create_send_tag
  4. mtl_ofi_create_recv_tag
  5. mtl_ofi_get_source

   1 /*
   2  * Copyright (c) 2013-2018 Intel, Inc. All rights reserved
   3  *
   4  * Copyright (c) 2015 Cisco Systems, Inc.  All rights reserved.
   5  * $COPYRIGHT$
   6  *
   7  * Additional copyrights may follow
   8  *
   9  * $HEADER$
  10  */
  11 
  12 #ifndef MTL_OFI_TYPES_H_HAS_BEEN_INCLUDED
  13 #define MTL_OFI_TYPES_H_HAS_BEEN_INCLUDED
  14 
  15 #include "mtl_ofi.h"
  16 
  17 BEGIN_C_DECLS
  18 
  19 /**
  20  * MTL Module Interface
  21  */
  22 
  23 typedef struct mca_mtl_ofi_context_t {
  24     /* Transmit and receive contexts */
  25     struct fid_ep *tx_ep;
  26     struct fid_ep *rx_ep;
  27 
  28     /* Completion queue */
  29     struct fid_cq *cq;
  30 
  31     /* Thread locking */
  32     opal_mutex_t context_lock;
  33 } mca_mtl_ofi_context_t;
  34 
  35 typedef struct mca_mtl_ofi_module_t {
  36     mca_mtl_base_module_t base;
  37 
  38     /** Fabric Domain handle */
  39     struct fid_fabric *fabric;
  40 
  41     /** Access Domain handle */
  42     struct fid_domain *domain;
  43 
  44     /** Address vector handle */
  45     struct fid_av *av;
  46 
  47     /* Multi-threaded Application flag */
  48     bool mpi_thread_multiple;
  49 
  50     /* Scalable Endpoint attributes */
  51     struct fid_ep *sep;                 /* Endpoint object */
  52     mca_mtl_ofi_context_t *ofi_ctxt;    /* OFI contexts */
  53     int threshold_comm_context_id;      /* Set threshold communicator ID */
  54     int *comm_to_context;               /* Map communicator ID to context */
  55     int rx_ctx_bits;                    /* Bits used for RX context */
  56     int total_ctxts_used;               /* Total number of contexts used */
  57     int enable_sep;                     /* MCA to enable/disable SEP feature */
  58     int thread_grouping;                /* MCA for thread grouping feature */
  59     int num_ofi_contexts;               /* MCA for number of contexts to use */
  60 
  61     /** Endpoint name length */
  62     size_t epnamelen;
  63 
  64     /** "Any source" address */
  65     fi_addr_t any_addr;
  66 
  67     /** OFI provider name */
  68     char *provider_name;
  69 
  70     /** Maximum inject size */
  71     size_t max_inject_size;
  72 
  73     /** Maximum number of CQ events to read in OFI Progress */
  74     int ofi_progress_event_count;
  75 
  76     /** Use FI_REMOTE_CQ_DATA*/
  77     bool fi_cq_data;
  78 
  79     /** Info used to create the OFI tag **/
  80     unsigned long long source_rank_tag_mask;
  81     int num_bits_source_rank;
  82     unsigned long long source_rank_mask;
  83     unsigned long long mpi_tag_mask;
  84     int num_bits_mpi_tag;
  85     int num_peers;
  86 
  87     /** Synchronous protocol tag bits */
  88     unsigned long long sync_send;
  89     unsigned long long sync_send_ack;
  90     unsigned long long sync_proto_mask;
  91 
  92     /** Optimized function Symbol Tables **/
  93     struct ompi_mtl_ofi_symtable sym_table;
  94 
  95 } mca_mtl_ofi_module_t;
  96 
  97 extern mca_mtl_ofi_module_t ompi_mtl_ofi;
  98 
  99 typedef struct mca_mtl_ofi_component_t {
 100     /** Base MTL component */
 101     mca_mtl_base_component_2_0_0_t super;
 102 } mca_mtl_ofi_component_t;
 103 
 104 typedef enum {
 105     OFI_REGULAR_EP  = 0,
 106     OFI_SCALABLE_EP,
 107 } mca_mtl_ofi_ep_type;
 108 
 109 /*
 110  * Define upper limit for number of events read from a CQ.
 111  * Setting this to 100 as this was deemed optimal from empirical data.
 112  * If one wants to read lesser number of events from the CQ, the MCA
 113  * variable can be used.
 114  */
 115 #define MTL_OFI_MAX_PROG_EVENT_COUNT    100
 116 
 117 /*OFI TAG:
 118  * Define 3 different OFI tag distributions:
 119  * 1) Support FI_REMOTE_CQ_DATA: No need for source rank in the tag
 120  * 2) ofi_tag_1: fallback when no FI_REMOTE_CQ_DATA is supported
 121  * 3) ofi_tag_2: Alternative tag when no FI_REMOTE_CQ_DATA is supported
 122  *    with more bits for the communicator ID.
 123  * More details of the tags are in the README file (mtl_ofi_tag_mode).
 124 */
 125 
 126 #define MTL_OFI_MINIMUM_CID_BITS        (8)
 127 
 128 /* Support FI_REMOTE_CQ_DATA, send the source rank in the CQ data (4 Bytes is the minimum)
 129  *  01234567 01234567 01234567 012345  67  01234567 01234567 01234567 01234567
 130  *                                   |    |
 131  *           context_id              |prot|          message tag
 132  */
 133 #define MTL_OFI_PROTO_BIT_COUNT         (2)
 134 #define MTL_OFI_HIGHEST_TAG_BIT         (0x8000000000000000ULL)
 135 
 136 #define MTL_OFI_CID_MASK_DATA           (0xFFFFFFFC00000000ULL)
 137 #define MTL_OFI_CID_BIT_COUNT_DATA      (30)
 138 #define MTL_OFI_TAG_MASK_DATA           (0x00000000FFFFFFFFULL)
 139 #define MTL_OFI_TAG_BIT_COUNT_DATA      (32)
 140 #define MTL_OFI_PROTO_MASK_DATA         (0x0000000300000000ULL)
 141 #define MTL_OFI_SYNC_SEND_DATA          (0x0000000100000000ULL)
 142 #define MTL_OFI_SYNC_SEND_ACK_DATA      (0x0000000200000000ULL)
 143 
 144 /* Send tag with CQ_DATA */
 145 __opal_attribute_always_inline__ static inline uint64_t
 146 mtl_ofi_create_send_tag_CQD(int comm_id, int tag)
 147 {
 148     uint64_t  match_bits = comm_id;
 149     match_bits = (match_bits << (MTL_OFI_TAG_BIT_COUNT_DATA
 150                                 + MTL_OFI_PROTO_BIT_COUNT));
 151     match_bits |= (tag & MTL_OFI_TAG_MASK_DATA);
 152     return match_bits;
 153 }
 154 
 155 /* Receive tag with CQ_DATA */
 156 __opal_attribute_always_inline__ static inline void
 157 mtl_ofi_create_recv_tag_CQD(uint64_t *match_bits, uint64_t *mask_bits,
 158                             int comm_id, int tag)
 159 {
 160     *mask_bits  = ompi_mtl_ofi.sync_proto_mask;
 161     *match_bits = (uint64_t) comm_id;
 162     *match_bits = (*match_bits << (MTL_OFI_PROTO_BIT_COUNT
 163                                 +  MTL_OFI_TAG_BIT_COUNT_DATA));
 164     if (MPI_ANY_TAG == tag) {
 165         /* Special negative tags are used for collective operations.
 166          * MPI_ANY_TAG should not match these special tags.
 167          * See ompi/mca/coll/base/coll_tags.h
 168          */
 169         *mask_bits  |= (ompi_mtl_ofi.mpi_tag_mask>>1);
 170     } else {
 171         *match_bits |= (ompi_mtl_ofi.mpi_tag_mask & tag);
 172     }
 173 }
 174 
 175 /*
 176 * ofi_tag_1: fallback when no FI_REMOTE_CQ_DATA is supported
 177 *
 178 *  01234567 0123 4567 01234567 012345   67   01234567 01234567 01234567 01234567
 179 *               |                     |    |
 180 *    Comm id    |     source          |prot|           message tag
 181 */
 182 
 183 #define MTL_OFI_CID_BIT_COUNT_1         (12)
 184 #define MTL_OFI_SOURCE_TAG_MASK_1       (0x000FFFFC00000000ULL)
 185 #define MTL_OFI_SOURCE_BIT_COUNT_1      (18)
 186 #define MTL_OFI_SOURCE_MASK_1           (0x000000000003FFFFULL)
 187 #define MTL_OFI_TAG_MASK_1              (0x00000000FFFFFFFFULL)
 188 #define MTL_OFI_TAG_BIT_COUNT_1         (32)
 189 #define MTL_OFI_PROTO_MASK_1            (0x0000000300000000ULL)
 190 #define MTL_OFI_SYNC_SEND_1             (0x0000000100000000ULL)
 191 #define MTL_OFI_SYNC_SEND_ACK_1         (0x0000000200000000ULL)
 192 
 193 /*
 194 * ofi_tag_2: Alternative tag when no FI_REMOTE_CQ_DATA is supported
 195 *
 196 *  01234567 01234567 01234567 01234567 01234567 01  23   4567 01234567 01234567
 197 *                            |                    |    |
 198 *                Comm id     |     source         |prot|     message tag
 199 */
 200 
 201 #define MTL_OFI_CID_BIT_COUNT_2         (24)
 202 #define MTL_OFI_SOURCE_TAG_MASK_2       (0x000000FFFFC00000ULL)
 203 #define MTL_OFI_SOURCE_BIT_COUNT_2      (18)
 204 #define MTL_OFI_SOURCE_MASK_2           (0x000000000003FFFFULL)
 205 #define MTL_OFI_TAG_MASK_2              (0x00000000000FFFFFULL)
 206 #define MTL_OFI_TAG_BIT_COUNT_2         (20)
 207 #define MTL_OFI_PROTO_MASK_2            (0x0000000000300000ULL)
 208 #define MTL_OFI_SYNC_SEND_2             (0x0000000000100000ULL)
 209 #define MTL_OFI_SYNC_SEND_ACK_2         (0x0000000000200000ULL)
 210 
 211 /* Send tag */
 212 __opal_attribute_always_inline__ static inline uint64_t
 213 mtl_ofi_create_send_tag(int comm_id, int source, int tag)
 214 {
 215     uint64_t  match_bits = comm_id;
 216     match_bits = (match_bits << ompi_mtl_ofi.num_bits_source_rank);
 217     match_bits |= (uint64_t)(source & ompi_mtl_ofi.source_rank_mask);
 218     match_bits = (match_bits << (ompi_mtl_ofi.num_bits_mpi_tag
 219                                  + MTL_OFI_PROTO_BIT_COUNT));
 220     match_bits |= (tag & ompi_mtl_ofi.mpi_tag_mask);
 221     return match_bits;
 222 }
 223 
 224 /* Receive tag*/
 225 __opal_attribute_always_inline__ static inline void
 226 mtl_ofi_create_recv_tag(uint64_t *match_bits, uint64_t *mask_bits,
 227                             int comm_id, int source, int tag)
 228 {
 229     *mask_bits  = ompi_mtl_ofi.sync_proto_mask;
 230     *match_bits = comm_id;
 231     *match_bits = (*match_bits << ompi_mtl_ofi.num_bits_source_rank);
 232 
 233     if (MPI_ANY_SOURCE == source) {
 234         *match_bits = (*match_bits << (ompi_mtl_ofi.num_bits_mpi_tag
 235                                     + MTL_OFI_PROTO_BIT_COUNT));
 236         *mask_bits |= ompi_mtl_ofi.source_rank_tag_mask;
 237     } else {
 238         *match_bits |= (uint64_t)(source & ompi_mtl_ofi.source_rank_mask);
 239         *match_bits = (*match_bits << (ompi_mtl_ofi.num_bits_mpi_tag
 240                                  + MTL_OFI_PROTO_BIT_COUNT));
 241     }
 242 
 243     if (MPI_ANY_TAG == tag) {
 244         /* Special negative tags are used for collective operations.
 245          * MPI_ANY_TAG should not match these special tags.
 246          * See ompi/mca/coll/base/coll_tags.h
 247          */
 248           *mask_bits  |= (ompi_mtl_ofi.mpi_tag_mask>>1);
 249     } else {
 250         *match_bits |= (ompi_mtl_ofi.mpi_tag_mask & tag);
 251     }
 252 }
 253 
 254 #define MTL_OFI_SET_SYNC_SEND(match_bits)          \
 255         match_bits |= ompi_mtl_ofi.sync_send
 256 
 257 #define MTL_OFI_IS_SYNC_SEND(match_bits)           \
 258     (ompi_mtl_ofi.sync_send == (ompi_mtl_ofi.sync_proto_mask & match_bits))
 259 
 260 #define MTL_OFI_IS_SYNC_SEND_ACK(match_bits)       \
 261     (ompi_mtl_ofi.sync_send_ack == (ompi_mtl_ofi.sync_proto_mask & match_bits))
 262 
 263 #define MTL_OFI_GET_TAG(match_bits)                \
 264     ((int)(match_bits & ompi_mtl_ofi.mpi_tag_mask))
 265 
 266 __opal_attribute_always_inline__ static inline int
 267 mtl_ofi_get_source(struct fi_cq_tagged_entry *wc)
 268 {
 269     int src;
 270     if (ompi_mtl_ofi.fi_cq_data) {
 271         src = (int) wc->data;
 272     }
 273     else {
 274         src = (int)((wc->tag >> (MTL_OFI_PROTO_BIT_COUNT +
 275                     ompi_mtl_ofi.num_bits_mpi_tag)) & ompi_mtl_ofi.source_rank_mask);
 276     }
 277 
 278     return src;
 279 }
 280 END_C_DECLS
 281 
 282 #endif /* MTL_OFI_TYPES_H_HAS_BEEN_INCLUDED */

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