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 
00016 /* Environment variables names */
00017 #define RESOURCES_CORES  "CORES"
00018 #define RESOURCES_MEMORY "MEMORY"
00019 #define RESOURCES_DISK   "DISK"
00020 #define RESOURCES_GPUS   "GPUS"
00021 
00022 // These fields are defined as signed integers, even though they
00023 // will only contain positive numbers. This is to conversion to
00024 // signed quantities when comparing to maximum limits.
00025 struct rmsummary
00026 {
00027         char    *category;
00028         char    *command;
00029         char    *task_id;
00030 
00031         int64_t  start;
00032         int64_t  end;
00033 
00034         char    *exit_type;
00035         int64_t  signal;
00036         int64_t  exit_status;
00037         int64_t  last_error;
00038 
00039         int64_t  wall_time;
00040         int64_t  total_processes;
00041         int64_t  max_concurrent_processes;
00042         int64_t  cpu_time;
00043         int64_t  virtual_memory;
00044         int64_t  memory;                     /* a.k.a. resident memory */
00045         int64_t  swap_memory;
00046 
00047         int64_t  bytes_read;
00048         int64_t  bytes_written;
00049 
00050         int64_t  bytes_sent;
00051         int64_t  bytes_received;
00052         int64_t  bandwidth;
00053 
00054         int64_t  total_files;
00055         int64_t  disk;
00056 
00057         int64_t  cores;
00058         int64_t  gpus;
00059 
00060         struct rmsummary *limits_exceeded;
00061 
00062         /* these fields are not used when reading/printing summaries */
00063         int64_t  fs_nodes;
00064 
00065 };
00066 
00067 struct rmsummary_field
00068 {
00069         char   *name;
00070         size_t  offset;
00071         int     type;
00072         union { uint64_t integer;
00073                 double   real;
00074                 char    *string;
00075         }       value;
00076 };
00077 
00078 void rmsummary_print(FILE *stream, struct rmsummary *s, struct jx *verbatim_fields);
00079 
00080 int rmsummary_assign_int_field(struct rmsummary *s, const char *key, int64_t value);
00081 int rmsummary_assign_char_field(struct rmsummary *s, const char *key, char *value);
00082 
00083 int64_t rmsummary_get_int_field(struct rmsummary *s, const char *key);
00084 const char *rmsummary_get_char_field(struct rmsummary *s, const char *key);
00085 
00087 struct rmsummary *rmsummary_parse_file_single(const char *filename);
00088 
00090 struct rmsummary *rmsummary_parse_string(const char *str);
00091 
00093 struct list *rmsummary_parse_file_multiple(const char *filename);
00094 
00096 struct rmsummary *rmsummary_parse_next(FILE *stream);
00097 
00098 struct jx *rmsummary_to_json(struct rmsummary *s, int only_resources);
00099 struct rmsummary *json_to_rmsummary(struct jx *j);
00100 
00101 struct rmsummary *rmsummary_create(signed char default_value);
00102 void rmsummary_delete(struct rmsummary *s);
00103 
00104 void rmsummary_read_env_vars(struct rmsummary *s);
00105 
00106 void rmsummary_merge_override(struct rmsummary *dest, const struct rmsummary *src);
00107 void rmsummary_merge_max(struct rmsummary *dest, const struct rmsummary *src);
00108 void rmsummary_merge_min(struct rmsummary *dest, const struct rmsummary *src);
00109 void rmsummary_debug_report(const struct rmsummary *s);
00110 
00111 double rmsummary_to_external_unit(const char *field, int64_t n);
00112 int rmsummary_to_internal_unit(const char *field, double input_number, int64_t *output_number, const char *unit);
00113 
00114 #endif

Generated on 7 Jul 2016 for cctools by  doxygen 1.6.1