root/opal/mca/common/ucx/common_ucx_wpool_int.h

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

INCLUDED FROM


   1 #ifndef COMMON_UCX_WPOOL_INT_H
   2 #define COMMON_UCX_WPOOL_INT_H
   3 
   4 #include "opal_config.h"
   5 #include "common_ucx.h"
   6 #include "common_ucx_wpool.h"
   7 
   8 typedef struct {
   9     opal_common_ucx_ctx_t *gctx;
  10     opal_common_ucx_winfo_t *winfo;
  11     opal_atomic_int32_t refcnt;
  12 } _tlocal_ctx_t;
  13 
  14 typedef struct {
  15     opal_common_ucx_winfo_t *worker;
  16     ucp_rkey_h *rkeys;
  17 } _mem_info_t;
  18 
  19 typedef struct {
  20     opal_common_ucx_wpmem_t *gmem;
  21     _mem_info_t *mem;
  22     opal_common_ucx_tlocal_fast_ptrs_t *mem_tls_ptr;
  23     _tlocal_ctx_t *ctx_rec;
  24 } _tlocal_mem_t;
  25 
  26 typedef struct {
  27     opal_list_item_t super;
  28     opal_common_ucx_winfo_t *ptr;
  29 } _winfo_list_item_t;
  30 OBJ_CLASS_DECLARATION(_winfo_list_item_t);
  31 
  32 
  33 typedef struct {
  34     opal_list_item_t super;
  35     opal_common_ucx_winfo_t *ptr;
  36 } _ctx_record_list_item_t;
  37 OBJ_CLASS_DECLARATION(_ctx_record_list_item_t);
  38 
  39 typedef struct {
  40     opal_list_item_t super;
  41     _tlocal_mem_t *ptr;
  42 } _mem_record_list_item_t;
  43 OBJ_CLASS_DECLARATION(_mem_record_list_item_t);
  44 
  45 /* thread-local table */
  46 typedef struct {
  47     opal_list_item_t super;
  48     opal_common_ucx_wpool_t *wpool;
  49     _tlocal_ctx_t **ctx_tbl;
  50     size_t ctx_tbl_size;
  51     _tlocal_mem_t **mem_tbl;
  52     size_t mem_tbl_size;
  53 } _tlocal_table_t;
  54 
  55 OBJ_CLASS_DECLARATION(_tlocal_table_t);
  56 
  57 static int _tlocal_tls_ctxtbl_extend(_tlocal_table_t *tbl, size_t append);
  58 static int _tlocal_tls_memtbl_extend(_tlocal_table_t *tbl, size_t append);
  59 static _tlocal_table_t* _common_ucx_tls_init(opal_common_ucx_wpool_t *wpool);
  60 static void _common_ucx_tls_cleanup(_tlocal_table_t *tls);
  61 static inline _tlocal_ctx_t *_tlocal_ctx_search(_tlocal_table_t *tls,
  62                                                 opal_common_ucx_ctx_t *ctx);
  63 static int _tlocal_ctx_record_cleanup(_tlocal_ctx_t *ctx_rec);
  64 static _tlocal_ctx_t *_tlocal_add_ctx(_tlocal_table_t *tls,
  65                                       opal_common_ucx_ctx_t *ctx);
  66 static int _tlocal_ctx_connect(_tlocal_ctx_t *ctx, int target);
  67 static inline _tlocal_mem_t *_tlocal_search_mem(_tlocal_table_t *tls,
  68                                                 opal_common_ucx_wpmem_t *gmem);
  69 static _tlocal_mem_t *_tlocal_add_mem(_tlocal_table_t *tls,
  70                                       opal_common_ucx_wpmem_t *mem);
  71 static int _tlocal_mem_create_rkey(_tlocal_mem_t *mem_rec, ucp_ep_h ep, int target);
  72 // TOD: Return the error from it
  73 static void _tlocal_mem_record_cleanup(_tlocal_mem_t *mem_rec);
  74 static void _tlocal_cleanup(void *arg);
  75 
  76 /* Sorted declarations */
  77 
  78 
  79 /* Internal Worker Information (winfo) management */
  80 static opal_common_ucx_winfo_t *_winfo_create(opal_common_ucx_wpool_t *wpool);
  81 static void _winfo_release(opal_common_ucx_winfo_t *winfo);
  82 static void _winfo_reset(opal_common_ucx_winfo_t *winfo);
  83 
  84 /* Internal Worker Pool (wpool) management */
  85 static int _wpool_list_put(opal_common_ucx_wpool_t *wpool, opal_list_t *list,
  86                            opal_common_ucx_winfo_t *winfo);
  87 static int _wpool_list_put(opal_common_ucx_wpool_t *wpool, opal_list_t *list,
  88                            opal_common_ucx_winfo_t *winfo);
  89 static opal_common_ucx_winfo_t *_wpool_list_get(opal_common_ucx_wpool_t *wpool,
  90                                        opal_list_t *list);
  91 static opal_common_ucx_winfo_t *_wpool_get_idle(opal_common_ucx_wpool_t *wpool,
  92                                        size_t comm_size);
  93 static int _wpool_add_active(opal_common_ucx_wpool_t *wpool,
  94                              opal_common_ucx_winfo_t *winfo);
  95 
  96 /* Internal Worker Pool Context management */
  97 static void _common_ucx_wpctx_free(opal_common_ucx_ctx_t *ctx);
  98 static int _common_ucx_wpctx_append(opal_common_ucx_ctx_t *ctx,
  99                                     opal_common_ucx_winfo_t *winfo);
 100 static void _common_ucx_wpctx_remove(opal_common_ucx_ctx_t *ctx,
 101                                      opal_common_ucx_winfo_t *winfo);
 102 
 103 /* Internal Worker Pool Memeory management */
 104 static int _comm_ucx_wpmem_map(opal_common_ucx_wpool_t *wpool,
 105                                void **base, size_t size, ucp_mem_h *memh_ptr,
 106                                opal_common_ucx_mem_type_t mem_type);
 107 static void _common_ucx_wpmem_free(opal_common_ucx_wpmem_t *mem);
 108 static int _common_ucx_wpmem_signup(opal_common_ucx_wpmem_t *mem);
 109 static void _common_ucx_mem_signout(opal_common_ucx_wpmem_t *mem);
 110 
 111 
 112 #endif // COMMON_UCX_WPOOL_INT_H

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