Browse Source

change "save_history_based_model" to public, separate "starpu_perfmodel_deinit" from "starpu_perfmodel_unload_model"

HE Kun 4 years ago
parent
commit
622b37ba5d
2 changed files with 21 additions and 2 deletions
  1. 12 0
      include/starpu_perfmodel.h
  2. 9 2
      src/core/perfmodel/perfmodel_history.c

+ 12 - 0
include/starpu_perfmodel.h

@@ -312,6 +312,13 @@ struct starpu_perfmodel
 void starpu_perfmodel_init(struct starpu_perfmodel *model);
 
 /**
+   Deinitialize the \p model performance model structure. You need to call this 
+   before deallocating the structure. You will probably want to call 
+   starpu_perfmodel_unload_model() before calling this function, to save the perfmodel.
+*/   
+int starpu_perfmodel_deinit(struct starpu_perfmodel *model);
+
+/**
    Load the performance model found in the file named \p filename. \p model has to be
    completely zero, and will be filled with the information stored in the given file.
 */
@@ -333,6 +340,11 @@ int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *mo
 int starpu_perfmodel_unload_model(struct starpu_perfmodel *model);
 
 /**
+	Save the performance model in its file.
+*/
+void starpu_save_history_based_model(struct starpu_perfmodel *model);
+
+/**
   Fills \p path (supposed to be \p maxlen long) with the full path to the
   performance model file for symbol \p symbol.  This path can later on be used
   for instance with starpu_perfmodel_load_file() .

+ 9 - 2
src/core/perfmodel/perfmodel_history.c

@@ -1156,7 +1156,7 @@ void starpu_perfmodel_get_model_path(const char *symbol, char *path, size_t maxl
 }
 
 #ifndef STARPU_SIMGRID
-static void save_history_based_model(struct starpu_perfmodel *model)
+void starpu_save_history_based_model(struct starpu_perfmodel *model)
 {
 	STARPU_ASSERT(model);
 	STARPU_ASSERT(model->symbol);
@@ -1200,7 +1200,7 @@ static void _starpu_dump_registered_models(void)
 	     node  = _starpu_perfmodel_list_next(node))
 	{
 		if (node->model->is_init)
-			save_history_based_model(node->model);
+			starpu_save_history_based_model(node->model);
 	}
 
 	STARPU_PTHREAD_RWLOCK_UNLOCK(&registered_models_rwlock);
@@ -1507,6 +1507,13 @@ int starpu_perfmodel_unload_model(struct starpu_perfmodel *model)
 		model->symbol = NULL;
 	}
 
+	starpu_perfmodel_deinit(model);
+
+	return 0;
+}
+
+int starpu_perfmodel_deinit(struct starpu_perfmodel *model){
+
 	_starpu_deinitialize_performance_model(model);
 	free(model->state);
 	model->state = NULL;