瀏覽代碼

merge src

Andra Hugo 13 年之前
父節點
當前提交
5d35bc5fe5

+ 36 - 26
src/Makefile.am

@@ -1,7 +1,7 @@
 # StarPU --- Runtime system for heterogeneous multicore architectures.
 #
-# Copyright (C) 2009, 2010, 2011  Université de Bordeaux 1
-# Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+# Copyright (C) 2009-2012  Université de Bordeaux 1
+# Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
 # Copyright (C) 2011  INRIA
 #
 # StarPU is free software; you can redistribute it and/or modify
@@ -28,30 +28,31 @@ if STARPU_HAVE_WINDOWS
 LC_MESSAGES=C
 export LC_MESSAGES
 
-ldflags += -Xlinker --output-def -Xlinker .libs/libstarpu.def
+ldflags += -Xlinker --output-def -Xlinker .libs/libstarpu-@STARPU_EFFECTIVE_VERSION@.def
 
 if STARPU_HAVE_MS_LIB
-.libs/libstarpu.lib: libstarpu.la dolib
-	./dolib "$(STARPU_MS_LIB)" X86 .libs/libstarpu.def libstarpu-0 .libs/libstarpu.lib
-all-local: .libs/libstarpu.lib
+.libs/libstarpu-@STARPU_EFFECTIVE_VERSION@.lib: libstarpu-@STARPU_EFFECTIVE_VERSION@.la dolib
+	./dolib "$(STARPU_MS_LIB)" $(STARPU_MS_LIB_ARCH) .libs/libstarpu-@STARPU_EFFECTIVE_VERSION@.def libstarpu-0 .libs/libstarpu-@STARPU_EFFECTIVE_VERSION@.lib
+all-local: .libs/libstarpu-@STARPU_EFFECTIVE_VERSION@.lib
 endif STARPU_HAVE_MS_LIB
 
 install-exec-hook:
-	$(INSTALL) .libs/libstarpu.def $(DESTDIR)$(libdir)
+	$(INSTALL) .libs/libstarpu-@STARPU_EFFECTIVE_VERSION@.def $(DESTDIR)$(libdir)
 if STARPU_HAVE_MS_LIB
-	$(INSTALL) .libs/libstarpu.lib $(DESTDIR)$(libdir)
-	$(INSTALL) .libs/libstarpu.exp $(DESTDIR)$(libdir)
+	$(INSTALL) .libs/libstarpu-@STARPU_EFFECTIVE_VERSION@.lib $(DESTDIR)$(libdir)
+	$(INSTALL) .libs/libstarpu-@STARPU_EFFECTIVE_VERSION@.exp $(DESTDIR)$(libdir)
 endif STARPU_HAVE_MS_LIB
 
 endif STARPU_HAVE_WINDOWS
 
-lib_LTLIBRARIES = libstarpu.la
+lib_LTLIBRARIES = libstarpu-@STARPU_EFFECTIVE_VERSION@.la
 
-libstarpu_la_CPPFLAGS = -I$(top_srcdir)/include/
+libstarpu_@STARPU_EFFECTIVE_VERSION@_la_CPPFLAGS = -I$(top_srcdir)/include/ -DBUILDING_STARPU
 
-libstarpu_la_CFLAGS = $(GLOBAL_AM_CFLAGS) $(HWLOC_CFLAGS) $(STARPU_CUDA_CPPFLAGS) $(STARPU_OPENCL_CPPFLAGS) $(FXT_CFLAGS)
-libstarpu_la_LIBADD = -lm $(HWLOC_LIBS) $(STARPU_CUDA_LDFLAGS) $(STARPU_OPENCL_LDFLAGS) $(FXT_LIBS) $(STARPU_GLPK_LDFLAGS)
-libstarpu_la_LDFLAGS = $(ldflags) -version-number 0:0:0 -no-undefined
+libstarpu_@STARPU_EFFECTIVE_VERSION@_la_CFLAGS = $(GLOBAL_AM_CFLAGS) $(HWLOC_CFLAGS) $(STARPU_CUDA_CPPFLAGS) $(STARPU_OPENCL_CPPFLAGS) $(FXT_CFLAGS)
+libstarpu_@STARPU_EFFECTIVE_VERSION@_la_LIBADD = -lm $(HWLOC_LIBS) $(STARPU_CUDA_LDFLAGS) $(STARPU_OPENCL_LDFLAGS) $(FXT_LIBS) $(STARPU_GLPK_LDFLAGS)
+libstarpu_@STARPU_EFFECTIVE_VERSION@_la_LDFLAGS = $(ldflags) -no-undefined									\
+  -version-info $(LIBSTARPU_INTERFACE_CURRENT):$(LIBSTARPU_INTERFACE_REVISION):$(LIBSTARPU_INTERFACE_AGE)
 
 noinst_HEADERS = 						\
 	core/dependencies/data_concurrency.h			\
@@ -69,6 +70,10 @@ noinst_HEADERS = 						\
 	core/topology.h						\
 	core/debug.h						\
 	core/errorcheck.h					\
+	core/combined_workers.h					\
+	core/parallel_task.h					\
+	core/task_bundle.h					\
+	sched_policies/detect_combined_workers.h		\
 	sched_policies/fifo_queues.h				\
 	sched_policies/deque_queues.h				\
 	sched_policies/stack_queues.h				\
@@ -85,7 +90,6 @@ noinst_HEADERS = 						\
 	datawizard/memory_nodes.h				\
 	datawizard/interfaces/data_interface.h			\
 	common/barrier.h					\
-	common/hash.h						\
 	common/timing.h						\
 	common/htable32.h					\
 	common/list.h						\
@@ -108,11 +112,13 @@ noinst_HEADERS = 						\
 	profiling/bound.h					\
 	profiling/profiling.h					\
 	util/starpu_insert_task_utils.h				\
+	util/starpu_data_cpy.h					\
 	starpu_parameters.h					\
-	top/starputop_message_queue.h				\
-	top/starputop_connection.h
+	top/starpu_top_message_queue.h				\
+	top/starpu_top_connection.h				\
+	top/starpu_top_core.h
 
-libstarpu_la_SOURCES = 						\
+libstarpu_@STARPU_EFFECTIVE_VERSION@_la_SOURCES = 						\
 	common/barrier.c					\
 	common/barrier_counter.c					\
 	common/hash.c 						\
@@ -178,6 +184,7 @@ libstarpu_la_SOURCES = 						\
 	datawizard/interfaces/vector_filters.c			\
 	datawizard/interfaces/variable_interface.c		\
 	datawizard/interfaces/void_interface.c			\
+	datawizard/interfaces/multiformat_interface.c           \
 	util/malloc.c						\
 	util/execute_on_all.c					\
 	util/starpu_create_sync_task.c				\
@@ -197,9 +204,9 @@ libstarpu_la_SOURCES = 						\
 	profiling/bound.c					\
 	profiling/profiling_helpers.c				\
 	top/starpu_top.c					\
-	top/starputop_task.c					\
-	top/starputop_message_queue.c				\
-	top/starputop_connection.c				\
+	top/starpu_top_task.c					\
+	top/starpu_top_message_queue.c				\
+	top/starpu_top_connection.c
 	worker_collection/worker_list.c				
 #	sched_policies/eager_central_policy.c			
 #	sched_policies/eager_central_priority_policy.c		
@@ -210,18 +217,21 @@ libstarpu_la_SOURCES = 						\
 #	sched_policies/parallel_greedy.c			
 
 if STARPU_USE_CPU
-libstarpu_la_SOURCES += drivers/cpu/driver_cpu.c
+libstarpu_@STARPU_EFFECTIVE_VERSION@_la_SOURCES += drivers/cpu/driver_cpu.c
 endif
 
 if STARPU_USE_CUDA
-libstarpu_la_SOURCES += drivers/cuda/driver_cuda.c
+libstarpu_@STARPU_EFFECTIVE_VERSION@_la_SOURCES += drivers/cuda/driver_cuda.c
 endif
 
 if STARPU_USE_GORDON
-libstarpu_la_SOURCES += drivers/gordon/driver_gordon.c
+libstarpu_@STARPU_EFFECTIVE_VERSION@_la_SOURCES += drivers/gordon/driver_gordon.c
 endif
 
 if STARPU_USE_OPENCL
-libstarpu_la_SOURCES += drivers/opencl/driver_opencl.c
-libstarpu_la_SOURCES += drivers/opencl/driver_opencl_utils.c
+libstarpu_@STARPU_EFFECTIVE_VERSION@_la_SOURCES += drivers/opencl/driver_opencl.c
+libstarpu_@STARPU_EFFECTIVE_VERSION@_la_SOURCES += drivers/opencl/driver_opencl_utils.c
 endif
+
+showcheck:
+	-cat /dev/null

+ 22 - 19
src/dolib.c

@@ -20,27 +20,30 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-int main(int argc, char *argv[]) {
-  char *prog, *arch, *def, *name, *lib;
-  char s[1024];
+int main(int argc, char *argv[])
+{
+	char *prog, *arch, *def, *name, *lib;
+	char s[1024];
 
-  if (argc != 6) {
-    fprintf(stderr,"bad number of arguments");
-    exit(EXIT_FAILURE);
-  }
+	if (argc != 6)
+	{
+		fprintf(stderr,"bad number of arguments");
+		exit(EXIT_FAILURE);
+	}
 
-  prog = argv[1];
-  arch = argv[2];
-  def = argv[3];
-  name = argv[4];
-  lib = argv[5];
+	prog = argv[1];
+	arch = argv[2];
+	def = argv[3];
+	name = argv[4];
+	lib = argv[5];
 
-  snprintf(s, sizeof(s), "\"%s\" /machine:%s /def:%s /name:%s /out:%s",
-      prog, arch, def, name, lib);
-  if (system(s)) {
-    fprintf(stderr, "%s failed\n", s);
-    exit(EXIT_FAILURE);
-  }
+	snprintf(s, sizeof(s), "\"%s\" /machine:%s /def:%s /name:%s /out:%s",
+		 prog, arch, def, name, lib);
+	if (system(s))
+	{
+		fprintf(stderr, "%s failed\n", s);
+		exit(EXIT_FAILURE);
+	}
 
-  exit(EXIT_SUCCESS);
+	exit(EXIT_SUCCESS);
 }

+ 216 - 124
src/profiling/bound.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  * Copyright (C) 2010, 2011  Université de Bordeaux 1
  * Copyright (C) 2011  Télécom-SudParis
  *
@@ -45,9 +45,10 @@
  * - the total numer of tasks of a given kind is equal to the number run by the
  *   application.
  */
-struct bound_task_pool {
+struct bound_task_pool
+{
 	/* Which codelet has been executed */
-	struct starpu_codelet_t *cl;
+	struct starpu_codelet *cl;
 	/* Task footprint key */
 	uint32_t footprint;
 	/* Number of tasks of this kind */
@@ -77,14 +78,15 @@ struct bound_task_pool {
 /* Note: only task-task, implicit data dependencies or task-tag dependencies
  * are taken into account. Tags released in a callback or something like this
  * is not taken into account, only tags associated with a task are. */
-struct bound_task {
+struct bound_task
+{
 	/* Unique ID */
 	unsigned long id;
 	/* Tag ID, if any */
 	starpu_tag_t tag_id;
 	int use_tag;
 	/* Which codelet has been executed */
-	struct starpu_codelet_t *cl;
+	struct starpu_codelet *cl;
 	/* Task footprint key */
 	uint32_t footprint;
 	/* Task priority */
@@ -100,7 +102,8 @@ struct bound_task {
 	struct bound_task *next;
 };
 
-struct bound_tag_dep {
+struct bound_tag_dep
+{
 	starpu_tag_t tag;
 	starpu_tag_t dep_tag;
 	struct bound_tag_dep *next;
@@ -121,7 +124,7 @@ void starpu_bound_start(int deps, int prio)
 	struct bound_task *t;
 	struct bound_tag_dep *td;
 
-	PTHREAD_MUTEX_LOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 
 	tp = task_pools;
 	task_pools = NULL;
@@ -137,7 +140,7 @@ void starpu_bound_start(int deps, int prio)
 	recorddeps = deps;
 	recordprio = prio;
 
-	PTHREAD_MUTEX_UNLOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 
 	for ( ; tp; tp = tp->next)
 		free(tp);
@@ -149,7 +152,7 @@ void starpu_bound_start(int deps, int prio)
 		free(td);
 }
 
-static int good_job(starpu_job_t j)
+static int good_job(struct _starpu_job *j)
 {
 	/* No codelet, nothing to measure */
 	if (j->exclude_from_dag)
@@ -165,7 +168,7 @@ static int good_job(starpu_job_t j)
 	return 1;
 }
 
-static void new_task(starpu_job_t j)
+static void new_task(struct _starpu_job *j)
 {
 	struct bound_task *t;
 
@@ -178,7 +181,7 @@ static void new_task(starpu_job_t j)
 	t->tag_id = j->task->tag_id;
 	t->use_tag = j->task->use_tag;
 	t->cl = j->task->cl;
-	t->footprint = _starpu_compute_buffers_footprint(j);
+	t->footprint = _starpu_compute_buffers_footprint(NULL, STARPU_CPU_DEFAULT, 0, j);
 	t->priority = j->task->priority;
 	t->deps = NULL;
 	t->depsn = 0;
@@ -187,7 +190,7 @@ static void new_task(starpu_job_t j)
 	tasks = t;
 }
 
-void _starpu_bound_record(starpu_job_t j)
+void _starpu_bound_record(struct _starpu_job *j)
 {
 	if (!_starpu_bound_recording)
 		return;
@@ -195,19 +198,23 @@ void _starpu_bound_record(starpu_job_t j)
 	if (!good_job(j))
 		return;
 
-	PTHREAD_MUTEX_LOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	/* Re-check, this time with mutex held */
-	if (!_starpu_bound_recording) {
-		PTHREAD_MUTEX_UNLOCK(&mutex);
+	if (!_starpu_bound_recording)
+	{
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 		return;
 	}
 
-	if (recorddeps) {
+	if (recorddeps)
+	{
 		new_task(j);
-	} else {
+	}
+	else
+	{
 		struct bound_task_pool *tp;
 
-		_starpu_compute_buffers_footprint(j);
+		_starpu_compute_buffers_footprint(NULL, STARPU_CPU_DEFAULT, 0, j);
 
 		if (last && last->cl == j->task->cl && last->footprint == j->footprint)
 			tp = last;
@@ -216,7 +223,8 @@ void _starpu_bound_record(starpu_job_t j)
 				if (tp->cl == j->task->cl && tp->footprint == j->footprint)
 					break;
 
-		if (!tp) {
+		if (!tp)
+		{
 			tp = (struct bound_task_pool *) malloc(sizeof(*tp));
 			tp->cl = j->task->cl;
 			tp->footprint = j->footprint;
@@ -229,7 +237,7 @@ void _starpu_bound_record(starpu_job_t j)
 		tp->n++;
 	}
 
-	PTHREAD_MUTEX_UNLOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 }
 
 void _starpu_bound_tag_dep(starpu_tag_t id, starpu_tag_t dep_id)
@@ -239,10 +247,11 @@ void _starpu_bound_tag_dep(starpu_tag_t id, starpu_tag_t dep_id)
 	if (!_starpu_bound_recording || !recorddeps)
 		return;
 
-	PTHREAD_MUTEX_LOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	/* Re-check, this time with mutex held */
-	if (!_starpu_bound_recording || !recorddeps) {
-		PTHREAD_MUTEX_UNLOCK(&mutex);
+	if (!_starpu_bound_recording || !recorddeps)
+	{
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 		return;
 	}
 
@@ -251,10 +260,10 @@ void _starpu_bound_tag_dep(starpu_tag_t id, starpu_tag_t dep_id)
 	td->dep_tag = dep_id;
 	td->next = tag_deps;
 	tag_deps = td;
-	PTHREAD_MUTEX_UNLOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 }
 
-void _starpu_bound_task_dep(starpu_job_t j, starpu_job_t dep_j)
+void _starpu_bound_task_dep(struct _starpu_job *j, struct _starpu_job *dep_j)
 {
 	struct bound_task *t;
 
@@ -264,10 +273,11 @@ void _starpu_bound_task_dep(starpu_job_t j, starpu_job_t dep_j)
 	if (!good_job(j) || !good_job(dep_j))
 		return;
 
-	PTHREAD_MUTEX_LOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	/* Re-check, this time with mutex held */
-	if (!_starpu_bound_recording || !recorddeps) {
-		PTHREAD_MUTEX_UNLOCK(&mutex);
+	if (!_starpu_bound_recording || !recorddeps)
+	{
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 		return;
 	}
 
@@ -276,7 +286,7 @@ void _starpu_bound_task_dep(starpu_job_t j, starpu_job_t dep_j)
 	t = j->bound_task;
 	t->deps = (struct bound_task **) realloc(t->deps, ++t->depsn * sizeof(t->deps[0]));
 	t->deps[t->depsn-1] = dep_j->bound_task;
-	PTHREAD_MUTEX_UNLOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 }
 
 static struct bound_task *find_job(unsigned long id)
@@ -289,7 +299,7 @@ static struct bound_task *find_job(unsigned long id)
 	return NULL;
 }
 
-void _starpu_bound_job_id_dep(starpu_job_t j, unsigned long id)
+void _starpu_bound_job_id_dep(struct _starpu_job *j, unsigned long id)
 {
 	struct bound_task *t, *dep_t;
 
@@ -299,55 +309,63 @@ void _starpu_bound_job_id_dep(starpu_job_t j, unsigned long id)
 	if (!good_job(j))
 		return;
 
-	PTHREAD_MUTEX_LOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	/* Re-check, this time with mutex held */
-	if (!_starpu_bound_recording || !recorddeps) {
-		PTHREAD_MUTEX_UNLOCK(&mutex);
+	if (!_starpu_bound_recording || !recorddeps)
+	{
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 		return;
 	}
 
 	new_task(j);
 	dep_t = find_job(id);
-	if (!dep_t) {
+	if (!dep_t)
+	{
 		fprintf(stderr,"dependency %lu not found !\n", id);
-		PTHREAD_MUTEX_UNLOCK(&mutex);
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 		return;
 	}
 	t = j->bound_task;
 	t->deps = (struct bound_task **) realloc(t->deps, ++t->depsn * sizeof(t->deps[0]));
 	t->deps[t->depsn-1] = dep_t;
-	PTHREAD_MUTEX_UNLOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 }
 
 void starpu_bound_stop(void)
 {
-	PTHREAD_MUTEX_LOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	_starpu_bound_recording = 0;
-	PTHREAD_MUTEX_UNLOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 }
 
-static void _starpu_get_tasks_times(int nw, int nt, double *times) {
+static void _starpu_get_tasks_times(int nw, int nt, double *times)
+{
 	struct bound_task_pool *tp;
 	int w, t;
-	for (w = 0; w < nw; w++) {
-		for (t = 0, tp = task_pools; tp; t++, tp = tp->next) {
-			struct starpu_job_s j = {
+	for (w = 0; w < nw; w++)
+	{
+		for (t = 0, tp = task_pools; tp; t++, tp = tp->next)
+		{
+			struct _starpu_job j =
+			{
 				.footprint = tp->footprint,
 				.footprint_is_computed = 1,
 			};
 			enum starpu_perf_archtype arch = starpu_worker_get_perf_archtype(w);
 			double length = _starpu_history_based_job_expected_perf(tp->cl->model, arch, &j, j.nimpl);
-			if (length == -1.0)
-				times[w*nt+t] = -1.0;
+			if (isnan(length))
+				times[w*nt+t] = NAN;
 			else
 				times[w*nt+t] = length / 1000.;
 		}
 	}
 }
 
-static int ancestor(struct bound_task *child, struct bound_task *parent) {
+static int ancestor(struct bound_task *child, struct bound_task *parent)
+{
 	int i;
-	for (i = 0; i < child->depsn; i++) {
+	for (i = 0; i < child->depsn; i++)
+	{
 		if (parent == child->deps[i])
 			return 1;
 		if (ancestor(child->deps[i], parent))
@@ -356,18 +374,21 @@ static int ancestor(struct bound_task *child, struct bound_task *parent) {
 	return 0;
 }
 
-void starpu_bound_print_dot(FILE *output) {
+void starpu_bound_print_dot(FILE *output)
+{
 	struct bound_task *t;
 	struct bound_tag_dep *td;
 	int i;
 
-	if (!recorddeps) {
+	if (!recorddeps)
+	{
 		fprintf(output, "Not supported\n");
 		return;
 	}
 	fprintf(output, "strict digraph bounddeps {\n");
-	for (t = tasks; t; t = t->next) {
-		fprintf(output, "\"t%lu\" [label=\"%lu: %s\"]\n", t->id, t->id, t->cl->model->symbol);
+	for (t = tasks; t; t = t->next)
+	{
+		fprintf(output, "\"t%lu\" [label=\"%lu: %s\"]\n", t->id, t->id, t->cl->name);
 		for (i = 0; i < t->depsn; i++)
 			fprintf(output, "\"t%lu\" -> \"t%lu\"\n", t->deps[i]->id, t->id);
 	}
@@ -378,6 +399,9 @@ void starpu_bound_print_dot(FILE *output) {
 
 /*
  * lp_solve format
+ *
+ * When dependencies are enabled, you can check the set of tasks and deps that
+ * were recorded by using tools/lp2paje and vite.
  */
 void starpu_bound_print_lp(FILE *output)
 {
@@ -385,27 +409,32 @@ void starpu_bound_print_lp(FILE *output)
 	int nw; /* Number of different workers */
 	int t, w;
 
-	PTHREAD_MUTEX_LOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	nw = starpu_worker_get_count();
 
-	if (recorddeps) {
+	if (recorddeps)
+	{
 		struct bound_task *t1, *t2;
 		struct bound_tag_dep *td;
 		int i;
 
 		nt = 0;
-		for (t1 = tasks; t1; t1 = t1->next) {
-			struct starpu_job_s j = {
+		for (t1 = tasks; t1; t1 = t1->next)
+		{
+			struct _starpu_job j =
+			{
 				.footprint = t1->footprint,
 				.footprint_is_computed = 1,
 			};
-			for (w = 0; w < nw; w++) {
+			for (w = 0; w < nw; w++)
+			{
 				enum starpu_perf_archtype arch = starpu_worker_get_perf_archtype(w);
-				if (t1->duration[arch] == 0.) {
+				if (_STARPU_IS_ZERO(t1->duration[arch]))
+				{
 					double length = _starpu_history_based_job_expected_perf(t1->cl->model, arch, &j,j.nimpl);
-					if (length == -1.0)
+					if (isnan(length))
 						/* Avoid problems with binary coding of doubles */
-						t1->duration[arch] = -1.0;
+						t1->duration[arch] = NAN;
 					else
 						t1->duration[arch] = length / 1000.;
 				}
@@ -422,10 +451,12 @@ void starpu_bound_print_lp(FILE *output)
 			fprintf(output, "c%lu <= tmax;\n", t1->id);
 
 		fprintf(output, "\n/* We have tasks executing on workers, exactly one worker executes each task */\n");
-		for (t1 = tasks; t1; t1 = t1->next) {
-			for (w = 0; w < nw; w++) {
+		for (t1 = tasks; t1; t1 = t1->next)
+		{
+			for (w = 0; w < nw; w++)
+			{
 				enum starpu_perf_archtype arch = starpu_worker_get_perf_archtype(w);
-				if (t1->duration[arch] != -1.0)
+				if (!isnan(t1->duration[arch]))
 					fprintf(output, " +t%luw%d", t1->id, w);
 			}
 			fprintf(output, " = 1;\n");
@@ -433,11 +464,13 @@ void starpu_bound_print_lp(FILE *output)
 
 		fprintf(output, "\n/* Completion time is start time plus computation time */\n");
 		fprintf(output, "/* According to where the task is indeed executed */\n");
-		for (t1 = tasks; t1; t1 = t1->next) {
-			fprintf(output, "/* %s %x */\tc%lu = s%lu", t1->cl->model->symbol, (unsigned) t1->footprint, t1->id, t1->id);
-			for (w = 0; w < nw; w++) {
+		for (t1 = tasks; t1; t1 = t1->next)
+		{
+			fprintf(output, "/* %s %x */\tc%lu = s%lu", t1->cl->name, (unsigned) t1->footprint, t1->id, t1->id);
+			for (w = 0; w < nw; w++)
+			{
 				enum starpu_perf_archtype arch = starpu_worker_get_perf_archtype(w);
-				if (t1->duration[arch] != -1.0)
+				if (!isnan(t1->duration[arch]))
 					fprintf(output, " + %f t%luw%d", t1->duration[arch], t1->id, w);
 			}
 			fprintf(output, ";\n");
@@ -451,7 +484,8 @@ void starpu_bound_print_lp(FILE *output)
 
 		fprintf(output, "\n/* Each tag finishes when its corresponding task finishes */");
 		for (t1 = tasks; t1; t1 = t1->next)
-			if (t1->use_tag) {
+			if (t1->use_tag)
+			{
 				for (w = 0; w < nw; w++)
 					fprintf(output, "c%lu = tag%lu;\n", t1->id, (unsigned long) t1->tag_id);
 			}
@@ -463,13 +497,17 @@ void starpu_bound_print_lp(FILE *output)
 /* TODO: factorize ancestor calls */
 		fprintf(output, "\n/* For each task pair and each worker, if both tasks are executed by the same worker,\n");
 		fprintf(output, "   one is started after the other's completion */\n");
-		for (t1 = tasks; t1; t1 = t1->next) {
+		for (t1 = tasks; t1; t1 = t1->next)
+		{
 			for (t2 = t1->next; t2; t2 = t2->next)
 			{
-				if (!ancestor(t1, t2) && !ancestor(t2, t1)) {
-					for (w = 0; w < nw; w++) {
+				if (!ancestor(t1, t2) && !ancestor(t2, t1))
+				{
+					for (w = 0; w < nw; w++)
+					{
 						enum starpu_perf_archtype arch = starpu_worker_get_perf_archtype(w);
-						if (t1->duration[arch] != -1.0) {
+						if (!isnan(t1->duration[arch]))
+						{
 							fprintf(output, "s%lu - c%lu >= -3e5 + 1e5 t%luw%d + 1e5 t%luw%d + 1e5 t%luafter%lu;\n",
 									t1->id, t2->id, t1->id, w, t2->id, w, t1->id, t2->id);
 							fprintf(output, "s%lu - c%lu >= -2e5 + 1e5 t%luw%d + 1e5 t%luw%d - 1e5 t%luafter%lu;\n",
@@ -491,26 +529,32 @@ void starpu_bound_print_lp(FILE *output)
 				}
 #endif
 
-		if (recordprio) {
+		if (recordprio)
+		{
 			fprintf(output, "\n/* For StarPU, a priority means given schedulable tasks it will consider the\n");
 			fprintf(output, " * more prioritized first */\n");
-			for (t1 = tasks; t1; t1 = t1->next) {
+			for (t1 = tasks; t1; t1 = t1->next)
+			{
 				for (t2 = t1->next; t2; t2 = t2->next)
 				{
 					if (!ancestor(t1, t2) && !ancestor(t2, t1)
-					     && t1->priority != t2->priority) {
-						if (t1->priority > t2->priority) {
+					     && t1->priority != t2->priority)
+					{
+						if (t1->priority > t2->priority)
+						{
 							/* Either t2 is scheduled before t1, but then it
 							   needs to be scheduled before some t dep finishes */
 
 							/* One of the t1 deps to give the maximum start time for t2 */
-							if (t1->depsn > 1) {
+							if (t1->depsn > 1)
+							{
 								for (i = 0; i < t1->depsn; i++)
 									fprintf(output, " + t%lut%lud%d", t2->id, t1->id, i);
 								fprintf(output, " = 1;\n");
 							}
 
-							for (i = 0; i < t1->depsn; i++) {
+							for (i = 0; i < t1->depsn; i++)
+							{
 								fprintf(output, "c%lu - s%lu >= ", t1->deps[i]->id, t2->id);
 								if (t1->depsn > 1)
 									/* Only checks this when it's this dependency that is chosen */
@@ -524,18 +568,22 @@ void starpu_bound_print_lp(FILE *output)
 
 							/* Or t2 is scheduled after t1 is.  */
 							fprintf(output, "s%lu - s%lu >= -1e5 t%luafter%lu;\n", t2->id, t1->id, t1->id, t2->id);
-						} else {
+						}
+						else
+						{
 							/* Either t1 is scheduled before t2, but then it
 							   needs to be scheduled before some t2 dep finishes */
 
 							/* One of the t2 deps to give the maximum start time for t1 */
-							if (t2->depsn > 1) {
+							if (t2->depsn > 1)
+							{
 								for (i = 0; i < t2->depsn; i++)
 									fprintf(output, " + t%lut%lud%d", t1->id, t2->id, i);
 								fprintf(output, " = 1;\n");
 							}
 
-							for (i = 0; i < t2->depsn; i++) {
+							for (i = 0; i < t2->depsn; i++)
+							{
 								fprintf(output, "c%lu - s%lu >= ", t2->deps[i]->id, t1->id);
 								if (t2->depsn > 1)
 									/* Only checks this when it's this dependency that is chosen */
@@ -555,14 +603,19 @@ void starpu_bound_print_lp(FILE *output)
 
 		for (t1 = tasks; t1; t1 = t1->next)
 			for (t2 = t1->next; t2; t2 = t2->next)
-				if (!ancestor(t1, t2) && !ancestor(t2, t1)) {
+				if (!ancestor(t1, t2) && !ancestor(t2, t1))
+				{
 					fprintf(output, "bin t%luafter%lu;\n", t1->id, t2->id);
-					if (recordprio && t1->priority != t2->priority) {
-						if (t1->priority > t2->priority) {
+					if (recordprio && t1->priority != t2->priority)
+					{
+						if (t1->priority > t2->priority)
+						{
 							if (t1->depsn > 1)
 								for (i = 0; i < t1->depsn; i++)
 									fprintf(output, "bin t%lut%lud%d;\n", t2->id, t1->id, i);
-						} else {
+						}
+						else
+						{
 							if (t2->depsn > 1)
 								for (i = 0; i < t2->depsn; i++)
 									fprintf(output, "bin t%lut%lud%d;\n", t1->id, t2->id, i);
@@ -573,7 +626,9 @@ void starpu_bound_print_lp(FILE *output)
 		for (t1 = tasks; t1; t1 = t1->next)
 			for (w = 0; w < nw; w++)
 				fprintf(output, "bin t%luw%d;\n", t1->id, w);
-	} else {
+	}
+	else
+	{
 		struct bound_task_pool *tp;
 		nt = 0;
 		for (tp = task_pools; tp; tp = tp->next)
@@ -589,12 +644,14 @@ void starpu_bound_print_lp(FILE *output)
 			fprintf(output, "min: tmax;\n\n");
 
 			fprintf(output, "/* Which is the maximum of all worker execution times (ms) */\n");
-			for (w = 0; w < nw; w++) {
+			for (w = 0; w < nw; w++)
+			{
 				char name[32];
 				starpu_worker_get_name(w, name, sizeof(name));
-				fprintf(output, "/* worker %s */\n", name);
-				for (t = 0, tp = task_pools; tp; t++, tp = tp->next) {
-					if (times[w*nt+t] != -1.0)
+				fprintf(output, "/* worker %s */\n0", name);
+				for (t = 0, tp = task_pools; tp; t++, tp = tp->next)
+				{
+					if (!isnan(times[w*nt+t]))
 						fprintf(output, "\t%+f * w%dt%dn", (float) times[w*nt+t], w, t);
 				}
 				fprintf(output, " <= tmax;\n");
@@ -602,10 +659,11 @@ void starpu_bound_print_lp(FILE *output)
 			fprintf(output, "\n");
 
 			fprintf(output, "/* And we have to have computed exactly all tasks */\n");
-			for (t = 0, tp = task_pools; tp; t++, tp = tp->next) {
-				fprintf(output, "/* task %s key %x */\n", tp->cl->model->symbol, (unsigned) tp->footprint);
+			for (t = 0, tp = task_pools; tp; t++, tp = tp->next)
+			{
+				fprintf(output, "/* task %s key %x */\n0", tp->cl->name, (unsigned) tp->footprint);
 				for (w = 0; w < nw; w++)
-					if (times[w*nt+t] != -1.0)
+					if (!isnan(times[w*nt+t]))
 						fprintf(output, "\t+w%dt%dn", w, t);
 				fprintf(output, " = %lu;\n", tp->n);
 				/* Show actual values */
@@ -619,7 +677,8 @@ void starpu_bound_print_lp(FILE *output)
 			fprintf(output, "/* int ");
 			int first = 1;
 			for (w = 0; w < nw; w++)
-				for (t = 0, tp = task_pools; tp; t++, tp = tp->next) {
+				for (t = 0, tp = task_pools; tp; t++, tp = tp->next)
+				{
 					if (!first)
 						fprintf(output, ",");
 					else
@@ -630,7 +689,7 @@ void starpu_bound_print_lp(FILE *output)
 		}
 	}
 
-	PTHREAD_MUTEX_UNLOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 }
 
 /*
@@ -643,18 +702,18 @@ void starpu_bound_print_mps(FILE *output)
 	int nw; /* Number of different workers */
 	int t, w;
 
-	if (recorddeps) {
+	if (recorddeps)
+	{
 		fprintf(output, "Not supported\n");
 		return;
 	}
 
-	PTHREAD_MUTEX_LOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 
 	nw = starpu_worker_get_count();
 	nt = 0;
 	for (tp = task_pools; tp; tp = tp->next)
 		nt++;
-
 	{
 		double times[nw*nt];
 
@@ -668,7 +727,8 @@ void starpu_bound_print_mps(FILE *output)
 		fprintf(output, " N  TMAX\n");
 
 		fprintf(output, "\n* Which is the maximum of all worker execution times (ms)\n");
-		for (w = 0; w < nw; w++) {
+		for (w = 0; w < nw; w++)
+		{
 			char name[32];
 			starpu_worker_get_name(w, name, sizeof(name));
 			fprintf(output, "* worker %s\n", name);
@@ -676,8 +736,9 @@ void starpu_bound_print_mps(FILE *output)
 		}
 
 		fprintf(output, "\n* And we have to have computed exactly all tasks\n");
-		for (t = 0, tp = task_pools; tp; t++, tp = tp->next) {
-			fprintf(output, "* task %s key %x\n", tp->cl->model->symbol, (unsigned) tp->footprint);
+		for (t = 0, tp = task_pools; tp; t++, tp = tp->next)
+		{
+			fprintf(output, "* task %s key %x\n", tp->cl->name, (unsigned) tp->footprint);
 			fprintf(output, " E  T%d\n", t);
 		}
 
@@ -686,7 +747,8 @@ void starpu_bound_print_mps(FILE *output)
 		fprintf(output, "\n* Execution times and completion of all tasks\n");
 		for (w = 0; w < nw; w++)
 			for (t = 0, tp = task_pools; tp; t++, tp = tp->next)
-				if (times[w*nt+t] != -1.0) {
+				if (!isnan(times[w*nt+t]))
+				{
 					char name[9];
 					snprintf(name, sizeof(name), "W%dT%d", w, t);
 					fprintf(stderr,"    %-8s  W%-7d  %12f\n", name, w, times[w*nt+t]);
@@ -707,7 +769,7 @@ void starpu_bound_print_mps(FILE *output)
 		fprintf(output, "ENDATA\n");
 	}
 
-	PTHREAD_MUTEX_UNLOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 }
 
 /*
@@ -751,7 +813,8 @@ static glp_prob *_starpu_bound_glp_resolve(int integer)
 		glp_set_obj_coef(lp, nw*nt+1, 1.);
 
 		for (w = 0; w < nw; w++)
-			for (t = 0, tp = task_pools; tp; t++, tp = tp->next) {
+			for (t = 0, tp = task_pools; tp; t++, tp = tp->next)
+			{
 				char name[32];
 				snprintf(name, sizeof(name), "w%dt%dn", w, t);
 				glp_set_col_name(lp, colnum(w, t), name);
@@ -763,15 +826,30 @@ static glp_prob *_starpu_bound_glp_resolve(int integer)
 
 		/* Total worker execution time */
 		glp_add_rows(lp, nw);
-		for (w = 0; w < nw; w++) {
+		for (t = 0, tp = task_pools; tp; t++, tp = tp->next)
+		{
+			int someone = 0;
+			for (w = 0; w < nw; w++)
+				if (!isnan(times[w*nt+t]))
+					someone = 1;
+			if (!someone)
+			{
+				/* This task does not have any performance model at all, abort */
+				glp_delete_prob(lp);
+				return NULL;
+			}
+		}
+		for (w = 0; w < nw; w++)
+		{
 			char name[32], title[64];
 			starpu_worker_get_name(w, name, sizeof(name));
 			snprintf(title, sizeof(title), "worker %s", name);
 			glp_set_row_name(lp, w+1, title);
-			for (t = 0, tp = task_pools; tp; t++, tp = tp->next) {
+			for (t = 0, tp = task_pools; tp; t++, tp = tp->next)
+			{
 				ia[n] = w+1;
 				ja[n] = colnum(w, t);
-				if (times[w*nt+t] == -1.)
+				if (isnan(times[w*nt+t]))
 					ar[n] = 1000000000.;
 				else
 					ar[n] = times[w*nt+t];
@@ -787,12 +865,14 @@ static glp_prob *_starpu_bound_glp_resolve(int integer)
 
 		/* Total task completion */
 		glp_add_rows(lp, nt);
-		for (t = 0, tp = task_pools; tp; t++, tp = tp->next) {
+		for (t = 0, tp = task_pools; tp; t++, tp = tp->next)
+		{
 			char name[32], title[64];
 			starpu_worker_get_name(w, name, sizeof(name));
-			snprintf(title, sizeof(title), "task %s key %x", tp->cl->model->symbol, (unsigned) tp->footprint);
+			snprintf(title, sizeof(title), "task %s key %x", tp->cl->name, (unsigned) tp->footprint);
 			glp_set_row_name(lp, nw+t+1, title);
-			for (w = 0; w < nw; w++) {
+			for (w = 0; w < nw; w++)
+			{
 				ia[n] = nw+t+1;
 				ja[n] = colnum(w, t);
 				ar[n] = 1;
@@ -810,12 +890,14 @@ static glp_prob *_starpu_bound_glp_resolve(int integer)
 	glp_init_smcp(&parm);
 	parm.msg_lev = GLP_MSG_OFF;
 	ret = glp_simplex(lp, &parm);
-	if (ret) {
+	if (ret)
+	{
 		glp_delete_prob(lp);
 		lp = NULL;
 		return NULL;
 	}
-	if (integer) {
+	if (integer)
+	{
 		glp_iocp iocp;
 		glp_init_iocp(&iocp);
 		iocp.msg_lev = GLP_MSG_OFF;
@@ -826,16 +908,19 @@ static glp_prob *_starpu_bound_glp_resolve(int integer)
 }
 #endif /* HAVE_GLPK_H */
 
-void starpu_bound_print(FILE *output, int integer __attribute__ ((unused))) {
+void starpu_bound_print(FILE *output, int integer __attribute__ ((unused)))
+{
 #ifdef HAVE_GLPK_H
-	if (recorddeps) {
+	if (recorddeps)
+	{
 		fprintf(output, "Not supported\n");
 		return;
 	}
 
-	PTHREAD_MUTEX_LOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	glp_prob *lp = _starpu_bound_glp_resolve(integer);
-	if (lp) {
+	if (lp)
+	{
 		struct bound_task_pool * tp;
 		int t, w;
 		int nw; /* Number of different workers */
@@ -850,8 +935,9 @@ void starpu_bound_print(FILE *output, int integer __attribute__ ((unused))) {
 
 		fprintf(output, "Theoretical minimum execution time: %f ms\n", tmax);
 
-		for (t = 0, tp = task_pools; tp; t++, tp = tp->next) {
-			fprintf(output, "%s key %x\n", tp->cl->model->symbol, (unsigned) tp->footprint);
+		for (t = 0, tp = task_pools; tp; t++, tp = tp->next)
+		{
+			fprintf(output, "%s key %x\n", tp->cl->name, (unsigned) tp->footprint);
 			for (w = 0; w < nw; w++)
 				if (integer)
 					fprintf(output, "\tw%dt%dn %f", w, t, glp_mip_col_val(lp, colnum(w, t)));
@@ -861,34 +947,40 @@ void starpu_bound_print(FILE *output, int integer __attribute__ ((unused))) {
 		}
 
 		glp_delete_prob(lp);
-	} else {
+	}
+	else
+	{
 		fprintf(stderr, "Simplex failed\n");
 	}
-	PTHREAD_MUTEX_UNLOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 #else /* HAVE_GLPK_H */
 	fprintf(output, "Please rebuild StarPU with glpk installed.\n");
 #endif /* HAVE_GLPK_H */
 }
 
-void starpu_bound_compute(double *res, double *integer_res __attribute__ ((unused)), int integer __attribute__ ((unused))) {
+void starpu_bound_compute(double *res, double *integer_res __attribute__ ((unused)), int integer __attribute__ ((unused)))
+{
 #ifdef HAVE_GLPK_H
 	double ret;
 
-	if (recorddeps) {
+	if (recorddeps)
+	{
 		*res = 0.;
 		return;
 	}
 
-	PTHREAD_MUTEX_LOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	glp_prob *lp = _starpu_bound_glp_resolve(integer);
-	if (lp) {
+	if (lp)
+	{
 		ret = glp_get_obj_val(lp);
 		if (integer)
 			*integer_res = glp_mip_obj_val(lp);
 		glp_delete_prob(lp);
-	} else
+	}
+	else
 		ret = 0.;
-	PTHREAD_MUTEX_UNLOCK(&mutex);
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&mutex);
 	*res = ret;
 #else /* HAVE_GLPK_H */
 	*res = 0.;

+ 3 - 3
src/profiling/bound.h

@@ -25,15 +25,15 @@
 extern int _starpu_bound_recording;
 
 /* Record task for bound computation */
-extern void _starpu_bound_record(starpu_job_t j);
+extern void _starpu_bound_record(struct _starpu_job *j);
 
 /* Record tag dependency: id depends on dep_id */
 extern void _starpu_bound_tag_dep(starpu_tag_t id, starpu_tag_t dep_id);
 
 /* Record task dependency: j depends on dep_j */
-extern void _starpu_bound_task_dep(starpu_job_t j, starpu_job_t dep_j);
+extern void _starpu_bound_task_dep(struct _starpu_job *j, struct _starpu_job *dep_j);
 
 /* Record job id dependency: j depends on job_id */
-extern void _starpu_bound_job_id_dep(starpu_job_t dep_j, unsigned long job_id);
+extern void _starpu_bound_job_id_dep(struct _starpu_job *dep_j, unsigned long job_id);
 
 #endif // __BOUND_H__

+ 48 - 44
src/profiling/profiling.c

@@ -39,7 +39,8 @@ static struct timespec executing_start_date[STARPU_NMAXWORKERS];
 
 /* Store the busid of the different (src, dst) pairs. busid_matrix[src][dst]
  * contains the busid of (src, dst) or -1 if the bus was not registered. */
-struct node_pair {
+struct node_pair
+{
 	int src;
 	int dst;
 	struct starpu_bus_profiling_info *bus_info;
@@ -47,10 +48,10 @@ struct node_pair {
 
 static int busid_matrix[STARPU_MAXNODES][STARPU_MAXNODES];
 static struct starpu_bus_profiling_info bus_profiling_info[STARPU_MAXNODES][STARPU_MAXNODES];
-static struct node_pair busid_to_node_pair[STARPU_MAXNODES*STARPU_MAXNODES]; 
+static struct node_pair busid_to_node_pair[STARPU_MAXNODES*STARPU_MAXNODES];
 static unsigned busid_cnt = 0;
 
-static void _do_starpu_bus_reset_profiling_info(struct starpu_bus_profiling_info *bus_info);
+static void _starpu_bus_reset_profiling_info(struct starpu_bus_profiling_info *bus_info);
 
 /*
  *	Global control of profiling
@@ -64,7 +65,7 @@ int starpu_profiling_status_set(int status)
 	int prev_value = profiling;
 	profiling = status;
 
-	STARPU_TRACE_SET_PROFILING(status);
+	_STARPU_TRACE_SET_PROFILING(status);
 
 	/* If we enable profiling, we reset the counters. */
 	if (status == STARPU_PROFILING_ENABLE)
@@ -80,7 +81,7 @@ int starpu_profiling_status_set(int status)
 			struct starpu_bus_profiling_info *bus_info;
 			bus_info = busid_to_node_pair[busid].bus_info;
 
-			_do_starpu_bus_reset_profiling_info(bus_info);;
+			_starpu_bus_reset_profiling_info(bus_info);
 		}
 	}
 
@@ -98,7 +99,7 @@ void _starpu_profiling_init(void)
 	const char *env;
 	for (worker = 0; worker < STARPU_NMAXWORKERS; worker++)
 	{
-		PTHREAD_MUTEX_INIT(&worker_info_mutex[worker], NULL);
+		_STARPU_PTHREAD_MUTEX_INIT(&worker_info_mutex[worker], NULL);
 		_starpu_worker_reset_profiling_info(worker);
 	}
 	if ((env = getenv("STARPU_PROFILING")) && atoi(env))
@@ -132,9 +133,9 @@ struct starpu_task_profiling_info *_starpu_allocate_profiling_info_if_needed(str
  *	Worker profiling
  */
 
-static void _do_starpu_worker_reset_profiling_info(int workerid)
+static void _starpu_worker_reset_profiling_info_with_lock(int workerid)
 {
-	starpu_clock_gettime(&worker_info[workerid].start_time);
+	_starpu_clock_gettime(&worker_info[workerid].start_time);
 
 	/* This is computed in a lazy fashion when the application queries
 	 * profiling info. */
@@ -148,45 +149,47 @@ static void _do_starpu_worker_reset_profiling_info(int workerid)
 	worker_info[workerid].used_cycles = 0;
 	worker_info[workerid].stall_cycles = 0;
 	worker_info[workerid].power_consumed = 0;
-	
+
 	/* We detect if the worker is already sleeping or doing some
 	 * computation */
-	starpu_worker_status status = _starpu_worker_get_status(workerid);
+	enum _starpu_worker_status status = _starpu_worker_get_status(workerid);
 
 	if (status == STATUS_SLEEPING)
 	{
 		worker_registered_sleeping_start[workerid] = 1;
-		starpu_clock_gettime(&sleeping_start_date[workerid]);
+		_starpu_clock_gettime(&sleeping_start_date[workerid]);
 	}
-	else {
+	else
+	{
 		worker_registered_sleeping_start[workerid] = 0;
 	}
 
 	if (status == STATUS_EXECUTING)
 	{
 		worker_registered_executing_start[workerid] = 1;
-		starpu_clock_gettime(&executing_start_date[workerid]);
+		_starpu_clock_gettime(&executing_start_date[workerid]);
 	}
-	else {
+	else
+	{
 		worker_registered_executing_start[workerid] = 0;
 	}
 }
 
 void _starpu_worker_reset_profiling_info(int workerid)
 {
-	PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
-	_do_starpu_worker_reset_profiling_info(workerid);
-	PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);
+	_STARPU_PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
+	_starpu_worker_reset_profiling_info_with_lock(workerid);
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);
 }
 
 void _starpu_worker_register_sleeping_start_date(int workerid, struct timespec *sleeping_start)
 {
 	if (profiling)
 	{
-		PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
-		worker_registered_sleeping_start[workerid] = 1;	
+		_STARPU_PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
+		worker_registered_sleeping_start[workerid] = 1;
 		memcpy(&sleeping_start_date[workerid], sleeping_start, sizeof(struct timespec));
-		PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);
 	}
 }
 
@@ -194,10 +197,10 @@ void _starpu_worker_register_executing_start_date(int workerid, struct timespec
 {
 	if (profiling)
 	{
-		PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
-		worker_registered_executing_start[workerid] = 1;	
+		_STARPU_PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
+		worker_registered_executing_start[workerid] = 1;
 		memcpy(&executing_start_date[workerid], executing_start, sizeof(struct timespec));
-		PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);
 	}
 }
 
@@ -205,10 +208,10 @@ void _starpu_worker_update_profiling_info_sleeping(int workerid, struct timespec
 {
 	if (profiling)
 	{
-		PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
+		_STARPU_PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
 
                 /* Perhaps that profiling was enabled while the worker was
-                 * already blocked, so we don't measure (end - start), but 
+                 * already blocked, so we don't measure (end - start), but
                  * (end - max(start,worker_start)) where worker_start is the
                  * date of the previous profiling info reset on the worker */
 		struct timespec *worker_start = &worker_info[workerid].start_time;
@@ -223,9 +226,9 @@ void _starpu_worker_update_profiling_info_sleeping(int workerid, struct timespec
 
 		starpu_timespec_accumulate(&worker_info[workerid].sleeping_time, &sleeping_time);
 
-		worker_registered_sleeping_start[workerid] = 0;	
+		worker_registered_sleeping_start[workerid] = 0;
 
-		PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);
 	}
 }
 
@@ -234,7 +237,7 @@ void _starpu_worker_update_profiling_info_executing(int workerid, struct timespe
 {
 	if (profiling)
 	{
-		PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
+		_STARPU_PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
 
 		if (executing_time)
 			starpu_timespec_accumulate(&worker_info[workerid].executing_time, executing_time);
@@ -243,9 +246,10 @@ void _starpu_worker_update_profiling_info_executing(int workerid, struct timespe
 		worker_info[workerid].stall_cycles += stall_cycles;
 		worker_info[workerid].power_consumed += power_consumed;
 		worker_info[workerid].executed_tasks += executed_tasks;
-	
-		PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);
-	} else /* Not thread safe, shouldn't be too much a problem */
+
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);
+	}
+	else /* Not thread safe, shouldn't be too much a problem */
 		worker_info[workerid].executed_tasks += executed_tasks;
 }
 
@@ -257,13 +261,13 @@ int starpu_worker_get_profiling_info(int workerid, struct starpu_worker_profilin
 		info->executed_tasks = worker_info[workerid].executed_tasks;
 	}
 
-	PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
+	_STARPU_PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);
 
 	if (info)
 	{
 		/* The total time is computed in a lazy fashion */
 		struct timespec now;
-		starpu_clock_gettime(&now);
+		_starpu_clock_gettime(&now);
 
 		/* In case some worker is currently sleeping, we take into
 		 * account the time spent since it registered. */
@@ -288,9 +292,9 @@ int starpu_worker_get_profiling_info(int workerid, struct starpu_worker_profilin
 		memcpy(info, &worker_info[workerid], sizeof(struct starpu_worker_profiling_info));
 	}
 
-	_do_starpu_worker_reset_profiling_info(workerid);
+	_starpu_worker_reset_profiling_info_with_lock(workerid);
 
-	PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);
 
 	return 0;
 }
@@ -305,7 +309,7 @@ void _starpu_profiling_set_task_push_start_time(struct starpu_task *task)
 	profiling_info = task->profiling_info;
 
 	if (profiling_info)
-		starpu_clock_gettime(&profiling_info->push_start_time);
+		_starpu_clock_gettime(&profiling_info->push_start_time);
 }
 
 void _starpu_profiling_set_task_push_end_time(struct starpu_task *task)
@@ -317,7 +321,7 @@ void _starpu_profiling_set_task_push_end_time(struct starpu_task *task)
 	profiling_info = task->profiling_info;
 
 	if (profiling_info)
-		starpu_clock_gettime(&profiling_info->push_end_time);
+		_starpu_clock_gettime(&profiling_info->push_end_time);
 }
 
 /*
@@ -329,14 +333,14 @@ void _starpu_initialize_busid_matrix(void)
 	int i, j;
 	for (j = 0; j < STARPU_MAXNODES; j++)
 	for (i = 0; i < STARPU_MAXNODES; i++)
-		busid_matrix[i][j] = -1;	
+		busid_matrix[i][j] = -1;
 
 	busid_cnt = 0;
 }
 
-static void _do_starpu_bus_reset_profiling_info(struct starpu_bus_profiling_info *bus_info)
+static void _starpu_bus_reset_profiling_info(struct starpu_bus_profiling_info *bus_info)
 {
-	starpu_clock_gettime(&bus_info->start_time);
+	_starpu_clock_gettime(&bus_info->start_time);
 	bus_info->transferred_bytes = 0;
 	bus_info->transfer_count = 0;
 }
@@ -354,7 +358,7 @@ int _starpu_register_bus(int src_node, int dst_node)
 	busid_to_node_pair[busid].dst = dst_node;
 	busid_to_node_pair[busid].bus_info = &bus_profiling_info[src_node][dst_node];
 
-	_do_starpu_bus_reset_profiling_info(&bus_profiling_info[src_node][dst_node]);
+	_starpu_bus_reset_profiling_info(&bus_profiling_info[src_node][dst_node]);
 
 	return busid;
 }
@@ -388,7 +392,7 @@ int starpu_bus_get_profiling_info(int busid, struct starpu_bus_profiling_info *b
 	if (bus_info)
 	{
 		struct timespec now;
-		starpu_clock_gettime(&now);
+		_starpu_clock_gettime(&now);
 
 		/* total_time = now - start_time */
 		starpu_timespec_sub(&now, &bus_profiling_info[src_node][dst_node].start_time,
@@ -397,10 +401,10 @@ int starpu_bus_get_profiling_info(int busid, struct starpu_bus_profiling_info *b
 		memcpy(bus_info, &bus_profiling_info[src_node][dst_node], sizeof(struct starpu_bus_profiling_info));
 	}
 
-	_do_starpu_bus_reset_profiling_info(&bus_profiling_info[src_node][dst_node]);
+	_starpu_bus_reset_profiling_info(&bus_profiling_info[src_node][dst_node]);
 
 	return 0;
-} 
+}
 
 void _starpu_bus_update_profiling_info(int src_node, int dst_node, size_t size)
 {

+ 10 - 5
src/profiling/profiling_helpers.c

@@ -30,7 +30,7 @@ void starpu_bus_profiling_helper_display_summary(void)
 	for (busid = 0; busid < bus_cnt; busid++)
 	{
 		int src, dst;
-	
+
 		src = starpu_bus_get_src(busid);
 		dst = starpu_bus_get_dst(busid);
 
@@ -67,7 +67,8 @@ void starpu_worker_profiling_helper_display_summary(void)
 
 		starpu_worker_get_name(workerid, name, sizeof(name));
 
-		if (profiling) {
+		if (profiling)
+		{
 			double total_time = starpu_timing_timespec_to_us(&info.total_time) / 1000.;
 			double executing_time = starpu_timing_timespec_to_us(&info.executing_time) / 1000.;
 			double sleeping_time = starpu_timing_timespec_to_us(&info.sleeping_time) / 1000.;
@@ -80,16 +81,20 @@ void starpu_worker_profiling_helper_display_summary(void)
 				fprintf(stderr, "\t%lu Mcy %lu Mcy stall\n", info.used_cycles/1000000, info.stall_cycles/1000000);
 			if (info.power_consumed)
 				fprintf(stderr, "\t%f J consumed\n", info.power_consumed);
-		} else {
+		}
+		else
+		{
 			fprintf(stderr, "\t%-32s\t%d task(s)\n", name, info.executed_tasks);
 		}
 
 		sum_consumed += info.power_consumed;
 	}
 
-	if (profiling) {
+	if (profiling)
+	{
 		const char *strval_idle_power = getenv("STARPU_IDLE_POWER");
-		if (strval_idle_power) {
+		if (strval_idle_power)
+		{
 			double idle_power = atof(strval_idle_power); /* Watt */
 			double idle_consumption = idle_power * overall_time / 1000.; /* J */
 

+ 10 - 8
src/starpu_parameters.h

@@ -10,6 +10,8 @@
  * StarPU is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
 #ifndef _STARPU_PARAMETERS_H
@@ -25,19 +27,19 @@
  * Here are the default values of alpha, beta, gamma
  */
 
-#define STARPU_DEFAULT_ALPHA 1.0
-#define STARPU_DEFAULT_BETA 1.0
-#define STARPU_DEFAULT_GAMMA 1000.0
+#define _STARPU_DEFAULT_ALPHA 1.0
+#define _STARPU_DEFAULT_BETA 1.0
+#define _STARPU_DEFAULT_GAMMA 1000.0
 
 /* How many executions a codelet will have to be measured before we
  * consider that calibration will provide a value good enough for scheduling */
-#define STARPU_CALIBRATION_MINIMUM 10
+#define _STARPU_CALIBRATION_MINIMUM 10
 
 /* Assumed relative performance ratios */
 /* TODO: benchmark a bit instead */
-#define STARPU_CPU_ALPHA	1.0f
-#define STARPU_CUDA_ALPHA	13.33f
-#define STARPU_OPENCL_ALPHA	12.22f
-#define STARPU_GORDON_ALPHA	6.0f /* XXX this is a random value ... */
+#define _STARPU_CPU_ALPHA	1.0f
+#define _STARPU_CUDA_ALPHA	13.33f
+#define _STARPU_OPENCL_ALPHA	12.22f
+#define _STARPU_GORDON_ALPHA	6.0f /* XXX this is a random value ... */
 
 #endif /* _STARPU_PARAMETERS_H */

+ 260 - 240
src/top/starpu_top.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011 William Braik, Yann Courtois, Jean-Marie Couteyen, Anthony
- * Roy
+ * Copyright (C) 2011 William Braik, Yann Courtois, Jean-Marie Couteyen, Anthony Roy
+ * Copyright (C) 2011, 2012 Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -17,71 +17,78 @@
 
 
 #include <starpu_top.h>
-#include <top/starputop_message_queue.h>
-#include <top/starputop_connection.h>
+#include <top/starpu_top_message_queue.h>
+#include <top/starpu_top_connection.h>
+#include <top/starpu_top_core.h>
 #include <profiling/profiling.h>
 #include <stdio.h>
 #include <string.h>
 #include <math.h>
 #include <pthread.h>
 #include <common/timing.h>
+#include <common/utils.h>
 
-extern starputop_message_queue_t*  starputop_mt;
+extern struct _starpu_top_message_queue*  _starpu_top_mt;
 int starpu_top = 0;
-int starputop_debug_on = 0;
-unsigned int starputop_data_cpt = 0;
-unsigned int starputop_param_cpt = 0;
-starputop_data* starputop_first_data = NULL;
-starputop_param* starputop_first_param = NULL;
-starputop_data** starputop_datas;
-starputop_param** starputop_params;
-
-sem_t starputop_wait_for_go;
-pthread_mutex_t starputop_wait_for_continue_mutex;
-pthread_cond_t starputop_wait_for_continue_cond = PTHREAD_COND_INITIALIZER;
-
-int starpu_top_status_get()
+int starpu_top_debug_on = 0;
+unsigned int starpu_top_data_cpt = 0;
+unsigned int starpu_top_param_cpt = 0;
+struct starpu_top_data* starpu_top_first_data = NULL;
+struct starpu_top_param* starpu_top_first_param = NULL;
+struct starpu_top_data** starpu_top_datas;
+struct starpu_top_param** starpu_top_params;
+
+sem_t starpu_top_wait_for_go;
+pthread_mutex_t starpu_top_wait_for_continue_mutex;
+pthread_cond_t starpu_top_wait_for_continue_cond = PTHREAD_COND_INITIALIZER;
+
+int _starpu_top_status_get()
 {
-  return starpu_top;
+	return starpu_top;
 }
 
-
-unsigned long long int current_timestamp();
+static
+unsigned long long current_timestamp();
 
 /*********************************************
 *****************INIT FUNC********************
 **********************************************/
 
-char *message_for_topdata_init(starputop_data* data);
-char *message_for_topparam_init(starputop_param* param);
+static
+char *message_for_topdata_init(struct starpu_top_data* data);
+
+static
+char *message_for_topparam_init(struct starpu_top_param* param);
 
 /*
  * we store data and param in a tab to offer a O(1) access when the program  is
  * running
  */
+static
 void copy_data_and_param()
 {
 	printf("%s:%d trace\n", __FILE__, __LINE__);
 	//copying datas
-	starputop_datas = (starputop_data **) malloc(starputop_data_cpt*sizeof(starputop_data*));
-	starputop_data* cur = starputop_first_data;
+	starpu_top_datas = (struct starpu_top_data **) malloc(starpu_top_data_cpt*sizeof(struct starpu_top_data*));
+	struct starpu_top_data* cur = starpu_top_first_data;
 	unsigned int i = 0;
-	for(i = 0; i < starputop_data_cpt; i++)
+	for(i = 0; i < starpu_top_data_cpt; i++)
 	{
-		starputop_datas[i] = cur;
+		starpu_top_datas[i] = cur;
 		cur = cur->next;
 	}
 	//copying params
-	starputop_params = (starputop_param **) malloc(starputop_param_cpt*sizeof(starputop_param*));
-	starputop_param* cur2 = starputop_first_param;
-	for(i = 0; i < starputop_param_cpt; i++)
+	starpu_top_params = (struct starpu_top_param **) malloc(starpu_top_param_cpt*sizeof(struct starpu_top_param*));
+	struct starpu_top_param* cur2 = starpu_top_first_param;
+	for(i = 0; i < starpu_top_param_cpt; i++)
 	{
-		starputop_params[i] = cur2;
+		starpu_top_params[i] = cur2;
 		cur2 = cur2->next;
 	}
 }
 
-static void starputop_get_device_type(int id, char* type){
+static void starpu_top_get_device_type(int id, char* type)
+{
 	enum starpu_archtype device_type=starpu_worker_get_type(id);
 	switch (device_type)
 	{
@@ -97,14 +104,14 @@ static void starputop_get_device_type(int id, char* type){
 	case STARPU_GORDON_WORKER:
 		strncpy(type, "GORDON",9);
 		break;
-	}  
+	}
 }
 
-static void starputop_send_devices_info()
+static void starpu_top_send_devices_info()
 {
 	char* message=(char *)malloc(5*sizeof(char));
 	snprintf(message,5,"DEV\n");
-	starputop_message_add(starputop_mt,message);
+	_starpu_top_message_add(_starpu_top_mt,message);
 
 	unsigned int i;
 	for(i=0;i<starpu_worker_get_count();i++)
@@ -112,191 +119,192 @@ static void starputop_send_devices_info()
 		message=(char *)malloc(sizeof(char)*128);
 		char dev_type[10];
 		char dev_name[64];
-		starputop_get_device_type(i,dev_type);
+		starpu_top_get_device_type(i,dev_type);
 		starpu_worker_get_name(i, dev_name,64);
-		snprintf(message, 128, "%d;%s;%s\n", i, dev_type, dev_name);
-		starputop_message_add(starputop_mt,message);    
+		snprintf(message, 128, "%u;%s;%s\n", i, dev_type, dev_name);
+		_starpu_top_message_add(_starpu_top_mt,message);
 	}
 
-	message=(char*)malloc(6*sizeof(char));                             
-	snprintf(message,6,"/DEV\n");                
-	starputop_message_add(starputop_mt,message);  
+	message=(char*)malloc(6*sizeof(char));
+	snprintf(message,6,"/DEV\n");
+	_starpu_top_message_add(_starpu_top_mt,message);
 }
 
 
-void starputop_init_and_wait(const char* server_name){
+void starpu_top_init_and_wait(const char* server_name)
+{
 	starpu_top=1;
-	sem_init(&starputop_wait_for_go,0,0);
-	
-	pthread_mutex_init(&starputop_wait_for_continue_mutex, NULL);
-	
+	sem_init(&starpu_top_wait_for_go,0,0);
+
+	_STARPU_PTHREAD_MUTEX_INIT(&starpu_top_wait_for_continue_mutex, NULL);
+
 	//profiling activation
 	starpu_profiling_status_set(STARPU_PROFILING_ENABLE);
 
 	//init locked queue before adding the first message
-	starputop_mt = starputop_message_queue_new();
+	_starpu_top_mt = _starpu_top_message_queue_new();
+	STARPU_ASSERT(_starpu_top_mt);
 
 	//waiting for UI to connect
 	printf("%s:%d launching network threads\n", __FILE__, __LINE__);
-	starputop_communications_threads_launcher();
+	_starpu_top_communications_threads_launcher();
 
 	//sending server information (report to protocol)
 	char* message = (char *) malloc(strlen("SERVERINFO\n")+1);
-	sprintf(message, "%s", "SERVERINFO\n");  
-	starputop_message_add(starputop_mt,message);
+	sprintf(message, "%s", "SERVERINFO\n");
+	_starpu_top_message_add(_starpu_top_mt,message);
 	message = (char *) malloc(strlen(server_name)+2);
 	sprintf(message, "%s\n", server_name);
-	starputop_message_add(starputop_mt,message);
+	_starpu_top_message_add(_starpu_top_mt,message);
 	message = (char *) malloc(25);
 	sprintf(message, "%lld\n", current_timestamp());
-	starputop_message_add(starputop_mt,message);
+	_starpu_top_message_add(_starpu_top_mt,message);
 	message = (char *) malloc(strlen("/SERVERINFO\n")+1);
 	sprintf(message,"%s", "/SERVERINFO\n");
-	starputop_message_add(starputop_mt,message);
+	_starpu_top_message_add(_starpu_top_mt,message);
 
 
 	//sending data list
 	message = (char *) malloc(strlen("DATA\n")+1);
 	sprintf(message, "%s", "DATA\n");
-	starputop_message_add(starputop_mt,message);
-	starputop_data * cur_data = starputop_first_data;
+	_starpu_top_message_add(_starpu_top_mt,message);
+	struct starpu_top_data * cur_data = starpu_top_first_data;
 	while(cur_data != NULL)
 	{
-		starputop_message_add(starputop_mt,message_for_topdata_init(cur_data));
+		_starpu_top_message_add(_starpu_top_mt,message_for_topdata_init(cur_data));
 		cur_data = cur_data->next;
 	}
 	message = (char *) malloc(strlen("/DATA\n")+1);
 	sprintf(message, "%s", "/DATA\n");
-	starputop_message_add(starputop_mt,message);
-	
+	_starpu_top_message_add(_starpu_top_mt,message);
+
 	//sending parameter list
 	message = (char *) malloc(strlen("PARAMS\n")+1);
 	sprintf(message, "%s", "PARAMS\n");
-	starputop_message_add(starputop_mt,message);
-	starputop_param * cur_param = starputop_first_param;
+	_starpu_top_message_add(_starpu_top_mt,message);
+	struct starpu_top_param * cur_param = starpu_top_first_param;
 	printf("%s:%d sending parameters\n", __FILE__, __LINE__);
-	while(cur_param != NULL){
-	  starputop_message_add(starputop_mt,message_for_topparam_init(cur_param));
+	while(cur_param != NULL)
+	{
+	  _starpu_top_message_add(_starpu_top_mt,message_for_topparam_init(cur_param));
 	  cur_param = cur_param->next;
 	}
 	printf("%s:%d parameters sended\n", __FILE__, __LINE__);
 	message = (char *) malloc(strlen("/PARAMS\n")+1);
 	sprintf(message, "%s", "/PARAMS\n");
-	starputop_message_add(starputop_mt,message);
-	
-	
+	_starpu_top_message_add(_starpu_top_mt,message);
+
+
 	//sending DEVICE list
 	printf("%s:%d sending devices info\n", __FILE__, __LINE__);
-	starputop_send_devices_info();
+	starpu_top_send_devices_info();
 	printf("%s:%d devices_info sended\n", __FILE__, __LINE__);
 	//copying data and params
 	copy_data_and_param();
-	
+
 	//sending READY message
 	message = (char *) malloc(strlen("READY\n")+1);
 	sprintf(message, "%s", "READY\n");
-	starputop_message_add(starputop_mt,message);
-	
+	_starpu_top_message_add(_starpu_top_mt,message);
+
 	//This threads keeps locked while we don't receive an GO message from UI
 	printf("%s:%d waiting for GO message\n", __FILE__, __LINE__);
-	sem_wait(&starputop_wait_for_go);
+	sem_wait(&starpu_top_wait_for_go);
 }
 
-void starputop_enqueue_data(starputop_data * data)
+static
+void starpu_top_enqueue_data(struct starpu_top_data * data)
 {
-	if(starputop_first_data == NULL)
+	if(starpu_top_first_data == NULL)
 	{
-		starputop_first_data = data;
+		starpu_top_first_data = data;
 	}
 	else
 	{
-		starputop_data * cur = starputop_first_data;
+		struct starpu_top_data * cur = starpu_top_first_data;
 		while(cur->next != NULL)
 			cur = cur->next;
 		cur->next = data;
 	}
 }
 
-starputop_data * starputop_add_data_boolean(
-			const char* data_name,
-			int active)
-{		
-	starputop_data * data = (starputop_data *) malloc(sizeof(starputop_data));
-	data->id = starputop_data_cpt++;
+struct starpu_top_data * starpu_top_add_data_boolean(const char* data_name,
+						     int active)
+{
+	struct starpu_top_data * data = (struct starpu_top_data *) malloc(sizeof(struct starpu_top_data));
+	data->id = starpu_top_data_cpt++;
 	data->name = data_name;
-	data->type = STARPUTOP_DATA_BOOLEAN;
+	data->type = STARPU_TOP_DATA_BOOLEAN;
 	data->active = active;
 	data->next = NULL;
 
-	starputop_enqueue_data(data);
+	starpu_top_enqueue_data(data);
 
 	return data;
 }
 
-starputop_data * starputop_add_data_integer(
-			const char* data_name,
-			int minimum_value,
-			int maximum_value,
-			int active)
-{	
-	starputop_data * data = (starputop_data *) malloc(sizeof(starputop_data));
-	data->id = starputop_data_cpt++;
-	data->name = data_name; 
-	data->type = STARPUTOP_DATA_INTEGER;
+struct starpu_top_data * starpu_top_add_data_integer(const char* data_name,
+						     int minimum_value,
+						     int maximum_value,
+						     int active)
+{
+	struct starpu_top_data * data = (struct starpu_top_data *) malloc(sizeof(struct starpu_top_data));
+	data->id = starpu_top_data_cpt++;
+	data->name = data_name;
+	data->type = STARPU_TOP_DATA_INTEGER;
 	data->int_min_value = minimum_value;
 	data->int_max_value = maximum_value;
 	data->active = active;
 	data->next = NULL;
 
-	starputop_enqueue_data(data);
+	starpu_top_enqueue_data(data);
 
 	return data;
 }
 
-starputop_data* starputop_add_data_float(
-			const char* data_name,
-			double minimum_value,
-			double maximum_value,
-			int active)
+struct starpu_top_data* starpu_top_add_data_float(const char* data_name,
+						  double minimum_value,
+						  double maximum_value,
+						  int active)
 {
-	starputop_data * data = (starputop_data *) malloc(sizeof(starputop_data));
-	data->id = starputop_data_cpt++;
+	struct starpu_top_data * data = (struct starpu_top_data *) malloc(sizeof(struct starpu_top_data));
+	data->id = starpu_top_data_cpt++;
 	data->name = data_name;
-	data->type = STARPUTOP_DATA_FLOAT;
+	data->type = STARPU_TOP_DATA_FLOAT;
 	data->double_min_value = minimum_value;
 	data->double_max_value = maximum_value;
 	data->active = active;
 	data->next = NULL;
 
-	starputop_enqueue_data(data);
+	starpu_top_enqueue_data(data);
 
 	return data;
 }
 
-char *message_for_topdata_init(starputop_data* data)
+char *message_for_topdata_init(struct starpu_top_data* data)
 {
 	char*message = (char *) malloc(256+strlen(data->name));
 	switch(data->type)
 	{
-		case STARPUTOP_DATA_BOOLEAN:
+		case STARPU_TOP_DATA_BOOLEAN:
 			sprintf(message,
-					"BOOL;%d;%s;%d\n",
+					"BOOL;%u;%s;%d\n",
 					data->id,
 					data->name,
 					data->active ? 1 : 0);
 			break;
-		case STARPUTOP_DATA_INTEGER:
+		case STARPU_TOP_DATA_INTEGER:
 			sprintf(message,
-					"INT;%d;%s;%d;%d;%d\n",
+					"INT;%u;%s;%d;%d;%d\n",
 					data->id,
 					data->name,
 					data->int_min_value,
 					data->int_max_value,
 					data->active ? 1 : 0);
 			break;
-		case STARPUTOP_DATA_FLOAT:
+		case STARPU_TOP_DATA_FLOAT:
 			sprintf(message,
-					"FLOAT;%d;%s;%f;%f;%d\n",
+					"FLOAT;%u;%s;%f;%f;%d\n",
 					data->id,
 					data->name,
 					data->double_min_value,
@@ -307,41 +315,41 @@ char *message_for_topdata_init(starputop_data* data)
 	return message;
 }
 
-char *message_for_topparam_init(starputop_param* param)
+char *message_for_topparam_init(struct starpu_top_param* param)
 {
 	char*message = NULL;
 	int i;
 	int length=0;
 	switch(param->type)
 	{
-	case STARPUTOP_PARAM_BOOLEAN:
+	case STARPU_TOP_PARAM_BOOLEAN:
 		message = (char *) malloc(256);
 		sprintf(message,
-				"BOOL;%d;%s;%d\n",
+				"BOOL;%u;%s;%d\n",
 				param->id,
 				param->name,
 				(*(int*)(param->value)) ? 1 : 0);
 		break;
-	case STARPUTOP_PARAM_INTEGER:
+	case STARPU_TOP_PARAM_INTEGER:
 		message = (char *) malloc(256);
 		sprintf(message,
-				"INT;%d;%s;%d;%d;%d\n",param->id,
+				"INT;%u;%s;%d;%d;%d\n",param->id,
 				param->name,
 				param->int_min_value,
 				param->int_max_value,
 				*(int*)(param->value));
 		break;
-	case STARPUTOP_PARAM_FLOAT:
+	case STARPU_TOP_PARAM_FLOAT:
 		message = (char *) malloc(256);
 		sprintf(message,
-				"FLOAT;%d;%s;%f;%f;%f\n",
+				"FLOAT;%u;%s;%f;%f;%f\n",
 				param->id,
 				param->name,
 				param->double_min_value,
 				param->double_max_value,
 				*(double*)(param->value));
 		break;
-	case STARPUTOP_PARAM_ENUM:
+	case STARPU_TOP_PARAM_ENUM:
 		//compute message lenght
 		for(i = 0; i < param->nb_values; i++)
 		{
@@ -349,10 +357,10 @@ char *message_for_topparam_init(starputop_param* param)
 		}
 		message = (char *) malloc(256+length);
 		sprintf(message,
-				"ENUM;%d;%s;",
+				"ENUM;%u;%s;",
 				param->id,
 				param->name);
-		
+
 		//compute the begin of enums elements in message
 		char* cur = message+strlen(message);
 		//add each enum element
@@ -371,105 +379,102 @@ char *message_for_topparam_init(starputop_param* param)
 	return message;
 }
 
-void starputop_enqueue_param(starputop_param* param)
+static
+void starpu_top_enqueue_param(struct starpu_top_param* param)
 {
-	if(starputop_first_param == NULL)
+	if(starpu_top_first_param == NULL)
 	{
-		starputop_first_param = param;
+		starpu_top_first_param = param;
 	}
 	else
 	{
-		starputop_param * cur = starputop_first_param;
+		struct starpu_top_param * cur = starpu_top_first_param;
 		while(cur->next != NULL)
 			cur = cur->next;
 		cur->next = param;
 	}
 }
 
-
-starputop_param* starputop_register_parameter_boolean(
-			const char* param_name,
-			int* parameter_field,
-			void (*callback)(struct starputop_param_t*))
+struct starpu_top_param* starpu_top_register_parameter_boolean(const char* param_name,
+							       int* parameter_field,
+							       void (*callback)(struct starpu_top_param*))
 {
-    STARPU_ASSERT(!starpu_top_status_get());
-	starputop_param * param = (starputop_param *) malloc(sizeof(starputop_param));
+	STARPU_ASSERT(!_starpu_top_status_get());
+	struct starpu_top_param * param = (struct starpu_top_param *) malloc(sizeof(struct starpu_top_param));
 	param->callback = callback;
 	param->name = param_name;
-	param->id = starputop_param_cpt++;
-	param->type = STARPUTOP_PARAM_BOOLEAN;
+	param->id = starpu_top_param_cpt++;
+	param->type = STARPU_TOP_PARAM_BOOLEAN;
 	param->value = (void*)parameter_field;
 	param->next = NULL;
-	
-	starputop_enqueue_param(param);
-	
+
+	starpu_top_enqueue_param(param);
+
 	return param;
 }
 
-
-starputop_param* starputop_register_parameter_integer(const char* param_name,
-			int* parameter_field,
-			int minimum_value,
-			int maximum_value,
-			void (*callback)(struct starputop_param_t*))
-{	
-	STARPU_ASSERT(!starpu_top_status_get());
-	starputop_param * param = (starputop_param *) malloc(sizeof(starputop_param));
+struct starpu_top_param* starpu_top_register_parameter_integer(const char* param_name,
+							       int* parameter_field,
+							       int minimum_value,
+							       int maximum_value,
+							       void (*callback)(struct starpu_top_param*))
+{
+	STARPU_ASSERT(!_starpu_top_status_get());
+	struct starpu_top_param * param = (struct starpu_top_param *) malloc(sizeof(struct starpu_top_param));
 	param->callback = callback;
 	param->name = param_name;
-	param->id = starputop_param_cpt++;
-	param->type = STARPUTOP_PARAM_INTEGER;
+	param->id = starpu_top_param_cpt++;
+	param->type = STARPU_TOP_PARAM_INTEGER;
 	param->value = (void*)parameter_field;
 	param->int_min_value = minimum_value;
 	param->int_max_value = maximum_value;
 	param->next = NULL;
 
-	starputop_enqueue_param(param);
-	
+	starpu_top_enqueue_param(param);
+
 	return param;
 }
-starputop_param* starputop_register_parameter_float(
-			const char* param_name,
-			double* parameter_field,
-			double minimum_value,
-			double maximum_value,
-			void (*callback)(struct starputop_param_t*))
+
+struct starpu_top_param* starpu_top_register_parameter_float(const char* param_name,
+							     double* parameter_field,
+							     double minimum_value,
+							     double maximum_value,
+							     void (*callback)(struct starpu_top_param*))
 {
-	STARPU_ASSERT(!starpu_top_status_get());
-	starputop_param * param = (starputop_param *) malloc(sizeof(starputop_param));
+	STARPU_ASSERT(!_starpu_top_status_get());
+	struct starpu_top_param * param = (struct starpu_top_param *) malloc(sizeof(struct starpu_top_param));
 	param->callback = callback;
 	param->name = param_name;
-	param->id = starputop_param_cpt++;
-	param->type = STARPUTOP_PARAM_FLOAT;
+	param->id = starpu_top_param_cpt++;
+	param->type = STARPU_TOP_PARAM_FLOAT;
 	param->value = (void*)parameter_field;
 	param->double_min_value = minimum_value;
 	param->double_max_value = maximum_value;
 	param->next = NULL;
 
-	starputop_enqueue_param(param);
+	starpu_top_enqueue_param(param);
 
 	return param;
 }
 
-starputop_param* starputop_register_parameter_enum(
-			const char* param_name,
-			int* parameter_field,
-			char** values,
-			int nb_values,
-			void (*callback)(struct starputop_param_t*))
+struct starpu_top_param* starpu_top_register_parameter_enum(const char* param_name,
+							    int* parameter_field,
+							    char** values,
+							    int nb_values,
+							    void (*callback)(struct starpu_top_param*))
 {
-	STARPU_ASSERT(!starpu_top_status_get());
-	starputop_param * param = (starputop_param *) malloc(sizeof(starputop_param));
+	STARPU_ASSERT(!_starpu_top_status_get());
+	struct starpu_top_param * param = (struct starpu_top_param *) malloc(sizeof(struct starpu_top_param));
 	param->callback = callback;
 	param->name = param_name;
-	param->id = starputop_param_cpt++;
-	param->type = STARPUTOP_PARAM_ENUM;
+	param->id = starpu_top_param_cpt++;
+	param->type = STARPU_TOP_PARAM_ENUM;
 	param->value = (void*)parameter_field;
 	param->enum_values = values;
 	param->nb_values = nb_values;
 	param->next = NULL;
-	
-	starputop_enqueue_param(param);
+
+	starpu_top_enqueue_param(param);
 
 	return param;
 }
@@ -477,88 +482,95 @@ starputop_param* starputop_register_parameter_enum(
 *****************UPDATE FUNC******************
 **********************************************/
 
-void starputop_update_data_boolean(const starputop_data* data, int value){
-	if (!starpu_top_status_get())
+void starpu_top_update_data_boolean(const struct starpu_top_data* data, int value)
+{
+	if (!_starpu_top_status_get())
 		return;
 	if(data->active)
 	{
 		char*message = (char *) malloc(256+strlen(data->name));
 		sprintf(message,
-				"U;%d;%d;%lld\n",
+				"U;%u;%d;%lld\n",
 				data->id,
 				(value?1:0),
 				current_timestamp());
-		starputop_message_add(starputop_mt,message);
+		_starpu_top_message_add(_starpu_top_mt,message);
 	}
 }
-void starputop_update_data_integer(const starputop_data* data,int value){
-	if (!starpu_top_status_get())
+
+void starpu_top_update_data_integer(const struct starpu_top_data* data, int value)
+{
+	if (!_starpu_top_status_get())
 		return;
 	if(data->active)
 	{
 		char*message = (char *) malloc(256+strlen(data->name));
 		sprintf(message,
-				"U;%d;%d;%lld\n",
+				"U;%u;%d;%lld\n",
 				data->id,
 				value,
 				current_timestamp());
-		starputop_message_add(starputop_mt,message);
+		_starpu_top_message_add(_starpu_top_mt,message);
 	}
 }
-void starputop_update_data_float(const starputop_data* data, double value){
-	if (!starpu_top_status_get())
+
+void starpu_top_update_data_float(const struct starpu_top_data* data, double value)
+{
+	if (!_starpu_top_status_get())
 		return;
 	if(data->active)
 	{
 		char*message = (char *) malloc(256+strlen(data->name));
 		sprintf(message,
-				"U;%d;%f;%lld\n",
+				"U;%u;%f;%lld\n",
 				data->id, value,
 				current_timestamp());
-		starputop_message_add(starputop_mt,message);
+		_starpu_top_message_add(_starpu_top_mt,message);
 	}
 }
-void starputop_update_parameter(const starputop_param* param){
-	if (!starpu_top_status_get())
+
+void starpu_top_update_parameter(const struct starpu_top_param* param)
+{
+	if (!_starpu_top_status_get())
 		return;
 	char*message = (char *) malloc(50);
 
 	switch(param->type)
 	{
-		case STARPUTOP_PARAM_BOOLEAN:
-		case STARPUTOP_PARAM_INTEGER:
-		case STARPUTOP_PARAM_ENUM:
+		case STARPU_TOP_PARAM_BOOLEAN:
+		case STARPU_TOP_PARAM_INTEGER:
+		case STARPU_TOP_PARAM_ENUM:
 			sprintf(message,
-					"SET;%d;%d;%lld\n",
+					"SET;%u;%d;%lld\n",
 					param->id,
 					*((int*)param->value),
 					current_timestamp());
 			break;
-		
-		case STARPUTOP_PARAM_FLOAT:
+
+		case STARPU_TOP_PARAM_FLOAT:
 			sprintf(message,
-					"SET;%d;%f;%lld\n",
+					"SET;%u;%f;%lld\n",
 					param->id,
 					*((double*)param->value),
 					current_timestamp());
 			break;
 	}
-	
-	starputop_message_add(starputop_mt,message);	
+
+	_starpu_top_message_add(_starpu_top_mt,message);
 }
 
 /*********************************************
 *****************DEBUG FUNC******************
 **********************************************/
 
-void starputop_debug_log(const char* debug_message)
+void starpu_top_debug_log(const char* debug_message)
 {
-	if(starputop_debug_on)
+	if(starpu_top_debug_on)
 	{
 		//length can be up to strlen*2, if message contains only unwanted chars
 		char * message = (char *) malloc(strlen(debug_message)*2+16);
 		sprintf(message,"MESSAGE;");
-		
+
 		//escape unwanted char : ; and \n
 		char* cur = message+8;
 		while(*debug_message!='\0')
@@ -576,12 +588,13 @@ void starputop_debug_log(const char* debug_message)
 		cur++;
 		*cur='\0';
 
-		starputop_message_add(starputop_mt,message);
+		_starpu_top_message_add(_starpu_top_mt,message);
 	}
 }
-void starputop_debug_lock(const char* debug_message)
+
+void starpu_top_debug_lock(const char* debug_message)
 {
-	if(starputop_debug_on)
+	if(starpu_top_debug_on)
 	{
 		char * message = (char *) malloc(strlen(debug_message)*2+16);
 		sprintf(message,"LOCK;");
@@ -600,38 +613,40 @@ void starputop_debug_lock(const char* debug_message)
 		*cur='\n';
 		*(cur+1)='\0';
 
-		starputop_message_add(starputop_mt,message);
+		_starpu_top_message_add(_starpu_top_mt,message);
 
 		//This threads keeps locked while we don't receive an STEP message
-		pthread_mutex_lock(&starputop_wait_for_continue_mutex);
-		pthread_cond_wait(&starputop_wait_for_continue_cond,&starputop_wait_for_continue_mutex);
-		pthread_mutex_unlock(&starputop_wait_for_continue_mutex);
+		_STARPU_PTHREAD_MUTEX_LOCK(&starpu_top_wait_for_continue_mutex);
+		_STARPU_PTHREAD_COND_WAIT(&starpu_top_wait_for_continue_cond,
+					  &starpu_top_wait_for_continue_mutex);
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&starpu_top_wait_for_continue_mutex);
 	}
 }
 
- 
- 
+
+
 /********************************************
  **************TIME FUNCTION****************
  *******************************************/
 
-unsigned long long int current_timestamp()
+unsigned long long current_timestamp()
 {
 	struct timespec now;
-	starpu_clock_gettime(&now);
-	return starpu_timing_timespec_to_ms(&now);
+	_starpu_clock_gettime(&now);
+	return _starpu_top_timing_timespec_to_ms(&now);
 }
 
-unsigned long long starpu_timing_timespec_to_ms(const struct timespec *ts)
+unsigned long long _starpu_top_timing_timespec_to_ms(const struct timespec *ts)
 {
-  return (1000.0*ts->tv_sec) + (0.000001*ts->tv_nsec);
+	return (1000.0*ts->tv_sec) + (0.000001*ts->tv_nsec);
 }
 
 /********************************************
  **************INPUT PROCESSING**************
  *******************************************/
 
-starputop_message_type starputop_get_message_type(const char* message)
+static
+enum starpu_top_message_type starpu_top_get_message_type(const char* message)
 {
 	if(!strncmp("GO\n", message,3))
 		return TOP_TYPE_GO;
@@ -645,108 +660,113 @@ starputop_message_type starputop_get_message_type(const char* message)
 		return TOP_TYPE_DISABLE;
 	else if(!strncmp("DEBUG;", message,6))
 		return TOP_TYPE_DEBUG;
-	else 
+	else
 		return TOP_TYPE_UNKNOW;
 }
 
-
-void starputop_unlock_starpu()
+static
+void starpu_top_unlock_starpu()
 {
-	sem_post(&starputop_wait_for_go);
+	sem_post(&starpu_top_wait_for_go);
 	printf("%s:%d starpu started\n", __FILE__, __LINE__);
 }
 
-void starputop_change_data_active(char* message, int active)
+static
+void starpu_top_change_data_active(char* message, int active)
 {
 	char* debut = strstr(message, ";")+1;
 	char* fin = strstr(debut+1, "\n");
 	*fin = '\0';
 	int data_id = atoi(debut);
 	printf("%s:%d data %d %s\n", __FILE__, __LINE__, data_id, active ? "ENABLED" : "DISABLE");
-	starputop_datas[data_id]->active = active;
+	starpu_top_datas[data_id]->active = active;
 }
 
-void starputop_change_parameter_value(const char* message){
+static
+void starpu_top_change_parameter_value(const char* message)
+{
 	const char*tmp = strstr(message, ";")+1;
 	int param_id = atoi(tmp);
-	starputop_param* param = starputop_params[param_id];
+	struct starpu_top_param* param = starpu_top_params[param_id];
 	tmp = strstr(tmp+1,";")+1;
 	int* val_ptr_int;
 	double* val_ptr_double;
 
 	switch(param->type)
 	{
-		case STARPUTOP_PARAM_BOOLEAN:
-		case STARPUTOP_PARAM_INTEGER:
+		case STARPU_TOP_PARAM_BOOLEAN:
+		case STARPU_TOP_PARAM_INTEGER:
 			val_ptr_int = (int*)param->value;
 			*val_ptr_int = atoi(tmp);
 		break;
-		
-		case STARPUTOP_PARAM_FLOAT:
+
+		case STARPU_TOP_PARAM_FLOAT:
 			val_ptr_double = (double*)param->value;
 			*val_ptr_double = atof(tmp);
 		break;
 
-		case STARPUTOP_PARAM_ENUM:
+		case STARPU_TOP_PARAM_ENUM:
 			val_ptr_int = (int*)param->value;
 			*val_ptr_int = atoi(tmp);
 		break;
-		
+
 	}
 	if(param->callback != NULL)
 		param->callback(param);
 }
 
-void starputop_change_debug_mode(const char*message)
+static
+void starpu_top_change_debug_mode(const char*message)
 {
 	const char* debut = strstr(message, ";")+1;
 	if(!strncmp("ON",debut, 2))
 	{
-		starputop_debug_on = 1;
+		starpu_top_debug_on = 1;
 		printf("%s:%d debug is now ON\n", __FILE__, __LINE__);
 	}
 	else
 	{
-		starputop_debug_on = 0;
+		starpu_top_debug_on = 0;
 		printf("%s:%d debug is now OFF\n", __FILE__, __LINE__);
 	}
 
 	char * m = (char *) malloc(strlen(message)+1);
 	sprintf(m,"%s",message);
-	starputop_message_add(starputop_mt,m);
+	_starpu_top_message_add(_starpu_top_mt,m);
 }
 
 /*
  * Unlock starpu if it was locked in debug state
 */
-void starputop_debug_next_step()
+static
+void starpu_top_debug_next_step()
 {
-	pthread_cond_signal(&starputop_wait_for_continue_cond);
+	_STARPU_PTHREAD_COND_SIGNAL(&starpu_top_wait_for_continue_cond);
 }
 
 
-void starputop_process_input_message(char *buffer)
+void _starpu_top_process_input_message(char *buffer)
 {
-	starputop_message_type message_type = starputop_get_message_type(buffer);
+	enum starpu_top_message_type message_type = starpu_top_get_message_type(buffer);
 	switch(message_type)
 	{
 		case TOP_TYPE_GO:
-			starputop_unlock_starpu();
+			starpu_top_unlock_starpu();
 		break;
 		case TOP_TYPE_ENABLE:
-			starputop_change_data_active(buffer, 1);
+			starpu_top_change_data_active(buffer, 1);
 		break;
 		case TOP_TYPE_DISABLE:
-			starputop_change_data_active(buffer, 0);
+			starpu_top_change_data_active(buffer, 0);
 		break;
 		case TOP_TYPE_SET:
-			starputop_change_parameter_value(buffer);
+			starpu_top_change_parameter_value(buffer);
 		break;
 		case TOP_TYPE_DEBUG:
-			starputop_change_debug_mode(buffer);
+			starpu_top_change_debug_mode(buffer);
 		break;
 		case TOP_TYPE_CONTINUE:
-			starputop_debug_next_step();
+			starpu_top_debug_next_step();
 		break;
 		default:
 			printf("%s:%d unknow message : '%s'\n", __FILE__, __LINE__, buffer);

+ 36 - 36
src/top/starputop_connection.c

@@ -27,8 +27,9 @@
 #  include <netdb.h>
 #endif
 
-#include <top/starputop_connection.h>
-#include <top/starputop_message_queue.h>
+#include <top/starpu_top_core.h>
+#include <top/starpu_top_connection.h>
+#include <top/starpu_top_message_queue.h>
 #include <starpu_top.h>
 #include <pthread.h>
 #include <stdio.h>
@@ -37,85 +38,84 @@
 #include <stdlib.h>
 #include <unistd.h>
 
-const char *STARPUTOP_PORT = "2011";
-const int STARPUTOP_BUFFER_SIZE=1024;
+const char *STARPU_TOP_PORT = "2011";
+const int STARPU_TOP_BUFFER_SIZE=1024;
 
-extern starputop_message_queue_t*  starputop_mt;
+extern struct _starpu_top_message_queue*  _starpu_top_mt;
 
 //client socket after fopen
-FILE* starputop_socket_fd_read;
-FILE* starputop_socket_fd_write;
+FILE* starpu_top_socket_fd_read;
+FILE* starpu_top_socket_fd_write;
 //client socket (file descriptor)
-int starputop_socket_fd;
-
+int starpu_top_socket_fd;
 
+static
 void * message_from_ui(void * p)
 {
 	(void) p;
-	char str[STARPUTOP_BUFFER_SIZE];
+	char str[STARPU_TOP_BUFFER_SIZE];
 	while(1)
 	{
-		char * check=fgets (str, STARPUTOP_BUFFER_SIZE, starputop_socket_fd_read);
+		char * check=fgets (str, STARPU_TOP_BUFFER_SIZE, starpu_top_socket_fd_read);
 
 		printf("Message from UI : %s",str);
 		if (check)
 		{
-			starputop_process_input_message(str);
+			_starpu_top_process_input_message(str);
 		}
 		else
 		{
 			fprintf(stderr,"Connection dropped\n");
 			//unlocking StarPU.
-			starputop_process_input_message("GO\n");
-			starputop_process_input_message("DEBUG;OFF\n");
-			starputop_process_input_message("STEP\n");
+			_starpu_top_process_input_message("GO\n");
+			_starpu_top_process_input_message("DEBUG;OFF\n");
+			_starpu_top_process_input_message("STEP\n");
 			return NULL;
 		}
 	}
-	return NULL;
 }
 
+static
 void * message_to_ui(void * p)
 {
 	(void) p;
 	while(1)
 	{
-		char* message = starputop_message_remove(starputop_mt);
+		char* message = _starpu_top_message_remove(_starpu_top_mt);
 		int len=strlen(message);
-		int check=fwrite(message, sizeof(char), len, starputop_socket_fd_write);
-		int check2=fflush(starputop_socket_fd_write);
+		int check=fwrite(message, sizeof(char), len, starpu_top_socket_fd_write);
+		int check2=fflush(starpu_top_socket_fd_write);
 		free(message);
 		if (check!=len || check2==EOF )
 		{
 			fprintf(stderr,"Connection dropped : message no longer send\n");
 			while(1)
 			{
-				message=starputop_message_remove(starputop_mt);
+				message=_starpu_top_message_remove(_starpu_top_mt);
 				free(message);
 			}
 		}
 	}
-	return NULL;
 }
 
-void starputop_communications_threads_launcher()
+void _starpu_top_communications_threads_launcher()
 {
 	pthread_t from_ui;
 	pthread_t to_ui;
 	pthread_attr_t threads_attr;
 
-  
+
 	//Connection to UI & Socket Initilization
 	printf("%s:%d Connection to UI initilization\n",__FILE__, __LINE__);
 	struct sockaddr_storage from;
 	struct addrinfo req, *ans;
 	int code;
 	req.ai_flags = AI_PASSIVE;
-	req.ai_family = PF_UNSPEC;            
+	req.ai_family = PF_UNSPEC;
 	req.ai_socktype = SOCK_STREAM;
-	req.ai_protocol = 0;  
-  
-	if ((code = getaddrinfo(NULL, STARPUTOP_PORT, &req, &ans)) != 0)
+	req.ai_protocol = 0;
+
+	if ((code = getaddrinfo(NULL, STARPU_TOP_PORT, &req, &ans)) != 0)
 	{
 		fprintf(stderr, " getaddrinfo failed %d\n", code);
 		exit(EXIT_FAILURE);
@@ -134,34 +134,34 @@ void starputop_communications_threads_launcher()
 
 	socklen_t len = sizeof(from);
 
-   	if ((starputop_socket_fd=accept(sock, (struct sockaddr *) &from, &len)) ==-1)
+   	if ((starpu_top_socket_fd=accept(sock, (struct sockaddr *) &from, &len)) ==-1)
 	{
 		fprintf(stderr, "accept error\n");
 		perror("accept");
 		exit(EXIT_FAILURE);
 	}
-	
-	if ( (starputop_socket_fd_read=fdopen(starputop_socket_fd, "r")) == NULL)
+
+	if ( (starpu_top_socket_fd_read=fdopen(starpu_top_socket_fd, "r")) == NULL)
 	{
 		perror("fdopen");
 		exit(EXIT_FAILURE);
 	}
 
-	starputop_socket_fd=dup(starputop_socket_fd);
-	
-	if ((starputop_socket_fd_write=fdopen(starputop_socket_fd, "w")) == NULL)
+	starpu_top_socket_fd=dup(starpu_top_socket_fd);
+
+	if ((starpu_top_socket_fd_write=fdopen(starpu_top_socket_fd, "w")) == NULL)
 	{
 		perror("fdopen");
 		exit(EXIT_FAILURE);
 	}
-	
+
 	close(sock);
-	
+
 	//Threads creation
 	fprintf(stderr,"Threads Creation\n");
 	pthread_attr_init(&threads_attr);
 	pthread_attr_setdetachstate(&threads_attr, PTHREAD_CREATE_DETACHED);
-	
+
 	pthread_create(&from_ui, &threads_attr, message_from_ui, NULL);
 	pthread_create(&to_ui, &threads_attr, message_to_ui, NULL);
 }

+ 11 - 9
src/top/starputop_connection.h

@@ -15,30 +15,32 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#ifndef __STARPUTOP_CONNECTION_H__
-#define __STARPUTOP_CONNECTION_H__
+#ifndef __STARPU_TOP_CONNECTION_H__
+#define __STARPU_TOP_CONNECTION_H__
 
 #include <stdlib.h>
-#include <top/starputop_message_queue.h>
+#include <top/starpu_top_message_queue.h>
 #include <starpu_top.h>
 
 #ifdef __cplusplus
-extern "C" {
+extern "C"
+{
 #endif
-  extern starputop_message_queue_t*  starputop_mt;
+
+extern struct _starpu_top_message_queue* _starpu_top_mt;
 
 /*
  * This function initialize the two communications threads.
  * It initializes the connection and then launches the threads.
  * The function wait the UI connection before launching the threads.
- * About mt : mt MUST be allocated before call. 
- * All messages in the queue are freed after used. 
+ * About mt : mt MUST be allocated before call.
+ * All messages in the queue are freed after used.
  */
-  void starputop_communications_threads_launcher();
+void _starpu_top_communications_threads_launcher();
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif // __STARPUTOP_CONNECTION_H__
+#endif // __STARPU_TOP_CONNECTION_H__
 

+ 57 - 0
src/top/starpu_top_core.h

@@ -0,0 +1,57 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2011 William Braik, Yann Courtois, Jean-Marie Couteyen, Anthony Roy
+ * Copyright (C) 2011, 2012 Centre National de la Recherche Scientifique
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+struct starpu_task;
+
+/*
+ * Convert timespec to ms
+ */
+unsigned long long _starpu_top_timing_timespec_to_ms(const struct timespec *ts);
+
+/*
+ * This function returns 1 if starpu_top is initialized. 0 otherwise.
+ */
+int _starpu_top_status_get();
+
+/*
+ * This functions notify UI than the task has started or ended
+ */
+void _starpu_top_task_started(struct starpu_task *task,
+			     int devid,
+			     const struct timespec* ts);
+void _starpu_top_task_ended(struct starpu_task *task,
+			   int devid,
+			   const struct timespec* ts );
+/*
+ * This functions notify UI than the task have been planed to
+ * run from timestamp_begin to timestamp_end, on computation-core
+ */
+void __starpu_top_task_prevision_timespec(struct starpu_task *task,
+					int devid,
+					const struct timespec* start,
+					const struct timespec* end);
+void _starpu_top_task_prevision(struct starpu_task *task,
+			       int devid, unsigned long long start,
+			       unsigned long long end);
+
+
+/****************************************************
+***************** Callback function *****************
+*****************************************************/
+
+void _starpu_top_process_input_message(char *message);
+

+ 25 - 24
src/top/starputop_message_queue.c

@@ -15,26 +15,26 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include  "starputop_message_queue.h"
-#include  <string.h>
-#include  <stdio.h>
-#include  <stdlib.h>
+#include "starpu_top_message_queue.h"
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <common/utils.h>
 
 //this global queue is used both by API and by network threads
-starputop_message_queue_t*  starputop_mt = NULL;
+struct _starpu_top_message_queue*  _starpu_top_mt = NULL;
 
 
-/* Will always return the pointer to starputop_message_queue */
-starputop_message_queue_t* starputop_message_add(
-			starputop_message_queue_t* s,
-			char* msg)
+/* Will always return the pointer to starpu_top_message_queue */
+struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_message_queue* s,
+							char* msg)
 {
-	starputop_message_queue_item_t* p = (starputop_message_queue_item_t *) malloc( 1 * sizeof(*p) );
-	pthread_mutex_lock(&(s->mutex));
+	struct _starpu_top_message_queue_item* p = (struct _starpu_top_message_queue_item *) malloc( 1 * sizeof(*p) );
+	_STARPU_PTHREAD_MUTEX_LOCK(&(s->mutex));
 	if( NULL == p )
 	{
 		fprintf(stderr, "IN %s, %s: malloc() failed\n", __FILE__, "list_add");
-		pthread_mutex_unlock(&(s->mutex));
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 		return s;
 	}
 
@@ -44,7 +44,7 @@ starputop_message_queue_t* starputop_message_add(
 	if( NULL == s )
 	{
 		printf("Queue not initialized\n");
-		pthread_mutex_unlock(&(s->mutex));
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 		return s;
 	}
 	else if( NULL == s->head && NULL == s->tail )
@@ -52,7 +52,7 @@ starputop_message_queue_t* starputop_message_add(
 		/* printf("Empty list, adding p->num: %d\n\n", p->num);  */
 		sem_post(&(s->semaphore));
 		s->head = s->tail = p;
-		pthread_mutex_unlock(&(s->mutex));
+		_STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 		return s;
 	}
 	else
@@ -62,48 +62,49 @@ starputop_message_queue_t* starputop_message_add(
 		s->tail->next = p;
 		s->tail = p;
 	}
-	pthread_mutex_unlock(&(s->mutex));
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 	return s;
 }
 
 //this is a queue and it is FIFO, so we will always remove the first element
-char* starputop_message_remove(starputop_message_queue_t* s)
+char* _starpu_top_message_remove(struct _starpu_top_message_queue* s)
 {
 	sem_wait(&(s->semaphore));
-	starputop_message_queue_item_t* h = NULL;
-	starputop_message_queue_item_t* p = NULL;
+	struct _starpu_top_message_queue_item* h = NULL;
+	struct _starpu_top_message_queue_item* p = NULL;
 
 	if( NULL == s )
 	{
 		printf("List is null\n");
 		return NULL;
 	}
-	pthread_mutex_lock(&(s->mutex));
+	_STARPU_PTHREAD_MUTEX_LOCK(&(s->mutex));
 	h = s->head;
 	p = h->next;
 	char* value = h->message;
 	free(h);
 	s->head = p;
 
-	
+
 	if( NULL == s->head )
 		//the element tail was pointing to is free(), so we need an update
 		s->tail = s->head;
-	pthread_mutex_unlock(&(s->mutex));
+	_STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 	return value;
 }
 
 
-starputop_message_queue_t* starputop_message_queue_new(void)
+struct _starpu_top_message_queue* _starpu_top_message_queue_new(void)
 {
-	starputop_message_queue_t* p = (starputop_message_queue_t *) malloc( 1 * sizeof(*p));
+	struct _starpu_top_message_queue* p = (struct _starpu_top_message_queue *) malloc( 1 * sizeof(*p));
 	if( NULL == p )
 	{
 		fprintf(stderr, "LINE: %d, malloc() failed\n", __LINE__);
+		return NULL;
 	}
 
 	p->head = p->tail = NULL;
 	sem_init(&(p->semaphore),0,0);
-	pthread_mutex_init(&(p->mutex), NULL);
+	_STARPU_PTHREAD_MUTEX_INIT(&(p->mutex), NULL);
 	return p;
 }

+ 15 - 17
src/top/starputop_message_queue.h

@@ -16,35 +16,33 @@
  */
 
 #include <sys/types.h>
-#include <semaphore.h> 
+#include <semaphore.h>
 #include <pthread.h>
 
-#ifndef __STARPUTOP_MESSAGE_QUEUE_H__
-#define __STARPUTOP_MESSAGE_QUEUE_H__
+#ifndef __STARPU_TOP_MESSAGE_QUEUE_H__
+#define __STARPU_TOP_MESSAGE_QUEUE_H__
 
-typedef struct starputop_message_queue_item
+struct _starpu_top_message_queue_item
 {
 	char *message;
-	struct starputop_message_queue_item* next;
-} starputop_message_queue_item_t;
+	struct _starpu_top_message_queue_item* next;
+};
 
-typedef struct starputop_message_queue
+struct _starpu_top_message_queue
 {
-	struct starputop_message_queue_item* head;
-	struct starputop_message_queue_item* tail;
+	struct _starpu_top_message_queue_item* head;
+	struct _starpu_top_message_queue_item* tail;
 	sem_t semaphore;
 	pthread_mutex_t mutex;
-} starputop_message_queue_t;
+};
 
 
-starputop_message_queue_t *starputop_message_add(
-			starputop_message_queue_t*,
-			char*);
+struct _starpu_top_message_queue *_starpu_top_message_add(struct _starpu_top_message_queue*,
+							char*);
 
-char* starputop_message_remove(starputop_message_queue_t*);
+char* _starpu_top_message_remove(struct _starpu_top_message_queue*);
 
-starputop_message_queue_t* starputop_message_queue_new();
-starputop_message_queue_t* starputop_message_queue_free(
-			starputop_message_queue_t*);
+struct _starpu_top_message_queue* _starpu_top_message_queue_new();
+struct _starpu_top_message_queue* _starpu_top_message_queue_free(struct _starpu_top_message_queue*);
 
 #endif

+ 43 - 46
src/top/starputop_task.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011 William Braik, Yann Courtois, Jean-Marie Couteyen, Anthony
- * Roy
+ * Copyright (C) 2011 William Braik, Yann Courtois, Jean-Marie Couteyen, Anthony Roy
+ * Copyright (C) 2011 Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -16,8 +16,9 @@
  */
 
 #include <starpu_top.h>
-#include <top/starputop_message_queue.h>
-#include <top/starputop_connection.h>
+#include <top/starpu_top_message_queue.h>
+#include <top/starpu_top_connection.h>
+#include <top/starpu_top_core.h>
 #include <core/task.h>
 #include <stdio.h>
 #include <string.h>
@@ -28,70 +29,66 @@
  **************TASK RELATED FUNCTIONS********
  *******************************************/
 
-void starputop_task_started(
-			struct starpu_task *task, 
-			int devid, 
-			const struct timespec *ts)
+void _starpu_top_task_started(struct starpu_task *task,
+			     int devid,
+			     const struct timespec *ts)
 {
 	unsigned long long taskid = _starpu_get_job_associated_to_task(task)->job_id;
-	STARPU_ASSERT(starpu_top_status_get());
+	STARPU_ASSERT(_starpu_top_status_get());
 	char *str = (char *) malloc(sizeof(char)*64);
 	snprintf(str, 64,
 				"START;%llu;%d;%llu\n",
-				taskid, 
-				devid, 
-				starpu_timing_timespec_to_ms(ts));
+				taskid,
+				devid,
+				_starpu_top_timing_timespec_to_ms(ts));
 
-	starputop_message_add(starputop_mt, str);
+	_starpu_top_message_add(_starpu_top_mt, str);
 }
 
-void starputop_task_ended(
-			struct starpu_task *task, 
-			int devid, 
-			const struct timespec *ts)
+void _starpu_top_task_ended(struct starpu_task *task,
+			   int devid,
+			   const struct timespec *ts)
 {
 	unsigned long long taskid = _starpu_get_job_associated_to_task(task)->job_id;
 	(void) devid; //unused
-	STARPU_ASSERT(starpu_top_status_get());
+	STARPU_ASSERT(_starpu_top_status_get());
 	char *str = (char *) malloc(sizeof(char)*64);
 	snprintf(str, 64,
-				"END;%llu;%llu\n", 
-				taskid, 
-				starpu_timing_timespec_to_ms(ts));
+				"END;%llu;%llu\n",
+				taskid,
+				_starpu_top_timing_timespec_to_ms(ts));
 
-	starputop_message_add(starputop_mt, str);
+	_starpu_top_message_add(_starpu_top_mt, str);
 }
 
-void starputop_task_prevision_timespec(
-			struct starpu_task *task,
-			int devid, 
-			const struct timespec* start, 
-			const struct timespec* end)
+void __starpu_top_task_prevision_timespec(struct starpu_task *task,
+					int devid,
+					const struct timespec* start,
+					const struct timespec* end)
 {
-	starputop_task_prevision(task, 
-							devid, 
-							starpu_timing_timespec_to_ms(start),
-							starpu_timing_timespec_to_ms(end));
+	_starpu_top_task_prevision(task,
+				  devid,
+				  _starpu_top_timing_timespec_to_ms(start),
+				  _starpu_top_timing_timespec_to_ms(end));
 }
 
-void starputop_task_prevision(
-			struct starpu_task *task, 
-			int devid, 
-			unsigned long long start, 
-			unsigned long long end)
+void _starpu_top_task_prevision(struct starpu_task *task,
+			       int devid,
+			       unsigned long long start,
+			       unsigned long long end)
 {
 	unsigned long long taskid = _starpu_get_job_associated_to_task(task)->job_id;
-	STARPU_ASSERT(starpu_top_status_get());
+	STARPU_ASSERT(_starpu_top_status_get());
 	struct timespec now;
-	starpu_clock_gettime(&now);
+	_starpu_clock_gettime(&now);
 	char * str= (char *)malloc(sizeof(char)*200);
-	snprintf(str, 128, 
-				"PREV;%llu;%d;%llu;%llu;%llu\n",
-				taskid,
-				devid,
-				starpu_timing_timespec_to_ms(&now),
-				start,
-				end);
+	snprintf(str, 128,
+		 "PREV;%llu;%d;%llu;%llu;%llu\n",
+		 taskid,
+		 devid,
+		 _starpu_top_timing_timespec_to_ms(&now),
+		 start,
+		 end);
 
-	starputop_message_add(starputop_mt, str);
+	_starpu_top_message_add(_starpu_top_mt, str);
 }

+ 12 - 9
src/util/execute_on_all.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -20,7 +20,8 @@
 #include <core/jobs.h>
 #include <core/task.h>
 
-struct wrapper_func_args {
+struct wrapper_func_args
+{
 	void (*func)(void *);
 	void *arg;
 };
@@ -40,16 +41,18 @@ void starpu_execute_on_each_worker(void (*func)(void *), void *arg, uint32_t whe
 	struct starpu_task *tasks[STARPU_NMAXWORKERS];
 
 	/* create a wrapper codelet */
-	struct starpu_codelet_t wrapper_cl = {
+	struct starpu_codelet wrapper_cl =
+	{
 		.where = where,
-		.cuda_func = wrapper_func,
-		.cpu_func = wrapper_func,
-		.opencl_func = wrapper_func,
+		.cuda_funcs = {wrapper_func, NULL},
+		.cpu_funcs = {wrapper_func, NULL},
+		.opencl_funcs = {wrapper_func, NULL},
 		/* XXX we do not handle Cell .. */
 		.nbuffers = 0
 	};
 
-	struct wrapper_func_args args = {
+	struct wrapper_func_args args =
+	{
 		.func = func,
 		.arg = arg
 	};
@@ -68,13 +71,13 @@ void starpu_execute_on_each_worker(void (*func)(void *), void *arg, uint32_t whe
 		tasks[worker]->destroy = 0;
 
 #ifdef STARPU_USE_FXT
-                starpu_job_t job = _starpu_get_job_associated_to_task(tasks[worker]);
+                struct _starpu_job *job = _starpu_get_job_associated_to_task(tasks[worker]);
                 job->model_name = "execute_on_all_wrapper";
 #endif
 
 		_starpu_exclude_task_from_dag(tasks[worker]);
 
-		ret = _starpu_task_submit_internal(tasks[worker]);
+		ret = starpu_task_submit(tasks[worker]);
 		if (ret == -ENODEV)
 		{
 			/* if the worker is not able to execute this tasks, we

+ 9 - 5
src/util/file.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010  Université de Bordeaux 1
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -20,17 +20,21 @@
 
 void _starpu_drop_comments(FILE *f)
 {
-	while(1) {
+	while(1)
+	{
 		int c = getc(f);
 
-		switch (c) {
+		switch (c)
+		{
 			case '#':
 			{
 				char s[128];
 				char *ret;
-				do {
+				do
+				{
 					ret = fgets(s, sizeof(s), f);
-				} while (ret && (!strchr(s, '\n')));
+				}
+				while (ret && (!strchr(s, '\n')));
 			}
 			case '\n':
 				continue;

+ 49 - 26
src/util/malloc.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2009-2010, 2012  Université de Bordeaux 1
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -20,11 +20,13 @@
 #include <core/workers.h>
 #include <common/config.h>
 #include <starpu.h>
+#include <starpu_data.h>
 #include <starpu_cuda.h>
 #include <drivers/opencl/driver_opencl.h>
 
 #if defined(STARPU_USE_CUDA) || defined(STARPU_USE_OPENCL)
-struct malloc_pinned_codelet_struct {
+struct malloc_pinned_codelet_struct
+{
 	void **ptr;
 	size_t dim;
 };
@@ -35,7 +37,7 @@ struct malloc_pinned_codelet_struct {
 //{
 //	struct malloc_pinned_codelet_struct *s = arg;
 //        //        *(s->ptr) = malloc(s->dim);
-//        _starpu_opencl_allocate_memory((void **)(s->ptr), s->dim, CL_MEM_READ_WRITE|CL_MEM_ALLOC_HOST_PTR);
+//        starpu_opencl_allocate_memory((void **)(s->ptr), s->dim, CL_MEM_READ_WRITE|CL_MEM_ALLOC_HOST_PTR);
 //}
 //#endif
 
@@ -52,15 +54,17 @@ static void malloc_pinned_cuda_codelet(void *buffers[] STARPU_ATTRIBUTE_UNUSED,
 #endif
 
 #if defined(STARPU_USE_CUDA)// || defined(STARPU_USE_OPENCL)
-static struct starpu_perfmodel_t malloc_pinned_model = {
+static struct starpu_perfmodel malloc_pinned_model =
+{
 	.type = STARPU_HISTORY_BASED,
 	.symbol = "malloc_pinned"
 };
 
-static starpu_codelet malloc_pinned_cl = {
-	.cuda_func = malloc_pinned_cuda_codelet,
+static struct starpu_codelet malloc_pinned_cl =
+{
+	.cuda_funcs = {malloc_pinned_cuda_codelet, NULL},
 //#ifdef STARPU_USE_OPENCL
-//	.opencl_func = malloc_pinned_opencl_codelet,
+//	.opencl_funcs = {malloc_pinned_opencl_codelet, NULL},
 //#endif
 	.nbuffers = 0,
 	.model = &malloc_pinned_model
@@ -74,12 +78,17 @@ int starpu_malloc(void **A, size_t dim)
 
 	STARPU_ASSERT(A);
 
-	if (_starpu_may_submit_cuda_task())
+	if (_starpu_can_submit_cuda_task())
 	{
 #ifdef STARPU_USE_CUDA
 		int push_res;
 
-		struct malloc_pinned_codelet_struct s = {
+#ifdef STARPU_DEVEL
+#warning TODO: CUDA4 is able to directly allocate from any thread without having to launch a task
+#endif
+
+		struct malloc_pinned_codelet_struct s =
+		{
 			.ptr = A,
 			.dim = dim
 		};
@@ -94,16 +103,17 @@ int starpu_malloc(void **A, size_t dim)
 
 		_starpu_exclude_task_from_dag(task);
 
-		push_res = _starpu_task_submit_internal(task);
+		push_res = starpu_task_submit(task);
 		STARPU_ASSERT(push_res != -ENODEV);
 #endif
 	}
-//	else if (_starpu_may_submit_opencl_task())
+//	else if (_starpu_can_submit_opencl_task())
 //	{
 //#ifdef STARPU_USE_OPENCL
 //		int push_res;
 //
-//		struct malloc_pinned_codelet_struct s = {
+//		struct malloc_pinned_codelet_struct s =
+//		{
 //			.ptr = A,
 //			.dim = dim
 //		};
@@ -118,11 +128,12 @@ int starpu_malloc(void **A, size_t dim)
 //
 //		_starpu_exclude_task_from_dag(task);
 //
-//		push_res = _starpu_task_submit_internal(task);
+//		push_res = starpu_task_submit(task);
 //		STARPU_ASSERT(push_res != -ENODEV);
 //#endif
 //        }
-        else {
+        else
+	{
 		*A = malloc(dim);
 	}
 
@@ -151,15 +162,17 @@ static void free_pinned_cuda_codelet(void *buffers[] STARPU_ATTRIBUTE_UNUSED, vo
 //#endif
 
 #if defined(STARPU_USE_CUDA) // || defined(STARPU_USE_OPENCL)
-static struct starpu_perfmodel_t free_pinned_model = {
+static struct starpu_perfmodel free_pinned_model =
+{
 	.type = STARPU_HISTORY_BASED,
 	.symbol = "free_pinned"
 };
 
-static starpu_codelet free_pinned_cl = {
-	.cuda_func = free_pinned_cuda_codelet,
+static struct starpu_codelet free_pinned_cl =
+{
+	.cuda_funcs = {free_pinned_cuda_codelet, NULL},
 //#ifdef STARPU_USE_OPENCL
-//	.opencl_func = free_pinned_opencl_codelet,
+//	.opencl_funcs = {free_pinned_opencl_codelet, NULL},
 //#endif
 	.nbuffers = 0,
 	.model = &free_pinned_model
@@ -171,9 +184,18 @@ int starpu_free(void *A)
 	if (STARPU_UNLIKELY(!_starpu_worker_may_perform_blocking_calls()))
 		return -EDEADLK;
 
-	if (_starpu_may_submit_cuda_task())
-	{
 #ifdef STARPU_USE_CUDA
+	if (!_starpu_is_initialized())
+	{
+		/* This is especially useful when starpu_free is called from
+ 		 * the GCC-plugin. starpu_shutdown will probably have already
+		 * been called, so we will not be able to submit a task. */
+		cudaError_t err = cudaFreeHost(A);
+		if (STARPU_UNLIKELY(err))
+			STARPU_CUDA_REPORT_ERROR(err);
+	}
+	else if (_starpu_can_submit_cuda_task())
+	{
 		int push_res;
 
                 free_pinned_cl.where = STARPU_CUDA;
@@ -186,11 +208,10 @@ int starpu_free(void *A)
 
 		_starpu_exclude_task_from_dag(task);
 
-		push_res = _starpu_task_submit_internal(task);
+		push_res = starpu_task_submit(task);
 		STARPU_ASSERT(push_res != -ENODEV);
-#endif
 	}
-//	else if (_starpu_may_submit_opencl_task())
+//	else if (_starpu_can_submit_opencl_task())
 //	{
 //#ifdef STARPU_USE_OPENCL
 //		int push_res;
@@ -205,11 +226,13 @@ int starpu_free(void *A)
 //
 //		_starpu_exclude_task_from_dag(task);
 //
-//		push_res = _starpu_task_submit_internal(task);
+//		push_res = starpu_task_submit(task);
 //		STARPU_ASSERT(push_res != -ENODEV);
 //#endif
 //	}
-	else {
+	else
+#endif
+	{
 		free(A);
 	}
 

+ 1 - 1
src/util/starpu_create_sync_task.c

@@ -39,6 +39,6 @@ void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t
 	/* This task does nothing */
 	sync_task->cl = NULL;
 
-	int sync_ret = _starpu_task_submit_internal(sync_task);
+	int sync_ret = starpu_task_submit(sync_task);
 	STARPU_ASSERT(!sync_ret);
 }

+ 32 - 14
src/util/starpu_data_cpy.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010  Université de Bordeaux 1
+ * Copyright (C) 2010, 2012  Université de Bordeaux 1
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -16,7 +16,9 @@
 
 #include <starpu.h>
 #include <common/config.h>
+#include <core/task.h>
 #include <datawizard/datawizard.h>
+#include <util/starpu_data_cpy.h>
 
 static void data_cpy_func(void *descr[], void *cl_arg)
 {
@@ -29,7 +31,8 @@ static void data_cpy_func(void *descr[], void *cl_arg)
 	void *dst_interface = descr[0];
 	void *src_interface = descr[1];
 
-	switch (type) {
+	switch (type)
+	{
 		case STARPU_CPU_WORKER:
 			STARPU_ASSERT(copy_methods->ram_to_ram);
 			copy_methods->ram_to_ram(src_interface, memory_node, dst_interface, memory_node);
@@ -49,43 +52,58 @@ static void data_cpy_func(void *descr[], void *cl_arg)
 
 }
 
-struct starpu_perfmodel_t copy_model = {
+struct starpu_perfmodel copy_model =
+{
 	.type = STARPU_HISTORY_BASED,
 	.symbol = "starpu_data_cpy"
 };
 
-static starpu_codelet copy_cl = {
+static struct starpu_codelet copy_cl =
+{
 	.where = STARPU_CPU|STARPU_CUDA|STARPU_OPENCL,
-	.cpu_func = data_cpy_func,
-	.cuda_func = data_cpy_func,
-	.opencl_func = data_cpy_func,
+	.cpu_funcs = {data_cpy_func, NULL},
+	.cuda_funcs = {data_cpy_func, NULL},
+	.opencl_funcs = {data_cpy_func, NULL},
 	.nbuffers = 2,
+	.modes = {STARPU_W, STARPU_R},
 	.model = &copy_model
 };
 
-int starpu_data_cpy(starpu_data_handle dst_handle, starpu_data_handle src_handle,
-			int asynchronous, void (*callback_func)(void*), void *callback_arg)
+int _starpu_data_cpy(starpu_data_handle_t dst_handle, starpu_data_handle_t src_handle,
+		     int asynchronous, void (*callback_func)(void*), void *callback_arg,
+		     int reduction, struct starpu_task *reduction_dep_task)
 {
 	const struct starpu_data_copy_methods *copy_methods = dst_handle->ops->copy_methods;
 
 	struct starpu_task *task = starpu_task_create();
 	STARPU_ASSERT(task);
 
+	struct _starpu_job *j = _starpu_get_job_associated_to_task(task);
+	if (reduction) {
+		j->reduction_task = reduction;
+		if (reduction_dep_task)
+			starpu_task_declare_deps_array(task, 1, &reduction_dep_task);
+	}
+
 	task->cl = &copy_cl;
 	task->cl_arg = (void *)copy_methods;
 
 	task->callback_func = callback_func;
 	task->callback_arg = callback_arg;
 
-	task->buffers[0].handle = dst_handle;
-	task->buffers[0].mode = STARPU_RW;
-	task->buffers[1].handle = src_handle;
-	task->buffers[1].mode = STARPU_R;
+	task->handles[0] = dst_handle;
+	task->handles[1] = src_handle;
 
 	task->synchronous = !asynchronous;
 
-	int ret = _starpu_task_submit_internal(task);
+	int ret = starpu_task_submit(task);
 	STARPU_ASSERT(!ret);
 
 	return 0;
 }
+
+int starpu_data_cpy(starpu_data_handle_t dst_handle, starpu_data_handle_t src_handle,
+			int asynchronous, void (*callback_func)(void*), void *callback_arg)
+{
+	return _starpu_data_cpy(dst_handle, src_handle, asynchronous, callback_func, callback_arg, 0, NULL);
+}

+ 27 - 0
src/util/starpu_data_cpy.h

@@ -0,0 +1,27 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2012  Université Bordeaux 1
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+#ifndef __STARPU_DATA_CPY_H__
+#define __STARPU_DATA_CPY_H__
+
+#include <starpu.h>
+
+int _starpu_data_cpy(starpu_data_handle_t dst_handle, starpu_data_handle_t src_handle,
+			int asynchronous, void (*callback_func)(void*), void *callback_arg,
+			int reduction, struct starpu_task *reduction_dep_task);
+
+#endif // __STARPU_DATA_CPY_H__
+

+ 9 - 8
src/util/starpu_insert_task.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010  Université de Bordeaux 1
- * Copyright (C) 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -23,7 +23,7 @@
 #include <stdarg.h>
 #include <util/starpu_insert_task_utils.h>
 
-void starpu_pack_cl_args(char **arg_buffer, size_t *arg_buffer_size, ...)
+void starpu_codelet_pack_args(char **arg_buffer, size_t *arg_buffer_size, ...)
 {
 	va_list varg_list;
 
@@ -32,16 +32,16 @@ void starpu_pack_cl_args(char **arg_buffer, size_t *arg_buffer_size, ...)
         *arg_buffer_size = _starpu_insert_task_get_arg_size(varg_list);
 
 	va_start(varg_list, arg_buffer_size);
-	_starpu_pack_cl_args(*arg_buffer_size, arg_buffer, varg_list);
+	_starpu_codelet_pack_args(*arg_buffer_size, arg_buffer, varg_list);
 }
 
-void starpu_unpack_cl_args(void *_cl_arg, ...)
+void starpu_codelet_unpack_args(void *_cl_arg, ...)
 {
 	unsigned char *cl_arg = (unsigned char *) _cl_arg;
 	unsigned current_arg_offset = 0;
 	va_list varg_list;
 
-	assert(cl_arg);
+	STARPU_ASSERT(cl_arg);
 	va_start(varg_list, _cl_arg);
 
 	/* We fill the different pointers with the appropriate arguments */
@@ -55,14 +55,15 @@ void starpu_unpack_cl_args(void *_cl_arg, ...)
 		size_t arg_size = *(size_t *)&cl_arg[current_arg_offset];
 		current_arg_offset += sizeof(size_t);
 
-		memcpy(argptr, &cl_arg[current_arg_offset], arg_size); 
+		memcpy(argptr, &cl_arg[current_arg_offset], arg_size);
 		current_arg_offset += arg_size;
 	}
 
 	va_end(varg_list);
+	free(cl_arg);
 }
 
-int starpu_insert_task(starpu_codelet *cl, ...)
+int starpu_insert_task(struct starpu_codelet *cl, ...)
 {
 	va_list varg_list;
 
@@ -73,7 +74,7 @@ int starpu_insert_task(starpu_codelet *cl, ...)
 
 	va_start(varg_list, cl);
 	char *arg_buffer;
-	_starpu_pack_cl_args(arg_buffer_size, &arg_buffer, varg_list);
+	_starpu_codelet_pack_args(arg_buffer_size, &arg_buffer, varg_list);
 
 	va_start(varg_list, cl);
         struct starpu_task *task = starpu_task_create();

+ 102 - 46
src/util/starpu_insert_task_utils.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2011, 2012  Centre National de la Recherche Scientifique
  * Copyright (C) 2011  INRIA
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -19,13 +19,14 @@
 #include <common/config.h>
 #include <common/utils.h>
 
-typedef void (*callback_func_t)(void *);
+typedef void (*_starpu_callback_func_t)(void *);
 
 /* Deal with callbacks. The unpack function may be called multiple times when
  * we have a parallel task, and we should not free the cl_arg parameter from
  * the callback function. */
-struct insert_task_cb_wrapper {
-	callback_func_t callback_func;
+struct insert_task_cb_wrapper
+{
+	_starpu_callback_func_t callback_func;
 	void *callback_arg;
 	void *arg_stack;
 };
@@ -39,8 +40,7 @@ void starpu_task_insert_callback_wrapper(void *_cl_arg_wrapper)
 	if (cl_arg_wrapper->callback_func)
 		cl_arg_wrapper->callback_func(cl_arg_wrapper->callback_arg);
 
-	/* Free the stack of arguments */
-	free(cl_arg_wrapper->arg_stack);
+	free(cl_arg_wrapper);
 }
 
 size_t _starpu_insert_task_get_arg_size(va_list varg_list)
@@ -52,31 +52,44 @@ size_t _starpu_insert_task_get_arg_size(va_list varg_list)
 
 	arg_buffer_size += sizeof(char);
 
-	while ((arg_type = va_arg(varg_list, int)) != 0) {
-		if (arg_type==STARPU_R || arg_type==STARPU_W || arg_type==STARPU_RW || arg_type == STARPU_SCRATCH || arg_type == STARPU_REDUX) {
-			va_arg(varg_list, starpu_data_handle);
+	while ((arg_type = va_arg(varg_list, int)) != 0)
+	{
+		if (arg_type==STARPU_R || arg_type==STARPU_W || arg_type==STARPU_RW || arg_type == STARPU_SCRATCH || arg_type == STARPU_REDUX)
+		{
+			(void)va_arg(varg_list, starpu_data_handle_t);
 		}
-		else if (arg_type==STARPU_VALUE) {
-			va_arg(varg_list, void *);
+		else if (arg_type==STARPU_VALUE)
+		{
+			(void)va_arg(varg_list, void *);
 			size_t cst_size = va_arg(varg_list, size_t);
 
 			arg_buffer_size += sizeof(size_t);
 			arg_buffer_size += cst_size;
 		}
-		else if (arg_type==STARPU_CALLBACK) {
-			va_arg(varg_list, callback_func_t);
+		else if (arg_type==STARPU_CALLBACK)
+		{
+			(void)va_arg(varg_list, _starpu_callback_func_t);
 		}
-		else if (arg_type==STARPU_CALLBACK_ARG) {
+		else if (arg_type==STARPU_CALLBACK_WITH_ARG)
+		{
+			va_arg(varg_list, _starpu_callback_func_t);
 			va_arg(varg_list, void *);
 		}
-		else if (arg_type==STARPU_PRIORITY) {
-			va_arg(varg_list, int);
+		else if (arg_type==STARPU_CALLBACK_ARG)
+		{
+			(void)va_arg(varg_list, void *);
 		}
-		else if (arg_type==STARPU_EXECUTE_ON_NODE) {
-			va_arg(varg_list, int);
+		else if (arg_type==STARPU_PRIORITY)
+		{
+			(void)va_arg(varg_list, int);
 		}
-		else if (arg_type==STARPU_EXECUTE_ON_DATA) {
-			va_arg(varg_list, starpu_data_handle);
+		else if (arg_type==STARPU_EXECUTE_ON_NODE)
+		{
+			(void)va_arg(varg_list, int);
+		}
+		else if (arg_type==STARPU_EXECUTE_ON_DATA)
+		{
+			(void)va_arg(varg_list, starpu_data_handle_t);
 		}
 	}
 
@@ -84,7 +97,7 @@ size_t _starpu_insert_task_get_arg_size(va_list varg_list)
         return arg_buffer_size;
 }
 
-int _starpu_pack_cl_args(size_t arg_buffer_size, char **arg_buffer, va_list varg_list)
+int _starpu_codelet_pack_args(size_t arg_buffer_size, char **arg_buffer, va_list varg_list)
 {
         int arg_type;
 	unsigned current_arg_offset = 0;
@@ -101,7 +114,7 @@ int _starpu_pack_cl_args(size_t arg_buffer_size, char **arg_buffer, va_list varg
 	{
 		if (arg_type==STARPU_R || arg_type==STARPU_W || arg_type==STARPU_RW || arg_type == STARPU_SCRATCH || arg_type == STARPU_REDUX)
 		{
-			va_arg(varg_list, starpu_data_handle);
+			(void)va_arg(varg_list, starpu_data_handle_t);
 		}
 		else if (arg_type==STARPU_VALUE)
 		{
@@ -120,29 +133,47 @@ int _starpu_pack_cl_args(size_t arg_buffer_size, char **arg_buffer, va_list varg
 		}
 		else if (arg_type==STARPU_CALLBACK)
 		{
-			va_arg(varg_list, callback_func_t);
+			(void)va_arg(varg_list, _starpu_callback_func_t);
 		}
-		else if (arg_type==STARPU_CALLBACK_ARG) {
+		else if (arg_type==STARPU_CALLBACK_WITH_ARG)
+		{
+			va_arg(varg_list, _starpu_callback_func_t);
 			va_arg(varg_list, void *);
 		}
+		else if (arg_type==STARPU_CALLBACK_ARG)
+		{
+			(void)va_arg(varg_list, void *);
+		}
 		else if (arg_type==STARPU_PRIORITY)
 		{
-			va_arg(varg_list, int);
+			(void)va_arg(varg_list, int);
 		}
-		else if (arg_type==STARPU_EXECUTE_ON_NODE) {
-			va_arg(varg_list, int);
+		else if (arg_type==STARPU_EXECUTE_ON_NODE)
+		{
+			(void)va_arg(varg_list, int);
 		}
-		else if (arg_type==STARPU_EXECUTE_ON_DATA) {
-			va_arg(varg_list, starpu_data_handle);
+		else if (arg_type==STARPU_EXECUTE_ON_DATA)
+		{
+			(void)va_arg(varg_list, starpu_data_handle_t);
 		}
 	}
 
-	(*arg_buffer)[0] = nargs;
+	if (nargs)
+	{
+		(*arg_buffer)[0] = nargs;
+	}
+	else
+	{
+		free(*arg_buffer);
+		*arg_buffer = NULL;
+	}
+
 	va_end(varg_list);
 	return 0;
 }
 
-int _starpu_insert_task_create_and_submit(char *arg_buffer, starpu_codelet *cl, struct starpu_task **task, va_list varg_list) {
+int _starpu_insert_task_create_and_submit(char *arg_buffer, struct starpu_codelet *cl, struct starpu_task **task, va_list varg_list)
+{
         int arg_type;
 	unsigned current_buffer = 0;
 
@@ -157,41 +188,59 @@ int _starpu_insert_task_create_and_submit(char *arg_buffer, starpu_codelet *cl,
 		if (arg_type==STARPU_R || arg_type==STARPU_W || arg_type==STARPU_RW || arg_type == STARPU_SCRATCH || arg_type == STARPU_REDUX)
 		{
 			/* We have an access mode : we expect to find a handle */
-			starpu_data_handle handle = va_arg(varg_list, starpu_data_handle);
+			starpu_data_handle_t handle = va_arg(varg_list, starpu_data_handle_t);
 
-			starpu_access_mode mode = arg_type;
+			enum starpu_access_mode mode = (enum starpu_access_mode) arg_type;
 
-			(*task)->buffers[current_buffer].handle = handle;
-			(*task)->buffers[current_buffer].mode = mode;
+			(*task)->handles[current_buffer] = handle;
+			if (cl->modes[current_buffer])
+				STARPU_ASSERT(cl->modes[current_buffer] == mode);
+			else
+#ifdef STARPU_DEVEL
+#  warning shall we print a warning to the user
+#endif
+				cl->modes[current_buffer] = mode;
 
 			current_buffer++;
 		}
 		else if (arg_type==STARPU_VALUE)
 		{
-			va_arg(varg_list, void *);
-			va_arg(varg_list, size_t);
+			(void)va_arg(varg_list, void *);
+			(void)va_arg(varg_list, size_t);
 		}
 		else if (arg_type==STARPU_CALLBACK)
 		{
 			void (*callback_func)(void *);
-			callback_func = va_arg(varg_list, callback_func_t);
+			callback_func = va_arg(varg_list, _starpu_callback_func_t);
 			cl_arg_wrapper->callback_func = callback_func;
 		}
-		else if (arg_type==STARPU_CALLBACK_ARG) {
+		else if (arg_type==STARPU_CALLBACK_WITH_ARG)
+		{
+			void (*callback_func)(void *);
+			void *callback_arg;
+			callback_func = va_arg(varg_list, _starpu_callback_func_t);
+			callback_arg = va_arg(varg_list, void *);
+			cl_arg_wrapper->callback_func = callback_func;
+			cl_arg_wrapper->callback_arg = callback_arg;
+		}
+		else if (arg_type==STARPU_CALLBACK_ARG)
+		{
 			void *callback_arg = va_arg(varg_list, void *);
 			cl_arg_wrapper->callback_arg = callback_arg;
 		}
 		else if (arg_type==STARPU_PRIORITY)
 		{
 			/* Followed by a priority level */
-			int prio = va_arg(varg_list, int); 
+			int prio = va_arg(varg_list, int);
 			(*task)->priority = prio;
 		}
-		else if (arg_type==STARPU_EXECUTE_ON_NODE) {
-			va_arg(varg_list, int);
+		else if (arg_type==STARPU_EXECUTE_ON_NODE)
+		{
+			(void)va_arg(varg_list, int);
 		}
-		else if (arg_type==STARPU_EXECUTE_ON_DATA) {
-			va_arg(varg_list, starpu_data_handle);
+		else if (arg_type==STARPU_EXECUTE_ON_DATA)
+		{
+			(void)va_arg(varg_list, starpu_data_handle_t);
 		}
 		else if (arg_type==STARPU_HYPERVISOR_TAG) {
 			int hypervisor_tag = va_arg(varg_list, int);
@@ -211,10 +260,17 @@ int _starpu_insert_task_create_and_submit(char *arg_buffer, starpu_codelet *cl,
 	(*task)->callback_func = starpu_task_insert_callback_wrapper;
 	(*task)->callback_arg = cl_arg_wrapper;
 
-	 int ret = starpu_task_submit(*task);
+	int ret = starpu_task_submit(*task);
 
 	if (STARPU_UNLIKELY(ret == -ENODEV))
-          fprintf(stderr, "submission of task %p wih codelet %p failed (symbol `%s')\n", *task, (*task)->cl, ((*task)->cl->model && (*task)->cl->model->symbol)?(*task)->cl->model->symbol:"none");
+	{
+		fprintf(stderr, "submission of task %p wih codelet %p failed (symbol `%s')\n",
+			*task, (*task)->cl,
+			(*task)->cl->name ? (*task)->cl->name :
+			((*task)->cl->model && (*task)->cl->model->symbol)?(*task)->cl->model->symbol:"none");
+		free(cl_arg_wrapper->arg_stack);
+		free(cl_arg_wrapper);
+	}
 
         return ret;
 }

+ 3 - 3
src/util/starpu_insert_task_utils.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -22,8 +22,8 @@
 #include <starpu.h>
 
 size_t _starpu_insert_task_get_arg_size(va_list varg_list);
-int _starpu_pack_cl_args(size_t arg_buffer_size, char **arg_buffer, va_list varg_list);
-int _starpu_insert_task_create_and_submit(char *arg_buffer, starpu_codelet *cl, struct starpu_task **task, va_list varg_list);
+int _starpu_codelet_pack_args(size_t arg_buffer_size, char **arg_buffer, va_list varg_list);
+int _starpu_insert_task_create_and_submit(char *arg_buffer, struct starpu_codelet *cl, struct starpu_task **task, va_list varg_list);
 
 #endif // __STARPU_INSERT_TASK_UTILS_H__
 

+ 25 - 6
src/util/starpu_task_list.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010  Université de Bordeaux 1
+ * Copyright (C) 2010-2011  Université de Bordeaux 1
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -29,7 +29,8 @@ void starpu_task_list_push_front(struct starpu_task_list *list,
 	{
 		list->tail = task;
 	}
-	else {
+	else
+	{
 		list->head->prev = task;
 	}
 
@@ -45,7 +46,8 @@ void starpu_task_list_push_back(struct starpu_task_list *list,
 	{
 		list->head = task;
 	}
-	else {
+	else
+	{
 		list->tail->next = task;
 	}
 
@@ -78,7 +80,8 @@ void starpu_task_list_erase(struct starpu_task_list *list,
 	{
 		p->next = task->next;
 	}
-	else {
+	else
+	{
 		list->head = task->next;
 	}
 
@@ -86,7 +89,8 @@ void starpu_task_list_erase(struct starpu_task_list *list,
 	{
 		task->next->prev = p;
 	}
-	else {
+	else
+	{
 		list->tail = p;
 	}
 
@@ -103,7 +107,7 @@ struct starpu_task *starpu_task_list_pop_front(struct starpu_task_list *list)
 
 	return task;
 }
-						
+
 struct starpu_task *starpu_task_list_pop_back(struct starpu_task_list *list)
 {
 	struct starpu_task *task = list->tail;
@@ -113,3 +117,18 @@ struct starpu_task *starpu_task_list_pop_back(struct starpu_task_list *list)
 
 	return task;
 }
+
+struct starpu_task *starpu_task_list_begin(struct starpu_task_list *list)
+{
+	return list->head;
+}
+
+struct starpu_task *starpu_task_list_end(struct starpu_task_list *list __attribute__ ((unused)))
+{
+	return NULL;
+}
+
+struct starpu_task *starpu_task_list_next(struct starpu_task *task)
+{
+	return task->next;
+}