浏览代码

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
     handle (sequential consistency will be enabled or disabled based
     on the value of the function parameter and the value of the
     on the value of the function parameter and the value of the
     sequential consistency defined for the given data)
     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:
 Small features:
   * Add cl_arg_free field to enable automatic free(cl_arg) on task
   * 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)
 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)
 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
 #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
 {
 {
 	struct _starpu_perfmodel_list *next;
 	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)
 static void parse_device(FILE *f, struct starpu_perfmodel *model, unsigned scan_history, unsigned * arch, unsigned archmax)
 {
 {
 	unsigned maxncore, ncore, ret;
 	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 */
 	/* Parsing maximun number of worker for this device */
 	_starpu_drop_comments(f);
 	_starpu_drop_comments(f);
@@ -419,6 +426,10 @@ static void dump_model_file(FILE *f, struct starpu_perfmodel *model)
 	unsigned nimpl;
 	unsigned nimpl;
 	unsigned idx = 0;
 	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 */
 	/* Finding the number of archs to write for each kind of device */
 	for (arch = 0; arch < STARPU_NARCH_VARIATIONS; arch++)
 	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
 		else
 		{
 		{
 			/* We load the available file */
 			/* We load the available file */
-			_STARPU_DEBUG("File exists\n");
+                        _STARPU_DEBUG("File exists\n");
 			FILE *f;
 			FILE *f;
 			f = fopen(path, "r");
 			f = fopen(path, "r");
 			STARPU_ASSERT(f);
 			STARPU_ASSERT(f);