Skip to content

Commit 6c08951

Browse files
committed
btl/uct: make uct endpoints array a flexible array member
Signed-off-by: Nathan Hjelm <[email protected]>
1 parent c5c5b42 commit 6c08951

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

opal/mca/btl/uct/btl_uct_endpoint.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,21 @@
1717

1818
static void mca_btl_uct_endpoint_construct (mca_btl_uct_endpoint_t *endpoint)
1919
{
20-
memset (endpoint->uct_eps, 0, sizeof (endpoint->uct_eps));
20+
memset (endpoint->uct_eps, 0, sizeof (endpoint->uct_eps[0]) * mca_btl_uct_component.num_contexts_per_module);
2121
endpoint->conn_ep = NULL;
2222
OBJ_CONSTRUCT(&endpoint->ep_lock, opal_recursive_mutex_t);
2323
}
2424

2525
static void mca_btl_uct_endpoint_destruct (mca_btl_uct_endpoint_t *endpoint)
2626
{
2727
for (int tl_index = 0 ; tl_index < 2 ; ++tl_index) {
28-
for (int i = 0 ; i < MCA_BTL_UCT_MAX_WORKERS ; ++i) {
29-
if (NULL != endpoint->uct_eps[tl_index][i].uct_ep) {
30-
uct_ep_destroy (endpoint->uct_eps[tl_index][i].uct_ep);
28+
for (int i = 0 ; i < mca_btl_uct_component.num_contexts_per_module ; ++i) {
29+
if (NULL != endpoint->uct_eps[i][tl_index].uct_ep) {
30+
uct_ep_destroy (endpoint->uct_eps[i][tl_index].uct_ep);
3131
}
3232
}
3333
}
3434

35-
memset (endpoint->uct_eps, 0, sizeof (endpoint->uct_eps));
36-
3735
OBJ_DESTRUCT(&endpoint->ep_lock);
3836
}
3937

@@ -43,12 +41,14 @@ OBJ_CLASS_INSTANCE(mca_btl_uct_endpoint_t, opal_object_t,
4341

4442
mca_btl_base_endpoint_t *mca_btl_uct_endpoint_create (opal_proc_t *proc)
4543
{
46-
mca_btl_uct_endpoint_t *endpoint = OBJ_NEW(mca_btl_uct_endpoint_t);
44+
mca_btl_uct_endpoint_t *endpoint = calloc (1, sizeof (*endpoint) + sizeof (endpoint->uct_eps[0]) *
45+
mca_btl_uct_component.num_contexts_per_module);
4746

4847
if (OPAL_UNLIKELY(NULL == endpoint)) {
4948
return NULL;
5049
}
5150

51+
OBJ_CONSTRUCT(endpoint, mca_btl_uct_endpoint_t);
5252
endpoint->ep_proc = proc;
5353

5454
return (mca_btl_base_endpoint_t *) endpoint;
@@ -295,7 +295,7 @@ static int mca_btl_uct_endpoint_connect_endpoint (mca_btl_uct_module_t *uct_btl,
295295
int mca_btl_uct_endpoint_connect (mca_btl_uct_module_t *uct_btl, mca_btl_uct_endpoint_t *endpoint, int context_id,
296296
void *ep_addr, int tl_index)
297297
{
298-
mca_btl_uct_tl_endpoint_t *tl_endpoint = endpoint->uct_eps[tl_index] + context_id;
298+
mca_btl_uct_tl_endpoint_t *tl_endpoint = endpoint->uct_eps[context_id] + tl_index;
299299
mca_btl_uct_device_context_t *tl_context = mca_btl_uct_module_get_rdma_context_specific (uct_btl, context_id);
300300
mca_btl_uct_tl_t *tl = (tl_index == uct_btl->rdma_tl->tl_index) ? uct_btl->rdma_tl : uct_btl->am_tl;
301301
uint8_t *rdma_tl_data = NULL, *conn_tl_data = NULL, *am_tl_data = NULL, *tl_data;

opal/mca/btl/uct/btl_uct_endpoint.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ static int mca_btl_uct_endpoint_test_am (mca_btl_uct_module_t *module, mca_btl_u
3737
int tl_index = module->am_tl->tl_index;
3838
int ep_index = context->context_id;
3939

40-
if (OPAL_LIKELY(MCA_BTL_UCT_ENDPOINT_FLAG_CONN_READY & endpoint->uct_eps[tl_index][ep_index].flags)) {
41-
*ep_handle = endpoint->uct_eps[tl_index][ep_index].uct_ep;
40+
if (OPAL_LIKELY(MCA_BTL_UCT_ENDPOINT_FLAG_CONN_READY & endpoint->uct_eps[ep_index][tl_index].flags)) {
41+
*ep_handle = endpoint->uct_eps[ep_index][tl_index].uct_ep;
4242
return OPAL_SUCCESS;
4343
}
4444

@@ -65,13 +65,13 @@ static inline int mca_btl_uct_endpoint_check (mca_btl_uct_module_t *module, mca_
6565
int ep_index = context->context_id;
6666
int rc;
6767

68-
if (OPAL_LIKELY(MCA_BTL_UCT_ENDPOINT_FLAG_CONN_READY & endpoint->uct_eps[tl_index][ep_index].flags)) {
69-
*ep_handle = endpoint->uct_eps[tl_index][ep_index].uct_ep;
68+
if (OPAL_LIKELY(MCA_BTL_UCT_ENDPOINT_FLAG_CONN_READY & endpoint->uct_eps[ep_index][tl_index].flags)) {
69+
*ep_handle = endpoint->uct_eps[ep_index][tl_index].uct_ep;
7070
return OPAL_SUCCESS;
7171
}
7272

7373
rc = mca_btl_uct_endpoint_connect (module, endpoint, ep_index, NULL, tl_index);
74-
*ep_handle = endpoint->uct_eps[tl_index][ep_index].uct_ep;
74+
*ep_handle = endpoint->uct_eps[ep_index][tl_index].uct_ep;
7575
BTL_VERBOSE(("mca_btl_uct_endpoint_connect returned %d", rc));
7676
return rc;
7777
}

opal/mca/btl/uct/btl_uct_rdma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ int mca_btl_uct_flush (mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endp
243243
do {
244244
uct_worker_progress (context->uct_worker);
245245

246-
if (NULL != endpoint && endpoint->uct_eps[tl_index][context->context_id].uct_ep) {
247-
ucs_status = uct_ep_flush (endpoint->uct_eps[tl_index][context->context_id].uct_ep, 0, NULL);
246+
if (NULL != endpoint && endpoint->uct_eps[context->context_id][tl_index].uct_ep) {
247+
ucs_status = uct_ep_flush (endpoint->uct_eps[context->context_id][tl_index].uct_ep, 0, NULL);
248248
} else {
249249
ucs_status = uct_iface_flush (context->uct_iface, 0, NULL);
250250
}

opal/mca/btl/uct/btl_uct_tl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static ucs_status_t mca_btl_uct_conn_req_cb (void *arg, void *data, size_t lengt
165165
mca_btl_uct_conn_req_t *req = (mca_btl_uct_conn_req_t *) ((uintptr_t) data + 8);
166166
struct opal_proc_t *remote_proc = opal_proc_for_name (req->proc_name);
167167
mca_btl_base_endpoint_t *endpoint = mca_btl_uct_get_ep (&module->super, remote_proc);
168-
mca_btl_uct_tl_endpoint_t *tl_endpoint = endpoint->uct_eps[req->tl_index] + req->context_id;
168+
mca_btl_uct_tl_endpoint_t *tl_endpoint = endpoint->uct_eps[req->context_id] + req->tl_index;
169169
int64_t type = *((int64_t *) data);
170170
int32_t ep_flags;
171171
int rc;

opal/mca/btl/uct/btl_uct_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ struct mca_btl_base_endpoint_t {
269269
mca_btl_uct_connection_ep_t *conn_ep;
270270

271271
/** endpoints into UCT for this BTL endpoint */
272-
mca_btl_uct_tl_endpoint_t uct_eps[2][MCA_BTL_UCT_MAX_WORKERS];
272+
mca_btl_uct_tl_endpoint_t uct_eps[][2];
273273
};
274274

275275
typedef struct mca_btl_base_endpoint_t mca_btl_base_endpoint_t;

0 commit comments

Comments
 (0)