/* * Measure RDS bandwidth (server side). */ void run_server_rds_bw(void) { char *buf; int sockfd; sockfd = init(); sync_test(); buf = qmalloc(Req.msg_size); while (!Finished) { int n = read(sockfd, buf, Req.msg_size); if (Finished) break; if (n != Req.msg_size) { LStat.r.no_errs++; continue; } LStat.r.no_bytes += n; LStat.r.no_msgs++; if (Req.access_recv) touch_data(buf, Req.msg_size); } stop_test_timer(); exchange_results(); free(buf); close(sockfd); }
/* * Measure RDS bandwidth (client side). */ void run_client_rds_bw(void) { char *buf; int sockfd; par_use(L_ACCESS_RECV); par_use(R_ACCESS_RECV); set_parameters(8*1024); client_send_request(); sockfd = init(); buf = qmalloc(Req.msg_size); sync_test(); while (!Finished) { int n = sendto(sockfd, buf, Req.msg_size, 0, (SA *)&RAddr, RLen); if (Finished) break; if (n != Req.msg_size) { LStat.s.no_errs++; continue; } LStat.s.no_bytes += n; LStat.s.no_msgs++; } stop_test_timer(); exchange_results(); free(buf); close(sockfd); show_results(BANDWIDTH); }
/* * Measure RDMA bandwidth (client side). */ int rd_client_rdma_bw(DEVICE *dev, CONNECTION *con, size_t n_req, const void **local_addr, const void **remote_addr, const size_t *sizes) { rd_post_rdma_std(dev, opcode, NCQE); while (!Finished) { int i; struct ibv_wc wc[NCQE]; int n = rd_poll(&dev, wc, cardof(wc)); if (Finished) break; if (n > LStat.max_cqes) LStat.max_cqes = n; for (i = 0; i < n; ++i) { int status = wc[i].status; if (status == IBV_WC_SUCCESS) { if (opcode == IBV_WR_RDMA_READ) { LStat.r.no_bytes += dev.msg_size; LStat.r.no_msgs++; LStat.rem_s.no_bytes += dev.msg_size; LStat.rem_s.no_msgs++; if (Req.access_recv) touch_data(dev.buffer, dev.msg_size); } } else do_error(status, &LStat.s.no_errs); } rd_post_rdma_std(&dev, opcode, n); } stop_test_timer(); exchange_results(); rd_close(&dev); fprintf(stderr, "Max n %d\n", LStat.max_cqes); return 0; }
/* * Measure RDS latency (client side). */ void run_client_rds_lat(void) { char *buf; int sockfd; set_parameters(1); client_send_request(); sockfd = init(); buf = qmalloc(Req.msg_size); sync_test(); while (!Finished) { int n = sendto(sockfd, buf, Req.msg_size, 0, (SA *)&RAddr, RLen); if (Finished) break; if (n != Req.msg_size) { LStat.s.no_errs++; continue; } LStat.s.no_bytes += n; LStat.s.no_msgs++; n = read(sockfd, buf, Req.msg_size); if (Finished) break; if (n != Req.msg_size) { LStat.r.no_errs++; continue; } LStat.r.no_bytes += n; LStat.r.no_msgs++; } stop_test_timer(); exchange_results(); free(buf); close(sockfd); show_results(LATENCY); }
/* * Measure RDS latency (server side). */ void run_server_rds_lat(void) { char *buf; int sockfd; sockfd = init(); sync_test(); buf = qmalloc(Req.msg_size); while (!Finished) { SS raddr; socklen_t rlen = sizeof(raddr); int n = recvfrom(sockfd, buf, Req.msg_size, 0, (SA *)&raddr, &rlen); if (Finished) break; if (n != Req.msg_size) { LStat.r.no_errs++; continue; } LStat.r.no_bytes += n; LStat.r.no_msgs++; n = sendto(sockfd, buf, Req.msg_size, 0, (SA *)&raddr, rlen); if (Finished) break; if (n != Req.msg_size) { LStat.s.no_errs++; continue; } LStat.s.no_bytes += n; LStat.s.no_msgs++; } stop_test_timer(); exchange_results(); free(buf); close(sockfd); }