Skip to content

Commit

Permalink
fabtests/hmem: change ZE memset to use uint8
Browse files Browse the repository at this point in the history
Match the behavior of memset() where the value passed in
is an int, but it is interpreted as a char.
While ZE can technically handle this scenario, others may not
so we need to standardize across ifaces

Signed-off-by: Alexia Ingerson <[email protected]>
  • Loading branch information
aingerson committed Sep 19, 2024
1 parent 6e84d68 commit 7232814
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions fabtests/common/hmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ int ft_hmem_free_host(enum fi_hmem_iface iface, void *buf)
return hmem_ops[iface].free_host(buf);
}

/*
* Matches the behavior of memset where value is an int but
* used as a unsigned char
*/
int ft_hmem_memset(enum fi_hmem_iface iface, uint64_t device, void *buf,
int value, size_t size)
{
Expand Down
4 changes: 3 additions & 1 deletion fabtests/common/hmem_ze.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,16 @@ int ft_ze_free(void *buf)

int ft_ze_memset(uint64_t device, void *buf, int value, size_t size)
{
unsigned char set_value = (unsigned char) value;
ze_result_t ze_ret;

ze_ret = (*libze_ops.zeCommandListReset)(cmd_list);
if (ze_ret)
return -FI_EINVAL;

ze_ret = (*libze_ops.zeCommandListAppendMemoryFill)(
cmd_list, buf, &value, sizeof(value),
cmd_list, buf, &set_value,
sizeof(set_value),
size, NULL, 0, NULL);
if (ze_ret)
return -FI_EINVAL;
Expand Down

0 comments on commit 7232814

Please sign in to comment.