aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@83718e91-0e4f-0410-abf4-91180603181f>2007-11-12 12:48:21 +0000
committertradke <tradke@83718e91-0e4f-0410-abf4-91180603181f>2007-11-12 12:48:21 +0000
commit1644c4794c9dad110d83fa8d4adb2fc50bba7a1c (patch)
treedaa3ce1a2719d4caebd4463246661aaba085496d
parent3313bb4636910f044a229ebafd6fa7a735a4dda4 (diff)
added steerable parameters Formaline::steered_parameters_log_exclusion_list and
Formaline::nr_of_parameter_changes_to_be_logged for users to specify which parameters should be logged and how often (see discussion thread http://lists.carpetcode.org/archives/developers/2007-November/002121.html) git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/Formaline/trunk@144 83718e91-0e4f-0410-abf4-91180603181f
-rw-r--r--param.ccl23
-rw-r--r--src/rdf_publisher.cc48
2 files changed, 62 insertions, 9 deletions
diff --git a/param.ccl b/param.ccl
index 8746ea2..eb1a28c 100644
--- a/param.ccl
+++ b/param.ccl
@@ -9,6 +9,14 @@ BOOLEAN verbose "Produce screen output" STEERABLE=always
{
} no
+
+
+# Parameters for collecting metadata
+
+BOOLEAN collect_metadata "Collect metadata and output it in various ways" STEERABLE=always
+{
+} yes
+
REAL update_interval "Update interval for the meta information (in seconds)" STEERABLE=always
{
0:* :: ""
@@ -30,14 +38,17 @@ INT metadata_lifetime "Lifetime of meta information sent to a server (in hours)"
1:* :: "a positive value to limit the lifetime to so many hours"
} 100
-
-
-# Parameters for collecting metadata
-
-BOOLEAN collect_metadata "Collect metadata and output it in various ways" STEERABLE=always
+STRING steered_parameters_log_exclusion_list "Parameters for which runtime changes should not be logged" STEERABLE=always
{
-} yes
+ "" :: "whitespace-separated list of parameter names"
+} "CarpetRegrid::coordinates"
+INT nr_of_parameter_changes_to_be_logged "number of parameter changes to be logged" STEERABLE=always
+{
+ -1: :: "log all changes"
+ 0: :: "no logs please"
+ 1:*:: "log this many changes for a given parameter, then stop logging"
+} -1
# Parameters for creating files containing the build and job ids
diff --git a/src/rdf_publisher.cc b/src/rdf_publisher.cc
index fd17707..3cbbf40 100644
--- a/src/rdf_publisher.cc
+++ b/src/rdf_publisher.cc
@@ -1,8 +1,12 @@
// $Header$
+#include <algorithm>
#include <cassert>
-#include <string>
+#include <cctype>
#include <iostream>
+#include <map>
+#include <set>
+#include <string>
#include "util_Table.h"
#include "cctk.h"
@@ -207,16 +211,54 @@ static CCTK_INT PublishTableAsRDF (CCTK_POINTER_TO_CONST cctkGH,
}
-static void ParameterSetNotify (void *unused,
+static void ParameterSetNotify (void *,
const char *thorn,
const char *parameter,
const char *new_value)
{
- unused = &unused;
+ DECLARE_CCTK_PARAMETERS;
+
+ // should parameter changes be logged at all ?
+ if (nr_of_parameter_changes_to_be_logged == 0) return;
+
+ // reparse the "steered_parameters_log_exclusion_list" if it has changed
+ int timesSet =
+ CCTK_ParameterQueryTimesSet("steered_parameters_log_exclusion_list",
+ CCTK_THORNSTRING);
+ static int lastTimesSet = -1;
+ static std::set<std::string> exclusionList;
+ if (lastTimesSet != timesSet) {
+ exclusionList.clear();
+ std::string parseString(steered_parameters_log_exclusion_list);
+ const std::string whitespaces(" \t\n");
+ while (1) {
+ std::string::size_type start = parseString.find_first_not_of(whitespaces);
+ if (start == std::string::npos) break;
+ std::string::size_type end = parseString.find_first_of(whitespaces,start);
+ if (end == std::string::npos) end = parseString.length();
+ std::string parameter(parseString, start, end - start);
+ transform(parameter.begin(), parameter.end(), parameter.begin(), tolower);
+ exclusionList.insert(parameter);
+ parseString.erase(0, end);
+ }
+ lastTimesSet = timesSet;
+ }
+
const char *name = "Set Parameter";
std::string key(thorn); key.append ("::"); key.append (parameter);
+ // // do not log steering events for parameters in the log exclusion list
+ std::string lcKey(key);
+ transform(lcKey.begin(), lcKey.end(), lcKey.begin(), tolower);
+ if (exclusionList.find(lcKey) != exclusionList.end()) return;
+
+ // check if the maximum number of parameter change logs has been reached
+ static std::map<std::string, int> logList;
+ logList[lcKey]++;
+ if (nr_of_parameter_changes_to_be_logged > 0 and
+ logList[lcKey] >= nr_of_parameter_changes_to_be_logged) return;
+
int type;
const void* data = CCTK_ParameterGet (parameter, thorn, &type);