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 
26 struct rmsummary
27 {
28  char *category;
29  char *command;
30  char *taskid;
31 
32  char *exit_type;
33  int64_t signal;
34  int64_t exit_status;
35  int64_t last_error;
36 
37  double start;
38  double end;
39 
40  double cores;
41  double cores_avg;
42  double gpus;
43 
44  double wall_time;
45  double cpu_time;
46 
47  double memory;
48  double virtual_memory;
49  double swap_memory;
50 
51  double disk;
52  double bytes_read;
53  double bytes_written;
54 
55  double bytes_received;
56  double bytes_sent;
57  double bandwidth;
58 
59  double machine_cpus;
60  double machine_load;
61  double context_switches;
62 
63  double max_concurrent_processes;
64  double total_processes;
65 
66  double total_files;
67  double fs_nodes;
68 
69  double workers;
70 
71  struct rmsummary *limits_exceeded;
72  struct rmsummary *peak_times; /* from start, in usecs */
73 
74  char *snapshot_name; /* NULL for root summary, otherwise the label of the snapshot */
75  size_t snapshots_count; /* number of intermediate measurements, if any. */
76  struct rmsummary **snapshots; /* snapshots_count sized array of snapshots. */
77 };
78 
79 void rmsummary_print(FILE *stream, struct rmsummary *s, int pprint, struct jx *verbatim_fields);
80 void rmsummary_print_buffer(struct buffer *B, const struct rmsummary *s, int only_resources);
81 char *rmsummary_print_string(const struct rmsummary *s, int only_resources);
82 
83 /* Returns 1 if resource set, 0 if resource does not exist. */
84 int rmsummary_set(struct rmsummary *s, const char *resource, double value);
85 double rmsummary_get(const struct rmsummary *s, const char *resource);
86 
87 void rmsummary_set_by_offset(struct rmsummary *s, size_t offset, double value);
88 double rmsummary_get_by_offset(const struct rmsummary *s, size_t offset);
89 
91 struct rmsummary *rmsummary_parse_file_single(const char *filename);
92 
94 struct rmsummary *rmsummary_parse_string(const char *str);
95 
97 struct list *rmsummary_parse_file_multiple(const char *filename);
98 
99 struct jx *rmsummary_to_json(const struct rmsummary *s, int only_resources);
100 struct rmsummary *json_to_rmsummary(struct jx *j);
101 
103 struct rmsummary *rmsummary_create(double default_value);
104 void rmsummary_delete(struct rmsummary *s);
105 
106 void rmsummary_read_env_vars(struct rmsummary *s);
107 
108 void rmsummary_merge_max_w_time(struct rmsummary *dest, const struct rmsummary *src);
109 
110 struct rmsummary *rmsummary_copy(const struct rmsummary *src, int deep_copy);
111 void rmsummary_merge_override(struct rmsummary *dest, const struct rmsummary *src);
112 void rmsummary_merge_max(struct rmsummary *dest, const struct rmsummary *src);
113 void rmsummary_merge_min(struct rmsummary *dest, const struct rmsummary *src);
114 void rmsummary_add(struct rmsummary *dest, const struct rmsummary *src);
115 
116 void rmsummary_debug_report(const struct rmsummary *s);
117 
118 struct rmsummary *rmsummary_get_snapshot(const struct rmsummary *s, size_t i);
119 int rmsummary_check_limits(struct rmsummary *measured, struct rmsummary *limits);
120 
121 size_t rmsummary_num_resources();
122 const char **rmsummary_list_resources();
123 
124 const char *rmsummary_resource_units(const char *resource_name);
125 int rmsummary_resource_decimals(const char *resource_name);
126 size_t rmsummary_resource_offset(const char *resource_name);
127 
128 const char *rmsummary_resource_to_str();
129 
130 #endif
JSON Expressions (JX) library.
Definition: rmsummary.h:26
String Buffer Operations.
Definition: buffer.h:26
JX value representing any expression type.
Definition: jx.h:115
Definition: category.h:50