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;
}
Exemple #2
0
/*
 * The general strategy here is that we call send_loop and do as many sends
 * in a row as we can until we get FI_EAGAIN which prevents us from continuing and
 * we have to drain the send_cq.  Then we do it again, until we've sent
 * all the messages we were going to send.
 */
static int send_loop(size_t size) {
	int q_opts = 0;
	int ret;
	struct fi_context send_ctx[max_opts];

	while (q_opts < max_opts) {
		do {
			ft_tag = q_opts + 1;
			if (tagged)
				ret = fi_tsend(ep, tx_buf, size, NULL, remote_fi_addr,
					ft_tag, (void *) &send_ctx[q_opts]);
			else
				ret = fi_send(ep, tx_buf, size, NULL, remote_fi_addr,
					(void *) &send_ctx[q_opts]);

			if (ret == FI_SUCCESS) {
				tx_seq++;
				q_opts++;
			}
		} while (!ret && (q_opts != max_opts));

		if (ret < 0) {
			if (ret == -FI_EAGAIN) {
				ret = ft_get_tx_comp(tx_seq);
				if (ret)
					return ret;
			} else {
				FT_PRINTERR("Send OP", ret);
				return ret;
			}
		}
	}

	ret = ft_get_tx_comp(tx_seq);
	if (ret)
		return ret;

	if (opts.verbose)
		printf("Success: Completed %d queued ops\n", q_opts);

	return 0;
}
Exemple #3
0
int ft_finalize(void)
{
	struct iovec iov;
	int ret;
	struct fi_context ctx;
	void *desc = fi_mr_desc(mr);

	strcpy(tx_buf + ft_tx_prefix_size(), "fin");
	iov.iov_base = tx_buf;
	iov.iov_len = 4 + ft_tx_prefix_size();

	if (hints->caps & FI_TAGGED) {
		struct fi_msg_tagged tmsg;

		memset(&tmsg, 0, sizeof tmsg);
		tmsg.msg_iov = &iov;
		tmsg.desc = &desc;
		tmsg.iov_count = 1;
		tmsg.addr = remote_fi_addr;
		tmsg.tag = tx_seq;
		tmsg.ignore = 0;
		tmsg.context = &ctx;

		ret = fi_tsendmsg(ep, &tmsg, FI_INJECT | FI_TRANSMIT_COMPLETE);
	} else {
		struct fi_msg msg;

		memset(&msg, 0, sizeof msg);
		msg.msg_iov = &iov;
		msg.desc = &desc;
		msg.iov_count = 1;
		msg.addr = remote_fi_addr;
		msg.context = &ctx;

		ret = fi_sendmsg(ep, &msg, FI_INJECT | FI_TRANSMIT_COMPLETE);
	}
	if (ret) {
		FT_PRINTERR("transmit", ret);
		return ret;
	}


	ret = ft_get_tx_comp(++tx_seq);
	if (ret)
		return ret;

	ret = ft_get_rx_comp(rx_seq);
	if (ret)
		return ret;

	return 0;
}
static int send_msg(int size)
{
	int ret;

	ret = fi_send(ep_array[0], buf, (size_t) size, fi_mr_desc(mr),
			addr_array[0], &tx_ctx);
	if (ret) {
		FT_PRINTERR("fi_send", ret);
		return ret;
	}

	ret = ft_get_tx_comp(++tx_seq);
	return ret;
}
Exemple #5
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;
}
Exemple #6
0
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;
}
Exemple #7
0
static int run_test()
{
	int ret;
	size_t size = 1000;
	struct fi_cq_data_entry comp;

	if (opts.dst_addr) {
		fprintf(stdout,
			"Posting send with CQ 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;
		}

		ret = ft_get_tx_comp(++tx_seq);
		fprintf(stdout, "Done\n");
	} else {
		fprintf(stdout, "Waiting for CQ data from client\n");
		ret = fi_cq_sread(rxcq, &comp, 1, NULL, -1);
		if (ret < 0) {
			if (ret == -FI_EAVAIL) {
				ret = ft_cq_readerr(rxcq);
			} else {
				FT_PRINTERR("fi_cq_sread", ret);
			}
			return ret;
		}

		if (comp.flags & FI_REMOTE_CQ_DATA) {
			if (comp.data == remote_cq_data) {
				fprintf(stdout, "remote_cq_data: success\n");
				ret = 0;
			} else {
				fprintf(stdout, "error, Expected data:0x%" PRIx64
					", Received data:0x%" PRIx64 "\n",
					remote_cq_data, comp.data);
				ret = -FI_EIO;
			}
		} else {
			fprintf(stdout, "error, CQ data flag not set\n");
			ret = -FI_EBADFLAGS;
		}
	}

	return ret;
}
Exemple #8
0
static int run_test(void)
{
	int ret = 0;
	const char *message = "Hello from Client!";
	size_t message_len = strlen(message) + 1;

	ret = ft_init_fabric();
	if (ret)
		return ret;

	ret = ft_exchange_keys(&remote);
	if (ret)
		return ret;

	if (opts.dst_addr) {
		fprintf(stdout, "RMA write to server\n");
		if (snprintf(tx_buf, tx_size, "%s", message) >= tx_size) {
                        fprintf(stderr, "Transmit buffer too small.\n");
                        return -FI_ETOOSMALL;
                }
		ret = fi_write(ep, tx_buf, message_len, mr_desc,
			       remote_fi_addr, remote.addr, remote.key,
			       &fi_ctx_write);
		if (ret)
			return ret;

		ret = ft_get_tx_comp(++tx_seq);
		if (ret)
			return ret;

		fprintf(stdout, "Received a completion event for RMA write\n");
	} else {
		ret = ft_get_rx_comp(rx_seq);
		if (ret)
			return ret;

		ret = check_recv_msg(message);
		if (ret)
			return ret;

		fprintf(stdout, "Received data from Client: %s\n", (char *) rx_buf);
	}

	/* TODO: need support for finalize operation to sync test */
	return 0;
}
Exemple #9
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;
}
Exemple #10
0
ssize_t ft_rma(enum ft_rma_opcodes op, struct fid_ep *ep, size_t size,
		struct fi_rma_iov *remote, void *context)
{
	int ret;

	ret = ft_post_rma(op, ep, size, remote, context);
	if (ret)
		return ret;

	if (op == FT_RMA_WRITEDATA) {
		ret = ft_rx(ep, 0);
		if (ret)
			return ret;
	}

	ret = ft_get_tx_comp(tx_seq);
	if (ret)
		return ret;

	return 0;
}
Exemple #11
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;
}
Exemple #12
0
static int run(void)
{
	int ret;

	ret = init_fabric();
	if (ret)
		return ret;

	ret = ft_init_av();
	if (ret)
		return ret;

	if (opts.dst_addr) {
		printf("Searching for a bad msg\n");
		ret = tagged_peek(0xbad);
		if (ret != -FI_ENOMSG) {
			FT_PRINTERR("FI_PEEK", ret);
			return ret;
		}

		printf("Synchronizing with sender..\n");
		ret = ft_sync();
		if (ret)
			return ret;

		printf("Searching for a good msg\n");
		ret = tagged_peek(0x900d);
		if (ret != 1) {
			FT_PRINTERR("FI_PEEK", ret);
			return ret;
		}

		printf("Receiving msg\n");
		ret = fi_trecv(ep, buf, rx_size, fi_mr_desc(mr), remote_fi_addr,
				0x900d, 0, &rx_ctx);
		if (ret) {
			FT_PRINTERR("fi_trecv", ret);
			return ret;
		}

		printf("Completing recv\n");
		ret = ft_get_rx_comp(++rx_seq);
		if (ret)
			return ret;

	} else {
		printf("Sending tagged message\n");
		ret = fi_tsend(ep, tx_buf, tx_size, fi_mr_desc(mr),
				remote_fi_addr, 0x900d, &tx_ctx);
		if (ret)
			return ret;

		printf("Synchronizing with receiver..\n");
		ret = ft_sync();
		if (ret)
			return ret;

		printf("Getting send completion\n");
		ret = ft_get_tx_comp(tx_seq + 1);
		if (ret)
			return ret;
	}

	ft_finalize();
	return 0;
}
Exemple #13
0
static int run_test_loop(void)
{
	int ret = 0;
	uint64_t op_data = send_data ? opts.transfer_size : NO_CQ_DATA;
	uint64_t op_tag = 0x1234;
	char *op_buf;
	int i, j;

	for (i = 0; i < num_iters; i++) {
		for (j = 0; j < concurrent_msgs; j++) {
			op_buf = get_tx_buf(j);
			if (ft_check_opts(FT_OPT_VERIFY_DATA))
				ft_fill_buf(op_buf + ft_tx_prefix_size(),
					    opts.transfer_size);

			ret = ft_post_tx_buf(ep, remote_fi_addr,
					     opts.transfer_size,
					     op_data, &tx_ctx_arr[j],
					     op_buf, mr_desc, op_tag);
			if (ret) {
				printf("ERROR send_msg returned %d\n", ret);
				return ret;
			}
		}

		ret = ft_sync();
		if (ret)
			return ret;

		for (j = 0; j < concurrent_msgs; j++) {
			op_buf = get_rx_buf(j);
			ret = ft_post_rx_buf(ep, opts.transfer_size,
					     &rx_ctx_arr[j], op_buf,
					     mr_desc, op_tag);
			if (ret) {
				printf("ERROR recv_msg returned %d\n", ret);
				return ret;
			}
		}

		for (j = 0; j < concurrent_msgs; j++) {
			ret = wait_recvs();
			if (ret < 1)
				return ret;
		}

		if (ft_check_opts(FT_OPT_VERIFY_DATA)) {
			for (j = 0; j < concurrent_msgs; j++) {
				op_buf = get_rx_buf(j);
				if (ft_check_buf(op_buf + ft_rx_prefix_size(),
						 opts.transfer_size))
					return -FI_EOTHER;
			}
		}

		for (j = 0; j < concurrent_msgs; j++) {
			ret = ft_get_tx_comp(tx_seq);
			if (ret)
				return ret;
		}

		if (i % 100 == 0)
			printf("PID %d GOOD iter %d/%ld completed\n",
				getpid(), i, num_iters);
	}

	(void) ft_sync();
	printf("PID %d GOOD all done\n", getpid());
	return ret;
}