Exemplo n.º 1
0
int main(int argc, char **argv)
{
	int op, ret, option_index;
	int use_hints = 0;

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

	hints->mode = ~0;
	hints->domain_attr->mode = ~0;
	hints->domain_attr->mr_mode = ~(FI_MR_BASIC | FI_MR_SCALABLE);

	while ((op = getopt_long(argc, argv, "n:P:c:m:t:a:p:d:f:elhv", longopts,
				 &option_index)) != -1) {
		switch (op) {
		case 0:
			/* there is no short variant only for --version */
			if (ver) {
				printf("%s: %s\n", argv[0], PACKAGE_VERSION);
				printf("libfabric: %s\n", fi_tostr("1", FI_TYPE_VERSION));
				printf("libfabric api: %d.%d\n",
				       FI_MAJOR_VERSION, FI_MINOR_VERSION);
				return EXIT_SUCCESS;
			}
			goto print_help;
		case 'n':
			node = optarg;
			break;
		case 'P':
			port = optarg;
			break;
		case 'c':
			ret = tokparse(optarg, str2cap, &hints->caps);
			if (ret)
				goto out;

			use_hints = 1;
			break;
		case 'm':
			hints->mode = 0;
			ret = tokparse(optarg, str2mode, &hints->mode);
			if (ret)
				goto out;

			use_hints = 1;
			break;
		case 't':
			ret = str2ep_type(optarg, &hints->ep_attr->type);
			if (ret)
				goto out;

			use_hints = 1;
			break;
		case 'a':
			ret = str2addr_format(optarg, &hints->addr_format);
			if (ret)
				goto out;

			use_hints = 1;
			break;
		case 'p':
			free(hints->fabric_attr->prov_name);
			hints->fabric_attr->prov_name = strdup(optarg);
			use_hints = 1;
			break;
		case 'd':
			hints->domain_attr->name = strdup(optarg);
			use_hints = 1;
			break;
		case 'f':
			hints->fabric_attr->name = strdup(optarg);
			use_hints = 1;
			break;
		case 'e':
			env = 1;
			break;
		case 'l':
			list_providers = 1;
			break;
		case 'v':
			verbose = 1;
			break;
		case 'h':
		default:
print_help:
			printf("Usage: %s\n", argv[0]);
			usage();
			return EXIT_FAILURE;
		}
	}

	ret = run(use_hints ? hints : NULL, node, port);

out:
	fi_freeinfo(hints);
	return -ret;
}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
	int op, ret, option_index;
	int use_hints = 0;

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

	hints->mode = ~0;

	while ((op = getopt_long(argc, argv, "n:p:c:m:t:a:f:ehv", longopts, &option_index)) != -1) {
		switch (op) {
		case 0:
			/* If --verbose set a flag, do nothing. */
			if (longopts[option_index].flag != 0)
				break;
		case 'n':
			node = optarg;
			break;
		case 'p':
			port = optarg;
			break;
		case 'c':
			hints->caps = tokparse(optarg, str2cap);
			use_hints = 1;
			break;
		case 'm':
			hints->mode = tokparse(optarg, str2mode);
			use_hints = 1;
			break;
		case 't':
			hints->ep_attr->type = str2ep_type(optarg);
			use_hints = 1;
			break;
		case 'a':
			hints->addr_format = str2addr_format(optarg);
			use_hints = 1;
			break;
		case 'f':
			hints->fabric_attr->prov_name = strdup(optarg);
			use_hints = 1;
			break;
		case 'v':
			verbose = 1;
			break;
		case 'h':
		default:
			printf("Usage: %s\n", argv[0]);
			usage();
			return EXIT_FAILURE;
		}
	}

	if (ver) {
		printf("%s: %s\n", argv[0], PACKAGE_VERSION);
		printf("libfabric: %s\n", fi_tostr("1", FI_TYPE_VERSION));
		printf("libfabric api: %d.%d\n", FI_MAJOR_VERSION, FI_MINOR_VERSION);
		return EXIT_SUCCESS;
	}

	ret = run(use_hints ? hints : NULL, node, port);
	fi_freeinfo(hints);
	return -ret;
}