Beispiel #1
0
/* Try opening fi->domain_attr->cq_cnt number of completion queues
 * simultaneously using a size hint of 0 (indicating the provider should choose
 * the size)
 */
static int cq_open_close_simultaneous(void)
{
	int ret;
	int opened;
	size_t count;
	int testret = FAIL;
	struct fid_cq **cq_array;

	count = fi->domain_attr->cq_cnt;
	FT_DEBUG("testing creation of up to %zu simultaneous CQs\n", count);

	cq_array = calloc(count, sizeof(*cq_array));
	if (!cq_array)
		return -FI_ENOMEM;

	ret = 0;
	for (opened = 0; opened < count && !ret; opened++) {
		ret = create_cq(&cq_array[opened], 0, 0, FI_CQ_FORMAT_UNSPEC,
				FI_WAIT_UNSPEC);
	}
	if (ret) {
		FT_WARN("fi_cq_open failed after %d (cq_cnt: %zu): %s",
			opened, count, fi_strerror(-ret));
	}

	testret = PASS;

	FT_CLOSEV_FID(cq_array, opened);
	free(cq_array);

	return TEST_RET_VAL(ret, testret);
}
Beispiel #2
0
static void free_res(void)
{
	if (rx_ep) {
		FT_CLOSEV_FID(rx_ep, ctx_cnt);
		free(rx_ep);
		rx_ep = NULL;
	}
	if (tx_ep) {
		FT_CLOSEV_FID(tx_ep, ctx_cnt);
		free(tx_ep);
		tx_ep = NULL;
	}
	if (rxcq_array) {
		FT_CLOSEV_FID(rxcq_array, ctx_cnt);
		free(rxcq_array);
		rxcq_array = NULL;
	}
	if (txcq_array) {
		FT_CLOSEV_FID(txcq_array, ctx_cnt);
		free(txcq_array);
		txcq_array = NULL;
	}
}
Beispiel #3
0
int main(int argc, char **argv)
{
	int op, ret;

	opts = INIT_OPTS;
	opts.options |= FT_OPT_SIZE;

	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
		switch (op) {
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "An RDM client-server example that uses shared context.\n");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];

	hints->ep_attr->type = FI_EP_RDM;
	hints->caps = FI_MSG | FI_NAMED_RX_CTX;
	hints->mode = FI_CONTEXT | FI_LOCAL_MR;
	hints->addr_format = FI_SOCKADDR;

	ret = run();

	FT_CLOSEV_FID(ep_array, ep_cnt);
	FT_CLOSE_FID(srx_ctx);
	FT_CLOSE_FID(stx_ctx);
	ft_free_res();
	free(addr_array);
	free(ep_array);
	return -ret;
}
Beispiel #4
0
int main(int argc, char **argv)
{
	int op, ret;
	int option_index = 0;

	struct option long_options[] = {
		{"no-tx-shared-ctx", no_argument, &tx_shared_ctx, 0},
		{"no-rx-shared-ctx", no_argument, &rx_shared_ctx, 0},
		{"ep-count", required_argument, 0, FT_EP_CNT},
		{0, 0, 0, 0},
	};

	opts = INIT_OPTS;
	opts.options |= FT_OPT_SIZE;

	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt_long(argc, argv, "h" ADDR_OPTS INFO_OPTS,
					long_options, &option_index)) != -1) {
		switch (op) {
		case FT_EP_CNT:
			ep_cnt = atoi(optarg);
			if (ep_cnt <= 0) {
				FT_ERR("ep_count needs to be greater than 0\n");
				return EXIT_FAILURE;
			}
			hints->domain_attr->ep_cnt = ep_cnt;
			break;
		default:
			ft_parse_addr_opts(op, optarg, &opts);
			ft_parseinfo(op, optarg, hints, &opts);
			break;
		case '?':
		case 'h':
			ft_usage(argv[0], "An RDM client-server example that uses"
				       " shared context.\n");
			FT_PRINT_OPTS_USAGE("--no-tx-shared-ctx",
					"Disable shared context for TX");
			FT_PRINT_OPTS_USAGE("--no-rx-shared-ctx",
					"Disable shared context for RX");
			FT_PRINT_OPTS_USAGE("--ep-count <count> (default: 4)",
					"# of endpoints to be opened");
			return EXIT_FAILURE;
		}
	}

	if (optind < argc)
		opts.dst_addr = argv[optind];

	hints->caps = FI_MSG;
	hints->mode = FI_CONTEXT;
	hints->domain_attr->mr_mode = opts.mr_mode;

	if (tx_shared_ctx)
		hints->ep_attr->tx_ctx_cnt = FI_SHARED_CONTEXT;
	if (rx_shared_ctx)
		hints->ep_attr->rx_ctx_cnt = FI_SHARED_CONTEXT;

	ret = run();

	FT_CLOSEV_FID(ep_array, ep_cnt);
	if (rx_shared_ctx)
		FT_CLOSE_FID(srx_ctx);
	if (tx_shared_ctx)
		FT_CLOSE_FID(stx_ctx);
	ft_free_res();
	free(addr_array);
	free(ep_array);
	fi_freeinfo(fi_dup);
	return ft_exit_code(ret);
}