Skip to content

Commit

Permalink
fabtests/common: use common device host buffer for check_buf
Browse files Browse the repository at this point in the history
The tx_msg_buf is a host buffer allocated with the hmem interface
which is used as a staging buffer for validation data to copy into the
device transfer buffer once filled with data. Currently, the tx_msg_buf
is onsly used on the fill_buf path but it can also be used on check_buf,
eliminating the need to alloc and free the staging buffer on every
transfer.

This also renames the tx_msg_buf variable to a more generic name
(dev_host_buf) since it is used on both the send and receive paths

Signed-off-by: Alexia Ingerson <[email protected]>
  • Loading branch information
aingerson authored and shefty committed Sep 30, 2023
1 parent 824f339 commit 8b3cee1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
31 changes: 13 additions & 18 deletions fabtests/common/shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ int ft_socket_pair[2];
fi_addr_t remote_fi_addr = FI_ADDR_UNSPEC;
char *buf = NULL, *tx_buf, *rx_buf;
/*
* tx_msg_buf are used by ft_fill_buf() to stage data sent over wire,
* dev_host_buf are used by ft_fill_buf() to stage data sent over wire,
* when tx_buf is on device memory.
*/
void *tx_msg_buf = NULL;
void *dev_host_buf = NULL;

char **tx_mr_bufs = NULL, **rx_mr_bufs = NULL;
size_t buf_size, tx_buf_size, rx_buf_size;
Expand Down Expand Up @@ -504,10 +504,10 @@ void ft_free_host_tx_buf(void)
{
int ret;

ret = ft_hmem_free_host(opts.iface, tx_msg_buf);
ret = ft_hmem_free_host(opts.iface, dev_host_buf);
if (ret)
FT_PRINTERR("ft_hmem_free_host", ret);
tx_msg_buf = NULL;
dev_host_buf = NULL;
}

/*
Expand Down Expand Up @@ -580,7 +580,7 @@ int ft_alloc_msgs(void)
max_msg_size = (opts.options & FT_OPT_ALLOC_MULT_MR)
? tx_mr_size : tx_size;

/* tx_msg_buf is used by ft_fill_buf() and ft_check_buf() as
/* dev_host_buf is used by ft_fill_buf() and ft_check_buf() as
* staging area to copy data to and from device buffer during
* data setup and verification.
*
Expand All @@ -591,7 +591,7 @@ int ft_alloc_msgs(void)
* a window started, and check all data in a window after
* a window completed.
*/
ret = ft_hmem_alloc_host(opts.iface, &tx_msg_buf,
ret = ft_hmem_alloc_host(opts.iface, &dev_host_buf,
max_msg_size * opts.window_size);
if (ret)
return ret;
Expand Down Expand Up @@ -1773,7 +1773,7 @@ void ft_free_res(void)
buf = rx_buf = tx_buf = NULL;
buf_size = rx_size = tx_size = tx_mr_size = rx_mr_size = 0;
}
if (tx_msg_buf)
if (dev_host_buf)
ft_free_host_tx_buf();

if (fi_pep) {
Expand Down Expand Up @@ -3430,8 +3430,8 @@ int ft_fill_buf(void *buf, size_t size)
int ret = 0;

if (opts.iface != FI_HMEM_SYSTEM) {
assert(tx_msg_buf);
msg_buf = tx_msg_buf;
assert(dev_host_buf);
msg_buf = dev_host_buf;
} else {
msg_buf = (char *) buf;
}
Expand Down Expand Up @@ -3460,14 +3460,12 @@ int ft_check_buf(void *buf, size_t size)
int ret = 0;

if (opts.iface != FI_HMEM_SYSTEM) {
recv_data = malloc(size);
if (!recv_data)
return -FI_ENOMEM;

assert(dev_host_buf);
ret = ft_hmem_copy_from(opts.iface, opts.device,
recv_data, buf, size);
dev_host_buf, buf, size);
if (ret)
goto out;
return ret;
recv_data = (char *)dev_host_buf;
} else {
recv_data = (char *)buf;
}
Expand All @@ -3485,9 +3483,6 @@ int ft_check_buf(void *buf, size_t size)
ret = -FI_EIO;
}

out:
if (opts.iface != FI_HMEM_SYSTEM)
free(recv_data);
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion fabtests/functional/unexpected_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static int alloc_bufs(void)
return ret;

if (opts.iface != FI_HMEM_SYSTEM) {
ret = ft_hmem_alloc_host(opts.iface, &tx_msg_buf,
ret = ft_hmem_alloc_host(opts.iface, &dev_host_buf,
tx_size * opts.window_size);
if (ret)
return ret;
Expand Down
2 changes: 1 addition & 1 deletion fabtests/include/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ extern struct fid_mc *mc;

extern fi_addr_t remote_fi_addr;
extern char *buf, *tx_buf, *rx_buf;
extern void *tx_msg_buf;
extern void *dev_host_buf;
extern struct ft_context *tx_ctx_arr, *rx_ctx_arr;
extern char **tx_mr_bufs, **rx_mr_bufs;
extern size_t buf_size, tx_size, rx_size, tx_mr_size, rx_mr_size;
Expand Down
2 changes: 1 addition & 1 deletion fabtests/ubertest/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ static int ft_setup_bufs(void)
if (ret)
return ret;

ret = ft_hmem_alloc_host(opts.iface, &tx_msg_buf,
ret = ft_hmem_alloc_host(opts.iface, &dev_host_buf,
ft_ctrl.size_array[ft_ctrl.size_cnt - 1]);
if (ret)
return ret;
Expand Down

0 comments on commit 8b3cee1

Please sign in to comment.