root/opal/mca/rcache/rcache.h

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

INCLUDED FROM


   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2007 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2009      IBM Corporation.  All rights reserved.
  14  * Copyright (c) 2015-2018 Los Alamos National Security, LLC. All rights
  15  *                         reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  */
  22 /**
  23   * @file
  24   * Description of the Registration Cache framework
  25   */
  26 #ifndef MCA_RCACHE_H
  27 #define MCA_RCACHE_H
  28 #include "opal/mca/mca.h"
  29 #include "opal/mca/mpool/mpool.h"
  30 #include "opal/threads/mutex.h"
  31 
  32 
  33 /* forward-declaration of rcache module structure */
  34 struct mca_rcache_base_module_t;
  35 typedef struct mca_rcache_base_module_t mca_rcache_base_module_t;
  36 
  37 enum {
  38     /** bypass the cache when registering */
  39     MCA_RCACHE_FLAGS_CACHE_BYPASS      = 0x0001,
  40     /** persistent registration */
  41     MCA_RCACHE_FLAGS_PERSIST           = 0x0002,
  42     /** registation requires strong ordering (disables relaxed ordering) */
  43     MCA_RCACHE_FLAGS_SO_MEM            = 0x0004,
  44     /** address range is cuda buffer */
  45     MCA_RCACHE_FLAGS_CUDA_GPU_MEM      = 0x0008,
  46     /** register with common cuda */
  47     MCA_RCACHE_FLAGS_CUDA_REGISTER_MEM = 0x0010,
  48     /** invalid registration (no valid for passing to rcache register) */
  49     MCA_RCACHE_FLAGS_INVALID           = 0x0080,
  50     /** reserved for rcache module */
  51     MCA_RCACHE_FLAGS_MOD_RESV0         = 0x0100,
  52     /** reserved for rcache module */
  53     MCA_RCACHE_FLAGS_MOD_RESV1         = 0x0200,
  54     /** reserved for rcache module */
  55     MCA_RCACHE_FLAGS_MOD_RESV2         = 0x0400,
  56     /** reserved for rcache module */
  57     MCA_RCACHE_FLAGS_MOD_RESV3         = 0x0800,
  58     /** reserved for register function */
  59     MCA_RCACHE_FLAGS_RESV0             = 0x1000,
  60     /** reserved for register function */
  61     MCA_RCACHE_FLAGS_RESV1             = 0x2000,
  62     /** reserved for register function */
  63     MCA_RCACHE_FLAGS_RESV2             = 0x4000,
  64     /** reserved for register function */
  65     MCA_RCACHE_FLAGS_RESV3             = 0x8000,
  66 };
  67 
  68 /** access flags */
  69 enum {
  70     /** register for local write */
  71     MCA_RCACHE_ACCESS_LOCAL_WRITE   = 0x01,
  72     /** register for remote read */
  73     MCA_RCACHE_ACCESS_REMOTE_READ   = 0x02,
  74     /** register for remote write */
  75     MCA_RCACHE_ACCESS_REMOTE_WRITE  = 0x04,
  76     /** register for local/remote atomic operations */
  77     MCA_RCACHE_ACCESS_REMOTE_ATOMIC = 0x08,
  78     /** register for any access */
  79     MCA_RCACHE_ACCESS_ANY           = 0x0f,
  80 };
  81 
  82 /** base class for all rcache registrations */
  83 struct mca_rcache_base_registration_t {
  84     /** alloc registrations to be allocated from an opal_free_list_t */
  85     opal_free_list_item_t super;
  86     /** rcache this registration belongs to */
  87     mca_rcache_base_module_t *rcache;
  88     /** base of registered region */
  89     unsigned char *base;
  90     /** bound of registered region */
  91     unsigned char *bound;
  92     /** artifact of old mpool/rcache architecture. used by cuda code */
  93     unsigned char *alloc_base;
  94     /** number of outstanding references */
  95     opal_atomic_int32_t ref_count;
  96     /** registration flags */
  97     opal_atomic_uint32_t flags;
  98     /** internal rcache context */
  99     void *rcache_context;
 100 #if OPAL_CUDA_GDR_SUPPORT
 101     /** CUDA gpu buffer identifier */
 102     unsigned long long gpu_bufID;
 103 #endif /* OPAL_CUDA_GDR_SUPPORT */
 104     /** registration access flags */
 105     int32_t access_flags;
 106     unsigned char padding[64];
 107 };
 108 
 109 typedef struct mca_rcache_base_registration_t mca_rcache_base_registration_t;
 110 
 111 OPAL_DECLSPEC OBJ_CLASS_DECLARATION(mca_rcache_base_registration_t);
 112 
 113 struct mca_rcache_base_resources_t {
 114     char  *cache_name;
 115     void  *reg_data;
 116     size_t sizeof_reg;
 117     int (*register_mem) (void *reg_data, void *base, size_t size,
 118                          mca_rcache_base_registration_t *reg);
 119     int (*deregister_mem) (void *reg_data, mca_rcache_base_registration_t *reg);
 120 };
 121 typedef struct mca_rcache_base_resources_t mca_rcache_base_resources_t;
 122 
 123 
 124 /**
 125  * component initialize
 126  */
 127 typedef struct mca_rcache_base_module_t *(*mca_rcache_base_component_init_fn_t)(mca_rcache_base_resources_t *);
 128 
 129 /**
 130   * register memory
 131   */
 132 typedef int (*mca_rcache_base_module_register_fn_t) (mca_rcache_base_module_t *rcache,
 133                                                      void *addr, size_t size, uint32_t flags,
 134                                                      int32_t access_flags,
 135                                                      mca_rcache_base_registration_t **reg);
 136 
 137 /**
 138   * deregister memory
 139   */
 140 typedef int (*mca_rcache_base_module_deregister_fn_t) (mca_rcache_base_module_t *rcache,
 141                                                        mca_rcache_base_registration_t *reg);
 142 
 143 /**
 144  * find registration in this memory pool
 145  */
 146 
 147 typedef int (*mca_rcache_base_module_find_fn_t) (mca_rcache_base_module_t *rcache, void *addr,
 148                                                  size_t size, mca_rcache_base_registration_t **reg);
 149 
 150 /**
 151  * release memory region
 152  */
 153 typedef int (*mca_rcache_base_module_invalidate_range_fn_t) (mca_rcache_base_module_t *rcache,
 154                                                              void *addr, size_t size);
 155 
 156 /**
 157  * evict one stale registration
 158  *
 159  * @returns true if successful
 160  * @returns false if no registration could be evicted
 161  */
 162 typedef bool (*mca_rcache_base_module_evict_fn_t) (mca_rcache_base_module_t *rcache);
 163 
 164 /**
 165   * finalize
 166   */
 167 typedef void (*mca_rcache_base_module_finalize_fn_t)(mca_rcache_base_module_t *rcache);
 168 
 169 /**
 170  * rcache component descriptor. Contains component version information and
 171  * open/close/init functions
 172  */
 173 
 174 struct mca_rcache_base_component_2_0_0_t{
 175     mca_base_component_t rcache_version;      /**< version */
 176     mca_base_component_data_t rcache_data; /**<metadata */
 177     mca_rcache_base_component_init_fn_t rcache_init; /**<init function */
 178 };
 179 
 180 typedef struct mca_rcache_base_component_2_0_0_t mca_rcache_base_component_2_0_0_t;
 181 
 182 typedef struct mca_rcache_base_component_2_0_0_t mca_rcache_base_component_t;
 183 
 184 
 185 /**
 186  * rcache module descriptor
 187  */
 188 struct mca_rcache_base_module_t {
 189     mca_rcache_base_component_t *rcache_component; /**< component struct */
 190 
 191     mca_rcache_base_module_register_fn_t rcache_register;
 192     mca_rcache_base_module_deregister_fn_t rcache_deregister;
 193     mca_rcache_base_module_find_fn_t rcache_find;
 194     mca_rcache_base_module_invalidate_range_fn_t rcache_invalidate_range;
 195     mca_rcache_base_module_finalize_fn_t rcache_finalize;
 196     mca_rcache_base_module_evict_fn_t rcache_evict;
 197     opal_mutex_t lock;
 198 };
 199 
 200 #define RCACHE_MAJOR_VERSION 3
 201 #define RCACHE_MINOR_VERSION 0
 202 #define RCACHE_RELEASE_VERSION 0
 203 
 204 /**
 205  * Macro for use in components that are of type rcache
 206  */
 207 #define MCA_RCACHE_BASE_VERSION_3_0_0 \
 208     OPAL_MCA_BASE_VERSION_2_1_0("rcache", RCACHE_MAJOR_VERSION, RCACHE_MAJOR_VERSION, RCACHE_RELEASE_VERSION)
 209 
 210 #endif /* MCA_RCACHE_H */
 211 

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