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, "
%s: %.2f | ", atp->result->name, atp->cpu_time_left); + SIM_PROJECT* p = (SIM_PROJECT*)atp->result->project; + fprintf(html_out, "%s: %.2f | ", + colors[p->index], atp->result->name, atp->cpu_time_left); } n++; } @@ -572,7 +617,7 @@ void CLIENT_STATE::html_rec() { fprintf(html_out, "%s | \n", html_msg.c_str()); + fprintf(html_out, "%s | \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 @@ +