Skip to content

Commit 6a15883

Browse files
committed
osc/rdma: Wrap calls to BTL RDMA functiions
Add wrappers to call all BTL RDMA functions. This commit just adds another layer of indirection to the communication calls. However, a follow-on patch will add logic to either call the BTL RDMA functions directly (for accelerated mode) or call the BTL AM RDMA compatibility layer for alternate mode. Signed-off-by: Brian Barrett <bbarrett@amazon.com>
1 parent 0394543 commit 6a15883

File tree

3 files changed

+111
-23
lines changed

3 files changed

+111
-23
lines changed

ompi/mca/osc/rdma/osc_rdma_accumulate.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,9 +762,10 @@ static inline int cas_rdma (ompi_osc_rdma_sync_t *sync, const void *source_addr,
762762
OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "RDMA compare-and-swap initiating blocking btl put...");
763763

764764
do {
765-
ret = btl->btl_put (btl, peer->data_endpoint, ptr, target_address,
766-
local_handle, target_handle, len, 0, MCA_BTL_NO_ORDER,
767-
ompi_osc_rdma_cas_put_complete, (void *) &complete, NULL);
765+
ret = ompi_osc_rdma_btl_put(module, peer->data_btl_index, peer->data_endpoint,
766+
ptr, target_address, local_handle, target_handle,
767+
len, 0, MCA_BTL_NO_ORDER,
768+
ompi_osc_rdma_cas_put_complete, (void *) &complete, NULL);
768769
if (OPAL_SUCCESS == ret || (OPAL_ERR_OUT_OF_RESOURCE != ret && OPAL_ERR_TEMP_OUT_OF_RESOURCE != ret)) {
769770
break;
770771
}

ompi/mca/osc/rdma/osc_rdma_btl_comm.h

Lines changed: 96 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,94 @@ void ompi_osc_rdma_atomic_complete(mca_btl_base_module_t *btl, struct mca_btl_ba
2626
void *context, void *data, int status);
2727

2828

29+
static inline int
30+
ompi_osc_rdma_btl_put(ompi_osc_rdma_module_t *module, uint8_t btl_index,
31+
struct mca_btl_base_endpoint_t *endpoint,
32+
void *local_address, uint64_t remote_address,
33+
struct mca_btl_base_registration_handle_t *local_handle,
34+
struct mca_btl_base_registration_handle_t *remote_handle,
35+
size_t size, int flags, int order,
36+
mca_btl_base_rdma_completion_fn_t cbfunc,
37+
void *cbcontext, void *cbdata)
38+
{
39+
mca_btl_base_module_t *btl = ompi_osc_rdma_selected_btl(module, btl_index);
40+
41+
return btl->btl_put(btl, endpoint, local_address, remote_address,
42+
local_handle, remote_handle, size, flags, order,
43+
cbfunc, cbcontext, cbdata);
44+
}
45+
46+
47+
static inline int
48+
ompi_osc_rdma_btl_get(ompi_osc_rdma_module_t *module, uint8_t btl_index,
49+
struct mca_btl_base_endpoint_t *endpoint,
50+
void *local_address, uint64_t remote_address,
51+
struct mca_btl_base_registration_handle_t *local_handle,
52+
struct mca_btl_base_registration_handle_t *remote_handle,
53+
size_t size, int flags, int order,
54+
mca_btl_base_rdma_completion_fn_t cbfunc,
55+
void *cbcontext, void *cbdata)
56+
{
57+
mca_btl_base_module_t *btl = ompi_osc_rdma_selected_btl(module, btl_index);
58+
59+
return btl->btl_get(btl, endpoint, local_address, remote_address,
60+
local_handle, remote_handle, size, flags, order,
61+
cbfunc, cbcontext, cbdata);
62+
}
63+
64+
65+
static inline int
66+
ompi_osc_rdma_btl_atomic_op(ompi_osc_rdma_module_t *module, uint8_t btl_index,
67+
struct mca_btl_base_endpoint_t *endpoint,
68+
uint64_t remote_address, struct mca_btl_base_registration_handle_t *remote_handle,
69+
mca_btl_base_atomic_op_t op, uint64_t operand, int flags, int order,
70+
mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext, void *cbdata)
71+
{
72+
mca_btl_base_module_t *btl = ompi_osc_rdma_selected_btl(module, btl_index);
73+
74+
return btl->btl_atomic_op(btl, endpoint, remote_address, remote_handle,
75+
op, operand, flags, order,
76+
cbfunc, cbcontext, cbdata);
77+
}
78+
79+
80+
static inline int
81+
ompi_osc_rdma_btl_atomic_fop(ompi_osc_rdma_module_t *module, uint8_t btl_index,
82+
struct mca_btl_base_endpoint_t *endpoint,
83+
void *local_address, uint64_t remote_address,
84+
struct mca_btl_base_registration_handle_t *local_handle,
85+
struct mca_btl_base_registration_handle_t *remote_handle,
86+
mca_btl_base_atomic_op_t op, uint64_t operand, int flags, int order,
87+
mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext, void *cbdata)
88+
89+
{
90+
mca_btl_base_module_t *btl = ompi_osc_rdma_selected_btl(module, btl_index);
91+
92+
return btl->btl_atomic_fop(btl, endpoint, local_address, remote_address,
93+
local_handle, remote_handle,
94+
op, operand, flags, order,
95+
cbfunc, cbcontext, cbdata);
96+
}
97+
98+
99+
static inline int
100+
ompi_osc_rdma_btl_atomic_cswap(ompi_osc_rdma_module_t *module, uint8_t btl_index,
101+
struct mca_btl_base_endpoint_t *endpoint,
102+
void *local_address, uint64_t remote_address,
103+
struct mca_btl_base_registration_handle_t *local_handle,
104+
struct mca_btl_base_registration_handle_t *remote_handle,
105+
uint64_t compare, uint64_t value, int flags, int order,
106+
mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext, void *cbdata)
107+
{
108+
mca_btl_base_module_t *btl = ompi_osc_rdma_selected_btl(module, btl_index);
109+
110+
return btl->btl_atomic_cswap(btl, endpoint, local_address, remote_address,
111+
local_handle, remote_handle,
112+
compare, value, flags, order,
113+
cbfunc, cbcontext, cbdata);
114+
}
115+
116+
29117
static inline int
30118
ompi_osc_rdma_btl_fop(ompi_osc_rdma_module_t *module, uint8_t btl_index,
31119
struct mca_btl_base_endpoint_t *endpoint, uint64_t address,
@@ -62,10 +150,10 @@ ompi_osc_rdma_btl_fop(ompi_osc_rdma_module_t *module, uint8_t btl_index,
62150
}
63151

64152
if (NULL != pending_op->op_frag) {
65-
ret = selected_btl->btl_atomic_fop (selected_btl, endpoint, pending_op->op_buffer,
66-
(intptr_t) address, pending_op->op_frag->handle, address_handle,
67-
op, operand, flags, MCA_BTL_NO_ORDER, ompi_osc_rdma_atomic_complete,
68-
(void *) pending_op, NULL);
153+
ret = ompi_osc_rdma_btl_atomic_fop(module, btl_index, endpoint, pending_op->op_buffer,
154+
(intptr_t) address, pending_op->op_frag->handle, address_handle,
155+
op, operand, flags, MCA_BTL_NO_ORDER, ompi_osc_rdma_atomic_complete,
156+
(void *) pending_op, NULL);
69157
}
70158

71159
if (OPAL_LIKELY(!ompi_osc_rdma_oor(ret))) {
@@ -129,9 +217,9 @@ ompi_osc_rdma_btl_op(ompi_osc_rdma_module_t *module, uint8_t btl_index,
129217

130218
/* spin until the btl has accepted the operation */
131219
do {
132-
ret = selected_btl->btl_atomic_op (selected_btl, endpoint, (intptr_t) address, address_handle,
133-
op, operand, flags, MCA_BTL_NO_ORDER, ompi_osc_rdma_atomic_complete,
134-
(void *) pending_op, NULL);
220+
ret = ompi_osc_rdma_btl_atomic_op(module, btl_index, endpoint, (intptr_t) address, address_handle,
221+
op, operand, flags, MCA_BTL_NO_ORDER, ompi_osc_rdma_atomic_complete,
222+
(void *) pending_op, NULL);
135223

136224
if (OPAL_LIKELY(!ompi_osc_rdma_oor(ret))) {
137225
break;
@@ -167,7 +255,6 @@ ompi_osc_rdma_btl_cswap(ompi_osc_rdma_module_t *module, uint8_t btl_index,
167255
int64_t compare, int64_t value, int flags, int64_t *result)
168256
{
169257
ompi_osc_rdma_pending_op_t *pending_op;
170-
mca_btl_base_module_t *selected_btl = ompi_osc_rdma_selected_btl (module, btl_index);
171258
int ret;
172259

173260
pending_op = OBJ_NEW(ompi_osc_rdma_pending_op_t);
@@ -184,7 +271,7 @@ ompi_osc_rdma_btl_cswap(ompi_osc_rdma_module_t *module, uint8_t btl_index,
184271
ret = ompi_osc_rdma_frag_alloc (module, 8, &pending_op->op_frag, (char **) &pending_op->op_buffer);
185272
}
186273
if (NULL != pending_op->op_frag) {
187-
ret = selected_btl->btl_atomic_cswap (selected_btl, endpoint, pending_op->op_buffer,
274+
ret = ompi_osc_rdma_btl_atomic_cswap(module, btl_index, endpoint, pending_op->op_buffer,
188275
address, pending_op->op_frag->handle, address_handle, compare,
189276
value, flags, 0, ompi_osc_rdma_atomic_complete, (void *) pending_op,
190277
NULL);

ompi/mca/osc/rdma/osc_rdma_comm.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "osc_rdma_sync.h"
2121
#include "osc_rdma_request.h"
2222
#include "osc_rdma_dynamic.h"
23+
#include "osc_rdma_btl_comm.h"
2324

2425
#include "ompi/mca/osc/base/osc_base_obj_convert.h"
2526
#include "opal/align.h"
@@ -99,9 +100,9 @@ int ompi_osc_get_data_blocking (ompi_osc_rdma_module_t *module, uint8_t btl_inde
99100
assert (!(source_address & ALIGNMENT_MASK(btl->btl_get_alignment)));
100101

101102
do {
102-
ret = btl->btl_get (btl, endpoint, ptr, aligned_addr,
103-
local_handle, source_handle, aligned_len, 0, MCA_BTL_NO_ORDER,
104-
ompi_osc_get_data_complete, (void *) &read_complete, NULL);
103+
ret = ompi_osc_rdma_btl_get(module, btl_index, endpoint, ptr, aligned_addr,
104+
local_handle, source_handle, aligned_len, 0, MCA_BTL_NO_ORDER,
105+
ompi_osc_get_data_complete, (void *) &read_complete, NULL);
105106
if (!ompi_osc_rdma_oor (ret)) {
106107
break;
107108
}
@@ -447,7 +448,6 @@ static int ompi_osc_rdma_put_real (ompi_osc_rdma_sync_t *sync, ompi_osc_rdma_pee
447448
mca_btl_base_registration_handle_t *local_handle, size_t size,
448449
mca_btl_base_rdma_completion_fn_t cb, void *context, void *cbdata) {
449450
ompi_osc_rdma_module_t *module = sync->module;
450-
mca_btl_base_module_t *btl = ompi_osc_rdma_selected_btl (module, peer->data_btl_index);
451451
int ret;
452452

453453
OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "initiating btl put of %lu bytes to remote address %" PRIx64 ", sync "
@@ -457,9 +457,9 @@ static int ompi_osc_rdma_put_real (ompi_osc_rdma_sync_t *sync, ompi_osc_rdma_pee
457457
ompi_osc_rdma_sync_rdma_inc (sync);
458458

459459
do {
460-
ret = btl->btl_put (btl, peer->data_endpoint, ptr, target_address,
461-
local_handle, target_handle, size, 0, MCA_BTL_NO_ORDER,
462-
cb, context, cbdata);
460+
ret = ompi_osc_rdma_btl_put(module, peer->data_btl_index, peer->data_endpoint,
461+
ptr, target_address, local_handle, target_handle,
462+
size, 0, MCA_BTL_NO_ORDER, cb, context, cbdata);
463463
if (OPAL_UNLIKELY(OMPI_SUCCESS == ret)) {
464464
return OMPI_SUCCESS;
465465
}
@@ -706,10 +706,10 @@ static int ompi_osc_rdma_get_contig (ompi_osc_rdma_sync_t *sync, ompi_osc_rdma_p
706706
}
707707

708708
do {
709-
ret = btl->btl_get (btl, peer->data_endpoint, ptr,
710-
aligned_source_base, local_handle, source_handle,
711-
aligned_len, 0, MCA_BTL_NO_ORDER, ompi_osc_rdma_get_complete,
712-
request, frag);
709+
ret = ompi_osc_rdma_btl_get(module, peer->data_btl_index, peer->data_endpoint,
710+
ptr, aligned_source_base, local_handle, source_handle,
711+
aligned_len, 0, MCA_BTL_NO_ORDER,
712+
ompi_osc_rdma_get_complete, request, frag);
713713
if (OPAL_LIKELY(OMPI_SUCCESS == ret)) {
714714
return OMPI_SUCCESS;
715715
}

0 commit comments

Comments
 (0)