// This file is part of BOINC. // http://boinc.berkeley.edu // Copyright (C) 2011 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 . // A trickle handler that grants credit based on run time // // message format: // // x // // The credit granted is based on the host's CPU benchmarks, // and assumes a single-threaded CPU app. // // Required cmdline arg: // // --max_runtime X Cap runtime at X // // This should match the frequency with which your app // sends trickle-up messages #include "error_numbers.h" #include "util.h" #include "credit.h" #include "miofile.h" #include "parse.h" #include "sched_msgs.h" #include "trickle_handler.h" double flops_50_percentile; // default if host value is <= 0 double flops_95_percentile; // limit for cheat-proofing double max_runtime = 0; int handle_trickle_init(int argc, char** argv) { int retval; for (int i=1; i max_runtime) { log_messages.printf(MSG_NORMAL, "Reported runtime exceeds bound: %f>%f\n", runtime, max_runtime ); runtime = max_runtime; } if (flops_sec < 0) { log_messages.printf(MSG_NORMAL, "host CPU speed %f < 0. Using %f instead\n", flops_sec, flops_50_percentile ); flops_sec = flops_50_percentile; } if (flops_sec > flops_95_percentile) { log_messages.printf(MSG_NORMAL, "host CPU speed %f exceeds %f. Using %f instead\n", flops_sec, flops_95_percentile, flops_95_percentile ); flops_sec = flops_95_percentile; } double credit = cpu_time_to_credit(runtime, flops_sec); grant_credit(host, dtime()-86400, credit); log_messages.printf(MSG_DEBUG, "granting %f credit to host %lu\n", credit, host.id ); // update the host's credit fields // retval = host.update_diff_validator(old_host); return 0; }