Skip to content

Commit

Permalink
- client: change the way project priorities are computed,
Browse files Browse the repository at this point in the history
    so that they do what they're supposed to
    (i.e. enforce resource shares)
- client: change log flag <debt_debug> to <priority_debug>
- client simulator: update REC even with large delta-t.
- client simulator: handle "no new work" apps correctly


svn path=/trunk/boinc/; revision=24429
  • Loading branch information
davidpanderson committed Oct 19, 2011
1 parent a80d483 commit b95ac02
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 56 deletions.
29 changes: 18 additions & 11 deletions api/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ include $(top_srcdir)/Makefile.incl

if ENABLE_LIBRARIES

# stuff linked into both main app and graphics app
# library for both main and graphics apps
api_files= \
boinc_api.cpp \
graphics2_util.cpp \
reduce_main.cpp

# stuff linked into graphics app
# library for graphics apps
graphics2_files = \
gutil.cpp \
gutil_text.cpp \
Expand All @@ -27,6 +27,10 @@ if OS_DARWIN
graphics2_files += macglutfix.m
endif

# library for OpenCL apps
opencl_files = \
boinc_opencl.cpp

EXTRA_DIST = *.h

if BUILD_GRAPHICS_API
Expand All @@ -36,13 +40,18 @@ endif
lib_LTLIBRARIES = libboinc_api.la
libboinc_api_la_SOURCES = $(api_files)
libboinc_api_la_LDFLAGS = -L$(libdir) -rpath $(libdir) -version-number $(LIBBOINC_VERSION)

if BUILD_GRAPHICS_API
lib_LTLIBRARIES += libboinc_graphics2.la
libboinc_graphics2_la_SOURCES = $(graphics2_files)
libboinc_graphics2_la_CPPFLAGS = -I$(top_srcdir)/lib
libboinc_graphics2_la_LDFLAGS = -L$(libdir) -rpath $(libdir) -version-number $(LIBBOINC_VERSION)
endif #BUILD_GRAPHICS_API

lib_LTLIBRARIES += libboinc_opencl.la
libboinc_opencl_la_SOURCES = $(opencl_files)
libboinc_opencl_la_LDFLAGS = -L$(libdir) -rpath $(libdir) -version-number $(LIBBOINC_VERSION)

if INSTALL_HEADERS
## install only headers that are meant for exporting the API !!
pkginclude_HEADERS = \
Expand All @@ -57,9 +66,11 @@ endif ## INSTALL_HEADERS
if OS_OS2
LIBBOINC_API_STATIC=boinc_api.${LIBEXT}
LIBBOINC_GRAPHICS2_STATIC=boinc_graphics2.${LIBEXT}
LIBBOINC_OPENCL_STATIC=boinc_opencl.${LIBEXT}
else
LIBBOINC_API_STATIC=libboinc_api.${LIBEXT}
LIBBOINC_GRAPHICS2_STATIC=libboinc_graphics2.${LIBEXT}
LIBBOINC_OPENCL_STATIC=libboinc_opencl.${LIBEXT}
endif


Expand All @@ -68,9 +79,10 @@ all_local = $(LIBBOINC_API_STATIC)
if BUILD_GRAPHICS_API
all_local += $(LIBBOINC_GRAPHICS2_STATIC)
endif
all_local += $(LIBBOINC_OPENCL_STATIC)
endif

all-local: $(all_local) boinc_opencl.o
all-local: $(all_local)

$(LIBBOINC_API_STATIC): libboinc_api.la
rm -f $(LIBBOINC_API_STATIC)
Expand All @@ -80,15 +92,10 @@ $(LIBBOINC_GRAPHICS2_STATIC): libboinc_graphics2.la
rm -f $(LIBBOINC_GRAPHICS2_STATIC)
$(LN) .libs/$(LIBBOINC_GRAPHICS2_STATIC) .

$(LIBBOINC_OPENCL_STATIC): libboinc_opencl.la
rm -f $(LIBBOINC_OPENCL_STATIC)
$(LN) .libs/$(LIBBOINC_OPENCL_STATIC) .

endif ## ENABLE_LIBRARIES

.PHONY:

EXTRA_PROGRAMS = api_app api_test

api_app_SOURCES = api_app.cpp ../lib/parse.cpp
api_app_LDADD = $(LIBAPI)
api_test_SOURCES = api_test.cpp ../lib/parse.cpp
api_test_LDADD = $(LIBAPI)

19 changes: 19 additions & 0 deletions checkin_notes
Original file line number Diff line number Diff line change
Expand Up @@ -7447,3 +7447,22 @@ Rom 18 Oct 2011
clientgui/
sg_BoincSimpleFrame.cpp
sg_ProjectPanel.cpp, .h

David 18 Oct 2011
- client: change the way project priorities are computed,
so that they do what they're supposed to
(i.e. enforce resource shares)
- client: change log flag <debt_debug> to <priority_debug>
- client simulator: update REC even with large delta-t.
- client simulator: handle "no new work" apps correctly

api/
Makefile.am
client/
work_fetch.cpp,h
client_types.h
client_state.cpp
sim.cpp
rr_sim.cpp
sim_util.cpp
cpu_sched.cpp
2 changes: 0 additions & 2 deletions client/client_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,6 @@ int CLIENT_STATE::init() {
//
check_too_large_jobs();

project_priority_init();

initialized = true;
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions client/client_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ struct PROJECT : PROJ_AM {
double idle_time_sumsq;
bool idle;
int max_infeasible_count;
bool no_apps;
// for DCF variants:
int completed_task_count;
double completions_ratio_mean;
Expand Down
45 changes: 30 additions & 15 deletions client/cpu_sched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ using std::list;
using std::isnan;
#endif

static double rec_sum;

#define DEADLINE_CUSHION 0
// try to finish jobs this much in advance of their deadline

Expand Down Expand Up @@ -162,7 +164,8 @@ struct PROC_RESOURCES {
void schedule(RESULT* rp, ACTIVE_TASK* atp, const char* description) {
if (log_flags.cpu_sched_debug) {
msg_printf(rp->project, MSG_INFO,
"[cpu_sched_debug] scheduling %s (%s) (prio %f)", rp->name, description,
"[cpu_sched_debug] scheduling %s (%s) (prio %f)",
rp->name, description,
rp->project->sched_priority
);
}
Expand Down Expand Up @@ -569,7 +572,7 @@ static void update_rec() {
p->pwf.rec_time
);

if (log_flags.debt_debug) {
if (log_flags.priority_debug) {
double dt = gstate.now - gstate.debt_interval_start;
msg_printf(p, MSG_INFO,
"[debt] recent est credit: %.2fG in %.2f sec, %f + %f ->%f",
Expand Down Expand Up @@ -603,22 +606,22 @@ static double total_peak_flops() {
return tpf;
}

static double rec_sum;

// Initialize project "priorities" based on REC:
// compute resource share and REC fractions
// among compute-intensive, non-suspended projects
//
void project_priority_init(bool set_rec_temp) {
void project_priority_init(bool for_work_fetch) {
double rs_sum = 0;
rec_sum = 0;
for (unsigned int i=0; i<gstate.projects.size(); i++) {
PROJECT* p = gstate.projects[i];
if (p->non_cpu_intensive) continue;
if (p->suspended_via_gui) continue;
if (set_rec_temp) {
p->pwf.rec_temp = p->pwf.rec;
if (for_work_fetch) {
if (!p->can_request_work()) continue;
} else {
if (!p->runnable(RSC_TYPE_ANY)) continue;
}
p->pwf.rec_temp = p->pwf.rec;
rs_sum += p->resource_share;
rec_sum += p->pwf.rec_temp;
}
Expand All @@ -633,19 +636,27 @@ void project_priority_init(bool set_rec_temp) {
} else {
p->resource_share_frac = p->resource_share/rs_sum;
p->compute_sched_priority();
if (log_flags.priority_debug) {
msg_printf(p, MSG_INFO, "[prio] %f rsf %f rt %f rs %f",
p->sched_priority, p->resource_share_frac,
p->pwf.rec_temp, rec_sum
);
}
}
}
}

void PROJECT::compute_sched_priority() {
sched_priority = resource_share_frac - pwf.rec_temp/rec_sum;
double rec_frac = pwf.rec_temp/rec_sum;

// projects with zero resource share are always lower priority
// than those with positive resource share
//
if (resource_share == 0) {
sched_priority -= 2;
sched_priority = -1e6 - rec_frac;
}
sched_priority = - rec_frac/resource_share_frac;

}

// called from the scheduler's job-selection loop;
Expand All @@ -659,6 +670,10 @@ void adjust_rec_sched(RESULT* rp) {
p->compute_sched_priority();
}

// make this a variable so simulator can change it
//
double debt_adjust_period = DEBT_ADJUST_PERIOD;

// adjust project REC
//
void CLIENT_STATE::adjust_rec() {
Expand All @@ -669,11 +684,11 @@ void CLIENT_STATE::adjust_rec() {
// it must be because the host was suspended for a long time.
// In this case, ignore the last period
//
if (elapsed_time > 2*DEBT_ADJUST_PERIOD || elapsed_time < 0) {
if (log_flags.debt_debug) {
if (elapsed_time > 2*debt_adjust_period || elapsed_time < 0) {
if (log_flags.priority_debug) {
msg_printf(NULL, MSG_INFO,
"[debt] adjust_debt: elapsed time (%d) longer than sched enforce period(%d). Ignoring this period.",
(int)elapsed_time, (int)DEBT_ADJUST_PERIOD
"[priority] adjust_rec: elapsed time (%d) longer than sched enforce period(%d). Ignoring this period.",
(int)elapsed_time, (int)debt_adjust_period
);
}
reset_debt_accounting();
Expand Down Expand Up @@ -842,7 +857,7 @@ void CLIENT_STATE::make_run_list(vector<RESULT*>& run_list) {

// set temporary variables
//
project_priority_init();
project_priority_init(false);
for (i=0; i<results.size(); i++) {
rp = results[i];
rp->already_selected = false;
Expand Down
2 changes: 1 addition & 1 deletion client/log_flags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void LOG_FLAGS::show() {
show_flag(buf, cpu_sched_debug, "cpu_sched_debug");
show_flag(buf, cpu_sched_status, "cpu_sched_status");
show_flag(buf, dcf_debug, "dcf_debug");
show_flag(buf, debt_debug, "debt_debug");
show_flag(buf, priority_debug, "priority_debug");
show_flag(buf, file_xfer_debug, "file_xfer_debug");
show_flag(buf, gui_rpc_debug, "gui_rpc_debug");
show_flag(buf, heartbeat_debug, "heartbeat_debug");
Expand Down
7 changes: 2 additions & 5 deletions client/rr_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void RR_SIM::simulate() {
double buf_end = gstate.now + gstate.work_buf_total();
double sim_now = gstate.now;
bool first = true;
project_priority_init(true);
project_priority_init(false);
while (1) {
sort_pending_lists(); // sort jobs by project priority
pick_jobs_to_run(sim_now-gstate.now);
Expand Down Expand Up @@ -397,12 +397,9 @@ void RR_SIM::simulate() {
p->pwf.rec_temp,
dtemp
);
p->compute_sched_priority();
}

// recalculate project priorities
//
project_priority_init(false);

sim_now += delta_t;
}

Expand Down
19 changes: 14 additions & 5 deletions client/sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ bool active;
bool gpu_active;
bool connected;

extern double debt_adjust_period;

SIM_RESULTS sim_results;
int njobs;

Expand Down Expand Up @@ -1274,7 +1276,7 @@ void cull_projects() {

for (i=0; i<gstate.projects.size(); i++) {
p = gstate.projects[i];
p->dont_request_more_work = true;
p->no_apps = true;
for (int j=0; j<coprocs.n_rsc; j++) {
p->no_rsc_apps[j] = true;
}
Expand All @@ -1288,19 +1290,25 @@ void cull_projects() {
for (i=0; i<gstate.apps.size(); i++) {
APP* app = gstate.apps[i];
if (!app->ignore) {
app->project->dont_request_more_work = false;
app->project->no_apps = false;
}
}
vector<PROJECT*>::iterator iter;
iter = gstate.projects.begin();
while (iter != gstate.projects.end()) {
p = *iter;
if (p->dont_request_more_work) {
if (p->no_apps) {
fprintf(summary_file,
"%s: Removing from simulation - no apps\n",
p->project_name
);
iter = gstate.projects.erase(iter);
} else if (p->non_cpu_intensive) {
fprintf(summary_file,
"%s: Removing from simulation - non CPU intensive\n",
p->project_name
);
iter = gstate.projects.erase(iter);
} else {
iter++;
}
Expand Down Expand Up @@ -1378,8 +1386,9 @@ void do_client_simulation() {
gstate.set_ncpus();
work_fetch.init();

set_initial_rec();
project_priority_init();
//set_initial_rec();

debt_adjust_period = delta;

gstate.request_work_fetch("init");
simulate();
Expand Down
5 changes: 3 additions & 2 deletions client/sim_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ int ACTIVE_TASK::resume_or_start(bool first_time) {
}
set_task_state(PROCESS_EXECUTING, "start");
char buf[256];
sprintf(buf, "Starting %s; deadline %s<br>",
result->name, sim_time_string(result->report_deadline)
sprintf(buf, "Starting %s<br>&nbsp;&nbsp;%s<br>&nbsp;&nbsp;deadline %s<br>",
result->name, result->project->get_project_name(),
sim_time_string(result->report_deadline)
);
html_msg += buf;
return 0;
Expand Down
18 changes: 9 additions & 9 deletions client/work_fetch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,16 +383,16 @@ void RSC_WORK_FETCH::set_request(PROJECT* p) {
}
}

// the number of additional instances needed to have our share
//
double x1;
x1 = ninstances - w.nused_total;

// our share of the idle instances
//
double x2 = nidle_now * w.fetchable_share;
req_instances = nidle_now * w.fetchable_share;

req_instances = std::max(x1, x2);
if (log_flags.work_fetch_debug) {
msg_printf(0, MSG_INFO,
"[wfd] ninst %d nused_total %f nidle_now %f fetch share %f req_inst %f",
ninstances, w.nused_total, nidle_now, w.fetchable_share, req_instances
);
}
if (req_instances && !req_secs) {
req_secs = 1;
}
Expand Down Expand Up @@ -608,7 +608,7 @@ PROJECT* WORK_FETCH::choose_project() {

rr_simulation();
compute_shares();
project_priority_init();
project_priority_init(true);

// adjust project priorities according to how much work they currently have queued
//
Expand All @@ -617,7 +617,7 @@ PROJECT* WORK_FETCH::choose_project() {
RESULT* rp = gstate.results[i];
total_flops_remaining += rp->estimated_flops_remaining();
}
#define CURRENT_QUEUE_WEIGHT .3
#define CURRENT_QUEUE_WEIGHT 1.
if (total_flops_remaining) {
for (unsigned int i=0; i<gstate.projects.size(); i++) {
p = gstate.projects[i];
Expand Down
Loading

0 comments on commit b95ac02

Please sign in to comment.