Skip to content

Commit

Permalink
CODESTYLE: Call clear attr func
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarka committed Sep 11, 2024
1 parent 14b42c2 commit 1896c15
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 180 deletions.
7 changes: 7 additions & 0 deletions src/components/base/ucc_base_iface.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ typedef struct ucc_base_ctx_attr_t {
uint32_t topo_required;
} ucc_base_ctx_attr_t;

static inline void ucc_base_ctx_attr_clear(ucc_base_ctx_attr_t *attr)
{
uint32_t mask = attr->attr.mask;
memset(attr, 0, sizeof(ucc_base_ctx_attr_t));
attr->attr.mask = mask;
}

typedef struct ucc_base_context_iface {
ucc_status_t (*create)(const ucc_base_context_params_t *params,
const ucc_base_config_t *config,
Expand Down
27 changes: 1 addition & 26 deletions src/components/cl/basic/cl_basic_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,33 +73,8 @@ ucc_cl_basic_get_context_attr(const ucc_base_context_t *context,
ucc_status_t status;
int i;

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR_LEN) {
attr->attr.ctx_addr_len = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR) {
attr->attr.ctx_addr = 0x0;
}

/* Global work buffer size is read directly from TL attr, so report 0
* here even if TL/UCP is enabled
*/
if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_WORK_BUFFER_SIZE) {
attr->attr.global_work_buffer_size = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_TYPE) {
attr->attr.type = UCC_CONTEXT_EXCLUSIVE;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_SYNC_TYPE) {
attr->attr.sync_type = UCC_NO_SYNC_COLLECTIVES;
}
ucc_base_ctx_attr_clear(attr);

/* CL BASIC reports topo_required if any of the TL available
* TL contexts needs it
*/
attr->topo_required = 0;
for (i = 0; i < ctx->super.n_tl_ctxs; i++) {
memset(&tl_attr, 0, sizeof(tl_attr));
status = UCC_TL_CTX_IFACE(ctx->super.tl_ctxs[i])
Expand Down
5 changes: 1 addition & 4 deletions src/components/cl/doca_urom/cl_doca_urom_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,6 @@ ucc_status_t
ucc_cl_doca_urom_get_context_attr(const ucc_base_context_t *context,
ucc_base_ctx_attr_t *attr)
{
if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR_LEN) {
attr->attr.ctx_addr_len = 0;
}

ucc_base_ctx_attr_clear(attr);
return UCC_OK;
}
22 changes: 1 addition & 21 deletions src/components/cl/hier/cl_hier_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,7 @@ ucc_status_t
ucc_cl_hier_get_context_attr(const ucc_base_context_t *context, /* NOLINT */
ucc_base_ctx_attr_t *attr)
{
if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR_LEN) {
attr->attr.ctx_addr_len = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR) {
attr->attr.ctx_addr = 0x0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_WORK_BUFFER_SIZE) {
attr->attr.global_work_buffer_size = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_TYPE) {
attr->attr.type = UCC_CONTEXT_EXCLUSIVE;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_SYNC_TYPE) {
attr->attr.sync_type = UCC_NO_SYNC_COLLECTIVES;
}

ucc_base_ctx_attr_clear(attr);
attr->topo_required = 1;

return UCC_OK;
}
22 changes: 1 addition & 21 deletions src/components/tl/cuda/tl_cuda_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,7 @@ ucc_status_t
ucc_tl_cuda_get_context_attr(const ucc_base_context_t *context, /* NOLINT */
ucc_base_ctx_attr_t *attr)
{
if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR_LEN) {
attr->attr.ctx_addr_len = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR) {
attr->attr.ctx_addr = 0x0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_WORK_BUFFER_SIZE) {
attr->attr.global_work_buffer_size = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_TYPE) {
attr->attr.type = UCC_CONTEXT_EXCLUSIVE;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_SYNC_TYPE) {
attr->attr.sync_type = UCC_NO_SYNC_COLLECTIVES;
}

ucc_base_ctx_attr_clear(attr);
attr->topo_required = 1;

return UCC_OK;
}
22 changes: 1 addition & 21 deletions src/components/tl/mlx5/tl_mlx5_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,28 +93,8 @@ ucc_status_t
ucc_tl_mlx5_get_context_attr(const ucc_base_context_t *context, /* NOLINT */
ucc_base_ctx_attr_t *attr)
{
if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR_LEN) {
attr->attr.ctx_addr_len = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR) {
attr->attr.ctx_addr = 0x0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_WORK_BUFFER_SIZE) {
attr->attr.global_work_buffer_size = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_TYPE) {
attr->attr.type = UCC_CONTEXT_EXCLUSIVE;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_SYNC_TYPE) {
attr->attr.sync_type = UCC_NO_SYNC_COLLECTIVES;
}

ucc_base_ctx_attr_clear(attr);
attr->topo_required = 1;

return UCC_OK;
}

Expand Down
23 changes: 1 addition & 22 deletions src/components/tl/nccl/tl_nccl_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,27 +220,6 @@ ucc_status_t
ucc_tl_nccl_get_context_attr(const ucc_base_context_t *context, /* NOLINT */
ucc_base_ctx_attr_t *attr)
{
if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR_LEN) {
attr->attr.ctx_addr_len = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR) {
attr->attr.ctx_addr = 0x0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_WORK_BUFFER_SIZE) {
attr->attr.global_work_buffer_size = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_TYPE) {
attr->attr.type = UCC_CONTEXT_EXCLUSIVE;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_SYNC_TYPE) {
attr->attr.sync_type = UCC_NO_SYNC_COLLECTIVES;
}

attr->topo_required = 0;

ucc_base_ctx_attr_clear(attr);
return UCC_OK;
}
23 changes: 1 addition & 22 deletions src/components/tl/rccl/tl_rccl_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,27 +117,6 @@ ucc_status_t
ucc_tl_rccl_get_context_attr(const ucc_base_context_t *context, /* NOLINT */
ucc_base_ctx_attr_t *attr)
{
if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR_LEN) {
attr->attr.ctx_addr_len = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR) {
attr->attr.ctx_addr = 0x0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_WORK_BUFFER_SIZE) {
attr->attr.global_work_buffer_size = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_TYPE) {
attr->attr.type = UCC_CONTEXT_EXCLUSIVE;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_SYNC_TYPE) {
attr->attr.sync_type = UCC_NO_SYNC_COLLECTIVES;
}

attr->topo_required = 0;

ucc_base_ctx_attr_clear(attr);
return UCC_OK;
}
23 changes: 1 addition & 22 deletions src/components/tl/self/tl_self_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,6 @@ ucc_status_t
ucc_tl_self_get_context_attr(const ucc_base_context_t *context, /* NOLINT */
ucc_base_ctx_attr_t *attr)
{
if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR_LEN) {
attr->attr.ctx_addr_len = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR) {
attr->attr.ctx_addr = 0x0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_WORK_BUFFER_SIZE) {
attr->attr.global_work_buffer_size = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_TYPE) {
attr->attr.type = UCC_CONTEXT_EXCLUSIVE;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_SYNC_TYPE) {
attr->attr.sync_type = UCC_NO_SYNC_COLLECTIVES;
}

attr->topo_required = 0;

ucc_base_ctx_attr_clear(attr);
return UCC_OK;
}
22 changes: 1 addition & 21 deletions src/components/tl/sharp/tl_sharp_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,27 +506,7 @@ UCC_CLASS_DEFINE(ucc_tl_sharp_context_t, ucc_tl_context_t);
ucc_status_t ucc_tl_sharp_get_context_attr(const ucc_base_context_t *context, /* NOLINT */
ucc_base_ctx_attr_t *attr)
{
if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR_LEN) {
attr->attr.ctx_addr_len = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_CTX_ADDR) {
attr->attr.ctx_addr = 0x0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_WORK_BUFFER_SIZE) {
attr->attr.global_work_buffer_size = 0;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_TYPE) {
attr->attr.type = UCC_CONTEXT_EXCLUSIVE;
}

if (attr->attr.mask & UCC_CONTEXT_ATTR_FIELD_SYNC_TYPE) {
attr->attr.sync_type = UCC_NO_SYNC_COLLECTIVES;
}

ucc_base_ctx_attr_clear(attr);
attr->topo_required = 1;

return UCC_OK;
}
2 changes: 2 additions & 0 deletions src/components/tl/ucp/tl_ucp_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ ucc_status_t ucc_tl_ucp_get_context_attr(const ucc_base_context_t *context,
size_t packed_length;
int i;

ucc_base_ctx_attr_clear(attr);

if (attr->attr.mask & (UCC_CONTEXT_ATTR_FIELD_CTX_ADDR_LEN |
UCC_CONTEXT_ATTR_FIELD_CTX_ADDR)) {
if (NULL == ctx->worker.worker_address) {
Expand Down

0 comments on commit 1896c15

Please sign in to comment.