static int send_xfer(int size) { struct fi_cq_entry comp; int ret; while (!credits) { ret = fi_cq_read(scq, &comp, 1); if (ret > 0) { goto post; } else if (ret < 0) { printf("RCQ read %d (%s)\n", ret, fi_strerror(-ret)); return ret; } } credits--; post: ret = dst_addr ? fi_send(ep, buf_ptr, (size_t) size, fi_mr_desc(mr), NULL) : fi_sendto(ep, buf_ptr, (size_t) size, fi_mr_desc(mr), client_addr, NULL); if (ret) printf("fi_send %d (%s)\n", ret, fi_strerror(-ret)); return ret; }
ssize_t ft_post_rma(enum ft_rma_opcodes op, struct fid_ep *ep, size_t size, struct fi_rma_iov *remote, void *context) { switch (op) { case FT_RMA_WRITE: FT_POST(fi_write, ft_get_tx_comp, tx_seq, "fi_write", ep, tx_buf, opts.transfer_size, fi_mr_desc(mr), remote_fi_addr, remote->addr, remote->key, context); break; case FT_RMA_WRITEDATA: FT_POST(fi_writedata, ft_get_tx_comp, tx_seq, "fi_writedata", ep, tx_buf, opts.transfer_size, fi_mr_desc(mr), remote_cq_data, remote_fi_addr, remote->addr, remote->key, context); break; case FT_RMA_READ: FT_POST(fi_read, ft_get_tx_comp, tx_seq, "fi_read", ep, rx_buf, opts.transfer_size, fi_mr_desc(mr), remote_fi_addr, remote->addr, remote->key, context); break; default: FT_ERR("Unknown RMA op type\n"); return EXIT_FAILURE; } return 0; }
static inline ssize_t rxm_ep_rma_reg_iov(struct rxm_ep *rxm_ep, const struct iovec *msg_iov, void **desc, void **desc_storage, size_t iov_count, uint64_t comp_flags, struct rxm_rma_buf *rma_buf) { size_t i; if (rxm_ep->msg_mr_local) { if (!rxm_ep->rxm_mr_local) { ssize_t ret = rxm_ep_msg_mr_regv(rxm_ep, msg_iov, iov_count, comp_flags & (FI_WRITE | FI_READ), rma_buf->mr.mr); if (OFI_UNLIKELY(ret)) return ret; for (i = 0; i < iov_count; i++) desc_storage[i] = fi_mr_desc(rma_buf->mr.mr[i]); rma_buf->mr.count = iov_count; } else { for (i = 0; i < iov_count; i++) desc_storage[i] = fi_mr_desc(desc[i]); } } return FI_SUCCESS; }
static int run_test() { int ret, i; /* Post recvs */ for (i = 0; i < ep_cnt; i++) { fprintf(stdout, "Posting recv for ctx: %d\n", i); ret = fi_recv(srx_ctx, rx_buf, rx_size, fi_mr_desc(mr), FI_ADDR_UNSPEC, NULL); if (ret) { FT_PRINTERR("fi_recv", ret); return ret; } rx_seq++; } if (opts.dst_addr) { /* Post sends addressed to remote EPs */ for (i = 0; i < ep_cnt; i++) { fprintf(stdout, "Posting send to remote ctx: %d\n", i); ret = fi_send(ep_array[i], tx_buf, tx_size, fi_mr_desc(mr), addr_array[i], NULL); if (ret) { FT_PRINTERR("fi_send", ret); return ret; } ret = ft_get_tx_comp(++tx_seq); if (ret) return ret; } } /* Wait for recv completions */ ret = ft_get_rx_comp(rx_seq); if (ret) return ret; if (!opts.dst_addr) { /* Post sends addressed to remote EPs */ for (i = 0; i < ep_cnt; i++) { fprintf(stdout, "Posting send to remote ctx: %d\n", i); ret = fi_send(ep_array[i], tx_buf, tx_size, fi_mr_desc(mr), addr_array[i], NULL); if (ret) { FT_PRINTERR("fi_send", ret); return ret; } ret = ft_get_tx_comp(++tx_seq); if (ret) return ret; } } return 0; }
static int init_av(void) { size_t addrlen; int ret, i; if (opts.dst_addr) { ret = ft_av_insert(av, fi->dest_addr, 1, &remote_fi_addr, 0, NULL); if (ret) return ret; addrlen = FT_MAX_CTRL_MSG; ret = fi_getname(&sep->fid, tx_buf, &addrlen); if (ret) { FT_PRINTERR("fi_getname", ret); return ret; } ret = fi_send(tx_ep[0], tx_buf, addrlen, fi_mr_desc(mr), remote_fi_addr, NULL); if (ret) { FT_PRINTERR("fi_send", ret); return ret; } ret = wait_for_comp(rxcq_array[0]); if (ret) return ret; } else { ret = wait_for_comp(rxcq_array[0]); if (ret) return ret; ret = ft_av_insert(av, rx_buf, 1, &remote_fi_addr, 0, NULL); if (ret) return ret; ret = fi_send(tx_ep[0], tx_buf, 1, fi_mr_desc(mr), remote_fi_addr, NULL); if (ret) { FT_PRINTERR("fi_send", ret); return ret; } } for (i = 0; i < ctx_cnt; i++) remote_rx_addr[i] = fi_rx_addr(remote_fi_addr, i, rx_ctx_bits); ret = fi_recv(rx_ep[0], rx_buf, rx_size, fi_mr_desc(mr), 0, NULL); if (ret) { FT_PRINTERR("fi_recv", ret); return ret; } ret = wait_for_comp(txcq_array[0]); return ret; }
/* * rpmem_fip_init_memory -- (internal) initialize common memory resources */ static int rpmem_fip_init_memory(struct rpmem_fip *fip) { ASSERTne(Pagesize, 0); int ret; /* * Register local memory space. The local memory will be used * with WRITE operation in rpmem_fip_persist function thus * the FI_WRITE access flag. */ ret = fi_mr_reg(fip->domain, fip->laddr, fip->size, FI_WRITE, 0, 0, 0, &fip->mr, NULL); if (ret) { RPMEM_FI_ERR(ret, "registrating memory"); return ret; } /* get local memory descriptor */ fip->mr_desc = fi_mr_desc(fip->mr); /* allocate buffer for read operation */ ASSERT(IS_PAGE_ALIGNED(RPMEM_RD_BUFF_SIZE)); errno = posix_memalign((void **)&fip->rd_buff, Pagesize, RPMEM_RD_BUFF_SIZE); if (errno) { RPMEM_LOG(ERR, "!allocating read buffer"); ret = -1; goto err_malloc_rd_buff; } /* * Register buffer for read operation. * The read operation utilizes READ operation thus * the FI_REMOTE_WRITE flag. */ ret = fi_mr_reg(fip->domain, fip->rd_buff, RPMEM_RD_BUFF_SIZE, FI_REMOTE_WRITE, 0, 0, 0, &fip->rd_mr, NULL); if (ret) { RPMEM_FI_ERR(ret, "registrating read buffer"); goto err_rd_mr; } /* get read buffer local memory descriptor */ fip->rd_mr_desc = fi_mr_desc(fip->rd_mr); return 0; err_rd_mr: free(fip->rd_buff); err_malloc_rd_buff: RPMEM_FI_CLOSE(fip->mr, "unregistering memory"); return ret; }
static int run_test() { int ret; size_t size = 1000; uint64_t remote_cq_data; struct fi_cq_data_entry comp; /* Set remote_cq_data based on the cq_data_size we got from fi_getinfo */ remote_cq_data = 0x0123456789abcdef & ((0x1ULL << (cq_data_size * 8)) - 1); if (dst_addr) { fprintf(stdout, "Posting send with immediate data: %lx\n", remote_cq_data); ret = fi_senddata(ep, buf, size, fi_mr_desc(mr), remote_cq_data, 0, buf); if (ret) { FI_PRINTERR("fi_send", ret); return ret; } wait_for_completion(scq, 1); fprintf(stdout, "Done\n"); } else { ret = fi_recv(ep, buf, size, fi_mr_desc(mr), 0, buf); if (ret) { FI_PRINTERR("fi_recv", ret); return ret; } fprintf(stdout, "Waiting for immediate data from client\n"); ret = fi_cq_sread(rcq, &comp, 1, NULL, -1); if (ret < 0) { if (ret == -FI_EAVAIL) { cq_readerr(rcq, "rcq"); } else { FI_PRINTERR("fi_cq_read: rcq", ret); } return ret; } /* Verify completion data */ if (comp.flags & FI_REMOTE_CQ_DATA) { if (comp.data == remote_cq_data) fprintf(stdout, "remote_cq_data: success\n"); else fprintf(stdout, "remote_cq_data: failure\n"); fprintf(stdout, "Expected data:0x%lx, Received data:0x%lx\n", remote_cq_data, comp.data); } } return 0; }
static int run_test() { int ret, i; /* Post recvs */ for (i = 0; i < ep_cnt; i++) { fprintf(stdout, "Posting recv for ctx: %d\n", i); ret = fi_recv(srx_ctx, buf, buffer_size, fi_mr_desc(mr), FI_ADDR_UNSPEC, NULL); if (ret) { FT_PRINTERR("fi_recv", ret); return ret; } } if (opts.dst_addr) { /* Post sends addressed to remote EPs */ for (i = 0; i < ep_cnt; i++) { fprintf(stdout, "Posting send to remote ctx: %d\n", i); ret = fi_send(ep[i], buf, transfer_size, fi_mr_desc(mr), remote_fi_addr[i], NULL); if (ret) { FT_PRINTERR("fi_send", ret); return ret; } wait_for_completion(scq, 1); } } /* Wait for recv completions */ for (i = 0; i < ep_cnt; i++) { wait_for_completion(rcq, 1); } if (!opts.dst_addr) { /* Post sends addressed to remote EPs */ for (i = 0; i < ep_cnt; i++) { fprintf(stdout, "Posting send to remote ctx: %d\n", i); ret = fi_send(ep[i], buf, transfer_size, fi_mr_desc(mr), remote_fi_addr[i], NULL); if (ret) { FT_PRINTERR("fi_send", ret); return ret; } wait_for_completion(scq, 1); } } return 0; }
ssize_t ft_post_tx(struct fid_ep *ep, fi_addr_t fi_addr, size_t size, struct fi_context* ctx) { if (hints->caps & FI_TAGGED) { FT_POST(fi_tsend, ft_get_tx_comp, tx_seq, "transmit", ep, tx_buf, size + ft_tx_prefix_size(), fi_mr_desc(mr), fi_addr, tx_seq, ctx); } else { FT_POST(fi_send, ft_get_tx_comp, tx_seq, "transmit", ep, tx_buf, size + ft_tx_prefix_size(), fi_mr_desc(mr), fi_addr, ctx); } return 0; }
ssize_t ft_post_rx(struct fid_ep *ep, size_t size, struct fi_context* ctx) { if (hints->caps & FI_TAGGED) { FT_POST(fi_trecv, ft_get_rx_comp, rx_seq, "receive", ep, rx_buf, MAX(size, FT_MAX_CTRL_MSG) + ft_rx_prefix_size(), fi_mr_desc(mr), 0, rx_seq, 0, ctx); } else { FT_POST(fi_recv, ft_get_rx_comp, rx_seq, "receive", ep, rx_buf, MAX(size, FT_MAX_CTRL_MSG) + ft_rx_prefix_size(), fi_mr_desc(mr), 0, ctx); } return 0; }
static int send_recv() { struct fi_cq_entry comp; int ret; if (opts.dst_addr) { /* Client */ fprintf(stdout, "Posting a send...\n"); sprintf(buf, "Hello from Client!"); ret = fi_send(ep, buf, sizeof("Hello from Client!"), fi_mr_desc(mr), remote_fi_addr, &fi_ctx_send); if (ret) { FT_PRINTERR("fi_send", ret); return ret; } /* Read send queue */ do { ret = fi_cq_read(scq, &comp, 1); if (ret < 0 && ret != -FI_EAGAIN) { FT_PRINTERR("fi_cq_read", ret); return ret; } } while (ret == -FI_EAGAIN); fprintf(stdout, "Send completion received\n"); } else { /* Server */ fprintf(stdout, "Posting a recv...\n"); ret = fi_recv(ep, buf, buffer_size, fi_mr_desc(mr), 0, &fi_ctx_recv); if (ret) { FT_PRINTERR("fi_recv", ret); return ret; } /* Read recv queue */ fprintf(stdout, "Waiting for client...\n"); do { ret = fi_cq_read(rcq, &comp, 1); if (ret < 0 && ret != -FI_EAGAIN) { FT_PRINTERR("fi_cq_read", ret); return ret; } } while (ret == -FI_EAGAIN); fprintf(stdout, "Received data from client: %s\n", (char *)buf); } return 0; }
static int execute_fetch_atomic_op(enum fi_op op) { int ret; ret = fi_fetch_atomic(ep, buf, 1, fi_mr_desc(mr), result, fi_mr_desc(mr_result), remote_fi_addr, remote.addr, remote.key, datatype, op, &fi_ctx_atomic); if (ret) { FT_PRINTERR("fi_fetch_atomic", ret); } else { ret = wait_for_completion(scq, 1); } return ret; }
static int recv_xfer(int size) { struct fi_cq_tagged_entry comp; int ret; do { ret = fi_cq_read(rcq, &comp, 1); if (ret < 0 && ret != -FI_EAGAIN) { if (ret == -FI_EAVAIL) { cq_readerr(rcq, "rcq"); } else { FT_PRINTERR("fi_cq_read", ret); } return ret; } } while (ret == -FI_EAGAIN); /* Posting recv for next send. Hence tag_data + 1 */ ret = fi_trecv(ep, buf, buffer_size, fi_mr_desc(mr), remote_fi_addr, tag_data + 1, 0, &fi_ctx_trecv); if (ret) FT_PRINTERR("fi_trecv", ret); return ret; }
static int run_test() { int ret = 0, i; if (opts.dst_addr) { for (i = 0; i < ctx_cnt && !ret; i++) { fprintf(stdout, "Posting send for ctx: %d\n", i); ret = fi_send(tx_ep[i], buf, tx_size, fi_mr_desc(mr), remote_rx_addr[i], NULL); if (ret) { FT_PRINTERR("fi_send", ret); return ret; } ret = wait_for_comp(txcq_array[i]); } } else { for (i = 0; i < ctx_cnt && !ret; i++) { fprintf(stdout, "wait for recv completion for ctx: %d\n", i); ret = wait_for_comp(rxcq_array[i]); } } return ret; }
int rxm_ep_repost_buf(struct rxm_rx_buf *rx_buf) { struct fid_mr *mr; void *desc = NULL; int ret; rx_buf->conn = NULL; rx_buf->recv_fs = NULL; rx_buf->recv_entry = NULL; memset(&rx_buf->unexp_msg, 0, sizeof(rx_buf->unexp_msg)); rx_buf->state = RXM_LMT_NONE; rx_buf->rma_iov = NULL; if (rx_buf->ep->msg_info->mode & FI_LOCAL_MR) { mr = util_buf_get_ctx(rx_buf->ep->rx_pool, rx_buf); desc = fi_mr_desc(mr); } FI_DBG(&rxm_prov, FI_LOG_EP_CTRL, "Re-posting rx buf\n"); ret = fi_recv(rx_buf->ep->srx_ctx, &rx_buf->pkt, RXM_BUF_SIZE, desc, FI_ADDR_UNSPEC, rx_buf); if (ret) FI_WARN(&rxm_prov, FI_LOG_EP_CTRL, "Unable to repost buf\n"); return ret; }
static int create_messages(struct cma_node *node) { int ret; if (!hints->ep_attr->max_msg_size) hints->tx_attr->size = 0; if (!hints->tx_attr->size) return 0; node->mem = malloc(hints->ep_attr->max_msg_size); if (!node->mem) { printf("failed message allocation\n"); return -1; } if (info->mode & FI_LOCAL_MR) { ret = fi_mr_reg(node->domain, node->mem, hints->ep_attr->max_msg_size, FI_SEND | FI_RECV, 0, 0, 0, &node->mr, NULL); if (ret) { FT_PRINTERR("fi_reg_mr", ret); goto err; } node->mrdesc = fi_mr_desc(node->mr); } ret = post_recvs(node); return ret; err: free(node->mem); return -1; }
static int wait_remote_writedata_completion(void) { struct fi_cq_data_entry comp; int ret; do { ret = fi_cq_read(rcq, &comp, 1); if (ret < 0 && ret != -FI_EAGAIN) { if (ret == -FI_EAVAIL) { cq_readerr(rcq, "rcq"); } else { FT_PRINTERR("fi_cq_read", ret); } return ret; } } while (ret == -FI_EAGAIN); ret = 0; if (comp.data != cq_data) { fprintf(stderr, "Got unexpected completion data %" PRIu64 "\n", comp.data); } assert(comp.op_context == buf || comp.op_context == NULL); if (comp.op_context == buf) { /* We need to repost the receive */ ret = fi_recv(ep, buf, buffer_size, fi_mr_desc(mr), 0, buf); if (ret) FT_PRINTERR("fi_recv", ret); } return ret; }
static int ft_setup_xcontrol_bufs(struct ft_xcontrol *ctrl) { size_t size; int i, ret; size = ft.size_array[ft.size_cnt - 1]; if (!ctrl->buf) { ctrl->buf = calloc(1, size); if (!ctrl->buf) return -FI_ENOMEM; } if ((fabric_info->mode & FI_LOCAL_MR) && !ctrl->mr) { ret = fi_mr_reg(domain, ctrl->buf, size, 0, 0, 0, 0, &ctrl->mr, NULL); if (ret) { FT_PRINTERR("fi_mr_reg", ret); return ret; } ctrl->memdesc = fi_mr_desc(ctrl->mr); } for (i = 0; i < ft.iov_cnt; i++) ctrl->iov_desc[i] = ctrl->memdesc; return 0; }
static int execute_fetch_atomic_op(enum fi_op op) { int ret; ret = fi_fetch_atomic(ep, buf, 1, fi_mr_desc(mr), result, fi_mr_desc(mr_result), remote_fi_addr, remote.addr, remote.key, datatype, op, &fi_ctx_atomic); if (ret) { fprintf(stderr, "fi_fetch_atomic %d (%s)\n", ret, fi_strerror(-ret)); } else { ret = wait_for_completion(scq, 1); } return ret; }
int wait_for_recv_completion(int num_completions) { int i, ret; struct fi_cq_data_entry comp; while (num_completions > 0) { ret = fi_cq_read(rxcq, &comp, 1); if (ret == -FI_EAGAIN) continue; if (ret < 0) { FT_PRINTERR("fi_cq_read", ret); return ret; } if (comp.len) num_completions--; if (comp.flags & FI_MULTI_RECV) { i = (comp.op_context == &ctx_multi_recv[0]) ? 0 : 1; ret = fi_recv(ep, rx_buf + (rx_size / 2) * i, rx_size / 2, fi_mr_desc(mr_multi_recv), 0, &ctx_multi_recv[i]); if (ret) { FT_PRINTERR("fi_recv", ret); return ret; } } } return 0; }
static int send_xfer(int size) { struct fi_cq_entry comp; int ret; while (!credits) { ret = fi_cq_read(scq, &comp, 1); if (ret > 0) { goto post; } else if (ret < 0 && ret != -FI_EAGAIN) { if (ret == -FI_EAVAIL) { cq_readerr(scq, "scq"); } else { FT_PRINTERR("fi_cq_read", ret); } return ret; } } credits--; post: ret = fi_send(ep, buf, (size_t) size, fi_mr_desc(mr), remote_fi_addr, &fi_ctx_send); if (ret) FT_PRINTERR("fi_send", ret); return ret; }
static int bind_ep_res(void) { int ret; ret = fi_bind(&ep->fid, &scq->fid, FI_SEND); if (ret) { printf("fi_bind scq %d (%s)\n", ret, fi_strerror(-ret)); return ret; } ret = fi_bind(&ep->fid, &rcq->fid, FI_RECV); if (ret) { printf("fi_bind rcq %d (%s)\n", ret, fi_strerror(-ret)); return ret; } ret = fi_bind(&ep->fid, &av->fid, 0); if (ret) { printf("fi_bind av %d (%s)\n", ret, fi_strerror(-ret)); return ret; } ret = fi_enable(ep); if (ret) { printf("fi_enable %d (%s)\n", ret, fi_strerror(-ret)); return ret; } ret = fi_recv(ep, buf, buffer_size, fi_mr_desc(mr), buf); if (ret) { printf("fi_recv %d (%s)\n", ret, fi_strerror(-ret)); } return ret; }
/* Common code will free allocated buffers and MR */ static int alloc_bufs(void) { int ret; tx_size = opts.transfer_size + ft_tx_prefix_size(); rx_size = opts.transfer_size + ft_rx_prefix_size(); buf_size = (tx_size + rx_size) * concurrent_msgs; buf = malloc(buf_size); tx_ctx_arr = calloc(concurrent_msgs, sizeof(*tx_ctx_arr)); rx_ctx_arr = calloc(concurrent_msgs, sizeof(*rx_ctx_arr)); if (!buf || !tx_ctx_arr || !rx_ctx_arr) return -FI_ENOMEM; rx_buf = buf; tx_buf = (char *) buf + rx_size * concurrent_msgs; if (fi->domain_attr->mr_mode & FI_MR_LOCAL) { ret = fi_mr_reg(domain, buf, buf_size, FI_SEND | FI_RECV, 0, FT_MR_KEY, 0, &mr, NULL); if (ret) return ret; mr_desc = fi_mr_desc(mr); } return 0; }
static int bind_ep_res(void) { int ret; ret = fi_ep_bind(ep, &cmeq->fid, 0); if (ret) { FT_PRINTERR("fi_ep_bind", ret); return ret; } ret = fi_ep_bind(ep, &scq->fid, FI_SEND); if (ret) { FT_PRINTERR("fi_ep_bind", ret); return ret; } ret = fi_ep_bind(ep, &rcq->fid, FI_RECV); if (ret) { FT_PRINTERR("fi_ep_bind", ret); return ret; } ret = fi_enable(ep); if (ret) { FT_PRINTERR("fi_enable", ret); return ret; } /* Post the first recv buffer */ ret = fi_recv(ep, buf, buffer_size, fi_mr_desc(mr), 0, buf); if (ret) FT_PRINTERR("fi_recv", ret); return ret; }
static int send_xfer(int size) { struct fi_cq_entry comp; int ret; while (!credits) { ret = fi_cq_read(scq, &comp, 1); if (ret > 0) { goto post; } else if (ret < 0) { if (ret == -FI_EAVAIL) { cq_readerr(scq, "scq"); } else { printf("scq read %d (%s)\n", ret, fi_strerror(-ret)); } return ret; } } credits--; post: ret = fi_send(ep, buf, (size_t) size, fi_mr_desc(mr), NULL); if (ret) printf("fi_send %d (%s)\n", ret, fi_strerror(-ret)); return ret; }
Test(rdm_tagged_sr, multi_tsend_trecv) { int i, it, ridx, ret; const int iters = 37; const int num_msgs = 17; const int slen = 256; uint64_t tags[num_msgs]; uint64_t rtag = 0x01000000; uint64_t ignore = 0xf0ffffff; char msg[num_msgs][slen]; struct fi_cq_tagged_entry cqe; srand(time(NULL)); for (it = 0; it < iters; it++) { for (i = 0; i < num_msgs; i++) { tags[i] = 0x01010abc + it*iters + i; sprintf(msg[i], "%d\n", i); ret = fi_tsend(ep[1], msg[i], strlen(msg[i]), NULL, gni_addr[0], tags[i], NULL); cr_assert(ret == FI_SUCCESS); do { ret = fi_cq_read(msg_cq[1], &cqe, 1); cr_assert((ret == 1) || (ret == -FI_EAGAIN)); } while (ret == -FI_EAGAIN); cr_assert(cqe.len == 0); cr_assert(cqe.tag == 0); } for (i = 0; i < num_msgs; i++) { ret = fi_trecv(ep[0], target, BUF_SZ, fi_mr_desc(loc_mr), gni_addr[1], rtag, ignore, NULL); cr_assert(ret == FI_SUCCESS); do { ret = fi_cq_read(msg_cq[0], &cqe, 1); cr_assert((ret == 1) || (ret == -FI_EAGAIN)); } while (ret == -FI_EAGAIN); cr_assert(rtag != cqe.tag); ret = sscanf(target, "%d", &ridx); cr_assert(ret == 1); cr_assert(cqe.len == strlen(msg[ridx])); /* zero out the tag for error checking below */ tags[ridx] = 0; } /* Make sure we got everything */ for (i = 0; i < num_msgs; i++) cr_assert(tags[i] == 0); } }
ssize_t ft_post_rx(size_t size) { ssize_t ret; if (hints->caps & FI_TAGGED) { ret = fi_trecv(ep, rx_buf, size + ft_rx_prefix_size(), fi_mr_desc(mr), 0, rx_seq, 0, &rx_ctx); } else { ret = fi_recv(ep, rx_buf, size + ft_rx_prefix_size(), fi_mr_desc(mr), 0, &rx_ctx); } if (ret) { FT_PRINTERR("receive", ret); return ret; } rx_seq++; return 0; }
ssize_t ft_post_tx(size_t size) { ssize_t ret; if (hints->caps & FI_TAGGED) { ret = fi_tsend(ep, tx_buf, size + ft_tx_prefix_size(), fi_mr_desc(mr), remote_fi_addr, tx_seq, &tx_ctx); } else { ret = fi_send(ep, tx_buf, size + ft_tx_prefix_size(), fi_mr_desc(mr), remote_fi_addr, &tx_ctx); } if (ret) { FT_PRINTERR("transmit", ret); return ret; } tx_seq++; return 0; }
static int run_test() { int ret; size_t size = 1000; uint64_t remote_cq_data; struct fi_cq_data_entry comp; if (fi->domain_attr->cq_data_size >= sizeof(uint64_t)) { remote_cq_data = 0x0123456789abcdefULL; } else { remote_cq_data = 0x0123456789abcdef & ((0x1ULL << (fi->domain_attr->cq_data_size * 8)) - 1); } if (opts.dst_addr) { fprintf(stdout, "Posting send with immediate data: 0x%" PRIx64 "\n", remote_cq_data); ret = fi_senddata(ep, buf, size, fi_mr_desc(mr), remote_cq_data, 0, buf); if (ret) { FT_PRINTERR("fi_send", ret); return ret; } ft_wait_for_comp(txcq, 1); fprintf(stdout, "Done\n"); } else { fprintf(stdout, "Waiting for immediate data from client\n"); ret = fi_cq_sread(rxcq, &comp, 1, NULL, -1); if (ret < 0) { if (ret == -FI_EAVAIL) { cq_readerr(rxcq, "rxcq"); } else { FT_PRINTERR("fi_cq_sread", ret); } return ret; } /* Verify completion data */ if (comp.flags & FI_REMOTE_CQ_DATA) { if (comp.data == remote_cq_data) fprintf(stdout, "remote_cq_data: success\n"); else fprintf(stdout, "remote_cq_data: failure\n"); fprintf(stdout, "Expected data:0x%" PRIx64 ", Received data:0x%" PRIx64 "\n", remote_cq_data, comp.data); } } return 0; }
static int send_msg(int size) { int ret; ret = fi_send(ep, buf, (size_t) size, fi_mr_desc(mr), remote_fi_addr, &fi_ctx_send); if (ret) FT_PRINTERR("fi_send", ret); return wait_for_completion(scq, 1); }