rmsummary.h

00001 /*
00002 Copyright (C) 2013- The University of Notre Dame This software is
00003 distributed under the GNU General Public License.  See the file
00004 COPYING for details.
00005 */
00006 
00007 #ifndef __RMSUMMARY_H
00008 #define __RMSUMMARY_H
00009 
00010 #include <stdio.h>
00011 #include <stdlib.h>
00012 
00013 #include "jx.h"
00014 #include "int_sizes.h"
00015 #include "buffer.h"
00016 
00017 /* Environment variables names */
00018 #define RESOURCES_CORES  "CORES"
00019 #define RESOURCES_MEMORY "MEMORY"
00020 #define RESOURCES_DISK   "DISK"
00021 #define RESOURCES_WALL_TIME "WALL_TIME"
00022 #define RESOURCES_GPUS   "GPUS"
00023 
00024 // These fields are defined as signed integers, even though they
00025 // will only contain positive numbers. This is to conversion to
00026 // signed quantities when comparing to maximum limits.
00027 struct rmsummary
00028 {
00029         char    *category;
00030         char    *command;
00031         char    *taskid;
00032 
00033         int64_t  start;                          /* usecs */
00034         int64_t  end;                            /* usecs */
00035 
00036         char    *exit_type;
00037         int64_t  signal;
00038         int64_t  exit_status;
00039         int64_t  last_error;
00040 
00041         int64_t  wall_time;                      /* usecs */
00042         int64_t  total_processes;
00043         int64_t  max_concurrent_processes;
00044         int64_t  cpu_time;                       /* usecs */
00045         int64_t  virtual_memory;                 /* MB */
00046         int64_t  memory;                         /* MB. a.k.a. resident memory */
00047         int64_t  swap_memory;                    /* MB */
00048 
00049         int64_t  bytes_read;                     /* B */
00050         int64_t  bytes_written;                  /* B */
00051 
00052         int64_t  bytes_sent;                     /* B */
00053         int64_t  bytes_received;                 /* B */
00054         int64_t  bandwidth;                      /* bps */
00055 
00056         int64_t  total_files;
00057         int64_t  disk;                           /* MB */
00058 
00059         int64_t  cores;                          /* peak usage in a small time window */
00060         int64_t  cores_avg;
00061         int64_t  gpus;
00062     int64_t  machine_load;                   /* peak load of the host */
00063     int64_t  machine_cpus;                   /* number of cpus of the host */
00064 
00065         struct rmsummary *limits_exceeded;
00066         struct rmsummary *peak_times;           /* from start, in usecs */
00067 
00068         char  *snapshot_name;                   /* NULL for main summary, otherwise label of the snapshot. */
00069         int    snapshots_count;                 /* number of intermediate measurements, if any. */
00070         struct rmsummary **snapshots;           /* snapshots_count sized array of snapshots. */
00071 
00072         /* these fields are not used when reading/printing summaries */
00073         int64_t  fs_nodes;
00074 };
00075 
00076 struct rmsummary_field
00077 {
00078         char   *name;
00079         size_t  offset;
00080         int     type;
00081         union { uint64_t integer;
00082                 double   real;
00083                 char    *string;
00084         }       value;
00085 };
00086 
00087 void rmsummary_print(FILE *stream, struct rmsummary *s, int pprint, struct jx *verbatim_fields);
00088 void rmsummary_print_buffer(struct buffer *B, const struct rmsummary *s, int only_resources);
00089 char *rmsummary_print_string(const struct rmsummary *s, int only_resources);
00090 
00091 const char *rmsummary_unit_of(const char *key);
00092 
00093 int rmsummary_assign_int_field(struct rmsummary *s, const char *key, int64_t value);
00094 int rmsummary_assign_char_field(struct rmsummary *s, const char *key, char *value);
00095 
00096 int64_t rmsummary_get_int_field(struct rmsummary *s, const char *key);
00097 const char *rmsummary_get_char_field(struct rmsummary *s, const char *key);
00098 
00100 struct rmsummary *rmsummary_parse_file_single(const char *filename);
00101 
00103 struct rmsummary *rmsummary_parse_string(const char *str);
00104 
00106 struct list *rmsummary_parse_file_multiple(const char *filename);
00107 
00108 struct jx *rmsummary_to_json(const struct rmsummary *s, int only_resources);
00109 struct rmsummary *json_to_rmsummary(struct jx *j);
00110 
00111 struct rmsummary *rmsummary_create(signed char default_value);
00112 void rmsummary_delete(struct rmsummary *s);
00113 
00114 void rmsummary_read_env_vars(struct rmsummary *s);
00115 
00116 void rmsummary_merge_max_w_time(struct rmsummary *dest, const struct rmsummary *src);
00117 
00118 struct rmsummary *rmsummary_copy(const struct rmsummary *src);
00119 void rmsummary_merge_override(struct rmsummary *dest, const struct rmsummary *src);
00120 void rmsummary_merge_max(struct rmsummary *dest, const struct rmsummary *src);
00121 void rmsummary_merge_min(struct rmsummary *dest, const struct rmsummary *src);
00122 void rmsummary_add(struct rmsummary *dest, const struct rmsummary *src);
00123 
00124 void rmsummary_debug_report(const struct rmsummary *s);
00125 
00126 double rmsummary_to_external_unit(const char *field, int64_t n);
00127 double rmsummary_to_base_unit(const char *field, int64_t n);
00128 int rmsummary_to_internal_unit(const char *field, double input_number, int64_t *output_number, const char *unit);
00129 
00130 size_t rmsummary_field_offset(const char *key);
00131 int64_t rmsummary_get_int_field_by_offset(const struct rmsummary *s, size_t offset);
00132 
00133 void rmsummary_add_conversion_field(const char *name, const char *internal, const char *external, const char *base, double exttoint, double inttobase, int float_flag);
00134 int rmsummary_field_is_float(const char *key);
00135 
00136 struct rmsummary *rmsummary_get_snapshot(const struct rmsummary *s, int i);
00137 
00138 #endif

Generated on 17 Sep 2019 for cctools by  doxygen 1.6.1