cctools
category.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2022 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 
13 #include "hash_table.h"
14 #include "itable.h"
15 #include "histogram.h"
16 #include "timestamp.h"
17 #include "bucketing_manager.h"
18 
22 typedef enum {
30 
31 
35 typedef enum {
67 
68 
69 struct category {
70  char *name;
71  category_mode_t allocation_mode;
72 
73  double fast_abort;
74 
75  struct rmsummary *first_allocation;
76  struct rmsummary *max_allocation;
77  struct rmsummary *min_allocation;
78  struct rmsummary *max_resources_seen;
79 
80  /* if 1, use first allocations. 0, use max fixed (if given) */
81  struct rmsummary *autolabel_resource;
82 
83  struct itable *histograms;
84 
85  /* manager for bucketing mode, if applicable */
86  bucketing_manager_t* bucketing_manager;
87 
88  /* number of tasks completed */
89  int64_t total_tasks;
90 
91  /* completions since last time first-allocation was updated. */
92  int64_t completions_since_last_reset;
93 
94  /* maximum number of tasks of this category allowed to be running concurrently. If less than 0, unlimited. */
95  int64_t max_concurrent;
96 
97  /* category is somewhat confident of the maximum seen value. */
98  int steady_state;
99 
100  /* stats for work queue */
101  uint64_t average_task_time;
102  struct work_queue_stats *wq_stats;
103 
104  /* stats for taskvine */
105  struct vine_stats *vine_stats;
106 
107  /* Max sandbox disk space observed, in MB. This is the minimum sandbox size needed if nothing else is known about the task.*/
108  int64_t min_vine_sandbox;
109 
110  /* variables for makeflow */
111  /* Mappings between variable names defined in the makeflow file and their values. */
112  struct hash_table *mf_variables;
113 };
114 
115 /* set autoallocation mode cores, memory, and disk. For other resources see category_enable_auto_resource. */
116 void category_specify_allocation_mode(struct category *c, int mode);
117 /* enable/disable autoallocation for the resource */
118 int category_enable_auto_resource(struct category *c, const char *resource_name, int autolabel);
119 
120 void category_specify_max_allocation(struct category *c, const struct rmsummary *s);
121 void category_specify_min_allocation(struct category *c, const struct rmsummary *s);
122 void category_specify_first_allocation_guess(struct category *c, const struct rmsummary *s);
123 
124 struct category *category_create(const char *name);
125 struct category *category_lookup_or_create(struct hash_table *categories, const char *name);
126 void category_delete(struct hash_table *categories, const char *name);
127 void categories_initialize(struct hash_table *categories, struct rmsummary *top, const char *summaries_file);
128 
129 int category_accumulate_summary(struct category *c, const struct rmsummary *rs, const struct rmsummary *max_worker);
130 
131 int category_bucketing_accumulate_summary(struct category *c, const struct rmsummary *rs, const struct rmsummary *max_worker, int taskid, int success);
132 
133 int category_in_bucketing_mode(struct category* c);
134 
135 int category_update_first_allocation(struct category *c, const struct rmsummary *max_worker);
136 
137 int category_in_steady_state(struct category *c);
138 
139 category_allocation_t category_next_label(struct category *c, category_allocation_t current_label, int resource_overflow, struct rmsummary *user, struct rmsummary *measured);
140 
141 const struct rmsummary *category_task_max_resources(struct category *c, struct rmsummary *user, category_allocation_t request, int taskid);
142 
143 const struct rmsummary *category_task_min_resources(struct category *c, struct rmsummary *user, category_allocation_t request, int taskid);
144 
145 #endif
bucketing_manager_t
Definition: bucketing_manager.h:12
CATEGORY_ALLOCATION_FIRST
@ CATEGORY_ALLOCATION_FIRST
No automatic allocation, or using first step value of the two-step policy.
Definition: category.h:23
work_queue_stats
Statistics describing a work queue.
Definition: work_queue.h:226
histogram.h
CATEGORY_ALLOCATION_MAX
@ CATEGORY_ALLOCATION_MAX
Using max of category.
Definition: category.h:25
category
Definition: category.h:69
itable.h
CATEGORY_ALLOCATION_MODE_MAX_THROUGHPUT
@ CATEGORY_ALLOCATION_MODE_MAX_THROUGHPUT
As above, but maximizing throughput.
Definition: category.h:59
CATEGORY_ALLOCATION_MODE_GREEDY_BUCKETING
@ CATEGORY_ALLOCATION_MODE_GREEDY_BUCKETING
Use the greedy bucketing algorithm to label resources.
Definition: category.h:61
CATEGORY_ALLOCATION_GREEDY_BUCKETING
@ CATEGORY_ALLOCATION_GREEDY_BUCKETING
Use the greedy bucketing algorithm to label resources.
Definition: category.h:27
CATEGORY_ALLOCATION_MODE_FIXED
@ CATEGORY_ALLOCATION_MODE_FIXED
When monitoring is disabled, all tasks run as WORK_QUEUE_ALLOCATION_MODE_FIXED.
Definition: category.h:36
category_mode_t
category_mode_t
Definition: category.h:35
rmsummary
Definition: rmsummary.h:26
CATEGORY_ALLOCATION_AUTO
@ CATEGORY_ALLOCATION_AUTO
Same as FIRST, FIRST is deprecated.
Definition: category.h:24
CATEGORY_ALLOCATION_MODE_EXHAUSTIVE_BUCKETING
@ CATEGORY_ALLOCATION_MODE_EXHAUSTIVE_BUCKETING
Use the exhaustive bucketing algorithm to label resources.
Definition: category.h:64
category_allocation_t
category_allocation_t
Definition: category.h:22
CATEGORY_ALLOCATION_MODE_MAX
@ CATEGORY_ALLOCATION_MODE_MAX
When monitoring is enabled, tasks are tried with maximum specified values of cores,...
Definition: category.h:43
vine_stats
Statistics describing a manager.
Definition: taskvine.h:153
timestamp.h
CATEGORY_ALLOCATION_EXHAUSTIVE_BUCKETING
@ CATEGORY_ALLOCATION_EXHAUSTIVE_BUCKETING
Use the exhaustive bucketing algorithm to label resources.
Definition: category.h:28
hash_table.h
CATEGORY_ALLOCATION_ERROR
@ CATEGORY_ALLOCATION_ERROR
No valid resources could be found.
Definition: category.h:26
CATEGORY_ALLOCATION_MODE_MIN_WASTE
@ CATEGORY_ALLOCATION_MODE_MIN_WASTE
As above, but tasks are first tried with an automatically computed allocation to minimize resource wa...
Definition: category.h:55