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 
24 // These fields are defined as signed integers, even though they
25 // will only contain positive numbers. This is to conversion to
26 // signed quantities when comparing to maximum limits.
27 struct rmsummary
28 {
29  char *category;
30  char *command;
31  char *taskid;
32 
33  int64_t start; /* usecs */
34  int64_t end; /* usecs */
35 
36  char *exit_type;
37  int64_t signal;
38  int64_t exit_status;
39  int64_t last_error;
40 
41  int64_t wall_time; /* usecs */
42  int64_t total_processes;
43  int64_t max_concurrent_processes;
44  int64_t cpu_time; /* usecs */
45  int64_t virtual_memory; /* MB */
46  int64_t memory; /* MB. a.k.a. resident memory */
47  int64_t swap_memory; /* MB */
48 
49  int64_t bytes_read; /* B */
50  int64_t bytes_written; /* B */
51 
52  int64_t bytes_sent; /* B */
53  int64_t bytes_received; /* B */
54  int64_t bandwidth; /* bps */
55 
56  int64_t total_files;
57  int64_t disk; /* MB */
58 
59  int64_t cores; /* peak usage in a small time window */
60  int64_t cores_avg;
61  int64_t gpus;
62  int64_t machine_load; /* peak load of the host */
63  int64_t machine_cpus; /* number of cpus of the host */
64 
65  struct rmsummary *limits_exceeded;
66  struct rmsummary *peak_times; /* from start, in usecs */
67 
68  char *snapshot_name; /* NULL for main summary, otherwise label of the snapshot. */
69  int snapshots_count; /* number of intermediate measurements, if any. */
70  struct rmsummary **snapshots; /* snapshots_count sized array of snapshots. */
71 
72  /* these fields are not used when reading/printing summaries */
73  int64_t fs_nodes;
74 };
75 
77 {
78  char *name;
79  size_t offset;
80  int type;
81  union { uint64_t integer;
82  double real;
83  char *string;
84  } value;
85 };
86 
87 void rmsummary_print(FILE *stream, struct rmsummary *s, int pprint, struct jx *verbatim_fields);
88 void rmsummary_print_buffer(struct buffer *B, const struct rmsummary *s, int only_resources);
89 char *rmsummary_print_string(const struct rmsummary *s, int only_resources);
90 
91 const char *rmsummary_unit_of(const char *key);
92 
93 int rmsummary_assign_int_field(struct rmsummary *s, const char *key, int64_t value);
94 int rmsummary_assign_char_field(struct rmsummary *s, const char *key, char *value);
95 
96 int64_t rmsummary_get_int_field(struct rmsummary *s, const char *key);
97 const char *rmsummary_get_char_field(struct rmsummary *s, const char *key);
98 
100 struct rmsummary *rmsummary_parse_file_single(const char *filename);
101 
103 struct rmsummary *rmsummary_parse_string(const char *str);
104 
106 struct list *rmsummary_parse_file_multiple(const char *filename);
107 
108 struct jx *rmsummary_to_json(const struct rmsummary *s, int only_resources);
109 struct rmsummary *json_to_rmsummary(struct jx *j);
110 
111 struct rmsummary *rmsummary_create(signed char default_value);
112 void rmsummary_delete(struct rmsummary *s);
113 
114 void rmsummary_read_env_vars(struct rmsummary *s);
115 
116 void rmsummary_merge_max_w_time(struct rmsummary *dest, const struct rmsummary *src);
117 
118 struct rmsummary *rmsummary_copy(const struct rmsummary *src);
119 void rmsummary_merge_override(struct rmsummary *dest, const struct rmsummary *src);
120 void rmsummary_merge_max(struct rmsummary *dest, const struct rmsummary *src);
121 void rmsummary_merge_min(struct rmsummary *dest, const struct rmsummary *src);
122 void rmsummary_add(struct rmsummary *dest, const struct rmsummary *src);
123 
124 void rmsummary_debug_report(const struct rmsummary *s);
125 
126 double rmsummary_to_external_unit(const char *field, int64_t n);
127 double rmsummary_to_base_unit(const char *field, int64_t n);
128 int rmsummary_to_internal_unit(const char *field, double input_number, int64_t *output_number, const char *unit);
129 
130 size_t rmsummary_field_offset(const char *key);
131 int64_t rmsummary_get_int_field_by_offset(const struct rmsummary *s, size_t offset);
132 
133 void rmsummary_add_conversion_field(const char *name, const char *internal, const char *external, const char *base, double exttoint, double inttobase, int float_flag);
134 int rmsummary_field_is_float(const char *key);
135 
136 struct rmsummary *rmsummary_get_snapshot(const struct rmsummary *s, int i);
137 
138 #endif
JSON Expressions (JX) library.
Definition: rmsummary.h:27
String Buffer Operations.
Definition: buffer.h:26
JX value representing any expression type.
Definition: jx.h:135
Definition: rmsummary.h:76
Definition: category.h:49