2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2007-05-01 21:21:13 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2007-05-01 21:21:13 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2007-05-01 21:21:13 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2007-05-01 21:21:13 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2007-05-01 21:21:13 +00:00
|
|
|
|
2007-04-30 22:43:45 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <algorithm>
|
2008-02-27 23:26:38 +00:00
|
|
|
#include <cstring>
|
2007-12-21 21:09:40 +00:00
|
|
|
#include <cstdio>
|
2007-04-30 22:43:45 +00:00
|
|
|
|
2008-02-05 21:26:43 +00:00
|
|
|
#ifdef _USING_FCGI_
|
|
|
|
#include "fcgi_stdio.h"
|
|
|
|
#endif
|
|
|
|
|
2008-05-08 17:48:40 +00:00
|
|
|
#ifdef SIM
|
|
|
|
#include <stdarg.h>
|
|
|
|
#else
|
|
|
|
#include "sched_config.h"
|
|
|
|
#include "sched_msgs.h"
|
|
|
|
#endif
|
|
|
|
|
2007-05-08 01:55:28 +00:00
|
|
|
#include "edf_sim.h"
|
|
|
|
|
2007-04-30 22:43:45 +00:00
|
|
|
using std::vector;
|
|
|
|
|
2008-05-08 17:48:40 +00:00
|
|
|
#define SUMMARY 0
|
|
|
|
// show candidate decision
|
|
|
|
#define WORKLOAD 1
|
|
|
|
// show workload
|
|
|
|
#define DETAIL 2
|
|
|
|
// show every step of simulation
|
2007-04-30 22:43:45 +00:00
|
|
|
|
2008-05-08 17:48:40 +00:00
|
|
|
static void log_msg(int level, const char* format, ...) {
|
|
|
|
#ifdef SIM
|
|
|
|
#else
|
|
|
|
switch(level) {
|
|
|
|
case SUMMARY:
|
|
|
|
if (!config.debug_send) return;
|
|
|
|
break;
|
|
|
|
case WORKLOAD:
|
|
|
|
if (!config.debug_edf_sim_workload) return;
|
|
|
|
break;
|
|
|
|
case DETAIL:
|
|
|
|
if (!config.debug_edf_sim_detail) return;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
va_list va;
|
|
|
|
va_start(va, format);
|
|
|
|
#ifdef SIM
|
|
|
|
vfprintf(stderr, format, va);
|
|
|
|
#else
|
|
|
|
log_messages.vprintf(MSG_DEBUG, format, va);
|
|
|
|
#endif
|
|
|
|
va_end(va);
|
|
|
|
}
|
- scheduler: add <workload_sim> config option.
If set, the scheduler will use EDF simulation,
together with the in-progress workload reported by the client,
to avoid sending results that
1) will miss their deadline, or
2) will cause an in-progress result to miss its deadline, or
3) will make an in-progress result miss its deadline
by more than is already predicted.
If this option is not set, or if the client request doesn't
include a workload description (i.e. the client is old)
use the existing approach, which assumes there's no workload.
NOTE: this is experimental. Production projects should not use it.
- EDF sim: write debug stuff to stderr instead of stdout
- Account manager:
- if an account is detach_when_done, set dont_request_more_work
- check done_request_more_work even for first-time projects
- update_uotd: generate a file for use by Google gadget
- user_links(): use full URLs (so can use in Google gadget)
client/
acct_mgr.C
work_fetch.C
html/
inc/
uotd.inc
util.inc
user/
uotd_gadget.php (new)
sched/
Makefile.am
edf_sim.C
sched_config.C,h
sched_resend.C
sched_send.C,h
server_types.C,h
svn path=/trunk/boinc/; revision=12639
2007-05-10 21:50:52 +00:00
|
|
|
|
2007-04-30 23:35:39 +00:00
|
|
|
bool lessthan_deadline(const IP_RESULT& p1, const IP_RESULT& p2) {
|
2007-04-30 22:43:45 +00:00
|
|
|
if (p1.computation_deadline < p2.computation_deadline) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-05-04 23:05:17 +00:00
|
|
|
// run an EDF simulation, marking which results will miss
|
2007-04-30 22:43:45 +00:00
|
|
|
// their deadlines and when
|
|
|
|
//
|
2007-04-30 23:35:39 +00:00
|
|
|
void mark_edf_misses (int ncpus, vector<IP_RESULT>& ip_results){
|
|
|
|
vector<IP_RESULT>::iterator ipp_it;
|
2007-05-10 16:07:45 +00:00
|
|
|
double booked_to[128];
|
2007-04-30 22:43:45 +00:00
|
|
|
int j;
|
|
|
|
|
2008-05-08 17:48:40 +00:00
|
|
|
log_msg(DETAIL, "mark_edf_misses\n");
|
2007-04-30 22:43:45 +00:00
|
|
|
|
|
|
|
// keeps track of when each cpu is next free
|
|
|
|
//
|
|
|
|
for (j=0; j<ncpus; j++) {
|
|
|
|
booked_to[j] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// sort ipp_results in ascending order by deadline
|
|
|
|
//
|
2007-04-30 23:35:39 +00:00
|
|
|
sort(ip_results.begin(), ip_results.end(), lessthan_deadline);
|
2007-04-30 22:43:45 +00:00
|
|
|
|
|
|
|
// simulate edf execution of all queued results
|
|
|
|
//
|
2007-04-30 23:35:39 +00:00
|
|
|
for (unsigned int i=0; i<ip_results.size(); i++) {
|
|
|
|
IP_RESULT& r = ip_results[i];
|
|
|
|
|
2007-04-30 22:43:45 +00:00
|
|
|
// find the CPU that will be free first
|
|
|
|
//
|
|
|
|
double lowest_booked_time = booked_to[0];
|
|
|
|
int lowest_booked_cpu = 0;
|
|
|
|
for (j=1; j<ncpus; j++) {
|
|
|
|
if (booked_to[j] < lowest_booked_time) {
|
|
|
|
lowest_booked_time = booked_to[j];
|
|
|
|
lowest_booked_cpu = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-30 23:35:39 +00:00
|
|
|
booked_to[lowest_booked_cpu] += r.cpu_time_remaining;
|
2008-05-08 17:48:40 +00:00
|
|
|
log_msg(DETAIL, " running %s on cpu %d; finishes at %.2f\n",
|
|
|
|
r.name, lowest_booked_cpu, booked_to[lowest_booked_cpu]/3600
|
2007-04-30 22:43:45 +00:00
|
|
|
);
|
2007-04-30 23:35:39 +00:00
|
|
|
if (booked_to[lowest_booked_cpu] > r.computation_deadline) {
|
|
|
|
r.misses_deadline = true;
|
|
|
|
r.estimated_completion_time = booked_to[lowest_booked_cpu];
|
2008-05-08 17:48:40 +00:00
|
|
|
log_msg(DETAIL, " %s misses_deadline; est completion %.2f\n",
|
|
|
|
r.name, booked_to[lowest_booked_cpu]/3600
|
2007-04-30 22:43:45 +00:00
|
|
|
);
|
|
|
|
} else {
|
2007-04-30 23:35:39 +00:00
|
|
|
r.misses_deadline = false;
|
2008-05-08 17:48:40 +00:00
|
|
|
log_msg(DETAIL, " %s makes deadline; est completion %.2f\n",
|
|
|
|
r.name, booked_to[lowest_booked_cpu]/3600
|
2007-04-30 22:43:45 +00:00
|
|
|
);
|
|
|
|
// if result doesn't miss its deadline,
|
|
|
|
// then the estimated_completion_time is of no use
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-08 17:48:40 +00:00
|
|
|
// For each ip_result, compute computation_deadline from report_deadline,
|
|
|
|
// and determine if the deadline would be missed by simulating EDF
|
2007-04-30 23:35:39 +00:00
|
|
|
//
|
|
|
|
void init_ip_results(
|
|
|
|
double work_buf_min,
|
|
|
|
int ncpus,
|
|
|
|
vector<IP_RESULT>& ip_results
|
|
|
|
){
|
|
|
|
unsigned int i;
|
- scheduler: add <workload_sim> config option.
If set, the scheduler will use EDF simulation,
together with the in-progress workload reported by the client,
to avoid sending results that
1) will miss their deadline, or
2) will cause an in-progress result to miss its deadline, or
3) will make an in-progress result miss its deadline
by more than is already predicted.
If this option is not set, or if the client request doesn't
include a workload description (i.e. the client is old)
use the existing approach, which assumes there's no workload.
NOTE: this is experimental. Production projects should not use it.
- EDF sim: write debug stuff to stderr instead of stdout
- Account manager:
- if an account is detach_when_done, set dont_request_more_work
- check done_request_more_work even for first-time projects
- update_uotd: generate a file for use by Google gadget
- user_links(): use full URLs (so can use in Google gadget)
client/
acct_mgr.C
work_fetch.C
html/
inc/
uotd.inc
util.inc
user/
uotd_gadget.php (new)
sched/
Makefile.am
edf_sim.C
sched_config.C,h
sched_resend.C
sched_send.C,h
server_types.C,h
svn path=/trunk/boinc/; revision=12639
2007-05-10 21:50:52 +00:00
|
|
|
|
2008-05-08 17:48:40 +00:00
|
|
|
log_msg(DETAIL,
|
|
|
|
"init_ip_results; work_buf_min %.2f ncpus %d:\n",
|
|
|
|
work_buf_min/3600, ncpus
|
|
|
|
);
|
2007-04-30 23:35:39 +00:00
|
|
|
for (i=0; i<ip_results.size(); i++) {
|
|
|
|
IP_RESULT& r = ip_results[i];
|
|
|
|
r.computation_deadline = r.report_deadline - work_buf_min;
|
2008-05-08 17:48:40 +00:00
|
|
|
log_msg(DETAIL, " %s: deadline %.2f cpu %.2f\n",
|
|
|
|
r.name, r.computation_deadline/3600, r.cpu_time_remaining/3600
|
- scheduler: add <workload_sim> config option.
If set, the scheduler will use EDF simulation,
together with the in-progress workload reported by the client,
to avoid sending results that
1) will miss their deadline, or
2) will cause an in-progress result to miss its deadline, or
3) will make an in-progress result miss its deadline
by more than is already predicted.
If this option is not set, or if the client request doesn't
include a workload description (i.e. the client is old)
use the existing approach, which assumes there's no workload.
NOTE: this is experimental. Production projects should not use it.
- EDF sim: write debug stuff to stderr instead of stdout
- Account manager:
- if an account is detach_when_done, set dont_request_more_work
- check done_request_more_work even for first-time projects
- update_uotd: generate a file for use by Google gadget
- user_links(): use full URLs (so can use in Google gadget)
client/
acct_mgr.C
work_fetch.C
html/
inc/
uotd.inc
util.inc
user/
uotd_gadget.php (new)
sched/
Makefile.am
edf_sim.C
sched_config.C,h
sched_resend.C
sched_send.C,h
server_types.C,h
svn path=/trunk/boinc/; revision=12639
2007-05-10 21:50:52 +00:00
|
|
|
);
|
2007-04-30 23:35:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// run edf simulation to determine whether any results miss their deadline
|
|
|
|
//
|
|
|
|
mark_edf_misses(ncpus, ip_results);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2007-04-30 22:43:45 +00:00
|
|
|
// Sort test_results by computation_deadline.
|
|
|
|
// For each test result in ascending order of deadline,
|
|
|
|
// see whether adding it to the work queue would cause deadline misses
|
|
|
|
// or deadline miss delays.
|
|
|
|
// If a test result passes these checks, append it to the work queue
|
|
|
|
// for further result additions.
|
|
|
|
// Return list of new results that can be sent to the client.
|
|
|
|
//
|
|
|
|
// NOTE: should we sort by increasing deadline or by increasing slack time?
|
|
|
|
//
|
|
|
|
vector<TEMP_RESULT> REQUEST_HANDLER_WORK_SEND::find_sendable_test_results (
|
|
|
|
vector<TEMP_RESULT> test_results,
|
|
|
|
int ncpus,
|
|
|
|
vector<TEMP_RESULT> ipp_results,
|
|
|
|
double cpu_pessimism_factor // = 1 by default
|
|
|
|
) {
|
|
|
|
//test results to send
|
|
|
|
vector<TEMP_RESULT> sendable_test_results;
|
|
|
|
vector<TEMP_RESULT>::iterator test_results_it;
|
|
|
|
|
|
|
|
sort(test_results.begin(), test_results.end(), lessthan_deadline);
|
|
|
|
|
|
|
|
// see if each test result can be added to the work queue without
|
|
|
|
// causing deadline misses or deadline miss delays
|
|
|
|
//
|
|
|
|
for (test_results_it = test_results.begin();
|
|
|
|
test_results_it != test_results.end();
|
|
|
|
test_results_it++
|
|
|
|
) {
|
|
|
|
bool failed = result_cause_deadline_miss_or_delay(
|
|
|
|
(*test_results_it).computation_deadline*cpu_pessimism_factor,
|
|
|
|
(*test_results_it).cpu_time_remaining,
|
|
|
|
ncpus,
|
|
|
|
ipp_results
|
|
|
|
);
|
|
|
|
if (!failed){
|
|
|
|
// add sendable result to work queue, copying by value, so that we
|
|
|
|
// can evaluate what happens if we add more new results to the queue
|
|
|
|
//
|
|
|
|
ipp_results.push_back(*test_results_it);
|
|
|
|
sendable_test_results.push_back (*test_results_it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (sendable_test_results);
|
|
|
|
}
|
2007-04-30 23:35:39 +00:00
|
|
|
#endif
|
2007-04-30 22:43:45 +00:00
|
|
|
|
2007-04-30 23:35:39 +00:00
|
|
|
// Return false if
|
2007-04-30 22:43:45 +00:00
|
|
|
// 1) the candidate result X would cause another result Y to miss its deadline
|
|
|
|
// (which Y would not have otherwise missed)
|
|
|
|
// 2) X causes another result Y to miss its deadline by more than
|
|
|
|
// it otherwise would have, or
|
|
|
|
// 3) X would miss its deadline
|
|
|
|
//
|
2007-04-30 23:35:39 +00:00
|
|
|
bool check_candidate (
|
2007-05-04 23:05:17 +00:00
|
|
|
IP_RESULT& candidate,
|
2007-04-30 22:43:45 +00:00
|
|
|
int ncpus,
|
2007-04-30 23:35:39 +00:00
|
|
|
vector<IP_RESULT> ip_results // passed by value (copy)
|
2007-04-30 22:43:45 +00:00
|
|
|
) {
|
2007-05-10 16:07:45 +00:00
|
|
|
double booked_to[128]; // keeps track of when each cpu is free
|
2007-04-30 22:43:45 +00:00
|
|
|
int j;
|
|
|
|
|
2008-05-08 17:48:40 +00:00
|
|
|
log_msg(DETAIL, "check_candidate %s: dl %.2f cpu %.2f\n",
|
|
|
|
candidate.name, candidate.computation_deadline/3600,
|
|
|
|
candidate.cpu_time_remaining/3600
|
2007-04-30 22:43:45 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
for (j=0; j<ncpus; j++) {
|
|
|
|
booked_to[j] = 0;
|
|
|
|
}
|
2007-04-30 23:35:39 +00:00
|
|
|
ip_results.push_back(candidate);
|
2007-04-30 22:43:45 +00:00
|
|
|
|
2007-04-30 23:35:39 +00:00
|
|
|
// sort ip_results in ascending order by deadline
|
2007-04-30 22:43:45 +00:00
|
|
|
//
|
2007-04-30 23:35:39 +00:00
|
|
|
sort(ip_results.begin(), ip_results.end(), lessthan_deadline);
|
2007-04-30 22:43:45 +00:00
|
|
|
|
|
|
|
// simulate execution of all queued results and test result
|
|
|
|
//
|
2007-04-30 23:35:39 +00:00
|
|
|
for (unsigned int i=0; i<ip_results.size(); i++) {
|
|
|
|
IP_RESULT& r = ip_results[i];
|
|
|
|
|
2007-04-30 22:43:45 +00:00
|
|
|
// find the CPU that will be free first
|
|
|
|
//
|
|
|
|
double lowest_booked_time = booked_to[0];
|
|
|
|
int lowest_booked_cpu = 0;
|
|
|
|
for (j=1; j<ncpus; j++) {
|
|
|
|
if (booked_to[j] < lowest_booked_time) {
|
|
|
|
lowest_booked_time = booked_to[j];
|
|
|
|
lowest_booked_cpu = j;
|
|
|
|
}
|
|
|
|
}
|
2007-04-30 23:35:39 +00:00
|
|
|
booked_to[lowest_booked_cpu] += r.cpu_time_remaining;
|
2008-05-08 17:48:40 +00:00
|
|
|
log_msg(DETAIL, " running %s on cpu %d; finishes at %.2f\n",
|
|
|
|
r.name, lowest_booked_cpu, booked_to[lowest_booked_cpu]/3600
|
2007-04-30 22:43:45 +00:00
|
|
|
);
|
|
|
|
|
2007-04-30 23:35:39 +00:00
|
|
|
// return false if completion time if > computation_deadline AND
|
2007-04-30 22:43:45 +00:00
|
|
|
// result would not have missed deadline to begin with
|
|
|
|
//
|
2007-04-30 23:35:39 +00:00
|
|
|
if (booked_to[lowest_booked_cpu] > r.computation_deadline
|
|
|
|
&& !r.misses_deadline
|
2007-04-30 22:43:45 +00:00
|
|
|
) {
|
2008-05-08 17:48:40 +00:00
|
|
|
log_msg(SUMMARY,
|
|
|
|
" cand. fails; %s now misses deadline: %.2f > %.2f\n",
|
|
|
|
r.name, booked_to[lowest_booked_cpu]/3600,
|
|
|
|
r.computation_deadline/3600
|
2007-04-30 22:43:45 +00:00
|
|
|
);
|
2007-04-30 23:35:39 +00:00
|
|
|
return false;
|
2007-04-30 22:43:45 +00:00
|
|
|
}
|
|
|
|
// check a late result (i.e., one that would have missed its
|
|
|
|
// deadline) // would be made even later
|
|
|
|
//
|
2007-04-30 23:35:39 +00:00
|
|
|
if (r.misses_deadline
|
|
|
|
&& booked_to[lowest_booked_cpu] > r.estimated_completion_time
|
2007-04-30 22:43:45 +00:00
|
|
|
){
|
2008-05-08 17:48:40 +00:00
|
|
|
log_msg(SUMMARY,
|
|
|
|
" cand. fails; late result %s would be returned even later\n",
|
|
|
|
r.name
|
|
|
|
);
|
2007-04-30 23:35:39 +00:00
|
|
|
return false;
|
2007-04-30 22:43:45 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-06 22:08:47 +00:00
|
|
|
log_msg(SUMMARY, " candidate succeeds\n");
|
2007-04-30 23:35:39 +00:00
|
|
|
return true;
|
2007-04-30 22:43:45 +00:00
|
|
|
}
|
|
|
|
|
2008-05-08 17:48:40 +00:00
|
|
|
#if 0
|
2007-04-30 22:43:45 +00:00
|
|
|
int main() {
|
|
|
|
vector<IP_RESULT> ip_results;
|
|
|
|
double work_buf_min = 0;
|
|
|
|
double cpu_pessimism_factor = 1;
|
|
|
|
int ncpus = 1;
|
2007-04-30 23:35:39 +00:00
|
|
|
bool flag;
|
2007-04-30 22:43:45 +00:00
|
|
|
|
|
|
|
ip_results.push_back(IP_RESULT("R1", 5, 3));
|
|
|
|
ip_results.push_back(IP_RESULT("R2", 5, 3));
|
2007-04-30 23:35:39 +00:00
|
|
|
init_ip_results(work_buf_min, ncpus, ip_results);
|
2007-04-30 22:43:45 +00:00
|
|
|
|
2007-04-30 23:35:39 +00:00
|
|
|
IP_RESULT c1 = IP_RESULT("C1", 10, 1);
|
|
|
|
if (check_candidate(c1, ncpus, ip_results)) {
|
|
|
|
printf("adding %s\n", c1.name);
|
|
|
|
ip_results.push_back(c1);
|
|
|
|
}
|
|
|
|
|
|
|
|
IP_RESULT c2 = IP_RESULT("C2", 7, 2);
|
|
|
|
if (check_candidate(c2, ncpus, ip_results)) {
|
|
|
|
printf("adding %s\n", c2.name);
|
|
|
|
ip_results.push_back(c2);
|
2007-04-30 22:43:45 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-08 01:55:28 +00:00
|
|
|
#endif
|