Browse Source

Merge @ 9052:9065

Marc Sergent 12 years ago
parent
commit
335d09eb10

+ 5 - 0
ChangeLog

@@ -14,6 +14,11 @@
 #
 # See the GNU Lesser General Public License in COPYING.LGPL for more details.
 
+StarPU 1.2.0 (svn revision xxxx)
+==============================================
+
+New features:
+
 StarPU 1.1.0 (svn revision xxxx)
 ==============================================
 

+ 1 - 1
configure.ac

@@ -16,7 +16,7 @@
 #
 # See the GNU Lesser General Public License in COPYING.LGPL for more details.
 
-AC_INIT([StarPU], [1.1.0], [starpu-devel@lists.gforge.inria.fr],
+AC_INIT([StarPU], [1.2.0], [starpu-devel@lists.gforge.inria.fr],
   [starpu], [http://runtime.bordeaux.inria.fr/StarPU/])
 AC_CONFIG_SRCDIR(include/starpu.h)
 AC_CONFIG_AUX_DIR([build-aux])

+ 4 - 0
doc/chapters/basic-api.texi

@@ -2286,6 +2286,10 @@ regression.
 loads a given performance model. The @var{model} structure has to be completely zero, and will be filled with the information saved in @code{$STARPU_HOME/.starpu}.
 @end deftypefun
 
+@deftypefun int starpu_perfmodel_unload_model ({struct starpu_perfmodel} *@var{model})
+unloads the given model which has been previously loaded through the function @code{starpu_perfmodel_load_symbol}
+@end deftypefun
+
 @deftypefun void starpu_perfmodel_debugfilepath ({struct starpu_perfmodel} *@var{model}, {enum starpu_perf_archtype} @var{arch}, char *@var{path}, size_t @var{maxlen}, unsigned nimpl)
 returns the path to the debugging information for the performance model.
 @end deftypefun

+ 21 - 20
examples/scheduler/dummy_sched.c

@@ -68,32 +68,33 @@ static int push_task_dummy(struct starpu_task *task)
 
 	/* lock all workers when pushing tasks on a list where all
 	   of them would pop for tasks */
-	unsigned worker = 0;
+        pthread_mutex_lock(&data->policy_mutex);
+
+	starpu_task_list_push_front(&data->sched_list, task);
+
+	_starpu_push_task_end(task);
+	pthread_mutex_unlock(&data->policy_mutex);
+
+
+        /*if there are no tasks block */
+        /* wake people waiting for a task */
+        unsigned worker = 0;
 	struct starpu_sched_ctx_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
-	struct starpu_sched_ctx_iterator it;
-	if(workers->init_iterator)
+
+        struct starpu_sched_ctx_iterator it;
+        if(workers->init_iterator)
 		workers->init_iterator(workers, &it);
 
 	while(workers->has_next(workers, &it))
-	{
-		worker = workers->get_next(workers, &it);
+        {
+                worker = workers->get_next(workers, &it);
 		pthread_mutex_t *sched_mutex;
-		pthread_cond_t *sched_cond;
-		starpu_worker_get_sched_condition(worker, &sched_mutex, &sched_cond);
+                pthread_cond_t *sched_cond;
+                starpu_worker_get_sched_condition(worker, &sched_mutex, &sched_cond);
 		pthread_mutex_lock(sched_mutex);
-	}
-
-	starpu_task_list_push_front(&data->sched_list, task);
-
-	while(workers->has_next(workers, &it))
-	{
-		worker = workers->get_next(workers, &it);
-		pthread_mutex_t *sched_mutex;
-		pthread_cond_t *sched_cond;
-		starpu_worker_get_sched_condition(worker, &sched_mutex, &sched_cond);
-		pthread_cond_signal(sched_cond);
-		pthread_mutex_unlock(sched_mutex);
-	}
+                pthread_cond_signal(sched_cond);
+                pthread_mutex_unlock(sched_mutex);
+        }
 
 	return 0;
 }

+ 2 - 0
include/starpu_perfmodel.h

@@ -201,6 +201,8 @@ enum starpu_perf_archtype starpu_worker_get_perf_archtype(int workerid);
 /* This function is intended to be used by external tools that should read the
  * performance model files */
 int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model);
+int starpu_perfmodel_unload_model(struct starpu_perfmodel *model);
+
 void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, enum starpu_perf_archtype arch, char *path, size_t maxlen, unsigned nimpl);
 void starpu_perfmodel_get_arch_name(enum starpu_perf_archtype arch, char *archname, size_t maxlen, unsigned nimpl);
 

+ 2 - 1
mpi/tests/mpi_reduction.c

@@ -94,7 +94,8 @@ int main(int argc, char **argv)
 			}
 		}
 	}
-	if (my_rank == 0) {
+	if (my_rank == 0)
+	{
 		dot = 14;
 		sum = (nb_elements * (nb_elements + 1)) / 2;
 		sum *= loops;

+ 43 - 30
src/core/perfmodel/perfmodel_history.c

@@ -699,6 +699,41 @@ void _starpu_initialize_registered_performance_models(void)
 	_STARPU_PTHREAD_RWLOCK_INIT(&registered_models_rwlock, NULL);
 }
 
+void _starpu_deinitialize_performance_model(struct starpu_perfmodel *model)
+{
+	unsigned arch;
+	unsigned nimpl;
+
+	for (arch = 0; arch < STARPU_NARCH_VARIATIONS; arch++)
+	{
+		for (nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
+		{
+			struct starpu_perfmodel_per_arch *archmodel = &model->per_arch[arch][nimpl];
+			struct starpu_perfmodel_history_list *list, *plist;
+			struct starpu_perfmodel_history_table *entry, *tmp;
+
+			HASH_ITER(hh, archmodel->history, entry, tmp)
+			{
+				HASH_DEL(archmodel->history, entry);
+				free(entry);
+			}
+			archmodel->history = NULL;
+
+			list = archmodel->list;
+			while (list)
+			{
+				free(list->entry);
+				plist = list;
+				list = list->next;
+				free(plist);
+			}
+			archmodel->list = NULL;
+		}
+	}
+
+	model->is_loaded = 0;
+}
+
 void _starpu_deinitialize_registered_performance_models(void)
 {
 	if (_starpu_get_calibrate_flag())
@@ -714,38 +749,9 @@ void _starpu_deinitialize_registered_performance_models(void)
 	while (node)
 	{
 		struct starpu_perfmodel *model = node->model;
-		unsigned arch;
-		unsigned nimpl;
 
 		_STARPU_PTHREAD_RWLOCK_WRLOCK(&model->model_rwlock);
-		for (arch = 0; arch < STARPU_NARCH_VARIATIONS; arch++)
-		{
-			for (nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
-			{
-				struct starpu_perfmodel_per_arch *archmodel = &model->per_arch[arch][nimpl];
-				struct starpu_perfmodel_history_list *list, *plist;
-				struct starpu_perfmodel_history_table *entry, *tmp;
-
-				HASH_ITER(hh, archmodel->history, entry, tmp)
-				{
-					HASH_DEL(archmodel->history, entry);
-					free(entry);
-				}
-				archmodel->history = NULL;
-
-				list = archmodel->list;
-				while (list)
-				{
-					free(list->entry);
-					plist = list;
-					list = list->next;
-					free(plist);
-				}
-				archmodel->list = NULL;
-			}
-		}
-
-		model->is_loaded = 0;
+		_starpu_deinitialize_performance_model(model);
 		_STARPU_PTHREAD_RWLOCK_UNLOCK(&model->model_rwlock);
 
 		pnode = node;
@@ -984,6 +990,13 @@ int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *mo
 	return 0;
 }
 
+int starpu_perfmodel_unload_model(struct starpu_perfmodel *model)
+{
+	free((char *)model->symbol);
+	_starpu_deinitialize_performance_model(model);
+	return 0;
+}
+
 void starpu_perfmodel_get_arch_name(enum starpu_perf_archtype arch, char *archname, size_t maxlen,unsigned nimpl)
 {
 	if (arch < STARPU_CUDA_DEFAULT)

+ 3 - 3
src/datawizard/user_interactions.c

@@ -323,11 +323,11 @@ void starpu_data_release_on_node(starpu_data_handle_t handle, unsigned node)
 {
 	STARPU_ASSERT(handle);
 
-	/* The application can now release the rw-lock */
-	_starpu_release_data_on_node(handle, 0, &handle->per_node[node]);
-
 	/* In case there are some implicit dependencies, unlock the "post sync" tasks */
 	_starpu_unlock_post_sync_tasks(handle);
+
+	/* The application can now release the rw-lock */
+	_starpu_release_data_on_node(handle, 0, &handle->per_node[node]);
 }
 
 void starpu_data_release(starpu_data_handle_t handle)

+ 8 - 0
tests/perfmodels/valid_model.c

@@ -86,6 +86,7 @@ static int submit(struct starpu_codelet *codelet, struct starpu_perfmodel *model
 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
         starpu_data_unregister(handle);
+	starpu_perfmodel_unload_model(&lmodel);
 	starpu_shutdown(); // To force dumping perf models on disk
 
 	ret = starpu_perfmodel_load_symbol(codelet->model->symbol, &lmodel);
@@ -99,6 +100,13 @@ static int submit(struct starpu_codelet *codelet, struct starpu_perfmodel *model
 	for (archid = 0; archid < STARPU_NARCH_VARIATIONS; archid++)
 		new_nsamples += lmodel.per_arch[archid][0].regression.nsample;
 
+	ret = starpu_perfmodel_unload_model(&lmodel);
+	if (ret == 1)
+	{
+		FPRINTF(stderr, "The performance model for the symbol <%s> could not be UNloaded\n", codelet->model->symbol);
+		return 1;
+	}
+
 	if (old_nsamples + nloops == new_nsamples)
 	{
 		FPRINTF(stderr, "Sampling for <%s> OK %d + %d == %d\n", codelet->model->symbol, old_nsamples, nloops, new_nsamples);