本文整理汇总了C++中FI_VERSION函数的典型用法代码示例。如果您正苦于以下问题:C++ FI_VERSION函数的具体用法?C++ FI_VERSION怎么用?C++ FI_VERSION使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FI_VERSION函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: usdf_fabric_checkname
static bool usdf_fabric_checkname(uint32_t version,
struct usd_device_attrs *dap, const char *hint)
{
int ret;
bool valid = false;
char *reference;
USDF_DBG("checking devname: version=%d, devname='%s'\n", version, hint);
if (version) {
ret = usdf_fabric_getname(version, dap, &reference);
if (ret < 0)
return false;
if (strcmp(reference, hint) == 0) {
valid = true;
} else {
USDF_DBG("hint %s failed to match %s\n", hint,
reference);
}
free(reference);
return valid;
}
/* The hint string itself is kind of a version check, in pre-1.4 the
* name was just the device name. In 1.4 and beyond, then name is
* actually CIDR
* notation.
*/
if (strstr(hint, "/"))
return usdf_fabric_checkname(FI_VERSION(1, 4), dap, hint);
return usdf_fabric_checkname(FI_VERSION(1, 3), dap, hint);
}
示例2: Test
Test(endpoint_info, info)
{
int ret;
hints = fi_allocinfo();
cr_assert(hints, "fi_allocinfo");
hints->fabric_attr->prov_name = strdup("gni");
ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, hints, &fi);
cr_assert(!ret, "fi_getinfo");
cr_assert_eq(fi->ep_attr->type, FI_EP_RDM);
cr_assert_eq(fi->next->ep_attr->type, FI_EP_DGRAM);
cr_assert_eq(fi->next->next->ep_attr->type, FI_EP_MSG);
fi_freeinfo(fi);
hints->ep_attr->type = FI_EP_RDM;
ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, hints, &fi);
cr_assert(!ret, "fi_getinfo");
cr_assert_eq(fi->ep_attr->type, FI_EP_RDM);
fi_freeinfo(fi);
hints->ep_attr->type = FI_EP_DGRAM;
ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, hints, &fi);
cr_assert(!ret, "fi_getinfo");
cr_assert_eq(fi->ep_attr->type, FI_EP_DGRAM);
fi_freeinfo(fi);
fi_freeinfo(hints);
}
示例3: do_invalid_fi_getinfo
/*
* Note: the default addr_format is FI_ADDR_STR unless use_str_fmt is otherwise
* set to false.
*/
void do_invalid_fi_getinfo(void)
{
int i, ret;
for (i = 0; i < NUMEPS; i++) {
/*
* This test is to ensure that gni provider fails to provide
* info if the FI_ADDR_STR format is being used and both the
* node and service parameters are non-NULL.
*
* See the fi_getinfo man page DESCRIPTION section.
*/
ret = fi_getinfo(FI_VERSION(1, 5), "this is a test", "testing",
0, hints, &fi[i]);
cr_assert(ret == -FI_ENODATA, "fi_getinfo returned: %s",
fi_strerror(-ret));
fi_freeinfo(fi[i]);
/*
* This test is to ensure that the gni provider does not allow
* FI_ADDR_STR to be used with api versions <= 1.5.
*/
ret = fi_getinfo(FI_VERSION(1, 0), NULL, NULL, 0, hints,
&fi[i]);
cr_assert(ret == -FI_ENODATA, "fi_getinfo returned: %s",
fi_strerror(-ret));
fi_freeinfo(fi[i]);
}
}
示例4: usdf_domain_checkname
/* In pre-1.4 the domain name was NULL. This is unfortunate as it makes it
* difficult to tell whether providing a name was intended. In this case, it can
* be broken into 4 cases:
*
* 1. Version is greater than or equal to 1.4 and a non-NULL hint is provided.
* Just do a string compare.
* 2. Version is greater than or equal to 1.4 and provided hint is NULL. Treat
* this as _valid_ as it could be an application requesting a 1.4 domain name
* but not providing an explicit hint.
* 3. Version is less than 1.4 and a name hint is provided. This should always
* be _invalid_.
* 4. Version is less than 1.4 and name hint is NULL. This will always be
* _valid_.
*/
bool usdf_domain_checkname(uint32_t version, struct usd_device_attrs *dap,
const char *hint)
{
char *reference;
bool valid;
int ret;
USDF_DBG("checking domain name: version=%d, domain name='%s'\n",
version, hint);
if (version) {
valid = false;
ret = usdf_domain_getname(version, dap, &reference);
if (ret < 0)
return false;
/* If the reference name exists, then this is version 1.4 or
* greater.
*/
if (reference) {
if (hint) {
/* Case 1 */
valid = (strcmp(reference, hint) == 0);
} else {
/* Case 2 */
valid = true;
}
} else {
/* Case 3 & 4 */
valid = (hint == NULL);
}
if (!valid)
USDF_DBG("given hint %s does not match %s -- invalid\n",
hint, reference);
free(reference);
return valid;
}
/* If hint is non-NULL then assume the version is 1.4 if not provided.
*/
if (hint)
return usdf_domain_checkname(FI_VERSION(1, 4), dap, hint);
return usdf_domain_checkname(FI_VERSION(1, 3), dap, hint);
}
示例5: ofi_get_info_caps
static uint64_t ofi_get_info_caps(const struct fi_info *prov_info,
const struct fi_info *user_info,
uint32_t api_version)
{
int prov_mode, user_mode;
uint64_t caps;
assert(user_info);
caps = ofi_get_caps(prov_info->caps, user_info->caps, prov_info->caps);
prov_mode = prov_info->domain_attr->mr_mode;
if (!ofi_rma_target_allowed(caps) ||
!(prov_mode & OFI_MR_MODE_RMA_TARGET))
return caps;
if (!user_info->domain_attr)
goto trim_caps;
user_mode = user_info->domain_attr->mr_mode;
if ((FI_VERSION_LT(api_version, FI_VERSION(1,5)) &&
(user_mode == FI_MR_UNSPEC)) ||
(user_mode == FI_MR_BASIC) ||
((user_mode & prov_mode & OFI_MR_MODE_RMA_TARGET) ==
(prov_mode & OFI_MR_MODE_RMA_TARGET)))
return caps;
trim_caps:
return caps & ~(FI_REMOTE_WRITE | FI_REMOTE_READ);
}
示例6: ofi_alter_info
/*
* Alter the returned fi_info based on the user hints. We assume that
* the hints have been validated and the starting fi_info is properly
* configured by the provider.
*/
void ofi_alter_info(struct fi_info *info, const struct fi_info *hints,
uint32_t api_version)
{
if (!hints)
return;
for (; info; info = info->next) {
/* This should stay before call to fi_alter_domain_attr as
* the checks depend on unmodified provider mr_mode attr */
info->caps = ofi_get_info_caps(info, hints, api_version);
if ((info->domain_attr->mr_mode & FI_MR_LOCAL) &&
(FI_VERSION_LT(api_version, FI_VERSION(1, 5)) ||
(hints && hints->domain_attr &&
(hints->domain_attr->mr_mode & (FI_MR_BASIC | FI_MR_SCALABLE)))))
info->mode |= FI_LOCAL_MR;
info->handle = hints->handle;
fi_alter_domain_attr(info->domain_attr, hints->domain_attr,
info->caps, api_version);
fi_alter_ep_attr(info->ep_attr, hints->ep_attr, info->caps);
fi_alter_rx_attr(info->rx_attr, hints->rx_attr, info->caps);
fi_alter_tx_attr(info->tx_attr, hints->tx_attr, info->caps);
}
}
示例7: fi_alter_domain_attr
static void fi_alter_domain_attr(struct fi_domain_attr *attr,
const struct fi_domain_attr *hints,
uint64_t info_caps, uint32_t api_version)
{
int hints_mr_mode;
hints_mr_mode = hints ? hints->mr_mode : 0;
if (hints_mr_mode & (FI_MR_BASIC | FI_MR_SCALABLE)) {
attr->mr_mode = hints_mr_mode;
} else if (FI_VERSION_LT(api_version, FI_VERSION(1, 5))) {
attr->mr_mode = (attr->mr_mode && attr->mr_mode != FI_MR_SCALABLE) ?
FI_MR_BASIC : FI_MR_SCALABLE;
} else {
if ((hints_mr_mode & attr->mr_mode) != attr->mr_mode) {
attr->mr_mode = ofi_cap_mr_mode(info_caps,
attr->mr_mode & hints_mr_mode);
}
}
attr->caps = ofi_get_caps(info_caps, hints ? hints->caps : 0, attr->caps);
if (!hints)
return;
if (hints->threading)
attr->threading = hints->threading;
if (hints->control_progress)
attr->control_progress = hints->control_progress;
if (hints->data_progress)
attr->data_progress = hints->data_progress;
if (hints->av_type)
attr->av_type = hints->av_type;
}
示例8: run
static int run(struct fi_info *hints, char *node, char *port)
{
struct fi_info *info;
int ret;
uint64_t flags;
flags = list_providers ? FI_PROV_ATTR_ONLY : 0;
ret = fi_getinfo(FI_VERSION(FI_MAJOR_VERSION, FI_MINOR_VERSION),
node, port, flags, hints, &info);
if (ret) {
fprintf(stderr, "fi_getinfo: %d\n", ret);
return ret;
}
if (env)
ret = print_vars();
else if (verbose)
ret = print_long_info(info);
else if (list_providers)
ret = print_providers(info);
else
ret = print_short_info(info);
fi_freeinfo(info);
return ret;
}
示例9: usdf_fabric_getname
static int usdf_fabric_getname(uint32_t version, struct usd_device_attrs *dap,
char **name)
{
int ret = FI_SUCCESS;
char *bufp = NULL;
struct in_addr in;
char *addrnetw;
if (FI_VERSION_GE(version, FI_VERSION(1, 4))) {
in.s_addr = dap->uda_ipaddr_be & dap->uda_netmask_be;
addrnetw = inet_ntoa(in);
ret = asprintf(&bufp, "%s/%d", addrnetw, dap->uda_prefixlen);
if (ret < 0) {
USDF_DBG(
"asprintf failed while creating fabric name\n");
ret = -ENOMEM;
}
} else {
bufp = strdup(dap->uda_devname);
if (!bufp) {
USDF_DBG("strdup failed while creating fabric name\n");
ret = -errno;
}
}
*name = bufp;
return ret;
}
示例10: usdf_check_mr_mode
/* A wrapper function to core utility function to check mr_mode bits.
* We need to check some more things for backward compatibility.
*/
int usdf_check_mr_mode(uint32_t version, const struct fi_info *hints,
uint64_t prov_mode)
{
int ret;
ret = ofi_check_mr_mode(version, prov_mode,
hints->domain_attr->mr_mode);
/* If ofi_check_mr_mode fails. */
if (ret) {
/* Is it because the user give 0 as mr_mode? */
if (hints->domain_attr->mr_mode == 0) {
if (FI_VERSION_LT(version, FI_VERSION(1, 5))) {
/* If the version is < 1.5, it is ok.
* We let this slide and catch it later on.
*/
return FI_SUCCESS;
} else if (hints->mode & FI_LOCAL_MR) {
/* If version is >= 1.5, we check fi_info mode
* for FI_LOCAL_MR for backward compatibility.
*/
return FI_SUCCESS;
}
}
}
return ret;
}
示例11: dg_setup_prog_manual
void dg_setup_prog_manual(void)
{
int ret = 0;
hints = fi_allocinfo();
cr_assert(hints, "fi_allocinfo");
hints->domain_attr->cq_data_size = 4;
hints->domain_attr->control_progress = FI_PROGRESS_MANUAL;
hints->mode = ~0;
hints->fabric_attr->name = strdup("gni");
ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, hints, &fi);
cr_assert(!ret, "fi_getinfo");
ret = fi_fabric(fi->fabric_attr, &fab, NULL);
cr_assert(!ret, "fi_fabric");
ret = fi_domain(fab, fi, &dom, NULL);
cr_assert(!ret, "fi_domain");
ret = fi_endpoint(dom, fi, &ep, NULL);
cr_assert(!ret, "fi_endpoint");
}
示例12: usdf_catch_dom_attr
/* Catch the version changes for domain_attr. */
int usdf_catch_dom_attr(uint32_t version, const struct fi_info *hints,
struct fi_domain_attr *dom_attr)
{
/* version 1.5 introduced new bits. If the user asked for older
* version, we can't return these new bits.
*/
if (FI_VERSION_LT(version, FI_VERSION(1, 5))) {
/* We checked mr_mode compatibility before calling
* this function. This means it is safe to return
* 1.4 default mr_mode.
*/
dom_attr->mr_mode = FI_MR_BASIC;
/* FI_REMOTE_COMM is introduced in 1.5. So don't return it. */
dom_attr->caps &= ~FI_REMOTE_COMM;
/* If FI_REMOTE_COMM is given for version < 1.5, fail. */
if (hints && hints->domain_attr) {
if (hints->domain_attr->caps == FI_REMOTE_COMM)
return -FI_EBADFLAGS;
}
}
return FI_SUCCESS;
}
示例13: rdm_sr_bnd_ep_setup
void rdm_sr_bnd_ep_setup(void)
{
int ret = 0, i = 0;
char my_hostname[HOST_NAME_MAX];
hints = fi_allocinfo();
cr_assert(hints, "fi_allocinfo");
hints->domain_attr->cq_data_size = NUMEPS * 2;
hints->mode = ~0;
hints->fabric_attr->name = strdup("gni");
ret = gethostname(my_hostname, sizeof(my_hostname));
cr_assert(!ret, "gethostname");
for (; i < NUMEPS; i++) {
ret = fi_getinfo(FI_VERSION(1, 0), my_hostname,
cdm_id[i], 0, hints, fi + i);
cr_assert(!ret, "fi_getinfo");
}
using_bnd_ep = 1;
rdm_sr_setup_common();
}
示例14: cntr_setup_eps
static inline void cntr_setup_eps(void)
{
int i, ret;
struct fi_av_attr attr;
hints = fi_allocinfo();
cr_assert(hints, "fi_allocinfo");
hints->domain_attr->cq_data_size = 4;
hints->mode = ~0;
hints->fabric_attr->name = strdup("gni");
ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, hints, &fi);
cr_assert(!ret, "fi_getinfo");
ret = fi_fabric(fi->fabric_attr, &fab, NULL);
cr_assert(!ret, "fi_fabric");
ret = fi_domain(fab, fi, &dom, NULL);
cr_assert(!ret, "fi_domain");
attr.type = FI_AV_MAP;
attr.count = 16;
ret = fi_av_open(dom, &attr, &av, NULL);
cr_assert(!ret, "fi_av_open");
for (i = 0; i < NUM_EPS; i++) {
ret = fi_endpoint(dom, fi, &ep[i], NULL);
cr_assert(!ret, "fi_endpoint");
}
}
示例15: ofi_eq_handle_err_entry
void ofi_eq_handle_err_entry(uint32_t api_version,
struct fi_eq_err_entry *err_entry,
struct fi_eq_err_entry *user_err_entry)
{
if ((FI_VERSION_GE(api_version, FI_VERSION(1, 5)))
&& user_err_entry->err_data && user_err_entry->err_data_size) {
void *err_data = user_err_entry->err_data;
size_t err_data_size = MIN(err_entry->err_data_size,
user_err_entry->err_data_size);
memcpy(err_data, err_entry->err_data, err_data_size);
*user_err_entry = *err_entry;
user_err_entry->err_data = err_data;
user_err_entry->err_data_size = err_data_size;
free(err_entry->err_data);
err_entry->err_data = NULL;
err_entry->err_data_size = 0;
} else {
*user_err_entry = *err_entry;
}
err_entry->err = 0;
err_entry->prov_errno = 0;
}