Skip to content

Commit c060ccd

Browse files
committed
UCP/DT: Add stats for struct dt
1 parent 9dc9e85 commit c060ccd

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/ucp/core/ucp_request.c

+2
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ UCS_PROFILE_FUNC(ucs_status_t, ucp_request_memory_reg,
268268
s, buffer, nc_memh);
269269
/* SET memh properly */
270270
state->dt.struct_dt.non_contig.memh[0] = nc_memh;
271+
UCS_STATS_UPDATE_COUNTER(s->stats, UCP_DT_STRUCT_STAT_IN_CACHE, 1);
271272
return UCS_OK;
272273
}
273274

@@ -304,6 +305,7 @@ UCS_PROFILE_FUNC(ucs_status_t, ucp_request_memory_reg,
304305
if (status != UCS_OK) {
305306
goto err;
306307
}
308+
UCS_STATS_UPDATE_COUNTER(s->stats, UCP_DT_STRUCT_STAT_CREATE, 1);
307309

308310
break;
309311
default:

src/ucp/dt/dt_struct.c

+24
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222
#include <string.h>
2323
#include <unistd.h>
2424

25+
#if ENABLE_STATS
26+
static ucs_stats_class_t ucp_dt_struct_stats_class = {
27+
.name = "dt_struct",
28+
.num_counters = UCP_DT_STRUCT_STAT_LAST,
29+
.counter_names = {
30+
[UCP_DT_STRUCT_STAT_CREATE] = "create",
31+
[UCP_DT_STRUCT_STAT_IN_CACHE] = "reuse"
32+
}
33+
};
34+
#endif
35+
2536
ucs_status_t _struct_register_ep_rec(uct_ep_h ep, void *buf, ucp_dt_struct_t *s,
2637
uct_mem_h contig_memh, uct_mem_h* memh);
2738

@@ -222,6 +233,7 @@ ucs_status_t ucp_dt_create_struct(ucp_struct_dt_desc_t *desc_ptr,
222233
size_t desc_count, size_t rep_count,
223234
ucp_datatype_t *datatype_p)
224235
{
236+
ucs_status_t status;
225237
ucp_dt_struct_t *dt;
226238
size_t i;
227239

@@ -269,6 +281,17 @@ ucs_status_t ucp_dt_create_struct(ucp_struct_dt_desc_t *desc_ptr,
269281
_set_struct_attributes(dt);
270282
*datatype_p = ((uintptr_t)dt) | UCP_DATATYPE_STRUCT;
271283

284+
285+
286+
status = UCS_STATS_NODE_ALLOC(&dt->stats,
287+
&ucp_dt_struct_stats_class,
288+
ucs_stats_get_root(), "%p-%d-%d",
289+
dt, desc_count, rep_count);
290+
if (status != UCS_OK) {
291+
ucs_error("Can't allocate stats: %s", ucs_status_string(status));
292+
return status;
293+
}
294+
272295
ucs_info("Created struct dt %p, len %ld (step %ld), depth %ld, uct_iovs %ld, rep count %ld",
273296
dt, dt->len, dt->step_len, dt->depth, dt->uct_iov_count, dt->rep_count);
274297

@@ -290,6 +313,7 @@ void ucp_dt_destroy_struct(ucp_datatype_t datatype_p)
290313
})
291314
kh_destroy_inplace(dt_struct, &dt->hash);
292315
ucs_free(dt->desc);
316+
UCS_STATS_NODE_FREE(dt->stats);
293317
ucs_free(dt);
294318
}
295319

src/ucp/dt/dt_struct.h

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <ucs/datastruct/khash.h>
1212
#include <uct/api/uct.h>
1313
#include <ucp/core/ucp_types.h>
14+
#include <ucs/stats/stats.h>
1415

1516
typedef struct ucp_dt_struct_hash_value {
1617
uct_md_h md;
@@ -36,6 +37,12 @@ int main() {
3637
}
3738
*/
3839

40+
enum {
41+
UCP_DT_STRUCT_STAT_CREATE,
42+
UCP_DT_STRUCT_STAT_IN_CACHE,
43+
UCP_DT_STRUCT_STAT_LAST
44+
};
45+
3946
/**
4047
* Structured datatype structure.
4148
*/
@@ -48,6 +55,7 @@ typedef struct ucp_dt_struct {
4855
size_t extent; /* total contig space covering the whole type */
4956
ptrdiff_t lb_displ; /* the lowest displacement from which extent is effective */
5057
khash_t(dt_struct) hash;
58+
UCS_STATS_NODE_DECLARE(stats);
5159
} ucp_dt_struct_t;
5260

5361
static inline ucp_dt_struct_t* ucp_dt_struct(ucp_datatype_t datatype)

0 commit comments

Comments
 (0)