Skip to content

Commit 5fb0d62

Browse files
committed
btl/uct: change mca_btl_uct_tl_t uct_dev_contexts member to be an array
The btl always allocates the maximum number of contexts. This is not a significant amount of memory. Rather than reduce it to be based on the configured maximum number of contexts it makes sense to just make it an array and remove the extra indirection when accessing the contexts.
1 parent a0f60ae commit 5fb0d62

File tree

3 files changed

+13
-29
lines changed

3 files changed

+13
-29
lines changed

opal/mca/btl/uct/btl_uct_component.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,11 @@ static size_t mca_btl_uct_module_modex_size(mca_btl_uct_module_t *module)
275275
return modex_size;
276276
}
277277

278-
static size_t mca_btl_uct_tl_modex_pack(mca_btl_uct_tl_t *tl, uint8_t *modex_data)
278+
static size_t mca_btl_uct_tl_modex_pack(mca_btl_uct_module_t *module, mca_btl_uct_tl_t *tl,
279+
uint8_t *modex_data)
279280
{
280-
mca_btl_uct_device_context_t *dev_context = tl->uct_dev_contexts[0];
281+
mca_btl_uct_device_context_t *dev_context =
282+
mca_btl_uct_module_get_tl_context_specific(module, tl, /*context_id=*/0);
281283
size_t modex_size = mca_btl_uct_tl_modex_size(tl);
282284

283285
*((uint32_t *) modex_data) = (uint32_t) modex_size;
@@ -316,16 +318,16 @@ static uint8_t *mca_btl_uct_modex_pack(mca_btl_uct_module_t *module, uint8_t *mo
316318
modex_data += name_len + 1;
317319

318320
if (module->rdma_tl) {
319-
modex_data += mca_btl_uct_tl_modex_pack(module->rdma_tl, modex_data);
321+
modex_data += mca_btl_uct_tl_modex_pack(module, module->rdma_tl, modex_data);
320322
}
321323

322324
if (module->am_tl && module->am_tl != module->rdma_tl) {
323-
modex_data += mca_btl_uct_tl_modex_pack(module->am_tl, modex_data);
325+
modex_data += mca_btl_uct_tl_modex_pack(module, module->am_tl, modex_data);
324326
}
325327

326328
if (module->conn_tl && module->conn_tl != module->rdma_tl
327329
&& module->conn_tl != module->am_tl) {
328-
modex_data += mca_btl_uct_tl_modex_pack(module->conn_tl, modex_data);
330+
modex_data += mca_btl_uct_tl_modex_pack(module, module->conn_tl, modex_data);
329331
}
330332

331333
return modex_data;

opal/mca/btl/uct/btl_uct_tl.c

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ static void mca_btl_uct_tl_destructor(mca_btl_uct_tl_t *tl)
160160
OBJ_RELEASE(tl->uct_md);
161161
}
162162

163-
free(tl->uct_dev_contexts);
164163
free(tl->uct_tl_name);
165164
free(tl->uct_dev_name);
166165

@@ -246,7 +245,10 @@ static int mca_btl_uct_setup_connection_tl(mca_btl_uct_module_t *module)
246245
return OPAL_ERR_NOT_SUPPORTED;
247246
}
248247

249-
ucs_status = uct_iface_set_am_handler(module->conn_tl->uct_dev_contexts[0]->uct_iface,
248+
mca_btl_uct_device_context_t *context = mca_btl_uct_module_get_tl_context_specific(module, module->conn_tl,
249+
/*context_id=*/0);
250+
251+
ucs_status = uct_iface_set_am_handler(context->uct_iface,
250252
MCA_BTL_UCT_CONNECT_RDMA, mca_btl_uct_conn_req_cb, module,
251253
UCT_CB_FLAG_ASYNC);
252254
if (UCS_OK != ucs_status) {
@@ -377,7 +379,7 @@ mca_btl_uct_device_context_t *mca_btl_uct_context_create(mca_btl_uct_module_t *m
377379
return NULL;
378380
}
379381

380-
if (context_id > 0 && tl == module->am_tl) {
382+
if (tl == module->am_tl) {
381383
BTL_VERBOSE(("installing AM handler for tl %p context id %d", (void *) tl, context_id));
382384
uct_iface_set_am_handler(context->uct_iface, MCA_BTL_UCT_FRAG, mca_btl_uct_am_handler,
383385
context, MCA_BTL_UCT_CB_FLAG_SYNC);
@@ -433,12 +435,6 @@ static mca_btl_uct_tl_t *mca_btl_uct_create_tl(mca_btl_uct_module_t *module, mca
433435
tl->uct_dev_name = strdup(tl_desc->dev_name);
434436
tl->priority = priority;
435437

436-
tl->uct_dev_contexts = calloc(MCA_BTL_UCT_MAX_WORKERS, sizeof(tl->uct_dev_contexts[0]));
437-
if (NULL == tl->uct_dev_contexts) {
438-
OBJ_RELEASE(tl);
439-
return NULL;
440-
}
441-
442438
(void) uct_md_iface_config_read(md->uct_md, tl_desc->tl_name, NULL, NULL, &tl->uct_tl_config);
443439

444440
int rc = mca_btl_uct_populate_tl_attr(module, tl);
@@ -491,16 +487,9 @@ static void mca_btl_uct_set_tl_rdma(mca_btl_uct_module_t *module, mca_btl_uct_tl
491487
static void mca_btl_uct_set_tl_am(mca_btl_uct_module_t *module, mca_btl_uct_tl_t *tl)
492488
{
493489
BTL_VERBOSE(("tl %s is suitable for active-messaging", tl->uct_tl_name));
494-
495-
if (module->rdma_tl == tl) {
496-
module->shared_endpoints = true;
497-
}
498490
module->am_tl = tl;
499491
OBJ_RETAIN(tl);
500492

501-
uct_iface_set_am_handler(tl->uct_dev_contexts[0]->uct_iface, MCA_BTL_UCT_FRAG,
502-
mca_btl_uct_am_handler, tl->uct_dev_contexts[0], UCT_CB_FLAG_ASYNC);
503-
504493
tl->tl_index = (module->rdma_tl && tl != module->rdma_tl) ? 1 : 0;
505494
module->comm_tls[tl->tl_index] = tl;
506495
if (tl->max_device_contexts <= 1) {
@@ -580,12 +569,6 @@ static int mca_btl_uct_evaluate_tl(mca_btl_uct_module_t *module, mca_btl_uct_tl_
580569
module->super.btl_latency = 1;
581570
}
582571

583-
if (tl == module->rdma_tl || tl == module->am_tl || tl == module->conn_tl) {
584-
/* make sure progress is enabled on the default context now that we know this TL will be
585-
* used */
586-
mca_btl_uct_context_enable_progress(tl->uct_dev_contexts[0]);
587-
}
588-
589572
return OPAL_SUCCESS;
590573
}
591574

@@ -629,7 +612,6 @@ int mca_btl_uct_query_tls(mca_btl_uct_module_t *module, mca_btl_uct_md_t *md,
629612
OBJ_RELEASE(tl);
630613

631614
if (OPAL_SUCCESS == rc) {
632-
mca_btl_uct_context_enable_progress(tl->uct_dev_contexts[0]);
633615
return OPAL_SUCCESS;
634616
}
635617

opal/mca/btl/uct/btl_uct_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ struct mca_btl_uct_tl_t {
327327
int max_device_contexts;
328328

329329
/** array of device contexts */
330-
mca_btl_uct_device_context_t **uct_dev_contexts;
330+
mca_btl_uct_device_context_t *uct_dev_contexts[MCA_BTL_UCT_MAX_WORKERS];
331331

332332
/** tl index. this is used to differentiate (if there is any difference)
333333
* between rdma and am endpoints */

0 commit comments

Comments
 (0)