From e97c64b92f954fc2c35bf9015345e805ff22c66a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 15 Jan 2011 08:11:21 +0000 Subject: [PATCH] - make the Manager build on FC11 - simulator work svn path=/trunk/boinc/; revision=22906 --- checkin_notes | 12 ++++++ client/sim.cpp | 23 +++++++----- client/sim_control.php | 85 ++++++++++++++++++++++++++++++++++++++---- clientgui/Makefile.am | 6 +-- sched/edf_sim.cpp | 30 +++++++++------ 5 files changed, 124 insertions(+), 32 deletions(-) diff --git a/checkin_notes b/checkin_notes index 5802c576ba..90a3055129 100644 --- a/checkin_notes +++ b/checkin_notes @@ -152,3 +152,15 @@ Bernd 14 Jan 2011 so these could be used in proprocessor directives generate_svn_version.sh + +David 14 Jan 2011 + - make the Manager build on FC11 + - simulator work + + clientgui/ + Makefile.am + sched/ + edf_sim.cpp + client/ + sim.cpp + sim_control.php diff --git a/client/sim.cpp b/client/sim.cpp index 30798d4287..117058b886 100644 --- a/client/sim.cpp +++ b/client/sim.cpp @@ -248,12 +248,17 @@ void CLIENT_STATE::handle_completed_results(PROJECT* p) { while (result_iter != results.end()) { RESULT* rp = *result_iter; if (rp->project == p && rp->ready_to_report) { - sprintf(buf, "result %s reported; %s
", - rp->name, - (gstate.now > rp->report_deadline)? - "MISSED DEADLINE": - "MADE DEADLINE" - ); + if (gstate.now > rp->report_deadline) { + sprintf(buf, "result %s reported; " + "MISSED DEADLINE by %f
\n", + rp->name, gstate.now - rp->report_deadline + ); + } else { + sprintf(buf, "result %s reported; " + "MADE DEADLINE
\n", + rp->name + ); + } PROJECT* spp = rp->project; if (gstate.now > rp->report_deadline) { sim_results.flops_wasted += rp->peak_flop_count; @@ -281,7 +286,7 @@ void CLIENT_STATE::get_workload(vector& ip_results) { RESULT* rp = results[i]; double x = rp->estimated_time_remaining(); if (x == 0) continue; - IP_RESULT ipr(rp->name, rp->report_deadline, x); + IP_RESULT ipr(rp->name, rp->report_deadline-now, x); ip_results.push_back(ipr); } init_ip_results(work_buf_min(), ncpus, ip_results); @@ -371,8 +376,9 @@ bool CLIENT_STATE::simulate_rpc(PROJECT* p) { WORKUNIT* wup = new WORKUNIT; make_job(p, wup, rp, apps); + double et = wup->rsc_fpops_est / rp->avp->flops; if (server_uses_workload) { - IP_RESULT c(rp->name, rp->report_deadline, rp->final_cpu_time); + IP_RESULT c(rp->name, rp->report_deadline-now, et); if (check_candidate(c, ncpus, ip_results)) { ip_results.push_back(c); } else { @@ -384,7 +390,6 @@ bool CLIENT_STATE::simulate_rpc(PROJECT* p) { continue; } } else { - double et = wup->rsc_fpops_est / rp->avp->flops; if (get_estimated_delay(rp) + et > wup->app->latency_bound) { //printf("%d: %s misses deadline\n", (int)gstate.now, p->project_name); APP_VERSION* avp = rp->avp; diff --git a/client/sim_control.php b/client/sim_control.php index 09360d400d..cc31c404a2 100644 --- a/client/sim_control.php +++ b/client/sim_control.php @@ -111,6 +111,8 @@ function do_sim($in, $out, $policy) { system($cmd); } +// display N results (usually 2) as bar graphs +// function write_gp_bar($fname, $title, $data_fname) { $f = fopen($fname, "w"); $s = << $png_fname"); } -function graph_n_results($title, $dir, $results) { +function graph_n_results1($title, $dir, $results) { $data_fname = "$dir/cr.dat"; $f = fopen($data_fname, "w"); foreach ($results as $r) { @@ -175,6 +198,22 @@ function graph_n_results($title, $dir, $results) { system("gnuplot < $gp_fname > $png_fname"); } +function graph_n_results2($title, $xlabel, $lab1, $lab2, $dir, $results1, $results2) { + for ($i=0; $i<2; $i++) { + $data_fname = "$dir/cr_$i.dat"; + $f = fopen($data_fname, "w"); + $rr = $i?$results2:$results1; + foreach ($rr as $r) { + $r->write($f); + } + fclose($f); + } + $gp_fname = "$dir/cr.gp"; + $png_fname = "$dir/cr.png"; + write_gp_line2($gp_fname, $title, $xlabel, $lab1, $lab2, "$dir/cr_0.dat", "$dir/cr_1.dat"); + system("gnuplot < $gp_fname > $png_fname"); +} + // create output dir, do a simulation, accumulate results // function do_sim_aux($out_dir, $scenario, $policy, $pname, $sum) { @@ -186,7 +225,7 @@ function do_sim_aux($out_dir, $scenario, $policy, $pname, $sum) { } function do_sim_param($out_dir, $scenario, $policy, $param, $sum) { - $sim_out_dir = $out_dir."/".$scenario."_".$param; + $sim_out_dir = $out_dir."/".$scenario."_".$policy->name."_".$param; @mkdir($sim_out_dir); $cs_template_fname = "$scenario/client_state_template.xml"; $cs_fname = "$scenario/client_state.xml"; @@ -223,7 +262,7 @@ function compare_policies($title, $set, $p1, $p2, $out_dir) { // Outputs are stored in the given directory. // Subdirectories scenario_arg/ store individual sim outputs // -function compare_params($title, $set, $policy, $lo, $hi, $inc, $out_dir) { +function compare_params1($title, $set, $policy, $lo, $hi, $inc, $out_dir) { @mkdir($out_dir); $results = array(); for ($x = $lo; $x <= $hi; $x += $inc) { @@ -233,7 +272,28 @@ function compare_params($title, $set, $policy, $lo, $hi, $inc, $out_dir) { } $results[] = $sum; } - graph_n_results($title, $out_dir, $results); + graph_n_results1($title, $out_dir, $results); +} + +// same, but compare 2 policies and graph only wasted CPU +// +function compare_params2($title, $xlabel, $lab1, $lab2, $set, $p1, $p2, $lo, $hi, $inc, $out_dir) { + @mkdir($out_dir); + $rr1 = array(); + $rr2 = array(); + for ($x = $lo; $x <= $hi; $x += $inc) { + $sum = new RESULT($x); + foreach ($set as $s) { + $sum = do_sim_param($out_dir, $s, $p1, $x, $sum); + } + $rr1[] = $sum; + $sum = new RESULT($x); + foreach ($set as $s) { + $sum = do_sim_param($out_dir, $s, $p2, $x, $sum); + } + $rr2[] = $sum; + } + graph_n_results2($title, $xlabel, $lab1, $lab2, $out_dir, $rr1, $rr2); } ///////////// EXAMPLE USAGES //////////// @@ -247,15 +307,24 @@ if (0) { compare_policies("Scenario 2", array("scen2"), $p1, $p2, "test1"); } -// evaluate a policy over a set of parameterized policies -// -if (1) { +if (0) { $p = new POLICY(""); $p->use_rec = true; $lo = 2e9; $hi = 1e10; $inc = 1e9; - compare_params("Scenario 3", array("s3"), $p, $lo, $hi, $inc, "test2"); + compare_params1("Scenario 3", array("s3"), $p, $lo, $hi, $inc, "test2"); +} + +// compare WRR and EDF +if (1) { + $p1 = new POLICY("DC_SIM"); + $p1->server_uses_workload = true; + $p2 = new POLICY("DC_APPROX"); + $lo = 1000; + $hi = 2000; + $inc = 100; + compare_params2("Wasted processing", "Job deadline", "DC_SIM", "DC_APPROX", array("scen5"), $p1, $p2, $lo, $hi, $inc, "test6"); } if (0) { diff --git a/clientgui/Makefile.am b/clientgui/Makefile.am index 1bb605462c..8335eea89e 100644 --- a/clientgui/Makefile.am +++ b/clientgui/Makefile.am @@ -118,9 +118,9 @@ EXTRA_DIST = *.h \ ../lib/error_numbers.h \ locale $(mac_headers) -boincmgr_CPPFLAGS = $(AM_CPPFLAGS) $(WX_CPPFLAGS) $(SQLITE3_CPPFLAGS) $(LIBNOTIFY_CFLAGS) $(CLIENTGUIFLAGS) -boincmgr_CXXFLAGS = $(AM_CXXFLAGS) $(WX_CXXFLAGS) $(SQLITE3_CPPFLAGS) $(LIBNOTIFY_CFLAGS) $(CLIENTGUIFLAGS) -boincmgr_LDADD = $(LIBBOINC) $(SQLITE3_LIBS) $(LIBNOTIFY_LIBS) $(CLIENTGUILIBS) $(BOINC_EXTRA_LIBS) $(CLIENTLIBS) +boincmgr_CPPFLAGS = $(AM_CPPFLAGS) $(WX_CPPFLAGS) $(SQLITE3_CPPFLAGS) $(LIBNOTIFY_CFLAGS) $(CLIENTGUIFLAGS) `pkg-config --cflags gtk+-2.0` +boincmgr_CXXFLAGS = $(AM_CXXFLAGS) $(WX_CXXFLAGS) $(SQLITE3_CPPFLAGS) $(LIBNOTIFY_CFLAGS) $(CLIENTGUIFLAGS) `pkg-config --cflags gtk+-2.0` +boincmgr_LDFLAGS = $(LIBBOINC) $(SQLITE3_LIBS) $(LIBNOTIFY_LIBS) $(CLIENTGUILIBS) $(BOINC_EXTRA_LIBS) $(CLIENTLIBS) `pkg-config --libs gtk+-2.0` -lnotify win_config.h: $(top_srcdir)/config.h grep '#define.*BOINC.*VERSION' $^ > $@ diff --git a/sched/edf_sim.cpp b/sched/edf_sim.cpp index 4c51299b4e..7f8ee25e3f 100644 --- a/sched/edf_sim.cpp +++ b/sched/edf_sim.cpp @@ -33,6 +33,9 @@ #include "edf_sim.h" +#ifdef SIM +extern FILE* logfile; +#endif using std::vector; @@ -43,6 +46,9 @@ using std::vector; #define DETAIL 2 // show every step of simulation +#define TIME_SCALE 1 +//#define TIME_SCALE 3600 + static void log_msg(int level, const char* format, ...) { #ifdef SIM #else @@ -61,7 +67,7 @@ static void log_msg(int level, const char* format, ...) { va_list va; va_start(va, format); #ifdef SIM - vfprintf(stderr, format, va); + vfprintf(logfile, format, va); #else log_messages.vprintf(MSG_NORMAL, format, va); #endif @@ -111,18 +117,18 @@ void mark_edf_misses (int ncpus, vector& ip_results){ booked_to[lowest_booked_cpu] += r.cpu_time_remaining; log_msg(DETAIL, "[edf_detail] running %s on cpu %d; finishes at %.2f\n", - r.name, lowest_booked_cpu, booked_to[lowest_booked_cpu]/3600 + r.name, lowest_booked_cpu, booked_to[lowest_booked_cpu]/TIME_SCALE ); if (booked_to[lowest_booked_cpu] > r.computation_deadline) { r.misses_deadline = true; r.estimated_completion_time = booked_to[lowest_booked_cpu]; log_msg(DETAIL, "[edf_detail] %s misses_deadline; est completion %.2f\n", - r.name, booked_to[lowest_booked_cpu]/3600 + r.name, booked_to[lowest_booked_cpu]/TIME_SCALE ); } else { r.misses_deadline = false; log_msg(DETAIL, "[edf_detail] %s makes deadline; est completion %.2f\n", - r.name, booked_to[lowest_booked_cpu]/3600 + r.name, booked_to[lowest_booked_cpu]/TIME_SCALE ); // if result doesn't miss its deadline, // then the estimated_completion_time is of no use @@ -142,13 +148,13 @@ void init_ip_results( log_msg(DETAIL, "[edf_detail] init_ip_results; work_buf_min %.2f ncpus %d:\n", - work_buf_min/3600, ncpus + work_buf_min/TIME_SCALE, ncpus ); for (i=0; i computation_deadline AND @@ -262,8 +268,8 @@ bool check_candidate ( ) { log_msg(SUMMARY, "[send] cand. fails; %s now misses deadline: %.2f > %.2f\n", - r.name, booked_to[lowest_booked_cpu]/3600, - r.computation_deadline/3600 + r.name, booked_to[lowest_booked_cpu]/TIME_SCALE, + r.computation_deadline/TIME_SCALE ); return false; }