Pārlūkot izejas kodu

- add support for Temanejo/Ayudame version 2

Olivier Aumage 8 gadi atpakaļ
vecāks
revīzija
cabe2dab63

+ 1 - 0
ChangeLog

@@ -21,6 +21,7 @@ StarPU 1.3.0 (svn revision xxxx)
 New features:
   * New scheduler with heterogeneous priorities
   * Support priorities for data transfers.
+  * Add support for Ayudame version 2.x debugging library.
 
 Small features:
   * Scheduling contexts may now be associated a user data pointer at creation

+ 45 - 3
configure.ac

@@ -3,8 +3,7 @@
 # Copyright (C) 2009-2016  Université de Bordeaux
 # Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
 # Copyright (C) 2011  Télécom-SudParis
-# Copyright (C) 2011, 2012, 2014  INRIA
-# Copyright (C) 2015, 2016  Inria
+# Copyright (C) 2011, 2012, 2014-2016  INRIA
 #
 # 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
@@ -1677,7 +1676,50 @@ fi
 
 AC_CHECK_HEADERS([glpk.h], [AC_DEFINE([STARPU_HAVE_GLPK_H], [1], [Define to 1 if you have the <glpk.h> header file.])])
 STARPU_HAVE_LIBRARY(GLPK, [glpk])
+
+AC_ARG_WITH(ayudame1-include-dir,
+	[AS_HELP_STRING([--with-ayudame1-include-dir=<path>],
+	[specify where Ayudame version 1 headers are installed])],
+	[
+		ayudame1_include_dir="$withval"
+		if test -n "$ayudame1_include_dir"; then
+			CPPFLAGS="-I$ayudame1_include_dir $CPPFLAGS"
+		fi
+	], [ayudame1_include_dir=no])
+AC_ARG_WITH(ayudame2-include-dir,
+	[AS_HELP_STRING([--with-ayudame2-include-dir=<path>],
+	[specify where Ayudame version 2 headers are installed])],
+	[
+		ayudame2_include_dir="$withval"
+		if test -n "$ayudame2_include_dir"; then
+			CPPFLAGS="-I$ayudame2_include_dir $CPPFLAGS"
+		fi
+	], [ayudame2_include_dir=no])
+
+# Ayudame 1 header is capitalized
 AC_CHECK_HEADERS([Ayudame.h])
+AC_ARG_ENABLE(ayudame1, [AS_HELP_STRING([--disable-ayudame1],
+				   [Do not use Ayudame lib version 1])],
+				   enable_ayudame1=$enableval, enable_ayudame1=yes)
+# Ayudame 2 header is lowercase
+AC_CHECK_HEADERS([ayudame.h])
+AC_ARG_ENABLE(ayudame2, [AS_HELP_STRING([--disable-ayudame2],
+				   [Do not use Ayudame lib version 2])],
+				   enable_ayudame2=$enableval, enable_ayudame2=yes)
+if test x$enable_ayudame1 = xyes -a x$ac_cv_header_Ayudame_h = xyes; then
+   AC_DEFINE([STARPU_USE_AYUDAME1], [1], [Define to 1 if Ayudame 1 is available and should be used])
+   ayu_msg="yes, use version 1"
+else
+   if test x$enable_ayudame2 = xyes -a x$ac_cv_header_ayudame_h = xyes; then
+      AC_DEFINE([STARPU_USE_AYUDAME2], [1], [Define to 1 if Ayudame 2 is available and should be used])
+      ayu_msg="yes, use version 2"
+   else
+      ayu_msg="no"
+   fi
+fi
+
+AM_CONDITIONAL([STARPU_USE_AYUDAME1], [test "x$enable_ayudame1" = "xyes"])
+AM_CONDITIONAL([STARPU_USE_AYUDAME2], [test "x$enable_ayudame2" = "xyes"])
 
 ###############################################################################
 #                                                                             #
@@ -2921,7 +2963,7 @@ AC_MSG_NOTICE([
                SOCL test suite:                             $run_socl_check
                Scheduler Hypervisor:                        $build_sc_hypervisor
                simgrid enabled:                             $enable_simgrid
-               ayudame enabled:                             $ac_cv_header_Ayudame_h
+               ayudame enabled:                             $ayu_msg
 	       Native fortran support:                      $enable_build_fortran
 	       Native MPI fortran support:                  $use_mpi_fort
 ])

+ 3 - 2
src/core/debug.c

@@ -2,6 +2,7 @@
  *
  * Copyright (C) 2009-2013  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2013, 2015  CNRS
+ * Copyright (C) 2016  Inria
  *
  * 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
@@ -73,7 +74,7 @@ void _starpu_print_to_logfile(const char *format STARPU_ATTRIBUTE_UNUSED, ...)
 }
 
 /* Record codelet to give ayudame nice function ids starting from 0. */
-#ifdef HAVE_AYUDAME_H
+#if defined(STARPU_USE_AYUDAME1)
 struct ayudame_codelet
 {
 	char *name;
@@ -119,4 +120,4 @@ int64_t _starpu_ayudame_get_func_id(struct starpu_codelet *cl)
 	STARPU_PTHREAD_MUTEX_UNLOCK(&ayudame_mutex);
 	return i + 1;
 }
-#endif
+#endif /* AYUDAME1 */

+ 265 - 2
src/core/debug.h

@@ -2,6 +2,7 @@
  *
  * Copyright (C) 2009-2013, 2016  Université de Bordeaux
  * Copyright (C) 2010, 2011  CNRS
+ * Copyright (C) 2016  Inria
  *
  * 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
@@ -25,8 +26,268 @@
 #include <common/config.h>
 #include <core/workers.h>
 
-#ifdef HAVE_AYUDAME_H
-#include <Ayudame.h>
+#if defined(STARPU_USE_AYUDAME1)
+/* Ayudame 1 API */
+# include <Ayudame.h>
+# ifndef AYU_RT_STARPU
+#  define AYU_RT_STARPU 4
+# endif
+# define STARPU_AYU_EVENT AYU_event
+
+# define STARPU_AYU_PREINIT() \
+	if (AYU_event) \
+	{ \
+		enum ayu_runtime_t ayu_rt = AYU_RT_STARPU; \
+		AYU_event(AYU_PREINIT, 0, (void*) &ayu_rt); \
+	}
+
+# define STARPU_AYU_INIT() \
+	if (AYU_event) \
+	{ \
+		AYU_event(AYU_INIT, 0, NULL); \
+	}
+
+# define STARPU_AYU_FINISH() \
+	if (AYU_event) \
+	{ \
+		AYU_event(AYU_FINISH, 0, NULL); \
+	}
+
+# define STARPU_AYU_ADDDEPENDENCY(previous, handle, job_id) \
+	if (AYU_event) \
+	{ \
+		uintptr_t __AYU_data[3] = { (previous), (uintptr_t) (handle), (uintptr_t) (handle) }; \
+		AYU_event(AYU_ADDDEPENDENCY, (job_id), __AYU_data); \
+	}
+
+# define STARPU_AYU_REMOVETASK(job_id) \
+	if (AYU_event) \
+	{ \
+		AYU_event(AYU_REMOVETASK, (job_id), NULL); \
+	}
+
+# define STARPU_AYU_ADDTASK(job_id, task) \
+	if (AYU_event) \
+	{ \
+		int64_t __AYU_data[2] = { \
+			((struct starpu_task *)(task))!=NULL?_starpu_ayudame_get_func_id(((struct starpu_task *)(task))->cl):0, \
+			((struct starpu_task *)(task))!=NULL?((struct starpu_task *)(task))->priority-STARPU_MIN_PRIO:0 \
+		}; \
+		AYU_event(AYU_ADDTASK, (job_id), __AYU_data); \
+	}
+
+# define STARPU_AYU_PRERUNTASK(job_id, workerid) \
+	if (AYU_event) \
+	{ \
+		intptr_t __id = (workerid); \
+		AYU_event(AYU_PRERUNTASK, (job_id), &__id); \
+	}
+
+# define STARPU_AYU_RUNTASK(job_id) \
+	if (AYU_event) \
+	{ \
+		AYU_event(AYU_RUNTASK, (job_id), NULL); \
+	}
+
+# define STARPU_AYU_POSTRUNTASK(job_id) \
+	if (AYU_event) \
+	{ \
+		AYU_event(AYU_POSTRUNTASK, (job_id), NULL); \
+	}
+
+# define STARPU_AYU_ADDTOTASKQUEUE(job_id, worker_id) \
+	if (AYU_event) \
+	{ \
+		intptr_t __id = (worker_id); \
+		AYU_event(AYU_ADDTASKTOQUEUE, (job_id), &__id); \
+	}
+
+# define STARPU_AYU_BARRIER() \
+	if (AYU_event) \
+	{ \
+		AYU_event(AYU_BARRIER, 0, NULL); \
+	}
+
+#elif defined(STARPU_USE_AYUDAME2)
+/* Ayudame 2 API */
+# include <ayudame.h>
+# define STARPU_AYU_EVENT ayu_event
+
+# define STARPU_AYU_PREINIT()
+
+# define STARPU_AYU_INIT()
+
+# define STARPU_AYU_FINISH() \
+	if (ayu_event){ \
+		ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
+		ayu_event_data_t __data; \
+		__data.common.client_id = __cli_id; \
+		ayu_event(AYU_FINISH, __data); \
+	}
+
+# define STARPU_AYU_ADDDEPENDENCY(previous, handle, job_id) \
+	if (ayu_event) \
+	{ \
+		ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
+		ayu_event_data_t __data; \
+		uint64_t __dep_id=0; \
+		__dep_id |= (previous) << 0; \
+		__dep_id |= (job_id) << 24; \
+		__dep_id |= (uintptr_t) (handle) << 48; \
+		__data.common.client_id = __cli_id; \
+		__data.add_dependency.dependency_id = __dep_id; \
+		__data.add_dependency.from_id=(previous); \
+		__data.add_dependency.to_id=(job_id); \
+		__data.add_dependency.dependency_label = "dep"; \
+		ayu_event(AYU_ADDDEPENDENCY, __data); \
+		ayu_wipe_data(&__data); \
+		\
+		char __buf[32]; \
+		snprintf(__buf, 32, "%llu", (unsigned long long)(uintptr_t) (handle)); \
+		__data.common.client_id = __cli_id; \
+		__data.set_property.property_owner_id = __dep_id; \
+		__data.set_property.key = "dep_address_value"; \
+		__data.set_property.value = __buf; \
+		ayu_event(AYU_SETPROPERTY, __data); \
+		ayu_wipe_data(&__data); \
+	}
+
+# define STARPU_AYU_REMOVETASK(job_id) \
+	if (ayu_event) \
+	{ \
+		ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
+		ayu_event_data_t __data; \
+		__data.common.client_id = __cli_id; \
+		__data.set_property.property_owner_id = (job_id); \
+		__data.set_property.key = "state"; \
+		__data.set_property.value = "finished"; \
+		ayu_event(AYU_SETPROPERTY, __data); \
+		ayu_wipe_data(&__data); \
+	}
+
+# define STARPU_AYU_ADDTASK(job_id, task) \
+	if (ayu_event) \
+	{ \
+		ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
+		ayu_event_data_t __data; \
+		__data.common.client_id = __cli_id; \
+		__data.add_task.task_id = (job_id); \
+		__data.add_task.scope_id = 0; \
+		__data.add_task.task_label = "task"; \
+		ayu_event(AYU_ADDTASK, __data); \
+		ayu_wipe_data(&__data); \
+		\
+		if ((task) != NULL) \
+		{ \
+			char __buf[32]; \
+			snprintf(__buf, 32, "%d", ((struct starpu_task *)(task))->priority); \
+			__data.common.client_id = __cli_id; \
+			__data.set_property.property_owner_id = (job_id); \
+			__data.set_property.key = "priority"; \
+			__data.set_property.value = __buf; \
+			ayu_event(AYU_SETPROPERTY, __data); \
+			ayu_wipe_data(&__data); \
+			\
+			const char *__name = ((struct starpu_task *)(task))->name != NULL?((struct starpu_task *)(task))->name: \
+			             ((struct starpu_task *)(task))->cl->name != NULL?((struct starpu_task *)(task))->cl->name:"<no_name>"; \
+			__data.common.client_id = __cli_id; \
+			__data.set_property.property_owner_id = (job_id); \
+			__data.set_property.key = "function_name"; \
+			__data.set_property.value = __name; \
+			ayu_event(AYU_SETPROPERTY, __data); \
+			ayu_wipe_data(&__data); \
+		} \
+	}
+
+# define STARPU_AYU_PRERUNTASK(job_id, workerid) \
+	if (ayu_event) \
+	{ \
+		ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
+		ayu_event_data_t __data; \
+		__data.common.client_id = __cli_id; \
+		__data.set_property.property_owner_id = (job_id); \
+		__data.set_property.key = "state"; \
+		__data.set_property.value = "running"; \
+		ayu_event(AYU_SETPROPERTY, __data); \
+		ayu_wipe_data(&__data); \
+		\
+		char __buf[32]; \
+		snprintf(__buf, 32, "%d", (workerid)); \
+		__data.common.client_id = __cli_id; \
+		__data.set_property.property_owner_id = (job_id); \
+		__data.set_property.key = "worker"; \
+		__data.set_property.value = __buf; \
+		ayu_event(AYU_SETPROPERTY, __data); \
+		ayu_wipe_data(&__data); \
+	}
+
+# define STARPU_AYU_RUNTASK(job_id) \
+	if (ayu_event) { \
+		ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
+		ayu_event_data_t __data; \
+		__data.common.client_id = __cli_id; \
+		__data.set_property.property_owner_id = (job_id); \
+		__data.set_property.key = "state"; \
+		__data.set_property.value = "running"; \
+		ayu_event(AYU_SETPROPERTY, __data); \
+		ayu_wipe_data(&__data); \
+	}
+
+# define STARPU_AYU_POSTRUNTASK(job_id) \
+	if (ayu_event) \
+	{ \
+		/* TODO ADD thread id core id etc */ \
+		ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
+		ayu_event_data_t __data; \
+		__data.common.client_id = __cli_id; \
+		__data.set_property.property_owner_id = (job_id); \
+		__data.set_property.key = "state"; \
+		__data.set_property.value = "finished"; \
+		ayu_event(AYU_SETPROPERTY, __data); \
+		ayu_wipe_data(&__data); \
+	}
+
+# define STARPU_AYU_ADDTOTASKQUEUE(job_id, worker_id) \
+	if (ayu_event) \
+	{ \
+		ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
+		ayu_event_data_t __data; \
+		__data.common.client_id = __cli_id; \
+		__data.set_property.property_owner_id = (job_id); \
+		__data.set_property.key = "state"; \
+		__data.set_property.value = "queued"; \
+		ayu_event(AYU_SETPROPERTY, __data); \
+		ayu_wipe_data(&__data); \
+		\
+		char __buf[32]; \
+		snprintf(__buf, 32, "%d", (int)(worker_id)); \
+		__data.common.client_id = __cli_id; \
+		__data.set_property.property_owner_id = (job_id); \
+		__data.set_property.key = "worker"; \
+		__data.set_property.value = __buf; \
+		ayu_event(AYU_SETPROPERTY, __data); \
+		ayu_wipe_data(&__data); \
+ 	}
+
+# define STARPU_AYU_BARRIER() \
+	if (ayu_event) \
+	{ \
+		/* How to generate a barrier event with Ayudame 2? */ \
+	}
+#else
+# define STARPU_AYU_EVENT (0)
+# define STARPU_AYU_PREINIT()
+# define STARPU_AYU_INIT()
+# define STARPU_AYU_FINISH()
+# define STARPU_AYU_ADDDEPENDENCY(previous, handle, next_job)
+# define STARPU_AYU_REMOVETASK(job_id)
+# define STARPU_AYU_ADDTASK(job_id, task)
+# define STARPU_AYU_PRERUNTASK(job_id, workerid)
+# define STARPU_AYU_RUNTASK(job_id)
+# define STARPU_AYU_POSTRUNTASK(job_id)
+# define STARPU_AYU_ADDTOTASKQUEUE(job_id, worker_id)
+# define STARPU_AYU_BARRIER()
+
 #endif
 
 /* Create a file that will contain StarPU's log */
@@ -41,8 +302,10 @@ void _starpu_print_to_logfile(const char *format, ...) STARPU_ATTRIBUTE_FORMAT(p
 /* Tell gdb whether FXT is compiled in or not */
 extern int _starpu_use_fxt;
 
+#if defined(STARPU_USE_AYUDAME1)
 /* Get an Ayudame id for CL */
 int64_t _starpu_ayudame_get_func_id(struct starpu_codelet *cl);
+#endif
 
 void _starpu_watchdog_init(void);
 void _starpu_watchdog_shutdown(void);

+ 3 - 10
src/core/dependencies/implicit_data_deps.c

@@ -2,6 +2,7 @@
  *
  * Copyright (C) 2010-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2013, 2015  CNRS
+ * Copyright (C) 2016  Inria
  *
  * 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
@@ -32,13 +33,7 @@ static void _starpu_add_ghost_dependency(starpu_data_handle_t handle STARPU_ATTR
 {
 	struct _starpu_job *next_job = _starpu_get_job_associated_to_task(next);
 	_starpu_bound_job_id_dep(handle, next_job, previous);
-#ifdef HAVE_AYUDAME_H
-	if (AYU_event)
-	{
-		uintptr_t AYU_data[3] = { previous, (uintptr_t) handle, (uintptr_t) handle };
-		AYU_event(AYU_ADDDEPENDENCY, next_job->job_id, AYU_data);
-	}
-#endif
+	STARPU_AYU_ADDDEPENDENCY(previous, handle, next_job->job_id);
 }
 
 static void _starpu_add_dependency(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUSED, struct starpu_task *previous STARPU_ATTRIBUTE_UNUSED, struct starpu_task *next STARPU_ATTRIBUTE_UNUSED)
@@ -81,9 +76,7 @@ static void _starpu_add_accessor(starpu_data_handle_t handle, struct starpu_task
 #else
 		_starpu_bound_recording
 #endif
-#ifdef HAVE_AYUDAME_H
-		|| AYU_event
-#endif
+		|| STARPU_AYU_EVENT
 		) && handle->last_submitted_ghost_sync_id_is_valid)
 	{
 		_STARPU_TRACE_GHOST_TASK_DEPS(handle->last_submitted_ghost_sync_id,

+ 22 - 45
src/core/dependencies/tags.c

@@ -2,6 +2,7 @@
  *
  * Copyright (C) 2009-2013  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013  CNRS
+ * Copyright (C) 2016  Inria
  *
  * 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
@@ -26,7 +27,11 @@
 #include <common/uthash.h>
 #include <core/debug.h>
 
-#define AYUDAME_OFFSET 4000000000000000000ULL
+#if defined(STARPU_USE_AYUDAME1) || defined(STARPU_USE_AYUDAME2)
+# define STARPU_AYUDAME_OFFSET 4000000000000000000ULL
+#else
+# define STARPU_AYUDAME_OFFSET 0
+#endif
 
 struct _starpu_tag_table
 {
@@ -139,11 +144,8 @@ void starpu_tag_remove(starpu_tag_t id)
 {
 	struct _starpu_tag_table *entry;
 
-#ifdef HAVE_AYUDAME_H
-	if (AYU_event)
-		AYU_event(AYU_REMOVETASK, id + AYUDAME_OFFSET, NULL);
-#endif
-
+	STARPU_ASSERT(STARPU_AYUDAME_OFFSET == 0 || id < STARPU_AYUDAME_OFFSET);
+	STARPU_AYU_REMOVETASK(id + STARPU_AYUDAME_OFFSET);
 	STARPU_PTHREAD_RWLOCK_WRLOCK(&tag_global_rwlock);
 
 	HASH_FIND_UINT64_T(tag_htbl, &id, entry);
@@ -200,14 +202,8 @@ static struct _starpu_tag *_gettag_struct(starpu_tag_t id)
 
 		HASH_ADD_UINT64_T(tag_htbl, id, entry2);
 
-#ifdef HAVE_AYUDAME_H
-		if (AYU_event)
-		{
-			int64_t AYU_data[2] = {0, 0};
-			STARPU_ASSERT(id < AYUDAME_OFFSET);
-			AYU_event(AYU_ADDTASK, id + AYUDAME_OFFSET, AYU_data);
-		}
-#endif
+		STARPU_ASSERT(STARPU_AYUDAME_OFFSET == 0 || id < STARPU_AYUDAME_OFFSET);
+		STARPU_AYU_ADDTASK(id + STARPU_AYUDAME_OFFSET, NULL);
 	}
 
 	return tag;
@@ -241,14 +237,9 @@ void _starpu_tag_set_ready(struct _starpu_tag *tag)
 	_starpu_enforce_deps_starting_from_task(j);
 
 	_starpu_spin_lock(&tag->lock);
-#ifdef HAVE_AYUDAME_H
-	if (AYU_event)
-	{
-		intptr_t id = 0;
-		AYU_event(AYU_PRERUNTASK, tag->id + AYUDAME_OFFSET, &id);
-		AYU_event(AYU_POSTRUNTASK, tag->id + AYUDAME_OFFSET, NULL);
-	}
-#endif
+	STARPU_ASSERT(STARPU_AYUDAME_OFFSET == 0 || tag->id < STARPU_AYUDAME_OFFSET);
+	STARPU_AYU_PRERUNTASK(tag->id + STARPU_AYUDAME_OFFSET, -1);
+	STARPU_AYU_POSTRUNTASK(tag->id + STARPU_AYUDAME_OFFSET);
 }
 
 /* the lock must be taken ! */
@@ -327,15 +318,9 @@ void _starpu_tag_declare(starpu_tag_t id, struct _starpu_job *job)
 	if (job->task->regenerate || job->submitted == 2 ||
 			tag->state != STARPU_DONE)
 		tag->state = STARPU_ASSOCIATED;
-#ifdef HAVE_AYUDAME_H
-	if (AYU_event)
-	{
-		uintptr_t AYU_data1[3] = {id+AYUDAME_OFFSET, 0, 0};
-		uintptr_t AYU_data2[3] = {job->job_id, 0, 0};
-		AYU_event(AYU_ADDDEPENDENCY, job->job_id, AYU_data1);
-		AYU_event(AYU_ADDDEPENDENCY, id+AYUDAME_OFFSET, AYU_data2);
-	}
-#endif
+	STARPU_ASSERT(STARPU_AYUDAME_OFFSET == 0 || id < STARPU_AYUDAME_OFFSET);
+	STARPU_AYU_ADDDEPENDENCY(id+STARPU_AYUDAME_OFFSET, 0, job->job_id);
+	STARPU_AYU_ADDDEPENDENCY(job->job_id, 0, id+STARPU_AYUDAME_OFFSET);
 	_starpu_spin_unlock(&tag->lock);
 }
 
@@ -366,13 +351,9 @@ void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t
 		_starpu_spin_lock(&tag_dep->lock);
 		_starpu_spin_lock(&tag_child->lock);
 		_starpu_tag_add_succ(tag_dep, cg);
-#ifdef HAVE_AYUDAME_H
-		if (AYU_event)
-		{
-			uintptr_t AYU_data[3] = {dep_id+AYUDAME_OFFSET, 0, 0};
-			AYU_event(AYU_ADDDEPENDENCY, id+AYUDAME_OFFSET, AYU_data);
-		}
-#endif
+		STARPU_ASSERT(STARPU_AYUDAME_OFFSET == 0 || dep_id < STARPU_AYUDAME_OFFSET);
+		STARPU_ASSERT(STARPU_AYUDAME_OFFSET == 0 || id < STARPU_AYUDAME_OFFSET);
+		STARPU_AYU_ADDDEPENDENCY(dep_id+STARPU_AYUDAME_OFFSET, 0, id+STARPU_AYUDAME_OFFSET);
 		_starpu_spin_unlock(&tag_child->lock);
 		_starpu_spin_unlock(&tag_dep->lock);
 	}
@@ -408,13 +389,9 @@ void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...)
 		_starpu_spin_lock(&tag_dep->lock);
 		_starpu_spin_lock(&tag_child->lock);
 		_starpu_tag_add_succ(tag_dep, cg);
-#ifdef HAVE_AYUDAME_H
-		if (AYU_event)
-		{
-			uintptr_t AYU_data[3] = {dep_id+AYUDAME_OFFSET, 0, 0};
-			AYU_event(AYU_ADDDEPENDENCY, id+AYUDAME_OFFSET, AYU_data);
-		}
-#endif
+		STARPU_ASSERT(STARPU_AYUDAME_OFFSET == 0 || dep_id < STARPU_AYUDAME_OFFSET);
+		STARPU_ASSERT(STARPU_AYUDAME_OFFSET == 0 || id < STARPU_AYUDAME_OFFSET);
+		STARPU_AYU_ADDDEPENDENCY(dep_id+STARPU_AYUDAME_OFFSET, 0, id+STARPU_AYUDAME_OFFSET);
 		_starpu_spin_unlock(&tag_child->lock);
 		_starpu_spin_unlock(&tag_dep->lock);
 	}

+ 3 - 6
src/core/dependencies/task_deps.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2010-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2015  CNRS
- * Copyright (C) 2014  INRIA
+ * Copyright (C) 2014, 2016  INRIA
  *
  * 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
@@ -112,13 +112,10 @@ void _starpu_task_declare_deps_array(struct starpu_task *task, unsigned ndeps, s
 
 		_STARPU_TRACE_TASK_DEPS(dep_job, job);
 		_starpu_bound_task_dep(job, dep_job);
-#ifdef HAVE_AYUDAME_H
-		if (AYU_event && check)
+		if (check)
 		{
-			uintptr_t AYU_data[3] = {dep_job->job_id, 0, 0};
-			AYU_event(AYU_ADDDEPENDENCY, job->job_id, AYU_data);
+			STARPU_AYU_ADDDEPENDENCY(dep_job->job_id, 0, job->job_id);
 		}
-#endif
 		if (_starpu_graph_record)
 			_starpu_graph_add_job_dep(job, dep_job);
 

+ 5 - 26
src/core/jobs.c

@@ -3,7 +3,7 @@
  * Copyright (C) 2009-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
  * Copyright (C) 2011  Télécom-SudParis
- * Copyright (C) 2011, 2014  INRIA
+ * Copyright (C) 2011, 2014, 2016  INRIA
  *
  * 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
@@ -89,21 +89,11 @@ struct _starpu_job* STARPU_ATTRIBUTE_MALLOC _starpu_job_create(struct starpu_tas
 #ifndef STARPU_USE_FXT
 	if (_starpu_bound_recording || _starpu_top_status_get() ||
 		_starpu_task_break_on_push != -1 || _starpu_task_break_on_pop != -1 || _starpu_task_break_on_sched != -1
-#ifdef HAVE_AYUDAME_H
-		|| AYU_event
-#endif
-			)
+		|| STARPU_AYU_EVENT)
 #endif
 	{
 		job->job_id = STARPU_ATOMIC_ADDL(&job_cnt, 1);
-#ifdef HAVE_AYUDAME_H
-		if (AYU_event)
-		{
-			/* Declare task to Ayudame */
-			int64_t AYU_data[2] = {_starpu_ayudame_get_func_id(task->cl), task->priority > STARPU_MIN_PRIO};
-			AYU_event(AYU_ADDTASK, job->job_id, AYU_data);
-		}
-#endif
+		STARPU_AYU_ADDTASK(job->job_id, task);
 	}
 	if (max_memory_use)
 	{
@@ -468,11 +458,7 @@ void _starpu_handle_job_termination(struct _starpu_job *j)
 		j->terminated = 2;
 	}
 	STARPU_PTHREAD_COND_BROADCAST(&j->sync_cond);
-
-#ifdef HAVE_AYUDAME_H
-	if (AYU_event) AYU_event(AYU_REMOVETASK, j->job_id, NULL);
-#endif
-
+	STARPU_AYU_REMOVETASK(j->job_id);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&j->sync_mutex);
 
 	if (detach && !continuation)
@@ -491,14 +477,7 @@ void _starpu_handle_job_termination(struct _starpu_job *j)
 		STARPU_ASSERT_MSG((detach && !destroy && !task->synchronous)
 				|| continuation
 				, "Regenerated task must be detached (was %d), and not have detroy=1 (was %d) or synchronous=1 (was %d)", detach, destroy, task->synchronous);
-
-#ifdef HAVE_AYUDAME_H
-		if (AYU_event)
-		{
-			int64_t AYU_data[2] = {j->exclude_from_dag?0:_starpu_ayudame_get_func_id(task->cl), task->priority > STARPU_MIN_PRIO};
-			AYU_event(AYU_ADDTASK, j->job_id, AYU_data);
-		}
-#endif
+		STARPU_AYU_ADDTASK(j->job_id, j->exclude_from_dag?NULL:task);
 
 		{
 #ifdef STARPU_OPENMP

+ 2 - 9
src/core/sched_policy.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2010-2016  Université de Bordeaux
  * Copyright (C) 2010-2015  CNRS
- * Copyright (C) 2011  INRIA
+ * Copyright (C) 2011, 2016  INRIA
  *
  * 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
@@ -413,14 +413,7 @@ int _starpu_repush_task(struct _starpu_job *j)
 
 	unsigned can_push = _starpu_increment_nready_tasks_of_sched_ctx(task->sched_ctx, task->flops, task);
 	task->status = STARPU_TASK_READY;
-
-#ifdef HAVE_AYUDAME_H
-	if (AYU_event)
-	{
-		intptr_t id = -1;
-		AYU_event(AYU_ADDTASKTOQUEUE, j->job_id, &id);
-	}
-#endif
+	STARPU_AYU_ADDTOTASKQUEUE(j->job_id, -1);
 	/* if the context does not have any workers save the tasks in a temp list */
 	if(!sched_ctx->is_initial_sched)
 	{

+ 3 - 8
src/core/task.c

@@ -3,7 +3,7 @@
  * Copyright (C) 2009-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
  * Copyright (C) 2011  Télécom-SudParis
- * Copyright (C) 2011, 2014  INRIA
+ * Copyright (C) 2011, 2014, 2016  INRIA
  *
  * 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
@@ -832,10 +832,7 @@ int _starpu_task_wait_for_all_and_return_nb_waited_tasks(void)
 	{
 		_STARPU_DEBUG("Waiting for all tasks\n");
 		STARPU_ASSERT_MSG(_starpu_worker_may_perform_blocking_calls(), "starpu_task_wait_for_all must not be called from a task or callback");
-
-#ifdef HAVE_AYUDAME_H
-		if (AYU_event) AYU_event(AYU_BARRIER, 0, NULL);
-#endif
+		STARPU_AYU_BARRIER();
 		struct _starpu_machine_config *config = (struct _starpu_machine_config *)_starpu_get_machine_config();
 		if(config->topology.nsched_ctxs == 1)
 		{
@@ -881,10 +878,8 @@ int _starpu_task_wait_for_all_in_ctx_and_return_nb_waited_tasks(unsigned sched_c
 	_STARPU_TRACE_TASK_WAIT_FOR_ALL_START();
 	int ret = _starpu_wait_for_all_tasks_of_sched_ctx(sched_ctx);
 	_STARPU_TRACE_TASK_WAIT_FOR_ALL_END();
-#ifdef HAVE_AYUDAME_H
 	/* TODO: improve Temanejo into knowing about contexts ... */
-	if (AYU_event) AYU_event(AYU_BARRIER, 0, NULL);
-#endif
+	STARPU_AYU_BARRIER();
 	return ret;
 }
 

+ 4 - 19
src/core/workers.c

@@ -4,7 +4,7 @@
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
  * Copyright (C) 2010, 2011  INRIA
  * Copyright (C) 2011  Télécom-SudParis
- * Copyright (C) 2011-2012  INRIA
+ * Copyright (C) 2011-2012, 2016  INRIA
  *
  * 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
@@ -626,10 +626,7 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
 	/* Get itimer of the main thread, to set it for the worker threads */
 	getitimer(ITIMER_PROF, &prof_itimer);
 #endif
-
-#ifdef HAVE_AYUDAME_H
-	if (AYU_event) AYU_event(AYU_INIT, 0, NULL);
-#endif
+	STARPU_AYU_INIT();
 
 	for (worker = 0; worker < nworkers; worker++)
 	{
@@ -1146,16 +1143,7 @@ int starpu_initialize(struct starpu_conf *user_conf, int *argc, char ***argv)
 
 	srand(2008);
 
-#ifdef HAVE_AYUDAME_H
-#ifndef AYU_RT_STARPU
-#define AYU_RT_STARPU 4
-#endif
-	if (AYU_event)
-	{
-		enum ayu_runtime_t ayu_rt = AYU_RT_STARPU;
-		AYU_event(AYU_PREINIT, 0, (void*) &ayu_rt);
-	}
-#endif
+	STARPU_AYU_PREINIT();
 	/* store the pointer to the user explicit configuration during the
 	 * initialization */
 	if (user_conf == NULL)
@@ -1565,10 +1553,7 @@ void starpu_shutdown(void)
 		free(_starpu_config.conf.cuda_opengl_interoperability);
 	if (_starpu_config.conf.n_not_launched_drivers)
 		free(_starpu_config.conf.not_launched_drivers);
-
-#ifdef HAVE_AYUDAME_H
-	if (AYU_event) AYU_event(AYU_FINISH, 0, NULL);
-#endif
+	STARPU_AYU_FINISH();
 
 #ifdef STARPU_USE_SCC
 	if (_starpu_scc_common_is_mp_initialized())

+ 5 - 21
src/drivers/driver_common/driver_common.c

@@ -3,7 +3,7 @@
  * Copyright (C) 2010-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
  * Copyright (C) 2011  Télécom-SudParis
- * Copyright (C) 2014  INRIA
+ * Copyright (C) 2014, 2016  INRIA
  *
  * 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
@@ -57,9 +57,7 @@ void _starpu_driver_start_job(struct _starpu_worker *worker, struct _starpu_job
 
 	if (rank == 0)
 	{
-#ifdef HAVE_AYUDAME_H
-		if (AYU_event) AYU_event(AYU_RUNTASK, j->job_id, NULL);
-#endif
+		STARPU_AYU_RUNTASK(j->job_id);
 		cl->per_worker_stats[workerid]++;
 
 		profiling_info = task->profiling_info;
@@ -141,9 +139,7 @@ void _starpu_driver_end_job(struct _starpu_worker *worker, struct _starpu_job *j
 			_starpu_clock_gettime(codelet_end);
 			_starpu_worker_register_executing_end(workerid);
 		}
-#ifdef HAVE_AYUDAME_H
-		if (AYU_event) AYU_event(AYU_POSTRUNTASK, j->job_id, NULL);
-#endif
+		STARPU_AYU_POSTRUNTASK(j->job_id);
 	}
 
 	if (starpu_top)
@@ -470,13 +466,7 @@ struct starpu_task *_starpu_get_worker_task(struct _starpu_worker *worker, int w
 	STARPU_PTHREAD_MUTEX_UNLOCK_SCHED(&worker->sched_mutex);
 
 
-#ifdef HAVE_AYUDAME_H
-	if (AYU_event)
-	{
-		intptr_t id = workerid;
-		AYU_event(AYU_PRERUNTASK, _starpu_get_job_associated_to_task(task)->job_id, &id);
-	}
-#endif
+	STARPU_AYU_PRERUNTASK(_starpu_get_job_associated_to_task(task)->job_id, workerid);
 
 	return task;
 }
@@ -559,13 +549,7 @@ int _starpu_get_multi_worker_task(struct _starpu_worker *workers, struct starpu_
 					workers[i].worker_size = 1;
 					workers[i].current_rank = 0;
 				}
-#ifdef HAVE_AYUDAME_H
-				if (AYU_event)
-				{
-					intptr_t id = workers[i].workerid;
-					AYU_event(AYU_PRERUNTASK, _starpu_get_job_associated_to_task(tasks[i])->job_id, &id);
-				}
-#endif
+				STARPU_AYU_PRERUNTASK(_starpu_get_job_associated_to_task(tasks[i])->job_id, workers[i].workerid);
 			}
 			else
 			{

+ 3 - 11
src/sched_policies/deque_modeling_policy_data_aware.c

@@ -3,7 +3,7 @@
  * Copyright (C) 2010-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016  CNRS
  * Copyright (C) 2011  Télécom-SudParis
- * Copyright (C) 2011-2012  INRIA
+ * Copyright (C) 2011-2012, 2016  INRIA
  *
  * 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
@@ -26,13 +26,11 @@
 #include <core/task.h>
 #include <core/workers.h>
 #include <core/sched_policy.h>
+#include <core/debug.h>
 
 #include <sched_policies/fifo_queues.h>
 #include <limits.h>
 
-#ifdef HAVE_AYUDAME_H
-#include <Ayudame.h>
-#endif
 
 #ifndef DBL_MIN
 #define DBL_MIN __DBL_MIN__
@@ -413,13 +411,7 @@ static int push_task_on_best_worker(struct starpu_task *task, int best_workerid,
 		starpu_prefetch_task_input_on_node(task, memory_node);
 	}
 
-#ifdef HAVE_AYUDAME_H
-	if (AYU_event)
-	{
-		intptr_t id = best_workerid;
-		AYU_event(AYU_ADDTASKTOQUEUE, _starpu_get_job_associated_to_task(task)->job_id, &id);
-	}
-#endif
+	STARPU_AYU_ADDTOTASKQUEUE(_starpu_get_job_associated_to_task(task)->job_id, best_workerid);
 	int ret = 0;
 	if (prio)
 	{

+ 2 - 4
src/sched_policies/heteroprio.c

@@ -24,14 +24,11 @@
 #include <common/fxt.h>
 #include <core/task.h>
 #include <core/workers.h>
+#include <core/debug.h>
 
 #include <sched_policies/fifo_queues.h>
 #include <limits.h>
 
-#ifdef HAVE_AYUDAME_H
-#include <Ayudame.h>
-#endif
-
 #ifndef DBL_MIN
 #define DBL_MIN __DBL_MIN__
 #endif
@@ -486,6 +483,7 @@ static struct starpu_task *pop_task_heteroprio_policy(unsigned sched_ctx_id)
 				struct starpu_task* task = _starpu_fifo_pop_local_task(bucket->tasks_queue);
 				STARPU_ASSERT(starpu_worker_can_execute_task(workerid, task, 0));
 				/* Save the task */
+				STARPU_AYU_ADDTOTASKQUEUE(_starpu_get_job_associated_to_task(task)->job_id, workerid);
 				_starpu_fifo_push_task(worker->tasks_queue, task);
 
 				/* Update general counter */

+ 3 - 13
src/sched_policies/random_policy.c

@@ -2,6 +2,7 @@
  *
  * Copyright (C) 2010-2014, 2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2016  CNRS
+ * Copyright (C) 2016  Inria
  *
  * 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,9 +23,7 @@
 #include <core/sched_ctx.h>
 #include <core/sched_policy.h>
 #include <sched_policies/fifo_queues.h>
-#ifdef HAVE_AYUDAME_H
-#include <Ayudame.h>
-#endif
+#include <core/debug.h>
 
 static int _random_push_task(struct starpu_task *task, unsigned prio)
 {
@@ -80,16 +79,7 @@ static int _random_push_task(struct starpu_task *task, unsigned prio)
 		
 		alpha += worker_alpha;
 	}
-
-
-#ifdef HAVE_AYUDAME_H
-	if (AYU_event)
-	{
-		intptr_t id = selected;
-		AYU_event(AYU_ADDTASKTOQUEUE, _starpu_get_job_associated_to_task(task)->job_id, &id);
-	}
-#endif
-
+	STARPU_AYU_ADDTOTASKQUEUE(_starpu_get_job_associated_to_task(task)->job_id, selected);
 	_STARPU_TASK_BREAK_ON(task, sched);
 	return starpu_push_local_task(selected, task, prio);
 }

+ 3 - 14
src/sched_policies/work_stealing_policy.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2010-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
- * Copyright (C) 2011, 2012  INRIA
+ * Copyright (C) 2011, 2012, 2016  INRIA
  *
  * 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
@@ -25,10 +25,7 @@
 #include <core/debug.h>
 #include <starpu_scheduler.h>
 #include <core/sched_policy.h>
-
-#ifdef HAVE_AYUDAME_H
-#include <Ayudame.h>
-#endif
+#include <core/debug.h>
 
 /* Experimental (dead) code which needs to be tested, fixed... */
 /* #define USE_OVERLOAD */
@@ -603,15 +600,7 @@ int ws_push_task(struct starpu_task *task)
 	starpu_pthread_cond_t *sched_cond;
 	starpu_worker_get_sched_condition(workerid, &sched_mutex, &sched_cond);
 	STARPU_PTHREAD_MUTEX_LOCK_SCHED(sched_mutex);
-#ifdef HAVE_AYUDAME_H
-	struct _starpu_job *j = _starpu_get_job_associated_to_task(task);
-	if (AYU_event)
-	{
-		intptr_t id = workerid;
-		AYU_event(AYU_ADDTASKTOQUEUE, j->job_id, &id);
-	}
-#endif
-
+	STARPU_AYU_ADDTOTASKQUEUE(_starpu_get_job_associated_to_task(task)->job_id, workerid);
 	STARPU_PTHREAD_MUTEX_LOCK(&ws->per_worker[workerid].worker_mutex);
 	_STARPU_TASK_BREAK_ON(task, sched);
 	record_data_locality(task, workerid);

+ 8 - 0
tools/Makefile.am

@@ -2,6 +2,7 @@
 #
 # Copyright (C) 2009-2016  Université de Bordeaux
 # Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
+# Copyright (C) 2016  Inria
 #
 # 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
@@ -248,6 +249,13 @@ dist_bin_SCRIPTS +=			\
 	starpu_paje_state_stats		\
 	starpu_trace_state_stats.py
 
+if STARPU_USE_AYUDAME2
+dist_bin_SCRIPTS +=			\
+	starpu_temanejo2.sh
+dist_pkgdata_DATA +=			\
+	ayudame.cfg
+endif
+
 if STARPU_HAVE_WINDOWS
 STARPU_MSVC_dir		 =	$(bindir)
 nobase_STARPU_MSVC__DATA =		\

+ 22 - 0
tools/ayudame.cfg

@@ -0,0 +1,22 @@
+# default configuration file for Ayudame2
+
+connect {
+    stdout_human = "true";
+    stdout_raw   = "false";
+    temanejo1    = "false";
+    temanejo     = "true";
+    dot          = "false";
+    dot_filename = "ayudame.dot";
+    xml          = "true";
+    xml_filename = "ayudame.xml";
+    ayu_port     = "8888";
+    ayu_host     = "localhost";
+}
+
+logging {
+    error           = "true";
+    warning         = "true";
+    info            = "true";
+    verbosity_level = "3";
+    debug           = "true";
+}

+ 27 - 0
tools/starpu_temanejo2.sh

@@ -0,0 +1,27 @@
+#!/bin/bash
+# StarPU --- Runtime system for heterogeneous multicore architectures.
+#
+# Copyright (C) 2016  Inria
+#
+# 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.
+#
+d=${AYUDAME2_INSTALL_DIR?}
+cmd=${1?"usage: $0 <cmd> [args*]"}
+shift
+if test ! -r ayudame.cfg; then
+	echo "warning: no 'ayudame.cfg' file found in current working directory, an example is available in <STARPU_INSTALL_DIR>/share/starpu/ayudame.cfg"
+fi
+PATH=$d/bin:$PATH
+LD_LIBRARY_PATH=$d/lib:$LD_LIBRARY_PATH
+PYTHONPATH=$d/lib/python2.7/site-packages:$PYTHONPATH
+export PATH LD_LIBRARY_PATH PYTHONPATH
+$d/bin/Temanejo2 -p 8888 -d 8889 -P $d/lib/libayudame.so -L $d/lib -A $cmd "$@"