From 8829d25b87a070d217c9ffc90ad6694fd729be11 Mon Sep 17 00:00:00 2001 From: snordmann Date: Mon, 22 May 2023 12:43:18 +0300 Subject: [PATCH] TL/MLX5: minor reviews --- src/components/tl/mlx5/tl_mlx5.h | 10 ++-------- src/components/tl/mlx5/tl_mlx5_rcache.c | 12 ++++++------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/components/tl/mlx5/tl_mlx5.h b/src/components/tl/mlx5/tl_mlx5.h index a8676c5a9a..7c7c122962 100644 --- a/src/components/tl/mlx5/tl_mlx5.h +++ b/src/components/tl/mlx5/tl_mlx5.h @@ -99,16 +99,10 @@ UCC_CLASS_DECLARE(ucc_tl_mlx5_team_t, ucc_base_context_t *, ucc_status_t tl_mlx5_rcache_create(ucc_tl_mlx5_context_t *ctx); typedef struct ucc_tl_mlx5_reg { - struct ibv_mr * mr; - ucs_rcache_region_t *region; + ucc_rcache_region_t *super; + struct ibv_mr *mr; } ucc_tl_mlx5_reg_t; -static inline ucc_tl_mlx5_reg_t * -ucc_tl_mlx5_get_rcache_reg_data(ucc_rcache_region_t *region) -{ - return (ucc_tl_mlx5_reg_t *)PTR_OFFSET(region, sizeof(ucc_rcache_region_t)); -} - #define UCC_TL_MLX5_SUPPORTED_COLLS (UCC_COLL_TYPE_ALLTOALL) #define UCC_TL_MLX5_TEAM_LIB(_team) \ diff --git a/src/components/tl/mlx5/tl_mlx5_rcache.c b/src/components/tl/mlx5/tl_mlx5_rcache.c index 05dd63dd3f..b22bb6dcc6 100644 --- a/src/components/tl/mlx5/tl_mlx5_rcache.c +++ b/src/components/tl/mlx5/tl_mlx5_rcache.c @@ -13,13 +13,13 @@ rcache_reg_mr(void *context, ucs_rcache_t *rcache, //NOLINT: rcache is unused { ucc_tl_mlx5_context_t *ctx = (ucc_tl_mlx5_context_t *)context; void * addr = (void *)rregion->super.start; - ucc_tl_mlx5_reg_t * mlx5_reg = ucc_tl_mlx5_get_rcache_reg_data( - rregion); + ucc_tl_mlx5_reg_t * mlx5_reg = ucc_derived_of(rregion, + ucc_tl_mlx5_reg_t); size_t length = (size_t)(rregion->super.end - rregion->super.start); int * change_flag = (int *)arg; - mlx5_reg->region = rregion; + mlx5_reg->super = rregion; *change_flag = 1; mlx5_reg->mr = ibv_reg_mr(ctx->shared_pd, addr, length, IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE); @@ -30,13 +30,13 @@ rcache_reg_mr(void *context, ucs_rcache_t *rcache, //NOLINT: rcache is unused return UCS_OK; } -static void rcache_dereg_mr(void * context, //NOLINT: context is unused +static void rcache_dereg_mr(void *context, //NOLINT: context is unused ucc_rcache_t *rcache, //NOLINT: rcache is unused ucc_rcache_region_t *rregion) { - ucc_tl_mlx5_reg_t *mlx5_reg = ucc_tl_mlx5_get_rcache_reg_data(rregion); + ucc_tl_mlx5_reg_t *mlx5_reg = ucc_derived_of(rregion, ucc_tl_mlx5_reg_t); - ucc_assert(mlx5_reg->region == rregion); + ucc_assert(mlx5_reg->super == rregion); ibv_dereg_mr(mlx5_reg->mr); mlx5_reg->mr = NULL; }