예제 #1
0
int pingpong(void)
{
	int ret, i;

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

	ft_start();
	for (i = 0; i < opts.iterations; i++) {
		ret = opts.dst_addr ?
			ft_tx(opts.transfer_size) : ft_rx(opts.transfer_size);
		if (ret)
			return ret;

		ret = opts.dst_addr ?
			ft_rx(opts.transfer_size) : ft_tx(opts.transfer_size);
		if (ret)
			return ret;
	}
	ft_stop();

	if (opts.machr)
		show_perf_mr(opts.transfer_size, opts.iterations, &start, &end, 2, opts.argc, opts.argv);
	else
		show_perf(test_name, opts.transfer_size, opts.iterations, &start, &end, 2);

	return 0;
}
예제 #2
0
static int run_test()
{
	int ret, i;

	if (!(tx_ctx_arr = calloc(ep_cnt, sizeof *tx_ctx_arr)))
		return -FI_ENOMEM;

	if (!(rx_ctx_arr = calloc(ep_cnt, sizeof *rx_ctx_arr)))
		return -FI_ENOMEM;

	/* Post recvs */
	for (i = 0; i < ep_cnt; i++) {
		if (rx_shared_ctx) {
			fprintf(stdout, "Posting recv #%d for shared rx ctx\n", i);
			ret = ft_post_rx(srx_ctx, rx_size, &rx_ctx_arr[i]);
		 } else {
			fprintf(stdout, "Posting recv for endpoint #%d\n", i);
			ret = ft_post_rx(ep_array[i], rx_size, &rx_ctx_arr[i]);
		 }
		if (ret)
			return ret;
	}

	if (opts.dst_addr) {
		/* Post sends addressed to remote EPs */
		for (i = 0; i < ep_cnt; i++) {
			if (tx_shared_ctx)
				fprintf(stdout, "Posting send #%d to shared tx ctx\n", i);
			else
				fprintf(stdout, "Posting send to endpoint #%d\n", i);
			ret = ft_tx(ep_array[i], addr_array[i], tx_size, &tx_ctx_arr[i]);
			if (ret)
				return ret;
		}
	}

	/* Wait for recv completions */
	ret = ft_get_rx_comp(rx_seq - 1);
	if (ret)
		return ret;

	if (!opts.dst_addr) {
		/* Post sends addressed to remote EPs */
		for (i = 0; i < ep_cnt; i++) {
			if (tx_shared_ctx)
				fprintf(stdout, "Posting send #%d to shared tx ctx\n", i);
			else
				fprintf(stdout, "Posting send to endpoint #%d\n", i);
			ret = ft_tx(ep_array[i], addr_array[i], tx_size, &tx_ctx_arr[i]);
			if (ret)
				return ret;
		}
	}

	return 0;
}
예제 #3
0
static int sync_test(void)
{
	int ret;

	ret = opts.dst_addr ? ft_tx(ep, remote_fi_addr, 1, &tx_ctx) : wait_for_recv_completion(1);
	if (ret)
		return ret;

	ret = opts.dst_addr ? wait_for_recv_completion(1) : ft_tx(ep, remote_fi_addr, 1, &tx_ctx);
	return ret;
}
예제 #4
0
int pingpong(void)
{
	int ret, i;

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

	if (opts.dst_addr) {
		for (i = 0; i < opts.iterations + opts.warmup_iterations; i++) {
			if (i == opts.warmup_iterations)
				ft_start();

			if (opts.transfer_size < fi->tx_attr->inject_size)
				ret = ft_inject(opts.transfer_size);
			else
				ret = ft_tx(opts.transfer_size);
			if (ret)
				return ret;

			ret = ft_rx(opts.transfer_size);
			if (ret)
				return ret;
		}
	} else {
		for (i = 0; i < opts.iterations + opts.warmup_iterations; i++) {
			if (i == opts.warmup_iterations)
				ft_start();

			ret = ft_rx(opts.transfer_size);
			if (ret)
				return ret;

			if (opts.transfer_size < fi->tx_attr->inject_size)
				ret = ft_inject(opts.transfer_size);
			else
				ret = ft_tx(opts.transfer_size);
			if (ret)
				return ret;
		}
	}
	ft_stop();

	if (opts.machr)
		show_perf_mr(opts.transfer_size, opts.iterations, &start, &end, 2, opts.argc, opts.argv);
	else
		show_perf(NULL, opts.transfer_size, opts.iterations, &start, &end, 2);

	return 0;
}
예제 #5
0
static int init_av(void)
{
	size_t addrlen;
	int ret;

	if (opts.dst_addr) {
		ret = ft_av_insert(av, fi->dest_addr, 1, &remote_fi_addr, 0, NULL);
		if (ret)
			return ret;

		addrlen = 64;
		ret = fi_getname(&ep->fid, tx_buf, &addrlen);
		if (ret) {
			FT_PRINTERR("fi_getname", ret);
			return ret;
		}

		ret = ft_tx(ep, remote_fi_addr, addrlen, &tx_ctx);
		if (ret)
			return ret;
	} else {
		ret = wait_for_recv_completion(1);
		if (ret)
			return ret;

		ret = ft_av_insert(av, rx_buf, 1, &remote_fi_addr, 0, NULL);
		if (ret)
			return ret;
	}

	return 0;
}
예제 #6
0
int send_recv_greeting(struct fid_ep *ep)
{
	int ret;
	const char *message = "Hello from Client!";
	size_t message_len = strlen(message) + 1;

	if (opts.dst_addr) {
		fprintf(stdout, "Sending message...\n");
		if (snprintf(tx_buf, tx_size, "%s", message) >= tx_size) {
			fprintf(stderr, "Transmit buffer too small.\n");
			return -FI_ETOOSMALL;
		}

		ret = ft_tx(ep, remote_fi_addr, message_len, &tx_ctx);
		if (ret)
			return ret;

		fprintf(stdout, "Send completion received\n");
	} else {
		fprintf(stdout, "Waiting for message from client...\n");
		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);
	}

	return 0;
}
예제 #7
0
static int run_test(void)
{
	int ret, i;

	ret = sync_test();
	if (ret) {
		fprintf(stderr, "sync_test failed!\n");
		goto out;
	}

	ft_start();
	if (opts.dst_addr) {
		for (i = 0; i < opts.iterations; i++) {
			ret = ft_tx(ep, remote_fi_addr, opts.transfer_size, &tx_ctx);
			if (ret)
				goto out;
		}
	} else {
		ret = wait_for_recv_completion(opts.iterations);
		if (ret)
			goto out;
	}
	ft_stop();

	if (opts.machr)
		show_perf_mr(opts.transfer_size, opts.iterations,
			&start, &end, 1, opts.argc, opts.argv);
	else
		show_perf(test_name, opts.transfer_size, opts.iterations,
			&start, &end, 1);

out:
	return ret;
}
예제 #8
0
static int stream(void)
{
	int ret, i;

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

	ft_start();
	for (i = 0; i < opts.iterations; i++) {
		ret = opts.dst_addr ?
			ft_tx(ep, remote_fi_addr, opts.transfer_size, &tx_ctx) : ft_rx(ep, opts.transfer_size);
		if (ret)
			return ret;
	}
	ft_stop();

	if (opts.machr)
		show_perf_mr(opts.transfer_size, opts.iterations, &start, &end, 1,
			     opts.argc, opts.argv);
	else
		show_perf(NULL, opts.transfer_size, opts.iterations, &start, &end, 1);

	return 0;
}
예제 #9
0
파일: shared.c 프로젝트: arsmith10/fabtests
int ft_sync()
{
	int ret;

	if (opts.dst_addr) {
		ret = ft_tx(1);
		if (ret)
			return ret;

		ret = ft_rx(1);
	} else {
		ret = ft_rx(1);
		if (ret)
			return ret;

		ret = ft_tx(1);
	}

	return ret;
}
예제 #10
0
int ft_sync()
{
	int ret;

	if (opts.dst_addr) {
		ret = ft_tx(ep, remote_fi_addr, 1, &tx_ctx);
		if (ret)
			return ret;

		ret = ft_rx(ep, 1);
	} else {
		ret = ft_rx(ep, 1);
		if (ret)
			return ret;

		ret = ft_tx(ep, remote_fi_addr, 1, &tx_ctx);
	}

	return ret;
}
예제 #11
0
파일: shared.c 프로젝트: arsmith10/fabtests
int ft_exchange_keys(struct fi_rma_iov *peer_iov)
{
	struct fi_rma_iov *rma_iov;
	int ret;

	if (opts.dst_addr) {
		rma_iov = tx_buf + ft_tx_prefix_size();
		rma_iov->addr = fi->domain_attr->mr_mode == FI_MR_SCALABLE ?
				0 : (uintptr_t) rx_buf + ft_rx_prefix_size();
		rma_iov->key = fi_mr_key(mr);
		ret = ft_tx(sizeof *rma_iov);
		if (ret)
			return ret;

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

		rma_iov = rx_buf + ft_rx_prefix_size();
		*peer_iov = *rma_iov;
		ret = ft_post_rx(rx_size);
	} else {
		ret = ft_get_rx_comp(rx_seq);
		if (ret)
			return ret;

		rma_iov = rx_buf + ft_rx_prefix_size();
		*peer_iov = *rma_iov;
		ret = ft_post_rx(rx_size);
		if (ret)
			return ret;

		rma_iov = tx_buf + ft_tx_prefix_size();
		rma_iov->addr = fi->domain_attr->mr_mode == FI_MR_SCALABLE ?
				0 : (uintptr_t) rx_buf + ft_rx_prefix_size();
		rma_iov->key = fi_mr_key(mr);
		ret = ft_tx(sizeof *rma_iov);
	}

	return ret;
}
예제 #12
0
파일: shared.c 프로젝트: arsmith10/fabtests
/* TODO: retry send for unreliable endpoints */
int ft_init_av(void)
{
	size_t addrlen;
	int ret;

	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(&ep->fid, (char *) tx_buf + ft_tx_prefix_size(),
				 &addrlen);
		if (ret) {
			FT_PRINTERR("fi_getname", ret);
			return ret;
		}

		ret = (int) ft_tx(addrlen);
		if (ret)
			return ret;

		ret = ft_rx(1);
	} else {
		ret = (int) ft_rx(FT_MAX_CTRL_MSG);
		if (ret)
			return ret;

		ret = ft_av_insert(av, (char *) rx_buf + ft_rx_prefix_size(),
				   1, &remote_fi_addr, 0, NULL);
		if (ret)
			return ret;

		ret = (int) ft_tx(1);
	}

	return ret;
}
예제 #13
0
파일: shared.c 프로젝트: arsmith10/fabtests
int send_recv_greeting(void)
{
	int ret;
	const char *message = "Hello from Client!";
	/* strlen doesn't include null terminated byte. snprintf size includes
	 * null terminated byte.
	 */
	size_t message_len = strlen(message) + 1;
	size_t recv_len;

	if (opts.dst_addr) {
		fprintf(stdout, "Sending message...\n");
		if (snprintf(tx_buf, tx_size, "%s", message) >= tx_size) {
			fprintf(stderr, "Transmit buffer too small.\n");
			return -FI_ETOOSMALL;
		}

		ret = ft_tx(message_len);
		if (ret)
			return ret;

		fprintf(stdout, "Send completion received\n");
	} else {
		fprintf(stdout, "Waiting for message from client...\n");
		ret = ft_get_rx_comp(rx_seq);
		if (ret)
			return ret;

		/* Account for null terminated byte. */
		recv_len = strlen(rx_buf) + 1;

		if (recv_len != message_len) {
			fprintf(stderr,
					"Received length does not match expected length.\n");
			return -1;
		}

		if (strncmp(rx_buf, message, MIN(recv_len, message_len))) {
			fprintf(stderr,
					"Received message does not match expected message.\n");
			return -1;
		}

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

	return 0;
}
예제 #14
0
static int send_recv()
{
	int ret;

	if (opts.dst_addr) {
		/* Client */
		fprintf(stdout, "Sending message to server...\n");
		sprintf(tx_buf, "Hello World!");
		ret = ft_tx(sizeof("Hello World!"));
		if (ret)
			return ret;

		fprintf(stdout, "Send completed\n");
	} else {
		fprintf(stdout, "Waiting for client...\n");
		ret = ft_get_rx_comp(rx_seq);
		if (ret)
			return ret;

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

	return 0;
}
예제 #15
0
파일: av_xfer.c 프로젝트: ofiwg/libfabric
static int av_removal_test(void)
{
	int ret;

	fprintf(stdout, "AV address removal: ");
	hints = fi_dupinfo(base_hints);
	if (!hints)
		return -FI_ENOMEM;

	ret = ft_init_fabric();
	if (ret)
		goto out;

	if (opts.dst_addr) {
		ret = ft_tx(ep, remote_fi_addr, opts.transfer_size, &tx_ctx);
		if (ret) {
			FT_PRINTERR("ft_tx", -ret);
			goto out;
		}

		ret = fi_av_remove(av, &remote_fi_addr, 1, 0);
		if (ret) {
			FT_PRINTERR("fi_av_remove", ret);
			goto out;
		}

		ret = ft_sync();
		if (ret)
			goto out;

		ret = ft_init_av();
		if (ret) {
			FT_PRINTERR("ft_init_av", -ret);
			goto out;
		}

		ret = ft_rx(ep, opts.transfer_size);
		if (ret) {
			FT_PRINTERR("ft_rx", -ret);
			goto out;
		}
	} else {
		ret = ft_rx(ep, opts.transfer_size);
		if (ret) {
			FT_PRINTERR("ft_rx", -ret);
			goto out;
		}

		ret = fi_av_remove(av, &remote_fi_addr, 1, 0);
		if (ret) {
			FT_PRINTERR("fi_av_remove", ret);
			goto out;
		}

		ret = ft_sync();
		if (ret)
			goto out;

		ret = ft_init_av();
		if (ret) {
			FT_PRINTERR("ft_init_av", -ret);
			goto out;
		}

		ret = ft_tx(ep, remote_fi_addr, opts.transfer_size, &tx_ctx);
		if (ret) {
			FT_PRINTERR("ft_tx", -ret);
			goto out;
		}
	}

	fprintf(stdout, "PASS\n");
	(void) ft_sync();
out:
	ft_free_res();
	return ret;
}
예제 #16
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;
}
예제 #17
0
static int init_av(void)
{
	int ret;
	int i;

	if (opts.dst_addr) {
		ret = ft_av_insert(av, fi->dest_addr, 1, &addr_array[0], 0, NULL);
		if (ret)
			return ret;
	}

	for (i = 0; i < ep_cnt; i++) {
		addrlen = tx_size;
		ret = fi_getname(&ep_array[i]->fid, tx_buf + ft_tx_prefix_size(),
				 &addrlen);
		if (ret) {
			FT_PRINTERR("fi_getname", ret);
			return ret;
		}

		if (opts.dst_addr) {
			ret = ft_tx(ep_array[0], addr_array[0], addrlen, &tx_ctx);
			if (ret)
				return ret;

			if (rx_shared_ctx)
				ret = ft_rx(srx_ctx, rx_size);
			else
				ret = ft_rx(ep_array[0], rx_size);
			if (ret)
				return ret;

			/* Skip the first address since we already have it in AV */
			if (i) {
				ret = ft_av_insert(av, rx_buf + ft_rx_prefix_size(), 1,
						   &addr_array[i], 0, NULL);
				if (ret)
					return ret;
			}
		} else {
			if (rx_shared_ctx)
				ret = ft_rx(srx_ctx, rx_size);
			else
				ret = ft_rx(ep_array[0], rx_size);
			if (ret)
				return ret;

			ret = ft_av_insert(av, rx_buf + ft_rx_prefix_size(), 1,
					   &addr_array[i], 0, NULL);
			if (ret)
				return ret;

			ret = ft_tx(ep_array[0], addr_array[0], addrlen, &tx_ctx);
			if (ret)
				return ret;

		}
	}

	/* ACK */
	if (opts.dst_addr) {
		ret = ft_tx(ep_array[0], addr_array[0], 1, &tx_ctx);
	} else {
		if (rx_shared_ctx)
			ret = ft_rx(srx_ctx, rx_size);
		else
			ret = ft_rx(ep_array[0], rx_size);
	}

	return ret;
}