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 
16 /* Environment variables names */
17 #define RESOURCES_CORES "CORES"
18 #define RESOURCES_MEMORY "MEMORY"
19 #define RESOURCES_DISK "DISK"
20 #define RESOURCES_GPUS "GPUS"
21 
22 // These fields are defined as signed integers, even though they
23 // will only contain positive numbers. This is to conversion to
24 // signed quantities when comparing to maximum limits.
25 struct rmsummary
26 {
27  char *category;
28  char *command;
29  char *task_id;
30 
31  int64_t start;
32  int64_t end;
33 
34  char *exit_type;
35  int64_t signal;
36  int64_t exit_status;
37  int64_t last_error;
38 
39  int64_t wall_time;
40  int64_t total_processes;
41  int64_t max_concurrent_processes;
42  int64_t cpu_time;
43  int64_t virtual_memory;
44  int64_t memory; /* a.k.a. resident memory */
45  int64_t swap_memory;
46 
47  int64_t bytes_read;
48  int64_t bytes_written;
49 
50  int64_t bytes_sent;
51  int64_t bytes_received;
52  int64_t bandwidth;
53 
54  int64_t total_files;
55  int64_t disk;
56 
57  int64_t cores;
58  int64_t gpus;
59 
60  struct rmsummary *limits_exceeded;
61 
62  /* these fields are not used when reading/printing summaries */
63  int64_t fs_nodes;
64 
65 };
66 
68 {
69  char *name;
70  size_t offset;
71  int type;
72  union { uint64_t integer;
73  double real;
74  char *string;
75  } value;
76 };
77 
78 void rmsummary_print(FILE *stream, struct rmsummary *s, struct jx *verbatim_fields);
79 
80 int rmsummary_assign_int_field(struct rmsummary *s, const char *key, int64_t value);
81 int rmsummary_assign_char_field(struct rmsummary *s, const char *key, char *value);
82 
83 int64_t rmsummary_get_int_field(struct rmsummary *s, const char *key);
84 const char *rmsummary_get_char_field(struct rmsummary *s, const char *key);
85 
87 struct rmsummary *rmsummary_parse_file_single(const char *filename);
88 
90 struct rmsummary *rmsummary_parse_string(const char *str);
91 
93 struct list *rmsummary_parse_file_multiple(const char *filename);
94 
96 struct rmsummary *rmsummary_parse_next(FILE *stream);
97 
98 struct jx *rmsummary_to_json(struct rmsummary *s, int only_resources);
99 struct rmsummary *json_to_rmsummary(struct jx *j);
100 
101 struct rmsummary *rmsummary_create(signed char default_value);
102 void rmsummary_delete(struct rmsummary *s);
103 
104 void rmsummary_read_env_vars(struct rmsummary *s);
105 
106 void rmsummary_merge_override(struct rmsummary *dest, const struct rmsummary *src);
107 void rmsummary_merge_max(struct rmsummary *dest, const struct rmsummary *src);
108 void rmsummary_merge_min(struct rmsummary *dest, const struct rmsummary *src);
109 void rmsummary_debug_report(const struct rmsummary *s);
110 
111 double rmsummary_to_external_unit(const char *field, int64_t n);
112 int rmsummary_to_internal_unit(const char *field, double input_number, int64_t *output_number, const char *unit);
113 
114 #endif
JSON Expressions (JX) library.
Definition: rmsummary.h:25
Definition: list.h:49
JX value representing any expression type.
Definition: jx.h:74
Definition: rmsummary.h:67
Definition: category.h:28