Преглед изворни кода

Add basic Temanejo support

Samuel Thibault пре 12 година
родитељ
комит
fe68b52593

+ 3 - 0
configure.ac

@@ -955,6 +955,8 @@ fi
 AC_CHECK_HEADERS([glpk.h])
 STARPU_HAVE_LIBRARY(GLPK, [glpk])
 
+AC_CHECK_HEADERS([Ayudame.h])
+
 ###############################################################################
 #                                                                             #
 #                  Miscellaneous options for StarPU                           #
@@ -1824,6 +1826,7 @@ AC_MSG_NOTICE([
 	       SOCL enabled:                                $build_socl
                SOCL test suite:                             $run_socl_check
                simgrid enabled:                             $enable_simgrid
+               ayudame enabled:                             $ac_cv_header_Ayudame_h
 ])
 
 if test "$build_socl" = "yes" -a "$run_socl_check" = "no" ; then

+ 2 - 0
doc/chapters/advanced-examples.texi

@@ -965,6 +965,8 @@ gdb helpers are also provided to show the whole StarPU state:
 (gdb) help starpu
 @end smallexample
 
+The Temanejo task debugger can also be used, see @ref{Task debugger}.
+
 @node The multiformat interface
 @section The multiformat interface
 It may be interesting to represent the same piece of data using two different

+ 16 - 0
doc/chapters/perf-feedback.texi

@@ -7,6 +7,7 @@
 @c See the file starpu.texi for copying conditions.
 
 @menu
+* Task debugger::               Using the Temanejo task debugger
 * On-line::                     On-line performance feedback
 * Off-line::                    Off-line performance feedback
 * Codelet performance::         Performance of codelets
@@ -15,6 +16,21 @@
 * Data statistics::        
 @end menu
 
+@node Task debugger
+@section Using the Temanejo task debugger
+
+StarPU can connect to Temanejo (see
+@url{http://www.hlrs.de/organization/av/spmt/research/temanejo/}), to permit
+nice visual task debugging. To do so, build Temanejo's @code{libayudame.so},
+install @code{Ayudame} to e.g. @code{/usr/local/include}, apply the
+@code{tools/patch-ayudame} to it to fix C build, re-@code{./configure}, make
+sure that it found it, rebuild StarPU.  Run the Temanejo GUI, give it the path
+to your application, any options you want to pass it, the path to libayudame.so.
+
+The number of CPUs currently can not be set.
+
+Only dependencies detected implicitly are currently shown.
+
 @node On-line
 @section On-line performance feedback
 

+ 3 - 0
doc/chapters/perf-optimization.texi

@@ -424,6 +424,9 @@ detailed in the next chapter. The various informations should be checked for.
 @end itemize
 @end itemize
 
+You can also use the Temanejo task debugger (see @ref{Task debugger}) to
+visualize the task graph more easily.
+
 @node Simulated performance
 @section Simulated performance
 

+ 5 - 1
src/core/debug.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2011  Université de Bordeaux 1
+ * Copyright (C) 2009-2012  Université de Bordeaux 1
  * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -25,6 +25,10 @@
 #include <common/config.h>
 #include <core/workers.h>
 
+#ifdef HAVE_AYUDAME_H
+#include <Ayudame.h>
+#endif
+
 /* Create a file that will contain StarPU's log */
 void _starpu_open_debug_logfile(void);
 

+ 41 - 4
src/core/dependencies/implicit_data_deps.c

@@ -20,6 +20,7 @@
 #include <core/task.h>
 #include <datawizard/datawizard.h>
 #include <profiling/bound.h>
+#include <core/debug.h>
 
 #if 0
 # define _STARPU_DEP_DEBUG(fmt, args ...) fprintf(stderr, fmt, ##args);
@@ -27,6 +28,24 @@
 # define _STARPU_DEP_DEBUG(fmt, args ...)
 #endif
 
+static void _starpu_add_ayudame_ghost_dependency(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUSED, unsigned long previous STARPU_ATTRIBUTE_UNUSED, struct starpu_task *next STARPU_ATTRIBUTE_UNUSED)
+{
+#ifdef HAVE_AYUDAME_H
+	if (AYU_event) {
+		int64_t AYU_data[3] = { previous, (int64_t) handle, (int64_t) handle };
+		AYU_event(AYU_ADDDEPENDENCY, _starpu_get_job_associated_to_task(next)->job_id, AYU_data);
+	}
+#endif
+}
+
+static void _starpu_add_ayudame_dependency(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUSED, struct starpu_task *previous STARPU_ATTRIBUTE_UNUSED, struct starpu_task *next STARPU_ATTRIBUTE_UNUSED)
+{
+#ifdef HAVE_AYUDAME_H
+	if (AYU_event)
+		_starpu_add_ayudame_ghost_dependency(handle, _starpu_get_job_associated_to_task(previous)->job_id, next);
+#endif
+}
+
 /* Read after Write (RAW) or Read after Read (RAR) */
 static void _starpu_add_reader_after_writer(starpu_data_handle_t handle, struct starpu_task *pre_sync_task, struct starpu_task *post_sync_task)
 {
@@ -41,8 +60,9 @@ static void _starpu_add_reader_after_writer(starpu_data_handle_t handle, struct
 	{
 		_STARPU_DEP_DEBUG("RAW %p\n", handle);
 		struct starpu_task *task_array[1] = {handle->last_submitted_writer};
-		_STARPU_DEP_DEBUG("dep %p -> %p\n", handle->last_submitted_writer, pre_sync_task);
 		_starpu_task_declare_deps_array(pre_sync_task, 1, task_array, 0);
+		_starpu_add_ayudame_dependency(handle, handle->last_submitted_writer, pre_sync_task);
+		_STARPU_DEP_DEBUG("dep %p -> %p\n", handle->last_submitted_writer, pre_sync_task);
 	}
         else
         {
@@ -53,14 +73,21 @@ static void _starpu_add_reader_after_writer(starpu_data_handle_t handle, struct
 	 * ghost one, we should report that here, and keep the
 	 * ghost writer valid */
 	if (
-#ifndef STARPU_USE_FXT
-		_starpu_bound_recording &&
+		(
+#ifdef STARPU_USE_FXT
+		1
+#else
+		_starpu_bound_recording
+#endif
+#ifdef HAVE_AYUDAME_H
+		|| AYU_event
 #endif
-		handle->last_submitted_ghost_writer_id_is_valid)
+		) && handle->last_submitted_ghost_writer_id_is_valid)
 	{
 		struct _starpu_job *pre_sync_job = _starpu_get_job_associated_to_task(pre_sync_task);
 		_STARPU_TRACE_GHOST_TASK_DEPS(handle->last_submitted_ghost_writer_id, pre_sync_job->job_id);
 		_starpu_bound_job_id_dep(pre_sync_job, handle->last_submitted_ghost_writer_id);
+		_starpu_add_ayudame_ghost_dependency(handle, handle->last_submitted_ghost_writer_id, pre_sync_task);
 		_STARPU_DEP_DEBUG("dep ID%lu -> %p\n", handle->last_submitted_ghost_writer_id, pre_sync_task);
 	}
 
@@ -94,6 +121,7 @@ static void _starpu_add_writer_after_readers(starpu_data_handle_t handle, struct
 			STARPU_ASSERT(l->task);
 			if (l->task != post_sync_task) {
 				task_array[i++] = l->task;
+				_starpu_add_ayudame_dependency(handle, l->task, pre_sync_task);
 				_STARPU_DEP_DEBUG("dep %p -> %p\n", l->task, pre_sync_task);
 			}
 
@@ -116,6 +144,7 @@ static void _starpu_add_writer_after_readers(starpu_data_handle_t handle, struct
 			unsigned long id = ghost_readers_id->id;
 			_STARPU_TRACE_GHOST_TASK_DEPS(id, pre_sync_job->job_id);
 			_starpu_bound_job_id_dep(pre_sync_job, id);
+			_starpu_add_ayudame_ghost_dependency(handle, id, pre_sync_task);
 			_STARPU_DEP_DEBUG("dep ID%lu -> %p\n", id, pre_sync_task);
 
 			struct _starpu_jobid_list *prev = ghost_readers_id;
@@ -141,6 +170,13 @@ static void _starpu_add_writer_after_writer(starpu_data_handle_t handle, struct
 	{
 		struct starpu_task *task_array[1] = {handle->last_submitted_writer};
 		_starpu_task_declare_deps_array(pre_sync_task, 1, task_array, 0);
+#ifdef HAVE_AYUDAME_H
+		if (AYU_event) {
+			int64_t AYU_data[3] = { _starpu_get_job_associated_to_task(handle->last_submitted_writer)->job_id, (int64_t) handle, (int64_t) handle };
+			AYU_event(AYU_ADDDEPENDENCY, _starpu_get_job_associated_to_task(pre_sync_task)->job_id, AYU_data);
+		}
+#endif
+		_starpu_add_ayudame_dependency(handle, handle->last_submitted_writer, pre_sync_task);
 		_STARPU_DEP_DEBUG("dep %p -> %p\n", handle->last_submitted_writer, pre_sync_task);
 	}
         else
@@ -160,6 +196,7 @@ static void _starpu_add_writer_after_writer(starpu_data_handle_t handle, struct
 			struct _starpu_job *pre_sync_job = _starpu_get_job_associated_to_task(pre_sync_task);
 			_STARPU_TRACE_GHOST_TASK_DEPS(handle->last_submitted_ghost_writer_id, pre_sync_job->job_id);
 			_starpu_bound_job_id_dep(pre_sync_job, handle->last_submitted_ghost_writer_id);
+			_starpu_add_ayudame_ghost_dependency(handle, handle->last_submitted_ghost_writer_id, pre_sync_task);
 			_STARPU_DEP_DEBUG("dep ID%lu -> %p\n", handle->last_submitted_ghost_writer_id, pre_sync_task);
 			handle->last_submitted_ghost_writer_id_is_valid = 0;
 		}

+ 6 - 1
src/core/jobs.c

@@ -27,6 +27,7 @@
 #include <profiling/bound.h>
 #include <starpu_top.h>
 #include <top/starpu_top_core.h>
+#include <core/debug.h>
 
 /* we need to identify each task to generate the DAG. */
 static unsigned job_cnt = 0;
@@ -53,7 +54,11 @@ struct _starpu_job* __attribute__((malloc)) _starpu_job_create(struct starpu_tas
 	job->task = task;
 
 #ifndef STARPU_USE_FXT
-	if (_starpu_bound_recording || _starpu_top_status_get())
+	if (_starpu_bound_recording || _starpu_top_status_get()
+#ifdef HAVE_AYUDAME_H
+		|| AYU_event
+#endif
+			)
 #endif
 		job->job_id = STARPU_ATOMIC_ADD(&job_cnt, 1);
 

+ 15 - 5
src/core/task.c

@@ -28,6 +28,7 @@
 #include <profiling/bound.h>
 #include <math.h>
 #include <string.h>
+#include <core/debug.h>
 
 /* XXX this should be reinitialized when StarPU is shutdown (or we should make
  * sure that no task remains !) */
@@ -367,6 +368,20 @@ int starpu_task_submit(struct starpu_task *task)
 	_starpu_task_check_deprecated_fields(task);
 	_starpu_codelet_check_deprecated_fields(task->cl);
 
+	/* internally, StarPU manipulates a struct _starpu_job * which is a wrapper around a
+	* task structure, it is possible that this job structure was already
+	* allocated. */
+	struct _starpu_job *j = _starpu_get_job_associated_to_task(task);
+
+#ifdef HAVE_AYUDAME_H
+	if (AYU_event) {
+#warning TODO: function id
+		int64_t AYU_data[2] = {0, task->priority > STARPU_MIN_PRIO};
+
+		AYU_event(AYU_ADDTASK, j->job_id, AYU_data);
+	}
+#endif
+
 	if (task->cl)
 	{
 		unsigned i;
@@ -448,11 +463,6 @@ int starpu_task_submit(struct starpu_task *task)
 	if (profiling)
 		_starpu_clock_gettime(&info->submit_time);
 
-	/* internally, StarPU manipulates a struct _starpu_job * which is a wrapper around a
-	* task structure, it is possible that this job structure was already
-	* allocated, for instance to enforce task depenencies. */
-	struct _starpu_job *j = _starpu_get_job_associated_to_task(task);
-
 	ret = _starpu_submit_job(j);
 
 	if (is_sync)

+ 11 - 0
src/core/workers.c

@@ -703,6 +703,17 @@ int starpu_init(struct starpu_conf *user_conf)
 
 	srand(2008);
 
+#ifdef HAVE_AYUDAME_H
+#ifndef AYU_RT_STARPU
+/* Dumb value for now */
+#define AYU_RT_STARPU 32
+#endif
+	if (AYU_event) {
+		enum ayu_runtime_t ayu_rt = AYU_RT_STARPU;
+		AYU_event(AYU_PREINIT, 0, (void*) &ayu_rt);
+	}
+#endif
+
 	/* store the pointer to the user explicit configuration during the
 	 * initialization */
 	if (user_conf == NULL)

+ 48 - 0
tools/patch-ayudame

@@ -0,0 +1,48 @@
+--- Ayudame.h	2012-10-31 10:29:19.000000000 -0600
++++ Ayudame.h	2012-11-16 17:34:04.963495624 -0700
+@@ -14,6 +14,7 @@
+ 
+ #include <stdint.h>
+ #include <unistd.h>
++#include <stdbool.h>
+ 
+ //#define _REENTRANT // defined by default by gcc
+ 
+@@ -68,7 +69,7 @@
+ // ---
+ 
+ 
+-const size_t AYU_buf_size=8;       // size of message buffer
++#define AYU_buf_size ((size_t)8)       // size of message buffer
+ extern unsigned long AYU_n_threads;       // current number of threads
+ extern unsigned long AYU_max_threads;     // maximum number of threads
+ 
+@@ -202,7 +203,9 @@
+ };
+ /******/
+ 
++#ifdef __cplusplus
+ extern "C" {
++#endif
+ 
+   /****f* AYUDAME/AYU_event
+    *  NAME
+@@ -224,7 +227,7 @@
+    *    void
+    *  SOURCE
+    */
+-  void AYU_event(ayu_event_t event, const int64_t taskId, void *p)
++  void AYU_event(enum ayu_event_t event, const int64_t taskId, void *p)
+     __attribute__ ((weak));
+   /******/
+ 
+@@ -342,7 +345,9 @@
+   void AYU_registerTask(void*) __attribute__ ((weak));
+   /******/
+ 
++#ifdef __cplusplus
+ }
++#endif
+ 
+ #ifndef AYU_MASTER_TASKID
+ #define AYU_MASTER_TASKID 0