diff --git a/client/app_config.cpp b/client/app_config.cpp index 143c51c9b6..c763720719 100644 --- a/client/app_config.cpp +++ b/client/app_config.cpp @@ -27,13 +27,49 @@ bool have_max_concurrent = false; +int APP_CONFIG::parse_gpu_versions(XML_PARSER& xp, PROJECT* p) { + double x; + while (!xp.get_tag()) { + if (xp.match_tag("/gpu_versions")) return 0; + else if (xp.parse_double("gpu_usage", x)) { + if (x <= 0) { + msg_printf(p, MSG_USER_ALERT, + "gpu_usage must be positive in app_config.xml" + ); + } else { + gpu_gpu_usage = x; + } + continue; + } + else if (xp.parse_double("cpu_usage", x)) { + if (x < 0) { + msg_printf(p, MSG_USER_ALERT, + "cpu_usage must be non-negative in app_config.xml" + ); + } else { + gpu_cpu_usage = x; + } + continue; + } + if (log_flags.unparsed_xml) { + msg_printf(p, MSG_INFO, + "Unparsed line in app_config.xml: %s", + xp.parsed_tag + ); + } + } + msg_printf_notice(p, false, NULL, + "missing in app_config.xml" + ); + return ERR_XML_PARSE; +} + // In these parsing functions, if there's an error you must // - generate a notice containing the string "app_config.xml" // - return an error code // int APP_CONFIG::parse(XML_PARSER& xp, PROJECT* p) { memset(this, 0, sizeof(APP_CONFIG)); - double x; while (!xp.get_tag()) { if (xp.match_tag("/app")) return 0; @@ -43,29 +79,8 @@ int APP_CONFIG::parse(XML_PARSER& xp, PROJECT* p) { continue; } if (xp.match_tag("gpu_versions")) { - while (!xp.get_tag()) { - if (xp.match_tag("/gpu_versions")) break; - if (xp.parse_double("gpu_usage", x)) { - if (x <= 0) { - msg_printf(p, MSG_USER_ALERT, - "gpu_usage must be positive in app_config.xml" - ); - } else { - gpu_gpu_usage = x; - } - continue; - } - if (xp.parse_double("cpu_usage", x)) { - if (x < 0) { - msg_printf(p, MSG_USER_ALERT, - "cpu_usage must be non-negative in app_config.xml" - ); - } else { - gpu_cpu_usage = x; - } - continue; - } - } + int retval = parse_gpu_versions(xp, p); + if (retval) return retval; continue; } if (xp.parse_bool("fraction_done_exact", fraction_done_exact)) { diff --git a/client/app_config.h b/client/app_config.h index 1dc88ab6f7..0bb198f3dd 100644 --- a/client/app_config.h +++ b/client/app_config.h @@ -35,6 +35,7 @@ struct APP_CONFIG { bool fraction_done_exact; int parse(XML_PARSER&, PROJECT*); + int parse_gpu_versions(XML_PARSER&, PROJECT*); }; struct APP_VERSION_CONFIG { diff --git a/client/client_state.cpp b/client/client_state.cpp index 16779b8f0f..bf19631a01 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -423,6 +423,15 @@ int CLIENT_STATE::init() { coprocs.coprocs[j].type, coprocs.coprocs[j].count ); + if (coprocs.coprocs[j].count > MAX_COPROC_INSTANCES) { + msg_printf(NULL, MSG_USER_ALERT, + "%d instances of %s specified in cc_config.xml; max is %d", + coprocs.coprocs[j].count, + coprocs.coprocs[j].type, + MAX_COPROC_INSTANCES + ); + coprocs.coprocs[j].count = MAX_COPROC_INSTANCES; + } } if (!cc_config.no_gpus #ifdef _WIN32 diff --git a/client/client_types.h b/client/client_types.h index c7d753f02d..b299a7fd3d 100644 --- a/client/client_types.h +++ b/client/client_types.h @@ -258,7 +258,7 @@ struct APP { // Can also specify in client_state.xml (for client emulator) int n_concurrent; // temp during job scheduling, to enforce max_concurrent - int non_excluded_instances[MAX_RSC]; + COPROC_INSTANCE_BITMAP non_excluded_instances[MAX_RSC]; // for each resource type, bitmap of the non-excluded instances #ifdef SIM double latency_bound; diff --git a/client/gpu_detect.cpp b/client/gpu_detect.cpp index 2d73b9c675..76628d3306 100644 --- a/client/gpu_detect.cpp +++ b/client/gpu_detect.cpp @@ -304,9 +304,11 @@ void COPROCS::correlate_gpus( cpu_opencls.clear(); } -// This is called from CLIENT_STATE::init() after adding NVIDIA, ATI and Intel GPUs +// This is called from CLIENT_STATE::init() +// after adding NVIDIA, ATI and Intel GPUs // If we don't care about the order of GPUs in COPROCS::coprocs[], // this code could be included at the end of COPROCS::correlate_gpus(). +// int COPROCS::add_other_coproc_types() { int retval = 0; @@ -318,8 +320,10 @@ int COPROCS::add_other_coproc_types() { } COPROC c; - // For other device types other than NVIDIA, ATI or Intel GPU coprocessor. - // we put each instance into a separate other_opencls element, so count=1. + // For device types other than NVIDIA, ATI or Intel GPU. + // we put each instance into a separate other_opencls element, + // so count=1. + // c.count = 1; c.opencl_device_count = 1; c.opencl_prop = other_opencls[i]; diff --git a/client/log_flags.cpp b/client/log_flags.cpp index 223176ea2b..5196d0c53e 100644 --- a/client/log_flags.cpp +++ b/client/log_flags.cpp @@ -592,7 +592,9 @@ void process_gpu_exclusions() { APP* app = gstate.apps[i]; for (int k=1; knon_excluded_instances[k] = (1<non_excluded_instances[k] |= ((COPROC_INSTANCE_BITMAP)1)<master_url)) continue; - int mask; + COPROC_INSTANCE_BITMAP mask; if (eg.device_num >= 0) { int index = cp.device_num_index(eg.device_num); // exclusion may refer to nonexistent GPU // if (index < 0) continue; - mask = 1<rsc_pwf[k].ncoprocs_excluded = 0; for (int b=0; bproject != p) continue; diff --git a/client/rr_sim.cpp b/client/rr_sim.cpp index 33a3fffd3f..a8b7e660b5 100644 --- a/client/rr_sim.cpp +++ b/client/rr_sim.cpp @@ -64,12 +64,14 @@ inline void rsc_string(RESULT* rp, char* buf) { // set "nused" bits of the source bitmap in the dest bitmap // -static inline void set_bits(int src, double nused, int& dst) { +static inline void set_bits( + COPROC_INSTANCE_BITMAP src, double nused, COPROC_INSTANCE_BITMAP& dst +) { // if all bits are already set, we're done // if ((src&dst) == src) return; - int bit = 1; - for (int i=0; i<32; i++) { + COPROC_INSTANCE_BITMAP bit = 1; + for (int i=0; i