| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#ifdef HAVE_CONFIG_H |
| 8 |
# include "config.h" |
| 9 |
#endif |
| 10 |
|
| 11 |
#include "ugni_types.h" |
| 12 |
#include "ugni_md.h" |
| 13 |
#include "ugni_device.h" |
| 14 |
#include "ugni_ep.h" |
| 15 |
#include "ugni_iface.h" |
| 16 |
|
| 17 |
ucs_status_t uct_ugni_iface_flush(uct_iface_h tl_iface, unsigned flags, |
| 18 |
uct_completion_t *comp) |
| 19 |
{ |
| 20 |
uct_ugni_iface_t *iface = ucs_derived_of(tl_iface, uct_ugni_iface_t); |
| 21 |
|
| 22 |
if (comp != NULL) { |
| 23 |
return UCS_ERR_UNSUPPORTED; |
| 24 |
} |
| 25 |
|
| 26 |
if (0 == iface->outstanding) { |
| 27 |
UCT_TL_IFACE_STAT_FLUSH(ucs_derived_of(tl_iface, uct_base_iface_t)); |
| 28 |
return UCS_OK; |
| 29 |
} |
| 30 |
|
| 31 |
UCT_TL_IFACE_STAT_FLUSH_WAIT(ucs_derived_of(tl_iface, uct_base_iface_t)); |
| 32 |
return UCS_INPROGRESS; |
| 33 |
} |
| 34 |
|
| 35 |
ucs_status_t uct_ugni_iface_get_address(uct_iface_h tl_iface, |
| 36 |
uct_iface_addr_t *addr) |
| 37 |
{ |
| 38 |
uct_ugni_iface_t *iface = ucs_derived_of(tl_iface, uct_ugni_iface_t); |
| 39 |
uct_sockaddr_ugni_t *iface_addr = (uct_sockaddr_ugni_t*)addr; |
| 40 |
|
| 41 |
iface_addr->domain_id = iface->cdm.domain_id; |
| 42 |
return UCS_OK; |
| 43 |
} |
| 44 |
|
| 45 |
int uct_ugni_iface_is_reachable(uct_iface_h tl_iface, const uct_device_addr_t *dev_addr, const uct_iface_addr_t *iface_addr) |
| 46 |
{ |
| 47 |
return 1; |
| 48 |
} |
| 49 |
|
| 50 |
int uct_ugni_iface_is_reachable_v2(const uct_iface_h tl_iface, |
| 51 |
const uct_iface_is_reachable_params_t *params) |
| 52 |
{ |
| 53 |
return uct_iface_is_reachable_params_valid( |
| 54 |
params, UCT_IFACE_IS_REACHABLE_FIELD_DEVICE_ADDR) && |
| 55 |
uct_iface_scope_is_reachable(tl_iface, params); |
| 56 |
} |
| 57 |
|
| 58 |
static ucs_mpool_ops_t uct_ugni_flush_mpool_ops = { |
| 59 |
.chunk_alloc = ucs_mpool_chunk_malloc, |
| 60 |
.chunk_release = ucs_mpool_chunk_free, |
| 61 |
.obj_init = NULL, |
| 62 |
.obj_cleanup = NULL, |
| 63 |
.obj_str = NULL |
| 64 |
}; |
| 65 |
|
| 66 |
void uct_ugni_cleanup_base_iface(uct_ugni_iface_t *iface) |
| 67 |
{ |
| 68 |
ucs_arbiter_cleanup(&iface->arbiter); |
| 69 |
ucs_mpool_cleanup(&iface->flush_pool, 1); |
| 70 |
uct_ugni_destroy_cq(iface->local_cq, &iface->cdm); |
| 71 |
uct_ugni_destroy_cdm(&iface->cdm); |
| 72 |
} |
| 73 |
|
| 74 |
UCS_CLASS_INIT_FUNC(uct_ugni_iface_t, uct_md_h md, uct_worker_h worker, |
| 75 |
const uct_iface_params_t *params, |
| 76 |
uct_iface_ops_t *uct_ugni_iface_ops, |
| 77 |
uct_iface_internal_ops_t *internal_ops, |
| 78 |
const uct_iface_config_t *tl_config |
| 79 |
UCS_STATS_ARG(ucs_stats_node_t *stats_parent)) |
| 80 |
{ |
| 81 |
uct_ugni_device_t *dev; |
| 82 |
ucs_status_t status; |
| 83 |
ucs_mpool_params_t mp_params; |
| 84 |
uct_ugni_iface_config_t *config = ucs_derived_of(tl_config, uct_ugni_iface_config_t); |
| 85 |
unsigned grow = (config->mpool.bufs_grow == 0) ? 128 : config->mpool.bufs_grow; |
| 86 |
|
| 87 |
ucs_assert(params->open_mode & UCT_IFACE_OPEN_MODE_DEVICE); |
| 88 |
|
| 89 |
UCS_CLASS_CALL_SUPER_INIT(uct_base_iface_t, uct_ugni_iface_ops, |
| 90 |
internal_ops, md, worker, params, |
| 91 |
tl_config UCS_STATS_ARG(params->stats_root) |
| 92 |
UCS_STATS_ARG(UCT_UGNI_MD_NAME)); |
| 93 |
dev = uct_ugni_device_by_name(params->mode.device.dev_name); |
| 94 |
if (NULL == dev) { |
| 95 |
ucs_error("No device was found: %s", params->mode.device.dev_name); |
| 96 |
return UCS_ERR_NO_DEVICE; |
| 97 |
} |
| 98 |
status = uct_ugni_create_cdm(&self->cdm, dev, self->super.worker->thread_mode); |
| 99 |
if (UCS_OK != status) { |
| 100 |
ucs_error("Failed to UGNI NIC, Error status: %d", status); |
| 101 |
return status; |
| 102 |
} |
| 103 |
status = uct_ugni_create_cq(&self->local_cq, UCT_UGNI_LOCAL_CQ, &self->cdm); |
| 104 |
if (UCS_OK != status) { |
| 105 |
goto clean_cdm; |
| 106 |
} |
| 107 |
self->outstanding = 0; |
| 108 |
sglib_hashed_uct_ugni_ep_t_init(self->eps); |
| 109 |
ucs_arbiter_init(&self->arbiter); |
| 110 |
|
| 111 |
ucs_mpool_params_reset(&mp_params); |
| 112 |
uct_iface_mpool_config_copy(&mp_params, &config->mpool); |
| 113 |
mp_params.elem_size = sizeof(uct_ugni_flush_group_t); |
| 114 |
mp_params.elems_per_chunk = grow; |
| 115 |
mp_params.ops = &uct_ugni_flush_mpool_ops; |
| 116 |
mp_params.name = "UGNI-DESC-ONLY"; |
| 117 |
status = ucs_mpool_init(&mp_params, &self->flush_pool); |
| 118 |
if (UCS_OK != status) { |
| 119 |
ucs_error("Could not init iface"); |
| 120 |
goto clean_cq; |
| 121 |
} |
| 122 |
return status; |
| 123 |
clean_cq: |
| 124 |
uct_ugni_destroy_cq(self->local_cq, &self->cdm); |
| 125 |
clean_cdm: |
| 126 |
uct_ugni_destroy_cdm(&self->cdm); |
| 127 |
return status; |
| 128 |
} |
| 129 |
|
| 130 |
UCS_CLASS_DEFINE_NEW_FUNC(uct_ugni_iface_t, uct_iface_t, uct_md_h, uct_worker_h, |
| 131 |
const uct_iface_params_t*, uct_iface_ops_t*, |
| 132 |
uct_iface_internal_ops_t*, |
| 133 |
const uct_iface_config_t * UCS_STATS_ARG(ucs_stats_node_t *)); |
| 134 |
|
| 135 |
static UCS_CLASS_CLEANUP_FUNC(uct_ugni_iface_t) |
| 136 |
{ |
| 137 |
uct_ugni_cleanup_base_iface(self); |
| 138 |
} |
| 139 |
|
| 140 |
UCS_CLASS_DEFINE(uct_ugni_iface_t, uct_base_iface_t); |