Skip to content

Commit

Permalink
prov/shm: refactor progress functions into function pointers
Browse files Browse the repository at this point in the history
Just like on the send side, make the progress functions be an array
of function pointers accessible by the command proto.
This cleans up the parameters of the progress calls and streamlines the
calls

This also renames the proto_ops to send_ops to make the two more clear

Signed-off-by: Alexia Ingerson <alexia.ingerson@intel.com>
  • Loading branch information
aingerson committed Dec 31, 2024
1 parent b3126ef commit c44dff8
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 195 deletions.
10 changes: 8 additions & 2 deletions prov/shm/src/smr.h
Original file line number Diff line number Diff line change
Expand Up @@ -587,13 +587,13 @@ size_t smr_copy_from_sar(struct smr_ep *ep, struct smr_freestack *sar_pool,
int smr_select_proto(void **desc, size_t iov_count, bool cma_avail,
bool ipc_valid, uint32_t op, uint64_t total_len,
uint64_t op_flags);
typedef ssize_t (*smr_proto_func)(
typedef ssize_t (*smr_send_func)(
struct smr_ep *ep, struct smr_region *peer_smr,
int64_t id, int64_t peer_id, uint32_t op, uint64_t tag,
uint64_t data, uint64_t op_flags, struct ofi_mr **desc,
const struct iovec *iov, size_t iov_count, size_t total_len,
void *context, struct smr_cmd *cmd);
extern smr_proto_func smr_proto_ops[smr_proto_max];
extern smr_send_func smr_send_ops[smr_proto_max];

int smr_write_err_comp(struct util_cq *cq, void *context,
uint64_t flags, uint64_t tag, int err);
Expand All @@ -603,6 +603,12 @@ int smr_complete_rx(struct smr_ep *ep, void *context, uint32_t op,
uint64_t flags, size_t len, void *buf, int64_t id,
uint64_t tag, uint64_t data);

typedef ssize_t (*smr_progress_func)(
struct smr_ep *ep, struct smr_cmd *cmd,
struct fi_peer_rx_entry *rx_entry, struct ofi_mr **mr,
struct iovec *iov, size_t iov_count);
extern smr_progress_func smr_progress_ops[smr_proto_max];

static inline uint64_t smr_rx_cq_flags(uint64_t rx_flags, uint16_t op_flags)
{
if (op_flags & SMR_REMOTE_CQ_DATA)
Expand Down
4 changes: 2 additions & 2 deletions prov/shm/src/smr_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ int smr_write_err_comp(struct util_cq *cq, void *context,
err_entry.op_context = context;
err_entry.flags = flags;
err_entry.tag = tag;
err_entry.err = err;
err_entry.prov_errno = -err;
err_entry.err = -err;
err_entry.prov_errno = err;
return ofi_peer_cq_write_error(cq, &err_entry);
}

Expand Down
2 changes: 1 addition & 1 deletion prov/shm/src/smr_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ static ssize_t smr_do_ipc(struct smr_ep *ep, struct smr_region *peer_smr,
return FI_SUCCESS;
}

smr_proto_func smr_proto_ops[smr_proto_max] = {
smr_send_func smr_send_ops[smr_proto_max] = {
[smr_proto_inline] = &smr_do_inline,
[smr_proto_inject] = &smr_do_inject,
[smr_proto_iov] = &smr_do_iov,
Expand Down
10 changes: 5 additions & 5 deletions prov/shm/src/smr_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ static ssize_t smr_generic_sendmsg(struct smr_ep *ep, const struct iovec *iov,
ce->ptr = smr_peer_to_peer(ep, id, (uintptr_t) &ce->cmd);
}

ret = smr_proto_ops[proto](ep, peer_smr, id, peer_id, op, tag, data,
op_flags, (struct ofi_mr **) desc, iov,
iov_count, total_len, context, cmd);
ret = smr_send_ops[proto](ep, peer_smr, id, peer_id, op, tag, data,
op_flags, (struct ofi_mr **) desc, iov,
iov_count, total_len, context, cmd);
if (ret) {
smr_cmd_queue_discard(ce, pos);
if (proto != smr_proto_inline)
Expand Down Expand Up @@ -249,8 +249,8 @@ static ssize_t smr_generic_inject(struct fid_ep *ep_fid, const void *buf,
ce->ptr = smr_local_to_peer(ep, id, peer_id, (uintptr_t) cmd);
}

ret = smr_proto_ops[proto](ep, peer_smr, id, peer_id, op, tag, data,
op_flags, NULL, &msg_iov, 1, len, NULL, cmd);
ret = smr_send_ops[proto](ep, peer_smr, id, peer_id, op, tag, data,
op_flags, NULL, &msg_iov, 1, len, NULL, cmd);
if (ret) {
smr_cmd_queue_discard(ce, pos);
ret = -FI_EAGAIN;
Expand Down
Loading

0 comments on commit c44dff8

Please sign in to comment.