2008-11-14 22:08:50 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2009-03-19 16:55:04 +00:00
|
|
|
// Simulate the processing of the current workload
|
|
|
|
// (include jobs that are downloading)
|
2009-02-01 04:37:19 +00:00
|
|
|
// with weighted round-robin (WRR) scheduling.
|
|
|
|
//
|
|
|
|
// For efficiency, we simulate an approximation of WRR.
|
|
|
|
// We don't model time-slicing.
|
|
|
|
// Instead we use a continuous model where, at a given point,
|
2009-03-19 16:55:04 +00:00
|
|
|
// each project has a set of running jobs that uses at most all CPUs.
|
2009-02-01 04:37:19 +00:00
|
|
|
// These jobs are assumed to run at a rate proportionate to their avg_ncpus,
|
2009-03-19 16:55:04 +00:00
|
|
|
// and each project gets total CPU proportionate to its RRS.
|
2009-02-01 04:37:19 +00:00
|
|
|
//
|
|
|
|
// For coprocessors, we saturate the resource;
|
|
|
|
// i.e. with 2 GPUs, we'd let a 1-GPU app and a 2-GPU app run together.
|
|
|
|
// Otherwise, there'd be the possibility of computing
|
|
|
|
// a nonzero shortfall inappropriately.
|
|
|
|
//
|
|
|
|
// Outputs are changes to global state:
|
|
|
|
// - deadline misses (per-project count, per-result flag)
|
|
|
|
// Deadline misses are not counted for tasks
|
|
|
|
// that are too large to run in RAM right now.
|
|
|
|
// - resource shortfalls (per-project and total)
|
|
|
|
// - counts of resources idle now
|
|
|
|
//
|
2008-11-14 22:08:50 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include "boinc_win.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SIM
|
|
|
|
#include "sim.h"
|
|
|
|
#else
|
|
|
|
#include "client_state.h"
|
|
|
|
#endif
|
2008-12-31 23:07:59 +00:00
|
|
|
|
|
|
|
#include "coproc.h"
|
2008-11-14 22:08:50 +00:00
|
|
|
#include "client_msgs.h"
|
|
|
|
|
2008-12-31 23:07:59 +00:00
|
|
|
// this is here (rather than rr_sim.h) because its inline functions
|
|
|
|
// refer to RESULT
|
|
|
|
//
|
2008-11-14 22:08:50 +00:00
|
|
|
struct RR_SIM_STATUS {
|
|
|
|
std::vector<RESULT*> active;
|
2009-02-02 18:47:34 +00:00
|
|
|
double active_ncpus;
|
2008-12-31 23:07:59 +00:00
|
|
|
double active_cudas;
|
2008-11-14 22:08:50 +00:00
|
|
|
|
2008-12-03 23:30:54 +00:00
|
|
|
inline void activate(RESULT* rp, double when) {
|
2009-02-02 18:47:34 +00:00
|
|
|
if (log_flags.rr_simulation) {
|
|
|
|
msg_printf(rp->project, MSG_INFO,
|
|
|
|
"[rr_sim] %.2f: starting %s", when, rp->name
|
|
|
|
);
|
|
|
|
}
|
2008-11-14 22:08:50 +00:00
|
|
|
active.push_back(rp);
|
2009-02-02 18:47:34 +00:00
|
|
|
cpu_work_fetch.sim_nused += rp->avp->avg_ncpus;
|
2009-02-02 18:45:00 +00:00
|
|
|
cuda_work_fetch.sim_nused += rp->avp->ncudas;
|
2008-11-14 22:08:50 +00:00
|
|
|
}
|
|
|
|
// remove *rpbest from active set,
|
2009-02-01 04:37:19 +00:00
|
|
|
// and adjust FLOPS left for other results
|
2008-11-14 22:08:50 +00:00
|
|
|
//
|
|
|
|
inline void remove_active(RESULT* rpbest) {
|
|
|
|
vector<RESULT*>::iterator it = active.begin();
|
|
|
|
while (it != active.end()) {
|
|
|
|
RESULT* rp = *it;
|
|
|
|
if (rp == rpbest) {
|
|
|
|
it = active.erase(it);
|
|
|
|
} else {
|
2008-12-02 03:58:32 +00:00
|
|
|
rp->rrsim_flops_left -= rp->rrsim_flops*rpbest->rrsim_finish_delay;
|
2008-11-14 22:08:50 +00:00
|
|
|
|
|
|
|
// can be slightly less than 0 due to roundoff
|
|
|
|
//
|
2008-12-02 03:58:32 +00:00
|
|
|
if (rp->rrsim_flops_left < -1) {
|
2008-11-14 22:08:50 +00:00
|
|
|
msg_printf(rp->project, MSG_INTERNAL_ERROR,
|
2008-12-02 03:58:32 +00:00
|
|
|
"%s: negative FLOPs left %f", rp->name, rp->rrsim_flops_left
|
2008-11-14 22:08:50 +00:00
|
|
|
);
|
|
|
|
}
|
2008-12-02 03:58:32 +00:00
|
|
|
if (rp->rrsim_flops_left < 0) {
|
|
|
|
rp->rrsim_flops_left = 0;
|
2008-11-14 22:08:50 +00:00
|
|
|
}
|
|
|
|
it++;
|
|
|
|
}
|
|
|
|
}
|
2009-02-02 18:47:34 +00:00
|
|
|
cpu_work_fetch.sim_nused -= rpbest->avp->avg_ncpus;
|
2009-02-02 18:45:00 +00:00
|
|
|
cuda_work_fetch.sim_nused -= rpbest->avp->ncudas;
|
2008-11-14 22:08:50 +00:00
|
|
|
}
|
2008-12-09 20:01:01 +00:00
|
|
|
|
2009-02-02 18:47:34 +00:00
|
|
|
RR_SIM_STATUS() {
|
|
|
|
active_ncpus = 0;
|
2009-01-10 00:48:22 +00:00
|
|
|
active_cudas = 0;
|
2009-02-02 18:47:34 +00:00
|
|
|
}
|
2009-02-01 04:37:19 +00:00
|
|
|
~RR_SIM_STATUS() {}
|
2008-11-14 22:08:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void RR_SIM_PROJECT_STATUS::activate(RESULT* rp) {
|
|
|
|
active.push_back(rp);
|
2009-02-02 18:47:34 +00:00
|
|
|
rp->project->cpu_pwf.sim_nused += rp->avp->avg_ncpus;
|
2009-02-02 18:45:00 +00:00
|
|
|
rp->project->cuda_pwf.sim_nused += rp->avp->ncudas;
|
2008-11-14 22:08:50 +00:00
|
|
|
}
|
|
|
|
|
2009-02-02 18:45:00 +00:00
|
|
|
void RR_SIM_PROJECT_STATUS::remove_active(RESULT* rp) {
|
2008-11-14 22:08:50 +00:00
|
|
|
std::vector<RESULT*>::iterator it = active.begin();
|
|
|
|
while (it != active.end()) {
|
2009-02-02 18:45:00 +00:00
|
|
|
if (*it == rp) {
|
2008-11-14 22:08:50 +00:00
|
|
|
it = active.erase(it);
|
|
|
|
} else {
|
|
|
|
it++;
|
|
|
|
}
|
|
|
|
}
|
2009-02-02 18:47:34 +00:00
|
|
|
rp->project->cpu_pwf.sim_nused -= rp->avp->avg_ncpus;
|
2009-02-02 18:45:00 +00:00
|
|
|
rp->project->cuda_pwf.sim_nused -= rp->avp->ncudas;
|
2008-11-14 22:08:50 +00:00
|
|
|
}
|
|
|
|
|
2008-12-09 20:01:01 +00:00
|
|
|
// estimate the rate (FLOPS) that this job will get long-term
|
|
|
|
// with weighted round-robin scheduling
|
2008-11-14 22:08:50 +00:00
|
|
|
//
|
2008-12-31 23:07:59 +00:00
|
|
|
void set_rrsim_flops(RESULT* rp) {
|
2009-07-17 18:29:10 +00:00
|
|
|
// For coproc jobs, use app version estimate
|
|
|
|
//
|
2008-12-09 20:01:01 +00:00
|
|
|
if (rp->uses_coprocs()) {
|
2009-02-27 21:44:39 +00:00
|
|
|
rp->rrsim_flops = rp->avp->flops * gstate.overall_cpu_frac();
|
2009-02-02 18:47:34 +00:00
|
|
|
return;
|
2008-11-14 22:08:50 +00:00
|
|
|
}
|
2008-12-09 20:01:01 +00:00
|
|
|
PROJECT* p = rp->project;
|
2008-11-14 22:08:50 +00:00
|
|
|
|
2009-07-17 18:29:10 +00:00
|
|
|
// For CPU jobs, estimate how many CPU seconds per second this job would get
|
2009-02-02 18:47:34 +00:00
|
|
|
// running with other jobs of this project, ignoring other factors
|
|
|
|
//
|
|
|
|
double x = 1;
|
|
|
|
if (p->cpu_pwf.sim_nused > gstate.ncpus) {
|
|
|
|
x = gstate.ncpus/p->cpu_pwf.sim_nused;
|
|
|
|
}
|
|
|
|
double r1 = x*rp->avp->avg_ncpus;
|
|
|
|
|
|
|
|
// if the project's total CPU usage is more than its share, scale
|
|
|
|
//
|
|
|
|
double share_cpus = p->cpu_pwf.runnable_share*gstate.ncpus;
|
|
|
|
double r2 = r1;
|
|
|
|
if (p->cpu_pwf.sim_nused > share_cpus) {
|
|
|
|
r2 *= (share_cpus / p->cpu_pwf.sim_nused);
|
|
|
|
}
|
|
|
|
|
|
|
|
// scale by overall CPU availability
|
|
|
|
//
|
|
|
|
double r3 = r2 * gstate.overall_cpu_frac();
|
2008-12-09 20:01:01 +00:00
|
|
|
|
2009-03-18 17:24:56 +00:00
|
|
|
rp->rrsim_flops = r3 * rp->avp->flops;
|
2009-01-14 23:56:07 +00:00
|
|
|
#if 0
|
2008-11-14 22:08:50 +00:00
|
|
|
if (log_flags.rr_simulation) {
|
2008-12-09 20:01:01 +00:00
|
|
|
msg_printf(p, MSG_INFO,
|
|
|
|
"[rr_sim] set_rrsim_flops: %f (r1 %f r2 %f r3 %f)",
|
|
|
|
rp->rrsim_flops, r1, r2, r3
|
2008-11-14 22:08:50 +00:00
|
|
|
);
|
|
|
|
}
|
2009-01-14 23:56:07 +00:00
|
|
|
#endif
|
2008-11-14 22:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CLIENT_STATE::print_deadline_misses() {
|
|
|
|
unsigned int i;
|
|
|
|
RESULT* rp;
|
|
|
|
PROJECT* p;
|
|
|
|
for (i=0; i<results.size(); i++){
|
|
|
|
rp = results[i];
|
2009-01-03 06:01:17 +00:00
|
|
|
if (rp->rr_sim_misses_deadline) {
|
2008-11-14 22:08:50 +00:00
|
|
|
msg_printf(rp->project, MSG_INFO,
|
2009-01-03 06:01:17 +00:00
|
|
|
"[cpu_sched_debug] Result %s projected to miss deadline.",
|
|
|
|
rp->name
|
2008-11-14 22:08:50 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i=0; i<projects.size(); i++) {
|
|
|
|
p = projects[i];
|
2009-04-10 19:01:38 +00:00
|
|
|
if (p->cpu_pwf.deadlines_missed) {
|
2008-11-14 22:08:50 +00:00
|
|
|
msg_printf(p, MSG_INFO,
|
2009-04-10 19:01:38 +00:00
|
|
|
"[cpu_sched_debug] Project has %d projected CPU deadline misses",
|
|
|
|
p->cpu_pwf.deadlines_missed
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (p->cuda_pwf.deadlines_missed) {
|
|
|
|
msg_printf(p, MSG_INFO,
|
|
|
|
"[cpu_sched_debug] Project has %d projected NVIDIA GPU deadline misses",
|
|
|
|
p->cuda_pwf.deadlines_missed
|
2008-11-14 22:08:50 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CLIENT_STATE::rr_simulation() {
|
|
|
|
PROJECT* p, *pbest;
|
|
|
|
RESULT* rp, *rpbest;
|
|
|
|
RR_SIM_STATUS sim_status;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
double ar = available_ram();
|
|
|
|
|
2008-12-31 23:07:59 +00:00
|
|
|
work_fetch.rr_init();
|
|
|
|
|
2008-11-14 22:08:50 +00:00
|
|
|
if (log_flags.rr_simulation) {
|
|
|
|
msg_printf(0, MSG_INFO,
|
2009-02-02 18:45:00 +00:00
|
|
|
"[rr_sim] rr_sim start: work_buf_total %.2f",
|
|
|
|
work_buf_total()
|
2008-11-14 22:08:50 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<projects.size(); i++) {
|
|
|
|
p = projects[i];
|
|
|
|
if (p->non_cpu_intensive) continue;
|
|
|
|
p->rr_sim_status.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Decide what jobs to include in the simulation,
|
|
|
|
// and pick the ones that are initially running
|
|
|
|
//
|
|
|
|
for (i=0; i<results.size(); i++) {
|
|
|
|
rp = results[i];
|
2009-03-19 16:55:04 +00:00
|
|
|
rp->rr_sim_misses_deadline = false;
|
2008-11-14 22:08:50 +00:00
|
|
|
if (!rp->nearly_runnable()) continue;
|
|
|
|
if (rp->some_download_stalled()) continue;
|
|
|
|
if (rp->project->non_cpu_intensive) continue;
|
2008-12-02 03:58:32 +00:00
|
|
|
rp->rrsim_flops_left = rp->estimated_flops_remaining();
|
2009-03-19 16:55:04 +00:00
|
|
|
|
2009-02-17 17:39:57 +00:00
|
|
|
//if (rp->rrsim_flops_left <= 0) continue;
|
|
|
|
// job may have fraction_done=1 but not be done;
|
|
|
|
// if it's past its deadline, we need to mark it as such
|
2009-03-19 16:55:04 +00:00
|
|
|
|
2008-11-14 22:08:50 +00:00
|
|
|
p = rp->project;
|
2009-02-23 21:34:13 +00:00
|
|
|
p->pwf.has_runnable_jobs = true;
|
2009-02-02 18:47:34 +00:00
|
|
|
if (rp->uses_cuda()) {
|
|
|
|
p->cuda_pwf.has_runnable_jobs = true;
|
2009-02-02 18:45:00 +00:00
|
|
|
if (cuda_work_fetch.sim_nused < coproc_cuda->count) {
|
|
|
|
sim_status.activate(rp, 0);
|
2009-02-01 04:37:19 +00:00
|
|
|
p->rr_sim_status.activate(rp);
|
|
|
|
} else {
|
|
|
|
cuda_work_fetch.pending.push_back(rp);
|
|
|
|
}
|
2008-11-14 22:08:50 +00:00
|
|
|
} else {
|
2009-02-02 18:47:34 +00:00
|
|
|
p->cpu_pwf.has_runnable_jobs = true;
|
2009-02-02 18:45:00 +00:00
|
|
|
if (p->cpu_pwf.sim_nused < ncpus) {
|
|
|
|
sim_status.activate(rp, 0);
|
2009-02-01 04:37:19 +00:00
|
|
|
p->rr_sim_status.activate(rp);
|
|
|
|
} else {
|
|
|
|
p->rr_sim_status.add_pending(rp);
|
|
|
|
}
|
2008-11-14 22:08:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-31 23:07:59 +00:00
|
|
|
// note the number of idle instances
|
|
|
|
//
|
2009-02-02 18:45:00 +00:00
|
|
|
cpu_work_fetch.nidle_now = ncpus - cpu_work_fetch.sim_nused;
|
2009-01-08 00:20:04 +00:00
|
|
|
if (cpu_work_fetch.nidle_now < 0) cpu_work_fetch.nidle_now = 0;
|
2008-12-31 23:07:59 +00:00
|
|
|
if (coproc_cuda) {
|
2009-02-02 18:45:00 +00:00
|
|
|
cuda_work_fetch.nidle_now = coproc_cuda->count - cuda_work_fetch.sim_nused;
|
2009-01-08 00:20:04 +00:00
|
|
|
if (cuda_work_fetch.nidle_now < 0) cuda_work_fetch.nidle_now = 0;
|
2008-12-31 23:07:59 +00:00
|
|
|
}
|
|
|
|
|
2009-01-03 06:01:17 +00:00
|
|
|
work_fetch.compute_shares();
|
2008-11-14 22:08:50 +00:00
|
|
|
|
2008-12-31 23:07:59 +00:00
|
|
|
// Simulation loop. Keep going until all work done
|
2008-11-14 22:08:50 +00:00
|
|
|
//
|
2009-01-03 06:01:17 +00:00
|
|
|
double buf_end = now + work_buf_total();
|
2008-11-14 22:08:50 +00:00
|
|
|
double sim_now = now;
|
|
|
|
while (sim_status.active.size()) {
|
|
|
|
|
|
|
|
// compute finish times and see which result finishes first
|
|
|
|
//
|
|
|
|
rpbest = NULL;
|
|
|
|
for (i=0; i<sim_status.active.size(); i++) {
|
|
|
|
rp = sim_status.active[i];
|
2009-02-02 18:47:34 +00:00
|
|
|
set_rrsim_flops(rp);
|
2008-12-02 03:58:32 +00:00
|
|
|
rp->rrsim_finish_delay = rp->rrsim_flops_left/rp->rrsim_flops;
|
2008-11-14 22:08:50 +00:00
|
|
|
if (!rpbest || rp->rrsim_finish_delay < rpbest->rrsim_finish_delay) {
|
|
|
|
rpbest = rp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pbest = rpbest->project;
|
|
|
|
|
|
|
|
if (log_flags.rr_simulation) {
|
|
|
|
msg_printf(pbest, MSG_INFO,
|
2009-02-02 18:47:34 +00:00
|
|
|
"[rr_sim] %.2f: %s finishes after %.2f (%.2fG/%.2fG)",
|
2009-02-02 18:45:00 +00:00
|
|
|
sim_now - now,
|
2009-02-02 18:47:34 +00:00
|
|
|
rpbest->name, rpbest->rrsim_finish_delay,
|
2009-01-14 23:56:07 +00:00
|
|
|
rpbest->rrsim_flops_left/1e9, rpbest->rrsim_flops/1e9
|
2008-11-14 22:08:50 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// "rpbest" is first result to finish. Does it miss its deadline?
|
|
|
|
//
|
2009-03-04 22:07:16 +00:00
|
|
|
double diff = (sim_now + rpbest->rrsim_finish_delay) - rpbest->computation_deadline();
|
2008-11-14 22:08:50 +00:00
|
|
|
if (diff > 0) {
|
|
|
|
ACTIVE_TASK* atp = lookup_active_task_by_result(rpbest);
|
|
|
|
if (atp && atp->procinfo.working_set_size_smoothed > ar) {
|
|
|
|
if (log_flags.rr_simulation) {
|
|
|
|
msg_printf(pbest, MSG_INFO,
|
2009-01-20 18:06:49 +00:00
|
|
|
"[rr_sim] %s misses deadline but too large to run",
|
2008-11-14 22:08:50 +00:00
|
|
|
rpbest->name
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rpbest->rr_sim_misses_deadline = true;
|
2009-03-19 16:55:04 +00:00
|
|
|
if (rpbest->uses_cuda()) {
|
2009-04-10 19:01:38 +00:00
|
|
|
pbest->cuda_pwf.deadlines_missed++;
|
2009-03-19 16:55:04 +00:00
|
|
|
cuda_work_fetch.deadline_missed_instances += rpbest->avp->ncudas;
|
|
|
|
} else {
|
2009-04-10 19:01:38 +00:00
|
|
|
pbest->cpu_pwf.deadlines_missed++;
|
2009-03-19 16:55:04 +00:00
|
|
|
cpu_work_fetch.deadline_missed_instances += rpbest->avp->avg_ncpus;
|
|
|
|
}
|
2008-11-14 22:08:50 +00:00
|
|
|
if (log_flags.rr_simulation) {
|
|
|
|
msg_printf(pbest, MSG_INFO,
|
2009-01-20 18:06:49 +00:00
|
|
|
"[rr_sim] %s misses deadline by %.2f",
|
2008-11-14 22:08:50 +00:00
|
|
|
rpbest->name, diff
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-17 18:29:10 +00:00
|
|
|
// update saturated time
|
|
|
|
//
|
2009-01-30 21:25:24 +00:00
|
|
|
double end_time = sim_now + rpbest->rrsim_finish_delay;
|
|
|
|
double x = end_time - gstate.now;
|
2009-07-17 18:29:10 +00:00
|
|
|
cpu_work_fetch.update_saturated_time(x);
|
2009-01-30 21:25:24 +00:00
|
|
|
if (coproc_cuda) {
|
2009-07-17 18:29:10 +00:00
|
|
|
cuda_work_fetch.update_saturated_time(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
// update busy time
|
|
|
|
//
|
|
|
|
if (rpbest->rr_sim_misses_deadline) {
|
|
|
|
double dur = rpbest->estimated_time_remaining(false) / gstate.overall_cpu_frac();
|
|
|
|
cpu_work_fetch.update_busy_time(dur, rpbest->avp->avg_ncpus);
|
|
|
|
if (rpbest->uses_cuda()) {
|
|
|
|
cuda_work_fetch.update_busy_time(dur, rpbest->avp->ncudas);
|
|
|
|
}
|
2009-01-30 21:25:24 +00:00
|
|
|
}
|
|
|
|
|
2008-12-31 23:07:59 +00:00
|
|
|
// increment resource shortfalls
|
2008-12-03 23:30:54 +00:00
|
|
|
//
|
|
|
|
if (sim_now < buf_end) {
|
|
|
|
if (end_time > buf_end) end_time = buf_end;
|
|
|
|
double d_time = end_time - sim_now;
|
2008-12-31 23:07:59 +00:00
|
|
|
|
2009-02-02 18:45:00 +00:00
|
|
|
cpu_work_fetch.accumulate_shortfall(d_time);
|
2008-12-31 23:07:59 +00:00
|
|
|
|
|
|
|
if (coproc_cuda) {
|
2009-02-02 18:45:00 +00:00
|
|
|
cuda_work_fetch.accumulate_shortfall(d_time);
|
2008-12-03 23:30:54 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-14 22:08:50 +00:00
|
|
|
|
|
|
|
sim_status.remove_active(rpbest);
|
|
|
|
pbest->rr_sim_status.remove_active(rpbest);
|
|
|
|
|
2009-06-02 22:53:57 +00:00
|
|
|
sim_now += rpbest->rrsim_finish_delay;
|
|
|
|
|
2009-03-19 16:55:04 +00:00
|
|
|
// start new jobs; may need to start more than one
|
|
|
|
// if this job used multiple resource instances
|
|
|
|
//
|
2009-02-01 04:37:19 +00:00
|
|
|
if (rpbest->uses_cuda()) {
|
|
|
|
while (1) {
|
2009-02-02 18:45:00 +00:00
|
|
|
if (cuda_work_fetch.sim_nused >= coproc_cuda->count) break;
|
2009-02-01 04:37:19 +00:00
|
|
|
if (!cuda_work_fetch.pending.size()) break;
|
|
|
|
RESULT* rp = cuda_work_fetch.pending[0];
|
|
|
|
cuda_work_fetch.pending.erase(cuda_work_fetch.pending.begin());
|
2009-02-02 18:45:00 +00:00
|
|
|
sim_status.activate(rp, sim_now-now);
|
2009-02-01 04:37:19 +00:00
|
|
|
pbest->rr_sim_status.activate(rp);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
while (1) {
|
2009-02-02 18:45:00 +00:00
|
|
|
if (pbest->cpu_pwf.sim_nused >= ncpus) break;
|
2009-02-01 04:37:19 +00:00
|
|
|
RESULT* rp = pbest->rr_sim_status.get_pending();
|
|
|
|
if (!rp) break;
|
2009-02-02 18:45:00 +00:00
|
|
|
sim_status.activate(rp, sim_now-now);
|
2008-11-14 22:08:50 +00:00
|
|
|
pbest->rr_sim_status.activate(rp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-02 18:47:34 +00:00
|
|
|
// if simulation ends before end of buffer, take the tail into account
|
|
|
|
//
|
2008-12-03 23:30:54 +00:00
|
|
|
if (sim_now < buf_end) {
|
2009-02-02 18:47:34 +00:00
|
|
|
double d_time = buf_end - sim_now;
|
2009-02-02 18:45:00 +00:00
|
|
|
cpu_work_fetch.accumulate_shortfall(d_time);
|
2008-12-31 23:07:59 +00:00
|
|
|
if (coproc_cuda) {
|
2009-02-02 18:45:00 +00:00
|
|
|
cuda_work_fetch.accumulate_shortfall(d_time);
|
2008-12-31 23:07:59 +00:00
|
|
|
}
|
2008-11-14 22:08:50 +00:00
|
|
|
}
|
|
|
|
}
|