Skip to content

Commit

Permalink
Merge pull request #699 from bturrubiates/pr/check-prefix
Browse files Browse the repository at this point in the history
Ensure prefix hint is respected for -k.
  • Loading branch information
shefty authored Aug 3, 2017
2 parents c0fbcee + f1591ca commit d5f844a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
6 changes: 3 additions & 3 deletions benchmarks/benchmark_shared.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015-2017 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2013-2015 Intel Corporation. All rights reserved.
*
* This software is available to you under a choice of one of two
Expand Down Expand Up @@ -46,7 +46,7 @@ void ft_parse_benchmark_opts(int op, char *optarg)
opts.options |= FT_OPT_VERIFY_DATA;
break;
case 'k':
hints->mode |= FI_MSG_PREFIX;
ft_force_prefix(hints, &opts);
break;
case 'j':
hints->tx_attr->inject_size = atoi(optarg);
Expand All @@ -62,7 +62,7 @@ void ft_parse_benchmark_opts(int op, char *optarg)
void ft_benchmark_usage(void)
{
FT_PRINT_OPTS_USAGE("-v", "enables data_integrity checks");
FT_PRINT_OPTS_USAGE("-k", "enable prefix mode");
FT_PRINT_OPTS_USAGE("-k", "force prefix mode");
FT_PRINT_OPTS_USAGE("-j", "maximum inject message size");
FT_PRINT_OPTS_USAGE("-W", "window size* (for bandwidth tests)\n\n"
"* The following condition is required to have at least "
Expand Down
8 changes: 7 additions & 1 deletion common/shared.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2013-2017 Intel Corporation. All rights reserved.
* Copyright (c) 2016 Cray Inc. All rights reserved.
* Copyright (c) 2014-2016, Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2014-2017, Cisco Systems, Inc. All rights reserved.
*
* This software is available to you under the BSD license below:
*
Expand Down Expand Up @@ -562,6 +562,12 @@ int ft_getinfo(struct fi_info *hints, struct fi_info **info)
FT_PRINTERR("fi_getinfo", ret);
return ret;
}

if (!ft_check_prefix_forced(*info, &opts)) {
FT_ERR("Provider disabled requested prefix mode.");
return -FI_ENODATA;
}

return 0;
}

Expand Down
31 changes: 30 additions & 1 deletion include/shared.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2017 Intel Corporation. All rights reserved.
* Copyright (c) 2014-2016, Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2014-2017, Cisco Systems, Inc. All rights reserved.
*
* This software is available to you under the BSD license below:
*
Expand Down Expand Up @@ -141,6 +141,9 @@ struct ft_opts {
int machr;
enum ft_rma_opcodes rma_op;
int argc;

/* Fail if the selected provider does not support FI_MSG_PREFIX. */
int force_prefix;
char **argv;
};

Expand Down Expand Up @@ -344,6 +347,32 @@ static inline void ft_stop(void)
clock_gettime(CLOCK_MONOTONIC, &end);
opts.options &= ~FT_OPT_ACTIVE;
}

/* Set the FI_MSG_PREFIX mode bit in the given fi_info structure and also set
* the option bit in the given opts structure. If using ft_getinfo, it will
* return -ENODATA if the provider clears the application requested mdoe bit.
*/
static inline void ft_force_prefix(struct fi_info *info, struct ft_opts *opts)
{
info->mode |= FI_MSG_PREFIX;
opts->force_prefix = 1;
}

/* If force_prefix was not requested, just continue. If it was requested,
* return true if it was respected by the provider.
*/
static inline bool ft_check_prefix_forced(struct fi_info *info,
struct ft_opts *opts)
{
if (opts->force_prefix) {
return (info->tx_attr->mode & FI_MSG_PREFIX) &&
(info->rx_attr->mode & FI_MSG_PREFIX);
}

/* Continue if forced prefix wasn't requested. */
return true;
}

int ft_sync();
int ft_sync_pair(int status);
int ft_fork_and_pair();
Expand Down

0 comments on commit d5f844a

Please sign in to comment.