HPCToolkit
cct2metrics.h
Go to the documentation of this file.
1 #ifndef CCT2METRICS_H
2 #define CCT2METRICS_H
3 
4 //
5 // cct_node -> metrics map
6 //
7 #include <stdbool.h>
8 
9 #include <hpcrun/metrics.h>
10 #include <cct/cct.h>
11 
12 
13 //
14 // ******** Typedef ********
15 //
16 //
18 //
19 // ******** initialization
20 //
21 // The cct2metrics map gets explicit reference
22 // only at initialization time.
23 //
24 // Thereafter, the interface ops refer to it
25 // implicitly.
26 // [Singleton pattern for GangOf4 enthusiasts]
27 
28 extern void hpcrun_cct2metrics_init(cct2metrics_t** map);
29 
30 // ******** Interface operations **********
31 //
32 
33 //
34 // for a given cct node, return the metric set
35 // associated with it.
36 //
37 // if there are no metrics for the node, then
38 // create a metric set, and return it.
39 //
41 
42 //
43 // get metric set for a node (NULL value is ok).
44 //
46 
48 
49 //
50 // check to see if node already has metrics
51 //
52 extern bool hpcrun_has_metric_set(cct_node_id_t cct_id);
53 
55 
56 //extern cct2metrics_t* cct2metrics_new(cct_node_id_t node, metric_set_t* metrics);
57 
58 typedef enum {SET, INCR} update_metric_t;
59 
60 static inline void
61 cct_metric_data_update(int metric_id,
62  cct_node_t* x, update_metric_t type,
63  cct_metric_data_t incr)
64 {
65  if (! hpcrun_has_metric_set(x)) {
67  }
69 
70  if (type == SET)
71  hpcrun_metric_std_set(metric_id, set, incr);
72  else if (type == INCR)
73  hpcrun_metric_std_inc(metric_id, set, incr);
74 }
75 
76 
77 static inline void
78 cct_metric_data_set(int metric_id,
79  cct_node_t* x,
81 {
82  cct_metric_data_update(metric_id, x, SET, val);
83 }
84 
85 static inline void
87  cct_node_t* x,
88  cct_metric_data_t incr)
89 {
90  cct_metric_data_update(metric_id, x, INCR, incr);
91 }
92 
93 
94 
95 #endif // CCT2METRICS_H
bool hpcrun_has_metric_set(cct_node_id_t cct_id)
Definition: cct2metrics.c:172
void cct2metrics_assoc(cct_node_t *node, metric_set_t *metrics)
metric_set_t * hpcrun_get_metric_set(cct_node_id_t cct_id)
Definition: cct2metrics.c:163
cct_node_t * node
Definition: cct.c:128
void hpcrun_metric_std_set(int metric_id, metric_set_t *set, hpcrun_metricVal_t value)
Definition: metrics.c:525
static void cct_metric_data_increment(int metric_id, cct_node_t *x, cct_metric_data_t incr)
Definition: cct2metrics.h:86
static void cct_metric_data_update(int metric_id, cct_node_t *x, update_metric_t type, cct_metric_data_t incr)
Definition: cct2metrics.h:61
static void cct_metric_data_set(int metric_id, cct_node_t *x, cct_metric_data_t val)
Definition: cct2metrics.h:78
int metrics[MAX_EVENTS][MAX_METRICS]
Definition: generic.c:147
Definition: cct.c:96
metric_set_t * hpcrun_metric_set_new(void)
Definition: metrics.c:456
metric_set_t * hpcrun_get_metric_set_specific(cct2metrics_t **map, cct_node_id_t cct_id)
Definition: cct2metrics.c:135
metric_set_t * hpcrun_reify_metric_set(cct_node_id_t cct_id)
Definition: cct2metrics.c:115
void hpcrun_metric_std_inc(int metric_id, metric_set_t *set, hpcrun_metricVal_t incr)
Definition: metrics.c:534
update_metric_t
Definition: cct2metrics.h:58
void hpcrun_cct2metrics_init(cct2metrics_t **map)
Definition: cct2metrics.c:52