2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-01-20 23:22:22 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2003-07-03 00:48:43 +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.
|
2003-07-03 00:48:43 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-01-20 23:22:22 +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.
|
2002-04-30 22:22:54 +00:00
|
|
|
//
|
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/>.
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
// If you change anything, make sure you also change:
|
2004-07-14 20:55:26 +00:00
|
|
|
// client_types.C (to write and parse it)
|
2002-04-30 22:22:54 +00:00
|
|
|
// client_state.C (to cross-link objects)
|
|
|
|
//
|
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
#ifndef _CLIENT_TYPES_
|
|
|
|
#define _CLIENT_TYPES_
|
2002-08-22 20:23:24 +00:00
|
|
|
|
2003-10-16 19:03:49 +00:00
|
|
|
#include "cpp.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2005-12-16 03:45:01 +00:00
|
|
|
#if !defined(_WIN32) || defined(__CYGWIN32__)
|
2009-02-26 00:23:23 +00:00
|
|
|
#include <cstdio>
|
2003-07-03 05:01:29 +00:00
|
|
|
#include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
|
2004-04-18 18:40:13 +00:00
|
|
|
#include "md5_file.h"
|
2008-09-04 12:50:54 +00:00
|
|
|
#include "cert_sig.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "hostinfo.h"
|
2008-03-27 18:25:29 +00:00
|
|
|
#include "coproc.h"
|
2004-06-12 04:45:36 +00:00
|
|
|
#include "miofile.h"
|
2009-02-26 17:12:55 +00:00
|
|
|
#include "common_defs.h"
|
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
#include "rr_sim.h"
|
2009-02-26 17:12:55 +00:00
|
|
|
#include "work_fetch.h"
|
2009-12-21 17:49:28 +00:00
|
|
|
#include "cs_notice.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2005-10-03 18:05:58 +00:00
|
|
|
#define MAX_FILE_INFO_LEN 4096
|
|
|
|
#define MAX_SIGNATURE_LEN 4096
|
|
|
|
#define MAX_KEY_LEN 4096
|
|
|
|
|
2009-09-22 21:02:06 +00:00
|
|
|
#define MAX_COPROCS_PER_JOB 8
|
|
|
|
|
2003-11-02 22:51:49 +00:00
|
|
|
// If the status is neither of these two,
|
|
|
|
// it will be an error code defined in error_numbers.h,
|
2004-03-25 22:24:33 +00:00
|
|
|
// indicating an unrecoverable error in the upload or download of the file,
|
|
|
|
// or that the file was too big and was deleted
|
2003-11-02 22:51:49 +00:00
|
|
|
//
|
|
|
|
#define FILE_NOT_PRESENT 0
|
|
|
|
#define FILE_PRESENT 1
|
|
|
|
|
2009-12-21 19:20:28 +00:00
|
|
|
struct FILE_INFO {
|
2003-11-02 22:51:49 +00:00
|
|
|
char name[256];
|
|
|
|
char md5_cksum[33];
|
|
|
|
double max_nbytes;
|
|
|
|
double nbytes;
|
|
|
|
double upload_offset;
|
|
|
|
bool generated_locally; // file is produced by app
|
|
|
|
int status;
|
|
|
|
bool executable; // change file protections to make executable
|
|
|
|
bool uploaded; // file has been uploaded
|
|
|
|
bool upload_when_present;
|
|
|
|
bool sticky; // don't delete unless instructed to do so
|
2004-09-10 00:41:48 +00:00
|
|
|
bool report_on_rpc; // include this in each scheduler request
|
2008-10-04 23:44:24 +00:00
|
|
|
/// if not in use, delete even if sticky is true
|
|
|
|
/// don't report to server even if report_on_rpc is true
|
2005-01-31 23:42:19 +00:00
|
|
|
bool marked_for_delete; // server requested delete;
|
2003-11-02 22:51:49 +00:00
|
|
|
bool signature_required; // true iff associated with app version
|
|
|
|
bool is_user_file;
|
2006-06-26 22:58:24 +00:00
|
|
|
bool is_project_file;
|
2006-12-12 23:32:25 +00:00
|
|
|
bool is_auto_update_file;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// for output files: gzip file when done, and append .gz to its name
|
2006-06-20 22:03:15 +00:00
|
|
|
bool gzip_when_done;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// nonzero if in the process of being up/downloaded
|
2006-11-26 02:06:30 +00:00
|
|
|
class PERS_FILE_XFER* pers_file_xfer;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// for upload files (to authenticate)
|
2009-12-21 19:20:28 +00:00
|
|
|
RESULT* result;
|
|
|
|
PROJECT* project;
|
2003-11-02 22:51:49 +00:00
|
|
|
int ref_cnt;
|
2005-03-09 23:28:37 +00:00
|
|
|
std::vector<std::string> urls;
|
2003-11-02 22:51:49 +00:00
|
|
|
int start_url;
|
|
|
|
int current_url;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// if the file_info is signed (for uploadable files)
|
|
|
|
/// this is the text that is signed
|
|
|
|
/// Otherwise it is the FILE_INFO's XML descriptor
|
|
|
|
/// (without enclosing <file_info> tags)
|
2005-10-03 18:05:58 +00:00
|
|
|
char signed_xml[MAX_FILE_INFO_LEN];
|
2008-10-04 23:44:24 +00:00
|
|
|
/// ... and this is the signature
|
2005-10-03 18:05:58 +00:00
|
|
|
char xml_signature[MAX_SIGNATURE_LEN];
|
2008-10-04 23:44:24 +00:00
|
|
|
/// if the file itself is signed (for executable files)
|
|
|
|
/// this is the signature
|
2005-10-03 18:05:58 +00:00
|
|
|
char file_signature[MAX_SIGNATURE_LEN];
|
2008-10-04 23:44:24 +00:00
|
|
|
/// if permanent error occurs during file xfer, it's recorded here
|
|
|
|
std::string error_msg;
|
2008-09-04 12:50:54 +00:00
|
|
|
CERT_SIGS* cert_sigs;
|
2003-11-02 22:51:49 +00:00
|
|
|
|
|
|
|
FILE_INFO();
|
|
|
|
~FILE_INFO();
|
2004-09-02 16:23:21 +00:00
|
|
|
void reset();
|
2003-11-02 22:51:49 +00:00
|
|
|
int set_permissions();
|
2004-06-12 04:45:36 +00:00
|
|
|
int parse(MIOFILE&, bool from_server);
|
|
|
|
int write(MIOFILE&, bool to_server);
|
2004-07-13 23:51:09 +00:00
|
|
|
int write_gui(MIOFILE&);
|
2008-10-04 23:44:24 +00:00
|
|
|
/// attempt to delete the underlying file
|
|
|
|
int delete_file();
|
2009-06-16 21:58:38 +00:00
|
|
|
const char* get_init_url();
|
|
|
|
const char* get_next_url();
|
|
|
|
const char* get_current_url();
|
2006-03-30 22:21:18 +00:00
|
|
|
bool had_failure(int& failnum);
|
|
|
|
void failure_message(std::string&);
|
2004-07-06 18:31:56 +00:00
|
|
|
int merge_info(FILE_INFO&);
|
2007-01-19 20:56:49 +00:00
|
|
|
int verify_file(bool, bool);
|
2008-09-04 12:17:58 +00:00
|
|
|
bool verify_file_certs();
|
2008-10-04 23:44:24 +00:00
|
|
|
/// gzip file and add .gz to name
|
|
|
|
int gzip();
|
2003-11-02 22:51:49 +00:00
|
|
|
};
|
|
|
|
|
2008-10-04 23:44:24 +00:00
|
|
|
/// Describes a connection between a file and a workunit, result, or application
|
|
|
|
|
|
|
|
/// In the first two cases,
|
|
|
|
/// the app will either use open() or fopen() to access the file
|
|
|
|
/// (in which case "open_name" is the name it will use)
|
|
|
|
/// or the app will be connected by the given fd (in which case fd is nonzero)
|
|
|
|
|
2003-11-02 22:51:49 +00:00
|
|
|
struct FILE_REF {
|
2008-10-04 23:44:24 +00:00
|
|
|
/// physical name
|
|
|
|
char file_name[256];
|
|
|
|
/// logical name
|
|
|
|
char open_name[256];
|
2003-11-02 22:51:49 +00:00
|
|
|
bool main_program;
|
|
|
|
FILE_INFO* file_info;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// if true, core client will copy the file instead of linking
|
2007-04-13 22:55:18 +00:00
|
|
|
bool copy_file;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// for output files: app may not generate file;
|
|
|
|
/// don't treat as error if file is missing.
|
2006-10-20 20:21:33 +00:00
|
|
|
bool optional;
|
2004-06-12 04:45:36 +00:00
|
|
|
int parse(MIOFILE&);
|
|
|
|
int write(MIOFILE&);
|
2003-11-02 22:51:49 +00:00
|
|
|
};
|
|
|
|
|
2009-07-16 16:35:57 +00:00
|
|
|
// file xfer backoff state for a project and direction (up/down)
|
|
|
|
// if file_xfer_failures exceeds FILE_XFER_FAILURE_LIMIT,
|
|
|
|
// we switch from a per-file to a project-wide backoff policy
|
|
|
|
// (separately for the up/down directions)
|
|
|
|
// NOTE: this refers to transient failures, not permanent.
|
|
|
|
//
|
|
|
|
#define FILE_XFER_FAILURE_LIMIT 3
|
|
|
|
struct FILE_XFER_BACKOFF {
|
|
|
|
int file_xfer_failures;
|
|
|
|
// count of consecutive failures
|
|
|
|
double next_xfer_time;
|
|
|
|
// when to start trying again
|
|
|
|
bool ok_to_transfer();
|
|
|
|
void file_xfer_failed(PROJECT*);
|
|
|
|
void file_xfer_succeeded();
|
|
|
|
|
|
|
|
FILE_XFER_BACKOFF() {
|
|
|
|
file_xfer_failures = 0;
|
|
|
|
next_xfer_time = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-10-04 23:44:24 +00:00
|
|
|
/// statistics at a specific day
|
|
|
|
|
2005-08-11 04:45:16 +00:00
|
|
|
struct DAILY_STATS {
|
2005-04-04 06:02:36 +00:00
|
|
|
double user_total_credit;
|
|
|
|
double user_expavg_credit;
|
|
|
|
double host_total_credit;
|
|
|
|
double host_expavg_credit;
|
|
|
|
double day;
|
2005-08-11 04:45:16 +00:00
|
|
|
|
|
|
|
void clear();
|
|
|
|
DAILY_STATS() {clear();}
|
|
|
|
int parse(FILE*);
|
2005-04-04 06:02:36 +00:00
|
|
|
};
|
2007-01-11 00:20:58 +00:00
|
|
|
bool operator < (const DAILY_STATS&, const DAILY_STATS&);
|
2009-07-16 16:35:57 +00:00
|
|
|
|
2009-12-21 19:20:28 +00:00
|
|
|
struct PROJECT {
|
2003-02-28 23:14:18 +00:00
|
|
|
// the following items come from the account file
|
2002-06-21 06:52:47 +00:00
|
|
|
// They are a function only of the user and the project
|
|
|
|
//
|
2008-10-04 23:44:24 +00:00
|
|
|
/// url of site that contains scheduler tags for this project
|
|
|
|
char master_url[256];
|
|
|
|
/// user's authenticator on this project
|
|
|
|
char authenticator[256];
|
|
|
|
/// without the enclosing <project_preferences> tags.
|
|
|
|
/// May include <venue> elements
|
|
|
|
/// This field is used only briefly: between handling a
|
|
|
|
/// scheduler RPC reply and writing the account file
|
2004-06-30 18:17:21 +00:00
|
|
|
std::string project_prefs;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// without enclosing <project_specific> tags
|
|
|
|
/// Does not include <venue> elements
|
2004-06-30 18:17:21 +00:00
|
|
|
std::string project_specific_prefs;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// GUI URLs, with enclosing <gui_urls> tags
|
2004-09-27 19:44:40 +00:00
|
|
|
std::string gui_urls;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// project's resource share relative to other projects.
|
2003-11-28 19:19:11 +00:00
|
|
|
double resource_share;
|
2009-10-23 21:57:58 +00:00
|
|
|
// the following are the user's project prefs
|
|
|
|
bool no_cpu_pref;
|
|
|
|
bool no_cuda_pref;
|
|
|
|
bool no_ati_pref;
|
|
|
|
// the following are from the project itself
|
|
|
|
bool no_cpu_apps;
|
|
|
|
bool no_cuda_apps;
|
|
|
|
bool no_ati_apps;
|
|
|
|
|
2008-10-04 23:44:24 +00:00
|
|
|
/// logically, this belongs in the client state file
|
|
|
|
/// rather than the account file.
|
|
|
|
/// But we need it in the latter in order to parse prefs.
|
2004-10-01 08:15:58 +00:00
|
|
|
char host_venue[256];
|
2005-04-22 03:46:01 +00:00
|
|
|
bool using_venue_specific_prefs;
|
2002-06-21 06:52:47 +00:00
|
|
|
|
|
|
|
// the following items come from client_state.xml
|
|
|
|
// They may depend on the host as well as user and project
|
2003-05-13 18:55:07 +00:00
|
|
|
// NOTE: if you add anything, add it to copy_state_fields() also!!!
|
2002-06-21 06:52:47 +00:00
|
|
|
//
|
2008-10-04 23:44:24 +00:00
|
|
|
/// where to find scheduling servers
|
2005-03-09 23:28:37 +00:00
|
|
|
std::vector<std::string> scheduler_urls;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// descriptive. not unique
|
|
|
|
char project_name[256];
|
|
|
|
/// URL of symbol server (Windows)
|
|
|
|
char symstore[256];
|
2002-06-21 06:52:47 +00:00
|
|
|
char user_name[256];
|
2003-02-24 21:25:16 +00:00
|
|
|
char team_name[256];
|
2004-04-18 18:40:13 +00:00
|
|
|
char email_hash[MD5_LEN];
|
|
|
|
char cross_project_id[MD5_LEN];
|
2007-09-03 23:00:22 +00:00
|
|
|
double cpid_time;
|
2006-05-23 06:46:19 +00:00
|
|
|
double user_total_credit;
|
|
|
|
double user_expavg_credit;
|
|
|
|
double user_create_time;
|
2002-04-30 22:22:54 +00:00
|
|
|
int hostid;
|
2006-05-23 06:46:19 +00:00
|
|
|
double host_total_credit;
|
|
|
|
double host_expavg_credit;
|
|
|
|
double host_create_time;
|
2006-10-23 16:00:51 +00:00
|
|
|
double ams_resource_share;
|
2010-01-28 05:21:14 +00:00
|
|
|
// resource share according to AMS; overrides project
|
|
|
|
// -1 means not specified by AMS
|
2006-05-23 06:46:19 +00:00
|
|
|
|
|
|
|
// stuff related to scheduler RPCs and master fetch
|
|
|
|
//
|
|
|
|
int rpc_seqno;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// # of consecutive times we've failed to contact all scheduling servers
|
|
|
|
int nrpc_failures;
|
2003-02-28 23:14:18 +00:00
|
|
|
int master_fetch_failures;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// earliest time to contact any server of this project (or zero)
|
|
|
|
double min_rpc_time;
|
2006-12-21 16:56:33 +00:00
|
|
|
void set_min_rpc_time(double future_time, const char* reason);
|
2008-10-14 21:40:14 +00:00
|
|
|
/// if nonzero, specifies a time when another scheduler RPC
|
|
|
|
/// should be done (as requested by server).
|
|
|
|
/// An RPC could be done sooner than this.
|
|
|
|
double next_rpc_time;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// returns true if min_rpc_time > now
|
2006-05-23 06:46:19 +00:00
|
|
|
bool waiting_until_min_rpc_time();
|
2008-10-04 23:44:24 +00:00
|
|
|
/// need to fetch and parse the master URL
|
2002-07-15 05:34:32 +00:00
|
|
|
bool master_url_fetch_pending;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// we need to do a scheduler RPC, for various possible reasons:
|
|
|
|
/// user request, propagate host CPID, time-based, etc.
|
|
|
|
/// Reasons are enumerated in scheduler_op.h
|
2006-08-24 20:33:46 +00:00
|
|
|
int sched_rpc_pending;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// we need to call request_work_fetch() when a project
|
|
|
|
/// transitions from being backed off to not.
|
|
|
|
/// This (slightly misnamed) keeps track of whether this
|
|
|
|
/// may still need to be done for given project
|
2006-11-08 00:20:16 +00:00
|
|
|
bool possibly_backed_off;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// have trickle up to send
|
|
|
|
bool trickle_up_pending;
|
|
|
|
/// when last RPC finished
|
|
|
|
double last_rpc_time;
|
2006-10-12 19:43:55 +00:00
|
|
|
|
|
|
|
// Other stuff
|
|
|
|
|
2008-10-04 23:44:24 +00:00
|
|
|
/// app_versions.xml file found in project dir;
|
|
|
|
/// use those apps rather then getting from server
|
|
|
|
bool anonymous_platform;
|
2004-09-23 22:27:41 +00:00
|
|
|
bool non_cpu_intensive;
|
2006-06-20 17:36:28 +00:00
|
|
|
bool verify_files_on_app_start;
|
2008-04-14 04:04:45 +00:00
|
|
|
bool use_symlinks;
|
2007-04-13 22:55:18 +00:00
|
|
|
|
|
|
|
// items send in scheduler replies, requesting that
|
|
|
|
// various things be sent in the next request
|
|
|
|
//
|
2008-10-04 23:44:24 +00:00
|
|
|
/// send the list of permanent files associated with the project
|
|
|
|
/// in the next scheduler reply
|
2004-09-23 22:27:41 +00:00
|
|
|
bool send_file_list;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// if nonzero, send time stats log from that point on
|
2007-04-13 22:55:18 +00:00
|
|
|
int send_time_stats_log;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// if nonzero, send this project's job log from that point on
|
2007-04-13 22:55:18 +00:00
|
|
|
int send_job_log;
|
|
|
|
|
2004-09-26 04:16:52 +00:00
|
|
|
bool suspended_via_gui;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// Return work, but don't request more
|
|
|
|
/// Used for a clean exit to a project,
|
|
|
|
/// or if a user wants to pause doing work for the project
|
2005-06-11 08:09:16 +00:00
|
|
|
bool dont_request_more_work;
|
2005-12-09 22:29:21 +00:00
|
|
|
bool attached_via_acct_mgr;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// when no results for this project, detach it.
|
2007-02-23 20:24:52 +00:00
|
|
|
bool detach_when_done;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// project has ended; advise user to detach
|
2007-05-24 16:07:21 +00:00
|
|
|
bool ended;
|
2005-10-03 18:05:58 +00:00
|
|
|
char code_sign_key[MAX_KEY_LEN];
|
2004-06-30 18:17:21 +00:00
|
|
|
std::vector<FILE_REF> user_files;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// files not specific to apps or work - e.g. icons
|
2006-06-26 22:58:24 +00:00
|
|
|
std::vector<FILE_REF> project_files;
|
2003-11-02 22:51:49 +00:00
|
|
|
int parse_preferences_for_user_files();
|
2006-10-09 18:58:52 +00:00
|
|
|
int parse_project_files(MIOFILE&, bool delete_existing_symlinks);
|
2006-06-26 22:58:24 +00:00
|
|
|
void write_project_files(MIOFILE&);
|
2006-10-09 21:43:59 +00:00
|
|
|
void link_project_files(bool recreate_symlink_files);
|
2006-07-25 21:07:14 +00:00
|
|
|
int write_symlink_for_project_file(FILE_INFO*);
|
2008-10-04 23:44:24 +00:00
|
|
|
/// when last project file download finished
|
2006-10-12 19:43:55 +00:00
|
|
|
double project_files_downloaded_time;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// called when a project file download finishes.
|
|
|
|
/// If it's the last one, set project_files_downloaded_time to now
|
2006-10-12 19:43:55 +00:00
|
|
|
void update_project_files_downloaded_time();
|
2005-06-18 21:54:24 +00:00
|
|
|
|
2008-10-04 23:44:24 +00:00
|
|
|
/// Multiply by this when estimating the CPU time of a result
|
|
|
|
/// (based on FLOPs estimated and benchmarks).
|
|
|
|
/// This is dynamically updated in a way that maintains an upper bound.
|
|
|
|
/// it goes down slowly but if a new estimate X is larger,
|
|
|
|
/// the factor is set to X.
|
2005-06-18 21:54:24 +00:00
|
|
|
double duration_correction_factor;
|
2008-12-02 22:19:39 +00:00
|
|
|
void update_duration_correction_factor(ACTIVE_TASK*);
|
2004-06-30 01:10:22 +00:00
|
|
|
|
2005-06-07 18:30:36 +00:00
|
|
|
// fields used by CPU scheduler and work fetch
|
|
|
|
// everything from here on applies only to CPU intensive projects
|
|
|
|
|
2008-10-04 23:44:24 +00:00
|
|
|
/// not suspended and not deferred and not no more work
|
2008-12-31 23:07:59 +00:00
|
|
|
bool can_request_work();
|
2009-12-02 03:41:52 +00:00
|
|
|
/// has a runnable result using the given resource type
|
|
|
|
bool runnable(int rsc_type);
|
2008-10-04 23:44:24 +00:00
|
|
|
/// has a result in downloading state
|
2005-06-07 21:21:35 +00:00
|
|
|
bool downloading();
|
2008-10-04 23:44:24 +00:00
|
|
|
/// runnable or contactable or downloading
|
2005-06-07 19:22:50 +00:00
|
|
|
bool potentially_runnable();
|
2008-10-04 23:44:24 +00:00
|
|
|
/// runnable or downloading
|
2006-06-15 23:15:27 +00:00
|
|
|
bool nearly_runnable();
|
2008-10-04 23:44:24 +00:00
|
|
|
/// the project has used too much CPU time recently
|
2006-06-15 23:15:27 +00:00
|
|
|
bool overworked();
|
2008-10-04 23:44:24 +00:00
|
|
|
/// a download is backed off
|
2006-11-21 20:57:36 +00:00
|
|
|
bool some_download_stalled();
|
2006-11-26 02:06:30 +00:00
|
|
|
bool some_result_suspended();
|
2005-06-07 18:30:36 +00:00
|
|
|
|
2008-05-23 22:03:27 +00:00
|
|
|
RR_SIM_PROJECT_STATUS rr_sim_status;
|
2008-05-23 20:58:06 +00:00
|
|
|
// temps used in CLIENT_STATE::rr_simulation();
|
|
|
|
|
2008-10-04 23:44:24 +00:00
|
|
|
/// the next result to run for this project
|
2005-06-01 05:49:51 +00:00
|
|
|
struct RESULT *next_runnable_result;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// number of results in UPLOADING state
|
|
|
|
/// Don't start new results if these exceeds 2*ncpus.
|
2007-01-25 21:36:27 +00:00
|
|
|
int nuploading_results;
|
2009-07-22 22:00:51 +00:00
|
|
|
bool too_many_uploading_results;
|
2005-05-09 04:49:56 +00:00
|
|
|
|
2008-12-31 23:07:59 +00:00
|
|
|
// stuff related to work fetch
|
|
|
|
//
|
|
|
|
RSC_PROJECT_WORK_FETCH cpu_pwf;
|
|
|
|
RSC_PROJECT_WORK_FETCH cuda_pwf;
|
2009-08-17 16:50:40 +00:00
|
|
|
RSC_PROJECT_WORK_FETCH ati_pwf;
|
2008-12-31 23:07:59 +00:00
|
|
|
PROJECT_WORK_FETCH pwf;
|
2009-01-23 18:29:28 +00:00
|
|
|
inline void reset() {
|
|
|
|
cpu_pwf.reset();
|
|
|
|
cuda_pwf.reset();
|
2009-08-17 16:50:40 +00:00
|
|
|
ati_pwf.reset();
|
2008-12-31 23:07:59 +00:00
|
|
|
}
|
2005-06-01 05:49:51 +00:00
|
|
|
|
2008-10-04 23:44:24 +00:00
|
|
|
/// # of results being returned in current scheduler op
|
2005-05-31 23:43:34 +00:00
|
|
|
int nresults_returned;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// get scheduler URL with random offset r
|
2005-06-01 05:49:51 +00:00
|
|
|
const char* get_scheduler_url(int index, double r);
|
2008-10-04 23:44:24 +00:00
|
|
|
/// temporary used when scanning projects
|
2004-08-21 23:11:19 +00:00
|
|
|
bool checked;
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2009-07-16 16:35:57 +00:00
|
|
|
FILE_XFER_BACKOFF download_backoff;
|
|
|
|
FILE_XFER_BACKOFF upload_backoff;
|
|
|
|
inline FILE_XFER_BACKOFF& file_xfer_backoff(bool is_upload) {
|
|
|
|
return is_upload?upload_backoff:download_backoff;
|
|
|
|
}
|
2005-09-30 21:29:31 +00:00
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
PROJECT();
|
2005-08-15 05:08:42 +00:00
|
|
|
~PROJECT(){}
|
2003-06-23 22:05:14 +00:00
|
|
|
void init();
|
2002-06-21 06:52:47 +00:00
|
|
|
void copy_state_fields(PROJECT&);
|
2003-05-08 23:28:01 +00:00
|
|
|
char *get_project_name();
|
2003-05-13 18:55:07 +00:00
|
|
|
int write_account_file();
|
2002-09-26 05:57:10 +00:00
|
|
|
int parse_account(FILE*);
|
2006-07-14 21:08:12 +00:00
|
|
|
int parse_account_file_venue();
|
2003-11-02 22:51:49 +00:00
|
|
|
int parse_account_file();
|
2004-06-12 04:45:36 +00:00
|
|
|
int parse_state(MIOFILE&);
|
2004-07-19 19:40:06 +00:00
|
|
|
int write_state(MIOFILE&, bool gui_rpc=false);
|
2005-04-04 06:02:36 +00:00
|
|
|
|
2005-04-12 23:07:04 +00:00
|
|
|
// statistic of the last x days
|
2005-08-11 04:45:16 +00:00
|
|
|
std::vector<DAILY_STATS> statistics;
|
2005-04-04 06:02:36 +00:00
|
|
|
int parse_statistics(MIOFILE&);
|
|
|
|
int parse_statistics(FILE*);
|
|
|
|
int write_statistics(MIOFILE&, bool gui_rpc=false);
|
|
|
|
int write_statistics_file();
|
2009-12-21 17:49:28 +00:00
|
|
|
|
|
|
|
// feed-related
|
|
|
|
std::vector<RSS_FEED> proj_feeds;
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct APP {
|
|
|
|
char name[256];
|
2006-06-26 19:08:00 +00:00
|
|
|
char user_friendly_name[256];
|
2002-04-30 22:22:54 +00:00
|
|
|
PROJECT* project;
|
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
int parse(MIOFILE&);
|
|
|
|
int write(MIOFILE&);
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
|
|
|
|
2002-05-17 22:33:57 +00:00
|
|
|
struct APP_VERSION {
|
|
|
|
char app_name[256];
|
|
|
|
int version_num;
|
2007-05-03 17:14:30 +00:00
|
|
|
char platform[256];
|
2008-03-27 18:25:29 +00:00
|
|
|
char plan_class[64];
|
2007-09-21 18:10:54 +00:00
|
|
|
char api_version[16];
|
2008-03-28 18:00:27 +00:00
|
|
|
double avg_ncpus;
|
|
|
|
double max_ncpus;
|
2009-08-19 18:41:47 +00:00
|
|
|
double ncudas;
|
|
|
|
double natis;
|
2009-12-11 22:45:59 +00:00
|
|
|
double gpu_ram;
|
2008-03-28 18:00:27 +00:00
|
|
|
double flops;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// additional cmdline args
|
|
|
|
char cmdline[256];
|
2008-03-28 18:00:27 +00:00
|
|
|
|
2002-05-17 22:33:57 +00:00
|
|
|
APP* app;
|
|
|
|
PROJECT* project;
|
2004-06-30 18:17:21 +00:00
|
|
|
std::vector<FILE_REF> app_files;
|
2003-03-02 19:24:09 +00:00
|
|
|
int ref_cnt;
|
2007-06-14 23:08:43 +00:00
|
|
|
char graphics_exec_path[512];
|
2009-04-09 16:46:03 +00:00
|
|
|
double max_working_set_size;
|
|
|
|
// max working set of tasks using this app version.
|
|
|
|
// temp var used in schedule_cpus()
|
2010-01-21 00:14:56 +00:00
|
|
|
//double temp_dcf;
|
2002-05-17 22:33:57 +00:00
|
|
|
|
2007-05-10 16:23:10 +00:00
|
|
|
APP_VERSION(){}
|
|
|
|
~APP_VERSION(){}
|
2004-06-12 04:45:36 +00:00
|
|
|
int parse(MIOFILE&);
|
2009-03-05 17:45:36 +00:00
|
|
|
int write(MIOFILE&, bool write_file_info = true);
|
2004-10-07 19:18:37 +00:00
|
|
|
bool had_download_failure(int& failnum);
|
2004-09-02 16:23:21 +00:00
|
|
|
void get_file_errors(std::string&);
|
|
|
|
void clear_errors();
|
2007-09-21 18:10:54 +00:00
|
|
|
int api_major_version();
|
2009-02-06 00:22:21 +00:00
|
|
|
bool missing_coproc();
|
2009-08-19 18:41:47 +00:00
|
|
|
bool uses_coproc(int rsc_type) {
|
|
|
|
switch (rsc_type) {
|
|
|
|
case RSC_TYPE_CUDA: return (ncudas>0);
|
|
|
|
case RSC_TYPE_ATI: return (natis>0);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2002-05-17 22:33:57 +00:00
|
|
|
};
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
struct WORKUNIT {
|
|
|
|
char name[256];
|
|
|
|
char app_name[256];
|
2008-10-04 23:44:24 +00:00
|
|
|
/// Deprecated, but need to keep around to let people revert
|
|
|
|
/// to versions before multi-platform support
|
2002-04-30 22:22:54 +00:00
|
|
|
int version_num;
|
2004-12-26 02:55:31 +00:00
|
|
|
std::string command_line;
|
2004-06-30 18:17:21 +00:00
|
|
|
std::vector<FILE_REF> input_files;
|
2002-04-30 22:22:54 +00:00
|
|
|
PROJECT* project;
|
|
|
|
APP* app;
|
|
|
|
int ref_cnt;
|
2003-09-04 00:41:51 +00:00
|
|
|
double rsc_fpops_est;
|
|
|
|
double rsc_fpops_bound;
|
|
|
|
double rsc_memory_bound;
|
|
|
|
double rsc_disk_bound;
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2007-05-10 16:23:10 +00:00
|
|
|
WORKUNIT(){}
|
|
|
|
~WORKUNIT(){}
|
2004-06-12 04:45:36 +00:00
|
|
|
int parse(MIOFILE&);
|
|
|
|
int write(MIOFILE&);
|
2004-10-07 19:18:37 +00:00
|
|
|
bool had_download_failure(int& failnum);
|
2004-06-30 18:17:21 +00:00
|
|
|
void get_file_errors(std::string&);
|
2005-01-13 18:57:27 +00:00
|
|
|
void clear_errors();
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RESULT {
|
|
|
|
char name[256];
|
|
|
|
char wu_name[256];
|
2009-06-30 20:22:54 +00:00
|
|
|
double received_time; // when we got this from server
|
2004-12-01 20:56:20 +00:00
|
|
|
double report_deadline;
|
2007-05-03 17:14:30 +00:00
|
|
|
int version_num; // identifies the app used
|
2008-03-27 18:25:29 +00:00
|
|
|
char plan_class[64];
|
2007-05-03 17:14:30 +00:00
|
|
|
char platform[256];
|
|
|
|
APP_VERSION* avp;
|
2004-06-30 18:17:21 +00:00
|
|
|
std::vector<FILE_REF> output_files;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// we're ready to report this result to the server;
|
|
|
|
/// either computation is done and all the files have been uploaded
|
|
|
|
/// or there was an error
|
2003-09-23 23:19:41 +00:00
|
|
|
bool ready_to_report;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// time when ready_to_report was set
|
2005-05-20 17:57:10 +00:00
|
|
|
double completed_time;
|
2009-06-30 20:22:54 +00:00
|
|
|
/// we've received the ack for this result from the server
|
2003-09-23 23:19:41 +00:00
|
|
|
bool got_server_ack;
|
2002-08-05 00:29:34 +00:00
|
|
|
double final_cpu_time;
|
2009-03-11 22:01:38 +00:00
|
|
|
double final_elapsed_time;
|
2008-10-04 23:44:24 +00:00
|
|
|
|
|
|
|
// the following are nonzero if reported by app
|
|
|
|
double fpops_per_cpu_sec;
|
|
|
|
double fpops_cumulative;
|
|
|
|
double intops_per_cpu_sec;
|
|
|
|
double intops_cumulative;
|
|
|
|
|
|
|
|
/// state of this result: see lib/result_state.h
|
|
|
|
int _state;
|
2007-01-24 21:20:57 +00:00
|
|
|
inline int state() { return _state; }
|
|
|
|
void set_state(int, const char*);
|
2008-10-04 23:44:24 +00:00
|
|
|
/// return value from the application
|
|
|
|
int exit_status;
|
|
|
|
/// the concatenation of:
|
|
|
|
///
|
|
|
|
/// - if report_result_error() is called for this result:
|
|
|
|
/// <message>x</message>
|
|
|
|
/// <exit_status>x</exit_status>
|
|
|
|
/// <signal>x</signal>
|
|
|
|
/// - if called in FILES_DOWNLOADED state:
|
|
|
|
/// <couldnt_start>x</couldnt_start>
|
|
|
|
/// - if called in NEW state:
|
|
|
|
/// <download_error>x</download_error> for each failed download
|
|
|
|
/// - if called in COMPUTE_DONE state:
|
|
|
|
/// <upload_error>x</upload_error> for each failed upload
|
|
|
|
///
|
|
|
|
/// - <stderr_txt>X</stderr_txt>, where X is the app's stderr output
|
2004-06-30 18:17:21 +00:00
|
|
|
std::string stderr_out;
|
2005-01-21 22:03:15 +00:00
|
|
|
bool suspended_via_gui;
|
2009-10-12 16:28:17 +00:00
|
|
|
bool coproc_missing;
|
|
|
|
// a coproc needed by this job is missing
|
|
|
|
// (e.g. because user removed their GPU board).
|
2003-07-03 00:48:43 +00:00
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
APP* app;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// this may be NULL after result is finished
|
2002-04-30 22:22:54 +00:00
|
|
|
WORKUNIT* wup;
|
|
|
|
PROJECT* project;
|
|
|
|
|
2007-05-10 16:23:10 +00:00
|
|
|
RESULT(){}
|
|
|
|
~RESULT(){}
|
2002-07-05 05:33:40 +00:00
|
|
|
void clear();
|
2004-06-12 04:45:36 +00:00
|
|
|
int parse_server(MIOFILE&);
|
|
|
|
int parse_state(MIOFILE&);
|
2006-05-25 20:10:08 +00:00
|
|
|
int parse_name(FILE*, const char* end_tag);
|
2004-06-12 04:45:36 +00:00
|
|
|
int write(MIOFILE&, bool to_server);
|
2004-07-13 23:51:09 +00:00
|
|
|
int write_gui(MIOFILE&);
|
2002-04-30 22:22:54 +00:00
|
|
|
bool is_upload_done(); // files uploaded?
|
2006-06-19 17:40:53 +00:00
|
|
|
void clear_uploaded_flags();
|
2005-04-28 23:19:58 +00:00
|
|
|
FILE_REF* lookup_file(FILE_INFO*);
|
|
|
|
FILE_INFO* lookup_file_logical(const char*);
|
2008-10-04 23:44:24 +00:00
|
|
|
/// abort the result if it hasn't started computing yet
|
|
|
|
|
|
|
|
/// Called only for results with no active task
|
|
|
|
/// (otherwise you need to abort the active task)
|
2006-05-25 20:10:08 +00:00
|
|
|
void abort_inactive(int);
|
2007-04-13 04:22:20 +00:00
|
|
|
void append_log_record();
|
2006-01-27 19:50:43 +00:00
|
|
|
|
|
|
|
// stuff related to CPU scheduling
|
|
|
|
|
2008-12-02 03:58:32 +00:00
|
|
|
double estimated_duration(bool for_work_fetch);
|
|
|
|
double estimated_duration_uncorrected();
|
|
|
|
double estimated_time_remaining(bool for_work_fetch);
|
|
|
|
inline double estimated_flops_remaining() {
|
|
|
|
return estimated_time_remaining(false)*avp->flops;
|
|
|
|
}
|
|
|
|
|
2009-02-26 17:12:55 +00:00
|
|
|
inline bool computing_done() {
|
|
|
|
if (state() >= RESULT_COMPUTE_ERROR) return true;
|
|
|
|
if (ready_to_report) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool not_started();
|
2008-10-04 23:44:24 +00:00
|
|
|
/// downloaded, not finished, not suspended, project not suspended
|
2005-06-07 18:30:36 +00:00
|
|
|
bool runnable();
|
2008-10-04 23:44:24 +00:00
|
|
|
/// downloading or downloaded,
|
|
|
|
/// not finished, suspended, project not suspended
|
2006-06-20 20:29:10 +00:00
|
|
|
bool nearly_runnable();
|
2008-10-04 23:44:24 +00:00
|
|
|
/// downloading, not downloaded, not suspended, project not suspended
|
2006-09-06 21:58:12 +00:00
|
|
|
bool downloading();
|
2008-10-04 23:44:24 +00:00
|
|
|
/// some input or app file is downloading, and backed off
|
|
|
|
/// i.e. it may be a long time before we can run this result
|
2006-11-26 02:06:30 +00:00
|
|
|
bool some_download_stalled();
|
2009-02-01 04:37:19 +00:00
|
|
|
inline bool uses_cuda() {
|
|
|
|
return (avp->ncudas > 0);
|
|
|
|
}
|
2009-08-17 16:50:40 +00:00
|
|
|
inline bool uses_ati() {
|
|
|
|
return (avp->natis > 0);
|
|
|
|
}
|
2009-02-01 04:37:19 +00:00
|
|
|
inline bool uses_coprocs() {
|
2009-08-17 16:50:40 +00:00
|
|
|
if (avp->ncudas > 0) return true;
|
|
|
|
if (avp->natis > 0) return true;
|
|
|
|
return false;
|
2008-09-25 01:04:53 +00:00
|
|
|
}
|
2007-03-05 00:32:26 +00:00
|
|
|
|
|
|
|
// temporaries used in CLIENT_STATE::rr_simulation():
|
2008-12-02 03:58:32 +00:00
|
|
|
double rrsim_flops_left;
|
2006-01-27 19:50:43 +00:00
|
|
|
double rrsim_finish_delay;
|
2008-12-02 03:58:32 +00:00
|
|
|
double rrsim_flops;
|
2008-11-01 21:10:08 +00:00
|
|
|
|
2008-10-04 23:44:24 +00:00
|
|
|
/// used to keep cpu scheduler from scheduling a result twice
|
|
|
|
/// transient; used only within schedule_cpus()
|
2006-01-27 19:50:43 +00:00
|
|
|
bool already_selected;
|
2008-10-04 23:44:24 +00:00
|
|
|
/// report deadline - prefs.work_buf_min - time slice
|
2006-04-05 05:50:34 +00:00
|
|
|
double computation_deadline();
|
2006-06-15 23:15:27 +00:00
|
|
|
bool rr_sim_misses_deadline;
|
2007-03-05 00:32:26 +00:00
|
|
|
|
2009-05-04 19:55:59 +00:00
|
|
|
// temporaries used in enforce_schedule():
|
|
|
|
bool unfinished_time_slice;
|
|
|
|
int seqno;
|
|
|
|
|
2008-10-04 23:44:24 +00:00
|
|
|
/// temporary used to tell GUI that this result is deadline-scheduled
|
2007-03-05 00:32:26 +00:00
|
|
|
bool edf_scheduled;
|
2009-09-22 21:02:06 +00:00
|
|
|
|
|
|
|
int coproc_indices[MAX_COPROCS_PER_JOB];
|
|
|
|
// keep track of coprocessor reservations
|
2009-10-04 02:51:44 +00:00
|
|
|
char resources[256];
|
|
|
|
// textual description of resources used
|
2009-12-11 22:45:59 +00:00
|
|
|
bool insufficient_video_ram();
|
|
|
|
double schedule_backoff;
|
|
|
|
// don't try to schedule until this time
|
|
|
|
// (wait for free video RAM)
|
2006-01-28 00:17:26 +00:00
|
|
|
};
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2008-10-04 23:44:24 +00:00
|
|
|
/// represents an always/auto/never value, possibly temporarily overridden
|
|
|
|
|
2006-11-10 17:55:22 +00:00
|
|
|
class MODE {
|
|
|
|
private:
|
|
|
|
int perm_mode;
|
|
|
|
int temp_mode;
|
|
|
|
double temp_timeout;
|
|
|
|
public:
|
|
|
|
MODE();
|
|
|
|
void set(int mode, double duration);
|
|
|
|
int get_perm();
|
|
|
|
int get_current();
|
2006-11-20 16:52:03 +00:00
|
|
|
double delay();
|
2006-11-10 17:55:22 +00:00
|
|
|
};
|
|
|
|
|
2008-10-04 23:44:24 +00:00
|
|
|
/// a platform supported by the client.
|
|
|
|
|
2007-05-02 17:53:35 +00:00
|
|
|
class PLATFORM {
|
|
|
|
public:
|
|
|
|
std::string name;
|
|
|
|
};
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
#endif
|