Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UCT/IB: Skip multi-thread memory registration for symmetric key #9447

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/uct/ib/mlx5/dv/ib_mlx5dv_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ static void uct_ib_mlx5_devx_reg_symmetric(uct_ib_mlx5_md_t *md,
uint32_t symmetric_rkey;
ucs_status_t status;

ucs_assert(!(memh->super.flags & UCT_IB_MEM_MULTITHREADED));

/* Best effort, only allocate in the range below the atomic keys. */
while (md->smkey_index < md->super.mkey_by_name_reserve.size) {
status = uct_ib_mlx5_devx_reg_ksm_data_contig(
Expand Down Expand Up @@ -588,6 +590,12 @@ static void uct_ib_mlx5_devx_reg_symmetric(uct_ib_mlx5_md_t *md,
md->super.mkey_by_name_reserve.base + start);
}

static UCS_F_ALWAYS_INLINE int
uct_ib_mlx5_devx_symmetric_rkey(const uct_ib_mlx5_md_t *md, unsigned flags)
{
return (flags & UCT_MD_MEM_SYMMETRIC_RKEY) &&
(md->flags & UCT_IB_MLX5_MD_FLAG_MKEY_BY_NAME_RESERVE);
}

static ucs_status_t
uct_ib_mlx5_devx_reg_mr(uct_ib_mlx5_md_t *md, uct_ib_mlx5_devx_mem_t *memh,
Expand All @@ -598,11 +606,14 @@ uct_ib_mlx5_devx_reg_mr(uct_ib_mlx5_md_t *md, uct_ib_mlx5_devx_mem_t *memh,
{
uint64_t access_flags = uct_ib_memh_access_flags(&md->super, &memh->super) &
access_mask;
unsigned flags = UCT_MD_MEM_REG_FIELD_VALUE(params, flags,
FIELD_FLAGS, 0);
ucs_status_t status;
uint32_t mkey;

if ((length >= md->super.config.min_mt_reg) &&
!(access_flags & IBV_ACCESS_ON_DEMAND)) {
!(access_flags & IBV_ACCESS_ON_DEMAND) &&
!uct_ib_mlx5_devx_symmetric_rkey(md, flags)) {
/* Verbs transports can issue atomic operations to the default key */
status = uct_ib_mlx5_devx_reg_mt(md, address, length,
(memh->super.flags &
Expand Down Expand Up @@ -672,8 +683,7 @@ uct_ib_mlx5_devx_mem_reg(uct_md_h uct_md, void *address, size_t length,
goto err_memh_free;
}

if ((flags & UCT_MD_MEM_SYMMETRIC_RKEY) &&
(md->flags & UCT_IB_MLX5_MD_FLAG_MKEY_BY_NAME_RESERVE)) {
if (uct_ib_mlx5_devx_symmetric_rkey(md, flags)) {
uct_ib_mlx5_devx_reg_symmetric(md, memh, address);
}

Expand Down
15 changes: 14 additions & 1 deletion test/gtest/uct/ib/test_ib_md.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class test_ib_md : public test_md
uct_rkey_t *rkey_p = NULL);
void check_smkeys(uct_rkey_t rkey1, uct_rkey_t rkey2);

void test_smkey_reg_atomic(void);

private:
#ifdef HAVE_MLX5_DV
uint32_t m_mlx5_flags = 0;
Expand Down Expand Up @@ -197,7 +199,7 @@ void test_ib_md::check_smkeys(uct_rkey_t rkey1, uct_rkey_t rkey2)
uct_ib_md_atomic_rkey(rkey2) - uct_ib_md_direct_rkey(rkey2));
}

UCS_TEST_P(test_ib_md, smkey_reg_atomic)
void test_ib_md::test_smkey_reg_atomic(void)
{
static const size_t size = 8192;
void *buffer;
Expand All @@ -222,4 +224,15 @@ UCS_TEST_P(test_ib_md, smkey_reg_atomic)
ucs_mmap_free(buffer, size);
}

UCS_TEST_P(test_ib_md, smkey_reg_atomic)
{
test_smkey_reg_atomic();
}

UCS_TEST_P(test_ib_md, smkey_reg_atomic_mt, "REG_MT_THRESH=1k",
"REG_MT_CHUNK=1k")
{
test_smkey_reg_atomic();
}

_UCT_MD_INSTANTIATE_TEST_CASE(test_ib_md, ib)
Loading