2007-02-15 21:11:05 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "app.h"
|
|
|
|
#include "time_stats.h"
|
2007-02-23 17:29:19 +00:00
|
|
|
#include "client_types.h"
|
2007-02-15 21:11:05 +00:00
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
|
2007-02-24 14:55:59 +00:00
|
|
|
#define WORK_FETCH_DONT_NEED 0
|
|
|
|
// project: suspended, deferred, or no new work (can't ask for more work)
|
|
|
|
// overall: not work_fetch_ok (from CPU policy)
|
|
|
|
#define WORK_FETCH_OK 1
|
|
|
|
// project: has more than min queue * share, not suspended/def/nonewwork
|
|
|
|
// overall: at least min queue, work fetch OK
|
|
|
|
#define WORK_FETCH_NEED 2
|
|
|
|
// project: less than min queue * resource share of DL/runnable results
|
|
|
|
// overall: less than min queue
|
|
|
|
#define WORK_FETCH_NEED_IMMEDIATELY 3
|
|
|
|
// project: no downloading or runnable results
|
|
|
|
// overall: at least one idle CPU
|
|
|
|
|
2007-04-10 20:13:15 +00:00
|
|
|
struct SIM_RESULTS {
|
|
|
|
double cpu_used;
|
|
|
|
double cpu_wasted;
|
|
|
|
double cpu_idle;
|
|
|
|
int nresults_met_deadline;
|
|
|
|
int nresults_missed_deadline;
|
2007-04-10 21:56:11 +00:00
|
|
|
double share_violation;
|
|
|
|
double variety;
|
|
|
|
double cpu_wasted_frac;
|
|
|
|
double cpu_idle_frac;
|
2007-04-10 20:13:15 +00:00
|
|
|
|
2007-04-10 21:56:11 +00:00
|
|
|
void compute();
|
|
|
|
void print(FILE* f, const char* title=0);
|
2007-04-10 20:13:15 +00:00
|
|
|
void parse(FILE* f);
|
|
|
|
void add(SIM_RESULTS& r);
|
|
|
|
SIM_RESULTS();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PROJECT_RESULTS {
|
|
|
|
double cpu_used;
|
|
|
|
double cpu_wasted;
|
|
|
|
int nresults_met_deadline;
|
|
|
|
int nresults_missed_deadline;
|
|
|
|
};
|
2007-02-24 20:10:06 +00:00
|
|
|
|
|
|
|
class NORMAL_DIST {
|
|
|
|
public:
|
|
|
|
double mean;
|
2007-04-04 19:34:01 +00:00
|
|
|
double stdev;
|
2007-02-24 20:10:06 +00:00
|
|
|
int parse(XML_PARSER&, char* end_tag);
|
|
|
|
double sample();
|
|
|
|
};
|
|
|
|
|
|
|
|
class UNIFORM_DIST {
|
|
|
|
public:
|
|
|
|
double lo;
|
|
|
|
double hi;
|
|
|
|
int parse(XML_PARSER&, char* end_tag);
|
|
|
|
double sample();
|
|
|
|
};
|
|
|
|
|
|
|
|
class RANDOM_PROCESS {
|
2007-04-09 02:17:26 +00:00
|
|
|
double last_time;
|
|
|
|
double time_left;
|
|
|
|
bool value;
|
|
|
|
double off_lambda;
|
2007-02-24 20:10:06 +00:00
|
|
|
public:
|
|
|
|
double frac;
|
|
|
|
double lambda;
|
|
|
|
int parse(XML_PARSER&, char* end_tag);
|
2007-04-09 02:17:26 +00:00
|
|
|
bool sample(double);
|
|
|
|
void init();
|
|
|
|
RANDOM_PROCESS();
|
2007-02-24 20:10:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SIM_APP: public APP {
|
|
|
|
public:
|
|
|
|
double latency_bound;
|
2007-03-29 16:40:43 +00:00
|
|
|
double fpops_est;
|
2007-02-24 20:10:06 +00:00
|
|
|
NORMAL_DIST fpops;
|
|
|
|
NORMAL_DIST checkpoint_period;
|
|
|
|
double working_set;
|
2007-03-29 16:40:43 +00:00
|
|
|
double weight;
|
2007-02-24 20:10:06 +00:00
|
|
|
|
2007-04-03 17:16:39 +00:00
|
|
|
SIM_APP(){}
|
2007-02-24 20:10:06 +00:00
|
|
|
int parse(XML_PARSER&);
|
|
|
|
};
|
|
|
|
|
|
|
|
class SIM_PROJECT: public PROJECT {
|
|
|
|
public:
|
|
|
|
RANDOM_PROCESS available;
|
2007-04-04 19:34:01 +00:00
|
|
|
int index;
|
|
|
|
int result_index;
|
2007-04-10 20:13:15 +00:00
|
|
|
int nidle_periods;
|
|
|
|
double idle_period_duration;
|
|
|
|
double idle_period_sumsq;
|
|
|
|
bool idle;
|
|
|
|
|
2007-02-24 20:10:06 +00:00
|
|
|
int parse(XML_PARSER&);
|
2007-04-10 20:13:15 +00:00
|
|
|
PROJECT_RESULTS project_results;
|
|
|
|
void print_results(FILE*, SIM_RESULTS&);
|
|
|
|
void init();
|
2007-02-24 20:10:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SIM_HOST: public HOST_INFO {
|
|
|
|
public:
|
|
|
|
RANDOM_PROCESS available;
|
|
|
|
RANDOM_PROCESS idle;
|
2007-04-06 22:19:17 +00:00
|
|
|
double connection_interval;
|
|
|
|
// min time between network connections
|
2007-02-24 20:10:06 +00:00
|
|
|
int parse(XML_PARSER&);
|
|
|
|
};
|
|
|
|
|
2007-02-15 21:11:05 +00:00
|
|
|
class CLIENT_STATE {
|
|
|
|
public:
|
|
|
|
double now;
|
|
|
|
vector<PROJECT*> projects;
|
|
|
|
vector<WORKUNIT*> workunits;
|
|
|
|
vector<RESULT*> results;
|
2007-02-24 00:11:30 +00:00
|
|
|
vector<APP*> apps;
|
2007-02-15 21:11:05 +00:00
|
|
|
ACTIVE_TASK_SET active_tasks;
|
|
|
|
GLOBAL_PREFS global_prefs;
|
2007-02-24 20:10:06 +00:00
|
|
|
SIM_HOST host_info;
|
2007-02-15 21:11:05 +00:00
|
|
|
TIME_STATS time_stats;
|
2007-02-24 04:29:58 +00:00
|
|
|
CLIENT_STATE();
|
2007-04-03 17:16:39 +00:00
|
|
|
bool initialized;
|
|
|
|
bool run_cpu_benchmarks;
|
2007-04-04 15:40:07 +00:00
|
|
|
FILE* html_out;
|
|
|
|
void html_start();
|
|
|
|
void html_rec();
|
|
|
|
void html_end();
|
|
|
|
std::string html_msg;
|
2007-04-10 20:13:15 +00:00
|
|
|
double share_violation();
|
|
|
|
double variety();
|
2007-02-15 21:11:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
double app_started;
|
|
|
|
public:
|
|
|
|
ACTIVE_TASK* lookup_active_task_by_result(RESULT*);
|
|
|
|
int report_result_error(RESULT&, const char *format, ...);
|
|
|
|
double available_ram();
|
|
|
|
double max_available_ram();
|
|
|
|
void set_client_state_dirty(const char*);
|
2007-02-21 22:27:35 +00:00
|
|
|
RESULT* lookup_result(PROJECT*, const char*);
|
2007-02-15 21:11:05 +00:00
|
|
|
|
|
|
|
// cpu_sched.C
|
|
|
|
private:
|
|
|
|
double debt_interval_start;
|
|
|
|
double total_wall_cpu_time_this_debt_interval;
|
|
|
|
// "wall CPU time" accumulated since last adjust_debts()
|
2007-04-11 21:49:57 +00:00
|
|
|
double fetchable_resource_share();
|
2007-02-15 21:11:05 +00:00
|
|
|
double total_cpu_time_this_debt_interval;
|
|
|
|
double cpu_shortfall;
|
|
|
|
bool work_fetch_no_new_work;
|
|
|
|
bool must_enforce_cpu_schedule;
|
|
|
|
bool must_schedule_cpus;
|
|
|
|
bool must_check_work_fetch;
|
|
|
|
std::vector <RESULT*> ordered_scheduled_results;
|
|
|
|
void assign_results_to_projects();
|
|
|
|
RESULT* largest_debt_project_best_result();
|
|
|
|
RESULT* earliest_deadline_result();
|
2007-03-15 23:39:22 +00:00
|
|
|
void reset_debt_accounting();
|
2007-02-15 21:11:05 +00:00
|
|
|
void adjust_debts();
|
|
|
|
bool possibly_schedule_cpus();
|
|
|
|
void schedule_cpus();
|
|
|
|
bool enforce_schedule();
|
|
|
|
bool no_work_for_a_cpu();
|
|
|
|
void rr_simulation();
|
|
|
|
void make_running_task_heap(vector<ACTIVE_TASK*>&);
|
|
|
|
void print_deadline_misses();
|
2007-04-03 19:06:26 +00:00
|
|
|
public:
|
2007-02-15 21:11:05 +00:00
|
|
|
inline double work_buf_min() {
|
|
|
|
return global_prefs.work_buf_min_days * 86400;
|
|
|
|
}
|
2007-03-28 21:30:45 +00:00
|
|
|
double work_buf_additional() {
|
|
|
|
return global_prefs.work_buf_additional_days * 86400;
|
|
|
|
}
|
2007-04-17 22:24:53 +00:00
|
|
|
inline double work_buf_total() {
|
|
|
|
double x = work_buf_min() + work_buf_additional();
|
|
|
|
if (x < 1) x = 1;
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2007-02-15 21:11:05 +00:00
|
|
|
void request_enforce_schedule(const char*);
|
|
|
|
void request_schedule_cpus(const char*);
|
|
|
|
|
|
|
|
// --------------- cs_apps.C:
|
|
|
|
private:
|
|
|
|
double total_resource_share();
|
|
|
|
double potentially_runnable_resource_share();
|
|
|
|
double nearly_runnable_resource_share();
|
|
|
|
public:
|
|
|
|
double runnable_resource_share();
|
|
|
|
void request_work_fetch(const char*);
|
|
|
|
// Check if work fetch needed. Called when:
|
|
|
|
// - core client starts (CS::init())
|
|
|
|
// - task is completed or fails
|
|
|
|
// - tasks are killed
|
|
|
|
// - an RPC completes
|
|
|
|
// - project suspend/detch/attach/reset GUI RPC
|
|
|
|
// - result suspend/abort GUI RPC
|
|
|
|
int quit_activities();
|
|
|
|
void set_ncpus();
|
|
|
|
double estimate_cpu_time(WORKUNIT&);
|
|
|
|
double get_fraction_done(RESULT* result);
|
|
|
|
int input_files_available(RESULT*, bool);
|
|
|
|
ACTIVE_TASK* get_next_graphics_capable_app();
|
|
|
|
int ncpus;
|
|
|
|
// number of usable cpus
|
|
|
|
private:
|
|
|
|
int nslots;
|
|
|
|
|
|
|
|
int app_finished(ACTIVE_TASK&);
|
|
|
|
bool start_apps();
|
|
|
|
bool handle_finished_apps();
|
|
|
|
public:
|
|
|
|
ACTIVE_TASK* get_task(RESULT*);
|
2007-02-23 17:29:19 +00:00
|
|
|
|
2007-02-24 14:55:59 +00:00
|
|
|
// --------------- cs_scheduler.C
|
|
|
|
private:
|
|
|
|
bool contacted_sched_server;
|
|
|
|
int overall_work_fetch_urgency;
|
|
|
|
double avg_proc_rate();
|
|
|
|
|
2007-02-23 17:29:19 +00:00
|
|
|
// --------------- work_fetch.C:
|
|
|
|
public:
|
|
|
|
int proj_min_results(PROJECT*, double);
|
|
|
|
void check_project_timeout();
|
|
|
|
PROJECT* next_project_master_pending();
|
|
|
|
PROJECT* next_project_sched_rpc_pending();
|
|
|
|
PROJECT* next_project_trickle_up_pending();
|
|
|
|
PROJECT* next_project_need_work();
|
|
|
|
PROJECT* find_project_with_overdue_results();
|
|
|
|
double overall_cpu_frac();
|
|
|
|
double time_until_work_done(PROJECT*, int, double);
|
|
|
|
bool compute_work_requests();
|
|
|
|
void scale_duration_correction_factors(double);
|
|
|
|
void generate_new_host_cpid();
|
|
|
|
void compute_nuploading_results();
|
|
|
|
|
|
|
|
//////////////////
|
|
|
|
int parse_projects(char*);
|
|
|
|
int parse_host(char*);
|
2007-04-06 19:47:37 +00:00
|
|
|
void simulate();
|
2007-02-23 17:29:19 +00:00
|
|
|
bool scheduler_rpc_poll();
|
2007-04-05 23:15:20 +00:00
|
|
|
bool simulate_rpc(PROJECT*);
|
2007-04-10 20:13:15 +00:00
|
|
|
void print_project_results(FILE*);
|
2007-02-15 21:11:05 +00:00
|
|
|
};
|
|
|
|
|
2007-02-21 22:27:35 +00:00
|
|
|
class NET_STATUS {
|
|
|
|
public:
|
|
|
|
bool have_sporadic_connection;
|
|
|
|
};
|
|
|
|
|
2007-02-15 21:11:05 +00:00
|
|
|
extern CLIENT_STATE gstate;
|
2007-02-24 14:55:59 +00:00
|
|
|
extern NET_STATUS net_status;
|