root/ompi/mca/osc/portals4/osc_portals4.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. get_displacement
  2. ompi_osc_portals4_complete_all
  3. ompi_osc_portals4_get_peer_group
  4. ompi_osc_portals4_get_peer

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2011-2017 Sandia National Laboratories.  All rights reserved.
   4  * Copyright (c) 2015-2018 Los Alamos National Security, LLC.  All rights
   5  *                         reserved.
   6  * Copyright (c) 2015-2017 Research Organization for Information Science
   7  *                         and Technology (RIST). All rights reserved.
   8  * Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
   9  * $COPYRIGHT$
  10  *
  11  * Additional copyrights may follow
  12  *
  13  * $HEADER$
  14  */
  15 
  16 #ifndef OSC_PORTALS4_PORTALS4_H
  17 #define OSC_PORTALS4_PORTALS4_H
  18 
  19 #include <portals4.h>
  20 #include "ompi/group/group.h"
  21 #include "ompi/communicator/communicator.h"
  22 
  23 #include "ompi/mca/mtl/portals4/mtl_portals4.h"
  24 
  25 #define REQ_OSC_TABLE_ID     4
  26 
  27 #define OSC_PORTALS4_IOVEC_MAX 64
  28 
  29 #define OSC_PORTALS4_MB_DATA    0x0000000000000000ULL
  30 #define OSC_PORTALS4_MB_CONTROL 0x1000000000000000ULL
  31 
  32 /* Component structure.  There is one of these per process, per process lifetime.
  33  *
  34  * Currently, the Portals 4 one-sided implementation only uses a
  35  * matching interface for all communication.  There are plans for
  36  * using a non-matching interface for a few windows (they each need
  37  * their own PTE, which is a precious resource).  In anticipation of
  38  * that, we initialize the network interfaces and keep them in the
  39  * component structure (for win create), but then also keep a handle
  40  * copy in the window module, so that we can use the right structures
  41  * once we add the non-matching support.
  42  *
  43  * The sizes are kept in the component structure because we can only
  44  * find them during PtlNIInit, and it would be poor to do that for
  45  * every window creation.  Again, the window module has a copy of the
  46  * max sizes, but tweaked to match the window configuration (ie,
  47  * there's one atomic size, instead of an ordered and unordered size,
  48  * since we know the ordering constraints during window creation).
  49  */
  50 struct ompi_osc_portals4_component_t {
  51     ompi_osc_base_component_t super;
  52 
  53     ptl_handle_ni_t matching_ni_h;
  54     ptl_handle_eq_t matching_eq_h;
  55     ptl_pt_index_t matching_pt_idx;
  56     ptl_size_t matching_atomic_max;
  57     ptl_size_t matching_fetch_atomic_max;
  58     ptl_size_t matching_atomic_ordered_size;
  59     ptl_size_t ptl_max_msg_size; /* max size given by portals (cf PtlNIInit) */
  60     bool no_locks;
  61     ptl_uid_t uid;
  62     opal_mutex_t lock;
  63     opal_condition_t cond;
  64 
  65     opal_free_list_t requests; /* request free list for the r* communication variants */
  66 };
  67 typedef struct ompi_osc_portals4_component_t ompi_osc_portals4_component_t;
  68 OMPI_DECLSPEC extern ompi_osc_portals4_component_t mca_osc_portals4_component;
  69 
  70 /* Data about me exposed to remote peers.  Used in generalized active
  71    target and passive target synchronization. */
  72 struct ompi_osc_portals4_node_state_t {
  73     volatile int32_t post_count;
  74     volatile int32_t complete_count;
  75     volatile uint64_t lock;
  76 };
  77 typedef struct ompi_osc_portals4_node_state_t ompi_osc_portals4_node_state_t;
  78 
  79 #define LOCK_ILLEGAL   (0x4000000000000000ULL)
  80 #define LOCK_UNLOCKED  (0x0000000000000000ULL)
  81 #define LOCK_EXCLUSIVE (0x0000000100000000ULL)
  82 
  83 /* Module structure.  There is one of these per window */
  84 struct ompi_osc_portals4_module_t {
  85     ompi_osc_base_module_t super;
  86     void *free_after; /* if non-null, this pointer should be free()ed when window destroyed */
  87     struct ompi_communicator_t *comm; /* communicator which backs this window (unique to this window) */
  88     int disp_unit; /* if -1, have to look at disp_units */
  89     int *disp_units; /* array (possibly NULL!) of displacement units, per peer */
  90     ptl_handle_ni_t ni_h; /* network interface used by this window */
  91     ptl_pt_index_t pt_idx; /* portal table index used by this window (this will be same across window) */
  92     ptl_handle_ct_t ct_h; /* Counting event handle used for completion in this window */
  93     int ct_link; /* PTL_EVENT_LINK flag */
  94     ptl_handle_md_t md_h; /* memory descriptor describing all of memory used by this window */
  95     ptl_handle_md_t req_md_h; /* memory descriptor with event completion used by this window */
  96     ptl_handle_me_t data_me_h; /* data match list entry (MB are CID | OSC_PORTALS4_MB_DATA) */
  97     ptl_handle_me_t control_me_h; /* match list entry for control data (node_state_t).  Match bits are (CID | OSC_PORTALS4_MB_CONTROL). */
  98     opal_atomic_int64_t opcount;
  99     ptl_match_bits_t match_bits; /* match bits for module.  Same as cid for comm in most cases. */
 100 
 101     ptl_iovec_t     *origin_iovec_list; /* list of memory segments that compose the noncontiguous region */
 102     ptl_handle_md_t  origin_iovec_md_h; /* memory descriptor describing a noncontiguous region in this window */
 103     ptl_iovec_t     *result_iovec_list; /* list of memory segments that compose the noncontiguous region */
 104     ptl_handle_md_t  result_iovec_md_h; /* memory descriptor describing a noncontiguous region in this window */
 105 
 106     ptl_size_t atomic_max; /* max size of atomic messages.  Will guarantee ordering IF ordering requested */
 107     ptl_size_t fetch_atomic_max; /* max size of fetchatomic messages.  Will guarantee ordering IF ordering requested */
 108 
 109     /* variable containing specified value.  Needed for atomic
 110     increments so they can be non-blocking */
 111     int32_t zero;
 112     int32_t one;
 113 
 114     ompi_group_t *start_group;
 115     ompi_group_t *post_group;
 116     opal_list_t outstanding_locks;
 117 
 118     bool passive_target_access_epoch; /* True if the access epoch is a passive target access epoch */
 119 
 120     /* things that are remotely accessible */
 121     ompi_osc_portals4_node_state_t state;
 122 };
 123 typedef struct ompi_osc_portals4_module_t ompi_osc_portals4_module_t;
 124 
 125 
 126 static inline size_t
 127 get_displacement(ompi_osc_portals4_module_t *module,
 128                  int target)
 129 {
 130     if (-1 == module->disp_unit) {
 131         return module->disp_units[target];
 132     } else {
 133         return module->disp_unit;
 134     }
 135 }
 136 
 137 
 138 int ompi_osc_portals4_attach(struct ompi_win_t *win, void *base, size_t len);
 139 int ompi_osc_portals4_detach(struct ompi_win_t *win, const void *base);
 140 
 141 int ompi_osc_portals4_free(struct ompi_win_t *win);
 142 
 143 int ompi_osc_portals4_put(const void *origin_addr,
 144                           int origin_count,
 145                           struct ompi_datatype_t *origin_dt,
 146                           int target,
 147                           ptrdiff_t target_disp,
 148                           int target_count,
 149                           struct ompi_datatype_t *target_dt,
 150                           struct ompi_win_t *win);
 151 
 152 int ompi_osc_portals4_get(void *origin_addr,
 153                           int origin_count,
 154                           struct ompi_datatype_t *origin_dt,
 155                           int target,
 156                           ptrdiff_t target_disp,
 157                           int target_count,
 158                           struct ompi_datatype_t *target_dt,
 159                           struct ompi_win_t *win);
 160 
 161 int ompi_osc_portals4_accumulate(const void *origin_addr,
 162                                  int origin_count,
 163                                  struct ompi_datatype_t *origin_dt,
 164                                  int target,
 165                                  ptrdiff_t target_disp,
 166                                  int target_count,
 167                                  struct ompi_datatype_t *target_dt,
 168                                  struct ompi_op_t *op,
 169                                  struct ompi_win_t *win);
 170 
 171 int ompi_osc_portals4_compare_and_swap(const void *origin_addr,
 172                                        const void *compare_addr,
 173                                        void *result_addr,
 174                                        struct ompi_datatype_t *dt,
 175                                        int target,
 176                                        ptrdiff_t target_disp,
 177                                        struct ompi_win_t *win);
 178 
 179 int ompi_osc_portals4_fetch_and_op(const void *origin_addr,
 180                                    void *result_addr,
 181                                    struct ompi_datatype_t *dt,
 182                                    int target,
 183                                    ptrdiff_t target_disp,
 184                                    struct ompi_op_t *op,
 185                                    struct ompi_win_t *win);
 186 
 187 int ompi_osc_portals4_get_accumulate(const void *origin_addr,
 188                                      int origin_count,
 189                                      struct ompi_datatype_t *origin_datatype,
 190                                      void *result_addr,
 191                                      int result_count,
 192                                      struct ompi_datatype_t *result_datatype,
 193                                      int target_rank,
 194                                      ptrdiff_t target_disp,
 195                                      int target_count,
 196                                      struct ompi_datatype_t *target_datatype,
 197                                      struct ompi_op_t *op,
 198                                      struct ompi_win_t *win);
 199 
 200 int ompi_osc_portals4_rput(const void *origin_addr,
 201                            int origin_count,
 202                            struct ompi_datatype_t *origin_dt,
 203                            int target,
 204                            ptrdiff_t target_disp,
 205                            int target_count,
 206                            struct ompi_datatype_t *target_dt,
 207                            struct ompi_win_t *win,
 208                            struct ompi_request_t **request);
 209 
 210 int ompi_osc_portals4_rget(void *origin_addr,
 211                            int origin_count,
 212                            struct ompi_datatype_t *origin_dt,
 213                            int target,
 214                            ptrdiff_t target_disp,
 215                            int target_count,
 216                            struct ompi_datatype_t *target_dt,
 217                            struct ompi_win_t *win,
 218                            struct ompi_request_t **request);
 219 
 220 int ompi_osc_portals4_raccumulate(const void *origin_addr,
 221                                   int origin_count,
 222                                   struct ompi_datatype_t *origin_dt,
 223                                   int target,
 224                                   ptrdiff_t target_disp,
 225                                   int target_count,
 226                                   struct ompi_datatype_t *target_dt,
 227                                   struct ompi_op_t *op,
 228                                   struct ompi_win_t *win,
 229                                   struct ompi_request_t **request);
 230 
 231 int ompi_osc_portals4_rget_accumulate(const void *origin_addr,
 232                                       int origin_count,
 233                                       struct ompi_datatype_t *origin_datatype,
 234                                       void *result_addr,
 235                                       int result_count,
 236                                       struct ompi_datatype_t *result_datatype,
 237                                       int target_rank,
 238                                       ptrdiff_t target_disp,
 239                                       int target_count,
 240                                       struct ompi_datatype_t *target_datatype,
 241                                       struct ompi_op_t *op,
 242                                       struct ompi_win_t *win,
 243                                       struct ompi_request_t **request);
 244 
 245 int ompi_osc_portals4_fence(int assert, struct ompi_win_t *win);
 246 
 247 int ompi_osc_portals4_start(struct ompi_group_t *group,
 248                             int assert,
 249                             struct ompi_win_t *win);
 250 
 251 int ompi_osc_portals4_complete(struct ompi_win_t *win);
 252 
 253 int ompi_osc_portals4_post(struct ompi_group_t *group,
 254                            int assert,
 255                            struct ompi_win_t *win);
 256 
 257 int ompi_osc_portals4_wait(struct ompi_win_t *win);
 258 
 259 int ompi_osc_portals4_test(struct ompi_win_t *win,
 260                            int *flag);
 261 
 262 int ompi_osc_portals4_lock(int lock_type,
 263                            int target,
 264                            int assert,
 265                            struct ompi_win_t *win);
 266 
 267 int ompi_osc_portals4_unlock(int target,
 268                              struct ompi_win_t *win);
 269 
 270 
 271 int ompi_osc_portals4_lock_all(int assert,
 272                                struct ompi_win_t *win);
 273 
 274 int ompi_osc_portals4_unlock_all(struct ompi_win_t *win);
 275 
 276 int ompi_osc_portals4_sync(struct ompi_win_t *win);
 277 
 278 int ompi_osc_portals4_flush(int target,
 279                             struct ompi_win_t *win);
 280 int ompi_osc_portals4_flush_all(struct ompi_win_t *win);
 281 int ompi_osc_portals4_flush_local(int target,
 282                                   struct ompi_win_t *win);
 283 int ompi_osc_portals4_flush_local_all(struct ompi_win_t *win);
 284 
 285 static inline int
 286 ompi_osc_portals4_complete_all(ompi_osc_portals4_module_t *module)
 287 {
 288     int ret;
 289     ptl_ct_event_t event;
 290 
 291     ret = PtlCTWait(module->ct_h, module->opcount, &event);
 292     if (PTL_OK != ret || 0 != event.failure) {
 293         opal_output_verbose(1, ompi_osc_base_framework.framework_output,
 294                             "%s:%d: flush_all ct failure: ret=%d, failure=%d\n",
 295                             __FILE__, __LINE__, ret, (int) event.failure);
 296         event.success = event.failure = 0;
 297         PtlCTSet(module->ct_h, event);
 298         module->opcount = 0;
 299     }
 300     assert(event.success == (size_t) module->opcount);
 301 
 302     PtlAtomicSync();
 303 
 304     return ret;
 305 }
 306 
 307 static inline ptl_process_t
 308 ompi_osc_portals4_get_peer_group(struct ompi_group_t *group, int rank)
 309 {
 310     return ompi_mtl_portals4_get_peer_group(group, rank);
 311 }
 312 
 313 static inline ptl_process_t
 314 ompi_osc_portals4_get_peer(ompi_osc_portals4_module_t *module, int rank)
 315 {
 316     return ompi_osc_portals4_get_peer_group(module->comm->c_remote_group, rank);
 317 }
 318 
 319 #endif

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