22
22
#include <string.h>
23
23
#include <unistd.h>
24
24
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
+
25
36
ucs_status_t _struct_register_ep_rec (uct_ep_h ep , void * buf , ucp_dt_struct_t * s ,
26
37
uct_mem_h contig_memh , uct_mem_h * memh );
27
38
@@ -222,6 +233,7 @@ ucs_status_t ucp_dt_create_struct(ucp_struct_dt_desc_t *desc_ptr,
222
233
size_t desc_count , size_t rep_count ,
223
234
ucp_datatype_t * datatype_p )
224
235
{
236
+ ucs_status_t status ;
225
237
ucp_dt_struct_t * dt ;
226
238
size_t i ;
227
239
@@ -269,6 +281,17 @@ ucs_status_t ucp_dt_create_struct(ucp_struct_dt_desc_t *desc_ptr,
269
281
_set_struct_attributes (dt );
270
282
* datatype_p = ((uintptr_t )dt ) | UCP_DATATYPE_STRUCT ;
271
283
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
+
272
295
ucs_info ("Created struct dt %p, len %ld (step %ld), depth %ld, uct_iovs %ld, rep count %ld" ,
273
296
dt , dt -> len , dt -> step_len , dt -> depth , dt -> uct_iov_count , dt -> rep_count );
274
297
@@ -290,6 +313,7 @@ void ucp_dt_destroy_struct(ucp_datatype_t datatype_p)
290
313
})
291
314
kh_destroy_inplace (dt_struct , & dt -> hash );
292
315
ucs_free (dt -> desc );
316
+ UCS_STATS_NODE_FREE (dt -> stats );
293
317
ucs_free (dt );
294
318
}
295
319
0 commit comments