Skip to content

Commit

Permalink
prov/verbs: Optimize search for device max inline size
Browse files Browse the repository at this point in the history
Let the user set the FI_VERBS_INLINE_SIZE environment variable to
decide the maximum size of an inline transfer. The getinfo call will
check if the device is capable of this size. If it is capable it will
use it. If it not capable then the size is too big and we can goto the
backwards search to find the largest inline size that is smaller than
the FI_VERBS_INLINE_SIZE variable.

If a user wants the maximum inject size that a device can do then they
should set this FI_VERBS_INLINE_SIZE variable to 0 so that the device
can find its largest inject size.

Signed-off-by: Zach Dworkin <zachary.dworkin@intel.com>
  • Loading branch information
zachdworkin authored and j-xiong committed Jun 27, 2024
1 parent a11979f commit 27dd4ae
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
6 changes: 4 additions & 2 deletions man/fi_verbs.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ The verbs provider checks for the following environment variables.
deprecated) EP type supports only 1

*FI_VERBS_INLINE_SIZE*
: Default maximum inline size. Actual inject size returned in fi_info
may be greater (default: 64)
: Maximum inline size for the verbs device. Actual inline size returned may be
different depending on device capability. This value will be returned by
fi_info as the inject size for the application to use. Set to 0 for the
maximum device inline size to be used. (default: 256).

*FI_VERBS_MIN_RNR_TIMER*
: Set min_rnr_timer QP attribute (0 - 31) (default: 12)
Expand Down
31 changes: 27 additions & 4 deletions prov/verbs/src/verbs_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ int vrb_find_max_inline(struct ibv_pd *pd, struct ibv_context *context,
struct ibv_cq *cq;
int max_inline = 2;
int rst = 0;
int pos, neg;
const char *dev_name = ibv_get_device_name(context->device);
uint8_t i;

Expand All @@ -502,6 +503,21 @@ int vrb_find_max_inline(struct ibv_pd *pd, struct ibv_context *context,
}
qp_attr.sq_sig_all = 1;

if (vrb_gl_data.def_inline_size >= max_inline) {
qp_attr.cap.max_inline_data = vrb_gl_data.def_inline_size;
qp = ibv_create_qp(pd, &qp_attr);
if (qp) {
rst = qp_attr.cap.max_inline_data;
goto out;
}

/*
* Truescale and iWarp will not reach here.
*/
max_inline = vrb_gl_data.def_inline_size;
goto backwards_query;
}

do {
if (qp)
ibv_destroy_qp(qp);
Expand All @@ -527,7 +543,8 @@ int vrb_find_max_inline(struct ibv_pd *pd, struct ibv_context *context,
} while (qp && (max_inline < INT_MAX / 2) && (max_inline *= 2));

if (rst != 0) {
int pos = rst, neg = max_inline;
backwards_query: ;
pos = rst, neg = max_inline;
do {
max_inline = pos + (neg - pos) / 2;
if (qp)
Expand All @@ -545,6 +562,7 @@ int vrb_find_max_inline(struct ibv_pd *pd, struct ibv_context *context,
rst = pos;
}

out:
if (qp) {
ibv_destroy_qp(qp);
}
Expand Down Expand Up @@ -643,9 +661,14 @@ int vrb_read_params(void)
VRB_WARN(FI_LOG_CORE, "Invalid value of rx_iov_limit\n");
return -FI_EINVAL;
}
if (vrb_get_param_int("inline_size", "Default maximum inline size. "
"Actual inject size returned in fi_info may be "
"greater", &vrb_gl_data.def_inline_size) ||
if (vrb_get_param_int("inline_size", "Maximum inline size for the "
"verbs device. Actual inline size returned may "
"be different depending on device capability. "
"This value will be returned by fi_info as the "
"inject size for the application to use. Set to "
"0 for the maximum device inline size to be "
"used. (default: 256).",
&vrb_gl_data.def_inline_size) ||
(vrb_gl_data.def_inline_size < 0)) {
VRB_WARN(FI_LOG_CORE, "Invalid value of inline_size\n");
return -FI_EINVAL;
Expand Down

0 comments on commit 27dd4ae

Please sign in to comment.