cctools
category.h
1 /*
2 Copyright (C) 2015- The University of Notre Dame
3 This software is distributed under the GNU General Public License.
4 See the file COPYING for details.
5 */
6 
7 #ifndef CCTOOLS_CATEGORY_H
8 #define CCTOOLS_CATEGORY_H
9 
10 #include "hash_table.h"
11 #include "histogram.h"
12 #include "timestamp.h"
13 
14 typedef enum {
15  CATEGORY_ALLOCATION_FIRST = 0,
16  CATEGORY_ALLOCATION_AUTO = 0,
17  CATEGORY_ALLOCATION_MAX,
18  CATEGORY_ALLOCATION_ERROR
19 } category_allocation_t;
20 
21 
22 /* Names here a little ugly. We call them 'WORK_QUEUE_' to present a uniform
23 name pattern for work queue applications, even when this is specific to
24 categories. We add macro definitions, with nicer names. */
25 
26 typedef enum {
30  WORK_QUEUE_ALLOCATION_MODE_FIXED = 0,
31  WORK_QUEUE_ALLOCATION_MODE_MAX,
39  WORK_QUEUE_ALLOCATION_MODE_MIN_WASTE,
41  WORK_QUEUE_ALLOCATION_MODE_MAX_THROUGHPUT
42 } category_mode_t;
43 
44 #define CATEGORY_ALLOCATION_MODE_FIXED WORK_QUEUE_ALLOCATION_MODE_FIXED
45 #define CATEGORY_ALLOCATION_MODE_MAX WORK_QUEUE_ALLOCATION_MODE_MAX
46 #define CATEGORY_ALLOCATION_MODE_MIN_WASTE WORK_QUEUE_ALLOCATION_MODE_MIN_WASTE
47 #define CATEGORY_ALLOCATION_MODE_MAX_THROUGHPUT WORK_QUEUE_ALLOCATION_MODE_MAX_THROUGHPUT
48 
49 struct category {
50  char *name;
51  category_mode_t allocation_mode;
52 
53  double fast_abort;
54 
55  struct rmsummary *first_allocation;
56  struct rmsummary *max_allocation;
57  struct rmsummary *max_resources_seen;
58 
59  /* if 1, use first allocations. 0, use max fixed (if given) */
60  struct rmsummary *autolabel_resource;
61 
62  struct histogram *cores_histogram;
63  struct histogram *cores_avg_histogram;
64  struct histogram *wall_time_histogram;
65  struct histogram *cpu_time_histogram;
66  struct histogram *max_concurrent_processes_histogram;
67  struct histogram *total_processes_histogram;
68  struct histogram *memory_histogram;
69  struct histogram *swap_memory_histogram;
70  struct histogram *virtual_memory_histogram;
71  struct histogram *bytes_read_histogram;
72  struct histogram *bytes_written_histogram;
73  struct histogram *bytes_received_histogram;
74  struct histogram *bytes_sent_histogram;
75  struct histogram *bandwidth_histogram;
76  struct histogram *total_files_histogram;
77  struct histogram *disk_histogram;
78 
79  int64_t total_tasks;
80 
81  /* assume that peak usage is independent of wall time */
82  int time_peak_independece;
83 
84  /* completions since last time first-allocation was updated. */
85  int64_t completions_since_last_reset;
86 
87 
88  /* category is somewhat confident of the maximum seen value. */
89  int steady_state;
90 
91  /* stats for wq */
92  uint64_t average_task_time;
93  struct work_queue_stats *wq_stats;
94 
95  /* variables for makeflow */
96  /* Mappings between variable names defined in the makeflow file and their values. */
97  struct hash_table *mf_variables;
98 };
99 
100 /* set autoallocation mode cores, memory, and disk. For other resources see category_enable_auto_resource. */
101 void category_specify_allocation_mode(struct category *c, int mode);
102 /* enable/disable autoallocation for the resource */
103 int category_enable_auto_resource(struct category *c, const char *resource_name, int autolabel);
104 
105 void category_specify_max_allocation(struct category *c, const struct rmsummary *s);
106 void category_specify_first_allocation_guess(struct category *c, const struct rmsummary *s);
107 
108 struct category *category_create(const char *name);
109 struct category *category_lookup_or_create(struct hash_table *categories, const char *name);
110 void category_delete(struct hash_table *categories, const char *name);
111 void categories_initialize(struct hash_table *categories, struct rmsummary *top, const char *summaries_file);
112 
113 int category_accumulate_summary(struct category *c, const struct rmsummary *rs, const struct rmsummary *max_worker);
114 int category_update_first_allocation(struct category *c, const struct rmsummary *max_worker);
115 
116 int category_in_steady_state(struct category *c);
117 
118 category_allocation_t category_next_label(struct category *c, category_allocation_t current_label, int resource_overflow, struct rmsummary *user, struct rmsummary *measured);
119 
120 const struct rmsummary *category_dynamic_task_max_resources(struct category *c, struct rmsummary *user, category_allocation_t request);
121 
122 const struct rmsummary *category_dynamic_task_min_resources(struct category *c, struct rmsummary *user, category_allocation_t request);
123 
124 #endif
Portable routines for high resolution timing.
Statistics describing a work queue.
Definition: work_queue.h:188
Definition: rmsummary.h:27
A general purpose hash table.
Keep counts of doubles that fall in some given bucket size.
Definition: category.h:49