File: mtl_psm2_stats.c

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (98 lines) | stat: -rw-r--r-- 4,081 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
 * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
 *                         University Research and Technology
 *                         Corporation.  All rights reserved.
 * Copyright (c) 2004-2010 The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
 *                         University of Stuttgart.  All rights reserved.
 * Copyright (c) 2004-2006 The Regents of the University of California.
 *                         All rights reserved.
 * Copyright (c) 2006      QLogic Corporation. All rights reserved.
 * Copyright (c) 2006-2017 Los Alamos National Security, LLC.  All rights
 *                         reserved.
 * Copyright (c) 2013-2015 Intel, Inc. All rights reserved
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#include "ompi_config.h"
#include "mtl_psm2.h"
#include "mtl_psm2_types.h"
#include "psm2.h"
#include "ompi/communicator/communicator.h"
#include "ompi/message/message.h"

#include "opal/mca/base/mca_base_pvar.h"

struct ompi_mtl_psm2_name_descs
{
    char *name;
    char *desc;
    ptrdiff_t offset;
};

const struct ompi_mtl_psm2_name_descs name_descs[PSM2_MQ_NUM_STATS] =
{
    { "rx_user_bytes", "Bytes received into a matched user buffer", 
      offsetof(struct psm2_mq_stats, rx_user_bytes) },
    { "rx_user_num", "Messages received into a matched user buffer",
      offsetof(struct psm2_mq_stats, rx_user_num) },
    { "rx_sys_bytes", "Bytes received into an unmatched system buffer",
      offsetof(struct psm2_mq_stats, rx_sys_bytes) },
    { "rx_sys_num", "Messages received into an unmatched system buffer",
      offsetof(struct psm2_mq_stats, rx_sys_num) },
    { "tx_num", "Total Messages transmitted (shm and hfi)",
      offsetof(struct psm2_mq_stats, tx_num) },
    { "tx_eager_num", "Messages transmitted eagerly",
      offsetof(struct psm2_mq_stats, tx_eager_num) },
    { "tx_eager_bytes", "Bytes transmitted eagerl",
      offsetof(struct psm2_mq_stats, tx_eager_bytes) },
    { "tx_rndv_num", "Messages transmitted using expected TID mechanism",
      offsetof(struct psm2_mq_stats, tx_rndv_num) },
    { "tx_rndv_bytes", "Bytes transmitted using expected TID mechanism",
      offsetof(struct psm2_mq_stats, tx_rndv_bytes) },
    { "tx_shm_num", "Messages transmitted (shm only)",
      offsetof(struct psm2_mq_stats, tx_shm_num) },
    { "rx_shm_num", "Messages received through shm",
      offsetof(struct psm2_mq_stats, rx_shm_num) },
    { "rx_sysbuf_num", "Number of system buffers allocated",
      offsetof(struct psm2_mq_stats, rx_sysbuf_num) },
    { "rx_sysbuf_bytes", "Bytes allocated for system buffers",
      offsetof(struct psm2_mq_stats, rx_sysbuf_bytes) },
};
 
static int mca_mtl_psm2_get_stats(const mca_base_pvar_t *pvar, void *value, void *obj)
{
    psm2_mq_stats_t stats;
    int index = (int)(intptr_t) pvar->ctx;

    psm2_mq_get_stats(ompi_mtl_psm2.mq, &stats);

    *(uint64_t *)value = *(uint64_t *)((uint8_t *)&stats + name_descs[index].offset); 

    return OMPI_SUCCESS;
}


int ompi_mtl_psm2_register_pvars(void)
{
    int i;

    /* PSM2 MQ performance variables */
    for (i = 0 ; i < PSM2_MQ_NUM_STATS; ++i) {
        (void) mca_base_component_pvar_register (&mca_mtl_psm2_component.super.mtl_version, 
                                                 name_descs[i].name, name_descs[i].desc,
                                                 OPAL_INFO_LVL_4, MCA_BASE_PVAR_CLASS_COUNTER,
                                                 MCA_BASE_VAR_TYPE_UNSIGNED_LONG,
                                                 NULL, MCA_BASE_VAR_BIND_NO_OBJECT,
                                                 MCA_BASE_PVAR_FLAG_READONLY | MCA_BASE_PVAR_FLAG_CONTINUOUS,
                                                 mca_mtl_psm2_get_stats, NULL, NULL,
                                                 (void *) (intptr_t) i);
    }
    return OMPI_SUCCESS;
}