Skip to content

Commit

Permalink
UCP/DT: Add stats for struct dt
Browse files Browse the repository at this point in the history
  • Loading branch information
brminich committed Apr 3, 2020
1 parent 9dc9e85 commit c060ccd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ucp/core/ucp_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ UCS_PROFILE_FUNC(ucs_status_t, ucp_request_memory_reg,
s, buffer, nc_memh);
/* SET memh properly */
state->dt.struct_dt.non_contig.memh[0] = nc_memh;
UCS_STATS_UPDATE_COUNTER(s->stats, UCP_DT_STRUCT_STAT_IN_CACHE, 1);
return UCS_OK;
}

Expand Down Expand Up @@ -304,6 +305,7 @@ UCS_PROFILE_FUNC(ucs_status_t, ucp_request_memory_reg,
if (status != UCS_OK) {
goto err;
}
UCS_STATS_UPDATE_COUNTER(s->stats, UCP_DT_STRUCT_STAT_CREATE, 1);

break;
default:
Expand Down
24 changes: 24 additions & 0 deletions src/ucp/dt/dt_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
#include <string.h>
#include <unistd.h>

#if ENABLE_STATS
static ucs_stats_class_t ucp_dt_struct_stats_class = {
.name = "dt_struct",
.num_counters = UCP_DT_STRUCT_STAT_LAST,
.counter_names = {
[UCP_DT_STRUCT_STAT_CREATE] = "create",
[UCP_DT_STRUCT_STAT_IN_CACHE] = "reuse"
}
};
#endif

ucs_status_t _struct_register_ep_rec(uct_ep_h ep, void *buf, ucp_dt_struct_t *s,
uct_mem_h contig_memh, uct_mem_h* memh);

Expand Down Expand Up @@ -222,6 +233,7 @@ ucs_status_t ucp_dt_create_struct(ucp_struct_dt_desc_t *desc_ptr,
size_t desc_count, size_t rep_count,
ucp_datatype_t *datatype_p)
{
ucs_status_t status;
ucp_dt_struct_t *dt;
size_t i;

Expand Down Expand Up @@ -269,6 +281,17 @@ ucs_status_t ucp_dt_create_struct(ucp_struct_dt_desc_t *desc_ptr,
_set_struct_attributes(dt);
*datatype_p = ((uintptr_t)dt) | UCP_DATATYPE_STRUCT;



status = UCS_STATS_NODE_ALLOC(&dt->stats,
&ucp_dt_struct_stats_class,
ucs_stats_get_root(), "%p-%d-%d",
dt, desc_count, rep_count);
if (status != UCS_OK) {
ucs_error("Can't allocate stats: %s", ucs_status_string(status));
return status;
}

ucs_info("Created struct dt %p, len %ld (step %ld), depth %ld, uct_iovs %ld, rep count %ld",
dt, dt->len, dt->step_len, dt->depth, dt->uct_iov_count, dt->rep_count);

Expand All @@ -290,6 +313,7 @@ void ucp_dt_destroy_struct(ucp_datatype_t datatype_p)
})
kh_destroy_inplace(dt_struct, &dt->hash);
ucs_free(dt->desc);
UCS_STATS_NODE_FREE(dt->stats);
ucs_free(dt);
}

Expand Down
8 changes: 8 additions & 0 deletions src/ucp/dt/dt_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <ucs/datastruct/khash.h>
#include <uct/api/uct.h>
#include <ucp/core/ucp_types.h>
#include <ucs/stats/stats.h>

typedef struct ucp_dt_struct_hash_value {
uct_md_h md;
Expand All @@ -36,6 +37,12 @@ int main() {
}
*/

enum {
UCP_DT_STRUCT_STAT_CREATE,
UCP_DT_STRUCT_STAT_IN_CACHE,
UCP_DT_STRUCT_STAT_LAST
};

/**
* Structured datatype structure.
*/
Expand All @@ -48,6 +55,7 @@ typedef struct ucp_dt_struct {
size_t extent; /* total contig space covering the whole type */
ptrdiff_t lb_displ; /* the lowest displacement from which extent is effective */
khash_t(dt_struct) hash;
UCS_STATS_NODE_DECLARE(stats);
} ucp_dt_struct_t;

static inline ucp_dt_struct_t* ucp_dt_struct(ucp_datatype_t datatype)
Expand Down

0 comments on commit c060ccd

Please sign in to comment.