category.h

00001 /*
00002 Copyright (C) 2015- The University of Notre Dame
00003 This software is distributed under the GNU General Public License.
00004 See the file COPYING for details.
00005 */
00006 
00007 #ifndef CCTOOLS_CATEGORY_H
00008 #define CCTOOLS_CATEGORY_H
00009 
00010 #include "hash_table.h"
00011 #include "histogram.h"
00012 #include "timestamp.h"
00013 
00014 typedef enum {
00015         CATEGORY_ALLOCATION_FIRST = 0,       
00016         CATEGORY_ALLOCATION_MAX,         
00017         CATEGORY_ALLOCATION_ERROR             
00018 } category_allocation_t;
00019 
00020 
00021 /* Names here a little ugly. We call them 'WORK_QUEUE_' to present a uniform
00022 name pattern for work queue applications, even when this is specific to
00023 categories. We add macro definitions, with nicer names. */
00024 
00025 typedef enum {
00029         WORK_QUEUE_ALLOCATION_MODE_FIXED = 0,   
00030         WORK_QUEUE_ALLOCATION_MODE_MAX,         
00038         WORK_QUEUE_ALLOCATION_MODE_MIN_WASTE,   
00040         WORK_QUEUE_ALLOCATION_MODE_MAX_THROUGHPUT 
00041 } category_mode_t;
00042 
00043 #define CATEGORY_ALLOCATION_MODE_FIXED          WORK_QUEUE_ALLOCATION_MODE_FIXED
00044 #define CATEGORY_ALLOCATION_MODE_MAX            WORK_QUEUE_ALLOCATION_MODE_MAX
00045 #define CATEGORY_ALLOCATION_MODE_MIN_WASTE      WORK_QUEUE_ALLOCATION_MODE_MIN_WASTE
00046 #define CATEGORY_ALLOCATION_MODE_MAX_THROUGHPUT WORK_QUEUE_ALLOCATION_MODE_MAX_THROUGHPUT
00047 
00048 struct category {
00049         char *name;
00050         category_mode_t allocation_mode;
00051 
00052         double fast_abort;
00053 
00054         struct rmsummary *first_allocation;
00055         struct rmsummary *max_allocation;
00056         struct rmsummary *max_resources_seen;
00057 
00058         /* if 1, use first allocations. 0, use max fixed (if given) */
00059         struct rmsummary *autolabel_resource;
00060 
00061         struct histogram *cores_histogram;
00062         struct histogram *wall_time_histogram;
00063         struct histogram *cpu_time_histogram;
00064         struct histogram *max_concurrent_processes_histogram;
00065         struct histogram *total_processes_histogram;
00066         struct histogram *memory_histogram;
00067         struct histogram *swap_memory_histogram;
00068         struct histogram *virtual_memory_histogram;
00069         struct histogram *bytes_read_histogram;
00070         struct histogram *bytes_written_histogram;
00071         struct histogram *bytes_received_histogram;
00072         struct histogram *bytes_sent_histogram;
00073         struct histogram *bandwidth_histogram;
00074         struct histogram *total_files_histogram;
00075         struct histogram *disk_histogram;
00076 
00077         uint64_t total_tasks;
00078 
00079         /* assume that peak usage is independent of wall time */
00080         int time_peak_independece;
00081 
00082         /* completions since last time first-allocation was updated. */
00083         uint64_t completions_since_last_reset;
00084 
00085 
00086         /* category is somewhat confident of the maximum seen value. */
00087         int steady_state;
00088 
00089         /* stats for wq */
00090         uint64_t average_task_time;
00091         struct work_queue_stats *wq_stats;
00092 
00093         /* variables for makeflow */
00094         /* Mappings between variable names defined in the makeflow file and their values. */
00095         struct hash_table *mf_variables;
00096 };
00097 
00098 /* set autoallocation mode cores, memory, and disk. For other resources see category_enable_auto_resource. */
00099 void category_specify_allocation_mode(struct category *c, int mode);
00100 /* enable/disable autoallocation for the resource */
00101 int category_enable_auto_resource(struct category *c, const char *resource_name, int autolabel);
00102 
00103 void category_specify_max_allocation(struct category *c, const struct rmsummary *s);
00104 void category_specify_first_allocation_guess(struct category *c, const struct rmsummary *s);
00105 
00106 struct category *category_lookup_or_create(struct hash_table *categories, const char *name);
00107 void category_delete(struct hash_table *categories, const char *name);
00108 void categories_initialize(struct hash_table *categories, struct rmsummary *top, const char *summaries_file);
00109 
00110 int category_accumulate_summary(struct category *c, const struct rmsummary *rs, const struct rmsummary *max_worker);
00111 int category_update_first_allocation(struct category *c, const struct rmsummary *max_worker);
00112 
00113 int category_in_steady_state(struct category *c);
00114 
00115 category_allocation_t category_next_label(struct category *c, category_allocation_t current_label, int resource_overflow, struct rmsummary *user, struct rmsummary *measured);
00116 
00117 const struct rmsummary *category_dynamic_task_max_resources(struct category *c, struct rmsummary *user, category_allocation_t request);
00118 
00119 const struct rmsummary *category_dynamic_task_min_resources(struct category *c, struct rmsummary *user, category_allocation_t request);
00120 
00121 #endif

Generated on 21 Nov 2016 for cctools by  doxygen 1.6.1