cctools
rmsummary.h
1 /*
2 Copyright (C) 2013- The University of Notre Dame This software is
3 distributed under the GNU General Public License. See the file
4 COPYING for details.
5 */
6 
7 #ifndef __RMSUMMARY_H
8 #define __RMSUMMARY_H
9 
10 #include <stdio.h>
11 #include <stdlib.h>
12 
13 #include "jx.h"
14 #include "int_sizes.h"
15 #include "buffer.h"
16 
17 /* Environment variables names */
18 #define RESOURCES_CORES "CORES"
19 #define RESOURCES_MEMORY "MEMORY"
20 #define RESOURCES_DISK "DISK"
21 #define RESOURCES_WALL_TIME "WALL_TIME"
22 #define RESOURCES_GPUS "GPUS"
23 #define RESOURCES_MPI_PROCESSES "MPI_PROCESSES"
24 
25 // These fields are defined as signed integers, even though they
26 // will only contain positive numbers. This is to conversion to
27 // signed quantities when comparing to maximum limits.
28 struct rmsummary
29 {
30  char *category;
31  char *command;
32  char *taskid;
33 
34  int64_t start; /* usecs */
35  int64_t end; /* usecs */
36 
37  char *exit_type;
38  int64_t signal;
39  int64_t exit_status;
40  int64_t last_error;
41 
42  int64_t wall_time; /* usecs */
43  int64_t total_processes;
44  int64_t max_concurrent_processes;
45  int64_t cpu_time; /* usecs */
46  int64_t virtual_memory; /* MB */
47  int64_t memory; /* MB. a.k.a. resident memory */
48  int64_t swap_memory; /* MB */
49 
50  int64_t bytes_read; /* B */
51  int64_t bytes_written; /* B */
52 
53  int64_t bytes_sent; /* B */
54  int64_t bytes_received; /* B */
55  int64_t bandwidth; /* bps */
56 
57  int64_t total_files;
58  int64_t disk; /* MB */
59 
60  int64_t cores; /* peak usage in a small time window */
61  int64_t cores_avg;
62  int64_t context_switches;
63  int64_t gpus;
64  int64_t machine_load; /* peak load of the host */
65  int64_t machine_cpus; /* number of cpus of the host */
66 
67  struct rmsummary *limits_exceeded;
68  struct rmsummary *peak_times; /* from start, in usecs */
69 
70  char *snapshot_name; /* NULL for main summary, otherwise label of the snapshot. */
71  int snapshots_count; /* number of intermediate measurements, if any. */
72  struct rmsummary **snapshots; /* snapshots_count sized array of snapshots. */
73 
74  /* these fields are not used when reading/printing summaries */
75  int64_t fs_nodes;
76 };
77 
79 {
80  char *name;
81  size_t offset;
82  int type;
83  union { uint64_t integer;
84  double real;
85  char *string;
86  } value;
87 };
88 
89 void rmsummary_print(FILE *stream, struct rmsummary *s, int pprint, struct jx *verbatim_fields);
90 void rmsummary_print_buffer(struct buffer *B, const struct rmsummary *s, int only_resources);
91 char *rmsummary_print_string(const struct rmsummary *s, int only_resources);
92 
93 const char *rmsummary_unit_of(const char *key);
94 
95 int rmsummary_assign_int_field(struct rmsummary *s, const char *key, int64_t value);
96 int rmsummary_assign_char_field(struct rmsummary *s, const char *key, char *value);
97 
98 int64_t rmsummary_get_int_field(const struct rmsummary *s, const char *key);
99 const char *rmsummary_get_char_field(const struct rmsummary *s, const char *key);
100 
102 struct rmsummary *rmsummary_parse_file_single(const char *filename);
103 
105 struct rmsummary *rmsummary_parse_string(const char *str);
106 
108 struct list *rmsummary_parse_file_multiple(const char *filename);
109 
110 struct jx *rmsummary_to_json(const struct rmsummary *s, int only_resources);
111 struct rmsummary *json_to_rmsummary(struct jx *j);
112 
113 struct rmsummary *rmsummary_create(signed char default_value);
114 void rmsummary_delete(struct rmsummary *s);
115 
116 void rmsummary_read_env_vars(struct rmsummary *s);
117 
118 void rmsummary_merge_max_w_time(struct rmsummary *dest, const struct rmsummary *src);
119 
120 struct rmsummary *rmsummary_copy(const struct rmsummary *src);
121 void rmsummary_merge_override(struct rmsummary *dest, const struct rmsummary *src);
122 void rmsummary_merge_max(struct rmsummary *dest, const struct rmsummary *src);
123 void rmsummary_merge_min(struct rmsummary *dest, const struct rmsummary *src);
124 void rmsummary_add(struct rmsummary *dest, const struct rmsummary *src);
125 
126 void rmsummary_debug_report(const struct rmsummary *s);
127 
128 double rmsummary_to_external_unit(const char *field, int64_t n);
129 double rmsummary_to_base_unit(const char *field, int64_t n);
130 int rmsummary_to_internal_unit(const char *field, double input_number, int64_t *output_number, const char *unit);
131 
132 size_t rmsummary_field_offset(const char *key);
133 int64_t rmsummary_get_int_field_by_offset(const struct rmsummary *s, size_t offset);
134 
135 void rmsummary_add_conversion_field(const char *name, const char *internal, const char *external, const char *base, double exttoint, double inttobase, int float_flag);
136 int rmsummary_field_is_float(const char *key);
137 
138 struct rmsummary *rmsummary_get_snapshot(const struct rmsummary *s, int i);
139 
140 int rmsummary_check_limits(struct rmsummary *measured, struct rmsummary *limits);
141 
142 #endif
JSON Expressions (JX) library.
Definition: rmsummary.h:28
String Buffer Operations.
Definition: buffer.h:26
JX value representing any expression type.
Definition: jx.h:115
Definition: rmsummary.h:78
Definition: category.h:50