diff --git a/checkin_notes b/checkin_notes index bfcd454d4e..0d355126b1 100755 --- a/checkin_notes +++ b/checkin_notes @@ -4404,7 +4404,15 @@ David 4 May 2007 David 4 May 2007 - API: if using graphics, set worker thread stack size limit to max - (from Rosetta@home) + (from Rhiju Das of Rosetta@home) api/ graphics_impl.C + +David 4 May 2007 + - Sim-related stuff + + sched/ + edf_sim.C + client/ + sim.C,h diff --git a/client/sim.C b/client/sim.C index 79b1902d1a..9ba203e00f 100644 --- a/client/sim.C +++ b/client/sim.C @@ -48,6 +48,7 @@ bool user_active; double duration = 86400, delta = 60; FILE* logfile; bool running; +double running_time = 0; SIM_RESULTS sim_results; @@ -167,8 +168,8 @@ void SIM_PROJECT::init() { rr_sim_deadlines_missed = 0; deadlines_missed = 0; - idle_period_duration = 0; - idle_period_sumsq = 0; + idle_time = 0; + idle_time_sumsq = 0; } void RESULT::clear() { @@ -443,16 +444,13 @@ bool ACTIVE_TASK_SET::poll() { for (i=0; iidle) { - p->idle_period_duration += diff; + p->idle_time += diff; + p->idle_time_sumsq += diff*(p->idle_time*p->idle_time); } else { - double ipd = p->idle_period_duration; - if (ipd) { - p->idle_period_sumsq += ipd*ipd; - p->nidle_periods++; - } - p->idle_period_duration = 0; + p->idle_time = 0; } } + running_time += diff; return action; } @@ -676,21 +674,26 @@ double CLIENT_STATE::share_violation() { } -// "variety" is defined as the RMS of the duration of idle periods -// across all projects +// "variety" is defined as follows: +// for each project P, maintain R(P), the time since P last ran, +// let S(P) be the RMS of R(P). +// Let variety = mean(S(P)) // double CLIENT_STATE::variety() { double sum = 0; - int n = 0; + double schedint = global_prefs.cpu_scheduling_period_minutes*60; unsigned int i; for (i=0; iidle_period_sumsq; - n += p->nidle_periods; + double avg_ss = p->idle_time_sumsq/running_time; + double s = sqrt(avg_ss); + sum += s; } - return sqrt(sum/n); + return sum/(projects.size()*schedint); } +// the CPU totals are there; compute the other fields +// void SIM_RESULTS::compute() { double total = cpu_used + cpu_wasted + cpu_idle; cpu_wasted_frac = cpu_wasted/total; @@ -703,7 +706,7 @@ void SIM_RESULTS::compute() { // void SIM_RESULTS::print(FILE* f, const char* title) { if (title) { - fprintf(f, title); + fprintf(f, "%s: ", title); } fprintf(f, "wasted_frac %f idle_frac %f share_violation %f variety %f\n", cpu_wasted_frac, cpu_idle_frac, share_violation, variety @@ -712,20 +715,26 @@ void SIM_RESULTS::print(FILE* f, const char* title) { void SIM_RESULTS::parse(FILE* f) { fscanf(f, "wasted_frac %lf idle_frac %lf share_violation %lf variety %lf", - &cpu_wasted, &cpu_idle, &share_violation, &variety + &cpu_wasted_frac, &cpu_idle_frac, &share_violation, &variety ); } + void SIM_RESULTS::add(SIM_RESULTS& r) { - cpu_used += r.cpu_used; - cpu_wasted += r.cpu_wasted; - cpu_idle += r.cpu_idle; - nresults_met_deadline += r.nresults_met_deadline; - nresults_missed_deadline += r.nresults_missed_deadline; + cpu_wasted_frac += r.cpu_wasted_frac; + cpu_idle_frac += r.cpu_idle_frac; + share_violation += r.share_violation; + variety += r.variety; } -SIM_RESULTS::SIM_RESULTS() { - cpu_used = 0; cpu_wasted=0; cpu_idle=0; - nresults_met_deadline = 0; nresults_missed_deadline = 0; +void SIM_RESULTS::divide(int n) { + cpu_wasted_frac /= n; + cpu_idle_frac /= n; + share_violation /= n; + variety /= n; +} + +void SIM_RESULTS::clear() { + memset(this, 0, sizeof(*this)); } void SIM_PROJECT::print_results(FILE* f, SIM_RESULTS& sr) { @@ -954,6 +963,7 @@ int main(int argc, char** argv) { logfile = fopen("sim_log.txt", "w"); + sim_results.clear(); for (i=1; i %s", duration, delta, SUMMARY_FILE ); - system(buf); + retval = system(buf); + if (retval) { + printf("simulation in %s failed\n", dir.c_str()); + exit(1); + } FILE* f = fopen(SUMMARY_FILE, "r"); sim_results.parse(f); fclose(f); @@ -1007,6 +1022,7 @@ int main(int argc, char** argv) { total_results.add(sim_results); chdir(".."); } + total_results.divide(dirs.size()); total_results.print(stdout, "Total"); } else { read_config_file(); diff --git a/client/sim.h b/client/sim.h index de23a39960..c0cd4a21b4 100644 --- a/client/sim.h +++ b/client/sim.h @@ -34,7 +34,8 @@ struct SIM_RESULTS { void print(FILE* f, const char* title=0); void parse(FILE* f); void add(SIM_RESULTS& r); - SIM_RESULTS(); + void divide(int); + void clear(); }; struct PROJECT_RESULTS { @@ -92,9 +93,8 @@ public: RANDOM_PROCESS available; int index; int result_index; - int nidle_periods; - double idle_period_duration; - double idle_period_sumsq; + double idle_time; + double idle_time_sumsq; bool idle; int parse(XML_PARSER&); diff --git a/sched/edf_sim.C b/sched/edf_sim.C index 7264859970..e68db31036 100644 --- a/sched/edf_sim.C +++ b/sched/edf_sim.C @@ -53,7 +53,7 @@ bool lessthan_deadline(const IP_RESULT& p1, const IP_RESULT& p2) { return false; } -// runs an edf simulation, markings which results will miss +// run an EDF simulation, marking which results will miss // their deadlines and when // void mark_edf_misses (int ncpus, vector& ip_results){ @@ -185,7 +185,7 @@ vector REQUEST_HANDLER_WORK_SEND::find_sendable_test_results ( // 3) X would miss its deadline // bool check_candidate ( - IP_RESULT candidate, + IP_RESULT& candidate, int ncpus, vector ip_results // passed by value (copy) ) {