diff --git a/checkin_notes b/checkin_notes index b7590c9920..6094551da1 100755 --- a/checkin_notes +++ b/checkin_notes @@ -3126,3 +3126,15 @@ Rom 4 Apr 2007 Rom 4 Apr 2007 (HEAD) - Tag for 5.9.3 release, all platforms boinc_core_release_5_9_3 + +David 5 Apr 2007 + - core client: round fractional work request up to 1 sec + - simulator now working + + client/ + scheduler_op.C + sim.C,h + sim_host/prefs/projects.xml (new) + lib/ + browser.C + prefs.C diff --git a/client/scheduler_op.C b/client/scheduler_op.C index 25a606edd9..a2a5c1e4d5 100644 --- a/client/scheduler_op.C +++ b/client/scheduler_op.C @@ -217,37 +217,36 @@ int SCHEDULER_OP::start_rpc(PROJECT* p) { int retval; char request_file[1024], reply_file[1024]; + // if requesting work, round up to 1 sec + // + if (p->work_request>0 && p->work_request<1) { + p->work_request = 1; + } + safe_strcpy(scheduler_url, p->get_scheduler_url(url_index, url_random)); if (log_flags.sched_ops) { msg_printf(p, MSG_INFO, "Sending scheduler request: %s", rpc_reason_string(reason) ); - if (p->work_request != 0.0 && p->nresults_returned != 0) { + if (p->work_request>0 && p->nresults_returned != 0) { msg_printf( p, MSG_INFO, - (p->work_request >= 1.0) ? - "Requesting %.0f seconds of new work, and reporting %d completed tasks": - "Requesting %g seconds of new work, and reporting %d completed tasks", + "Requesting %.0f seconds of new work, and reporting %d completed tasks", p->work_request, p->nresults_returned ); } else if (p->work_request != 0) { msg_printf( p, MSG_INFO, - (p->work_request >= 1.0) ? - "Requesting %.0f seconds of new work": - "Requesting %g seconds of new work", + "Requesting %.0f seconds of new work", p->work_request ); } else if (p->nresults_returned != 0) { - msg_printf( - p, MSG_INFO, - "Reporting %d tasks\n", - p->nresults_returned + msg_printf(p, MSG_INFO, + "Reporting %d tasks\n", p->nresults_returned ); } else { - msg_printf( - p, MSG_INFO, + msg_printf( p, MSG_INFO, "(not requesting new work or reporting completed tasks)" ); } diff --git a/client/sim.C b/client/sim.C index b4e4bb3171..84423702d1 100644 --- a/client/sim.C +++ b/client/sim.C @@ -237,10 +237,10 @@ RESULT* CLIENT_STATE::lookup_result(PROJECT* p, const char* name) { return 0; } -void CLIENT_STATE::simulate_rpc(PROJECT* p) { - static int result_num=0; +void CLIENT_STATE::simulate_rpc(PROJECT* _p) { double net_fpops = host_info.p_fpops; char buf[256]; + SIM_PROJECT* p = (SIM_PROJECT*) _p; // remove ready-to-report results // @@ -255,7 +255,7 @@ void CLIENT_STATE::simulate_rpc(PROJECT* p) { result_iter++; } } - sprintf(buf, "
RPC to %s; asking for %f", p->project_name, p->work_request); + sprintf(buf, "RPC to %s; asking for %f
", p->project_name, p->work_request); html_msg += buf; while (p->work_request > 0) { @@ -273,14 +273,14 @@ void CLIENT_STATE::simulate_rpc(PROJECT* p) { rp->clear(); rp->project = p; rp->wup = wup; - sprintf(rp->name, "%s_%d", p->project_name, result_num++); + sprintf(rp->name, "%s_%d", p->project_name, p->result_index++); rp->set_state(RESULT_FILES_DOWNLOADED, "simulate_rpc"); wup->project = p; wup->rsc_fpops_est = ap->fpops_est; results.push_back(rp); double ops = ap->fpops.sample(); rp->final_cpu_time = ops/net_fpops; - sprintf(buf, "
got job %s: %f", rp->name, rp->final_cpu_time); + sprintf(buf, "got job %s: %f
", rp->name, rp->final_cpu_time); html_msg += buf; p->work_request -= ap->fpops_est/net_fpops; } @@ -329,7 +329,7 @@ bool ACTIVE_TASK_SET::poll() { atp->result->exit_status = 0; gstate.request_schedule_cpus("ATP poll"); gstate.request_work_fetch("ATP poll"); - sprintf(buf, "
result %s finished\n", atp->result->name); + sprintf(buf, "result %s finished
", atp->result->name); gstate.html_msg += buf; } } @@ -365,7 +365,7 @@ int ACTIVE_TASK::resume_or_start(bool first_time) { } set_task_state(PROCESS_EXECUTING, "start"); char buf[256]; - sprintf(buf, "
Starting %s: %f", result->name, cpu_time_left); + sprintf(buf, "Starting %s: %f
", result->name, cpu_time_left); gstate.html_msg += buf; return 0; } @@ -392,15 +392,26 @@ PROJECT::PROJECT() { } double NORMAL_DIST::sample() { - int i; - double x=0; - for (i=0; i<9; i++) { - x += drand(); - } - x /= 3; - x *= var; - x += mean; - return x; + const double p0 = 0.322232431088; const double q0 = 0.099348462606; + const double p1 = 1.0; const double q1 = 0.588581570495; + const double p2 = 0.342242088547; const double q2 = 0.531103462366; + const double p3 = 0.204231210245e-1; const double q3 = 0.103537752850; + const double p4 = 0.453642210148e-4; const double q4 = 0.385607006340e-2; + double u, t, p, q, z; + + u = drand(); + if (u < 0.5) + t = sqrt(-2.0 * log(u)); + else + t = sqrt(-2.0 * log(1.0 - u)); + p = p0 + t * (p1 + t * (p2 + t * (p3 + t * p4))); + q = q0 + t * (q1 + t * (q2 + t * (q3 + t * q4))); + if (u < 0.5) + z = (p / q) - t; + else + z = t - (p / q); + return (mean + stdev * z); + } int NORMAL_DIST::parse(XML_PARSER& xp, char* end_tag) { @@ -409,9 +420,12 @@ int NORMAL_DIST::parse(XML_PARSER& xp, char* end_tag) { while(!xp.get(tag, sizeof(tag), is_tag)) { if (!is_tag) return ERR_XML_PARSE; if (xp.parse_double(tag, "mean", mean)) continue; - else if (xp.parse_double(tag, "var", var)) continue; + else if (xp.parse_double(tag, "stdev", stdev)) continue; else if (!strcmp(tag, end_tag)) return 0; - else return ERR_XML_PARSE; + else { + printf("unrecognized: %s\n", tag); + return ERR_XML_PARSE; + } } return ERR_XML_PARSE; } @@ -424,7 +438,10 @@ int UNIFORM_DIST::parse(XML_PARSER& xp, char* end_tag) { if (xp.parse_double(tag, "lo", lo)) continue; else if (xp.parse_double(tag, "hi", hi)) continue; else if (!strcmp(tag, end_tag)) return 0; - else return ERR_XML_PARSE; + else { + printf("unrecognized: %s\n", tag); + return ERR_XML_PARSE; + } } return ERR_XML_PARSE; } @@ -437,7 +454,10 @@ int RANDOM_PROCESS::parse(XML_PARSER& xp, char* end_tag) { if (xp.parse_double(tag, "frac", frac)) continue; else if (xp.parse_double(tag, "lambda", lambda)) continue; else if (!strcmp(tag, end_tag)) return 0; - else return ERR_XML_PARSE; + else { + printf("unrecognized: %s\n", tag); + return ERR_XML_PARSE; + } } return ERR_XML_PARSE; } @@ -461,7 +481,10 @@ int SIM_APP::parse(XML_PARSER& xp) { retval = checkpoint_period.parse(xp, "/checkpoint_period"); if (retval) return retval; } else if (xp.parse_double(tag, "working_set", working_set)) continue; - else return ERR_XML_PARSE; + else { + printf("unrecognized: %s\n", tag); + return ERR_XML_PARSE; + } } return ERR_XML_PARSE; } @@ -485,7 +508,10 @@ int SIM_PROJECT::parse(XML_PARSER& xp) { if (retval) return retval; } else if (xp.parse_double(tag, "resource_share", resource_share)) { continue; - } else return ERR_XML_PARSE; + } else { + printf("unrecognized: %s\n", tag); + return ERR_XML_PARSE; + } } return ERR_XML_PARSE; } @@ -508,7 +534,10 @@ int SIM_HOST::parse(XML_PARSER& xp) { } else if (!strcmp(tag, "idle")) { retval = idle.parse(xp, "/idle"); if (retval) return retval; - } else return ERR_XML_PARSE; + } else { + printf("unrecognized: %s\n", tag); + return ERR_XML_PARSE; + } } return ERR_XML_PARSE; } @@ -517,7 +546,7 @@ int CLIENT_STATE::parse_projects(char* name) { char tag[256]; bool is_tag; MIOFILE mf; - int retval; + int retval, index=0; FILE* f = fopen(name, "r"); if (!f) return ERR_FOPEN; @@ -531,9 +560,14 @@ int CLIENT_STATE::parse_projects(char* name) { p->init(); retval = p->parse(xp); if (retval) return retval; + p->index = index++; + p->result_index = 0; projects.push_back(p); } else if (!strcmp(tag, "/projects")) { return 0; + } else { + printf("unrecognized: %s\n", tag); + return ERR_XML_PARSE; } } return ERR_XML_PARSE; @@ -550,6 +584,15 @@ int CLIENT_STATE::parse_host(char* name) { return host_info.parse(xp); } +char* colors[] = { + "#ffffdd", + "#ffddff", + "#ddffff", + "#ddffdd", + "#ddddff", + "#ffdddd", +}; + void CLIENT_STATE::html_start() { html_out = fopen("sim_out.html", "w"); fprintf(html_out, "\n"); @@ -561,7 +604,9 @@ void CLIENT_STATE::html_rec() { for (unsigned int i=0; itask_state() == PROCESS_EXECUTING) { - fprintf(html_out, "", atp->result->name, atp->cpu_time_left); + SIM_PROJECT* p = (SIM_PROJECT*)atp->result->project; + fprintf(html_out, "", + colors[p->index], atp->result->name, atp->cpu_time_left); } n++; } @@ -572,7 +617,7 @@ void CLIENT_STATE::html_rec() { fprintf(html_out, ""); n++; } - fprintf(html_out, "\n", html_msg.c_str()); + fprintf(html_out, "\n", html_msg.c_str()); html_msg = ""; } @@ -603,8 +648,8 @@ void CLIENT_STATE::simulate(double duration, double delta) { html_end(); } -void parse_error(char* file) { - printf("can't parse %s\n", file); +void parse_error(char* file, int retval) { + printf("can't parse %s: %d\n", file, retval); exit(1); } @@ -623,7 +668,7 @@ char* next_arg(int argc, char** argv, int& i) { int main(int argc, char** argv) { char projects[256], host[256], prefs[256]; - double duration = 20000, delta = 10; + double duration = 200, delta = 10; bool flag; int i, retval; @@ -647,11 +692,11 @@ int main(int argc, char** argv) { read_config_file(); retval = gstate.parse_projects(projects); - if (retval) parse_error("projects"); + if (retval) parse_error(projects, retval); retval = gstate.parse_host(host); - if (retval) parse_error("host"); + if (retval) parse_error(host, retval); retval = gstate.global_prefs.parse_file(prefs, "", flag); - if (retval) parse_error("prefs"); + if (retval) parse_error(prefs, retval); gstate.set_ncpus(); printf("ncpus: %d\n", gstate.ncpus); diff --git a/client/sim.h b/client/sim.h index 6888056796..5887fe3664 100644 --- a/client/sim.h +++ b/client/sim.h @@ -23,7 +23,7 @@ using std::vector; class NORMAL_DIST { public: double mean; - double var; + double stdev; int parse(XML_PARSER&, char* end_tag); double sample(); }; @@ -59,6 +59,8 @@ public: class SIM_PROJECT: public PROJECT { public: RANDOM_PROCESS available; + int index; + int result_index; int parse(XML_PARSER&); }; diff --git a/client/sim_host.xml b/client/sim_host.xml new file mode 100644 index 0000000000..63fee0cb8f --- /dev/null +++ b/client/sim_host.xml @@ -0,0 +1,9 @@ + + 1 + 1e9 + 2 + + .8 + 1000 + + diff --git a/client/sim_prefs.xml b/client/sim_prefs.xml new file mode 100644 index 0000000000..42462cddaf --- /dev/null +++ b/client/sim_prefs.xml @@ -0,0 +1,23 @@ + + http://isaac.ssl.berkeley.edu/alpha/ + isaac.ssl.berkeley.edu/alpha_cgi/cgi +1170192285 + +3 + +1 + +0.0001 +4 +100 +180 +100 +50 +2 +75 +50 +90 +200000 +200000 + + diff --git a/client/sim_projects.xml b/client/sim_projects.xml new file mode 100644 index 0000000000..e01d8577a5 --- /dev/null +++ b/client/sim_projects.xml @@ -0,0 +1,36 @@ + + + P1 + 100 + + 1000 + 100 + + 100 + 10 + + 1e7 + + + .7 + 1000 + + + + P2 + 50 + + 500 + 50 + + 50 + 10 + + 1e7 + + + .7 + 1000 + + + diff --git a/doc/compile.php b/doc/compile.php index 5a94499a38..4318563d92 100644 --- a/doc/compile.php +++ b/doc/compile.php @@ -8,7 +8,6 @@ THIS FILE IS DEPRECATED. DON'T LINK TO IT.

Platform-specific cookbooks

diff --git a/lib/browser.C b/lib/browser.C index f043921b2d..be296f2247 100644 --- a/lib/browser.C +++ b/lib/browser.C @@ -46,10 +46,11 @@ typedef HRESULT (WINAPI *MYSHGETFOLDERPATH)(HWND hwnd, int csidl, HANDLE hToken, #endif -// reterieve the user's application data directory. +// retrieve the user's application data directory. // Win : C:\Documents and Settings\\Application Data -// Linux: ~/ -bool get_home_dir_path( std::string& path ) { +// Unix: ~/ +// +void get_home_dir_path( std::string& path ) { #ifdef _WIN32 TCHAR szBuffer[MAX_PATH]; HMODULE hShell32; @@ -57,8 +58,9 @@ bool get_home_dir_path( std::string& path ) { // Attempt to link to dynamic function if it exists hShell32 = LoadLibrary(_T("SHELL32.DLL")); - if (NULL != hShell32) + if (NULL != hShell32) { pfnMySHGetFolderPath = (MYSHGETFOLDERPATH) GetProcAddress(hShell32, _T("SHGetFolderPathA")); + } if (NULL != pfnMySHGetFolderPath) { if (SUCCEEDED((pfnMySHGetFolderPath)(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, szBuffer))) { @@ -68,15 +70,13 @@ bool get_home_dir_path( std::string& path ) { } // Free the dynamically linked to library - if (NULL != hShell32) + if (NULL != hShell32) { FreeLibrary(hShell32); + } #else - path = std::string(_T("~/")); + path = std::string("~/"); #endif - if (!path.empty()) - return true; - return false; } // parse name value pairs based on INI file rules. diff --git a/lib/prefs.C b/lib/prefs.C index cbe155d3dc..70a1a960ce 100644 --- a/lib/prefs.C +++ b/lib/prefs.C @@ -107,7 +107,7 @@ void GLOBAL_PREFS::defaults() { hangup_if_dialed = false; dont_verify_images = false; work_buf_min_days = 0.1; - work_buf_additional_days = 1.0; + work_buf_additional_days = 0; max_cpus = 16; cpu_scheduling_period_minutes = 60; disk_interval = 60; @@ -324,7 +324,7 @@ int GLOBAL_PREFS::parse_override( mask.dont_verify_images = true; continue; } else if (xp.parse_double(tag, "work_buf_min_days", work_buf_min_days)) { - if (work_buf_min_days < 0.01) work_buf_min_days = 0.01; + if (work_buf_min_days < 0.00001) work_buf_min_days = 0.00001; mask.work_buf_min_days = true; continue; } else if (xp.parse_double(tag, "work_buf_additional_days", work_buf_additional_days)) {
%s: %.2f%s: %.2f
%s
%s