Преглед на файлове

Performance models files are now stored in a directory whose name
include the version of the performance model format. The version
number is also written in the file itself.

When updating the format, the internal variable
_STARPU_PERFMODEL_VERSION should be updated. It is then possible
to switch easily between differents versions of StarPU having
different performance model formats.

Nathalie Furmento преди 12 години
родител
ревизия
996e85965e
променени са 4 файла, в които са добавени 33 реда и са изтрити 3 реда
  1. 7 0
      ChangeLog
  2. 3 2
      src/core/perfmodel/perfmodel.c
  3. 11 0
      src/core/perfmodel/perfmodel.h
  4. 12 1
      src/core/perfmodel/perfmodel_history.c

+ 7 - 0
ChangeLog

@@ -40,6 +40,13 @@ New features:
     handle (sequential consistency will be enabled or disabled based
     on the value of the function parameter and the value of the
     sequential consistency defined for the given data)
+  * Performance models files are now stored in a directory whose name
+    include the version of the performance model format. The version
+    number is also written in the file itself.
+    When updating the format, the internal variable
+    _STARPU_PERFMODEL_VERSION should be updated. It is then possible
+    to switch easily between differents versions of StarPU having
+    different performance model formats.
 
 Small features:
   * Add cl_arg_free field to enable automatic free(cl_arg) on task

+ 3 - 2
src/core/perfmodel/perfmodel.c

@@ -426,8 +426,9 @@ void _starpu_get_perf_model_dir(char *path, size_t maxlen)
 
 void _starpu_get_perf_model_dir_codelets(char *path, size_t maxlen)
 {
-	_starpu_get_perf_model_dir(path, maxlen);
-	strncat(path, "/codelets/", maxlen);
+	char perf_model_path[256];
+	_starpu_get_perf_model_dir(perf_model_path, maxlen);
+	snprintf(path, maxlen, "%s/codelets/%d/", perf_model_path, _STARPU_PERFMODEL_VERSION);
 }
 
 void _starpu_get_perf_model_dir_bus(char *path, size_t maxlen)

+ 11 - 0
src/core/perfmodel/perfmodel.h

@@ -29,6 +29,17 @@ extern "C"
 {
 #endif
 
+/**
+ * Performance models files are stored in a directory whose name
+ * include the version of the performance model format. The version
+ * number is also written in the file itself.
+ * When updating the format, the variable _STARPU_PERFMODEL_VERSION
+ * should be updated. It is then possible to switch easily between
+ * differents versions of StarPU having different performance model
+ * formats.
+ */
+#define _STARPU_PERFMODEL_VERSION 42
+
 struct _starpu_perfmodel_list
 {
 	struct _starpu_perfmodel_list *next;

+ 12 - 1
src/core/perfmodel/perfmodel_history.c

@@ -295,6 +295,13 @@ static void parse_arch(FILE *f, struct starpu_perfmodel *model, unsigned scan_hi
 static void parse_device(FILE *f, struct starpu_perfmodel *model, unsigned scan_history, unsigned * arch, unsigned archmax)
 {
 	unsigned maxncore, ncore, ret;
+	int version;
+
+	/* Parsing performance model version */
+	_starpu_drop_comments(f);
+	ret = fscanf(f, "%d\n", &version);
+	STARPU_ASSERT_MSG(version == _STARPU_PERFMODEL_VERSION, "Incorrect performance model file with a model version %d not being the current model version (%d)\n",
+			  version, _STARPU_PERFMODEL_VERSION);
 
 	/* Parsing maximun number of worker for this device */
 	_starpu_drop_comments(f);
@@ -419,6 +426,10 @@ static void dump_model_file(FILE *f, struct starpu_perfmodel *model)
 	unsigned nimpl;
 	unsigned idx = 0;
 
+	fprintf(f, "##################\n");
+	fprintf(f, "# Performance Model Version\n");
+	fprintf(f, "%d\n\n", _STARPU_PERFMODEL_VERSION);
+
 	/* Finding the number of archs to write for each kind of device */
 	for (arch = 0; arch < STARPU_NARCH_VARIATIONS; arch++)
 	{
@@ -888,7 +899,7 @@ void _starpu_load_history_based_model(struct starpu_perfmodel *model, unsigned s
 		else
 		{
 			/* We load the available file */
-			_STARPU_DEBUG("File exists\n");
+                        _STARPU_DEBUG("File exists\n");
 			FILE *f;
 			f = fopen(path, "r");
 			STARPU_ASSERT(f);