2012-05-08 12:31:37 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2012 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/>.
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
#include "sched_config.h"
|
|
|
|
#include "sched_customize.h"
|
|
|
|
#include "plan_class_spec.h"
|
|
|
|
|
2012-05-14 19:49:12 +00:00
|
|
|
using std::string;
|
2012-05-08 12:31:37 +00:00
|
|
|
|
|
|
|
int PLAN_CLASS_SPECS::parse_file(char*path) {
|
|
|
|
#ifndef _USING_FCGI_
|
|
|
|
FILE* f = fopen(path, "r");
|
|
|
|
#else
|
|
|
|
FCGI_FILE *f = FCGI::fopen(path, "r");
|
|
|
|
#endif
|
|
|
|
if (!f) return ERR_FOPEN;
|
|
|
|
int retval = parse_specs(f);
|
|
|
|
fclose(f);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PLAN_CLASS_SPEC::check(SCHEDULER_REQUEST& sreq, HOST_USAGE& hu) {
|
2012-05-14 19:49:12 +00:00
|
|
|
COPROC* cpp = NULL;
|
2012-05-14 06:54:38 +00:00
|
|
|
|
2012-05-08 12:31:37 +00:00
|
|
|
// fill HOST_USAGE with defaults
|
|
|
|
hu.ncudas = 0;
|
|
|
|
hu.natis = 0;
|
|
|
|
hu.gpu_ram = 0;
|
|
|
|
hu.avg_ncpus = 1;
|
|
|
|
hu.max_ncpus = 1;
|
|
|
|
hu.projected_flops = sreq.host.p_fpops;
|
|
|
|
hu.peak_flops = sreq.host.p_fpops;
|
2012-05-14 06:54:38 +00:00
|
|
|
strcpy(hu.cmdline, "");
|
2012-05-08 12:31:37 +00:00
|
|
|
|
|
|
|
// CPU features
|
2012-05-14 06:54:38 +00:00
|
|
|
//
|
2012-06-03 17:31:00 +00:00
|
|
|
// older clients report CPU features in p_model,
|
|
|
|
// within square brackets
|
|
|
|
//
|
|
|
|
// the requested features are surrounded by spaces,
|
|
|
|
// so we can look for them with strstr()
|
|
|
|
//
|
|
|
|
if (!cpu_features.empty()) {
|
|
|
|
char buf[8192], buf2[512];
|
|
|
|
sprintf(buf, " %s ", sreq.host.p_features);
|
|
|
|
char* p = strrchr(sreq.host.p_model, '[');
|
|
|
|
if (p) {
|
|
|
|
sprintf(buf2, " %s", p+1);
|
|
|
|
p = strchr(buf2, ']');
|
|
|
|
if (p) {
|
|
|
|
*p = 0;
|
|
|
|
}
|
|
|
|
strcat(buf2, " ");
|
|
|
|
strcat(buf, buf2);
|
|
|
|
}
|
|
|
|
downcase_string(buf);
|
|
|
|
|
|
|
|
for (unsigned int i=0; i<cpu_features.size(); i++) {
|
|
|
|
if (!strstr(sreq.host.p_features, cpu_features[i].c_str())) {
|
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
|
|
|
"[version] CPU lacks feature '%s' (got '%s')\n",
|
|
|
|
cpu_features[i].c_str(), sreq.host.p_features
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-14 06:54:38 +00:00
|
|
|
// OS version
|
|
|
|
//
|
|
|
|
if (have_os_regex && regexec(&(os_regex), sreq.host.os_version, 0, NULL, 0)) {
|
2012-05-08 12:31:37 +00:00
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
2012-05-14 06:54:38 +00:00
|
|
|
"[version] OS version '%s' didn't match regexp\n",
|
|
|
|
sreq.host.os_version
|
2012-05-08 12:31:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// project-specific preference
|
2012-05-14 06:54:38 +00:00
|
|
|
//
|
|
|
|
if (have_project_prefs_regex && strlen(project_prefs_tag)) {
|
|
|
|
char tag[256], value[256];
|
2012-05-08 12:31:37 +00:00
|
|
|
char buf[65536];
|
|
|
|
extract_venue(g_reply->user.project_prefs, g_reply->host.venue, buf);
|
|
|
|
sprintf(tag,"<%s>",project_prefs_tag);
|
2012-05-14 06:54:38 +00:00
|
|
|
bool p = parse_str(buf, tag, value, sizeof(value));
|
2012-05-08 12:31:37 +00:00
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
2012-05-14 06:54:38 +00:00
|
|
|
"[version] parsed project prefs setting '%s' : %s\n",
|
|
|
|
project_prefs_tag, p?"true":"false"
|
2012-05-08 12:31:37 +00:00
|
|
|
);
|
|
|
|
}
|
2012-05-14 06:54:38 +00:00
|
|
|
if (regexec(&(project_prefs_regex), value, 0, NULL, 0)) {
|
2012-05-08 12:31:37 +00:00
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
2012-05-14 06:54:38 +00:00
|
|
|
"[version] project prefs setting '%s' prevents using plan class.\n",
|
|
|
|
project_prefs_tag
|
2012-05-08 12:31:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-14 19:49:12 +00:00
|
|
|
double gpu_ram = 0;
|
|
|
|
int driver_version = 0;
|
2012-05-08 12:31:37 +00:00
|
|
|
double gpu_utilization = 1.0;
|
|
|
|
|
|
|
|
// user defined gpu_utilization
|
2012-05-14 06:54:38 +00:00
|
|
|
//
|
|
|
|
if (strlen(gpu_utilization_tag)) {
|
2012-05-08 12:31:37 +00:00
|
|
|
char tag[256];
|
|
|
|
char buf[65536];
|
|
|
|
double v = 0;
|
|
|
|
extract_venue(g_reply->user.project_prefs, g_reply->host.venue, buf);
|
|
|
|
sprintf(tag,"<%s>",gpu_utilization_tag);
|
|
|
|
bool p = parse_double(buf, tag, v);
|
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
|
|
|
"[version] parsed project prefs setting '%s' : %s : %f\n",
|
|
|
|
gpu_utilization_tag, p?"true":"false", v
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (v) {
|
|
|
|
gpu_utilization = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-14 06:54:38 +00:00
|
|
|
// ATI
|
|
|
|
//
|
|
|
|
if (!strcmp(gpu_type, "ati")) {
|
|
|
|
COPROC_ATI& cp = sreq.coprocs.ati;
|
2012-05-14 19:49:12 +00:00
|
|
|
cpp = &cp;
|
2012-05-08 12:31:37 +00:00
|
|
|
|
|
|
|
if (!cp.count) {
|
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
2012-05-14 06:54:38 +00:00
|
|
|
"[version] No ATI devices found\n"
|
2012-05-08 12:31:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (min_gpu_ram_mb) {
|
2012-05-14 06:54:38 +00:00
|
|
|
ati_requirements.update(0, min_gpu_ram_mb * MEGA);
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
|
|
|
if (min_driver_version) {
|
2012-05-14 06:54:38 +00:00
|
|
|
ati_requirements.update(abs(min_driver_version), 0);
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
2012-05-14 19:49:12 +00:00
|
|
|
cp.set_peak_flops();
|
2012-05-14 06:54:38 +00:00
|
|
|
gpu_ram = cp.opencl_prop.global_mem_size;
|
2012-05-08 12:31:37 +00:00
|
|
|
|
2012-05-14 19:49:12 +00:00
|
|
|
driver_version = 0;
|
2012-05-14 06:54:38 +00:00
|
|
|
if (cp.have_cal) {
|
|
|
|
int major, minor, release, scanned;
|
|
|
|
scanned = sscanf(cp.version, "%d.%d.%d", &major, &minor, &release);
|
|
|
|
if (scanned != 3) {
|
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
|
|
|
"[version] driver version '%s' couldn't be parsed\n",
|
|
|
|
cp.version
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
driver_version = release + minor * 10000 + major * 1000000;
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
2012-05-14 06:54:38 +00:00
|
|
|
} else {
|
2012-05-08 12:31:37 +00:00
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
2012-05-14 06:54:38 +00:00
|
|
|
"[version] no CAL, driver version couldn't be determined\n"
|
2012-05-08 12:31:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2012-05-14 06:54:38 +00:00
|
|
|
} else if (!strcmp(gpu_type, "nvidia")) {
|
|
|
|
// NVIDIA
|
|
|
|
//
|
|
|
|
COPROC_NVIDIA& cp = sreq.coprocs.nvidia;
|
2012-05-14 19:49:12 +00:00
|
|
|
cpp = &cp;
|
|
|
|
|
2012-05-14 06:54:38 +00:00
|
|
|
if (!cp.count) {
|
2012-05-08 12:31:37 +00:00
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
2012-05-14 06:54:38 +00:00
|
|
|
"[version] No NVIDIA devices found\n"
|
2012-05-08 12:31:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-05-14 06:54:38 +00:00
|
|
|
if (min_gpu_ram_mb) {
|
|
|
|
cuda_requirements.update(0, min_gpu_ram_mb * MEGA);
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
2012-05-14 06:54:38 +00:00
|
|
|
if (min_driver_version) {
|
|
|
|
cuda_requirements.update(abs(min_driver_version), 0);
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
2012-05-14 06:54:38 +00:00
|
|
|
// compute capability
|
|
|
|
int v = (cp.prop.major)*100 + cp.prop.minor;
|
2012-05-14 19:49:12 +00:00
|
|
|
if (min_nvidia_compcap && min_nvidia_compcap > v) {
|
2012-05-08 12:31:37 +00:00
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
2012-05-14 19:49:12 +00:00
|
|
|
"[version] NVIDIA compute capability required min: %d, supplied: %d\n",
|
|
|
|
min_nvidia_compcap, v
|
2012-05-08 12:31:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-14 19:49:12 +00:00
|
|
|
if (max_nvidia_compcap && max_nvidia_compcap < v) {
|
2012-05-08 12:31:37 +00:00
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
2012-05-14 06:54:38 +00:00
|
|
|
"[version] CUDA compute capability required max: %d, supplied: %d\n",
|
2012-05-14 19:49:12 +00:00
|
|
|
max_nvidia_compcap, v
|
2012-05-08 12:31:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-14 06:54:38 +00:00
|
|
|
if (cuda) {
|
|
|
|
// CUDA version
|
|
|
|
if (min_cuda_version && min_cuda_version > cp.cuda_version) {
|
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
|
|
|
"[version] CUDA version required min: %d, supplied: %d\n",
|
|
|
|
min_cuda_version, cp.cuda_version
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
2012-05-14 06:54:38 +00:00
|
|
|
if (max_cuda_version && max_cuda_version < cp.cuda_version) {
|
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
|
|
|
"[version] CUDA version required max: %d, supplied: %d\n",
|
|
|
|
max_cuda_version, cp.cuda_version
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-14 06:54:38 +00:00
|
|
|
gpu_ram = cp.prop.totalGlobalMem;
|
2012-05-14 19:49:12 +00:00
|
|
|
cp.set_peak_flops();
|
2012-05-14 06:54:38 +00:00
|
|
|
}
|
2012-05-08 12:31:37 +00:00
|
|
|
|
2012-06-03 17:31:00 +00:00
|
|
|
if (opencl) {
|
|
|
|
// check for OpenCL at all
|
|
|
|
if (!cpp->have_opencl) {
|
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
|
|
|
"[version] GPU doesn't support OpenCL\n"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// OpenCL device version
|
|
|
|
//
|
|
|
|
if (min_opencl_version && min_opencl_version > cpp->opencl_prop.opencl_device_version_int) {
|
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
|
|
|
"[version] OpenCL device version required min: %d, supplied: %d\n",
|
|
|
|
min_opencl_version, cpp->opencl_prop.opencl_device_version_int
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-14 06:54:38 +00:00
|
|
|
// general GPU
|
|
|
|
//
|
|
|
|
if (strlen(gpu_type)) {
|
2012-05-08 12:31:37 +00:00
|
|
|
|
|
|
|
// GPU RAM
|
2012-05-14 06:54:38 +00:00
|
|
|
if (min_gpu_ram_mb && min_gpu_ram_mb * MEGA > gpu_ram) {
|
2012-05-08 12:31:37 +00:00
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
2012-05-14 06:54:38 +00:00
|
|
|
"[version] GPU RAM required min: %f, supplied: %f\n",
|
|
|
|
min_gpu_ram_mb * MEGA, gpu_ram
|
2012-05-08 12:31:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-05-14 06:54:38 +00:00
|
|
|
|
2012-05-08 12:31:37 +00:00
|
|
|
|
|
|
|
// (display) driver version
|
2012-05-14 19:49:12 +00:00
|
|
|
if (min_driver_version && driver_version) {
|
|
|
|
if (min_driver_version > driver_version) {
|
2012-05-14 06:54:38 +00:00
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
|
|
|
"[version] driver version required min: %d, supplied: %d\n",
|
2012-05-14 19:49:12 +00:00
|
|
|
abs(min_driver_version), driver_version
|
2012-05-14 06:54:38 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-14 19:49:12 +00:00
|
|
|
if (max_driver_version && driver_version) {
|
|
|
|
if (max_driver_version < driver_version) {
|
2012-05-14 06:54:38 +00:00
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
|
|
|
"[version] driver version required max: %d, supplied: %d\n",
|
2012-05-14 19:49:12 +00:00
|
|
|
abs(max_driver_version), driver_version
|
2012-05-14 06:54:38 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return false;
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hu.gpu_ram = (gpu_ram_used_mb?gpu_ram_used_mb:min_gpu_ram_mb) * MEGA;
|
|
|
|
|
2012-05-14 19:49:12 +00:00
|
|
|
double gpu_usage;
|
|
|
|
|
|
|
|
// if ngpus < 0, set gpu_usage by the fraction of the total
|
2012-05-14 06:54:38 +00:00
|
|
|
// video RAM a tasks would take
|
2012-05-08 12:31:37 +00:00
|
|
|
// i.e. fill the device memory with tasks
|
2012-05-14 06:54:38 +00:00
|
|
|
//
|
2012-05-08 12:31:37 +00:00
|
|
|
if (ngpus < 0) {
|
2012-05-14 19:49:12 +00:00
|
|
|
gpu_usage = (floor(gpu_ram/ hu.gpu_ram) * hu.gpu_ram) / gpu_ram ;
|
2012-05-08 12:31:37 +00:00
|
|
|
} else if (ngpus > 0) {
|
2012-05-14 19:49:12 +00:00
|
|
|
gpu_usage = ngpus * gpu_utilization;
|
2012-05-08 12:31:37 +00:00
|
|
|
} else {
|
2012-05-14 19:49:12 +00:00
|
|
|
gpu_usage = gpu_utilization;
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
coproc_perf(
|
|
|
|
capped_host_fpops(),
|
2012-05-14 19:49:12 +00:00
|
|
|
gpu_peak_flops_scale * gpu_usage * cpp->peak_flops,
|
2012-05-08 12:31:37 +00:00
|
|
|
cpu_frac,
|
|
|
|
hu.projected_flops,
|
|
|
|
hu.avg_ncpus
|
|
|
|
);
|
|
|
|
if (avg_ncpus) {
|
|
|
|
hu.avg_ncpus = avg_ncpus;
|
|
|
|
}
|
|
|
|
|
2012-05-14 19:49:12 +00:00
|
|
|
if (!strcmp(gpu_type, "ati")) {
|
|
|
|
hu.natis = gpu_usage;
|
|
|
|
} else if (!strcmp(gpu_type, "nvidia")) {
|
|
|
|
hu.ncudas = gpu_usage;
|
|
|
|
}
|
2012-05-14 06:54:38 +00:00
|
|
|
} else { // CPU only
|
2012-05-08 12:31:37 +00:00
|
|
|
if (avg_ncpus) {
|
|
|
|
hu.avg_ncpus = avg_ncpus;
|
|
|
|
} else {
|
2012-06-03 17:31:00 +00:00
|
|
|
if (max_threads > g_wreq->effective_ncpus) {
|
|
|
|
hu.avg_ncpus = g_wreq->effective_ncpus;
|
|
|
|
} else {
|
|
|
|
hu.avg_ncpus = max_threads;
|
|
|
|
}
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
hu.peak_flops = capped_host_fpops() * hu.avg_ncpus;
|
2012-05-14 19:49:12 +00:00
|
|
|
hu.projected_flops = capped_host_fpops() * hu.avg_ncpus * projected_flops_scale;
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
2012-05-14 19:49:12 +00:00
|
|
|
hu.max_ncpus = hu.avg_ncpus;
|
2012-05-08 12:31:37 +00:00
|
|
|
|
|
|
|
if (config.debug_version_select) {
|
|
|
|
log_messages.printf(MSG_NORMAL,
|
2012-05-14 19:49:12 +00:00
|
|
|
"[version] host_flops: %e, \tscale: %.2f, \tprojected_flops: %e, \tpeak_flops: %e\n",
|
|
|
|
sreq.host.p_fpops, projected_flops_scale, hu.projected_flops,
|
|
|
|
hu.peak_flops
|
2012-05-08 12:31:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2012-05-14 06:54:38 +00:00
|
|
|
}
|
2012-05-08 12:31:37 +00:00
|
|
|
|
|
|
|
|
2012-05-14 06:54:38 +00:00
|
|
|
bool PLAN_CLASS_SPECS::check(
|
|
|
|
SCHEDULER_REQUEST& sreq, char* plan_class, HOST_USAGE& hu
|
|
|
|
) {
|
2012-05-08 12:31:37 +00:00
|
|
|
for (unsigned int i=0; i<classes.size(); i++) {
|
|
|
|
if (!strcmp(classes[i].name, plan_class)) {
|
|
|
|
return classes[i].check(sreq, hu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log_messages.printf(MSG_CRITICAL, "Unknown plan class: %s\n", plan_class);
|
|
|
|
return false;
|
2012-05-14 06:54:38 +00:00
|
|
|
}
|
2012-05-08 12:31:37 +00:00
|
|
|
|
2012-05-14 06:54:38 +00:00
|
|
|
int PLAN_CLASS_SPEC::parse(XML_PARSER& xp) {
|
|
|
|
char buf[256];
|
|
|
|
while (!xp.get_tag()) {
|
|
|
|
if (xp.match_tag("/plan_class")) {
|
2012-05-14 19:49:12 +00:00
|
|
|
return 0;
|
2012-05-14 06:54:38 +00:00
|
|
|
}
|
|
|
|
if (xp.parse_str("name", name, sizeof(name))) continue;
|
|
|
|
if (xp.parse_str("gpu_type", gpu_type, sizeof(gpu_type))) continue;
|
2012-05-14 19:49:12 +00:00
|
|
|
if (xp.parse_bool("cuda", cuda)) continue;
|
|
|
|
if (xp.parse_bool("cal", cal)) continue;
|
|
|
|
if (xp.parse_bool("opencl", opencl)) continue;
|
|
|
|
if (xp.parse_bool("virtualbox", virtualbox)) continue;
|
|
|
|
if (xp.parse_bool("is64bit", is64bit)) continue;
|
2012-05-14 06:54:38 +00:00
|
|
|
if (xp.parse_str("cpu_feature", buf, sizeof(buf))) {
|
|
|
|
cpu_features.push_back(" " + (string)buf + " ");
|
|
|
|
continue;
|
|
|
|
}
|
2012-05-14 19:49:12 +00:00
|
|
|
if (xp.parse_int("min_ncpus", min_ncpus)) continue;
|
2012-05-14 06:54:38 +00:00
|
|
|
if (xp.parse_int("max_threads", max_threads)) continue;
|
|
|
|
if (xp.parse_double("projected_flops_scale", projected_flops_scale)) continue;
|
|
|
|
if (xp.parse_str("os_regex", buf, sizeof(buf))) {
|
2012-05-14 19:49:12 +00:00
|
|
|
if (regcomp(&(os_regex), buf, REG_EXTENDED|REG_NOSUB) ) {
|
2012-05-14 06:54:38 +00:00
|
|
|
log_messages.printf(MSG_CRITICAL, "BAD REGEXP: %s\n", buf);
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
have_os_regex = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (xp.parse_str("project_prefs_tag", project_prefs_tag, sizeof(project_prefs_tag))) continue;
|
2012-05-14 19:49:12 +00:00
|
|
|
if (xp.parse_str("project_prefs_regex", buf, sizeof(buf))) {
|
|
|
|
if (regcomp(&(project_prefs_regex), buf, REG_EXTENDED|REG_NOSUB) ) {
|
2012-05-14 06:54:38 +00:00
|
|
|
log_messages.printf(MSG_CRITICAL, "BAD REGEXP: %s\n", buf);
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
2012-05-14 19:49:12 +00:00
|
|
|
have_project_prefs_regex = true;
|
2012-05-14 06:54:38 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (xp.parse_double("avg_ncpus", avg_ncpus)) continue;
|
2012-05-08 12:31:37 +00:00
|
|
|
|
2012-05-14 19:49:12 +00:00
|
|
|
if (xp.parse_double("cpu_frac", cpu_frac)) continue;
|
2012-05-14 06:54:38 +00:00
|
|
|
if (xp.parse_double("min_gpu_ram_mb", min_gpu_ram_mb)) continue;
|
|
|
|
if (xp.parse_double("gpu_ram_used_mb", gpu_ram_used_mb)) continue;
|
2012-05-14 19:49:12 +00:00
|
|
|
if (xp.parse_double("gpu_peak_flops_scale", gpu_peak_flops_scale)) continue;
|
2012-05-14 06:54:38 +00:00
|
|
|
if (xp.parse_double("ngpus", ngpus)) continue;
|
|
|
|
if (xp.parse_int("min_driver_version", min_driver_version)) continue;
|
|
|
|
if (xp.parse_int("max_driver_version", max_driver_version)) continue;
|
|
|
|
if (xp.parse_str("gpu_utilization_tag", gpu_utilization_tag, sizeof(gpu_utilization_tag))) continue;
|
2012-05-08 12:31:37 +00:00
|
|
|
|
2012-05-14 06:54:38 +00:00
|
|
|
if (xp.parse_int("min_nvidia_compcap", min_nvidia_compcap)) continue;
|
|
|
|
if (xp.parse_int("max_nvidia_compcap", max_nvidia_compcap)) continue;
|
2012-05-08 12:31:37 +00:00
|
|
|
|
2012-05-14 06:54:38 +00:00
|
|
|
if (xp.parse_int("min_cuda_version", min_cuda_version)) continue;
|
|
|
|
if (xp.parse_int("max_cuda_version", max_cuda_version)) continue;
|
|
|
|
|
|
|
|
if (xp.parse_int("min_opencl_version", min_opencl_version)) continue;
|
|
|
|
if (xp.parse_int("max_opencl_version", max_opencl_version)) continue;
|
|
|
|
|
|
|
|
if (xp.parse_int("min_vbox_version", min_vbox_version)) continue;
|
|
|
|
if (xp.parse_int("max_vbox_version", max_vbox_version)) continue;
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
2012-05-14 19:49:12 +00:00
|
|
|
return ERR_XML_PARSE;
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PLAN_CLASS_SPECS::parse_specs(FILE* f) {
|
|
|
|
MIOFILE mf;
|
|
|
|
XML_PARSER xp(&mf);
|
|
|
|
mf.init_file(f);
|
|
|
|
if (!xp.parse_start("plan_classes")) return ERR_XML_PARSE;
|
|
|
|
while (!xp.get_tag()) {
|
|
|
|
if (!xp.is_tag) {
|
|
|
|
fprintf(stderr, "PLAN_CLASS_SPECS::parse(): unexpected text %s\n", xp.parsed_tag);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (xp.match_tag("/plan_classes")) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (xp.match_tag("plan_class")) {
|
|
|
|
PLAN_CLASS_SPEC pc;
|
2012-05-14 19:49:12 +00:00
|
|
|
int retval = pc.parse(xp);
|
2012-05-14 06:54:38 +00:00
|
|
|
if (retval) return retval;
|
2012-05-08 12:31:37 +00:00
|
|
|
classes.push_back(pc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
2012-05-14 06:54:38 +00:00
|
|
|
}
|
2012-05-08 12:31:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
PLAN_CLASS_SPEC::PLAN_CLASS_SPEC() {
|
2012-05-14 06:54:38 +00:00
|
|
|
strcpy(name, "");
|
|
|
|
strcpy(gpu_type, "");
|
|
|
|
cuda = false;
|
|
|
|
cal = false;
|
|
|
|
opencl = false;
|
|
|
|
virtualbox = false;
|
|
|
|
is64bit = false;
|
|
|
|
min_ncpus = 0;
|
|
|
|
max_threads = 0;
|
|
|
|
projected_flops_scale = 1;
|
|
|
|
have_os_regex = false;
|
|
|
|
strcpy(project_prefs_tag, "");
|
|
|
|
avg_ncpus = 0;
|
|
|
|
|
2012-05-14 19:49:12 +00:00
|
|
|
cpu_frac = .1;
|
2012-05-14 06:54:38 +00:00
|
|
|
min_gpu_ram_mb = 0;
|
|
|
|
gpu_ram_used_mb = 0;
|
|
|
|
gpu_peak_flops_scale = 1;
|
|
|
|
ngpus = 1;
|
|
|
|
min_driver_version = 0;
|
|
|
|
max_driver_version = 0;
|
|
|
|
strcpy(gpu_utilization_tag, "");
|
2012-05-08 12:31:37 +00:00
|
|
|
|
2012-05-14 19:49:12 +00:00
|
|
|
min_nvidia_compcap = 0;
|
|
|
|
max_nvidia_compcap = 0;
|
2012-05-08 12:31:37 +00:00
|
|
|
min_cuda_version = 0;
|
|
|
|
max_cuda_version = 0;
|
|
|
|
|
|
|
|
min_opencl_version = 0;
|
2012-05-14 06:54:38 +00:00
|
|
|
max_opencl_version = 0;
|
2012-05-08 12:31:37 +00:00
|
|
|
|
2012-05-14 06:54:38 +00:00
|
|
|
min_vbox_version = 0;
|
|
|
|
max_vbox_version = 0;
|
2012-05-08 12:31:37 +00:00
|
|
|
}
|