From 7abfe400634e5cddc96ed8a3edba1d51a1927d64 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 15 Apr 2013 12:00:14 -0700 Subject: [PATCH] - scheduler: add optional element to plan_class_spec.xml. This regular expression is matched against the "host summary" string stored in host.serialnum. You can use this, e.g., to allow only particular GPU models. --- sched/plan_class_spec.cpp | 23 +++++++++++++++++++++++ sched/plan_class_spec.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/sched/plan_class_spec.cpp b/sched/plan_class_spec.cpp index 53df1c5bfc..4c6cde52dc 100644 --- a/sched/plan_class_spec.cpp +++ b/sched/plan_class_spec.cpp @@ -93,6 +93,20 @@ bool PLAN_CLASS_SPEC::check(SCHEDULER_REQUEST& sreq, HOST_USAGE& hu) { return false; } + // host summary + // + if (have_host_summary_regex + && regexec(&(host_summary_regex), g_reply->host.serialnum, 0, NULL, 0) + ) { + if (config.debug_version_select) { + log_messages.printf(MSG_NORMAL, + "[version] plan_class_spec: host summary '%s' didn't match regexp\n", + g_reply->host.serialnum + ); + } + return false; + } + // OS version // if (have_os_regex && regexec(&(os_regex), sreq.host.os_version, 0, NULL, 0)) { @@ -632,6 +646,14 @@ int PLAN_CLASS_SPEC::parse(XML_PARSER& xp) { have_os_regex = true; continue; } + if (xp.parse_str("host_summary_regex", buf, sizeof(buf))) { + if (regcomp(&(host_summary_regex), buf, REG_EXTENDED|REG_NOSUB) ) { + log_messages.printf(MSG_CRITICAL, "BAD REGEXP: %s\n", buf); + return ERR_XML_PARSE; + } + have_host_summary_regex = true; + continue; + } if (xp.parse_str("project_prefs_tag", project_prefs_tag, sizeof(project_prefs_tag))) continue; if (xp.parse_str("project_prefs_regex", buf, sizeof(buf))) { if (regcomp(&(project_prefs_regex), buf, REG_EXTENDED|REG_NOSUB) ) { @@ -710,6 +732,7 @@ PLAN_CLASS_SPEC::PLAN_CLASS_SPEC() { max_threads = 1; projected_flops_scale = 1; have_os_regex = false; + have_host_summary_regex = false; strcpy(project_prefs_tag, ""); have_project_prefs_regex = false; avg_ncpus = 0; diff --git a/sched/plan_class_spec.h b/sched/plan_class_spec.h index 3fa053a7bf..1cdfb35c81 100644 --- a/sched/plan_class_spec.h +++ b/sched/plan_class_spec.h @@ -44,6 +44,8 @@ struct PLAN_CLASS_SPEC { int min_core_client_version; int max_core_client_version; // for non-compute-intensive, or override for GPU apps + bool have_host_summary_regex; + regex_t host_summary_regex; // GPU apps //