static int send_recv() { struct fi_cq_entry comp; int ret; ret = fi_recv(ep, rx_buf, rx_size + ft_rx_prefix_size(), mr_desc, 0, &rx_ctx); if (ret) return ret; ft_sync(); fprintf(stdout, "Posting a send...\n"); ret = ft_post_tx(ep, remote_fi_addr, tx_size, NO_CQ_DATA, &tx_ctx); if (ret) return ret; while ((tx_cq_cntr < tx_seq) || (rx_cq_cntr < rx_seq)) { /* Wait for completion events on CQs */ ret = fi_wait(waitset, -1); if (ret < 0) { FT_PRINTERR("fi_wait", ret); return ret; } /* Read the send completion entry */ ret = fi_cq_read(txcq, &comp, 1); if (ret > 0) { tx_cq_cntr++; fprintf(stdout, "Received send completion event!\n"); } else if (ret < 0 && ret != -FI_EAGAIN) { if (ret == -FI_EAVAIL) { ret = ft_cq_readerr(txcq); } else { FT_PRINTERR("fi_cq_read", ret); } return ret; } /* Read the recv completion entry */ ret = fi_cq_read(rxcq, &comp, 1); if (ret > 0) { rx_cq_cntr++; fprintf(stdout, "Received recv completion event!\n"); } else if (ret < 0 && ret != -FI_EAGAIN) { if (ret == -FI_EAVAIL) { ret = ft_cq_readerr(rxcq); } else { FT_PRINTERR("fi_cq_read", ret); } return ret; } } return 0; }
ssize_t ft_tx(size_t size) { ssize_t ret; if (ft_check_opts(FT_OPT_VERIFY_DATA | FT_OPT_ACTIVE)) ft_fill_buf((char *) tx_buf + ft_tx_prefix_size(), size); ret = ft_post_tx(size); if (ret) return ret; ret = ft_get_tx_comp(tx_seq); return ret; }
ssize_t ft_tx(struct fid_ep *ep, fi_addr_t fi_addr, size_t size, struct fi_context *ctx) { ssize_t ret; if (ft_check_opts(FT_OPT_VERIFY_DATA | FT_OPT_ACTIVE)) ft_fill_buf((char *) tx_buf + ft_tx_prefix_size(), size); ret = ft_post_tx(ep, fi_addr, size, ctx); if (ret) return ret; ret = ft_get_tx_comp(tx_seq); return ret; }
static int send_recv() { struct fi_cq_entry comp; int ret; fprintf(stdout, "Posting a send...\n"); ret = ft_post_tx(tx_size); if (ret) return ret; while ((tx_cq_cntr < tx_seq) || (rx_cq_cntr < rx_seq)) { /* Wait for completion events on CQs */ ret = fi_wait(waitset, -1); if (ret < 0) { FT_PRINTERR("fi_wait", ret); return ret; } /* Read the send completion entry */ ret = fi_cq_read(txcq, &comp, 1); if (ret > 0) { tx_cq_cntr++; fprintf(stdout, "Received send completion event!\n"); } else if (ret < 0 && ret != -FI_EAGAIN) { if (ret == -FI_EAVAIL) { ret = ft_cq_readerr(txcq); } else { FT_PRINTERR("fi_cq_read", ret); } return ret; } /* Read the recv completion entry */ ret = fi_cq_read(rxcq, &comp, 1); if (ret > 0) { rx_cq_cntr++; fprintf(stdout, "Received recv completion event!\n"); } else if (ret < 0 && ret != -FI_EAGAIN) { if (ret == -FI_EAVAIL) { ret = ft_cq_readerr(rxcq); } else { FT_PRINTERR("fi_cq_read", ret); } return ret; } } return 0; }
static int do_transfers(void) { int i, ret; for (i = 0; i < num_eps; i++) { rx_buf = recv_bufs[i]; ret = ft_post_rx(eps[i], opts.transfer_size, &recv_ctx[i]); if (ret) return ret; } for (i = 0; i < num_eps; i++) { if (ft_check_opts(FT_OPT_VERIFY_DATA)) ft_fill_buf(send_bufs[i], opts.transfer_size); tx_buf = send_bufs[i]; ret = ft_post_tx(eps[i], remote_addr[i], opts.transfer_size, &send_ctx[i]); if (ret) return ret; } ret = ft_get_tx_comp(num_eps); if (ret < 0) return ret; ret = ft_get_rx_comp(num_eps); if (ret < 0) return ret; if (ft_check_opts(FT_OPT_VERIFY_DATA)) { for (i = 0; i < num_eps; i++) { ret = ft_check_buf(recv_bufs[i], opts.transfer_size); if (ret) return ret; } } for (i = 0; i < num_eps; i++) ft_finalize_ep(eps[i]); printf("PASSED multi ep\n"); return 0; }
int bandwidth(void) { int ret, i, j; ret = ft_sync(); if (ret) return ret; /* The loop structured allows for the possibility that the sender * immediately overruns the receiving side on the first transfer (or * the entire window). This could result in exercising parts of the * provider's implementation of FI_RM_ENABLED. For better or worse, * some MPI-level benchmarks tend to use this type of loop for measuring * bandwidth. */ if (opts.dst_addr) { for (i = 0; i < opts.iterations + opts.warmup_iterations; i++) { if (i == opts.warmup_iterations) ft_start(); for(j = 0; j < opts.window_size; j++) { if (opts.transfer_size < fi->tx_attr->inject_size) ret = ft_inject(opts.transfer_size); else ret = ft_post_tx(opts.transfer_size); if (ret) return ret; } ret = ft_get_tx_comp(tx_seq); if (ret) return ret; ret = ft_rx(4); if (ret) return ret; } } else { for (i = 0; i < opts.iterations + opts.warmup_iterations; i++) { if (i == opts.warmup_iterations) ft_start(); for(j = 0; j < opts.window_size; j++) { ret = ft_post_rx(opts.transfer_size); if (ret) return ret; } ret = ft_get_rx_comp(rx_seq-1); /* rx_seq is always one ahead */ if (ret) return ret; ret = ft_tx(4); if (ret) return ret; } } ft_stop(); if (opts.machr) show_perf_mr(opts.transfer_size, opts.iterations, &start, &end, opts.window_size, opts.argc, opts.argv); else show_perf(NULL, opts.transfer_size, opts.iterations, &start, &end, opts.window_size); return 0; }
static int send_recv() { struct fi_cq_entry comp; struct epoll_event event; struct fid *fids[1]; int ret; const char *message = "Hello from Client!"; size_t message_len = strlen(message) + 1; if (opts.dst_addr) { fprintf(stdout, "Posting a send...\n"); if (snprintf(tx_buf, tx_size, "%s", message) >= tx_size) { fprintf(stderr, "Transmit buffer too small.\n"); return -FI_ETOOSMALL; } ret = ft_post_tx(ep, remote_fi_addr, message_len, NO_CQ_DATA, &tx_ctx); if (ret) return ret; memset(&event, 0, sizeof event); fids[0] = &txcq->fid; do { if (fi_trywait(fabric, fids, 1) == FI_SUCCESS) { ret = TEMP_FAILURE_RETRY(epoll_wait(epfd, &event, 1, -1)); if (ret < 0) { ret = -errno; FT_PRINTERR("epoll_wait", ret); return ret; } if (event.data.ptr != &txcq->fid) fprintf(stdout, "unexpected event!\n"); } ret = fi_cq_read(txcq, &comp, 1); } while (ret == -FI_EAGAIN); if (ret < 0) { if (ret == -FI_EAVAIL) ret = ft_cq_readerr(txcq); return ret; } fprintf(stdout, "Send completion received\n"); } else { fprintf(stdout, "Waiting for client...\n"); memset(&event, 0, sizeof event); fids[0] = &rxcq->fid; do { if (fi_trywait(fabric, fids, 1) == FI_SUCCESS) { ret = TEMP_FAILURE_RETRY(epoll_wait(epfd, &event, 1, -1)); if (ret < 0) { ret = -errno; FT_PRINTERR("epoll_wait", ret); return ret; } if (event.data.ptr != &rxcq->fid) { fprintf(stdout, "unexpected event!\n"); } } ret = fi_cq_read(rxcq, &comp, 1); } while (ret == -FI_EAGAIN); if (ret < 0) { if (ret == -FI_EAVAIL) ret = ft_cq_readerr(rxcq); return ret; } ret = check_recv_msg(message); if (ret) return ret; fprintf(stdout, "Received data from client: %s\n", (char *) rx_buf); } return 0; }