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-05-08 01:55:28 +00:00
|
|
|
#include "../sched/edf_sim.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;
|
2007-07-12 19:52:58 +00:00
|
|
|
double monotony;
|
2007-04-10 21:56:11 +00:00
|
|
|
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);
|
2007-05-04 23:05:17 +00:00
|
|
|
void divide(int);
|
|
|
|
void clear();
|
2007-04-10 20:13:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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-05-04 23:05:17 +00:00
|
|
|
double idle_time;
|
|
|
|
double idle_time_sumsq;
|
2007-04-10 20:13:15 +00:00
|
|
|
bool idle;
|
2007-05-08 23:12:40 +00:00
|
|
|
int max_infeasible_count;
|
2007-05-09 15:23:10 +00:00
|
|
|
// for DCF variants:
|
|
|
|
int completed_task_count;
|
|
|
|
double completions_ratio_mean;
|
|
|
|
double completions_ratio_s;
|
|
|
|
double completions_ratio_stdev;
|
|
|
|
double completions_required_stdevs;
|
2007-04-10 20:13:15 +00:00
|
|
|
|
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-05-08 01:55:28 +00:00
|
|
|
void backoff();
|
2007-05-09 15:23:10 +00:00
|
|
|
void update_dcf_stats(RESULT*);
|
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;
|
2008-04-01 20:46:41 +00:00
|
|
|
COPROCS coprocs;
|
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;
|
2007-07-12 18:38:53 +00:00
|
|
|
void html_start(bool);
|
2007-04-04 15:40:07 +00:00
|
|
|
void html_rec();
|
2007-07-12 18:38:53 +00:00
|
|
|
void html_end(bool);
|
2007-04-04 15:40:07 +00:00
|
|
|
std::string html_msg;
|
2007-04-10 20:13:15 +00:00
|
|
|
double share_violation();
|
2007-07-12 19:52:58 +00:00
|
|
|
double monotony();
|
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();
|
2008-03-27 18:35:57 +00:00
|
|
|
void make_running_task_heap(vector<ACTIVE_TASK*>&, double&);
|
2007-02-15 21:11:05 +00:00
|
|
|
void print_deadline_misses();
|
2007-04-03 19:06:26 +00:00
|
|
|
public:
|
2007-06-25 19:05:29 +00:00
|
|
|
double retry_shmem_time;
|
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*);
|
2008-04-01 20:46:41 +00:00
|
|
|
bool sufficient_coprocs(APP_VERSION&);
|
|
|
|
void reserve_coprocs(APP_VERSION&);
|
|
|
|
void free_coprocs(APP_VERSION&);
|
2007-02-15 21:11:05 +00:00
|
|
|
|
|
|
|
// --------------- 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);
|
2007-11-07 19:32:32 +00:00
|
|
|
int input_files_available(RESULT*, bool, FILE_INFO** f=0);
|
2007-02-15 21:11:05 +00:00
|
|
|
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();
|
|
|
|
|
|
|
|
//////////////////
|
2007-05-08 01:55:28 +00:00
|
|
|
void make_job(SIM_PROJECT*, WORKUNIT*, RESULT*);
|
|
|
|
void handle_completed_results();
|
|
|
|
void get_workload(vector<IP_RESULT>&);
|
2007-02-23 17:29:19 +00:00
|
|
|
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;
|
2007-05-08 01:55:28 +00:00
|
|
|
extern FILE* logfile;
|
|
|
|
extern bool user_active;
|
|
|
|
extern SIM_RESULTS sim_results;
|
|
|
|
extern double calculate_exponential_backoff(
|
|
|
|
int n, double MIN, double MAX
|
|
|
|
);
|
|
|
|
|
2007-05-09 15:23:10 +00:00
|
|
|
extern bool dcf_dont_use;
|
|
|
|
extern bool dcf_stats;
|
2007-05-15 20:29:26 +00:00
|
|
|
extern bool cpu_sched_rr_only;
|
|
|
|
extern bool dual_dcf;
|
2007-07-11 20:13:53 +00:00
|
|
|
extern bool work_fetch_old;
|